diff options
author | Max Horn | 2004-12-30 12:54:04 +0000 |
---|---|---|
committer | Max Horn | 2004-12-30 12:54:04 +0000 |
commit | 9581bd5691183bc9aca1f59fc80e656f1ff82239 (patch) | |
tree | 885802d1bafcd71024f8fc5aa0b86be824707857 /gui/launcher.cpp | |
parent | 8531caf82282305e96769cea1a95aaa15ce5c57a (diff) | |
download | scummvm-rg350-9581bd5691183bc9aca1f59fc80e656f1ff82239.tar.gz scummvm-rg350-9581bd5691183bc9aca1f59fc80e656f1ff82239.tar.bz2 scummvm-rg350-9581bd5691183bc9aca1f59fc80e656f1ff82239.zip |
Fix for bug #1091801 (ALL: Possible to create corrupt config file)
svn-id: r16379
Diffstat (limited to 'gui/launcher.cpp')
-rw-r--r-- | gui/launcher.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 5e9f9b3e08..e029dc4e8d 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -69,6 +69,27 @@ enum { }; /* + * TODO: Clean up this ugly design: we subclass EditTextWidget to perform + * input validation. It would be much more elegant to use a decorator pattern, + * or a validation callback, or something like that. + */ +class DomainEditTextWidget : public EditTextWidget { +public: + DomainEditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text) + : EditTextWidget(boss, x, y, w, h, text) { + } + +protected: + bool tryInsertChar(char c, int pos) { + if (isalnum(c) || c == '-' || c == '_') { + _label.insertChar(c, pos); + return true; + } + return false; + } +}; + +/* * A dialog that allows the user to edit a config game entry. * TODO: add widgets for some/all of the following * - Maybe scaler/graphics mode. But there are two problems: @@ -96,7 +117,7 @@ public: protected: EditTextWidget *_descriptionWidget; - EditTextWidget *_domainWidget; + DomainEditTextWidget *_domainWidget; StaticTextWidget *_gamePathWidget; StaticTextWidget *_extraPathWidget; @@ -141,7 +162,7 @@ EditGameDialog::EditGameDialog(const String &domain, GameSettings target) // GUI: Label & edit widget for the game ID new StaticTextWidget(tab, x, yoffset + 2, labelWidth, kLineHeight, "ID: ", kTextAlignRight); - _domainWidget = new EditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10, kLineHeight, _domain); + _domainWidget = new DomainEditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10, kLineHeight, _domain); yoffset += 16; // GUI: Label & edit widget for the description |