diff --git a/stella/src/gui/AddrValueWidget.cxx b/stella/src/gui/AddrValueWidget.cxx index 96ed6f1c4..a700d1e45 100644 --- a/stella/src/gui/AddrValueWidget.cxx +++ b/stella/src/gui/AddrValueWidget.cxx @@ -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: AddrValueWidget.cxx,v 1.1 2005-06-15 18:45:28 stephena Exp $ +// $Id: AddrValueWidget.cxx,v 1.2 2005-06-15 21:18:47 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -103,7 +103,7 @@ void AddrValueWidget::setList(const AddrList& alist, const ValueList& vlist) { sprintf(temp, "%.4x:", _addrList[i]); _addrStringList.push_back(temp); - sprintf(temp, "%.3d", _valueList[i]); + sprintf(temp, "%3d", _valueList[i]); _valueStringList.push_back(temp); } @@ -335,7 +335,7 @@ void AddrValueWidget::drawWidget(bool hilite) for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++) { const OverlayColor textColor = (_selectedItem == pos && _editMode) - ? kTextColor : kTextColor; + ? kColor : kTextColor; const int y = _y + 2 + kLineHeight * i; // Draw the selected item inverted, on a highlighted background. @@ -413,7 +413,6 @@ void AddrValueWidget::scrollToCurrent() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void AddrValueWidget::startEditMode() { -cerr << "AddrValueWidget::startEditMode()\n"; if (_editable && !_editMode && _selectedItem >= 0) { _editMode = true; @@ -432,11 +431,17 @@ void AddrValueWidget::endEditMode() _editMode = false; // Update the both the string representation and the real data - _valueStringList[_selectedItem] = _editString; + int value = atoi(_editString.c_str()); + if(_editString.length() == 0 || value < 0 || value > 255) + { + abortEditMode(); + return; + } -int value = atoi(_editString.c_str()); -cerr << "new value: " << value << endl; - _valueList[_selectedItem] = value; // FIXME - do error checking + char temp[10]; + sprintf(temp, "%3d", value); + _valueStringList[_selectedItem] = temp; + _valueList[_selectedItem] = value; sendCommand(kAVItemDataChangedCmd, _selectedItem); } @@ -444,8 +449,18 @@ cerr << "new value: " << value << endl; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void AddrValueWidget::abortEditMode() { -cerr << "AddrValueWidget::abortEditMode()\n"; // undo any changes made assert(_selectedItem >= 0); _editMode = false; } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool AddrValueWidget::tryInsertChar(char c, int pos) +{ + if (c >= '0' && c <= '9') + { + _editString.insert(pos, 1, c); + return true; + } + return false; +} diff --git a/stella/src/gui/AddrValueWidget.hxx b/stella/src/gui/AddrValueWidget.hxx index bf65e321c..ec1bcc454 100644 --- a/stella/src/gui/AddrValueWidget.hxx +++ b/stella/src/gui/AddrValueWidget.hxx @@ -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: AddrValueWidget.hxx,v 1.1 2005-06-15 18:45:28 stephena Exp $ +// $Id: AddrValueWidget.hxx,v 1.2 2005-06-15 21:18:47 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -59,11 +59,11 @@ class AddrValueWidget : public EditableWidget, public CommandSender void setList(const StringList& list); void setList(const AddrList& alist, const ValueList& vlist); -// int getSelected() const { return _selectedItem; } -// void setSelected(int item); -// const string& getSelectedString() const { return _list[_selectedItem]; } - bool isEditable() const { return _editable; } - void setEditable(bool editable) { _editable = editable; } + int getSelectedAddr() const { return _addrList[_selectedItem]; } + int getSelectedValue() const { return _valueList[_selectedItem]; } + + bool isEditable() const { return _editable; } + void setEditable(bool editable) { _editable = editable; } void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; } void scrollTo(int item); @@ -92,7 +92,9 @@ class AddrValueWidget : public EditableWidget, public CommandSender void lostFocusWidget(); void scrollToCurrent(); -protected: + bool tryInsertChar(char c, int pos); + + protected: AddrList _addrList; ValueList _valueList; StringList _addrStringList; diff --git a/stella/src/gui/CheatWidget.cxx b/stella/src/gui/CheatWidget.cxx index 9f6430219..06b5d8ddf 100644 --- a/stella/src/gui/CheatWidget.cxx +++ b/stella/src/gui/CheatWidget.cxx @@ -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: CheatWidget.cxx,v 1.5 2005-06-15 18:45:28 stephena Exp $ +// $Id: CheatWidget.cxx,v 1.6 2005-06-15 21:18:47 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -55,7 +55,7 @@ CheatWidget::CheatWidget(GuiObject* boss, int x, int y, int w, int h) "Enter a value:", kTextAlignLeft); myEditBox = new EditNumWidget(boss, 90, ypos - 2, charWidth*10, charHeight, ""); - myEditBox->setFont(_boss->instance()->consoleFont()); + myEditBox->setFont(instance()->consoleFont()); // myEditBox->setTarget(this); myActiveWidget = myEditBox; ypos += border; @@ -122,15 +122,9 @@ void CheatWidget::handleCommand(CommandSender* sender, int cmd, int data) break; case kAVItemDataChangedCmd: - cerr << "data changed\n"; - break; - - case kAVItemDoubleClickedCmd: - cerr << "kListItemDoubleClickedCmd\n"; - break; - - case kAVItemActivatedCmd: - cerr << "kListItemActivatedCmd\n"; + int addr = myResultsList->getSelectedAddr() - kRamStart; + int value = myResultsList->getSelectedValue(); + instance()->debugger().writeRAM(addr, value); break; } } @@ -146,11 +140,11 @@ void CheatWidget::doSearch() // An empty field means return all memory locations comparisonSearch = false; } - else if(str[0] == '+' || str[0] == '-') + else if(str.find_first_of("+-", 0) != string::npos) { // Don't accept these characters here, only in compare - myEditBox->setEditString(""); - return; // FIXME - message about invalid format + myResult->setLabel("Invalid input +|-"); + return; } int searchVal = atoi(str.c_str()); @@ -160,7 +154,7 @@ void CheatWidget::doSearch() // Now, search all memory locations for this value, and add it to the // search array - Debugger& dbg = _boss->instance()->debugger(); + Debugger& dbg = instance()->debugger(); AddrValue av; int searchCount = 0; for(int addr = 0; addr < kRamSize; ++addr) @@ -216,6 +210,13 @@ void CheatWidget::doCompare() } // Do some pre-processing on the string + if(str.find_first_of("+-", 0) > 0) + { + // Only accept '+' or '-' at the start of the string + myResult->setLabel("Input must be [+|-]NUM"); + return; + } + if(str[0] == '+' || str[0] == '-') { bool negative = false; @@ -235,7 +236,7 @@ void CheatWidget::doCompare() AddrValueList tempList; // Now, search all memory locations specified in mySearchArray for this value - Debugger& dbg = _boss->instance()->debugger(); + Debugger& dbg = instance()->debugger(); AddrValue av; int searchCount = 0; diff --git a/stella/src/gui/ListWidget.cxx b/stella/src/gui/ListWidget.cxx index 30c8c6e86..4c5075ed9 100644 --- a/stella/src/gui/ListWidget.cxx +++ b/stella/src/gui/ListWidget.cxx @@ -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: ListWidget.cxx,v 1.18 2005-06-15 18:45:28 stephena Exp $ +// $Id: ListWidget.cxx,v 1.19 2005-06-15 21:18:47 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -215,6 +215,7 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers) _quickSelectStr = (char)ascii; else _quickSelectStr += (char)ascii; + _quickSelectTime = time + 300; // FIXME: This is bad slow code (it scans the list linearly each time a // key is pressed); it could be much faster. Only of importance if we have diff --git a/stella/src/gui/PromptWidget.cxx b/stella/src/gui/PromptWidget.cxx index c898df96e..c970089f5 100644 --- a/stella/src/gui/PromptWidget.cxx +++ b/stella/src/gui/PromptWidget.cxx @@ -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: PromptWidget.cxx,v 1.3 2005-06-14 01:11:48 stephena Exp $ +// $Id: PromptWidget.cxx,v 1.4 2005-06-15 21:18:47 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -259,11 +259,34 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers) break; case 273: // cursor up - historyScroll(+1); + if (instance()->eventHandler().kbdShift(modifiers)) + { + if(_scrollLine <= _firstLineInBuffer + _linesPerPage - 1) + break; + + _scrollLine -= 1; + updateScrollBuffer(); + draw(); + instance()->frameBuffer().refresh(); + } + else + historyScroll(+1); break; case 274: // cursor down - historyScroll(-1); + if (instance()->eventHandler().kbdShift(modifiers)) + { + // Don't scroll down when at bottom of buffer + if(_scrollLine >= _promptEndPos / _lineWidth) + break; + + _scrollLine += 1; + updateScrollBuffer(); + draw(); + instance()->frameBuffer().refresh(); + } + else + historyScroll(-1); break; case 275: // cursor right