From 81a994164552185d94703d381453865a4570b38e Mon Sep 17 00:00:00 2001 From: Aloshi Date: Tue, 7 Jan 2014 16:57:30 -0600 Subject: [PATCH] Added an error if the tag is missing. Made SystemView more themable (added a ThemeExtras component, made theming on pre-existing elements less restrictive). --- THEMES.md | 4 +- src/SystemData.cpp | 6 +++ src/main.cpp | 105 +++++++++++++++++++-------------------- src/views/SystemView.cpp | 10 ++-- src/views/SystemView.h | 1 + 5 files changed, 67 insertions(+), 59 deletions(-) diff --git a/THEMES.md b/THEMES.md index a787436cf..196e0d03b 100644 --- a/THEMES.md +++ b/THEMES.md @@ -200,8 +200,8 @@ Reference * image name="header" - POSITION | SIZE | PATH #### system - * image name="header" - PATH - * image name="system" - PATH + * image name="header" - ALL + * image name="system" - ALL #### menu * ninepatch name="background" - PATH diff --git a/src/SystemData.cpp b/src/SystemData.cpp index 187b223e8..a0ee45567 100644 --- a/src/SystemData.cpp +++ b/src/SystemData.cpp @@ -238,6 +238,12 @@ bool SystemData::loadConfig(const std::string& path, bool writeExample) //actually read the file pugi::xml_node systemList = doc.child("systemList"); + if(!systemList) + { + LOG(LogError) << "es_systems.cfg is missing the tag!"; + return false; + } + for(pugi::xml_node system = systemList.child("system"); system; system = system.next_sibling("system")) { std::string name, fullname, path, cmd; diff --git a/src/main.cpp b/src/main.cpp index 2a43f2e18..013919bb4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,62 +24,59 @@ bool scrape_cmdline = false; bool parseArgs(int argc, char* argv[], unsigned int* width, unsigned int* height) { - if(argc > 1) + for(int i = 1; i < argc; i++) { - for(int i = 1; i < argc; i++) + if(strcmp(argv[i], "-w") == 0) { - if(strcmp(argv[i], "-w") == 0) - { - *width = atoi(argv[i + 1]); - i++; //skip the argument value - }else if(strcmp(argv[i], "-h") == 0) - { - *height = atoi(argv[i + 1]); - i++; //skip the argument value - }else if(strcmp(argv[i], "--gamelist-only") == 0) - { - Settings::getInstance()->setBool("PARSEGAMELISTONLY", true); - }else if(strcmp(argv[i], "--ignore-gamelist") == 0) - { - Settings::getInstance()->setBool("IGNOREGAMELIST", true); - }else if(strcmp(argv[i], "--draw-framerate") == 0) - { - Settings::getInstance()->setBool("DRAWFRAMERATE", true); - }else if(strcmp(argv[i], "--no-exit") == 0) - { - Settings::getInstance()->setBool("DONTSHOWEXIT", true); - }else if(strcmp(argv[i], "--debug") == 0) - { - Settings::getInstance()->setBool("DEBUG", true); - Log::setReportingLevel(LogDebug); - }else if(strcmp(argv[i], "--dimtime") == 0) - { - Settings::getInstance()->setInt("DIMTIME", atoi(argv[i + 1]) * 1000); - i++; //skip the argument value - }else if(strcmp(argv[i], "--windowed") == 0) - { - Settings::getInstance()->setBool("WINDOWED", true); - }else if(strcmp(argv[i], "--scrape") == 0) - { - scrape_cmdline = true; - }else if(strcmp(argv[i], "--help") == 0) - { - std::cout << "EmulationStation, a graphical front-end for ROM browsing.\n"; - std::cout << "Command line arguments:\n"; - std::cout << "-w [width in pixels] set screen width\n"; - std::cout << "-h [height in pixels] set screen height\n"; - std::cout << "--gamelist-only skip automatic game detection, only read from gamelist.xml\n"; - std::cout << "--ignore-gamelist ignore the gamelist (useful for troubleshooting)\n"; - std::cout << "--draw-framerate display the framerate\n"; - std::cout << "--no-exit don't show the exit option in the menu\n"; - std::cout << "--debug even more logging\n"; - std::cout << "--dimtime [seconds] time to wait before dimming the screen (default 30, use 0 for never)\n"; - std::cout << "--scrape scrape using command line interface\n"; - std::cout << "--windowed not fullscreen\n"; - std::cout << "--help summon a sentient, angry tuba\n\n"; - std::cout << "More information available in README.md.\n"; - return false; //exit after printing help - } + *width = atoi(argv[i + 1]); + i++; //skip the argument value + }else if(strcmp(argv[i], "-h") == 0) + { + *height = atoi(argv[i + 1]); + i++; //skip the argument value + }else if(strcmp(argv[i], "--gamelist-only") == 0) + { + Settings::getInstance()->setBool("PARSEGAMELISTONLY", true); + }else if(strcmp(argv[i], "--ignore-gamelist") == 0) + { + Settings::getInstance()->setBool("IGNOREGAMELIST", true); + }else if(strcmp(argv[i], "--draw-framerate") == 0) + { + Settings::getInstance()->setBool("DRAWFRAMERATE", true); + }else if(strcmp(argv[i], "--no-exit") == 0) + { + Settings::getInstance()->setBool("DONTSHOWEXIT", true); + }else if(strcmp(argv[i], "--debug") == 0) + { + Settings::getInstance()->setBool("DEBUG", true); + Log::setReportingLevel(LogDebug); + }else if(strcmp(argv[i], "--dimtime") == 0) + { + Settings::getInstance()->setInt("DIMTIME", atoi(argv[i + 1]) * 1000); + i++; //skip the argument value + }else if(strcmp(argv[i], "--windowed") == 0) + { + Settings::getInstance()->setBool("WINDOWED", true); + }else if(strcmp(argv[i], "--scrape") == 0) + { + scrape_cmdline = true; + }else if(strcmp(argv[i], "--help") == 0) + { + std::cout << "EmulationStation, a graphical front-end for ROM browsing.\n"; + std::cout << "Command line arguments:\n"; + std::cout << "-w [width in pixels] set screen width\n"; + std::cout << "-h [height in pixels] set screen height\n"; + std::cout << "--gamelist-only skip automatic game detection, only read from gamelist.xml\n"; + std::cout << "--ignore-gamelist ignore the gamelist (useful for troubleshooting)\n"; + std::cout << "--draw-framerate display the framerate\n"; + std::cout << "--no-exit don't show the exit option in the menu\n"; + std::cout << "--debug even more logging\n"; + std::cout << "--dimtime [seconds] time to wait before dimming the screen (default 30, use 0 for never)\n"; + std::cout << "--scrape scrape using command line interface\n"; + std::cout << "--windowed not fullscreen, should be used in conjunction with -w and -h\n"; + std::cout << "--help summon a sentient, angry tuba\n\n"; + std::cout << "More information available in README.md.\n"; + return false; //exit after printing help } } diff --git a/src/views/SystemView.cpp b/src/views/SystemView.cpp index 6a69bd308..33b8f5093 100644 --- a/src/views/SystemView.cpp +++ b/src/views/SystemView.cpp @@ -10,7 +10,8 @@ SystemView::SystemView(Window* window, SystemData* system) : GuiComponent(window mHeaderImage(window), mHeaderText(window), - mImage(window) + mImage(window), + mExtras(window) { setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); @@ -26,6 +27,7 @@ SystemView::SystemView(Window* window, SystemData* system) : GuiComponent(window mImage.setPosition(mSize.x() / 2, mSize.y() * 0.6f); mImage.setResize(0, mSize.y() * 0.8f, false); + addChild(&mExtras); addChild(&mImage); addChild(&mHeaderText); addChild(&mHeaderImage); @@ -37,8 +39,10 @@ void SystemView::updateData() { using namespace ThemeFlags; + mExtras.setExtras(ThemeData::makeExtras(mSystem->getTheme(), "system", mWindow)); + mHeaderImage.setImage(""); - mHeaderImage.applyTheme(mSystem->getTheme(), "system", "header", PATH); + mHeaderImage.applyTheme(mSystem->getTheme(), "system", "header", ALL); // header if(mHeaderImage.hasImage()) @@ -51,7 +55,7 @@ void SystemView::updateData() mHeaderText.setText(mSystem->getFullName()); } - mImage.applyTheme(mSystem->getTheme(), "system", "system", PATH); + mImage.applyTheme(mSystem->getTheme(), "system", "system", ALL); } bool SystemView::input(InputConfig* config, Input input) diff --git a/src/views/SystemView.h b/src/views/SystemView.h index a926285c0..9fd4c25d4 100644 --- a/src/views/SystemView.h +++ b/src/views/SystemView.h @@ -22,4 +22,5 @@ private: TextComponent mHeaderText; ImageComponent mHeaderImage; ImageComponent mImage; + ThemeExtras mExtras; };