void iwTrade::Msg_ComboSelectItem(const unsigned ctrl_id, const int selection) { switch(ctrl_id) { // Change ware/figure mode case 2: { ctrlComboBox* names = this->GetCtrl<ctrlComboBox>(4); names->DeleteAllItems(); if(selection == 0) { // Add ware names for(unsigned i = 0; i < wares.size(); ++i) names->AddString(_(WARE_NAMES[wares[i]])); } else { // Add job names for(unsigned i = 0; i < jobs.size(); ++i) names->AddString(_(JOB_NAMES[jobs[i]])); } names->SetSelection(0); Msg_ComboSelectItem(4, 0); } break; case 4: { unsigned number; if(this->GetCtrl<ctrlComboBox>(2)->GetSelection() == 0) { // Wares // Set the new image of the ware which was selected GetCtrl<ctrlImage>(5)->SetImage(LOADER.GetMapImageN(2250 + wares[selection])); // Get the number of available wares number = GetPossibleTradeAmount(wares[selection]); } else { glArchivItem_Bitmap* image = LOADER.GetMapImageN(2300 + jobs[selection]); // Exception: charburner if(jobs[selection] == JOB_CHARBURNER) image = LOADER.GetImageN("io_new", 5); GetCtrl<ctrlImage>(5)->SetImage(image); // Get the number of available figures number = GetPossibleTradeAmount(jobs[selection]); } char str[256]; sprintf(str, "/ %u", number); GetCtrl<ctrlText>(7)->SetText(str); } break; } }
iwTrade::iwTrade(const nobBaseWarehouse& wh, const GameWorldViewer& gwv, GameCommandFactory& gcFactory) : IngameWindow(wh.CreateGUIID(), (unsigned short) - 2, (unsigned short) - 2, 400, 194, _("Trade"), LOADER.GetImageN("resource", 41)), wh(wh), gwv(gwv), gcFactory(gcFactory), possibleSrcWarehouses(gwv.GetPlayer().GetWarehousesForTrading(wh)) { // Get title of the player SetTitle(_("Trade with %s") + gwv.GetWorld().GetPlayer(wh.GetPlayer()).name); // Gebäudebild und dessen Schatten AddImage( 0, 100, 144, LOADER.GetNationImage(wh.GetNation(), 250 + 5 * wh.GetBuildingType())); const unsigned left_column = 200; this->AddComboBox(4, left_column, 84, 160, 18, TC_GREY, NormalFont, 90); // Ware/Figure names this->AddText(1, left_column, 30, "Deal in:", COLOR_YELLOW, glArchivItem_Font::DF_LEFT, NormalFont); ctrlComboBox* box = this->AddComboBox(2, left_column, 44, 160, 18, TC_GREY, NormalFont, 200); // Ware or figure? box->AddString(_("Wares")); box->AddString(_("Settlers")); this->AddText(3, left_column, 70, "Type:", COLOR_YELLOW, glArchivItem_Font::DF_LEFT, NormalFont); // Create possible wares, figures for(unsigned i = 0; i < WARE_TYPES_COUNT; ++i) { // Only add one shield type if(GoodType(i) != ConvertShields(GoodType(i))) continue; // Don't add nothing or empty water if(i == GD_NOTHING || i == GD_WATEREMPTY) continue; wares.push_back(GoodType(i)); } for(unsigned i = 0; i < JOB_TYPES_COUNT; ++i) { // Can't trade boat carriers if(i == JOB_BOATCARRIER) continue; jobs.push_back(Job(i)); } AddImage(5, left_column + 20, 130, NULL, _("Ware you like to trade")); AddEdit(6, left_column + 34, 120, 39 , 20, TC_GREY, NormalFont)->SetNumberOnly(true); AddText(7, left_column + 75, 125, "/ 20", COLOR_YELLOW, glArchivItem_Font::DF_LEFT, NormalFont); AddTextButton(8, left_column, 150, 150, 22, TC_GREEN2, _("Send"), NormalFont); // Choose wares at first box->SetSelection(0); Msg_ComboSelectItem(2, 0); }
iwTrade::iwTrade(const nobBaseWarehouse& wh, const GameWorldViewer& gwv, GameCommandFactory& gcFactory) : IngameWindow(wh.CreateGUIID(), IngameWindow::posAtMouse, Extent(400, 194), _("Trade"), LOADER.GetImageN("resource", 41)), wh(wh), gwv(gwv), gcFactory(gcFactory), possibleSrcWarehouses(gwv.GetPlayer().GetWarehousesForTrading(wh)) { // Get title of the player SetTitle((boost::format(_("Trade with %s")) % gwv.GetWorld().GetPlayer(wh.GetPlayer()).name).str()); // Gebäudebild und dessen Schatten AddImage(0, DrawPoint(100, 144), LOADER.GetNationImage(wh.GetNation(), 250 + 5 * wh.GetBuildingType())); const unsigned left_column = 200; AddComboBox(4, DrawPoint(left_column, 84), Extent(160, 18), TC_GREY, NormalFont, 90); // Ware/Figure names AddText(1, DrawPoint(left_column, 30), "Deal in:", COLOR_YELLOW, FontStyle::LEFT, NormalFont); ctrlComboBox* box = this->AddComboBox(2, DrawPoint(left_column, 44), Extent(160, 18), TC_GREY, NormalFont, 200); // Ware or figure? box->AddString(_("Wares")); box->AddString(_("Settlers")); AddText(3, DrawPoint(left_column, 70), "Type:", COLOR_YELLOW, FontStyle::LEFT, NormalFont); // Create possible wares, figures for(unsigned i = 0; i < NUM_WARE_TYPES; ++i) { // Only add one shield type if(GoodType(i) != ConvertShields(GoodType(i))) continue; // Don't add empty water if(i == GD_WATEREMPTY) continue; wares.push_back(GoodType(i)); } for(unsigned i = 0; i < NUM_JOB_TYPES; ++i) { // Can't trade boat carriers if(i == JOB_BOATCARRIER) continue; jobs.push_back(Job(i)); } AddImage(5, DrawPoint(left_column + 20, 130), static_cast<ITexture*>(nullptr), _("Ware you like to trade")); AddEdit(6, DrawPoint(left_column + 34, 120), Extent(39, 20), TC_GREY, NormalFont)->SetNumberOnly(true); AddText(7, DrawPoint(left_column + 75, 125), "/ 20", COLOR_YELLOW, FontStyle::LEFT, NormalFont); AddTextButton(8, DrawPoint(left_column, 150), Extent(150, 22), TC_GREEN2, _("Send"), NormalFont); // Choose wares at first box->SetSelection(0); Msg_ComboSelectItem(2, 0); }