Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,350 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "graphics/cursorman.h"
#include "bagel/spacebar/dialogs/credits_dialog.h"
#include "bagel/spacebar/dialogs/opt_window.h"
#include "bagel/spacebar/baglib/bagel.h"
#include "bagel/spacebar/baglib/master_win.h"
#include "bagel/boflib/file_functions.h"
#include "bagel/boflib/string_functions.h"
namespace Bagel {
namespace SpaceBar {
struct ST_CREDITS {
const char *_pszBackground;
const char *_pszTextFile;
int _nLeft;
int _nTop;
int _nRight;
int _nBottom;
int _nScrollRate;
int _nPointSize;
};
#define CREDIT_TIMER_ID 567
#define NUM_SCREENS 12
#define MY_MASK_COLOR 1
#define LINE_HEIGHT 24
#define PIX_SCROLL_DY 1
static const ST_CREDITS g_cScreen[NUM_SCREENS] = {
// Background Credit text topLeft BotRight Delay PointSize
{ "BARAREA.BMP", "CREDITS1.TXT", 370, 6, 636, 150, 30, 20 },
{ "CILIA.BMP", "CREDITS2.TXT", 6, 120, 310, 360, 10, 24 },
{ "AUDITON.BMP", "CREDITS3.TXT", 320, 120, 636, 360, 10, 24 },
{ "CAST1.BMP", "CAST1.TXT", 6, 120, 310, 360, 10, 24 },
{ "CAST2.BMP", "CAST2.TXT", 376, 120, 636, 360, 10, 24 },
{ "CAST3.BMP", "CAST3.TXT", 6, 120, 310, 360, 10, 24 },
{ "CAST4.BMP", "CAST4.TXT", 6, 120, 290, 360, 10, 24 },
{ "VILDROID.BMP", "CREDITS5.TXT", 394, 120, 636, 360, 10, 22 },
{ "ZZAZZL.BMP", "CREDITS6.TXT", 6, 220, 284, 474, 10, 24 },
{ "SRAFFAN.BMP", "CREDITS7.TXT", 352, 310, 636, 474, 10, 24 },
{ "FLEEBIX.BMP", "CREDITS8.TXT", 466, 230, 636, 474, 10, 18 },
{ "TRISECKS.BMP", "CREDITS9.TXT", 6, 374, 636, 474, 10, 24 }
};
static bool g_b1 = false;
CBagCreditsDialog::CBagCreditsDialog() {
_iScreen = 0;
_pszNextLine = _pszEnd = nullptr;
_pszText = nullptr;
_nLines = 0;
_nNumPixels = 0;
_pCreditsBmp = nullptr;
_pSaveBmp = nullptr;
_bDisplay = false;
}
void CBagCreditsDialog::onInitDialog() {
assert(isValidObject(this));
// Hide cursor for credit screens
CursorMan.showMouse(false);
CBofDialog::onInitDialog();
setReturnValue(-1);
// Start at 1st credit screen
_iScreen = 0;
assert(_pBackdrop != nullptr);
CBofPalette *pPal = _pBackdrop->getPalette();
selectPalette(pPal);
g_b1 = true;
// Load 1st credit text file
loadNextTextFile();
}
ErrorCode CBagCreditsDialog::loadNextTextFile() {
assert(isValidObject(this));
// Our credits text must exist
assert(fileExists(buildSysDir(g_cScreen[_iScreen]._pszTextFile)));
CBofRect cRect;
cRect.left = g_cScreen[_iScreen]._nLeft;
cRect.top = g_cScreen[_iScreen]._nTop;
cRect.right = g_cScreen[_iScreen]._nRight;
cRect.bottom = g_cScreen[_iScreen]._nBottom;
// Get rid of any previous work area
delete _pCreditsBmp;
_pCreditsBmp = nullptr;
// Create a new work area
_pCreditsBmp = new CBofBitmap(cRect.width(), cRect.height() + LINE_HEIGHT + 2, _pBackdrop->getPalette());
_pCreditsBmp->fillRect(nullptr, MY_MASK_COLOR);
// Kill any previous work area
delete _pSaveBmp;
_pSaveBmp = new CBofBitmap(_pCreditsBmp->width(), _pCreditsBmp->height(), _pBackdrop->getPalette());
CBofRect tmpRect = _pSaveBmp->getRect();
_pBackdrop->paint(_pSaveBmp, &tmpRect, &cRect);
// Get rid of any previous credits screen
if (_pszText != nullptr) {
bofFree(_pszText);
_pszText = nullptr;
}
CBofFile cFile(buildSysDir(g_cScreen[_iScreen]._pszTextFile), CBF_BINARY | CBF_READONLY);
if (!cFile.errorOccurred()) {
// Read in text file
uint32 lSize = cFile.getLength();
_pszText = (char *)bofCleanAlloc(lSize + 1);
cFile.read(_pszText, lSize);
_pszNextLine = _pszText;
_pszEnd = _pszText + lSize;
_nNumPixels = 0;
// Determine the number of lines of text in credits
_nLines = strCharCount(_pszText, '\n');
strreplaceChar(_pszText, '\r', ' ');
strreplaceChar(_pszText, '\n', '\0');
paintLine(linesPerPage() - 1, _pszNextLine);
nextLine();
paintLine(linesPerPage(), _pszNextLine);
nextLine();
_bDisplay = true;
}
return _errCode;
}
int CBagCreditsDialog::linesPerPage() {
assert(isValidObject(this));
int retVal = (g_cScreen[_iScreen]._nBottom - g_cScreen[_iScreen]._nTop) / (LINE_HEIGHT + 2) + 1;
return retVal;
}
void CBagCreditsDialog::onClose() {
assert(isValidObject(this));
delete _pCreditsBmp;
_pCreditsBmp = nullptr;
delete _pSaveBmp;
_pSaveBmp = nullptr;
if (_pszText != nullptr) {
bofFree(_pszText);
_pszText = nullptr;
}
_pszNextLine = _pszEnd = nullptr;
_nLines = 0;
_nNumPixels = 0;
_bDisplay = false;
killBackdrop();
CBofDialog::onClose();
// Can have cursor back now
CursorMan.showMouse(true);
}
void CBagCreditsDialog::onPaint(CBofRect *pRect) {
assert(isValidObject(this));
paintBackdrop(pRect);
validateAnscestors();
}
void CBagCreditsDialog::onLButtonDown(uint32 /*nFlags*/, CBofPoint */*pPoint*/, void *) {
assert(isValidObject(this));
nextScreen();
}
void CBagCreditsDialog::onKeyHit(uint32 /*lKey*/, uint32 /*nRepCount*/) {
assert(isValidObject(this));
nextScreen();
}
void CBagCreditsDialog::onMainLoop() {
assert(isValidObject(this));
// If it's OK to show the credits
if (_bDisplay) {
displayCredits();
}
// Check again...could have changed in displayCredits()
if (_bDisplay) {
// Control the scroll rate
assert(_iScreen >= 0 && _iScreen < NUM_SCREENS);
bofSleep(g_cScreen[_iScreen]._nScrollRate);
}
}
ErrorCode CBagCreditsDialog::displayCredits() {
assert(isValidObject(this));
if (_nNumPixels < (_nLines + linesPerPage() + 1) * LINE_HEIGHT) {
assert(_pCreditsBmp != nullptr);
if (_pCreditsBmp != nullptr) {
assert(_pBackdrop != nullptr);
assert(_pSaveBmp != nullptr);
_pSaveBmp->paint(_pBackdrop, g_cScreen[_iScreen]._nLeft, g_cScreen[_iScreen]._nTop);
CBofRect cRect;
cRect.setRect(0, 0, _pCreditsBmp->width() - 1, _pCreditsBmp->height() - 1 - (LINE_HEIGHT + 2));
_pCreditsBmp->paint(_pBackdrop, g_cScreen[_iScreen]._nLeft, g_cScreen[_iScreen]._nTop, &cRect, MY_MASK_COLOR);
if (g_b1) {
_pBackdrop->paint(this, 0, 0);
g_b1 = false;
} else {
cRect.left = g_cScreen[_iScreen]._nLeft;
cRect.top = g_cScreen[_iScreen]._nTop;
cRect.right = cRect.left + _pCreditsBmp->width() - 1;
cRect.bottom = cRect.top + _pCreditsBmp->height() - 1 - (LINE_HEIGHT + 2);
_pBackdrop->paint(this, &cRect, &cRect);
}
// Strip off top layer so it won't wrap around
for (int i = 0; i < PIX_SCROLL_DY; i++) {
_pCreditsBmp->line(0, i, _pCreditsBmp->width() - 1, i, MY_MASK_COLOR);
}
// Scroll text up 1 pixel
_pCreditsBmp->scrollUp(PIX_SCROLL_DY);
_nNumPixels += PIX_SCROLL_DY;
if ((_nNumPixels % LINE_HEIGHT) == 0) {
paintLine(linesPerPage(), _pszNextLine);
nextLine();
}
}
} else {
nextScreen();
}
return _errCode;
}
ErrorCode CBagCreditsDialog::nextScreen() {
assert(isValidObject(this));
if (++_iScreen < NUM_SCREENS) {
// Load next screen (flushes previous backdrop)
CBofBitmap *pBmp = SpaceBar::loadBitmap(buildSysDir(g_cScreen[_iScreen]._pszBackground));
if (pBmp != nullptr) {
setBackdrop(pBmp);
g_b1 = true;
}
// Load credit text for this screen
loadNextTextFile();
} else {
// Since there are no more screens to show, then we are outta here
_bDisplay = false;
close();
}
return _errCode;
}
ErrorCode CBagCreditsDialog::paintLine(int nLine, char *pszText) {
assert(isValidObject(this));
assert(pszText != nullptr);
assert(nLine >= 0 && nLine <= linesPerPage());
assert(_pCreditsBmp != nullptr);
CBofRect cRect;
cRect.setRect(0, nLine * LINE_HEIGHT, _pCreditsBmp->width() - 1, (nLine + 1) * LINE_HEIGHT - 1);
_pCreditsBmp->fillRect(&cRect, MY_MASK_COLOR);
if (*pszText != '\0') {
paintShadowedText(_pCreditsBmp, &cRect, pszText, g_cScreen[_iScreen]._nPointSize, TEXT_NORMAL, CTEXT_WHITE, JUSTIFY_CENTER);
}
return _errCode;
}
void CBagCreditsDialog::nextLine() {
assert(isValidObject(this));
assert(_pszNextLine != nullptr);
if ((_pszNextLine != nullptr) && (_pszNextLine < _pszEnd)) {
while (*_pszNextLine != '\0') {
_pszNextLine++;
}
if (_pszNextLine < _pszEnd) {
_pszNextLine++;
}
assert(_pszNextLine <= _pszEnd);
}
}
} // namespace SpaceBar
} // namespace Bagel

View File

@@ -0,0 +1,70 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BAGEL_DIALOGS_CREDITS_DIALOG_H
#define BAGEL_DIALOGS_CREDITS_DIALOG_H
#include "bagel/spacebar/boflib/gui/dialog.h"
namespace Bagel {
namespace SpaceBar {
class CBagCreditsDialog : public CBofDialog {
public:
CBagCreditsDialog();
virtual void onInitDialog();
protected:
virtual void onPaint(CBofRect *pRect);
virtual void onClose();
virtual void onKeyHit(uint32 lKey, uint32 lRepCount);
virtual void onLButtonDown(uint32 nFlags, CBofPoint *pPoint, void * = nullptr);
virtual void onMainLoop();
ErrorCode nextScreen();
ErrorCode displayCredits();
ErrorCode loadNextTextFile();
int linesPerPage();
void nextLine();
ErrorCode paintLine(int nLine, char *pszText);
CBofBitmap *_pCreditsBmp;
CBofBitmap *_pSaveBmp;
char *_pszNextLine;
char *_pszEnd;
char *_pszText;
int _nLines;
int _nNumPixels;
int _iScreen;
bool _bDisplay;
};
} // namespace SpaceBar
} // namespace Bagel
#endif

View File

@@ -0,0 +1,120 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "bagel/spacebar/dialogs/next_cd_dialog.h"
#include "bagel/spacebar/dialogs/opt_window.h"
#include "bagel/spacebar/baglib/cursor.h"
#include "bagel/spacebar/baglib/bagel.h"
#include "bagel/spacebar/boflib/std_keys.h"
namespace Bagel {
namespace SpaceBar {
#define OK_BTN 5
CBagNextCDDialog::CBagNextCDDialog() {
// Inits
_nReturnValue = -1;
_pButton = nullptr;
_lFlags = 0;
}
void CBagNextCDDialog::onInitDialog() {
assert(isValidObject(this));
CBofDialog::onInitDialog();
setReturnValue(-1);
assert(_pBackdrop != nullptr);
CBofPalette *pPal = _pBackdrop->getPalette();
selectPalette(pPal);
// Build all our buttons
_pButton = new CBofBmpButton;
CBofBitmap *pUp = loadBitmap(buildSysDir("CDOKUP.BMP"), pPal);
CBofBitmap *pDown = loadBitmap(buildSysDir("CDOKDN.BMP"), pPal);
CBofBitmap *pFocus = loadBitmap(buildSysDir("CDOKUP.BMP"), pPal);
CBofBitmap *pDis = loadBitmap(buildSysDir("CDOKUP.BMP"), pPal);
_pButton->loadBitmaps(pUp, pDown, pFocus, pDis);
_pButton->create("NextCD", 77, 127, 60, 30, this, OK_BTN);
_pButton->show();
// Show System cursor
CBagCursor::showSystemCursor();
}
void CBagNextCDDialog::onClose() {
assert(isValidObject(this));
CBagCursor::hideSystemCursor();
// Destroy my buttons
delete _pButton;
_pButton = nullptr;
CBofDialog::onClose();
}
void CBagNextCDDialog::onPaint(CBofRect *pRect) {
assert(isValidObject(this));
assert(pRect != nullptr);
_bFirstTime = false;
// Paint the dialog
if (_pBackdrop != nullptr) {
_pBackdrop->paint(this, pRect, pRect, 1);
}
_bHavePainted = true;
validateAnscestors();
}
void CBagNextCDDialog::onKeyHit(uint32 lKey, uint32 nRepCount) {
assert(isValidObject(this));
switch (lKey) {
// Cancel
case BKEY_ENTER:
case BKEY_ESC:
close();
break;
default:
CBofDialog::onKeyHit(lKey, nRepCount);
break;
}
}
void CBagNextCDDialog::onBofButton(CBofObject * /*pObject*/, int nFlags) {
assert(isValidObject(this));
if (nFlags == BUTTON_CLICKED) {
close();
}
}
} // namespace SpaceBar
} // namespace Bagel

View File

@@ -0,0 +1,108 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BAGEL_DIALOGS_NEXT_CD_DIALOG_H
#define BAGEL_DIALOGS_NEXT_CD_DIALOG_H
#include "bagel/spacebar/boflib/gui/dialog.h"
#include "bagel/spacebar/boflib/gui/button.h"
namespace Bagel {
namespace SpaceBar {
#define NUM_QUIT_BUTTONS 3
class CBagQuitDialog : public CBofDialog {
public:
CBagQuitDialog();
void onInitDialog() override;
protected:
void onPaint(CBofRect *pRect) override;
void onClose() override;
void onBofButton(CBofObject *pObject, int nState) override;
void onKeyHit(uint32 lKey, uint32 lRepCount) override;
// Data
//
CBofBmpButton *_pButtons[NUM_QUIT_BUTTONS];
};
class CBagNextCDDialog : public CBofDialog {
public:
CBagNextCDDialog();
void onInitDialog() override;
protected:
void onPaint(CBofRect *pRect) override;
void onClose() override;
void onBofButton(CBofObject *, int nFlags) override;
void onKeyHit(uint32 lKey, uint32 nRepCount) override;
// Data
CBofBmpButton *_pButton;
};
class CBagCreditsDialog : public CBofDialog {
public:
CBagCreditsDialog();
void onInitDialog() override;
protected:
void onPaint(CBofRect *pRect) override;
void onClose() override;
void onKeyHit(uint32 lKey, uint32 lRepCount) override;
void onLButtonDown(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
void onMainLoop() override;
ErrorCode nextScreen();
ErrorCode displayCredits();
ErrorCode loadNextTextFile();
int linesPerPage();
void nextLine();
ErrorCode paintLine(int nLine, char *pszText);
CBofBitmap *_pCreditsBmp;
CBofBitmap *_pSaveBmp;
char *_pszNextLine;
char *_pszEnd;
char *_pszText;
int _nLines;
int _nNumPixels;
int _iScreen;
bool _bDisplay;
};
} // namespace SpaceBar
} // namespace Bagel
#endif

View File

@@ -0,0 +1,699 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "common/config-manager.h"
#include "bagel/spacebar/dialogs/opt_window.h"
#include "bagel/spacebar/dialogs/save_dialog.h"
#include "bagel/spacebar/baglib/bagel.h"
#include "bagel/boflib/sound.h"
#include "bagel/spacebar/baglib/storage_dev_win.h"
#include "bagel/spacebar/baglib/pan_window.h"
#include "bagel/spacebar/boflib/std_keys.h"
#include "bagel/bagel.h"
#include "bagel/boflib/file_functions.h"
#include "bagel/boflib/log.h"
namespace Bagel {
namespace SpaceBar {
#define USER_OPTIONS "UserOptions"
#define BROWN_SCROLL_BKGD "SLIDER.BMP"
#define BROWN_SCROLL_THMB "THUMB.BMP"
#define BROWN_SCROLL_LFUP "LEFTUP.BMP"
#define BROWN_SCROLL_RTUP "RIGHTUP.BMP"
#define BROWN_SCROLL_LFDN "LEFTDN.BMP"
#define BROWN_SCROLL_RTDN "RIGHTDN.BMP"
#define VOLUME_MIN 0
#define VOLUME_MAX 12
#define VOLUME_DEFAULT 10
#define CHECKBOX_WIDTH 20
#define CHECKBOX_HEIGHT 20
#define FLYTHROUGHS_LEFT 41
#define FLYTHROUGHS_TOP 151
#define PANIMATIONS_LEFT 41
#define PANIMATIONS_TOP 201
// Button IDs
//
#define SAVE_ID 0
#define RESTORE_ID 1
#define RESTART_ID 2
#define QUIT_ID 3
#define HELP_ID 4
#define CREDITS_ID 5
#define OKAY_ID 6
#define DEFAULTS_ID 7
#define PANSPEED_ID 8
#define CORRECTION_ID 9
#define FLYTHROUGHS_ID 10
#define PAN_CHECK_ID 11
#define MIDI_VOL_ID 12
#define WAVE_VOL_ID 13
struct ST_BUTTONS {
const char *_pszName;
const char *_pszUp;
const char *_pszDown;
const char *_pszFocus;
const char *_pszDisabled;
int _nLeft;
int _nTop;
int _nWidth;
int _nHeight;
int _nID;
};
static const ST_BUTTONS g_stButtons[NUM_SYS_BUTTONS] = {
{ "Save", "saveup.bmp", "savedn.bmp", "savegr.bmp", "savegr.bmp", 490, 55, 120, 40, SAVE_ID },
{ "Restore", "restorup.bmp", "restordn.bmp", "restorgr.bmp", "restorgr.bmp", 490, 110, 120, 40, RESTORE_ID },
{ "Restart", "restarup.bmp", "restardn.bmp", "restarup.bmp", "restarup.bmp", 490, 165, 120, 40, RESTART_ID },
{ "Quit", "quitup.bmp", "quitdn.bmp", "quitup.bmp", "quitup.bmp", 490, 220, 120, 40, QUIT_ID },
{ "Help", "helpup.bmp", "helpdn.bmp", "helpup.bmp", "helpup.bmp", 490, 275, 120, 40, HELP_ID },
{ "Credits", "creditup.bmp", "creditdn.bmp", "creditup.bmp", "creditdn.bmp", 490, 330, 120, 40, CREDITS_ID },
{ "Okay", "okayup.bmp", "okaydn.bmp", "okayup.bmp", "okayup.bmp", 490, 385, 120, 40, OKAY_ID },
{ "Defaults", "dfaultup.bmp", "dfaultdn.bmp", "dfaultup.bmp", "dfaultup.bmp", 72, 360, 120, 40, DEFAULTS_ID }
};
CBagOptWindow::CBagOptWindow() {
// Inits
_pFlythroughs = nullptr;
_pPanimations = nullptr;
_pMidiVolumeScroll = nullptr;
_pWaveVolumeScroll = nullptr;
_pCorrectionScroll = nullptr;
_pPanSpeedScroll = nullptr;
_bDirty = false;
// CBofDialog Inits
_pDlgBackground = nullptr;
_bFirstTime = true;
_bTempBitmap = false;
_lFlags = BOFDLG_DEFAULT;
_bEndDialog = false;
_cSystemData._bPanimations = true;
_cSystemData._bFlythroughs = true;
_cSystemData._nCorrection = 4;
_cSystemData._nPanSpeed = 1;
_cSystemData._nMusicVolume = VOLUME_DEFAULT;
_cSystemData._nSoundVolume = VOLUME_DEFAULT;
_cColorScheme._cFace = RGB(123, 156, 206);
_cColorScheme._cHighlight = RGB(255, 255, 255);
_cColorScheme._cShadow = RGB(255, 255, 255);
_cColorScheme._cText = RGB(0, 0, 0);
_cColorScheme._cTextDisabled = CTEXT_WHITE;
_cColorScheme._cOutline = RGB(123, 156, 206);
// Don't need to save the background behind this dialog
_lFlags &= ~BOFDLG_SAVEBACKGND;
_nReturnValue = -1;
for (int i = 0; i < NUM_SYS_BUTTONS; i++) {
_pButtons[i] = nullptr;
}
_pSavePalette = nullptr;
}
ErrorCode CBagOptWindow::detach() {
assert(isValidObject(this));
CBagCursor::hideSystemCursor();
// Save any changes that the user made
saveOutNewSettings();
// Destroy all buttons
for (int i = 0; i < NUM_SYS_BUTTONS; i++) {
delete _pButtons[i];
_pButtons[i] = nullptr;
}
delete _pFlythroughs;
_pFlythroughs = nullptr;
delete _pPanimations;
_pPanimations = nullptr;
delete _pMidiVolumeScroll;
_pMidiVolumeScroll = nullptr;
delete _pWaveVolumeScroll;
_pWaveVolumeScroll = nullptr;
delete _pCorrectionScroll;
_pCorrectionScroll = nullptr;
delete _pPanSpeedScroll;
_pPanSpeedScroll = nullptr;
CBofApp::getApp()->setPalette(_pSavePalette);
return _errCode;
}
void CBagOptWindow::onPaint(CBofRect *pRect) {
assert(isValidObject(this));
assert(pRect != nullptr);
paintBackdrop(pRect);
validateAnscestors();
}
ErrorCode CBagOptWindow::attach() {
// Save off the current game's palette
_pSavePalette = CBofApp::getApp()->getPalette();
CBofPalette *pPal = nullptr;
// Insert ours
if (_pBackdrop != nullptr) {
pPal = _pBackdrop->getPalette();
CBofApp::getApp()->setPalette(pPal);
}
// Paint stuff
if (_pBackdrop != nullptr) {
CBofBitmap cBmp(buildSysDir("MUSICVOL.BMP"), pPal);
cBmp.paint(_pBackdrop, 30, 30);
}
if (_pBackdrop != nullptr) {
CBofBitmap cBmp(buildSysDir("AUDIOVOL.BMP"), pPal);
cBmp.paint(_pBackdrop, 30, 80);
}
if (_pBackdrop != nullptr) {
CBofBitmap cBmp(buildSysDir("FLYTHRUS.BMP"), pPal);
cBmp.paint(_pBackdrop, 30, 140);
}
if (_pBackdrop != nullptr) {
CBofBitmap cBmp(buildSysDir("PANIMATS.BMP"), pPal);
cBmp.paint(_pBackdrop, 30, 190);
}
if (_pBackdrop != nullptr) {
CBofBitmap cBmp(buildSysDir("CORRECTN.BMP"), pPal);
cBmp.paint(_pBackdrop, 30, 250);
}
if (_pBackdrop != nullptr) {
CBofBitmap cBmp(buildSysDir("PANSPEED.BMP"), pPal);
cBmp.paint(_pBackdrop, 30, 300);
}
// Build all our buttons
for (int i = 0; i < NUM_SYS_BUTTONS; i++) {
assert(_pButtons[i] == nullptr);
_pButtons[i] = new CBofBmpButton;
CBofBitmap *pUp = loadBitmap(buildSysDir(g_stButtons[i]._pszUp), pPal);
CBofBitmap *pDown = loadBitmap(buildSysDir(g_stButtons[i]._pszDown), pPal);
CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stButtons[i]._pszFocus), pPal);
CBofBitmap *pDis = loadBitmap(buildSysDir(g_stButtons[i]._pszDisabled), pPal);
_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
_pButtons[i]->create(g_stButtons[i]._pszName, g_stButtons[i]._nLeft, g_stButtons[i]._nTop, g_stButtons[i]._nWidth, g_stButtons[i]._nHeight, this, g_stButtons[i]._nID);
_pButtons[i]->show();
}
char szBuf1[MAX_DIRPATH];
char szBuf2[MAX_DIRPATH];
char szBuf3[MAX_DIRPATH];
char szBuf4[MAX_DIRPATH];
char szBuf5[MAX_DIRPATH];
char szBuf6[MAX_DIRPATH];
Common::strcpy_s(szBuf1, buildSysDir(BROWN_SCROLL_BKGD));
Common::strcpy_s(szBuf2, buildSysDir(BROWN_SCROLL_THMB));
Common::strcpy_s(szBuf3, buildSysDir(BROWN_SCROLL_LFUP));
Common::strcpy_s(szBuf4, buildSysDir(BROWN_SCROLL_RTUP));
Common::strcpy_s(szBuf5, buildSysDir(BROWN_SCROLL_LFDN));
Common::strcpy_s(szBuf6, buildSysDir(BROWN_SCROLL_RTDN));
// Midi volume control
CBofRect cRect;
cRect.setRect(73, 48, 73 + 120 - 1, 48 + 20 - 1);
_pMidiVolumeScroll = new CBofScrollBar;
_pMidiVolumeScroll->create("", &cRect, this, MIDI_VOL_ID);
_pMidiVolumeScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
_pMidiVolumeScroll->setScrollRange(VOLUME_MIN, VOLUME_MAX, true);
_pMidiVolumeScroll->show();
// Digital Audio volume control
cRect.setRect(73, 98, 73 + 120 - 1, 98 + 20 - 1);
_pWaveVolumeScroll = new CBofScrollBar;
_pWaveVolumeScroll->create("", &cRect, this, WAVE_VOL_ID);
_pWaveVolumeScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
_pWaveVolumeScroll->setScrollRange(VOLUME_MIN, VOLUME_MAX, true);
_pWaveVolumeScroll->show();
// Pan Correction control
cRect.setRect(73, 268, 73 + 120 - 1, 268 + 20 - 1);
_pCorrectionScroll = new CBofScrollBar;
_pCorrectionScroll->create("", &cRect, this, CORRECTION_ID);
_pCorrectionScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
_pCorrectionScroll->setScrollRange(0, 6, true);
_pCorrectionScroll->show();
// Pan Speed control
cRect.setRect(73, 318, 73 + 120 - 1, 318 + 20 - 1);
_pPanSpeedScroll = new CBofScrollBar;
_pPanSpeedScroll->create("", &cRect, this, PANSPEED_ID);
_pPanSpeedScroll->loadBitmaps(szBuf1, szBuf2, szBuf3, szBuf4, szBuf5, szBuf6);
_pPanSpeedScroll->setScrollRange(0, 5, true);
_pPanSpeedScroll->show();
cRect.setRect(FLYTHROUGHS_LEFT, FLYTHROUGHS_TOP, FLYTHROUGHS_LEFT + CHECKBOX_WIDTH, FLYTHROUGHS_TOP + CHECKBOX_HEIGHT);
_pFlythroughs = new CBofCheckButton();
_pFlythroughs->loadColorScheme(&_cColorScheme);
_errCode = _pFlythroughs->create("", &cRect, this, FLYTHROUGHS_ID);
_pFlythroughs->show();
cRect.setRect(PANIMATIONS_LEFT, PANIMATIONS_TOP, PANIMATIONS_LEFT + CHECKBOX_WIDTH, PANIMATIONS_TOP + CHECKBOX_HEIGHT);
_pPanimations = new CBofCheckButton();
_pPanimations->loadColorScheme(&_cColorScheme);
_errCode = _pPanimations->create("", &cRect, this, PAN_CHECK_ID);
_pPanimations->show();
loadIniSettings();
putDialogData();
CBagCursor::showSystemCursor();
return _errCode;
}
void CBagOptWindow::putDialogData() {
assert(isValidObject(this));
if (_pMidiVolumeScroll != nullptr)
_pMidiVolumeScroll->setPos(_cSystemData._nMusicVolume, true, true);
if (_pWaveVolumeScroll != nullptr)
_pWaveVolumeScroll->setPos(_cSystemData._nSoundVolume, true, true);
if (_pCorrectionScroll != nullptr)
_pCorrectionScroll->setPos(_cSystemData._nCorrection, true, true);
if (_pPanSpeedScroll != nullptr)
_pPanSpeedScroll->setPos(_cSystemData._nPanSpeed, true, true);
if (_pFlythroughs != nullptr)
_pFlythroughs->SetCheck(_cSystemData._bFlythroughs);
if (_pPanimations != nullptr)
_pPanimations->SetCheck(_cSystemData._bPanimations);
}
void CBagOptWindow::getDialogData() {
assert(isValidObject(this));
if (_pMidiVolumeScroll != nullptr) {
_cSystemData._nMusicVolume = _pMidiVolumeScroll->getPos();
}
if (_pWaveVolumeScroll != nullptr) {
_cSystemData._nSoundVolume = _pWaveVolumeScroll->getPos();
}
if (_pCorrectionScroll != nullptr) {
_cSystemData._nCorrection = _pCorrectionScroll->getPos();
}
if (_pPanSpeedScroll != nullptr) {
_cSystemData._nPanSpeed = _pPanSpeedScroll->getPos();
}
if (_pPanimations != nullptr) {
_cSystemData._bPanimations = _pPanimations->GetCheck();
}
if (_pFlythroughs != nullptr) {
_cSystemData._bFlythroughs = _pFlythroughs->GetCheck();
}
}
void CBagOptWindow::onBofButton(CBofObject *pObject, int nState) {
assert(isValidObject(this));
assert(pObject != nullptr);
if (nState == BUTTON_CLICKED) {
CBofButton *pButton = (CBofButton *)pObject;
CBagMasterWin *pWin;
CBagel *pApp;
switch (pButton->getControlID()) {
case HELP_ID:
pApp = CBagel::getBagApp();
if (pApp != nullptr) {
pWin = pApp->getMasterWnd();
if ((pWin != nullptr) && pWin->getCurrentGameWindow() != nullptr) {
pWin->onHelp(((CBagStorageDevWnd *)pWin->getCurrentGameWindow())->getHelpFilename(), false, this);
}
}
break;
case CREDITS_ID:
pApp = CBagel::getBagApp();
if (pApp != nullptr) {
pWin = pApp->getMasterWnd();
if (pWin != nullptr) {
pWin->showCreditsDialog(this);
}
}
break;
case OKAY_ID:
close();
break;
case DEFAULTS_ID:
returnToDefaults();
break;
case QUIT_ID: {
pApp = CBagel::getBagApp();
if (pApp != nullptr) {
pWin = pApp->getMasterWnd();
if ((pWin != nullptr) && pWin->showQuitDialog(this)) {
_nReturnValue = 0;
killBackground();
close();
g_engine->quitGame();
}
}
break;
}
case SAVE_ID: {
pApp = CBagel::getBagApp();
if (pApp != nullptr) {
pWin = pApp->getMasterWnd();
if (pWin != nullptr) {
pWin->showSaveDialog(this);
}
}
break;
}
case RESTORE_ID: {
pApp = CBagel::getBagApp();
if (pApp != nullptr) {
pWin = pApp->getMasterWnd();
if ((pWin != nullptr) && pWin->showRestoreDialog(this)) {
// Can't restore a deleted palette
_pSavePalette = nullptr;
killBackground();
close();
}
}
break;
}
case RESTART_ID: {
pApp = CBagel::getBagApp();
if (pApp != nullptr) {
pWin = pApp->getMasterWnd();
if ((pWin != nullptr) && pWin->showRestartDialog(this)) {
// Can't restore a deleted palette
_pSavePalette = nullptr;
killBackground();
close();
}
}
break;
}
default:
logWarning("Unknown button pressed");
break;
}
} else {
CBofButton *pButton = (CBofButton *)pObject;
switch (pButton->getControlID()) {
case FLYTHROUGHS_ID:
_cSystemData._bFlythroughs = (pButton->getState() == BUTTON_CHECKED);
_bDirty = true;
break;
case PAN_CHECK_ID:
_cSystemData._bPanimations = (pButton->getState() == BUTTON_CHECKED);
_bDirty = true;
break;
default:
break;
}
}
}
void CBagOptWindow::onBofScrollBar(CBofObject *pObj, int nPos) {
assert(isValidObject(this));
CBofScrollBar *pScroll = (CBofScrollBar *)pObj;
if (pScroll == _pMidiVolumeScroll) {
_cSystemData._nMusicVolume = nPos;
CBofSound::setVolume(_cSystemData._nMusicVolume, _cSystemData._nSoundVolume);
} else if (pScroll == _pWaveVolumeScroll) {
_cSystemData._nSoundVolume = nPos;
CBofSound::setVolume(_cSystemData._nMusicVolume, _cSystemData._nSoundVolume);
} else if (pScroll == _pCorrectionScroll) {
_cSystemData._nCorrection = nPos;
} else if (pScroll == _pPanSpeedScroll) {
_cSystemData._nPanSpeed = nPos;
}
}
void CBagOptWindow::saveOutNewSettings() {
assert(isValidObject(this));
CBagel *pApp = CBagel::getBagApp();
// Write out current system settings
ConfMan.setBool("Panimations", _cSystemData._bPanimations);
ConfMan.setBool("FlyThroughs", _cSystemData._bFlythroughs);
ConfMan.setInt("Correction", 6 - _cSystemData._nCorrection);
ConfMan.setInt("PanSpeed", _cSystemData._nPanSpeed);
ConfMan.setInt("music_volume", VOLUME_SVM(_cSystemData._nMusicVolume));
ConfMan.setInt("sfx_volume", VOLUME_SVM(_cSystemData._nSoundVolume));
ConfMan.flushToDisk();
if (pApp) {
CBagMasterWin *pWin = pApp->getMasterWnd();
// Set current Pan correction
if (pWin != nullptr) {
int n = pWin->getCorrection();
CBagStorageDevWnd *pSDev = pWin->getCurrentStorageDev();
if ((pSDev != nullptr) && pSDev->getDeviceType() == SDEV_GAMEWIN) {
CBagPanWindow *pPan = (CBagPanWindow *)pSDev;
CBagPanWindow::setRealCorrection(n);
if (pPan->getSlideBitmap() != nullptr) {
pPan->getSlideBitmap()->setCorrWidth(n);
}
}
}
}
CBofSound::setVolume(_cSystemData._nMusicVolume, _cSystemData._nSoundVolume);
CBagPanWindow::setPanSpeed(_cSystemData._nPanSpeed);
_bDirty = false;
}
void CBagOptWindow::loadIniSettings() {
assert(isValidObject(this));
ConfMan.registerDefault("Panimations", true);
ConfMan.registerDefault("FlyThroughs", true);
ConfMan.registerDefault("Correction", 2);
ConfMan.registerDefault("PanSpeed", 1);
// Read in current system settings
_cSystemData._bPanimations = ConfMan.getBool("Panimations");
_cSystemData._bFlythroughs = ConfMan.getBool("FlyThroughs");
int nTemp = ConfMan.getInt("Correction");
if (nTemp < 0 || nTemp > 6)
nTemp = 2;
_cSystemData._nCorrection = 6 - nTemp;
// Pan speed
nTemp = ConfMan.getInt("PanSpeed");
if (nTemp < 0 || nTemp > 5)
nTemp = 1;
_cSystemData._nPanSpeed = nTemp;
// Midi Volume
int musVolume = ConfMan.getBool("music_mute") ? 0 : CLIP(ConfMan.getInt("music_volume"), 0, 255);
_cSystemData._nMusicVolume = SVM_VOLUME(musVolume);
// Digital Audio Volume
int sfxVolume = ConfMan.getBool("sfx_mute") ? 0 : CLIP(ConfMan.getInt("sfx_volume"), 0, 255);
_cSystemData._nSoundVolume = SVM_VOLUME(sfxVolume);
}
void CBagOptWindow::returnToDefaults() {
assert(isValidObject(this));
_cSystemData._bPanimations = true;
_cSystemData._bFlythroughs = true;
_cSystemData._nCorrection = 4;
_cSystemData._nPanSpeed = 1;
_cSystemData._nMusicVolume = VOLUME_DEFAULT;
_cSystemData._nSoundVolume = VOLUME_DEFAULT;
putDialogData();
_bDirty = true;
}
void CBagOptWindow::onInitDialog() {
assert(isValidObject(this));
CBofDialog::onInitDialog();
attach();
}
void CBagOptWindow::onKeyHit(uint32 lKey, uint32 lRepCount) {
assert(isValidObject(this));
CBagMasterWin *pWin;
CBagel *pApp;
switch (lKey) {
// Help
case BKEY_F1:
pApp = CBagel::getBagApp();
if (pApp != nullptr) {
pWin = pApp->getMasterWnd();
if ((pWin != nullptr) && (pWin->getCurrentGameWindow() != nullptr)) {
pWin->onHelp(((CBagStorageDevWnd *)pWin->getCurrentGameWindow())->getHelpFilename(), false, this);
}
}
break;
// Save
case BKEY_ALT_s:
case BKEY_F2:
case BKEY_SAVE:
pApp = CBagel::getBagApp();
if (pApp != nullptr) {
pWin = pApp->getMasterWnd();
if (pWin != nullptr) {
pWin->showSaveDialog(this);
}
}
break;
// Restore
case BKEY_ALT_r:
case BKEY_RESTORE:
pApp = CBagel::getBagApp();
if (pApp != nullptr) {
pWin = pApp->getMasterWnd();
if ((pWin != nullptr) && pWin->showRestoreDialog(this)) {
// Can't restore a deleted palette
_pSavePalette = nullptr;
killBackground();
close();
}
}
break;
// Restart
case BKEY_F12:
pApp = CBagel::getBagApp();
if (pApp != nullptr) {
pWin = pApp->getMasterWnd();
if ((pWin != nullptr) && pWin->showRestartDialog(this)) {
// Can't restore a deleted palette
_pSavePalette = nullptr;
killBackground();
close();
}
}
break;
// Quit
case BKEY_ALT_F4:
case BKEY_ALT_q: {
pApp = CBagel::getBagApp();
if (pApp != nullptr) {
pWin = pApp->getMasterWnd();
if ((pWin != nullptr) && pWin->showQuitDialog(this)) {
_nReturnValue = 0;
killBackground();
close();
}
}
break;
}
// Close
case BKEY_ESC:
close();
break;
default:
CBofDialog::onKeyHit(lKey, lRepCount);
break;
}
}
const char *buildSysDir(const char *pszFile) {
assert(pszFile != nullptr);
static char szBuf[MAX_DIRPATH];
// Get the path to the system directory
Common::sprintf_s(szBuf, "$SBARDIR%sGENERAL%sSYSTEM%s%s", PATH_DELIMETER, PATH_DELIMETER, PATH_DELIMETER, pszFile);
CBofString cTemp(szBuf, MAX_DIRPATH);
fixPathName(cTemp);
return &szBuf[0];
}
} // namespace SpaceBar
} // namespace Bagel

View File

@@ -0,0 +1,109 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BAGEL_DIALOGS_OPT_WINDOW_H
#define BAGEL_DIALOGS_OPT_WINDOW_H
#include "bagel/spacebar/boflib/gui/dialog.h"
#include "bagel/spacebar/boflib/gui/button.h"
#include "bagel/spacebar/boflib/gui/scroll_bar.h"
#include "bagel/spacebar/boflib/gui/text_box.h"
namespace Bagel {
namespace SpaceBar {
struct SYSTEM_DATA {
int _nMusicVolume;
int _nSoundVolume;
bool _bFlythroughs;
bool _bPanimations;
int _nCorrection;
int _nPanSpeed;
};
#define NUM_SYS_BUTTONS 8
class CBagOptWindow : public CBofDialog {
public:
CBagOptWindow();
virtual ErrorCode attach();
virtual ErrorCode detach();
/**
* Get the system settings from CBofApp.
*/
void loadIniSettings();
/**
* Save Out New Settings to the ini file of the App.
*/
void saveOutNewSettings();
/**
* Change Settings to the defaults
*/
void returnToDefaults();
/**
* Changes the states of buttons & controls to reflect the current variable values.
*/
void putDialogData();
/**
* Changes the current variable values to reflect the states of buttons & controls.
*/
void getDialogData();
protected:
void onPaint(CBofRect *pRect) override;
void onInitDialog() override;
void onBofScrollBar(CBofObject *pObject, int nPos) override;
void onBofButton(CBofObject *pObject, int nState) override;
void onKeyHit(uint32 lKey, uint32 lRepCount) override;
// Data members
//
CBofBmpButton *_pButtons[NUM_SYS_BUTTONS];
SYSTEM_DATA _cSystemData;
ST_COLORSCHEME _cColorScheme;
CBofCheckButton *_pFlythroughs;
CBofCheckButton *_pPanimations;
CBofScrollBar *_pMidiVolumeScroll;
CBofScrollBar *_pWaveVolumeScroll;
CBofScrollBar *_pCorrectionScroll;
CBofScrollBar *_pPanSpeedScroll;
CBofPalette *_pSavePalette;
bool _bDirty;
};
const char *buildSysDir(const char *pszFile);
} // namespace SpaceBar
} // namespace Bagel
#endif

View File

@@ -0,0 +1,168 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "bagel/spacebar/dialogs/quit_dialog.h"
#include "bagel/spacebar/dialogs/opt_window.h"
#include "bagel/spacebar/baglib/cursor.h"
#include "bagel/spacebar/baglib/button_object.h"
#include "bagel/spacebar/baglib/bagel.h"
#include "bagel/spacebar/baglib/master_win.h"
#include "bagel/spacebar/boflib/std_keys.h"
namespace Bagel {
namespace SpaceBar {
struct ST_BUTTONS {
const char *_pszName;
const char *_pszUp;
const char *_pszDown;
const char *_pszFocus;
const char *_pszDisabled;
int _nLeft;
int _nTop;
int _nWidth;
int _nHeight;
int _nID;
};
static const ST_BUTTONS g_stQuitButtons[NUM_QUIT_BUTTONS] = {
{ "Save", "SAVEQTUP.BMP", "SAVEQTDN.BMP", "SAVEQTUP.BMP", "SAVEQTUP.BMP", 220, 190, 200, 38, SAVE_BTN },
{ "Quit", "JUSTQTUP.BMP", "JUSTQTDN.BMP", "JUSTQTUP.BMP", "JUSTQTUP.BMP", 220, 237, 200, 38, QUIT_BTN },
{ "Cancel", "PLAYUP.BMP", "PLAYDN.BMP", "PLAYUP.BMP", "PLAYUP.BMP", 220, 284, 200, 38, CANCEL_BTN }
};
CBagQuitDialog::CBagQuitDialog() {
// Inits
_nReturnValue = -1;
for (int i = 0; i < NUM_QUIT_BUTTONS; i++) {
_pButtons[i] = nullptr;
}
}
void CBagQuitDialog::onInitDialog() {
assert(isValidObject(this));
CBofDialog::onInitDialog();
setReturnValue(-1);
if (_pBackdrop == nullptr)
fatalError(ERR_UNKNOWN, "Unexpected null value found in _paBackdrop");
CBofPalette *pPal = _pBackdrop->getPalette();
selectPalette(pPal);
// Paint the SaveList Box onto the background
CBofBitmap cBmp(buildSysDir("QUITDBOX.BMP"), pPal);
cBmp.paint(_pBackdrop, 205, 150);
// Build all our buttons
for (int i = 0; i < NUM_QUIT_BUTTONS; i++) {
assert(_pButtons[i] == nullptr);
_pButtons[i] = new CBofBmpButton;
CBofBitmap *pUp = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszUp), pPal);
CBofBitmap *pDown = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszDown), pPal);
CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszFocus), pPal);
CBofBitmap *pDis = loadBitmap(buildSysDir(g_stQuitButtons[i]._pszDisabled), pPal);
_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
_pButtons[i]->create(g_stQuitButtons[i]._pszName, g_stQuitButtons[i]._nLeft, g_stQuitButtons[i]._nTop, g_stQuitButtons[i]._nWidth, g_stQuitButtons[i]._nHeight, this, g_stQuitButtons[i]._nID);
_pButtons[i]->show();
}
// Show System cursor
CBagCursor::showSystemCursor();
}
void CBagQuitDialog::onClose() {
assert(isValidObject(this));
CBagCursor::hideSystemCursor();
// Destroy all buttons
for (int i = 0; i < NUM_QUIT_BUTTONS; i++) {
delete _pButtons[i];
_pButtons[i] = nullptr;
}
if (_nReturnValue == QUIT_BTN || _nReturnValue == SAVE_BTN)
killBackground();
CBofDialog::onClose();
}
void CBagQuitDialog::onPaint(CBofRect *pRect) {
assert(isValidObject(this));
paintBackdrop(pRect);
validateAnscestors();
}
void CBagQuitDialog::onKeyHit(uint32 lKey, uint32 nRepCount) {
assert(isValidObject(this));
if (lKey == BKEY_ESC) {
// Cancel
//
setReturnValue(CANCEL_BTN);
close();
} else
CBofDialog::onKeyHit(lKey, nRepCount);
}
void CBagQuitDialog::onBofButton(CBofObject *pObject, int nFlags) {
assert(isValidObject(this));
assert(pObject != nullptr);
if (nFlags != BUTTON_CLICKED)
return;
CBofBmpButton *pButton = (CBofBmpButton *)pObject;
if (pButton != nullptr) {
int nId = pButton->getControlID();
bool bQuit = true;
if (nId == SAVE_BTN) {
CBagel *pApp = CBagel::getBagApp();
if (pApp != nullptr) {
CBagMasterWin *pWin = pApp->getMasterWnd();
if (pWin != nullptr) {
bQuit = pWin->showSaveDialog(this, false);
}
}
}
if (bQuit) {
setReturnValue(nId);
close();
}
}
}
} // namespace SpaceBar
} // namespace Bagel

View File

@@ -0,0 +1,54 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BAGEL_DIALOGS_QUIT_DIALOG_H
#define BAGEL_DIALOGS_QUIT_DIALOG_H
#include "bagel/spacebar/boflib/gui/dialog.h"
#include "bagel/spacebar/boflib/gui/button.h"
namespace Bagel {
namespace SpaceBar {
#define NUM_QUIT_BUTTONS 3
class CBagQuitDialog : public CBofDialog {
public:
CBagQuitDialog();
virtual void onInitDialog();
protected:
virtual void onPaint(CBofRect *pRect);
virtual void onClose();
virtual void onBofButton(CBofObject *pObject, int nState);
virtual void onKeyHit(uint32 lKey, uint32 lRepCount);
// Data
CBofBmpButton *_pButtons[NUM_QUIT_BUTTONS];
};
} // namespace SpaceBar
} // namespace Bagel
#endif

View File

@@ -0,0 +1,243 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "bagel/spacebar/dialogs/restart_dialog.h"
#include "bagel/spacebar/baglib/bagel.h"
#include "bagel/spacebar/baglib/button_object.h"
#include "bagel/spacebar/baglib/master_win.h"
#include "bagel/spacebar/boflib/std_keys.h"
#include "bagel/spacebar/dialogs/opt_window.h"
#include "bagel/boflib/file_functions.h"
#include "bagel/boflib/log.h"
namespace Bagel {
namespace SpaceBar {
#define LOADING_BMP "$SBARDIR\\GENERAL\\SYSTEM\\LOADING.BMP"
struct ST_BUTTONS {
const char *_pszName;
const char *_pszUp;
const char *_pszDown;
const char *_pszFocus;
const char *_pszDisabled;
int _nLeft;
int _nTop;
int _nWidth;
int _nHeight;
int _nID;
};
static const ST_BUTTONS g_stRestartButtons[NUM_RESTART_BTNS] = {
{ "Yes", "yesup.bmp", "yesdn.bmp", "yesup.bmp", "yesup.bmp", 194, 249, 120, 40, RESTART_BTN },
{ "Cancel", "cancelup.bmp", "canceldn.bmp", "cancelup.bmp", "cancelup.bmp", 324, 249, 120, 40, CANCEL_BTN }
};
CBagRestartDialog::CBagRestartDialog(const char *pszFileName, CBofWindow *pWin)
: CBofDialog(pszFileName, pWin) {
// Inits
_pSavePalette = nullptr;
_nReturnValue = -1;
for (int i = 0; i < NUM_RESTART_BTNS; i++) {
_pButtons[i] = nullptr;
}
}
void CBagRestartDialog::onInitDialog() {
assert(isValidObject(this));
CBofDialog::onInitDialog();
if (_pBackdrop == nullptr)
fatalError(ERR_UNKNOWN, "Unexpected null value found in _paBackdrop");
// Save off the current game's palette
_pSavePalette = CBofApp::getApp()->getPalette();
// Insert ours
CBofPalette *pPal = _pBackdrop->getPalette();
CBofApp::getApp()->setPalette(pPal);
// Paint the SaveList Box onto the background
pPal = _pBackdrop->getPalette();
CBofBitmap cBmp(buildSysDir("RESTDBOX.BMP"), pPal);
cBmp.paint(_pBackdrop, 181, 182);
// Build all our buttons
for (int i = 0; i < NUM_RESTART_BTNS; i++) {
assert(_pButtons[i] == nullptr);
_pButtons[i] = new CBofBmpButton;
CBofBitmap *pUp = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszUp), pPal);
CBofBitmap *pDown = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszDown), pPal);
CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszFocus), pPal);
CBofBitmap *pDis = loadBitmap(buildSysDir(g_stRestartButtons[i]._pszDisabled), pPal);
_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
_pButtons[i]->create(g_stRestartButtons[i]._pszName, g_stRestartButtons[i]._nLeft, g_stRestartButtons[i]._nTop, g_stRestartButtons[i]._nWidth, g_stRestartButtons[i]._nHeight, this, g_stRestartButtons[i]._nID);
_pButtons[i]->show();
}
// Show System cursor
CBagCursor::showSystemCursor();
}
void CBagRestartDialog::onClose() {
assert(isValidObject(this));
CBagCursor::hideSystemCursor();
// Destroy all buttons
for (int i = 0; i < NUM_RESTART_BTNS; i++) {
delete _pButtons[i];
_pButtons[i] = nullptr;
}
CBofDialog::onClose();
if (_nReturnValue != RESTART_BTN) {
CBofApp::getApp()->setPalette(_pSavePalette);
} else {
CBofApp::getApp()->setPalette(nullptr);
}
}
void CBagRestartDialog::onPaint(CBofRect *pRect) {
assert(isValidObject(this));
paintBackdrop(pRect);
validateAnscestors();
}
void CBagRestartDialog::onKeyHit(uint32 lKey, uint32 nRepCount) {
assert(isValidObject(this));
switch (lKey) {
// Start a new game
case BKEY_ENTER: {
CBagel *pApp = CBagel::getBagApp();
if (pApp != nullptr) {
CBagMasterWin *pWin = pApp->getMasterWnd();
if (pWin != nullptr) {
char szBuf[256];
Common::strcpy_s(szBuf, LOADING_BMP);
CBofString cStr(szBuf, 256);
fixPathName(cStr);
CBofRect cRect;
cRect.left = (640 - 180) / 2;
cRect.top = (480 - 50) / 2;
cRect.right = cRect.left + 180 - 1;
cRect.bottom = cRect.top + 50 - 1;
CBofCursor::hide();
paintBitmap(this, cStr, &cRect);
pWin->newGame();
CBofCursor::show();
killBackground();
_nReturnValue = RESTART_BTN;
onClose();
}
}
break;
}
// Cancel
case BKEY_ESC:
close();
break;
default:
CBofDialog::onKeyHit(lKey, nRepCount);
break;
}
}
void CBagRestartDialog::onBofButton(CBofObject *pObject, int nFlags) {
assert(isValidObject(this));
assert(pObject != nullptr);
if (nFlags != BUTTON_CLICKED)
return;
CBofBmpButton *pButton = (CBofBmpButton *)pObject;
switch (pButton->getControlID()) {
// Cancel
case CANCEL_BTN: {
close();
break;
}
// Restart a new game
case RESTART_BTN: {
CBagel *pApp = CBagel::getBagApp();
if (pApp != nullptr) {
CBagMasterWin *pWin = pApp->getMasterWnd();
if (pWin != nullptr) {
char szBuf[256];
Common::strcpy_s(szBuf, LOADING_BMP);
CBofString cStr(szBuf, 256);
fixPathName(cStr);
CBofRect cRect;
cRect.left = (640 - 180) / 2;
cRect.top = (480 - 50) / 2;
cRect.right = cRect.left + 180 - 1;
cRect.bottom = cRect.top + 50 - 1;
CBofCursor::hide();
paintBitmap(this, cStr, &cRect);
pWin->newGame();
CBofCursor::show();
killBackground();
_nReturnValue = RESTART_BTN;
onClose();
}
}
break;
}
default:
logWarning(buildString("Restart/Restore: Unknown button: %d", pButton->getControlID()));
break;
}
}
} // namespace SpaceBar
} // namespace Bagel

View File

@@ -0,0 +1,56 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BAGEL_DIALOGS_RESTART_DIALOG_H
#define BAGEL_DIALOGS_RESTART_DIALOG_H
#include "bagel/spacebar/boflib/gui/button.h"
#include "bagel/spacebar/boflib/gui/text_box.h"
#include "bagel/spacebar/dialogs/save_dialog.h"
namespace Bagel {
namespace SpaceBar {
#define NUM_RESTART_BTNS 2
class CBagRestartDialog : public CBofDialog {
public:
CBagRestartDialog(const char *pszFileName, CBofWindow *pWin);
virtual void onInitDialog();
protected:
virtual void onPaint(CBofRect *pRect);
virtual void onClose();
virtual void onBofButton(CBofObject *pObject, int nState);
virtual void onKeyHit(uint32 lKey, uint32 lRepCount);
// Data
CBofBmpButton *_pButtons[NUM_RESTART_BTNS];
CBofPalette *_pSavePalette;
};
} // namespace SpaceBar
} // namespace Bagel
#endif

View File

@@ -0,0 +1,427 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "bagel/spacebar/dialogs/restore_dialog.h"
#include "bagel/spacebar/dialogs/save_dialog.h"
#include "bagel/spacebar/baglib/bagel.h"
#include "bagel/spacebar/baglib/button_object.h"
#include "bagel/boflib/sound.h"
#include "bagel/spacebar/dialogs/opt_window.h"
#include "bagel/bagel.h"
#include "bagel/boflib/log.h"
#include "bagel/spacebar/boflib/std_keys.h"
namespace Bagel {
namespace SpaceBar {
#define DIALOG_WIDTH 640
#define DIALOG_HEIGHT 480
// Edit Text control placement
//
#define EDIT_DX 330
#define EDIT_DY 20
#define EDIT_X 154 //((DIALOG_WIDTH - EDIT_DX) / 2)
#define EDIT_Y 405
// List box placement
//
#define LIST_DX EDIT_DX
#define LIST_DY 200 //248
#define LIST_X 155 //((DIALOG_WIDTH - LIST_DX) / 2)
#define LIST_Y 72
#define LIST_TEXT_DY EDIT_DY
#define LIST_FONT_SIZE 12
struct ST_BUTTONS {
const char *_pszName;
const char *_pszUp;
const char *_pszDown;
const char *_pszFocus;
const char *_pszDisabled;
int _nLeft;
int _nTop;
int _nWidth;
int _nHeight;
int _nID;
};
static const ST_BUTTONS g_stButtons[NUM_RESTORE_BTNS] = {
{ "Restore", "restorup.bmp", "restordn.bmp", "restorgr.bmp", "restorgr.bmp", 21, 400, 120, 40, RESTORE_BTN},
{ "Cancel", "cancelup.bmp", "canceldn.bmp", "cancelup.bmp", "cancelup.bmp", 495, 400, 120, 40, CANCEL_BTN},
{ "LineUp", "lineupup.bmp", "lineupdn.bmp", "lineupup.bmp", "lineupgr.bmp", 490, 50, 25, 25, LINEUP_BTN},
{ "LineDn", "linednup.bmp", "linedndn.bmp", "linednup.bmp", "linedngr.bmp", 490, 250, 25, 25, LINEDN_BTN},
{ "PageUp", "pageupup.bmp", "pageupdn.bmp", "pageupup.bmp", "pageupgr.bmp", 490, 80, 25, 25, PAGEUP_BTN},
{ "PageDn", "pagednup.bmp", "pagedndn.bmp", "pagednup.bmp", "pagedngr.bmp", 490, 215, 25, 25, PAGEDN_BTN}
};
extern CBofWindow *g_hackWindow;
extern int g_nSelectedSlot;
CBagRestoreDialog::CBagRestoreDialog() {
logInfo("Constructing CBagRestoreDialog");
Common::fill(_pButtons, _pButtons + NUM_RESTORE_BTNS, (CBofBmpButton *)nullptr);
g_nSelectedSlot = -1;
}
ErrorCode CBagRestoreDialog::attach() {
assert(isValidObject(this));
_bRestored = false;
_nSelectedItem = g_nSelectedSlot;
// Save off the current game's palette
_pSavePalette = CBofApp::getApp()->getPalette();
CBofPalette *pPal = nullptr;
// Insert ours
if (_pBackdrop != nullptr) {
pPal = _pBackdrop->getPalette();
CBofApp::getApp()->setPalette(pPal);
}
// Paint the SaveList Box onto the background
if (_pBackdrop != nullptr) {
CBofBitmap cBmp(buildSysDir("SAVELIST.BMP"), pPal);
cBmp.paint(_pBackdrop, 153, 50);
}
if (_pBackdrop != nullptr) {
CBofBitmap cBmp(buildSysDir("TYPESAVE.BMP"), pPal);
cBmp.paint(_pBackdrop, 152, 400);
}
// Build all our buttons
for (int i = 0; i < NUM_RESTORE_BTNS; i++) {
assert(_pButtons[i] == nullptr);
_pButtons[i] = new CBofBmpButton;
CBofBitmap *pUp = loadBitmap(buildSysDir(g_stButtons[i]._pszUp), pPal);
CBofBitmap *pDown = loadBitmap(buildSysDir(g_stButtons[i]._pszDown), pPal);
CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stButtons[i]._pszFocus), pPal);
CBofBitmap *pDis = loadBitmap(buildSysDir(g_stButtons[i]._pszDisabled), pPal);
_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
_pButtons[i]->create(g_stButtons[i]._pszName, g_stButtons[i]._nLeft, g_stButtons[i]._nTop, g_stButtons[i]._nWidth, g_stButtons[i]._nHeight, this, g_stButtons[i]._nID);
_pButtons[i]->show();
}
if (_nSelectedItem == -1) {
_pButtons[0]->setState(BUTTON_DISABLED);
}
// Get a list of saves, and filter out the autosave entry if present
// (we don't show the autosave slot in the original UI)
_savesList = g_engine->listSaves();
int nNumSavedGames = 0;
for (SaveStateList::iterator it = _savesList.begin(); it != _savesList.end();) {
if (it->isAutosave()) {
it = _savesList.erase(it);
} else {
nNumSavedGames = MAX(nNumSavedGames, it->getSaveSlot());
it++;
}
}
// The list box must not be currently allocated
if (_pListBox != nullptr)
fatalError(ERR_UNKNOWN, "Unexpected value found in _pListBox");
// Create a list box for the user to choose the slot to save into
CBofRect cRect(LIST_X, LIST_Y, LIST_X + LIST_DX - 1, LIST_Y + LIST_DY - 1);
_pListBox = new CBofListBox();
_pListBox->create("SaveGameList", &cRect, this);
_pListBox->setPointSize(LIST_FONT_SIZE);
_pListBox->setItemHeight(LIST_TEXT_DY);
// Set a color for selection highlighting
if (_pBackdrop != nullptr) {
CBofPalette *pPal2 = _pBackdrop->getPalette();
byte iPalIdx = pPal2->getNearestIndex(RGB(255, 0, 0));
_pListBox->setHighlightColor(pPal2->getColor(iPalIdx));
}
// Fill the list box with save game entries
for (int i = 0; i < nNumSavedGames; i++) {
Common::String desc = "Empty";
for (const auto &entry : _savesList) {
if (entry.getSaveSlot() == (i + 1)) {
desc = entry.getDescription();
break;
}
}
_pListBox->addToTail(desc.c_str(), false);
}
// Must be a valid item by now
if (_nSelectedItem != -1) {
_pListBox->setSelectedItem(_nSelectedItem, false);
}
_pListBox->show();
_pListBox->updateWindow();
if (!errorOccurred()) {
// There could not already be a text field
assert(_pText == nullptr);
_pText = new CBofText;
cRect.setRect(170, 405, 470, 435);
_pText->setupText(&cRect, JUSTIFY_LEFT, FORMAT_CENTER_LEFT);
_pText->SetSize(16);
_pText->setWeight(TEXT_BOLD);
// Set initial selected item
if (_nSelectedItem != -1) {
_pText->setText(_pListBox->getText(_nSelectedItem));
} else {
_pText->setText("");
}
}
CBagCursor::showSystemCursor();
return _errCode;
}
ErrorCode CBagRestoreDialog::detach() {
assert(isValidObject(this));
CBagCursor::hideSystemCursor();
delete _pText;
_pText = nullptr;
delete _pScrollBar;
_pScrollBar = nullptr;
delete _pListBox;
_pListBox = nullptr;
// Destroy all buttons
for (int i = 0; i < NUM_RESTORE_BTNS; i++) {
delete _pButtons[i];
_pButtons[i] = nullptr;
}
_nSelectedItem = -1;
CBofApp::getApp()->setPalette(_pSavePalette);
return _errCode;
}
void CBagRestoreDialog::onPaint(CBofRect *pRect) {
assert(isValidObject(this));
paintBackdrop(pRect);
if (_pListBox != nullptr) {
_pListBox->repaintAll();
}
if (_pText != nullptr) {
_pText->display(this);
}
validateAnscestors();
}
ErrorCode CBagRestoreDialog::RestoreAndclose() {
assert(isValidObject(this));
if (!errorOccurred()) {
// We should not be able to access the save button if we
// have not yet chosen a slot to save into.
assert(_nSelectedItem != -1);
if (_nSelectedItem != -1) {
logInfo(buildString("Restoring from slot #%d", _nSelectedItem));
g_nSelectedSlot = _nSelectedItem;
// If we are restoring a game, then we don't need to repaint
// the background, because the screen is changing to a restored state.
killBackground();
close();
// Restore
if (g_engine->loadGameState(_nSelectedItem + 1).getCode() == Common::kNoError) {
_bRestored = true;
}
}
}
return _errCode;
}
void CBagRestoreDialog::onKeyHit(uint32 lKey, uint32 nRepCount) {
assert(isValidObject(this));
switch (lKey) {
case BKEY_UP:
if (_pListBox != nullptr) {
_pListBox->lineUp();
}
break;
case BKEY_DOWN:
if (_pListBox != nullptr) {
_pListBox->lineDown();
}
break;
case BKEY_PAGEUP:
if (_pListBox != nullptr) {
_pListBox->pageUp();
}
break;
case BKEY_PAGEDOWN:
if (_pListBox != nullptr) {
_pListBox->pageDown();
}
break;
// Save into current slot, and exit
case BKEY_ENTER:
if (_nSelectedItem != -1)
RestoreAndclose();
break;
// Cancel without saving
case BKEY_ESC:
close();
break;
default:
CBofDialog::onKeyHit(lKey, nRepCount);
break;
}
}
void CBagRestoreDialog::onBofButton(CBofObject *pObject, int nFlags) {
assert(isValidObject(this));
assert(pObject != nullptr);
if (nFlags != BUTTON_CLICKED)
return;
CBofBmpButton *pButton = (CBofBmpButton *)pObject;
switch (pButton->getControlID()) {
// Do actual save
case RESTORE_BTN:
RestoreAndclose();
break;
// Cancel without saving
case CANCEL_BTN:
close();
break;
case LINEUP_BTN:
if (_pListBox != nullptr) {
_pListBox->lineUp();
}
break;
case LINEDN_BTN:
if (_pListBox != nullptr) {
_pListBox->lineDown();
}
break;
case PAGEUP_BTN:
if (_pListBox != nullptr) {
_pListBox->pageUp();
}
break;
case PAGEDN_BTN:
if (_pListBox != nullptr) {
_pListBox->pageDown();
}
break;
default:
logWarning(buildString("Save/Restore: Unknown button: %d", pButton->getControlID()));
break;
}
}
void CBagRestoreDialog::onBofListBox(CBofObject *pObject, int nItemIndex) {
assert(isValidObject(this));
assert(pObject != nullptr);
CBofListBox *pListBox = (CBofListBox *)pObject;
// There is only one list box on this dialog
if (_pListBox != nullptr) {
// Force item to be highlighted
_pListBox->repaintAll();
// Show selected item in the Edit control
if (_pText != nullptr) {
_pText->setText(_pListBox->getText(nItemIndex));
_pText->display(this);
}
_nSelectedItem = nItemIndex;
}
if (_nSelectedItem != -1) {
if ((_pButtons[0] != nullptr) && (_pButtons[0]->getState() == BUTTON_DISABLED)) {
_pButtons[0]->setState(BUTTON_UP, true);
}
// If user double-clicked on this entry, then just restore it now
if (pListBox->getState() == LISTBOX_USENOW) {
RestoreAndclose();
}
} else if ((_pButtons[0] != nullptr) && (_pButtons[0]->getState() != BUTTON_DISABLED)) {
_pButtons[0]->setState(BUTTON_DISABLED, true);
}
}
void CBagRestoreDialog::onInitDialog() {
assert(isValidObject(this));
CBofDialog::onInitDialog();
attach();
}
} // namespace SpaceBar
} // namespace Bagel

View File

@@ -0,0 +1,87 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BAGEL_DIALOGS_RESTORE_DIALOG_H
#define BAGEL_DIALOGS_RESTORE_DIALOG_H
#include "bagel/bagel.h"
#include "bagel/spacebar/boflib/gui/list_box.h"
#include "bagel/spacebar/boflib/gui/scroll_bar.h"
#include "bagel/spacebar/boflib/gui/button.h"
#include "bagel/spacebar/boflib/gui/text_box.h"
#include "bagel/spacebar/dialogs/save_dialog.h"
namespace Bagel {
namespace SpaceBar {
#define NUM_RESTORE_BTNS 6
class CBagRestoreDialog : public CBofDialog {
private:
ErrorCode RestoreAndclose();
CBofBmpButton *_pButtons[NUM_RESTORE_BTNS];
CBofScrollBar *_pScrollBar = nullptr;
CBofText *_pText = nullptr;
CBofListBox *_pListBox = nullptr;
int _nSelectedItem = -1;
StBagelSave *_pSaveBuf = nullptr;
int _nBufSize = 0;
bool _bRestored = false;
CBofPalette *_pSavePalette = nullptr;
SaveStateList _savesList;
protected:
void onPaint(CBofRect *pRect) override;
void onBofButton(CBofObject *pObject, int nState) override;
void onBofListBox(CBofObject *pObject, int nItemIndex) override;
void onKeyHit(uint32 lKey, uint32 lRepCount) override;
public:
CBagRestoreDialog();
virtual ErrorCode attach();
virtual ErrorCode detach();
StBagelSave *getSaveGameBuffer(int &nLength) {
nLength = _nBufSize;
return _pSaveBuf;
}
void setSaveGameBuffer(StBagelSave *pBuf, int nLength) {
_pSaveBuf = pBuf;
_nBufSize = nLength;
}
bool restored() {
return _bRestored;
}
void onInitDialog() override;
};
} // namespace SpaceBar
} // namespace Bagel
#endif

View File

@@ -0,0 +1,411 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "bagel/spacebar/dialogs/save_dialog.h"
#include "bagel/spacebar/baglib/bagel.h"
#include "bagel/spacebar/baglib/button_object.h"
#include "bagel/bagel.h"
#include "bagel/boflib/log.h"
#include "bagel/spacebar/boflib/std_keys.h"
namespace Bagel {
namespace SpaceBar {
const char *buildSysDir(const char *pszFile);
#define DIALOG_WIDTH 640
#define DIALOG_HEIGHT 480
// Edit Text control placement
//
#define EDIT_DX 326
#define EDIT_DY 20
#define EDIT_X 156 //((DIALOG_WIDTH - EDIT_DX) / 2)
#define EDIT_Y 409
// List box placement
//
#define LIST_DX EDIT_DX
#define LIST_DY 200 //248
#define LIST_X 155 //((DIALOG_WIDTH - LIST_DX) / 2)
#define LIST_Y 72
#define LIST_TEXT_DY EDIT_DY
#define LIST_FONT_SIZE 12
struct ST_BUTTONS {
const char *_name;
const char *_up;
const char *_down;
const char *_focus;
const char *_disabled;
int _left;
int _top;
int _width;
int _height;
int _id;
};
static const ST_BUTTONS g_stButtons[NUM_BUTTONS] = {
{ "Save", "saveup.bmp", "savedn.bmp", "savegr.bmp", "savegr.bmp", 21, 400, 120, 40, SAVE_BTN },
{ "Cancel", "cancelup.bmp", "canceldn.bmp", "cancelup.bmp", "cancelup.bmp", 495, 400, 120, 40, CANCEL_BTN },
{ "LineUp", "lineupup.bmp", "lineupdn.bmp", "lineupup.bmp", "lineupgr.bmp", 490, 50, 25, 25, LINEUP_BTN },
{ "LineDn", "linednup.bmp", "linedndn.bmp", "linednup.bmp", "linedngr.bmp", 490, 250, 25, 25, LINEDN_BTN },
{ "PageUp", "pageupup.bmp", "pageupdn.bmp", "pageupup.bmp", "pageupgr.bmp", 490, 80, 25, 25, PAGEUP_BTN },
{ "PageDn", "pagednup.bmp", "pagedndn.bmp", "pagednup.bmp", "pagedngr.bmp", 490, 215, 25, 25, PAGEDN_BTN }
};
// Globals
int g_nSelectedSlot;
CBagSaveDialog::CBagSaveDialog() {
logInfo("Constructing CBagSaveDialog");
g_nSelectedSlot = -1;
_pListBox = nullptr;
_pEditText = nullptr;
_pScrollBar = nullptr;
_nSelectedItem = -1;
_pSaveBuf = nullptr;
_nBufSize = 0;
_pSavePalette = nullptr;
for (int i = 0; i < NUM_BUTTONS; i++) {
_pButtons[i] = nullptr;
}
}
ErrorCode CBagSaveDialog::attach() {
assert(isValidObject(this));
g_engine->enableKeymapper(false);
// Save off the current game's palette
_pSavePalette = CBofApp::getApp()->getPalette();
CBofPalette *pPal = nullptr;
// Insert ours
if (_pBackdrop != nullptr) {
pPal = _pBackdrop->getPalette();
CBofApp::getApp()->setPalette(pPal);
}
// Paint the SaveList Box onto the background
if (_pBackdrop != nullptr) {
CBofBitmap cBmp(buildSysDir("SAVELIST.BMP"), pPal);
cBmp.paint(_pBackdrop, 153, 50);
}
if (_pBackdrop != nullptr) {
CBofBitmap cBmp(buildSysDir("TYPESAVE.BMP"), pPal);
cBmp.paint(_pBackdrop, 152, 400);
}
// Build all our buttons
for (int i = 0; i < NUM_BUTTONS; i++) {
assert(_pButtons[i] == nullptr);
_pButtons[i] = new CBofBmpButton;
CBofBitmap *pUp = loadBitmap(buildSysDir(g_stButtons[i]._up), pPal);
CBofBitmap *pDown = loadBitmap(buildSysDir(g_stButtons[i]._down), pPal);
CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stButtons[i]._focus), pPal);
CBofBitmap *pDis = loadBitmap(buildSysDir(g_stButtons[i]._disabled), pPal);
_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
_pButtons[i]->create(g_stButtons[i]._name, g_stButtons[i]._left, g_stButtons[i]._top, g_stButtons[i]._width, g_stButtons[i]._height, this, g_stButtons[i]._id);
_pButtons[i]->show();
}
// The edit text control must not be currently allocated
assert(_pEditText == nullptr);
_pEditText = new CBofEditText("", EDIT_X, EDIT_Y, EDIT_DX, EDIT_DY, this);
_pEditText->setText("");
_pEditText->show();
// Get a list of saves, and filter out the autosave entry if present
// (we don't show the autosave slot in the original UI)
_savesList = g_engine->listSaves();
for (SaveStateList::iterator it = _savesList.begin(); it != _savesList.end(); ++it) {
if (it->isAutosave()) {
_savesList.erase(it);
break;
}
}
// The list box must not be currently allocated
assert(_pListBox == nullptr);
// Create a list box for the user to choose the slot to save into
_pListBox = new CBofListBox();
CBofRect cRect(LIST_X, LIST_Y, LIST_X + LIST_DX - 1, LIST_Y + LIST_DY - 1);
_pListBox->create("SaveGameList", &cRect, this);
_pListBox->setPointSize(LIST_FONT_SIZE);
_pListBox->setItemHeight(LIST_TEXT_DY);
// Set a color for selection highlighting
if (_pBackdrop != nullptr) {
CBofPalette *pPal2 = _pBackdrop->getPalette();
byte iPalIdx = pPal2->getNearestIndex(RGB(255, 0, 0));
_pListBox->setHighlightColor(pPal2->getColor(iPalIdx));
}
// Fill the list box with save game entries
for (int i = 0; i < MAX_SAVED_GAMES; i++) {
char title[MAX_SAVE_TITLE];
Common::strcpy_s(title, "Empty"); // Default empty string
for (const auto &entry : _savesList) {
if (entry.getSaveSlot() == (i + 1)) {
Common::String desc = entry.getDescription();
Common::strcpy_s(title, desc.c_str());
if (_nSelectedItem == -1) {
_nSelectedItem = i;
_pEditText->setText(desc.c_str());
}
break;
}
}
_pListBox->addToTail(title, false);
}
_pListBox->show();
_pListBox->updateWindow();
if (_nSelectedItem != -1) {
_pEditText->setFocus();
_pListBox->setSelectedItem(_nSelectedItem, false);
if (_nSelectedItem >= 9) {
_pListBox->scrollTo(_nSelectedItem - 8);
}
} else if (_pButtons[0] != nullptr) {
_pButtons[0]->setState(BUTTON_DISABLED);
}
CBagCursor::showSystemCursor();
return _errCode;
}
ErrorCode CBagSaveDialog::detach() {
assert(isValidObject(this));
g_engine->enableKeymapper(true);
CBagCursor::hideSystemCursor();
delete _pScrollBar;
_pScrollBar = nullptr;
delete _pEditText;
_pEditText = nullptr;
delete _pListBox;
_pListBox = nullptr;
// Destroy all buttons
for (int i = 0; i < NUM_BUTTONS; i++) {
delete _pButtons[i];
_pButtons[i] = nullptr;
}
_nSelectedItem = -1;
// Restore the saved palette
CBofApp::getApp()->setPalette(_pSavePalette);
return _errCode;
}
void CBagSaveDialog::onPaint(CBofRect *pRect) {
assert(isValidObject(this));
paintBackdrop(pRect);
if (_pListBox != nullptr) {
_pListBox->repaintAll();
}
validateAnscestors();
}
void CBagSaveDialog::saveAndClose() {
assert(isValidObject(this));
// We should not be able to access the save button if we
// have not yet chosen a slot to save into.
assert(_nSelectedItem != -1);
if (_nSelectedItem != -1) {
logInfo(buildString("Saving into slot #%d", _nSelectedItem));
g_nSelectedSlot = _nSelectedItem;
// Save the game
g_engine->saveGameState(_nSelectedItem + 1,
_pEditText->getText().getBuffer());
close();
setReturnValue(SAVE_BTN);
}
}
void CBagSaveDialog::onKeyHit(uint32 lKey, uint32 nRepCount) {
assert(isValidObject(this));
switch (lKey) {
case BKEY_UP:
if (_pListBox != nullptr) {
_pListBox->lineUp();
}
break;
case BKEY_DOWN:
if (_pListBox != nullptr) {
_pListBox->lineDown();
}
break;
case BKEY_PAGEUP:
if (_pListBox != nullptr) {
_pListBox->pageUp();
}
break;
case BKEY_PAGEDOWN:
if (_pListBox != nullptr) {
_pListBox->pageDown();
}
break;
// Save into current slot, and exit
case BKEY_ENTER:
saveAndClose();
break;
// Cancel without saving
case BKEY_ESC:
setReturnValue(CANCEL_BTN);
close();
break;
default:
CBofDialog::onKeyHit(lKey, nRepCount);
break;
}
}
void CBagSaveDialog::onBofButton(CBofObject *pObject, int nFlags) {
assert(isValidObject(this));
assert(pObject != nullptr);
if (nFlags != BUTTON_CLICKED)
return;
CBofBmpButton *pButton = (CBofBmpButton *)pObject;
switch (pButton->getControlID()) {
// Do actual save
case SAVE_BTN:
setReturnValue(SAVE_BTN);
saveAndClose();
break;
// Cancel without saving
case CANCEL_BTN:
setReturnValue(CANCEL_BTN);
close();
break;
case LINEUP_BTN:
if (_pListBox != nullptr) {
_pListBox->lineUp();
}
break;
case LINEDN_BTN:
if (_pListBox != nullptr) {
_pListBox->lineDown();
}
break;
case PAGEUP_BTN:
if (_pListBox != nullptr) {
_pListBox->pageUp();
}
break;
case PAGEDN_BTN:
if (_pListBox != nullptr) {
_pListBox->pageDown();
}
break;
default:
logWarning(buildString("Save/Restore: Unknown button: %d", pButton->getControlID()));
break;
}
}
void CBagSaveDialog::onBofListBox(CBofObject * /*pObject*/, int nItemIndex) {
assert(isValidObject(this));
// Reset the focus away from the text field if set
releaseFocus();
// There is only one list box on this dialog
if (_pListBox != nullptr) {
// Force item to be highlighted
_pListBox->repaintAll();
// Show selected item in the Edit control
if (_pEditText != nullptr) {
_pEditText->setFocus();
_pEditText->setText(_pListBox->getText(nItemIndex));
}
_nSelectedItem = nItemIndex;
}
if ((_nSelectedItem != -1) && (_pButtons[0] != nullptr) && (_pButtons[0]->getState() == BUTTON_DISABLED)) {
_pButtons[0]->setState(BUTTON_UP, true);
}
}
void CBagSaveDialog::onInitDialog() {
assert(isValidObject(this));
CBofDialog::onInitDialog();
attach();
}
} // namespace SpaceBar
} // namespace Bagel

View File

@@ -0,0 +1,81 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BAGEL_DIALOGS_SAVE_DIALOG_H
#define BAGEL_DIALOGS_SAVE_DIALOG_H
#include "bagel/spacebar/boflib/gui/dialog.h"
#include "bagel/spacebar/boflib/gui/list_box.h"
#include "bagel/spacebar/boflib/gui/scroll_bar.h"
#include "bagel/spacebar/boflib/gui/button.h"
#include "bagel/spacebar/boflib/gui/edit_text.h"
#include "engines/savestate.h"
namespace Bagel {
namespace SpaceBar {
#define NUM_BUTTONS 6
class CBagSaveDialog : public CBofDialog {
public:
CBagSaveDialog();
virtual ErrorCode attach();
virtual ErrorCode detach();
byte *getSaveGameBuffer(int &nLength) {
nLength = _nBufSize;
return _pSaveBuf;
}
void setSaveGameBuffer(byte *pBuf, int nLength) {
_pSaveBuf = pBuf;
_nBufSize = nLength;
}
void onInitDialog() override;
protected:
void onPaint(CBofRect *pRect) override;
void onBofButton(CBofObject *pObject, int nFlags) override;
void onBofListBox(CBofObject *pObject, int nItemIndex) override;
void onKeyHit(uint32 lKey, uint32 nRepCount) override;
void saveAndClose();
CBofBmpButton *_pButtons[NUM_BUTTONS];
CBofScrollBar *_pScrollBar;
CBofEditText *_pEditText;
CBofListBox *_pListBox;
int _nSelectedItem;
byte *_pSaveBuf;
int _nBufSize;
CBofPalette *_pSavePalette;
SaveStateList _savesList;
};
} // namespace SpaceBar
} // namespace Bagel
#endif

View File

@@ -0,0 +1,165 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "bagel/spacebar/dialogs/start_dialog.h"
#include "bagel/spacebar/baglib/bagel.h"
#include "bagel/spacebar/baglib/button_object.h"
#include "bagel/boflib/sound.h"
#include "bagel/spacebar/dialogs/opt_window.h"
#include "bagel/bagel.h"
#include "bagel/spacebar/boflib/std_keys.h"
namespace Bagel {
namespace SpaceBar {
struct ST_BUTTONS {
const char *_pszName;
const char *_pszUp;
const char *_pszDown;
const char *_pszFocus;
const char *_pszDisabled;
int _nLeft;
int _nTop;
int _nWidth;
int _nHeight;
int _nID;
};
static const ST_BUTTONS g_stStartButtons[NUM_START_BTNS] = {
{ "Restore", "start1up.bmp", "start1dn.bmp", "start1gr.bmp", "start1gr.bmp", 110, 396, 120, 40, RESTORE_BTN },
{ "Restart", "start2up.bmp", "start2dn.bmp", "start2up.bmp", "start2up.bmp", 238, 416, 120, 40, RESTART_BTN },
{ "Quit", "start3up.bmp", "start3dn.bmp", "start3up.bmp", "start3up.bmp", 366, 436, 120, 40, QUIT_BTN }
};
CBagStartDialog::CBagStartDialog(const char *pszFileName, CBofWindow *pWin)
: CBofDialog(pszFileName, pWin) {
// Inits
_lFlags &= ~BOFDLG_SAVEBACKGND;
Common::fill(_buttons, _buttons + NUM_START_BTNS, (CBofBmpButton *)nullptr);
}
void CBagStartDialog::onInitDialog() {
assert(isValidObject(this));
CBofDialog::onInitDialog();
setReturnValue(-1);
// Halt all audio when user dies (and at start of game).
CBofSound::stopSounds();
// Save off the current game's palette
_savePalette = CBofApp::getApp()->getPalette();
// Insert ours
CBofPalette *pPal = _pBackdrop->getPalette();
CBofApp::getApp()->setPalette(pPal);
// Build all our buttons
for (int i = 0; i < NUM_START_BTNS; i++) {
assert(_buttons[i] == nullptr);
_buttons[i] = new CBofBmpButton;
CBofBitmap *pUp = loadBitmap(buildSysDir(g_stStartButtons[i]._pszUp), pPal);
CBofBitmap *pDown = loadBitmap(buildSysDir(g_stStartButtons[i]._pszDown), pPal);
CBofBitmap *pFocus = loadBitmap(buildSysDir(g_stStartButtons[i]._pszFocus), pPal);
CBofBitmap *pDis = loadBitmap(buildSysDir(g_stStartButtons[i]._pszDisabled), pPal);
_buttons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
_buttons[i]->create(g_stStartButtons[i]._pszName, g_stStartButtons[i]._nLeft, g_stStartButtons[i]._nTop, g_stStartButtons[i]._nWidth, g_stStartButtons[i]._nHeight, this, g_stStartButtons[i]._nID);
_buttons[i]->show();
}
// Disable the restore button if there are no saved games
CBagel *pApp = CBagel::getBagApp();
if ((pApp != nullptr) && !g_engine->savesExist())
_buttons[0]->setState(BUTTON_DISABLED);
// Show System cursor
CBagCursor::showSystemCursor();
}
void CBagStartDialog::onClose() {
assert(isValidObject(this));
CBagCursor::hideSystemCursor();
// Destroy all buttons
for (int i = 0; i < NUM_START_BTNS; i++) {
delete _buttons[i];
_buttons[i] = nullptr;
}
killBackground();
CBofDialog::onClose();
}
void CBagStartDialog::onPaint(CBofRect *pRect) {
assert(isValidObject(this));
paintBackdrop(pRect);
validateAnscestors();
}
void CBagStartDialog::onKeyHit(uint32 lKey, uint32 nRepCount) {
assert(isValidObject(this));
if (lKey == BKEY_ESC) {
setReturnValue(QUIT_BTN);
close();
} else {
CBofDialog::onKeyHit(lKey, nRepCount);
}
}
void CBagStartDialog::onBofButton(CBofObject *pObject, int nFlags) {
assert(isValidObject(this));
assert(pObject != nullptr);
if (nFlags != BUTTON_CLICKED)
return;
CBofBmpButton *pButton = (CBofBmpButton *)pObject;
int nId = pButton->getControlID();
if (nId == RESTORE_BTN) {
CBagel *pApp = CBagel::getBagApp();
if (pApp != nullptr) {
CBagMasterWin *pWin = pApp->getMasterWnd();
if ((pWin != nullptr) && pWin->showRestoreDialog(this)) {
close();
}
}
} else {
setReturnValue(nId);
close();
}
}
} // namespace SpaceBar
} // namespace Bagel

View File

@@ -0,0 +1,57 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef BAGEL_DIALOGS_START_DIALOG_H
#define BAGEL_DIALOGS_START_DIALOG_H
#include "bagel/spacebar/boflib/gui/list_box.h"
#include "bagel/spacebar/boflib/gui/button.h"
#include "bagel/spacebar/boflib/gui/text_box.h"
#include "bagel/spacebar/dialogs/save_dialog.h"
namespace Bagel {
namespace SpaceBar {
#define NUM_START_BTNS 3
class CBagStartDialog : public CBofDialog {
private:
CBofBmpButton *_buttons[NUM_START_BTNS];
CBofPalette *_savePalette = nullptr;
protected:
void onPaint(CBofRect *pRect) override;
void onClose() override;
void onBofButton(CBofObject *pObject, int nFlags) override;
void onKeyHit(uint32 lKey, uint32 nRepCount) override;
public:
CBagStartDialog(const char *pszFileName, CBofWindow *pWin);
void onInitDialog() override;
};
} // namespace SpaceBar
} // namespace Bagel
#endif