diff options
Diffstat (limited to 'gui/themebrowser.cpp')
-rw-r--r-- | gui/themebrowser.cpp | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/gui/themebrowser.cpp b/gui/themebrowser.cpp index bf718d5e4a..c935f04143 100644 --- a/gui/themebrowser.cpp +++ b/gui/themebrowser.cpp @@ -43,21 +43,21 @@ enum { // but for now this simple browser works, // also it will get its own theme config values // and not use 'browser_' anymore -ThemeBrowser::ThemeBrowser() : Dialog("browser") { +ThemeBrowser::ThemeBrowser() : Dialog("Browser") { _fileList = 0; - new StaticTextWidget(this, "browser_headline", "Select a Theme"); + new StaticTextWidget(this, "Browser.Headline", "Select a Theme"); // Add file list - _fileList = new ListWidget(this, "browser_list"); + _fileList = new ListWidget(this, "Browser.List"); _fileList->setNumberingMode(kListNumberingOff); _fileList->setEditable(false); - _fileList->setHints(THEME_HINT_PLAIN_COLOR); + _backgroundType = GUI::Theme::kDialogBackgroundPlain; // Buttons - new ButtonWidget(this, "browser_cancel", "Cancel", kCloseCmd, 0); - new ButtonWidget(this, "browser_choose", "Choose", kChooseCmd, 0); + new ButtonWidget(this, "Browser.Cancel", "Cancel", kCloseCmd, 0); + new ButtonWidget(this, "Browser.Choose", "Choose", kChooseCmd, 0); } void ThemeBrowser::open() { @@ -91,9 +91,8 @@ void ThemeBrowser::updateListing() { // classic is always build in Entry th; - th.name = "Classic (Builtin)"; - th.type = "Classic"; - th.file = "Classic (Builtin)"; + th.name = "ScummVM Classic Theme (Builtin Version)"; + th.file = "builtin"; _themes.push_back(th); // we are using only the paths 'themepath', 'extrapath', DATA_PATH and '.' @@ -151,12 +150,28 @@ void ThemeBrowser::addDir(ThList &list, const Common::String &dir, int level) { return; for (Common::FSList::const_iterator i = fslist.begin(); i != fslist.end(); ++i) { - if (i->isDirectory()) { - addDir(list, i->getPath(), level-1); - } else { + Entry th; + if (isTheme(*i, th)) { + bool add = true; + + for (ThList::const_iterator p = list.begin(); p != list.end(); ++p) { + if (p->name == th.name || p->file == th.file) { + add = false; + break; + } + } + + if (add) + list.push_back(th); + } + } + + if (node.lookupFile(fslist, "THEMERC", false, true, 1)) { + for (FSList::const_iterator i = fslist.begin(); i != fslist.end(); ++i) { Entry th; - if (isTheme(*i, th)) { + if (isTheme(i->getParent(), th)) { bool add = true; + for (ThList::const_iterator p = list.begin(); p != list.end(); ++p) { if (p->name == th.name || p->file == th.file) { add = false; @@ -172,27 +187,18 @@ void ThemeBrowser::addDir(ThList &list, const Common::String &dir, int level) { } bool ThemeBrowser::isTheme(const Common::FilesystemNode &node, Entry &out) { - Common::ConfigFile cfg; - Common::String type; - - out.file = node.getName(); - for (int i = out.file.size()-1; out.file[i] != '.' && i > 0; --i) { - out.file.deleteLastChar(); - } - out.file.deleteLastChar(); - - if (out.file.empty()) + out.file = node.getPath(); + +#ifdef USE_ZLIB + if (!out.file.hasSuffix(".zip") && !node.isDirectory()) return false; - - if (!Theme::themeConfigUseable(out.file, "", &type, &cfg)) +#else + if (!node.isDirectory()) + return false; +#endif + + if (!Theme::themeConfigUseable(node, out.name)) return false; - - out.type = type; - - if (cfg.hasKey("name", "theme")) - cfg.getKey("name", "theme", out.name); - else - out.name = out.file; return true; } |