diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index 03975bf7d..09abe0efd 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -308,8 +308,8 @@ void DebuggerDialog::addRomArea() // Disassembly area xpos = r.left + vBorder; ypos += myRam->getHeight() + 5; - const int tabWidth = r.width() - vBorder; - const int tabHeight = r.height() - ypos; + const int tabWidth = r.width() - vBorder - 1; + const int tabHeight = r.height() - ypos - 1; int tabID; // Since there are two tab widgets in this dialog, we specifically diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index f0438ece1..199f5905a 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -405,7 +405,8 @@ void RomListWidget::handleCommand(CommandSender* sender, int cmd, int data, int case kCheckActionCmd: // We let the parent class handle this // Pass it as a kRLBreakpointChangedCmd command, since that's the intent - sendCommand(kRLBreakpointChangedCmd, myCheckList[id]->getState(), _currentPos+id); + sendCommand(RomListWidget::kBreakpointChangedCmd, + myCheckList[id]->getState(), _currentPos+id); break; case kSetPositionCmd: @@ -597,7 +598,7 @@ void RomListWidget::endEditMode() // Send a message that editing finished with a return/enter key press // The parent then calls getEditString() to get the newly entered data _editMode = false; - sendCommand(kRLRomChangedCmd, _selectedItem, _id); + sendCommand(RomListWidget::kRomChangedCmd, _selectedItem, _id); // Reset to normal data entry EditableWidget::endEditMode(); diff --git a/src/debugger/gui/RomListWidget.hxx b/src/debugger/gui/RomListWidget.hxx index 5f3de7c85..e94b46f6b 100644 --- a/src/debugger/gui/RomListWidget.hxx +++ b/src/debugger/gui/RomListWidget.hxx @@ -32,17 +32,18 @@ class CheckListWidget; #include "CartDebug.hxx" #include "EditableWidget.hxx" -// Some special commands for this widget -enum { - kRLBreakpointChangedCmd = 'RLbp', // click on the checkbox for a breakpoint - kRLRomChangedCmd = 'RLpr' // ROM item data changed - 'data' will be item index -}; - /** RomListWidget */ class RomListWidget : public EditableWidget { friend class RomWidget; + public: + enum { + kBreakpointChangedCmd = 'RLbp', // click on the checkbox for a breakpoint + kRomChangedCmd = 'RLpr' // ROM item data changed - 'data' will be + // item index + }; + public: RomListWidget(GuiObject* boss, const GUI::Font& font, int x, int y, int w, int h); diff --git a/src/debugger/gui/RomWidget.cxx b/src/debugger/gui/RomWidget.cxx index 3639884aa..92a9a4dfd 100644 --- a/src/debugger/gui/RomWidget.cxx +++ b/src/debugger/gui/RomWidget.cxx @@ -139,7 +139,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) { switch(cmd) { - case kRLBreakpointChangedCmd: + case RomListWidget::kBreakpointChangedCmd: // 'id' is the line in the disassemblylist to be accessed // 'data' is the state of the breakpoint at 'id' setBreak(id, data); @@ -149,12 +149,12 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) myRomList->draw(); break; - case kRLRomChangedCmd: + case RomListWidget::kRomChangedCmd: // 'data' is the line in the disassemblylist to be accessed patchROM(data, myRomList->getEditString()); break; - case kCMenuItemSelectedCmd: + case ContextMenu::kItemSelectedCmd: { const string& rmb = myRomList->myMenu->getSelectedTag(); diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index 10ad8c0e1..4aa130532 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -87,7 +87,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in switch(cmd) { - case kCMenuItemSelectedCmd: + case ContextMenu::kItemSelectedCmd: { const string& rmb = myMenu->getSelectedTag(); diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index e6a7357e3..666678073 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -200,7 +200,7 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int { switch(cmd) { - case kCMenuItemSelectedCmd: + case ContextMenu::kItemSelectedCmd: { int level = (int) atoi(myMenu->getSelectedTag().c_str()); if(level > 0) diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 5891d8cf5..7b7f5f9ae 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -385,9 +385,10 @@ void OSystem::setUIPalette() void OSystem::setBaseDir(const string& basedir) { FilesystemNode node(basedir); - myBaseDir = node.getPath(); if(!node.isDirectory()) node.makeDir(); + + myBaseDir = node.getPath(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -823,6 +824,7 @@ void OSystem::validatePath(string& path, const string& setting, FilesystemNode node(s); if(!node.isDirectory()) node.makeDir(); + path = node.getPath(); mySettings->setString(setting, node.getShortPath()); } diff --git a/src/gui/BrowserDialog.cxx b/src/gui/BrowserDialog.cxx index 348e6df51..aac3178f1 100644 --- a/src/gui/BrowserDialog.cxx +++ b/src/gui/BrowserDialog.cxx @@ -47,19 +47,18 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font, _fileList(NULL), _currentPath(NULL), _nodeList(NULL), - _mode(FilesystemNode::kListDirectoriesOnly) + _mode(FilesystemNode::kListAll) { + // Set real dimensions + _w = max_w; + _h = max_h; + const int lineHeight = font.getLineHeight(), buttonWidth = font.getStringWidth("Defaults") + 20, buttonHeight = font.getLineHeight() + 4; int xpos, ypos; ButtonWidget* b; - // Set real dimensions - // This is one dialog that can take as much space as is available - _w = BSPF_min(max_w, 480); - _h = BSPF_min(max_h, 380); - xpos = 10; ypos = 4; _title = new StaticTextWidget(this, font, xpos, ypos, _w - 2 * xpos, lineHeight, @@ -123,18 +122,6 @@ BrowserDialog::~BrowserDialog() void BrowserDialog::show(const string& title, const string& startpath, FilesystemNode::ListMode mode, int cmd) { - // TODO - dialog has to be added before any settings are changed, - // since (for example) changing the title triggers a redraw, - // and the dialog must be added (so it exists) for that to happen - // Fixing this requires changes to the underlying widget classes - // (ie, changing a widgets contents should signal its dialog that a - // redraw is necessary; it shouldn't be responsible for redraw itself) - // - // Doing it this way has the unfortunate side effect that a previous - // title is temporarily visible when re-using the browser for different - // purposes - open(); - _title->setLabel(title); _cmd = cmd; _mode = mode; @@ -151,6 +138,9 @@ void BrowserDialog::show(const string& title, const string& startpath, // Alway refresh file list updateListing(); + + // Finally, open the dialog after it has been fully updated + open(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -208,7 +198,7 @@ void BrowserDialog::handleCommand(CommandSender* sender, int cmd, case kChooseCmd: // Send a signal to the calling class that a selection has been made // Since we aren't derived from a widget, we don't have a 'data' or 'id' - if(_cmd) sendCommand(_cmd, 0, 0); + if(_cmd) sendCommand(_cmd, -1, -1); close(); break; diff --git a/src/gui/BrowserDialog.hxx b/src/gui/BrowserDialog.hxx index aac83efac..568a77983 100644 --- a/src/gui/BrowserDialog.hxx +++ b/src/gui/BrowserDialog.hxx @@ -36,6 +36,13 @@ class GameList; class BrowserDialog : public Dialog, public CommandSender { + public: + enum ListMode { + kFileLoad, // File selector, no input from user + kFileSave, // File selector, filename changable by user + kDirectoryOpen // Directories only, no input from user + }; + public: BrowserDialog(GuiObject* boss, const GUI::Font& font, int max_w, int max_h); virtual ~BrowserDialog(); diff --git a/src/gui/ContextMenu.cxx b/src/gui/ContextMenu.cxx index a30678179..f88b23190 100644 --- a/src/gui/ContextMenu.cxx +++ b/src/gui/ContextMenu.cxx @@ -202,7 +202,7 @@ bool ContextMenu::sendSelectionUp() return false; _selectedItem--; - sendCommand(_cmd ? _cmd : kCMenuItemSelectedCmd, _selectedItem, -1); + sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); return true; } @@ -213,7 +213,7 @@ bool ContextMenu::sendSelectionDown() return false; _selectedItem++; - sendCommand(_cmd ? _cmd : kCMenuItemSelectedCmd, _selectedItem, -1); + sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); return true; } @@ -224,7 +224,7 @@ bool ContextMenu::sendSelectionFirst() return false; _selectedItem = 0; - sendCommand(_cmd ? _cmd : kCMenuItemSelectedCmd, _selectedItem, -1); + sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); return true; } @@ -235,7 +235,7 @@ bool ContextMenu::sendSelectionLast() return false; _selectedItem = _entries.size() - 1; - sendCommand(_cmd ? _cmd : kCMenuItemSelectedCmd, _selectedItem, -1); + sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); return true; } @@ -396,7 +396,7 @@ void ContextMenu::sendSelection() // Send any command associated with the selection _selectedItem = item; - sendCommand(_cmd ? _cmd : kCMenuItemSelectedCmd, _selectedItem, -1); + sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/ContextMenu.hxx b/src/gui/ContextMenu.hxx index 621a3d71a..61384b08f 100644 --- a/src/gui/ContextMenu.hxx +++ b/src/gui/ContextMenu.hxx @@ -27,10 +27,6 @@ #include "Command.hxx" #include "Dialog.hxx" -enum { - kCMenuItemSelectedCmd = 'CMsl' -}; - /** * Popup context menu which, when clicked, "pop up" a list of items and * lets the user pick on of them. @@ -43,6 +39,11 @@ enum { */ class ContextMenu : public Dialog, public CommandSender { + public: + enum { + kItemSelectedCmd = 'CMsl' + }; + public: ContextMenu(GuiObject* boss, const GUI::Font& font, const StringMap& items, int cmd = 0); diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 6a032d938..0ff2913de 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -80,6 +80,7 @@ void Dialog::open(bool refresh) uInt32 surfaceID = instance().frameBuffer().allocateSurface(_w, _h, _isBase); _surface = instance().frameBuffer().surface(surfaceID); } + parent().addDialog(this); center(); loadConfig(); @@ -90,7 +91,8 @@ void Dialog::open(bool refresh) _visible = true; - parent().addDialog(this, refresh); + if(refresh) + instance().frameBuffer().refresh(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -106,7 +108,10 @@ void Dialog::close(bool refresh) _visible = false; - parent().removeDialog(refresh); + parent().removeDialog(); + + if(refresh) + instance().frameBuffer().refresh(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index 77eb90864..4272d1c30 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -112,27 +112,19 @@ void DialogContainer::draw(bool full) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DialogContainer::addDialog(Dialog* d, bool refresh) +void DialogContainer::addDialog(Dialog* d) { const GUI::Rect& screen = myOSystem->frameBuffer().screenRect(); assert(d->getWidth() <= screen.width() && d->getHeight() <= screen.height()); myDialogStack.push(d); - - if(refresh) - myOSystem->frameBuffer().refresh(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DialogContainer::removeDialog(bool refresh) +void DialogContainer::removeDialog() { if(!myDialogStack.empty()) - { myDialogStack.pop(); - - if(refresh) - myOSystem->frameBuffer().refresh(); - } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/DialogContainer.hxx b/src/gui/DialogContainer.hxx index dcec579c3..1b52bf294 100644 --- a/src/gui/DialogContainer.hxx +++ b/src/gui/DialogContainer.hxx @@ -141,12 +141,12 @@ class DialogContainer /** Add a dialog box to the stack. */ - void addDialog(Dialog* d, bool refresh); + void addDialog(Dialog* d); /** Remove the topmost dialog box from the stack. */ - void removeDialog(bool refresh); + void removeDialog(); protected: OSystem* myOSystem; diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index f4d34990e..8ee2991a7 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -174,7 +174,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent, mySelectedItem = 0; // Highlight 'Rom Listing' // Create an options dialog, similar to the in-game one - myOptions = new OptionsDialog(osystem, parent, this, w, h, true); // not in game mode + myOptions = new OptionsDialog(osystem, parent, this, w * 0.8, h * 0.8, true); // Create a game list, which contains all the information about a ROM that // the launcher needs @@ -619,7 +619,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd, updateListing(); break; - case kCMenuItemSelectedCmd: + case ContextMenu::kItemSelectedCmd: handleContextMenu(); break; diff --git a/src/gui/Menu.cxx b/src/gui/Menu.cxx index c84d5700d..512b791ac 100644 --- a/src/gui/Menu.cxx +++ b/src/gui/Menu.cxx @@ -39,7 +39,7 @@ Menu::Menu(OSystem* osystem) } else { - dw = 640; dh = 420; + dw = 480; dh = 380; } myBaseDialog = new OptionsDialog(myOSystem, this, 0, dw, dh, false); // in game mode } diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index dd65a897d..ab331e6b7 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -68,15 +68,12 @@ Widget::~Widget() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Widget::draw() { - if(!_dirty) + if(!_dirty || !isVisible() || !_boss->isVisible()) return; _dirty = false; - - FBSurface& s = _boss->dialog().surface(); - if(!isVisible() || !_boss->isVisible()) - return; + FBSurface& s = _boss->dialog().surface(); bool hasBorder = _flags & WIDGET_BORDER; int oldX = _x, oldY = _y, oldW = _w, oldH = _h; diff --git a/src/unix/FSNodePOSIX.cxx b/src/unix/FSNodePOSIX.cxx index ed05d8e75..0a9e05388 100644 --- a/src/unix/FSNodePOSIX.cxx +++ b/src/unix/FSNodePOSIX.cxx @@ -57,6 +57,10 @@ void FilesystemNodePOSIX::setFlags() { _isDirectory = S_ISDIR(st.st_mode); _isFile = S_ISREG(st.st_mode); + + // Add a trailing slash, if necessary + if (_isDirectory && _path.length() > 0 && _path[_path.length()-1] != '/') + _path += '/'; } else _isDirectory = _isFile = false; @@ -94,14 +98,8 @@ FilesystemNodePOSIX::FilesystemNodePOSIX(const string& p, bool verify) _displayName = lastPathComponent(_path); - if (verify) - { + if(verify) setFlags(); - - // Add a trailing slash, if necessary - if (_isDirectory && _path.length() > 0 && _path[_path.length()-1] != '/') - _path += '/'; - } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -184,6 +182,9 @@ bool FilesystemNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode, entry._isDirectory = (dp->d_type == DT_DIR); entry._isFile = (dp->d_type == DT_REG); } + + if (entry._isDirectory) + entry._path += "/"; } #endif @@ -197,9 +198,6 @@ bool FilesystemNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode, (mode == FilesystemNode::kListDirectoriesOnly && !entry._isDirectory)) continue; - if (entry._isDirectory) - entry._path += "/"; - myList.push_back(new FilesystemNodePOSIX(entry)); } closedir(dirp);