First pass at converting GameInfoDialog to be able to edit properties.

I know it doesn't compile, but I have to commit it before I go home :)


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@798 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-09-28 19:59:24 +00:00
parent 0158d919e6
commit b0c1c04598
3 changed files with 225 additions and 144 deletions

View File

@ -1,3 +1,20 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: BankRomCheat.hxx,v 1.2 2005-09-28 19:59:24 stephena Exp $
//============================================================================
#ifndef BANK_ROM_CHEAT_HXX #ifndef BANK_ROM_CHEAT_HXX
#define BANK_ROM_CHEAT_HXX #define BANK_ROM_CHEAT_HXX
@ -5,24 +22,25 @@
#include "OSystem.hxx" #include "OSystem.hxx"
#include "Cheat.hxx" #include "Cheat.hxx"
class BankRomCheat : public Cheat { class BankRomCheat : public Cheat
public: {
BankRomCheat(OSystem *os, string code); public:
~BankRomCheat(); BankRomCheat(OSystem *os, string code);
~BankRomCheat();
virtual bool enabled(); virtual bool enabled();
virtual bool enable(); virtual bool enable();
virtual bool disable(); virtual bool disable();
private:
OSystem* myOSystem;
private: bool _enabled;
bool _enabled; uInt8 savedRom[16];
uInt8 savedRom[16]; uInt16 address;
uInt16 address; uInt8 value;
uInt8 value; uInt8 count;
uInt8 count; int bank;
int bank;
OSystem *myOSystem;
}; };
#endif #endif

View File

@ -13,143 +13,202 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: GameInfoDialog.cxx,v 1.10 2005-08-11 21:57:30 stephena Exp $ // $Id: GameInfoDialog.cxx,v 1.11 2005-09-28 19:59:24 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
//============================================================================ //============================================================================
#include "OSystem.hxx" #include "DialogContainer.hxx"
#include "Props.hxx" #include "BrowserDialog.hxx"
#include "Widget.hxx" #include "PopUpWidget.hxx"
#include "Dialog.hxx" #include "TabWidget.hxx"
#include "GameInfoDialog.hxx" #include "FSNode.hxx"
#include "GuiUtils.hxx"
#include "bspf.hxx" #include "bspf.hxx"
#include "LauncherDialog.hxx"
#include "LauncherOptionsDialog.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GameInfoDialog::GameInfoDialog(OSystem* osystem, DialogContainer* parent, LauncherOptionsDialog::LauncherOptionsDialog(
int x, int y, int w, int h) OSystem* osystem, DialogContainer* parent, GuiObject* boss,
: Dialog(osystem, parent, x, y, w, h), int x, int y, int w, int h)
myPage(1), : Dialog(osystem, parent, x, y, w, h),
myNumPages(2), CommandSender(boss),
myGameProperties(NULL) myBrowser(NULL)
{ {
// Add Previous, Next and Close buttons const GUI::Font& font = instance()->font();
myPrevButton = addButton(10, h - 24, "Previous", kPrevCmd, 'P');
myNextButton = addButton((kButtonWidth + 15), h - 24,
"Next", kNextCmd, 'N');
addButton(w - (kButtonWidth + 10), h - 24, "Close", kCloseCmd, 'C');
myPrevButton->clearFlags(WIDGET_ENABLED);
myTitle = new StaticTextWidget(this, 5, 5, w-10, kFontHeight, "", kTextAlignCenter); const int vBorder = 4;
for(uInt8 i = 0; i < LINES_PER_PAGE; i++) int xpos, ypos;
{
myKey[i] = new StaticTextWidget(this, 10, 18 + (10 * i), 80, kFontHeight, // The tab widget
"", kTextAlignLeft); xpos = 2; ypos = vBorder;
myDesc[i] = new StaticTextWidget(this, 90, 18 + (10 * i), 160, kFontHeight, myTab = new TabWidget(this, xpos, ypos, _w - 2*xpos, _h - 24 - 2*ypos);
"", kTextAlignLeft);
} // 1) The ROM locations tab
myTab->addTab("ROM Settings");
// ROM path
xpos = 15;
new ButtonWidget(myTab, xpos, ypos, kButtonWidth + 14, 16, "Path",
kChooseRomDirCmd, 0);
xpos += kButtonWidth + 30;
myRomPath = new StaticTextWidget(myTab, xpos, ypos + 3,
_w - xpos - 10, kLineHeight,
"", kTextAlignLeft);
// 2) The snapshot settings tab
myTab->addTab(" Snapshot Settings ");
// Snapshot path
xpos = 15;
new ButtonWidget(myTab, xpos, ypos, kButtonWidth + 14, 16, "Path",
kChooseSnapDirCmd, 0);
xpos += kButtonWidth + 30;
mySnapPath = new StaticTextWidget(myTab, xpos, ypos + 3,
_w - xpos - 10, kLineHeight,
"", kTextAlignLeft);
// Snapshot save name
xpos = 10; ypos += 22;
mySnapTypePopup = new PopUpWidget(myTab, xpos, ypos, 140, kLineHeight,
"Save snapshot as: ", 87, 0);
mySnapTypePopup->appendEntry("romname", 1);
mySnapTypePopup->appendEntry("md5sum", 2);
// Snapshot single or multiple saves
xpos = 30; ypos += 18;
mySnapSingleCheckbox = new CheckboxWidget(myTab, font, xpos, ypos,
"Multiple snapshots");
// Activate the first tab
myTab->setActiveTab(0);
// Add OK & Cancel buttons
#ifndef MAC_OSX
addButton(_w - 2 *(kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
addButton(_w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
#else
addButton(_w - 2 *(kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
#endif
// Create file browser dialog
int baseW = instance()->frameBuffer().baseWidth();
int baseH = instance()->frameBuffer().baseHeight();
myBrowser = new BrowserDialog(this, 60, 20, baseW - 120, baseH - 40);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GameInfoDialog::~GameInfoDialog() LauncherOptionsDialog::~LauncherOptionsDialog()
{ {
delete myBrowser;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameInfoDialog::updateStrings(uInt8 page, uInt8 lines, void LauncherOptionsDialog::loadConfig()
string& title, string*& key, string* &dsc)
{ {
if(myGameProperties == NULL) string s;
return; bool b;
key = new string[lines]; s = instance()->settings().getString("romdir");
dsc = new string[lines]; myRomPath->setLabel(s);
uInt8 i = 0; s = instance()->settings().getString("ssdir");
switch(page) mySnapPath->setLabel(s);
{
case 1:
title = "Common game properties";
ADD_BIND("Name:", myGameProperties->get("Cartridge.Name"));
ADD_LINE;
ADD_BIND("Manufacturer:", myGameProperties->get("Cartridge.Manufacturer"));
ADD_BIND("Model:", myGameProperties->get("Cartridge.ModelNo"));
ADD_BIND("Rarity:", myGameProperties->get("Cartridge.Rarity"));
ADD_BIND("Note:", myGameProperties->get("Cartridge.Note"));
ADD_BIND("Type:", myGameProperties->get("Cartridge.Type"));
ADD_LINE;
ADD_BIND("MD5sum:", myGameProperties->get("Cartridge.MD5"));
break;
case 2: s = instance()->settings().getString("ssname");
title = "Other game properties"; if(s == "romname")
ADD_BIND("TV Type:", myGameProperties->get("Console.TelevisionType")); mySnapTypePopup->setSelectedTag(1);
ADD_BIND("Left Controller:", myGameProperties->get("Controller.Left")); else if(s == "md5sum")
ADD_BIND("Right Controller:", myGameProperties->get("Controller.Left")); mySnapTypePopup->setSelectedTag(2);
ADD_BIND("Format:", myGameProperties->get("Display.Format")); else
ADD_BIND("XStart:", myGameProperties->get("Display.XStart")); mySnapTypePopup->setSelectedTag(0);
ADD_BIND("Width:", myGameProperties->get("Display.Width"));
ADD_BIND("YStart:", myGameProperties->get("Display.YStart"));
ADD_BIND("Height:", myGameProperties->get("Display.Height"));
ADD_BIND("CPU Type:", myGameProperties->get("Emulation.CPU"));
ADD_BIND("Use HMoveBlanks:", myGameProperties->get("Emulation.HmoveBlanks"));
break;
}
while(i < lines) b = instance()->settings().getBool("sssingle");
ADD_LINE; mySnapSingleCheckbox->setState(!b);
myTab->loadConfig();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameInfoDialog::displayInfo() void LauncherOptionsDialog::saveConfig()
{ {
string titleStr, *keyStr, *dscStr; string s;
bool b;
updateStrings(myPage, LINES_PER_PAGE, titleStr, keyStr, dscStr); s = myRomPath->getLabel();
instance()->settings().setString("romdir", s);
myTitle->setLabel(titleStr); s = mySnapPath->getLabel();
for(uInt8 i = 0; i < LINES_PER_PAGE; i++) instance()->settings().setString("ssdir", s);
{
myKey[i]->setLabel(keyStr[i]);
myDesc[i]->setLabel(dscStr[i]);
}
delete[] keyStr; s = mySnapTypePopup->getSelectedString();
delete[] dscStr; instance()->settings().setString("ssname", s);
_dirty = true; b = mySnapSingleCheckbox->getState();
instance()->settings().setBool("sssingle", !b);
// Flush changes to disk
instance()->settings().saveConfig();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameInfoDialog::handleCommand(CommandSender* sender, int cmd, void LauncherOptionsDialog::openRomBrowser()
int data, int id)
{ {
switch(cmd) myBrowser->setTitle("Select ROM directory:");
myBrowser->setEmitSignal(kRomDirChosenCmd);
myBrowser->setStartPath(myRomPath->getLabel());
parent()->addDialog(myBrowser);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherOptionsDialog::openSnapBrowser()
{
myBrowser->setTitle("Select snapshot directory:");
myBrowser->setEmitSignal(kSnapDirChosenCmd);
myBrowser->setStartPath(mySnapPath->getLabel());
parent()->addDialog(myBrowser);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherOptionsDialog::handleCommand(CommandSender* sender, int cmd,
int data, int id)
{
switch (cmd)
{ {
case kNextCmd: case kOKCmd:
myPage++; saveConfig();
if(myPage >= myNumPages) close();
myNextButton->clearFlags(WIDGET_ENABLED); sendCommand(kRomDirChosenCmd, 0, 0); // Let the boss know romdir has changed
if(myPage >= 2)
myPrevButton->setFlags(WIDGET_ENABLED);
displayInfo();
break; break;
case kPrevCmd: case kChooseRomDirCmd:
myPage--; openRomBrowser();
if(myPage <= myNumPages)
myNextButton->setFlags(WIDGET_ENABLED);
if(myPage <= 1)
myPrevButton->clearFlags(WIDGET_ENABLED);
displayInfo();
break; break;
case kChooseSnapDirCmd:
openSnapBrowser();
break;
case kRomDirChosenCmd:
{
FilesystemNode dir(myBrowser->getResult());
myRomPath->setLabel(dir.path());
break;
}
case kSnapDirChosenCmd:
{
FilesystemNode dir(myBrowser->getResult());
mySnapPath->setLabel(dir.path());
break;
}
default: default:
Dialog::handleCommand(sender, cmd, data, 0); Dialog::handleCommand(sender, cmd, data, 0);
break;
} }
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: GameInfoDialog.hxx,v 1.7 2005-07-05 15:25:44 stephena Exp $ // $Id: GameInfoDialog.hxx,v 1.8 2005-09-28 19:59:24 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -22,51 +22,55 @@
#ifndef GAME_INFO_DIALOG_HXX #ifndef GAME_INFO_DIALOG_HXX
#define GAME_INFO_DIALOG_HXX #define GAME_INFO_DIALOG_HXX
class DialogContainer; class OSystem;
class CommandSender; class GuiObject;
class ButtonWidget; class EditTextWidget;
class PopUpWidget;
class StaticTextWidget; class StaticTextWidget;
class TabWidget;
#define ADD_BIND(k,d) do { key[i] = k; dsc[i] = d; i++; } while(0)
#define ADD_TEXT(d) ADD_BIND("",d)
#define ADD_LINE ADD_BIND("","")
#define LINES_PER_PAGE 10
#include "OSystem.hxx"
#include "Dialog.hxx" #include "Dialog.hxx"
#include "Props.hxx" #include "Command.hxx"
#include "bspf.hxx"
class GameInfoDialog : public Dialog class GameInfoDialog : public Dialog, public CommandSender
{ {
public: public:
GameInfoDialog(OSystem* osystem, DialogContainer* parent, GameInfoDialog(OSystem* osystem, DialogContainer* parent,
GuiObject* boss,
int x, int y, int w, int h); int x, int y, int w, int h);
~GameInfoDialog(); ~GameInfoDialog();
void setGameProfile(Properties& props) { myGameProperties = &props; } virtual void loadConfig();
virtual void saveConfig();
protected:
ButtonWidget* myNextButton;
ButtonWidget* myPrevButton;
StaticTextWidget* myTitle;
StaticTextWidget* myKey[LINES_PER_PAGE];
StaticTextWidget* myDesc[LINES_PER_PAGE];
uInt8 myPage;
uInt8 myNumPages;
private:
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
virtual void updateStrings(uInt8 page, uInt8 lines,
string& title, string*& key, string* &dsc);
void displayInfo();
void loadConfig() { displayInfo(); }
private: private:
Properties* myGameProperties; TabWidget* myTab;
// Cartridge properties
EditTextWidget* myName;
StaticTextWidget* myMD5;
EditTextWidget* myManufacturer;
EditTextWidget* myModelNo;
EditTextWidget* myNote;
PopupWidget* mySound;
PopupWidget* myType;
// Console/controller properties
PopupWidget* myLeftDiff;
PopupWidget* myRightDiff;
PopupWidget* myTVType;
PopupWidget* myLeftController;
PopupWidget* myRightController;
// Display properties
PopupWidget* myFormat;
EditTextWidget* myXStart;
EditTextWidget* myWidth;
EditTextWidget* myYStart;
EditTextWidget* myHeight;
PopupWidget* myHmoveBlanks;
}; };
#endif #endif