void Dialog::editPort(){ if( !desktop ) { std::cerr << "No desktop found.\n"; return; } try { myDialogComponent = loadGUIFile( "gui/portdialog.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 Port-Data //int port_flags = world(pointX, pointY)->reportingConstruction->flags; Port *port = dynamic_cast<Port *>(world(pointX, pointY)->reportingConstruction); Paragraph* p = getParagraph( *myDialogComponent, "DialogTitle" ); std::stringstream title; title << _("Port") << " ( " << pointX <<" , " << pointY << " )"; p->setText( title.str() ); CheckButton* cb; cb = getCheckButton( *myDialogComponent, "BuyFood" ); if( port->commodityRuleCount[Construction::STUFF_FOOD].take) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellFood" ); if( port->commodityRuleCount[Construction::STUFF_FOOD].give) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyCoal" ); if( port->commodityRuleCount[Construction::STUFF_COAL].take) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellCoal" ); if( port->commodityRuleCount[Construction::STUFF_COAL].give) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyOre" ); if( port->commodityRuleCount[Construction::STUFF_ORE].take) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellOre" ); if( port->commodityRuleCount[Construction::STUFF_ORE].give) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyGoods" ); if( port->commodityRuleCount[Construction::STUFF_GOODS].take) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellGoods" ); if( port->commodityRuleCount[Construction::STUFF_GOODS].give) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuySteel" ); if( port->commodityRuleCount[Construction::STUFF_STEEL].take) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellSteel" ); if( port->commodityRuleCount[Construction::STUFF_STEEL].give) cb->check(); else cb->uncheck(); // connect signals Button* applyButton = getButton( *myDialogComponent, "Apply" ); applyButton->clicked.connect( makeCallback(*this, &Dialog::applyPortButtonClicked ) ); Button* gotoButton = getButton( *myDialogComponent, "goto" ); gotoButton->clicked.connect( makeCallback( *this, &Dialog::gotoButtonClicked ) ); }
void Dialog::editPort(){ if( !desktop ) { std::cerr << "No desktop found.\n"; return; } try { myDialogComponent = loadGUIFile( "gui/portdialog.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 Port-Data Paragraph* p = getParagraph( *myDialogComponent, "DialogTitle" ); std::stringstream title; title << _("Port") << " ( " << pointX <<" , " << pointY << " )"; p->setText( title.str() ); CheckButton* cb; 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::applyPortButtonClicked ) ); Button* gotoButton = getButton( *myDialogComponent, "goto" ); gotoButton->clicked.connect( makeCallback( *this, &Dialog::gotoButtonClicked ) ); }
void MainMenu::fillNewGameMenu() { const std::string buttonNames[]={"File0","File1","File2","File3","File4","File5"}; char **files= PHYSFS_enumerateFiles("opening"); char **fptr=files; CheckButton *button; fileMap.clear(); for(int i=0;i<6;i++) { button=getCheckButton(*newGameMenu.get(),buttonNames[i]); button->clicked.connect(makeCallback(*this,&MainMenu::selectLoadGameButtonClicked)); while(*fptr) { if(std::string(*fptr).find(".scn")!=std::string::npos) break; fptr++; } if(*fptr) { std::string f=*fptr; if(f.length()>5){ f=f.substr(0,f.length()-4); // truncate .scn } // save real name fileMap.insert(std::pair<std::string, std::string>(buttonNames[i], f )); // use translated name for caption button->setCaptionText(_(f.c_str())); fptr++; } else button->setCaptionText(""); } PHYSFS_freeList(files); button=getCheckButton(*newGameMenu.get(),"WithVillage"); button->check(); //button->setCaptionText(_("random empty board")); //button->clicked.connect(makeCallback(*this,&MainMenu::selectLoadGameButtonClicked)); button=getCheckButton(*newGameMenu.get(),"RiverDelta"); button->setCaptionText(_("river delta")); button->clicked.connect(makeCallback(*this,&MainMenu::selectLoadGameButtonClicked)); button=getCheckButton(*newGameMenu.get(),"DesertArea"); button->setCaptionText(_("semi desert")); button->clicked.connect(makeCallback(*this,&MainMenu::selectLoadGameButtonClicked)); button=getCheckButton(*newGameMenu.get(),"TemperateArea"); button->setCaptionText(_("temperate")); button->clicked.connect(makeCallback(*this,&MainMenu::selectLoadGameButtonClicked)); button=getCheckButton(*newGameMenu.get(),"SwampArea"); button->setCaptionText(_("swamp")); button->clicked.connect(makeCallback(*this,&MainMenu::selectLoadGameButtonClicked)); return; /* Is there a better way to add filenames to the directory? */ _("good_times"); _("bad_times"); _("Beach"); _("extreme_arid"); _("extreme_wetland"); }