aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-04-10 14:33:44 +0000
committerTorbjörn Andersson2005-04-10 14:33:44 +0000
commit13dc149ded691e718905049990dd0220230c500e (patch)
tree188daa35002ceb085c35778f63918e4b66365723 /gui
parent53a64266c8963f46be68f54fcd1fb89432a02826 (diff)
downloadscummvm-rg350-13dc149ded691e718905049990dd0220230c500e.tar.gz
scummvm-rg350-13dc149ded691e718905049990dd0220230c500e.tar.bz2
scummvm-rg350-13dc149ded691e718905049990dd0220230c500e.zip
Applied patch #1175374 ("FluidSynth MIDI driver"), with a few documentation
changes. There are a few things that could use a bit more work, and I've only tested it on my Linux box. I have verified that ScummVM still compiles when it's disabled, though, so it shouldn't break anything too badly. svn-id: r17512
Diffstat (limited to 'gui')
-rw-r--r--gui/browser.cpp116
-rw-r--r--gui/browser.h34
-rw-r--r--gui/launcher.cpp8
-rw-r--r--gui/launcher.h4
-rw-r--r--gui/options.cpp49
-rw-r--r--gui/options.h8
6 files changed, 188 insertions, 31 deletions
diff --git a/gui/browser.cpp b/gui/browser.cpp
index 9e42f6900e..5294c9860c 100644
--- a/gui/browser.cpp
+++ b/gui/browser.cpp
@@ -34,16 +34,16 @@ namespace GUI {
* other operating systems.
*/
-BrowserDialog::BrowserDialog(const char *title)
+DirBrowserDialog::DirBrowserDialog(const char *title)
: Dialog(20, 10, 320 -2 * 20, 200 - 2 * 10) {
_titleRef = CFStringCreateWithCString(0, title, CFStringGetSystemEncoding());
}
-BrowserDialog::~BrowserDialog() {
+DirBrowserDialog::~DirBrowserDialog() {
CFRelease(_titleRef);
}
-int BrowserDialog::runModal() {
+int DirBrowserDialog::runModal() {
NavDialogRef dialogRef;
WindowRef windowRef = 0;
NavDialogCreationOptions options;
@@ -125,7 +125,7 @@ enum {
kGoUpCmd = 'GoUp'
};
-BrowserDialog::BrowserDialog(const char *title)
+DirBrowserDialog::DirBrowserDialog(const char *title)
: Dialog(20, 10, 320 -2 * 20, 200 - 2 * 10)
{
@@ -150,7 +150,7 @@ BrowserDialog::BrowserDialog(const char *title)
addButton(_w - (kButtonWidth+10), _h - 24, "Choose", kChooseCmd, 0);
}
-void BrowserDialog::open() {
+void DirBrowserDialog::open() {
// If no node has been set, or the last used one is now invalid,
// go back to the root/default dir.
if (!_node.isValid()) {
@@ -164,7 +164,7 @@ void BrowserDialog::open() {
Dialog::open();
}
-void BrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
+void DirBrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kChooseCmd: {
// If nothing is selected in the list widget, choose the current dir.
@@ -193,7 +193,7 @@ void BrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
}
}
-void BrowserDialog::updateListing() {
+void DirBrowserDialog::updateListing() {
// Update the path display
_currentPath->setLabel(_node.path());
@@ -216,4 +216,106 @@ void BrowserDialog::updateListing() {
#endif // MACOSX
+FileBrowserDialog::FileBrowserDialog(const char *title)
+ : Dialog(20, 10, 320 -2 * 20, 200 - 2 * 10)
+ {
+
+ _fileList = NULL;
+ _currentPath = NULL;
+
+ // Headline - TODO: should be customizable during creation time
+ new StaticTextWidget(this, 10, 8, _w - 2 * 10, kLineHeight, title, kTextAlignCenter);
+
+ // Current path - TODO: handle long paths ?
+ _currentPath = new StaticTextWidget(this, 10, 20, _w - 2 * 10, kLineHeight,
+ "DUMMY", kTextAlignLeft);
+
+ // Add file list
+ _fileList = new ListWidget(this, 10, 34, _w - 2 * 10, _h - 34 - 24 - 10);
+ _fileList->setNumberingMode(kListNumberingOff);
+ _fileList->setEditable(false);
+
+ // Buttons
+ addButton(10, _h - 24, "Go up", kGoUpCmd, 0);
+ addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
+ addButton(_w - (kButtonWidth+10), _h - 24, "Choose", kChooseCmd, 0);
+}
+
+void FileBrowserDialog::open() {
+ // If no node has been set, or the last used one is now invalid,
+ // go back to the root/default dir.
+ if (!_node.isValid()) {
+ _node = FilesystemNode();
+ }
+
+ // Alway refresh file list
+ updateListing();
+
+ // Call super implementation
+ Dialog::open();
+}
+
+void FileBrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
+ switch (cmd) {
+ case kChooseCmd: {
+ int selection = _fileList->getSelected();
+ if (selection < 0)
+ break;
+ if (_nodeContent[selection].isDirectory()) {
+ _node = _nodeContent[selection];
+ updateListing();
+ } else {
+ _choice = _nodeContent[selection];
+ setResult(1);
+ close();
+ }
+ }
+ break;
+ case kGoUpCmd:
+ _node = _node.getParent();
+ updateListing();
+ break;
+ case kListItemActivatedCmd:
+ case kListItemDoubleClickedCmd:
+ if (_nodeContent[data].isDirectory()) {
+ _node = _nodeContent[data];
+ updateListing();
+ } else {
+ _choice = _nodeContent[data];
+ setResult(1);
+ close();
+ }
+ break;
+ default:
+ Dialog::handleCommand(sender, cmd, data);
+ }
+}
+
+void FileBrowserDialog::updateListing() {
+ // Update the path display
+ _currentPath->setLabel(_node.path());
+
+ // Read in the data from the file system
+ _nodeContent = _node.listDir(AbstractFilesystemNode::kListAll);
+ _nodeContent.sort();
+
+ // Populate the ListWidget
+ Common::StringList list;
+ int size = _nodeContent.size();
+ int i;
+
+ for (i = 0; i < size; i++) {
+ if (_nodeContent[i].isDirectory())
+ list.push_back(_nodeContent[i].displayName() + "/");
+ else
+ list.push_back(_nodeContent[i].displayName());
+ }
+
+ _fileList->setList(list);
+ _fileList->scrollTo(0);
+
+ // Finally, redraw
+ draw();
+}
+
} // End of namespace GUI
diff --git a/gui/browser.h b/gui/browser.h
index 97b573f1ee..46b3512fe7 100644
--- a/gui/browser.h
+++ b/gui/browser.h
@@ -34,14 +34,16 @@ namespace GUI {
class ListWidget;
class StaticTextWidget;
-class BrowserDialog : public Dialog {
+// TODO: Common parent class for DirBrowserDialog and FileBrowserDialog
+
+class DirBrowserDialog : public Dialog {
typedef Common::String String;
typedef Common::StringList StringList;
public:
- BrowserDialog(const char *title);
+ DirBrowserDialog(const char *title);
#ifdef MACOSX
- ~BrowserDialog();
+ ~DirBrowserDialog();
virtual int runModal();
#else
virtual void open();
@@ -50,13 +52,12 @@ public:
const FilesystemNode &getResult() { return _choice; }
-
protected:
#ifdef MACOSX
CFStringRef _titleRef;
#else
ListWidget *_fileList;
- StaticTextWidget*_currentPath;
+ StaticTextWidget *_currentPath;
FilesystemNode _node;
FSList _nodeContent;
#endif
@@ -67,6 +68,29 @@ protected:
#endif
};
+// TODO: MACOSX version
+
+class FileBrowserDialog : public Dialog {
+ typedef Common::String String;
+ typedef Common::StringList StringList;
+public:
+ FileBrowserDialog(const char *title);
+
+ virtual void open();
+ virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
+
+ const FilesystemNode &getResult() { return _choice; }
+
+protected:
+ ListWidget *_fileList;
+ StaticTextWidget *_currentPath;
+ FilesystemNode _node;
+ FSList _nodeContent;
+ FilesystemNode _choice;
+
+ void updateListing();
+};
+
} // End of namespace GUI
#endif
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 07acdad6ee..e9b784ef45 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -349,7 +349,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
// Change path for the game
case kCmdGameBrowser: {
- BrowserDialog *_browser = new BrowserDialog("Select additional game directory");
+ DirBrowserDialog *_browser = new DirBrowserDialog("Select additional game directory");
if (_browser->runModal() > 0) {
// User made his choice...
FilesystemNode dir(_browser->getResult());
@@ -366,7 +366,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
// Change path for extra game data (eg, using sword cutscenes when playing via CD)
case kCmdExtraBrowser: {
- BrowserDialog *_browser = new BrowserDialog("Select additional game directory");
+ DirBrowserDialog *_browser = new DirBrowserDialog("Select additional game directory");
if (_browser->runModal() > 0) {
// User made his choice...
FilesystemNode dir(_browser->getResult());
@@ -377,7 +377,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
}
// Change path for stored save game (perm and temp) data
case kCmdSaveBrowser: {
- BrowserDialog *_browser = new BrowserDialog("Select directory for saved games");
+ DirBrowserDialog *_browser = new DirBrowserDialog("Select directory for saved games");
if (_browser->runModal() > 0) {
// User made his choice...
FilesystemNode dir(_browser->getResult());
@@ -449,7 +449,7 @@ LauncherDialog::LauncherDialog(GameDetector &detector)
updateButtons();
// Create file browser dialog
- _browser = new BrowserDialog("Select directory with game data");
+ _browser = new DirBrowserDialog("Select directory with game data");
}
void LauncherDialog::selectGame(const String &name) {
diff --git a/gui/launcher.h b/gui/launcher.h
index ba6cfa5210..90c51b657d 100644
--- a/gui/launcher.h
+++ b/gui/launcher.h
@@ -28,7 +28,7 @@ class GameDetector;
namespace GUI {
-class BrowserDialog;
+class DirBrowserDialog;
class ListWidget;
class LauncherDialog : public Dialog {
@@ -47,7 +47,7 @@ protected:
Widget *_removeButton;
StringList _domains;
GameDetector &_detector;
- BrowserDialog *_browser;
+ DirBrowserDialog *_browser;
void updateListing();
void updateButtons();
diff --git a/gui/options.cpp b/gui/options.cpp
index c3f21b5163..040fafc9d0 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -50,7 +50,7 @@
namespace GUI {
// TODO - allow changing options for:
-// - the save path (use _browser!)
+// - the save path (use _dirBrowser!)
// - music & graphics driver (but see also the comments on EditGameDialog
// for some techincal difficulties with this)
// - default volumes (sfx/speech/music)
@@ -60,6 +60,7 @@ enum {
kMusicVolumeChanged = 'muvc',
kSfxVolumeChanged = 'sfvc',
kSpeechVolumeChanged = 'vcvc',
+ kChooseSoundFontCmd = 'chsf',
kChooseSaveDirCmd = 'chos',
kChooseExtraDirCmd = 'chex'
};
@@ -343,18 +344,24 @@ int OptionsDialog::addMIDIControls(GuiObject *boss, int yoffset) {
_midiPopUp->appendEntry(md->description, md->id);
md++;
}
+
+ // SoundFont
+ new ButtonWidget(boss, x, yoffset, kButtonWidth + 14, 16, "SoundFont: ", kChooseSoundFontCmd, 0);
+ _soundFont = new StaticTextWidget(boss, x + kButtonWidth + 20, yoffset + 3, _w - (x + kButtonWidth + 20) - 10, kLineHeight, "None", kTextAlignLeft);
+
+ yoffset += 18;
// Multi midi setting
_multiMidiCheckbox = new CheckboxWidget(boss, x, yoffset, w, 16, "Mixed Adlib/MIDI mode");
- yoffset += 16;
+ yoffset += 15;
// Native mt32 setting
_mt32Checkbox = new CheckboxWidget(boss, x, yoffset, w, 16, "True Roland MT-32 (disable GM emulation)");
- yoffset += 16;
+ yoffset += 15;
// Subtitles on/off
_subCheckbox = new CheckboxWidget(boss, x, yoffset, w, 16, "Display subtitles");
- yoffset += 16;
+ yoffset += 15;
_enableAudioSettings = true;
@@ -448,8 +455,9 @@ GlobalOptionsDialog::GlobalOptionsDialog(GameDetector &detector)
addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
- // Create file browser dialog
- _browser = new BrowserDialog("Select directory for savegames");
+ // Create file browser dialogs
+ _dirBrowser = new DirBrowserDialog("Select directory for savegames");
+ _fileBrowser = new FileBrowserDialog("Select SoundFont");
#ifdef _WIN32_WCE
_keysDialog = new CEKeysDialog();
@@ -457,7 +465,8 @@ GlobalOptionsDialog::GlobalOptionsDialog(GameDetector &detector)
}
GlobalOptionsDialog::~GlobalOptionsDialog() {
- delete _browser;
+ delete _dirBrowser;
+ delete _fileBrowser;
#ifdef _WIN32_WCE
delete _keysDialog;
@@ -471,6 +480,7 @@ void GlobalOptionsDialog::open() {
// Set _savePath to the current save path
Common::String dir(ConfMan.get("savepath", _domain));
Common::String extraPath(ConfMan.get("extrapath", _domain));
+ Common::String soundFont(ConfMan.get("soundfont", _domain));
if (!dir.isEmpty()) {
_savePath->setLabel(dir);
@@ -486,6 +496,12 @@ void GlobalOptionsDialog::open() {
} else {
_extraPath->setLabel(extraPath);
}
+
+ if (soundFont.isEmpty() || !ConfMan.hasKey("soundfont", _domain)) {
+ _soundFont->setLabel("None");
+ } else {
+ _soundFont->setLabel(soundFont);
+ }
#endif
}
@@ -497,6 +513,10 @@ void GlobalOptionsDialog::close() {
String extraPath = _extraPath->getLabel();
if (!extraPath.isEmpty() && (extraPath != "None"))
ConfMan.set("extrapath", extraPath, _domain);
+
+ String soundFont = _soundFont->getLabel();
+ if (!soundFont.isEmpty() && (soundFont != "None"))
+ ConfMan.set("soundfont", soundFont, _domain);
}
OptionsDialog::close();
}
@@ -504,20 +524,27 @@ void GlobalOptionsDialog::close() {
void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kChooseSaveDirCmd:
- if (_browser->runModal() > 0) {
+ if (_dirBrowser->runModal() > 0) {
// User made his choice...
- FilesystemNode dir(_browser->getResult());
+ FilesystemNode dir(_dirBrowser->getResult());
_savePath->setLabel(dir.path());
// TODO - we should check if the directory is writeable before accepting it
}
break;
case kChooseExtraDirCmd:
- if (_browser->runModal() > 0) {
+ if (_dirBrowser->runModal() > 0) {
// User made his choice...
- FilesystemNode dir(_browser->getResult());
+ FilesystemNode dir(_dirBrowser->getResult());
_extraPath->setLabel(dir.path());
}
break;
+ case kChooseSoundFontCmd:
+ if (_fileBrowser->runModal() > 0) {
+ // User made his choice...
+ FilesystemNode file(_fileBrowser->getResult());
+ _soundFont->setLabel(file.path());
+ }
+ break;
#ifdef _WIN32_WCE
case kChooseKeyMappingCmd:
_keysDialog->runModal();
diff --git a/gui/options.h b/gui/options.h
index 497e216ed5..5797a62494 100644
--- a/gui/options.h
+++ b/gui/options.h
@@ -32,7 +32,8 @@ class GameDetector;
namespace GUI {
-class BrowserDialog;
+class DirBrowserDialog;
+class FileBrowserDialog;
class CheckboxWidget;
class PopUpWidget;
class SliderWidget;
@@ -55,6 +56,8 @@ protected:
/** Config domain this dialog is used to edit. */
String _domain;
+ StaticTextWidget *_soundFont;
+
int addGraphicControls(GuiObject *boss, int yoffset);
int addMIDIControls(GuiObject *boss, int yoffset);
int addVolumeControls(GuiObject *boss, int yoffset);
@@ -109,7 +112,8 @@ public:
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
protected:
- BrowserDialog *_browser;
+ DirBrowserDialog *_dirBrowser;
+ FileBrowserDialog *_fileBrowser;
#ifdef _WIN32_WCE
CEKeysDialog *_keysDialog;
#endif