private void AnimClick(ConResource pButton) { if (pButton.CurSprite != pButton.NumSprites - 1) { pButton.CurSprite++; _text.FlushForRedraw(); pButton.DrawToScreen(NoMask); _text.DrawToScreen(WithMask); _system.GraphicsManager.UpdateScreen(); Delay(150); if (_controlPanel == null) return; pButton.CurSprite--; _text.FlushForRedraw(); pButton.DrawToScreen(NoMask); _text.DrawToScreen(WithMask); _system.GraphicsManager.UpdateScreen(); } }
private void DoToggleFx(ConResource pButton) { SystemVars.Instance.SystemFlags ^= SystemFlags.FxOff; if (SystemVars.Instance.SystemFlags.HasFlag(SystemFlags.FxOff)) { pButton.CurSprite = 0; _statusBar.SetToText(0x7000 + 87); } else { pButton.CurSprite = 2; _statusBar.SetToText(0x7000 + 86); } // TODO: configuration //ConfMan.setBool("sfx_mute", SystemVars.SystemFlags.HasFlag(SystemFlags.FX_OFF) != 0); pButton.DrawToScreen(WithMask); _system.GraphicsManager.UpdateScreen(); }
private void ToggleMusic(ConResource pButton) { SystemVars.Instance.SystemFlags ^= SystemFlags.MusOff; if (SystemVars.Instance.SystemFlags.HasFlag(SystemFlags.MusOff)) { _skyMusic.StartMusic(0); pButton.CurSprite = 0; _statusBar.SetToText(0x7000 + 89); } else { _skyMusic.StartMusic(SystemVars.Instance.CurrentMusic); pButton.CurSprite = 2; _statusBar.SetToText(0x7000 + 88); } // TODO: configuration // ConfMan.setBool("music_mute", (SkyEngine::_systemVars.systemFlags & SF_MUS_OFF) != 0); pButton.DrawToScreen(WithMask); _system.GraphicsManager.UpdateScreen(); }
private ushort HandleClick(ConResource pButton) { switch (pButton.OnClick) { case DoNothing: return 0; case RestGamePanel: if (!LoadSaveAllowed()) return CancelPressed; // can't save/restore while choosing AnimClick(pButton); return SaveRestorePanel(false); // texts can't be edited case SaveGamePanel: if (!LoadSaveAllowed()) return CancelPressed; // can't save/restore while choosing AnimClick(pButton); return SaveRestorePanel(true); // texts can be edited case SaveAGame: AnimClick(pButton); return SaveGameToFile(true); case RestoreAGame: AnimClick(pButton); return RestoreGameFromFile(false); case RestoreAuto: AnimClick(pButton); return RestoreGameFromFile(true); case SpCancel: AnimClick(pButton); return CancelPressed; case ShiftDownFast: AnimClick(pButton); return ShiftDown(Fast); case ShiftDownSlow: AnimClick(pButton); return ShiftDown(Slow); case ShiftUpFast: AnimClick(pButton); return ShiftUp(Fast); case ShiftUpSlow: AnimClick(pButton); return ShiftUp(Slow); case SpeedSlide: _mouseClicked = true; return DoSpeedSlide(); case MusicSlide: _mouseClicked = true; return DoMusicSlide(); case ToggleFx: DoToggleFx(pButton); return Toggled; case ToggleMs: ToggleMusic(pButton); return Toggled; case ToggleText: AnimClick(pButton); return DoToggleText(); case Exit: AnimClick(pButton); return QuitPanel; case Restart: AnimClick(pButton); if (GetYesNo("Restart?")) { RestartGame(); return GameRestored; } return 0; case QuitToDos: AnimClick(pButton); if (GetYesNo("Quit to DOS?")) SkyEngine.QuitGame(); return 0; default: throw new InvalidOperationException(string.Format("Control::handleClick: unknown routine: {0:X2}", pButton.OnClick)); } }
private void RemovePanel() { _screenBuf = null; _sprites.ControlPanel = null; _sprites.Button = null; _sprites.ButtonDown = null; _sprites.SavePanel = null; _sprites.YesNo = null; _sprites.Slide = null; _sprites.Slide2 = null; _sprites.Slode = null; _sprites.Slode2 = null; _sprites.MusicBodge = null; _controlPanel = null; _exitButton = null; _controlPanel = null; _slide = null; _slide2 = null; _slode = null; _restorePanButton = null; _savePanel = null; _saveButton = null; _downFastButton = null; _downSlowButton = null; _upFastButton = null; _upSlowButton = null; _quitButton = null; _autoSaveButton = null; _savePanButton = null; _dosPanButton = null; _restartPanButton = null; _fxPanButton = null; _musicPanButton = null; _bodge = null; _yesNo = null; _text = null; _statusBar = null; _restoreButton = null; _textSprite = null; }
private void InitPanel() { _screenBuf = new byte[Screen.GameScreenWidth * Screen.FullScreenHeight]; var volY = (ushort)((127 - _skyMusic.Volume) / 4 + 59 - MpnlY); // volume slider's Y coordinate var spdY = (ushort)((SystemVars.Instance.GameSpeed - 2) / SpeedMultiply); spdY += MpnlY + 83; // speed slider's initial position _sprites.ControlPanel = _skyDisk.LoadFile(60500); _sprites.Button = _skyDisk.LoadFile(60501); _sprites.ButtonDown = _skyDisk.LoadFile(60502); _sprites.SavePanel = _skyDisk.LoadFile(60503); _sprites.YesNo = _skyDisk.LoadFile(60504); _sprites.Slide = _skyDisk.LoadFile(60505); _sprites.Slode = _skyDisk.LoadFile(60506); _sprites.Slode2 = _skyDisk.LoadFile(60507); _sprites.Slide2 = _skyDisk.LoadFile(60508); if (SystemVars.Instance.GameVersion.Version.Minor < 368) _sprites.MusicBodge = null; else _sprites.MusicBodge = _skyDisk.LoadFile(60509); //Main control panel: X Y Text OnClick _controlPanel = CreateResource(_sprites.ControlPanel, 1, 0, 0, 0, 0, DoNothing, Mainpanel); _exitButton = CreateResource(_sprites.Button, 3, 0, 16, 125, 50, Exit, Mainpanel); _slide = CreateResource(_sprites.Slide2, 1, 0, 19, (short)spdY, 95, SpeedSlide, Mainpanel); _slide2 = CreateResource(_sprites.Slide2, 1, 0, 19, (short)volY, 14, MusicSlide, Mainpanel); _slode = CreateResource(_sprites.Slode2, 1, 0, 9, 49, 0, DoNothing, Mainpanel); _restorePanButton = CreateResource(_sprites.Button, 3, 0, 58, 19, 51, RestGamePanel, Mainpanel); _savePanButton = CreateResource(_sprites.Button, 3, 0, 58, 39, 48, SaveGamePanel, Mainpanel); _dosPanButton = CreateResource(_sprites.Button, 3, 0, 58, 59, 93, QuitToDos, Mainpanel); _restartPanButton = CreateResource(_sprites.Button, 3, 0, 58, 79, 94, Restart, Mainpanel); _fxPanButton = CreateResource(_sprites.Button, 3, 0, 58, 99, 90, ToggleFx, Mainpanel); if (SkyEngine.IsCDVersion) { // CD Version: Toggle text/speech _musicPanButton = CreateResource(_sprites.Button, 3, 0, 58, 119, 52, ToggleText, Mainpanel); } else { // disk version: toggle music on/off _musicPanButton = CreateResource(_sprites.Button, 3, 0, 58, 119, 91, ToggleMs, Mainpanel); } _bodge = CreateResource(_sprites.MusicBodge, 2, 1, 98, 115, 0, DoNothing, Mainpanel); _yesNo = CreateResource(_sprites.YesNo, 1, 0, -2, 40, 0, DoNothing, Mainpanel); _text = new TextResource(null, 1, 0, 15, 137, 0, DoNothing, _system, _screenBuf); _controlPanLookList = new[] { _exitButton, _restorePanButton, _savePanButton, _dosPanButton, _restartPanButton, _fxPanButton, _musicPanButton, _slide, _slide2 }; // save/restore panel _savePanel = CreateResource(_sprites.SavePanel, 1, 0, 0, 0, 0, DoNothing, Savepanel); _saveButton = CreateResource(_sprites.Button, 3, 0, 29, 129, 48, SaveAGame, Savepanel); _downFastButton = CreateResource(_sprites.ButtonDown, 1, 0, 212, 114, 0, ShiftDownFast, Savepanel); _downSlowButton = CreateResource(_sprites.ButtonDown, 1, 0, 212, 104, 0, ShiftDownSlow, Savepanel); _upFastButton = CreateResource(_sprites.ButtonDown, 1, 0, 212, 10, 0, ShiftUpFast, Savepanel); _upSlowButton = CreateResource(_sprites.ButtonDown, 1, 0, 212, 21, 0, ShiftUpSlow, Savepanel); _quitButton = CreateResource(_sprites.Button, 3, 0, 72, 129, 49, SpCancel, Savepanel); _restoreButton = CreateResource(_sprites.Button, 3, 0, 29, 129, 51, RestoreAGame, Savepanel); _autoSaveButton = CreateResource(_sprites.Button, 3, 0, 115, 129, 0x8FFF, RestoreAuto, Savepanel); _savePanLookList = new[] { _saveButton, _downSlowButton, _downFastButton, _upFastButton, _upSlowButton, _quitButton }; _restorePanLookList = new[] { _restoreButton, _downSlowButton, _downFastButton, _upFastButton, _upSlowButton, _quitButton, _autoSaveButton }; _statusBar = new ControlStatus(_skyText, _system, _screenBuf); _textSprite = null; }
private void ShowSprites(byte[][] nameSprites, bool allowSave) { var drawResource = new ConResource(null, 1, 0, 0, 0, 0, 0, _system, _screenBuf); for (ushort cnt = 0; cnt < MaxOnScreen; cnt++) { drawResource.SetSprite(nameSprites[cnt]); drawResource.SetXy(GameNameX, (ushort)(GameNameY + cnt * PanCharHeight)); if (ServiceLocator.Platform.ToStructure<DataFileHeader>(nameSprites[cnt], 0).flag != 0) { // name is highlighted for (ushort cnty = (ushort)(GameNameY + cnt * PanCharHeight); cnty < GameNameY + (cnt + 1) * PanCharHeight - 1; cnty++) { _screenBuf.Set(cnty * Screen.GameScreenWidth + GameNameX, 37, PanLineWidth); } drawResource.DrawToScreen(WithMask); if (allowSave) { drawResource.SetSprite(nameSprites[MaxOnScreen]); drawResource.SetXy((ushort)(GameNameX + _enteredTextWidth + 1), (ushort)(GameNameY + cnt * PanCharHeight + 4)); drawResource.DrawToScreen(WithMask); } _system.GraphicsManager.CopyRectToScreen(_screenBuf, (GameNameY + cnt * PanCharHeight) * Screen.GameScreenWidth + GameNameX, Screen.GameScreenWidth, GameNameX, GameNameY + cnt * PanCharHeight, PanLineWidth, PanCharHeight); } else drawResource.DrawToScreen(NoMask); } }
private void ButtonControl(ConResource pButton) { if (pButton == null) { _textSprite = null; _curButtonText = 0; _text.SetSprite(null); return; } if (_curButtonText != pButton.Text) { _textSprite = null; _curButtonText = (int)pButton.Text; if (pButton.Text != 0) { DisplayedText textRes; if (pButton.Text == 0xFFFF) // text for autosave button textRes = _skyText.DisplayText("Restore Autosave", null, false, PanLineWidth, 255); else textRes = _skyText.DisplayText((ushort)pButton.Text, null, false, PanLineWidth, 255); _textSprite = textRes.TextData; _text.SetSprite(_textSprite); } else _text.SetSprite(null); } var mouse = _system.InputManager.GetMousePosition(); var destY = mouse.X - 16 >= 0 ? mouse.Y - 16 : 0; _text.SetXy((ushort)(mouse.X + 12), (ushort)destY); }