aboutsummaryrefslogtreecommitdiff
path: root/gui/launcher.cpp
diff options
context:
space:
mode:
authorMax Horn2002-11-19 01:36:47 +0000
committerMax Horn2002-11-19 01:36:47 +0000
commitce3cde15a027fd092d0d27fa165f0166d4ecb927 (patch)
tree6da6d74fef1a1bf25b6380eed687f6fcc1f1068a /gui/launcher.cpp
parentf2007606a9155190ffe061dfde90fd1711ec73e8 (diff)
downloadscummvm-rg350-ce3cde15a027fd092d0d27fa165f0166d4ecb927.tar.gz
scummvm-rg350-ce3cde15a027fd092d0d27fa165f0166d4ecb927.tar.bz2
scummvm-rg350-ce3cde15a027fd092d0d27fa165f0166d4ecb927.zip
added some preliminary game auto detect code to the launcher; this required a small change to the FS API, Windows/Morphos code will have to be adapted slightly I fear. Also, not all games are detected correctly, and some probably never will be, so we still have to add a dialog for cases where auto detect doesn't work
svn-id: r5600
Diffstat (limited to 'gui/launcher.cpp')
-rw-r--r--gui/launcher.cpp78
1 files changed, 77 insertions, 1 deletions
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 2526d0a6ba..8d3e727b83 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -24,10 +24,12 @@
#include "newgui.h"
#include "ListWidget.h"
+#include "backends/fs/fs.h"
#include "common/config-file.h"
#include "common/engine.h"
#include "common/gameDetector.h"
+
enum {
kStartCmd = 'STRT',
kOptionsCmd = 'OPTN',
@@ -118,6 +120,74 @@ LauncherDialog::LauncherDialog(NewGui *gui, GameDetector &detector)
bw->setEnabled(false);
}
+bool findGame(FilesystemNode *dir)
+{
+ /*
+ atlantis -> ATLANTIS.000
+ dig -> dig.la0
+ ft -> ft.la0
+ indy3 -> 00.LFL, ???
+ indy3vga -> 00.LFL, INDYVGA.EXE
+ loom -> 00.LFL, LOOMEXE.EXE
+ loomcd -> 000.LFL, LOOM.EXE
+ maniac -> 00.LFL, MANIACEX.EXE
+ monkey -> monkey.000
+ monkey2 -> monkey2.000
+ monkeyvga -> 000.LFL, MONKEY.EXE
+ samnmax -> samnmax.000
+ tentacle -> tentacle.000
+ zak -> 00.LFL, zakexe.exe
+ zak256 -> 00.LFL, ZAK.EXP
+ */
+
+ // TODO - this doesn't deal with Simon games at all yet!
+ // We may have to offer a choice dialog between win/dos/talkie versions...
+
+ // TODO - if we can't decide which game this supposedly is, we should ask the user.
+ // We simply can't autodetect all games, e.g. for old games (with 00.LFL), it is
+ // hard to distinguish them based on file names alone. We do luck for .exe files
+ // but those could be deleted by the user, or for the Amiga/Mac/... versions
+ // may not be present at all.
+ // Or maybe somebody has a better idea? Is there a reliable way to tell from
+ // the XX.lfl files which game we are dealing with (taking into account that
+ // for most of the games many variations exist, so we can't just hard code expected
+ // file sizes or checksums).
+
+// ScummVM::Map<String, FilesystemNode *file> map;
+
+ FSList *files = dir->listDir(FilesystemNode::kListFilesOnly);
+ int size = files->size();
+ for (int i = 0; i < size; i++) {
+ const char *filename = (*files)[i].displayName().c_str();
+ //printf("%2d. %s\n", i, filename);
+
+ // Check if there is any game matching this file
+ const VersionSettings *v = version_settings;
+ while (v->filename && v->gamename) {
+ char detectName[256];
+ if (v->detectname)
+ strcpy(detectName, v->detectname);
+ else {
+ strcpy(detectName, v->filename);
+ if (v->features & GF_AFTER_V7)
+ strcat(detectName, ".la0");
+ else if (v->features & GF_HUMONGOUS)
+ strcat(detectName, ".he0");
+ else
+ strcat(detectName, ".000");
+ }
+ if (0 == scumm_stricmp(detectName, filename)) {
+ printf("Match found, apparently this is '%s'\n", v->gamename);
+ return true;
+ }
+ v++;
+ }
+ }
+
+ printf("Unable to autodetect a game in %s\n", dir->displayName().c_str());
+ return false;
+}
+
void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
{
int item;
@@ -132,7 +202,13 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
// which choices are possible. E.g. if we don't find atlantis.000 in that
// directory, then it's not FOA etc.
BrowserDialog *browser = new BrowserDialog(_gui);
- browser->runModal();
+ if (browser->runModal()) {
+ // User did make a choice...
+ FilesystemNode *dir = browser->getResult();
+
+ // ...so let's examine it and try to figure out which game it is
+ findGame(dir);
+ }
delete browser;
}
break;