From 50396dda70076f37801066a23c6ab37ecd6c3975 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 30 Sep 2008 12:37:28 +0000 Subject: cleanup svn-id: r34701 --- gui/theme.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'gui') diff --git a/gui/theme.cpp b/gui/theme.cpp index 8928d2f467..39dedd3875 100644 --- a/gui/theme.cpp +++ b/gui/theme.cpp @@ -71,9 +71,10 @@ const Graphics::Font *Theme::loadFont(const char *filename) { #ifdef USE_ZLIB Common::ZipArchive zipArchive(_stylefile + ".zip"); - if (zipArchive.hasFile(cacheFilename)) { - Common::FilePtr stream(zipArchive.openFile(cacheFilename)); - font = Graphics::NewFont::loadFromCache(*stream.get()); + Common::SeekableReadStream *stream(zipArchive.openFile(cacheFilename)); + if (stream) { + font = Graphics::NewFont::loadFromCache(*stream); + delete stream; } #endif if (font) @@ -88,9 +89,10 @@ const Graphics::Font *Theme::loadFont(const char *filename) { #ifdef USE_ZLIB if (!font) { Common::ZipArchive zipArchive(_stylefile + ".zip"); - if (zipArchive.hasFile(filename)) { - Common::FilePtr stream(zipArchive.openFile(filename)); - font = Graphics::NewFont::loadFont(*stream.get()); + Common::SeekableReadStream *stream(zipArchive.openFile(filename)); + if (stream) { + font = Graphics::NewFont::loadFont(*stream); + delete stream; } } #endif @@ -139,10 +141,9 @@ bool Theme::loadConfigFile(const Common::String &stylefile) { #ifdef USE_ZLIB // Maybe find a nicer solution to this Common::ZipArchive zipArchive(stylefile + ".zip"); - if (zipArchive.hasFile(stylefile + ".ini")) { - Common::FilePtr stream(zipArchive.openFile(stylefile + ".ini")); - if (_configFile.loadFromStream(*stream.get())) - return true; + Common::File file; + if (file.open(stylefile + ".ini", zipArchive)) { + return _configFile.loadFromStream(file); } #endif -- cgit v1.2.3 From d2c0facc6afdf33f45e82cd28f13a27ff9fa2017 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 30 Sep 2008 17:09:41 +0000 Subject: Fix ThemeBrowser to use FSNodes, not getPath() svn-id: r34713 --- gui/themebrowser.cpp | 19 +++++++++---------- gui/themebrowser.h | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'gui') diff --git a/gui/themebrowser.cpp b/gui/themebrowser.cpp index bf718d5e4a..6957ddcafa 100644 --- a/gui/themebrowser.cpp +++ b/gui/themebrowser.cpp @@ -101,10 +101,10 @@ void ThemeBrowser::updateListing() { // files in other places are ignored in this dialog // TODO: let the user browse the complete FS too/only the FS? if (ConfMan.hasKey("themepath")) - addDir(_themes, ConfMan.get("themepath"), 0); + addDir(_themes, Common::FilesystemNode(ConfMan.get("themepath")), 0); #ifdef DATA_PATH - addDir(_themes, DATA_PATH); + addDir(_themes, Common::FilesystemNode(DATA_PATH)); #endif #ifdef MACOSX @@ -112,7 +112,7 @@ void ThemeBrowser::updateListing() { if (resourceUrl) { char buf[256]; if (CFURLGetFileSystemRepresentation(resourceUrl, true, (UInt8 *)buf, 256)) { - Common::String resourcePath = buf; + Common::FilesystemNode resourcePath(buf); addDir(_themes, resourcePath, 0); } CFRelease(resourceUrl); @@ -120,9 +120,9 @@ void ThemeBrowser::updateListing() { #endif if (ConfMan.hasKey("extrapath")) - addDir(_themes, ConfMan.get("extrapath")); + addDir(_themes, Common::FilesystemNode(ConfMan.get("extrapath"))); - addDir(_themes, ".", 0); + addDir(_themes, Common::FilesystemNode("."), 0); // Populate the ListWidget Common::StringList list; @@ -137,12 +137,10 @@ void ThemeBrowser::updateListing() { draw(); } -void ThemeBrowser::addDir(ThList &list, const Common::String &dir, int level) { +void ThemeBrowser::addDir(ThList &list, const Common::FilesystemNode &node, int level) { if (level < 0) return; - Common::FilesystemNode node(dir); - if (!node.exists() || !node.isReadable()) return; @@ -152,7 +150,7 @@ void ThemeBrowser::addDir(ThList &list, const Common::String &dir, int level) { for (Common::FSList::const_iterator i = fslist.begin(); i != fslist.end(); ++i) { if (i->isDirectory()) { - addDir(list, i->getPath(), level-1); + addDir(list, *i, level-1); } else { Entry th; if (isTheme(*i, th)) { @@ -176,7 +174,8 @@ bool ThemeBrowser::isTheme(const Common::FilesystemNode &node, Entry &out) { Common::String type; out.file = node.getName(); - for (int i = out.file.size()-1; out.file[i] != '.' && i > 0; --i) { + // Remove the filename extension + while (out.file.lastChar() != '.') { out.file.deleteLastChar(); } out.file.deleteLastChar(); diff --git a/gui/themebrowser.h b/gui/themebrowser.h index e16a329c0e..fb378d9c66 100644 --- a/gui/themebrowser.h +++ b/gui/themebrowser.h @@ -57,7 +57,7 @@ private: void updateListing(); - void addDir(ThList &list, const Common::String &dir, int level = 4); + void addDir(ThList &list, const Common::FilesystemNode &node, int level = 4); bool isTheme(const Common::FilesystemNode &node, Entry &out); }; -- cgit v1.2.3 From c7fde102e325b423b1b153a78f7544697c052b72 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 2 Oct 2008 16:58:59 +0000 Subject: Renamed FilesystemNode -> FSNode svn-id: r34716 --- gui/browser.cpp | 12 ++++++------ gui/browser.h | 6 +++--- gui/launcher.cpp | 14 +++++++------- gui/massadd.cpp | 6 +++--- gui/massadd.h | 4 ++-- gui/options.cpp | 10 +++++----- gui/themebrowser.cpp | 16 ++++++++-------- gui/themebrowser.h | 4 ++-- 8 files changed, 36 insertions(+), 36 deletions(-) (limited to 'gui') diff --git a/gui/browser.cpp b/gui/browser.cpp index 978187c17e..e417a03688 100644 --- a/gui/browser.cpp +++ b/gui/browser.cpp @@ -107,7 +107,7 @@ int BrowserDialog::runModal() { err = FSRefMakePath(&ref, (UInt8*)buf, sizeof(buf)-1); assert(err == noErr); - _choice = Common::FilesystemNode(buf); + _choice = Common::FSNode(buf); choiceMade = true; } @@ -160,9 +160,9 @@ BrowserDialog::BrowserDialog(const char *title, bool dirBrowser) void BrowserDialog::open() { if (ConfMan.hasKey("browser_lastpath")) - _node = Common::FilesystemNode(ConfMan.get("browser_lastpath")); + _node = Common::FSNode(ConfMan.get("browser_lastpath")); if (!_node.isDirectory()) - _node = Common::FilesystemNode("."); + _node = Common::FSNode("."); // Alway refresh file list updateListing(); @@ -227,9 +227,9 @@ void BrowserDialog::updateListing() { ConfMan.set("browser_lastpath", _node.getPath()); // Read in the data from the file system - Common::FilesystemNode::ListMode listMode = - _isDirBrowser ? Common::FilesystemNode::kListDirectoriesOnly - : Common::FilesystemNode::kListAll; + Common::FSNode::ListMode listMode = + _isDirBrowser ? Common::FSNode::kListDirectoriesOnly + : Common::FSNode::kListAll; if (!_node.getChildren(_nodeContent, listMode)) { _nodeContent.clear(); } else { diff --git a/gui/browser.h b/gui/browser.h index c8bdec26a2..8dc7eda43a 100644 --- a/gui/browser.h +++ b/gui/browser.h @@ -50,7 +50,7 @@ public: virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); #endif - const Common::FilesystemNode &getResult() { return _choice; } + const Common::FSNode &getResult() { return _choice; } protected: #ifdef MACOSX @@ -58,10 +58,10 @@ protected: #else ListWidget *_fileList; StaticTextWidget *_currentPath; - Common::FilesystemNode _node; + Common::FSNode _node; Common::FSList _nodeContent; #endif - Common::FilesystemNode _choice; + Common::FSNode _choice; bool _isDirBrowser; #ifndef MACOSX diff --git a/gui/launcher.cpp b/gui/launcher.cpp index e9f718f4f0..c37a412440 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -395,7 +395,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat if (browser.runModal() > 0) { // User made this choice... - Common::FilesystemNode file(browser.getResult()); + Common::FSNode file(browser.getResult()); _soundFont->setLabel(file.getPath()); if (!file.getPath().empty() && (file.getPath() != "None")) @@ -413,11 +413,11 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat BrowserDialog browser("Select directory with game data", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); // TODO: Verify the game can be found in the new directory... Best // done with optional specific gameid to pluginmgr detectgames? - // FSList files = dir.listDir(FilesystemNode::kListFilesOnly); + // FSList files = dir.listDir(FSNode::kListFilesOnly); _gamePathWidget->setLabel(dir.getPath()); draw(); @@ -431,7 +431,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat BrowserDialog browser("Select additional game directory", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); _extraPathWidget->setLabel(dir.getPath()); draw(); } @@ -443,7 +443,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat BrowserDialog browser("Select directory for saved games", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); _savePathWidget->setLabel(dir.getPath()); draw(); } @@ -953,9 +953,9 @@ void LauncherDialog::addGame() { if (_browser->runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(_browser->getResult()); + Common::FSNode dir(_browser->getResult()); Common::FSList files; - if (!dir.getChildren(files, Common::FilesystemNode::kListAll)) { + if (!dir.getChildren(files, Common::FSNode::kListAll)) { error("browser returned a node that is not a directory: '%s'", dir.getPath().c_str()); } diff --git a/gui/massadd.cpp b/gui/massadd.cpp index c34c190776..6d40c4e78b 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -58,7 +58,7 @@ enum { -MassAddDialog::MassAddDialog(const Common::FilesystemNode &startDir) +MassAddDialog::MassAddDialog(const Common::FSNode &startDir) : Dialog("massadddialog"), _dirsScanned(0), _okButton(0), @@ -156,10 +156,10 @@ void MassAddDialog::handleTickle() { // Perform a breadth-first scan of the filesystem. while (!_scanStack.empty() && (g_system->getMillis() - t) < kMaxScanTime) { - Common::FilesystemNode dir = _scanStack.pop(); + Common::FSNode dir = _scanStack.pop(); Common::FSList files; - if (!dir.getChildren(files, Common::FilesystemNode::kListAll)) { + if (!dir.getChildren(files, Common::FSNode::kListAll)) { error("browser returned a node that is not a directory: '%s'", dir.getPath().c_str()); } diff --git a/gui/massadd.h b/gui/massadd.h index 733559cf37..c2a0eff2ba 100644 --- a/gui/massadd.h +++ b/gui/massadd.h @@ -38,14 +38,14 @@ class StaticTextWidget; class MassAddDialog : public Dialog { public: - MassAddDialog(const Common::FilesystemNode &startDir); + MassAddDialog(const Common::FSNode &startDir); //void open(); void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); void handleTickle(); private: - Common::Stack _scanStack; + Common::Stack _scanStack; GameList _games; /** diff --git a/gui/options.cpp b/gui/options.cpp index 335d4bc3d0..6797e4a80c 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -835,7 +835,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 BrowserDialog browser("Select directory for savegames", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); if (dir.isWritable()) { _savePath->setLabel(dir.getPath()); } else { @@ -851,7 +851,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 BrowserDialog browser("Select directory for GUI themes", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); _themePath->setLabel(dir.getPath()); draw(); } @@ -861,7 +861,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 BrowserDialog browser("Select directory for extra files", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); _extraPath->setLabel(dir.getPath()); draw(); } @@ -872,7 +872,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 BrowserDialog browser("Select directory for plugins", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); _pluginsPath->setLabel(dir.getPath()); draw(); } @@ -883,7 +883,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 BrowserDialog browser("Select SoundFont", false); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode file(browser.getResult()); + Common::FSNode file(browser.getResult()); _soundFont->setLabel(file.getPath()); if (!file.getPath().empty() && (file.getPath() != "None")) diff --git a/gui/themebrowser.cpp b/gui/themebrowser.cpp index 6957ddcafa..bf74c16e2f 100644 --- a/gui/themebrowser.cpp +++ b/gui/themebrowser.cpp @@ -101,10 +101,10 @@ void ThemeBrowser::updateListing() { // files in other places are ignored in this dialog // TODO: let the user browse the complete FS too/only the FS? if (ConfMan.hasKey("themepath")) - addDir(_themes, Common::FilesystemNode(ConfMan.get("themepath")), 0); + addDir(_themes, Common::FSNode(ConfMan.get("themepath")), 0); #ifdef DATA_PATH - addDir(_themes, Common::FilesystemNode(DATA_PATH)); + addDir(_themes, Common::FSNode(DATA_PATH)); #endif #ifdef MACOSX @@ -112,7 +112,7 @@ void ThemeBrowser::updateListing() { if (resourceUrl) { char buf[256]; if (CFURLGetFileSystemRepresentation(resourceUrl, true, (UInt8 *)buf, 256)) { - Common::FilesystemNode resourcePath(buf); + Common::FSNode resourcePath(buf); addDir(_themes, resourcePath, 0); } CFRelease(resourceUrl); @@ -120,9 +120,9 @@ void ThemeBrowser::updateListing() { #endif if (ConfMan.hasKey("extrapath")) - addDir(_themes, Common::FilesystemNode(ConfMan.get("extrapath"))); + addDir(_themes, Common::FSNode(ConfMan.get("extrapath"))); - addDir(_themes, Common::FilesystemNode("."), 0); + addDir(_themes, Common::FSNode("."), 0); // Populate the ListWidget Common::StringList list; @@ -137,7 +137,7 @@ void ThemeBrowser::updateListing() { draw(); } -void ThemeBrowser::addDir(ThList &list, const Common::FilesystemNode &node, int level) { +void ThemeBrowser::addDir(ThList &list, const Common::FSNode &node, int level) { if (level < 0) return; @@ -145,7 +145,7 @@ void ThemeBrowser::addDir(ThList &list, const Common::FilesystemNode &node, int return; Common::FSList fslist; - if (!node.getChildren(fslist, Common::FilesystemNode::kListAll)) + if (!node.getChildren(fslist, Common::FSNode::kListAll)) return; for (Common::FSList::const_iterator i = fslist.begin(); i != fslist.end(); ++i) { @@ -169,7 +169,7 @@ void ThemeBrowser::addDir(ThList &list, const Common::FilesystemNode &node, int } } -bool ThemeBrowser::isTheme(const Common::FilesystemNode &node, Entry &out) { +bool ThemeBrowser::isTheme(const Common::FSNode &node, Entry &out) { Common::ConfigFile cfg; Common::String type; diff --git a/gui/themebrowser.h b/gui/themebrowser.h index fb378d9c66..509e9dc2eb 100644 --- a/gui/themebrowser.h +++ b/gui/themebrowser.h @@ -57,8 +57,8 @@ private: void updateListing(); - void addDir(ThList &list, const Common::FilesystemNode &node, int level = 4); - bool isTheme(const Common::FilesystemNode &node, Entry &out); + void addDir(ThList &list, const Common::FSNode &node, int level = 4); + bool isTheme(const Common::FSNode &node, Entry &out); }; } // end of namespace GUI -- cgit v1.2.3 From c77124ff50dee8864a94a31b4a0f2a588daed445 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 2 Oct 2008 17:20:21 +0000 Subject: Fix for bug #2142743: Assertion on clicking "Theme" in Options svn-id: r34719 --- gui/themebrowser.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'gui') diff --git a/gui/themebrowser.cpp b/gui/themebrowser.cpp index bf74c16e2f..2c1c542319 100644 --- a/gui/themebrowser.cpp +++ b/gui/themebrowser.cpp @@ -174,11 +174,17 @@ bool ThemeBrowser::isTheme(const Common::FSNode &node, Entry &out) { Common::String type; out.file = node.getName(); + + // Only accept .ini and .zip fies + if (!out.file.hasSuffix(".ini") && !out.file.hasSuffix(".zip")) + return false; + // Remove the filename extension - while (out.file.lastChar() != '.') { + while (!out.file.empty() && out.file.lastChar() != '.') { out.file.deleteLastChar(); } - out.file.deleteLastChar(); + if (out.file.lastChar() == '.') + out.file.deleteLastChar(); if (out.file.empty()) return false; -- cgit v1.2.3 From b178332e3e5eef2972e566b5a4fca5b66189ba20 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 3 Oct 2008 00:16:21 +0000 Subject: Fixed typos (thanks to Raziel^ for spotting them). svn-id: r34727 --- gui/credits.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gui') diff --git a/gui/credits.h b/gui/credits.h index c04a99ddbd..d311561cc7 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -109,7 +109,7 @@ static const char *credits[] = { "\\C\\c0""Andrew Kurushin", "\\C\\c0""Eugene Sandulenko", "\\C\\c0""", -"\\C\\c1""Tinsel;", +"\\C\\c1""Tinsel", "\\C\\c0""Torbj\366rn Andersson", "\\C\\c0""Paul Gilbert", "\\C\\c0""Sven Hesse", @@ -217,7 +217,7 @@ static const char *credits[] = { "\\C\\c0""Peter Moraliyski", "\\C\\c2""Port: GP32", "\\C\\c0""Juha Niemim\344ki", -"\\C\\c2""Formaer AmigaOS 4 packager", +"\\C\\c2""Former AmigaOS 4 packager", "\\C\\c0""Jeremy Newman", "\\C\\c2""Former webmaster", "\\C\\c0""Lionel Ulmer", -- cgit v1.2.3 From b41cd58cee80ae682d6806fc448ca6772fd8ef61 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 4 Oct 2008 13:09:01 +0000 Subject: Renamed some MetaEngine feature flags; removed explicit numbers from this feature flag list (nothing should rely on their specific values, anyway); added a note that Engine::hasFeature should become independant of MetaEngine::hasFeature svn-id: r34738 --- gui/launcher.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gui') diff --git a/gui/launcher.cpp b/gui/launcher.cpp index c37a412440..c4b0a9bd6a 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -554,10 +554,10 @@ int SaveLoadChooser::runModal(const EnginePlugin *plugin, const String &target) _plugin = plugin; _target = target; _delSupport = (*_plugin)->hasFeature(MetaEngine::kSupportsDeleteSave); - _metaInfoSupport = (*_plugin)->hasFeature(MetaEngine::kSupportsMetaInfos); - _thumbnailSupport = _metaInfoSupport && (*_plugin)->hasFeature(MetaEngine::kSupportsThumbnails); - _saveDateSupport = _metaInfoSupport && (*_plugin)->hasFeature(MetaEngine::kSupportsSaveDate); - _playTimeSupport = _metaInfoSupport && (*_plugin)->hasFeature(MetaEngine::kSupportsSavePlayTime); + _metaInfoSupport = (*_plugin)->hasFeature(MetaEngine::kSavesSupportMetaInfo); + _thumbnailSupport = _metaInfoSupport && (*_plugin)->hasFeature(MetaEngine::kSavesSupportThumbnail); + _saveDateSupport = _metaInfoSupport && (*_plugin)->hasFeature(MetaEngine::kSavesSupportCreationDate); + _playTimeSupport = _metaInfoSupport && (*_plugin)->hasFeature(MetaEngine::kSavesSupportPlayTime); reflowLayout(); updateSaveList(); -- cgit v1.2.3