mirror of https://github.com/stella-emu/stella.git
Added more extensive GUI for cheatcode support, including a checklist
where each cheat can be toggled on or off. Of course, it doesn't actually do anything yet, since it isn't connected to the CheatManager. For now, input of cheats from the GUI is completely disabled. Commandline should still work, though. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@894 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
49955806d8
commit
8e5cb83f60
|
@ -13,53 +13,78 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: CheatCodeDialog.cxx,v 1.2 2005-11-13 03:55:24 stephena Exp $
|
||||
// $Id: CheatCodeDialog.cxx,v 1.3 2005-11-26 21:23:35 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
//============================================================================
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "OSystem.hxx"
|
||||
#include "Props.hxx"
|
||||
#include "Widget.hxx"
|
||||
#include "Dialog.hxx"
|
||||
#include "CheatCodeDialog.hxx"
|
||||
#include "GuiUtils.hxx"
|
||||
#include "CheckListWidget.hxx"
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
||||
/*
|
||||
enum {
|
||||
kEnableCheat = 'ENAC',
|
||||
kLoadCmd = 'LDCH'
|
||||
kAddCheatCmd = 'CHTA',
|
||||
kEditCheatCmd = 'CHTE',
|
||||
kRemCheatCmd = 'CHTR',
|
||||
kAddOneShotCmd = 'CHTO'
|
||||
};
|
||||
*/
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CheatCodeDialog::CheatCodeDialog(OSystem* osystem, DialogContainer* parent,
|
||||
int x, int y, int w, int h)
|
||||
: Dialog(osystem, parent, x, y, w, h),
|
||||
myErrorFlag(false)
|
||||
: Dialog(osystem, parent, x, y, w, h)
|
||||
{
|
||||
const GUI::Font& font = instance()->font();
|
||||
const int fontHeight = font.getFontHeight(),
|
||||
lwidth = font.getMaxCharWidth() * 8;
|
||||
int xpos, ypos;
|
||||
|
||||
// List of cheats, with checkboxes to enable/disable
|
||||
xpos = 10; ypos = 10;
|
||||
myCheatList = new CheckListWidget(this, font, xpos, ypos,
|
||||
_w - 25 - kButtonWidth, _h - 50);
|
||||
myCheatList->setStyle(kXFill);
|
||||
myCheatList->setEditable(false);
|
||||
myCheatList->setFlags(WIDGET_NODRAW_FOCUS);
|
||||
addFocusWidget(myCheatList);
|
||||
|
||||
xpos += myCheatList->getWidth() + 15; ypos = 15;
|
||||
addButton(xpos, ypos, "Add", kAddCheatCmd, 0);
|
||||
addButton(xpos, ypos+=20, "Edit", kEditCheatCmd, 0);
|
||||
addButton(xpos, ypos+=20, "Remove", kRemCheatCmd, 0);
|
||||
addButton(xpos, ypos+=30, "One shot", kAddOneShotCmd, 0);
|
||||
|
||||
/*
|
||||
Move this to new dialog
|
||||
xpos = 10; ypos = 10 + myCheatList->getHeight() + 10;
|
||||
myTitle = new StaticTextWidget(this, xpos, ypos, lwidth, fontHeight,
|
||||
"Cheat Code", kTextAlignLeft);
|
||||
|
||||
xpos += myTitle->getWidth();
|
||||
myInput = new EditTextWidget(this, xpos, ypos-1, 48, fontHeight, "");
|
||||
addFocusWidget(myInput);
|
||||
|
||||
xpos = 10; ypos += fontHeight + 5;
|
||||
myError = new StaticTextWidget(this, xpos, ypos, lwidth, kFontHeight,
|
||||
"", kTextAlignLeft);
|
||||
myError->setColor(kTextColorEm);
|
||||
*/
|
||||
|
||||
// addButton(w - (kButtonWidth + 10), 5, "Close", kCloseCmd, 'C');
|
||||
|
||||
// Add OK and Cancel buttons
|
||||
#ifndef MAC_OSX
|
||||
addButton(_w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd, 0);
|
||||
addButton(_w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
|
||||
#else
|
||||
addButton(_w - 2 * (kButtonWidth + 7), _h - 24, "Cancel", kCloseCmd, 0);
|
||||
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -70,6 +95,45 @@ CheatCodeDialog::~CheatCodeDialog()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CheatCodeDialog::loadConfig()
|
||||
{
|
||||
// FIXME - connect to CheatManager
|
||||
StringList l;
|
||||
BoolArray b;
|
||||
|
||||
ostringstream buf;
|
||||
for(int i = 0; i < 10; ++i)
|
||||
{
|
||||
buf << "Line " << i+1;
|
||||
l.push_back(buf.str());
|
||||
b.push_back(bool(i % 2));
|
||||
buf.str("");
|
||||
}
|
||||
myCheatList->setList(l, b);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CheatCodeDialog::saveConfig()
|
||||
{
|
||||
// FIXME - connect to CheatManager
|
||||
for(int i = 0; i < 10; ++i)
|
||||
cerr << "Cheat " << i << ": " << myCheatList->getState(i) << endl;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CheatCodeDialog::addCheat()
|
||||
{
|
||||
cerr << "CheatCodeDialog::addCheat()\n";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CheatCodeDialog::editCheat(int cheatNumber)
|
||||
{
|
||||
cerr << "CheatCodeDialog::editCheat() " << cheatNumber << endl;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CheatCodeDialog::removeCheat(int cheatNumber)
|
||||
{
|
||||
cerr << "CheatCodeDialog::removeCheat() " << cheatNumber << endl;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -78,6 +142,36 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
{
|
||||
switch(cmd)
|
||||
{
|
||||
case kOKCmd:
|
||||
saveConfig();
|
||||
close();
|
||||
break;
|
||||
|
||||
case kCloseCmd:
|
||||
close();
|
||||
break;
|
||||
|
||||
case kListItemDoubleClickedCmd:
|
||||
editCheat(myCheatList->getSelected());
|
||||
break;
|
||||
|
||||
case kAddCheatCmd:
|
||||
addCheat();
|
||||
break;
|
||||
|
||||
case kEditCheatCmd:
|
||||
editCheat(myCheatList->getSelected());
|
||||
break;
|
||||
|
||||
case kRemCheatCmd:
|
||||
removeCheat(myCheatList->getSelected());
|
||||
break;
|
||||
|
||||
case kAddOneShotCmd:
|
||||
cerr << "add one-shot cheat\n";
|
||||
break;
|
||||
|
||||
/*
|
||||
case kEditAcceptCmd:
|
||||
{
|
||||
// cerr << myInput->getEditString() << endl;
|
||||
|
@ -121,7 +215,7 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
myErrorFlag = false;
|
||||
}
|
||||
break;
|
||||
|
||||
*/
|
||||
default:
|
||||
Dialog::handleCommand(sender, cmd, data, 0);
|
||||
break;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: CheatCodeDialog.hxx,v 1.1 2005-11-12 22:59:20 stephena Exp $
|
||||
// $Id: CheatCodeDialog.hxx,v 1.2 2005-11-26 21:23:35 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -26,6 +26,7 @@ class DialogContainer;
|
|||
class CommandSender;
|
||||
class ButtonWidget;
|
||||
class StaticTextWidget;
|
||||
class CheckListWidget;
|
||||
|
||||
#include "OSystem.hxx"
|
||||
#include "Dialog.hxx"
|
||||
|
@ -45,15 +46,23 @@ class CheatCodeDialog : public Dialog
|
|||
protected:
|
||||
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
||||
void loadConfig();
|
||||
void saveConfig();
|
||||
|
||||
private:
|
||||
void addCheat();
|
||||
void editCheat(int cheatNumber);
|
||||
void removeCheat(int cheatNumber);
|
||||
|
||||
private:
|
||||
CheckListWidget* myCheatList;
|
||||
/*
|
||||
ButtonWidget* myExitButton;
|
||||
StaticTextWidget* myTitle;
|
||||
StaticTextWidget* myError;
|
||||
EditTextWidget* myInput;
|
||||
// CheckboxWidget* myEnableCheat;
|
||||
|
||||
bool myErrorFlag;
|
||||
*/
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: OSystem.cxx,v 1.46 2005-11-21 13:47:34 stephena Exp $
|
||||
// $Id: OSystem.cxx,v 1.47 2005-11-26 21:23:35 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -116,7 +116,7 @@ OSystem::OSystem()
|
|||
myFeatures += "Debugger ";
|
||||
#endif
|
||||
#ifdef CHEATCODE_SUPPORT
|
||||
myFeatures += "Cheats"; // FIXME - string too long in 'About'
|
||||
myFeatures += "Cheats";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: AboutDialog.cxx,v 1.8 2005-10-09 21:55:53 stephena Exp $
|
||||
// $Id: AboutDialog.cxx,v 1.9 2005-11-26 21:23:35 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -78,7 +78,7 @@ void AboutDialog::updateStrings(int page, int lines, string& title, string* &dsc
|
|||
case 1:
|
||||
title = string("Stella ") + STELLA_VERSION;
|
||||
ADD_ATEXT("\\CA multi-platform Atari 2600 VCS emulator");
|
||||
ADD_ATEXT(string("\\C\\c2Supports: ") + instance()->features());
|
||||
ADD_ATEXT(string("\\C\\c2") + instance()->features());
|
||||
ADD_ALINE;
|
||||
ADD_ATEXT("\\CCopyright (C) 1995-2005 The Stella team");
|
||||
ADD_ATEXT("\\Chttp://stella.sourceforge.net");
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: CheckListWidget.cxx,v 1.7 2005-08-26 16:44:17 stephena Exp $
|
||||
// $Id: CheckListWidget.cxx,v 1.8 2005-11-26 21:23:35 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -29,8 +29,10 @@ CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font,
|
|||
{
|
||||
int ypos = _y + 2;
|
||||
|
||||
// rowheight is determined by largest item on a line
|
||||
// rowheight is determined by largest item on a line,
|
||||
// possibly meaning that number of rows will change
|
||||
_rowHeight = MAX(_rowHeight, CheckboxWidget::boxSize());
|
||||
_rows = h / _rowHeight;
|
||||
|
||||
// Create a CheckboxWidget for each row in the list
|
||||
CheckboxWidget* t;
|
||||
|
@ -125,7 +127,8 @@ void CheckListWidget::drawWidget(bool hilite)
|
|||
_checkList[i]->setDirty();
|
||||
_checkList[i]->draw();
|
||||
|
||||
const int y = _y + 2 + _rowHeight * i;
|
||||
// FIXME - properly account for differing font heights
|
||||
const int y = _y + 2 + _rowHeight * i + 2;
|
||||
|
||||
GUI::Rect r(getEditRect());
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: OptionsDialog.cxx,v 1.33 2005-11-13 22:25:47 stephena Exp $
|
||||
// $Id: OptionsDialog.cxx,v 1.34 2005-11-26 21:23:35 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -120,7 +120,7 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent)
|
|||
myGameInfoDialog = new GameInfoDialog(myOSystem, parent, this, x, y, w, h);
|
||||
|
||||
#ifdef CHEATCODE_SUPPORT
|
||||
w = 140; h = 40;
|
||||
w = 230; h = 150;
|
||||
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
|
||||
myCheatCodeDialog = new CheatCodeDialog(myOSystem, parent, x, y, w, h);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue