void Dialog::askRocket(){ if( !desktop ) { std::cerr << "No desktop found.\n"; return; } try { myDialogComponent = loadGUIFile( "gui/launch_rocket_yn.xml" ); assert( myDialogComponent != 0); registerDialog(); blockingDialogIsOpen = true; iAmBlocking = true; } catch(std::exception& e) { std::cerr << "Couldn't display message 'launch_rocket_yn': " << e.what() << "\n"; return; } Paragraph* p = getParagraph( *myDialogComponent, "DialogTitle" ); std::stringstream title; title << _("Launchsite") << " ( " << pointX <<" , " << pointY << " )"; p->setText( title.str() ); // connect signals Button* yesButton = getButton( *myDialogComponent, "Yes" ); yesButton->clicked.connect( makeCallback(*this, &Dialog::okayLaunchRocketButtonClicked ) ); Button* noButton = getButton( *myDialogComponent, "No" ); noButton->clicked.connect( makeCallback( *this, &Dialog::closeDialogButtonClicked ) ); Button* gotoButton = getButton( *myDialogComponent, "goto" ); gotoButton->clicked.connect( makeCallback( *this, &Dialog::gotoButtonClicked ) ); }
/* * Update Message in Message Window */ void updateMessageText( const std::string text ) { //Dialog Test Component* root = getGameView(); if(!root) { //happens while in menu. std::cerr << "Root not found.\n"; return; } while( root->getParent() ) root = root->getParent(); Desktop* desktop = dynamic_cast<Desktop*> (root); if(!desktop) { std::cerr << "Root not a desktop!?!\n"; return; } try { //test if message Windows is open Component* messageTextComponent = 0; messageTextComponent = root->findComponent( "messageText" ); if(messageTextComponent == 0) { messageTextComponent = loadGUIFile("gui/messagearea.xml"); assert(messageTextComponent != 0); desktop->addChildComponent(messageTextComponent); } Paragraph* messageText = getParagraph(*messageTextComponent, "messageText"); messageText->setText( text ); } catch(std::exception& e) { std::cerr << "Couldn't display message '" << text << "': " << e.what() << "\n"; return; } }
void MainMenu::loadMainMenu() { if(mainMenu.get() == 0) { mainMenu.reset(loadGUIFile("gui/mainmenu.xml")); // connect signals Button* quitButton = getButton(*mainMenu, "QuitButton"); quitButton->clicked.connect( makeCallback(*this, &MainMenu::quitButtonClicked)); Button* continueButton = getButton(*mainMenu, "ContinueButton"); continueButton->clicked.connect( makeCallback(*this, &MainMenu::continueButtonClicked)); Button* newGameButton = getButton(*mainMenu, "NewGameButton"); newGameButton->clicked.connect( makeCallback(*this, &MainMenu::newGameButtonClicked)); Button* loadGameButton = getButton(*mainMenu, "LoadButton"); loadGameButton->clicked.connect( makeCallback(*this, &MainMenu::loadGameButtonClicked)); Button* saveGameButton = getButton(*mainMenu, "SaveButton"); saveGameButton->clicked.connect( makeCallback(*this, &MainMenu::saveGameButtonClicked)); Button* creditsButton = getButton(*mainMenu, "CreditsButton"); creditsButton->clicked.connect( makeCallback(*this, &MainMenu::creditsButtonClicked)); Button* optionsButton = getButton(*mainMenu, "OptionsButton"); optionsButton->clicked.connect( makeCallback(*this, &MainMenu::optionsButtonClicked)); } mainMenu->resize(getConfig()->videoX, getConfig()->videoY); //(SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h); }
void Dialog::editMarket(){ if( !desktop ) { std::cerr << "No desktop found.\n"; return; } try { myDialogComponent = loadGUIFile( "gui/tradedialog.xml" ); assert( myDialogComponent != 0); registerDialog(); blockingDialogIsOpen = true; iAmBlocking = true; } catch(std::exception& e) { std::cerr << "Couldn't display dialog 'tradedialog.xml': " << e.what() << "\n"; return; } // set Dialog to Market-Data Paragraph* p = getParagraph( *myDialogComponent, "DialogTitle" ); std::stringstream title; title << _("Market") << " ( " << pointX <<" , " << pointY << " )"; p->setText( title.str() ); Market * market = static_cast <Market *> (world(pointX, pointY)->reportingConstruction); CheckButton* cb; cb = getCheckButton( *myDialogComponent, "BuyJobs" ); if( market->commodityRuleCount[Construction::STUFF_JOBS].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellJobs" ); if( market->commodityRuleCount[Construction::STUFF_JOBS].give ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyFood" ); if( market->commodityRuleCount[Construction::STUFF_FOOD].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellFood" ); if( market->commodityRuleCount[Construction::STUFF_FOOD].give ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyCoal" ); if( market->commodityRuleCount[Construction::STUFF_COAL].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellCoal" ); if( market->commodityRuleCount[Construction::STUFF_COAL].give ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyOre" ); if( market->commodityRuleCount[Construction::STUFF_ORE].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellOre" ); if( market->commodityRuleCount[Construction::STUFF_ORE].give ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyGoods" ); if( market->commodityRuleCount[Construction::STUFF_GOODS].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellGoods" ); if( market->commodityRuleCount[Construction::STUFF_GOODS].give ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuySteel" ); if( market->commodityRuleCount[Construction::STUFF_STEEL].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellSteel" ); if( market->commodityRuleCount[Construction::STUFF_STEEL].give) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyWaste" ); if( market->commodityRuleCount[Construction::STUFF_WASTE].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellWaste" ); if( market->commodityRuleCount[Construction::STUFF_WASTE].give) cb->check(); else cb->uncheck(); // connect signals Button* applyButton = getButton( *myDialogComponent, "Apply" ); applyButton->clicked.connect( makeCallback(*this, &Dialog::applyMarketButtonClicked ) ); Button* gotoButton = getButton( *myDialogComponent, "goto" ); gotoButton->clicked.connect( makeCallback( *this, &Dialog::gotoButtonClicked ) ); }
void Dialog::editMarket(){ if( !desktop ) { std::cerr << "No desktop found.\n"; return; } try { myDialogComponent = loadGUIFile( "gui/tradedialog.xml" ); assert( myDialogComponent != 0); registerDialog(); blockingDialogIsOpen = true; iAmBlocking = true; } catch(std::exception& e) { std::cerr << "Couldn't display dialog 'tradedialog.xml': " << e.what() << "\n"; return; } // set Dialog to Market-Data Paragraph* p = getParagraph( *myDialogComponent, "DialogTitle" ); std::stringstream title; title << _("Market") << " ( " << pointX <<" , " << pointY << " )"; p->setText( title.str() ); CheckButton* cb; cb = getCheckButton( *myDialogComponent, "BuyJobs" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MB_JOBS ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellJobs" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MS_JOBS ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyFood" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MB_FOOD) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellFood" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MS_FOOD) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyCoal" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MB_COAL) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellCoal" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MS_COAL) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyOre" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MB_ORE) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellOre" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MS_ORE) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyGoods" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MB_GOODS) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellGoods" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MS_GOODS) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuySteel" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MB_STEEL) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellSteel" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MS_STEEL) cb->check(); else cb->uncheck(); // connect signals Button* applyButton = getButton( *myDialogComponent, "Apply" ); applyButton->clicked.connect( makeCallback(*this, &Dialog::applyMarketButtonClicked ) ); Button* gotoButton = getButton( *myDialogComponent, "goto" ); gotoButton->clicked.connect( makeCallback( *this, &Dialog::gotoButtonClicked ) ); }
void MainMenu::loadCreditsMenu() { if(creditsMenu.get() == 0) { creditsMenu.reset(loadGUIFile("gui/credits.xml")); Button* backButton = getButton(*creditsMenu, "BackButton"); backButton->clicked.connect( makeCallback(*this, &MainMenu::creditsBackButtonClicked)); } creditsMenu->resize(getConfig()->videoX, getConfig()->videoY); //(SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h); }
void MainMenu::loadSaveGameMenu() { if(saveGameMenu.get() == 0) { saveGameMenu.reset(loadGUIFile("gui/savegame.xml")); // connect signals Button* saveButton = getButton(*saveGameMenu, "SaveButton"); saveButton->clicked.connect( makeCallback(*this, &MainMenu::loadGameSaveButtonClicked)); Button* backButton = getButton(*saveGameMenu, "BackButton"); backButton->clicked.connect( makeCallback(*this, &MainMenu::loadGameBackButtonClicked)); // fill in file-names into slots fillLoadMenu( true ); } saveGameMenu->resize(getConfig()->videoX, getConfig()->videoY); //(SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h); }
void MainMenu::loadNewGameMenu() { if(newGameMenu.get() == 0) { newGameMenu.reset(loadGUIFile("gui/newgame.xml")); // connect signals Button* startButton = getButton(*newGameMenu, "StartButton"); startButton->clicked.connect(makeCallback(*this, &MainMenu::newGameStartButtonClicked)); Button* backButton = getButton(*newGameMenu, "BackButton"); backButton->clicked.connect(makeCallback(*this, &MainMenu::newGameBackButtonClicked)); fillNewGameMenu(); } newGameMenu->resize(getConfig()->videoX, getConfig()->videoY); //(SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h); }
Game::Game() { gui.reset(loadGUIFile("gui/app.xml")); gui->resize(SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h); Button* gameMenu = getButton( *gui, "GameMenuButton" ); gameMenu->clicked.connect( makeCallback(*this, &Game::gameButtonClicked )); Button* helpButton = getButton( *gui, "HelpButton" ); helpButton->clicked.connect( makeCallback(*this, &Game::gameButtonClicked )); Button* statButton = getButton( *gui, "StatButton" ); statButton->clicked.connect( makeCallback(*this, &Game::gameButtonClicked )); Desktop* desktop = dynamic_cast<Desktop*> (gui.get()); if(desktop == 0) throw std::runtime_error("Game UI is not a Desktop Component"); helpWindow.reset(new HelpWindow(desktop)); gameptr = this; }
void Dialog::coalSurvey(){ if( !desktop ) { std::cerr << "No desktop found.\n"; return; } try { myDialogComponent = loadGUIFile( "gui/coal_survey_yn.xml" ); assert( myDialogComponent != 0); registerDialog(); blockingDialogIsOpen = true; iAmBlocking = true; } catch(std::exception& e) { std::cerr << "Couldn't display message 'coal_survey_yn': " << e.what() << "\n"; return; } // connect signals Button* yesButton = getButton( *myDialogComponent, "Yes" ); yesButton->clicked.connect( makeCallback(*this, &Dialog::okayCoalSurveyButtonClicked ) ); Button* noButton = getButton( *myDialogComponent, "No" ); noButton->clicked.connect( makeCallback( *this, &Dialog::closeDialogButtonClicked ) ); }
//no Signals caught here, so ScreenInterface has to catch them. void Dialog::msgDialog( std::string message, std::string extraString){ if( !desktop ) { std::cerr << "No desktop found.\n"; return; } //generate filename. foo.mes => gui/foo.xml std::string filename = "gui/"; filename += message; std::string::size_type pos = filename.rfind( ".mes" ); if( pos != std::string::npos ){ filename.replace( pos, 4 ,".xml"); } std::auto_ptr<Component> myDialogComponent (loadGUIFile( filename )); //set Extra-String getParagraph( *myDialogComponent, "ExtraText" )->setText( extraString ); // connect signals Button* noButton = getButton( *myDialogComponent, "Ok" ); noButton->clicked.connect( makeCallback( *this, &Dialog::closeDialogButtonClicked ) ); this->myDialogComponent = myDialogComponent.release(); registerDialog(); }
/* * Show game statistics in dialog and write them to RESULTS_FILENAME. * * gamestats.xml has 11 lines * statistic_text1 * [...] * statistic_text11 * and 15 lines in a Table with 6 columns * statistic_text_1_1 statistic_number_1_1 statistic_text_1_2 statistic_number_1_2 statistic_text_1_3 statistic_number_1_3 * [...] // * statistic_text_15_1 statistic_number_15_1 statistic_text_15_2 statistic_number_15_2 statistic_text_15_3 statistic_number_15_3 */ void Dialog::gameStats(){ saveGameStats(); if( !desktop ) { std::cerr << "No desktop found.\n"; return; } bool useExisting = false; myDialogComponent = desktop->findComponent("GameStats"); if( myDialogComponent == 0){ try { myDialogComponent = loadGUIFile( "gui/gamestats.xml" ); assert( myDialogComponent != 0); registerDialog(); } catch(std::exception& e) { std::cerr << "Couldn't display message 'gamestats': " << e.what() << "\n"; return; } } else { useExisting = true; } // Fill in Fields. int line = 1; int maxlength = 567; char* outf = (char *) malloc ( maxlength ); int group_count[NUM_OF_GROUPS]; count_all_groups (group_count); if (cheat_flag){ setParagraphN( "statistic_text", line++, _("----- IN TEST MODE -------") ); } snprintf (outf, maxlength, _("Game statistics from LinCity-NG Version %s"), PACKAGE_VERSION); setParagraphN( "statistic_text", line++, outf ); if (strlen (given_scene) > 3){ snprintf (outf, maxlength, _("Initial loaded scene - %s"), given_scene); setParagraphN( "statistic_text", line++, outf ); } if (sustain_flag){ snprintf (outf, maxlength, _("Economy is sustainable")); setParagraphN( "statistic_text", line++, outf ); } snprintf (outf, maxlength, _("Population %d of which %d are not housed.") ,housed_population + people_pool, people_pool); setParagraphN( "statistic_text", line++, outf ); snprintf (outf, maxlength, _("Max population %d Number evacuated %d Total births %d") ,max_pop_ever, total_evacuated, total_births); setParagraphN( "statistic_text", line++, outf ); snprintf (outf, maxlength, _("Date %s %04d Money %8d Tech-level %5.1f (%5.1f)"), current_month(total_time), current_year(total_time), total_money, (float) tech_level * 100.0 / MAX_TECH_LEVEL, (float) highest_tech_level * 100.0 / MAX_TECH_LEVEL); setParagraphN( "statistic_text", line++, outf ); snprintf (outf, maxlength, _("Deaths by starvation %7d History %8.3f"), total_starve_deaths, starve_deaths_history); setParagraphN( "statistic_text", line++, outf ); snprintf (outf, maxlength, _("Deaths from pollution %7d History %8.3f"), total_pollution_deaths, pollution_deaths_history); setParagraphN( "statistic_text", line++, outf ); snprintf (outf, maxlength, _("Years of unemployment %7d History %8.3f"), total_unemployed_years, unemployed_history); setParagraphN( "statistic_text", line++, outf ); snprintf (outf, maxlength, _("Rockets launched %2d Successful launches %2d"), rockets_launched, rockets_launched_success); setParagraphN( "statistic_text", line++, outf ); while( line <= 11 ){ //clear remaining lines setParagraphN( "statistic_text", line++, "" ); } free( outf ); setTableRC("statistic", 1, 1, _("Residences"), group_count[GROUP_RESIDENCE_LL] + group_count[GROUP_RESIDENCE_ML] + group_count[GROUP_RESIDENCE_HL] + group_count[GROUP_RESIDENCE_LH] + group_count[GROUP_RESIDENCE_MH] + group_count[GROUP_RESIDENCE_HH]); setTableRC("statistic", 1, 2, _("Markets"), group_count[GROUP_MARKET] ); setTableRC("statistic", 1, 3, _("Farms"), group_count[GROUP_ORGANIC_FARM]); setTableRC("statistic", 2, 1, _("Water wells"), group_count[GROUP_WATERWELL]); setTableRC("statistic", 2, 2, "", ""); setTableRC("statistic", 2, 3, "", ""); setTableRC("statistic", 3, 1, "", ""); setTableRC("statistic", 3, 2, "", ""); setTableRC("statistic", 3, 3, "", ""); setTableRC("statistic", 4, 1, _("Monuments"), group_count[GROUP_MONUMENT]); setTableRC("statistic", 4, 2, _("Schools"), group_count[GROUP_SCHOOL]); setTableRC("statistic", 4, 3, _("Universities"), group_count[GROUP_UNIVERSITY]); setTableRC("statistic", 5, 1, _("Fire stations"), group_count[GROUP_FIRESTATION]); setTableRC("statistic", 5, 2, _("Parks"), group_count[GROUP_PARKLAND]); setTableRC("statistic", 5, 3, _("Sports fields"), group_count[GROUP_CRICKET]); setTableRC("statistic", 6, 1, _("Health centres"), group_count[GROUP_HEALTH]); setTableRC("statistic", 6, 2, _("Tips"), group_count[GROUP_TIP]); setTableRC("statistic", 6, 3, _("Shanties"), group_count[GROUP_SHANTY]); setTableRC("statistic", 7, 1, "", ""); setTableRC("statistic", 7, 2, "", ""); setTableRC("statistic", 7, 3, "", ""); setTableRC("statistic", 8, 1, _("Windmills"), group_count[GROUP_WINDMILL]); setTableRC("statistic", 8, 2, _("Coal powers"), group_count[GROUP_COAL_POWER]); setTableRC("statistic", 8, 3, _("Solar powers"), group_count[GROUP_SOLAR_POWER]); setTableRC("statistic", 9, 1, _("Substations"), group_count[GROUP_SUBSTATION]); setTableRC("statistic", 9, 2, _("Power lines"), group_count[GROUP_POWER_LINE]); setTableRC("statistic", 9, 3, _("Ports"), group_count[GROUP_PORT]); setTableRC("statistic", 10, 1, _("Tracks"), group_count[GROUP_TRACK]); setTableRC("statistic", 10, 2, _("Roads"), group_count[GROUP_ROAD]); setTableRC("statistic", 10, 3, _("Rail"), group_count[GROUP_RAIL]); setTableRC("statistic", 11, 1, "", ""); setTableRC("statistic", 11, 2, "", ""); setTableRC("statistic", 11, 3, "", ""); setTableRC("statistic", 12, 1, _("Potteries"), group_count[GROUP_POTTERY]); setTableRC("statistic", 12, 2, _("Blacksmiths"), group_count[GROUP_BLACKSMITH]); setTableRC("statistic", 12, 3, _("Mills"), group_count[GROUP_MILL]); setTableRC("statistic", 13, 1, _("Light inds"), group_count[GROUP_INDUSTRY_L]); setTableRC("statistic", 13, 2, _("Heavy inds"), group_count[GROUP_INDUSTRY_H]); setTableRC("statistic", 13, 3, _("Recyclers"), group_count[GROUP_RECYCLE]); setTableRC("statistic", 14, 1, _("Coal mines"), group_count[GROUP_COALMINE]); setTableRC("statistic", 14, 2, _("Ore mines"), group_count[GROUP_OREMINE]); setTableRC("statistic", 14, 3, _("Communes"), group_count[GROUP_COMMUNE]); setTableRC("statistic", 15, 1, "", ""); setTableRC("statistic", 15, 2, "", ""); setTableRC("statistic", 15, 3, "", ""); if( !useExisting ){ // connect signals Button* noButton = getButton( *myDialogComponent, "Okay" ); noButton->clicked.connect( makeCallback( *this, &Dialog::closeDialogButtonClicked ) ); } }
/* * Show game statistics in dialog and write them to RESULTS_FILENAME. * * gamestats.xml has 11 lines * statistic_text1 * [...] * statistic_text11 * and 15 lines in a Table with 6 columns * statistic_text_1_1 statistic_number_1_1 statistic_text_1_2 statistic_number_1_2 statistic_text_1_3 statistic_number_1_3 * [...] // * statistic_text_15_1 statistic_number_15_1 statistic_text_15_2 statistic_number_15_2 statistic_text_15_3 statistic_number_15_3 */ void Dialog::gameStats(){ saveGameStats(); if( !desktop ) { std::cerr << "No desktop found.\n"; return; } bool useExisting = false; myDialogComponent = desktop->findComponent("GameStats"); if( myDialogComponent == 0){ try { myDialogComponent = loadGUIFile( "gui/gamestats.xml" ); assert( myDialogComponent != 0); registerDialog(); } catch(std::exception& e) { std::cerr << "Couldn't display message 'gamestats': " << e.what() << "\n"; return; } } else { useExisting = true; } // Fill in Fields. int line = 1; int maxlength = 567; char* outf = (char *) malloc ( maxlength ); if (cheat_flag){ setParagraphN( "statistic_text", line++, _("----- IN TEST MODE -------") ); } snprintf (outf, maxlength,"%s %s", _("Game statistics from LinCity-NG Version"), PACKAGE_VERSION); setParagraphN( "statistic_text", line++, outf ); if (strlen (given_scene) > 3){ snprintf (outf, maxlength,"%s - %s", _("Initial loaded scene"), given_scene); setParagraphN( "statistic_text", line++, outf ); } if (sustain_flag){ snprintf (outf, maxlength, "%s", _("Economy is sustainable")); setParagraphN( "statistic_text", line++, outf ); } snprintf (outf, maxlength, "%s %d %s %d %s.", _("Population"), population + people_pool, _("of which"), people_pool, _("are not housed")); setParagraphN( "statistic_text", line++, outf ); snprintf (outf, maxlength, "%s %d %s %d %s %d", _("Max population"), max_pop_ever, _("Number evacuated"), total_evacuated, _("Total births"), total_births); setParagraphN( "statistic_text", line++, outf ); snprintf (outf, maxlength, "%s %s %04d %s %8d %s %5.1f (%5.1f)", _("Date"), current_month(total_time), current_year(total_time), _("Money"), total_money, _("Tech-level"), (float) tech_level * 100.0 / MAX_TECH_LEVEL, (float) highest_tech_level * 100.0 / MAX_TECH_LEVEL); setParagraphN( "statistic_text", line++, outf ); snprintf (outf, maxlength, "%s %7d %s %8.3f", _("Deaths by starvation"), total_starve_deaths, _("History"), starve_deaths_history); setParagraphN( "statistic_text", line++, outf ); snprintf (outf, maxlength, "%s %7d %s %8.3f", _("Deaths from pollution"), total_pollution_deaths, _("History"), pollution_deaths_history); setParagraphN( "statistic_text", line++, outf ); snprintf (outf, maxlength, "%s %7d %s %8.3f", _("Years of unemployment"), total_unemployed_years, _("History"), unemployed_history); setParagraphN( "statistic_text", line++, outf ); snprintf (outf, maxlength, "%s %2d %s %2d", _("Rockets launched"), rockets_launched, _("Successful launches"), rockets_launched_success); setParagraphN( "statistic_text", line++, outf ); while( line <= 11 ){ //clear remaining lines setParagraphN( "statistic_text", line++, "" ); } free( outf ); setTableRC("statistic", 1, 1, _("Residences"), Counted<Residence>::getInstanceCount()); setTableRC("statistic", 1, 2, _("Markets"), Counted<Market>::getInstanceCount()); setTableRC("statistic", 1, 3, _("Farms"), Counted<Organic_farm>::getInstanceCount()); setTableRC("statistic", 2, 1, _("Water wells"), Counted<Waterwell>::getInstanceCount()); setTableRC("statistic", 2, 2, _("Wind powers"), Counted<Windpower>::getInstanceCount()); setTableRC("statistic", 2, 3, "", ""); setTableRC("statistic", 3, 1, "", ""); setTableRC("statistic", 3, 2, "", ""); setTableRC("statistic", 3, 3, "", ""); setTableRC("statistic", 4, 1, _("Monuments"), Counted<Monument>::getInstanceCount()); setTableRC("statistic", 4, 2, _("Schools"), Counted<School>::getInstanceCount()); setTableRC("statistic", 4, 3, _("Universities"), Counted<University>::getInstanceCount()); setTableRC("statistic", 5, 1, _("Fire stations"), Counted<FireStation>::getInstanceCount()); setTableRC("statistic", 5, 2, _("Parks"), Counted<Parkland>::getInstanceCount()); setTableRC("statistic", 5, 3, _("Sports fields"), Counted<Cricket>::getInstanceCount()); setTableRC("statistic", 6, 1, _("Health centres"), Counted<HealthCentre>::getInstanceCount()); setTableRC("statistic", 6, 2, _("Tips"), Counted<Tip>::getInstanceCount()); setTableRC("statistic", 6, 3, _("Shanties"), Counted<Shanty>::getInstanceCount()); setTableRC("statistic", 7, 1, "", ""); setTableRC("statistic", 7, 2, "", ""); setTableRC("statistic", 7, 3, "", ""); setTableRC("statistic", 8, 1, _("Windmills"), Counted<Windmill>::getInstanceCount()); setTableRC("statistic", 8, 2, _("Coal powers"), Counted<Coal_power>::getInstanceCount()); setTableRC("statistic", 8, 3, _("Solar powers"), Counted<SolarPower>::getInstanceCount()); setTableRC("statistic", 9, 1, _("Substations"), Counted<Substation>::getInstanceCount()); setTableRC("statistic", 9, 2, _("Power lines"), Counted<Powerline>::getInstanceCount()); setTableRC("statistic", 9, 3, _("Ports"), Counted<Port>::getInstanceCount()); setTableRC("statistic", 10, 1, _("Tracks"), Counted<Track>::getInstanceCount()); setTableRC("statistic", 10, 2, _("Roads"), Counted<Road>::getInstanceCount()); setTableRC("statistic", 10, 3, _("Rail"), Counted<Rail>::getInstanceCount()); setTableRC("statistic", 11, 1, "", ""); setTableRC("statistic", 11, 2, "", ""); setTableRC("statistic", 11, 3, "", ""); setTableRC("statistic", 12, 1, _("Potteries"), Counted<Pottery>::getInstanceCount()); setTableRC("statistic", 12, 2, _("Blacksmiths"), Counted<Blacksmith>::getInstanceCount()); setTableRC("statistic", 12, 3, _("Mills"), Counted<Mill>::getInstanceCount()); setTableRC("statistic", 13, 1, _("Light inds"), Counted<IndustryLight>::getInstanceCount()); setTableRC("statistic", 13, 2, _("Heavy inds"), Counted<IndustryHeavy>::getInstanceCount()); setTableRC("statistic", 13, 3, _("Recyclers"), Counted<Recycle>::getInstanceCount()); setTableRC("statistic", 14, 1, _("Coal mines"), Counted<Coalmine>::getInstanceCount()); setTableRC("statistic", 14, 2, _("Ore mines"), Counted<Oremine>::getInstanceCount()); setTableRC("statistic", 14, 3, _("Forests"), Counted<Commune>::getInstanceCount()); setTableRC("statistic", 15, 1, "", ""); setTableRC("statistic", 15, 2, "", ""); setTableRC("statistic", 15, 3, "", ""); if( !useExisting ){ // connect signals Button* noButton = getButton( *myDialogComponent, "Okay" ); noButton->clicked.connect( makeCallback( *this, &Dialog::closeDialogButtonClicked ) ); } }
void MainMenu::loadOptionsMenu() { if(optionsMenu.get() == 0) { optionsMenu.reset(loadGUIFile("gui/options.xml")); CheckButton* currentCheckButton = getCheckButton(*optionsMenu, "BackgroundMusic"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "SoundFX"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "Fullscreen"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "MusicVolumePlus"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "MusicVolumeMinus"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "FXVolumePlus"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "FXVolumeMinus"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "TrackPrev"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "TrackNext"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "ResolutionPrev"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "ResolutionNext"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "WorldLenPrev"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "WorldLenNext"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "LanguagePrev"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "LanguageNext"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "BinaryMode"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); currentCheckButton = getCheckButton(*optionsMenu, "SeedMode"); currentCheckButton->clicked.connect( makeCallback(*this, &MainMenu::optionsMenuButtonClicked)); Button* currentButton = getButton(*optionsMenu, "BackButton"); currentButton->clicked.connect( makeCallback(*this, &MainMenu::optionsBackButtonClicked)); } //adjust checkbutton-states if( getConfig()->musicEnabled ){ getCheckButton(*optionsMenu, "BackgroundMusic")->check(); } else { getCheckButton(*optionsMenu, "BackgroundMusic")->uncheck(); } if( getConfig()->soundEnabled ){ getCheckButton(*optionsMenu, "SoundFX")->check(); } else { getCheckButton(*optionsMenu, "SoundFX")->uncheck(); } if( getConfig()->useFullScreen ){ getCheckButton(*optionsMenu, "Fullscreen")->check(); } else { getCheckButton(*optionsMenu, "Fullscreen")->uncheck(); } if (binary_mode) { getCheckButton(*optionsMenu, "BinaryMode")->check();} else { getCheckButton(*optionsMenu, "BinaryMode")->uncheck();} if (seed_compression) { getCheckButton(*optionsMenu, "SeedMode")->check();} else { getCheckButton(*optionsMenu, "SeedMode")->uncheck();} //current background track musicParagraph = getParagraph( *optionsMenu, "musicParagraph"); musicParagraph->setText(getSound()->currentTrack.title); std::stringstream mode; mode << SDL_GetVideoSurface()->w << "x" << SDL_GetVideoSurface()->h; getParagraph( *optionsMenu, "resolutionParagraph")->setText(mode.str()); mode.str(""); mode << world.len(); getParagraph( *optionsMenu, "WorldLenParagraph")->setText(mode.str()); languageParagraph = getParagraph( *optionsMenu, "languageParagraph"); currentLanguage = getConfig()->language; languageParagraph->setText( getConfig()->language ); languages = dictionaryManager->get_languages(); languages.insert( "autodetect" ); languages.insert( "en" ); // English is the default when no translation is used optionsMenu->resize(getConfig()->videoX, getConfig()->videoY); //(SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h); }