/// <summary> /// Prompt user to download the log file /// </summary> public void DownloadLog() { if (EmulationWarnings.CheckRequirement(EmulationWarnings.Requirement.VMConnected)) { EmulatorManager.FetchLogFile(); } }
public override void Update() { if (loadingPanel.activeSelf) { Text t = loadingPanel.transform.Find("Text").GetComponent <Text>(); if (!EmulatorManager.IsVMConnected()) { uploadFinished = true; uploadSuccess = false; } if (uploadFinished) { if (!uploadSuccess) { UserMessageManager.Dispatch("Failed to upload new user program", EmulationWarnings.WARNING_DURATION); } t.text = "Loading..."; loadingPanel.SetActive(false); uploadFinished = false; } else { if (Time.unscaledTime >= lastAdditionalDot + 0.75) { dotCount = (dotCount + 1) % 4; t.text = "Loading"; for (int i = 0; i < dotCount; i++) { t.text += "."; } lastAdditionalDot = Time.unscaledTime; } } } }
public MainWindow() { InitializeComponent(); emuMgr = EmulatorManager.Instance; romMgr = RomManager.Instance; romMgr.NewRomAdded += RomMgr_NewRomAdded; UpdateEmulatorList(); }
/// <summary> /// Empty stream buffer into UI /// </summary> public static void Update() { if (EmulatorManager.IsTryingToRunRobotCode() && !EmulatorManager.IsRobotCodeRestarting() && !printStreamOpen) // Start stream if needed { Task.Factory.StartNew(OpenPrintStream, TaskCreationOptions.LongRunning); } while (newPrintQueue.Count > 0) { AddLine(newPrintQueue.Dequeue()); } }
public CheatsPage() { this.InitializeComponent(); this.manager = EmulatorManager.Current; this.storage = StorageManager.Current; this.resources = new ResourceLoader(); this.validator = this.manager.Emulator.CheatValidator; this.messageService = new UWPMessageService(this.Dispatcher); this.cheatData = new ObservableCollection <CheatDataWrapper>(); this.cheatView.ItemsSource = this.cheatData; }
public void Update() { if (lastGameSpecificMessageFocused != gameSpecificMessage.isFocused) { InputControl.freeze = gameSpecificMessage.isFocused; lastGameSpecificMessageFocused = gameSpecificMessage.isFocused; } VMConnectionImage.sprite = EmulatorManager.IsVMConnected() ? StatusGood : StatusBad; robotCodeUploadedImage.sprite = EmulatorManager.IsFRCUserProgramPresent() ? StatusGood : StatusBad; robotCodeRunningImage.sprite = EmulatorManager.IsRunningRobotCode() ? StatusGood : StatusBad; robotCodeConnectedImage.sprite = EmulatorNetworkConnection.Instance.IsConnected() ? StatusGood : StatusBad; }
public async void RestartRobotCode() { if (EmulationWarnings.CheckRequirement(EmulationWarnings.Requirement.UserProgramPresent) && EmulationWarnings.CheckRequirement(EmulationWarnings.Requirement.UserProgramNotRestarting)) { bool success = await EmulatorManager.RestartRobotCode(); if (!success) { UserMessageManager.Dispatch("Failed to restart user program", EmulationWarnings.WARNING_DURATION); } } }
public ControllerOverlayPage() { this.InitializeComponent(); var app = (App.Current as App); this.resources = new ResourceLoader(); this.msgService = new UWPMessageService(this.Dispatcher); this.settings = app.Settings; this.keyDownHandler = new KeyEventHandler(handleKeyDown); this.pointerHandler = new PointerEventHandler(handlePointerPressed); this.pointerMoveHandler = new PointerEventHandler(handlePointerMoved); this.pointerReleaseHandler = new TypedEventHandler <CoreWindow, PointerEventArgs>(handlePointerReleased); this.paneOpenHandler = new CallbackDelegate(handlePaneOpening); this.manualSnapshotButton.DataContext = this.settings; this.customizeVPadButton.DataContext = this.settings; this.controllerScaleSlider.DataContext = this.settings; this.controllerOpacitySlider.DataContext = this.settings; this.controllerStyleCombobox.DataContext = this.settings; this.fpsPanel.DataContext = this.settings; if (app.MainPage == null) { app.MainPageCreated += (p) => { this.manager = EmulatorManager.Current; this.manager.MovedToForeground(); this.manager.Emulator.RenderComponent.FrameRateChanged += this.UpdateFPS; SetSaveSlotContext(this.manager); RegisterEvents(app); }; } else { this.manager = EmulatorManager.Current; this.manager.MovedToForeground(); this.manager.Emulator.RenderComponent.FrameRateChanged += this.UpdateFPS; RegisterEvents(app); } this.moveBarUp.Completed += MoveBarUp_Completed; this.moveBarDown.Completed += MoveBarDown_Completed; this.moveLayoutBarDown.Completed += MoveLayoutBarDown_Completed; this.moveLayoutBarUp.Completed += MoveLayoutBarUp_Completed; this.moveLayoutBarFurtherDown.Completed += MoveLayoutBarFurtherDown_Completed; this.moveLayoutBarHalfUp.Completed += MoveLayoutBarHalfUp_Completed; this.moveLayoutBarCompletelyUp.Completed += MoveLayoutBarCompletelyUp_Completed; this.moveLayoutBarCompletelyDown.Completed += MoveLayoutBarCompletelyDown_Completed; customizationPanel.DataContext = this; }
/// <summary> /// Метод для создания сетки и робота /// </summary> /// <param name="rowCount">количество строк</param> /// <param name="columnCount">количество столбцов</param> /// <param name="rowPoint">местоположение робота в строке</param> /// <param name="columnPoint">местоположение робота в столбце</param> public void CreateGrid(int rowCount, int columnCount, int rowPoint, int columnPoint) { _robot = new Robot { Row = rowPoint, Column = columnPoint }; _grid = new Grid { RowCount = rowCount, ColumnCount = columnCount, Cells = new Cell[rowCount, columnCount] }; var initCommand = new ViewGrid(_grid, _robot); _visibleGrid.Children.Clear(); _manager = new EmulatorManager(_visibleGrid, _grid.Cells, rowCount, columnCount); _visibleRobot = _robotInitializer.CreateRobot(Colors.Coral); _manager.AddRobot(_visibleRobot, rowPoint, columnPoint); }
public override void Start() { canvas = GameObject.Find("Canvas"); emulationToolbar = Auxiliary.FindObject(canvas, "EmulationToolbar"); loadingPanel = Auxiliary.FindObject(canvas, "LoadingPanel"); useEmulationButtonText = Auxiliary.FindObject(canvas, "UseEmulationButton").GetComponentInChildren <Text>(); useEmulationButtonImage = Auxiliary.FindObject(canvas, "UseEmulationImage").GetComponentInChildren <Image>(); try { EmulatorManager.programType = (UserProgram.Type)Enum.Parse(typeof(UserProgram.Type), PlayerPrefs.GetString("UserProgramType"), false); } catch (Exception) { } EmulatorManager.StartUpdatingStatus(); EmulationDriverStation.Instance.BeginTrackingVMConnectionStatus(); }
/// <summary> /// Begin reading robot print-outs into the string buffer /// </summary> private static void OpenPrintStream() { printStreamOpen = true; if (remoteReader == null) { remoteReader = EmulatorManager.CreateRobotOutputStream(); } while (remoteReader != null && EmulatorManager.IsTryingToRunRobotCode() && !EmulatorManager.IsRobotCodeRestarting() && EmulatorManager.IsRobotOutputStreamGood() && Instance && RobotIOPanel.Instance.enablePrints) { try { int r = remoteReader.Read(); if (r != -1) { char c = (char)r; if (c == '\n' && (newPrintBuffer.Length > MIN_LINE_BUFFER_LEN || timeoutTimer.ElapsedMilliseconds > TIMEOUT)) // Concatenate multiple short prints if in quick enough succession { timeoutTimer.Restart(); newPrintQueue.Enqueue(newPrintBuffer); newPrintBuffer = ""; } else { newPrintBuffer += c; } } } catch (Exception e) { Debug.Log(e.ToString()); break; } } if (remoteReader != null) { remoteReader.Dispose(); remoteReader = null; if (EmulatorManager.IsRobotOutputStreamGood()) { EmulatorManager.CloseRobotOutputStream(); } } printStreamOpen = false; }
/// <summary> /// Indicator for VM connection status /// </summary> private System.Collections.IEnumerator UpdateVMConnectionStatus() // TODO move to emulation toolbar { while (true) { if (EmulatorManager.IsVMConnected()) { VMConnectionStatusImage.sprite = EmulatorConnection; if (EmulatorNetworkConnection.Instance.IsConnected()) { VMConnectionStatusMessage.text = "Connected"; } else { VMConnectionStatusMessage.text = "Ready"; RobotDisabled(); } if (!EmulatorManager.IsRunningRobotCodeRunner() && !EmulatorManager.IsTryingToRunRobotCode() && !EmulatorManager.IsRobotCodeRestarting()) { EmulatorManager.RestartRobotCode(); } } else { if (!EmulatorManager.IsVMInstalled()) { VMConnectionStatusImage.sprite = EmulatorNotInstalled; VMConnectionStatusMessage.text = "Not Installed"; } else if (!EmulatorManager.IsVMRunning()) { VMConnectionStatusImage.sprite = StartEmulator; VMConnectionStatusMessage.text = "Start Emulator"; } else { VMConnectionStatusImage.sprite = EmulatorConnection; VMConnectionStatusMessage.text = "Starting"; } RobotDisabled(); } yield return(new WaitForSeconds(1.0f)); // s } }
public void ToggleRobotPrints() { bool newEnable = !enablePrints; // TODO warn and wait if last command didnt finish if (!enablePrints && newEnable && EmulatorManager.IsRobotOutputStreamGood()) // When trying to enable, wait until old connection closes { UserMessageManager.Dispatch("Waiting to close last readout connection", EmulationWarnings.WARNING_DURATION); } else { enablePrints = newEnable; enablePrintsButtonImage.sprite = enablePrints ? SelectedButtonImage : UnselectedButtonImage; if (enablePrints && !EmulatorManager.IsTryingToRunRobotCode()) { UserMessageManager.Dispatch("Readout enabled, waiting for robot program to start", EmulationWarnings.WARNING_DURATION); } } }
public void Update() { if (shouldBeActive) // Handle hiding the panel. Other UIs don't hide automatically, but this one is big and should. { if (InputControl.GetButtonDown(new KeyMapping("Hide Menu", KeyCode.H, Input.Enums.KeyModifier.Ctrl), true)) // TODO make global control { mainPanel.SetActive(!mainPanel.activeSelf); } } if (mainPanel.activeSelf) // Update rest of UI { bool anyFieldfocused = false; foreach (var group in robotIOGroups) { anyFieldfocused = anyFieldfocused || group.Update(); } if (anyFieldfocused != lastAnyFieldfocused) { InputControl.freeze = anyFieldfocused; // Prevent users inputting values from triggering controls lastAnyFieldfocused = anyFieldfocused; } if (miniCamera == null) { InitMiniCamera(); } UpdateMiniCamera(); Resize(); DynamicCamera.ControlEnabled = false; } else if (lastActive) { DynamicCamera.ControlEnabled = true; } if (enablePrints && EmulatorManager.IsTryingToRunRobotCode() && !EmulatorManager.IsRobotCodeRestarting()) // Update robot prints { RobotPrintManager.Update(); } lastActive = mainPanel.activeSelf; }
public async void LoadCode() { string[] selectedFiles = SFB.StandaloneFileBrowser.OpenFilePanel("Robot Code Executable", "C:\\", "", false); if (selectedFiles.Length != 1) { AnalyticsManager.GlobalInstance.LogEventAsync(AnalyticsLedger.EventCatagory.EmulationTab, AnalyticsLedger.EventAction.CodeType, "No Code", AnalyticsLedger.getMilliseconds().ToString()); } else { UserProgram userProgram = new UserProgram(selectedFiles[0]); if (userProgram.ProgramType == UserProgram.Type.INVALID) { UserMessageManager.Dispatch("Invalid user program type", EmulationWarnings.WARNING_DURATION); } else if (userProgram.Size > EmulatorManager.MAX_FILE_SIZE) { UserMessageManager.Dispatch(Math.Round((double)userProgram.Size / (1024 * 1024), 2) + " MB user program is too large (capacity is " + Math.Round((double)EmulatorManager.MAX_FILE_SIZE / (1024 * 1024), 2) + " MB)", EmulationWarnings.WARNING_DURATION); } else { if (userProgram.Size > EmulatorManager.WARNING_FILE_SIZE) { UserMessageManager.Dispatch("Uploading large, " + Math.Round((double)userProgram.Size / (1024 * 1024), 2) + " MB user program. Upload may take a while.", EmulationWarnings.WARNING_DURATION); } PlayerPrefs.SetString("UserProgramType", userProgram.ProgramType.ToString()); AnalyticsManager.GlobalInstance.LogEventAsync(AnalyticsLedger.EventCatagory.EmulationTab, AnalyticsLedger.EventAction.CodeType, userProgram.ProgramType.ToString(), AnalyticsLedger.getMilliseconds().ToString()); loadingPanel.SetActive(true); uploadSuccess = await EmulatorManager.SCPFileSender(userProgram); uploadFinished = true; } } }
public void OnVMConnectionStatusClicked() { if (EmulationWarnings.CheckRequirement((EmulationWarnings.Requirement.VMInstalled)) && !EmulatorManager.IsVMRunning() && !EmulatorManager.IsVMConnected()) { AnalyticsManager.GlobalInstance.LogEventAsync(AnalyticsLedger.EventCatagory.EmulationTab, AnalyticsLedger.EventAction.Clicked, "Emulation Start", AnalyticsLedger.getMilliseconds().ToString()); if (EmulatorManager.StartEmulator()) // If successful { EmulationDriverStation.Instance.SetActive(true); } else { UserMessageManager.Dispatch("Emulator failed to start.", EmulationWarnings.WARNING_DURATION); } } else if (EmulatorManager.IsVMRunning()) { EmulationDriverStation.Instance.SetKillEmulatorDialogActive(true); } }
public GameSearchViewModel(EmulatorManager emulatorManager) { mEmulatorManager = emulatorManager; mSearchInputCommand = new SearchInputCommand(this); mSearchDeleteCommand = new SearchDeleteCommand(this); mSearchClearCommand = new SearchClearCommand(this); mLaunchGameCommand = new LaunchGameCommand(); addRangeToGames(mEmulatorManager.games); searchInputs = new ObservableCollection<SearchInputObject>(); SearchInputObject obj; for (char c = 'A'; c <= 'Z'; ++c) { obj = new SearchInputObject(); obj.actualChar = c; obj.display = c.ToString(); obj.command = mSearchInputCommand; searchInputs.Add(obj); } obj = new SearchInputObject(); obj.display = "_"; obj.command = mSearchInputCommand; obj.actualChar = ' '; searchInputs.Add(obj); obj = new SearchInputObject(); obj.display = "<"; obj.command = mSearchDeleteCommand; searchInputs.Add(obj); obj = new SearchInputObject(); obj.display = "Clear"; obj.command = mSearchClearCommand; searchInputs.Add(obj); }
public CustomCommand() { emuMgr = EmulatorManager.Instance; }
public GameSearch(EmulatorManager emulatorManager) { mGameSearchVM = new GameSearchViewModel(emulatorManager); InitializeComponent(); }
public void KillEmulator() { EmulatorManager.KillEmulator(); }
public PlayCommand() { romMgr = RomManager.Instance; emuMgr = EmulatorManager.Instance; }