FlashlightWindow::FlashlightWindow(Ogui *ogui, game::Game *game, int player) { this->ogui = ogui; this->game = game; this->player = player; int xPosition = getLocaleGuiInt("gui_flashlight_position_x", 0); int yPosition = getLocaleGuiInt("gui_flashlight_position_y", 0); this->win = ogui->CreateSimpleWindow(xPosition, yPosition, getLocaleGuiInt("gui_flashlight_size_x", 0), getLocaleGuiInt("gui_flashlight_size_y", 0), NULL); this->win->SetUnmovable(); this->flashlightBackgroundOnImage = ogui->LoadOguiImage(getLocaleGuiString("gui_flashlight_on_image")); this->flashlightBackgroundLowImage = ogui->LoadOguiImage(getLocaleGuiString("gui_flashlight_low_image")); this->flashlightBackgroundOffImage = ogui->LoadOguiImage(getLocaleGuiString("gui_flashlight_off_image")); this->fillupImage = ogui->LoadOguiImage(getLocaleGuiString("gui_flashlight_fillup_image")); this->fillupLowImage = ogui->LoadOguiImage(getLocaleGuiString("gui_flashlight_fillup_low_image")); flashlightBackgroundButton = ogui->CreateSimpleImageButton(win, 0, 0, getLocaleGuiInt("gui_flashlight_size_x", 0), getLocaleGuiInt("gui_flashlight_size_y", 0), NULL, NULL, NULL); flashlightBackgroundButton->SetDisabled(true); flashlightBackgroundButton->SetDisabledImage(flashlightBackgroundOffImage); fillupButton = ogui->CreateSimpleImageButton(win, getLocaleGuiInt("gui_flashlight_fillup_offset_x", 0), getLocaleGuiInt("gui_flashlight_fillup_offset_y", 0), getLocaleGuiInt("gui_flashlight_fillup_size_x", 0), getLocaleGuiInt("gui_flashlight_fillup_size_y", 0), NULL, NULL, NULL); fillupButton->SetDisabled(true); fillupButton->SetDisabledImage(fillupImage); win->SetEffectListener(this); #ifdef PROJECT_SURVIVOR OguiAligner::align(win, OguiAligner::WIDESCREEN_FIX_LEFT, ogui); OguiAligner::align(flashlightBackgroundButton, OguiAligner::WIDESCREEN_FIX_LEFT, ogui); OguiAligner::align(fillupButton, OguiAligner::WIDESCREEN_FIX_LEFT, ogui); #endif }
void UpgradeWindow::getWeaponPosition(int number, int *x, int *y) { fb_assert(number >= -1 && number < UPGRADEWINDOW_MAX_WEAPONS); int posx = getLocaleGuiInt("gui_upgrades_slot_position_x", 0); int posy = getLocaleGuiInt("gui_upgrades_slot_position_y", 0); int offx = getLocaleGuiInt("gui_upgrades_slot_offset_x", 0); int offy = getLocaleGuiInt("gui_upgrades_slot_offset_y", 0); *x = posx + (number / 5) * offx; *y = posy + (number % 5) * offy; }
OguiButton* MainMenu::addButton( const std::string& text, int command, IOguiFont* font, IOguiFont* high, IOguiFont* down, IOguiFont* disa, OguiButton::TEXT_H_ALIGN halign) { assert( ogui ); assert( win ); static int count = 1; std::string preHeader = "gui_mainmenu_button_pos_"; if (!text.empty()) { OguiButton* b; int x = getLocaleGuiInt( ( preHeader + "x_" + std::to_string( count ) ).c_str(), buttonX ); int y = getLocaleGuiInt( ( preHeader + "y_" + std::to_string( count ) ).c_str(), buttonY ); int w = getLocaleGuiInt( ( preHeader + "w_" + std::to_string( count ) ).c_str(), buttonW ); int h = getLocaleGuiInt( ( preHeader + "h_" + std::to_string( count ) ).c_str(), buttonH ); OguiWindow *parent_win = win; if(getLocaleGuiInt( ( preHeader + "window_" + std::to_string( count ) ).c_str(), 1 ) == 2) { parent_win = win2; } b = ogui->CreateSimpleTextButton( parent_win, x, y, w, h, buttonNormal.c_str(), buttonDown.c_str(), buttonHigh.c_str(), ( buttonPaddingString + text ).c_str(), command ); b->SetListener( this ); if ( font ) b->SetFont( font ); if ( high ) b->SetHighlightedFont( high ); if ( down ) b->SetDownFont( down ); if ( disa ) b->SetDisabledFont( disa ); b->SetTextHAlign( halign ); // b->SetTextVAlign( verticalAlign ); b->SetEventMask( OGUI_EMASK_CLICK | OGUI_EMASK_OVER ); buttonX += buttonAddX; buttonY += buttonAddY; buttons.push_back( b ); count++; if( count > numberOfButtons ) count = 1; return b; } count++; return 0; }
LogEntry::LogEntry( const std::string& var_name ) : watchVariable( var_name ), text( getLocaleGuiString( ( variable_text_prefix + var_name ).c_str() ) ), description( getLocaleGuiString( ( variable_desc_prefix + var_name ).c_str() ) ), variableType( getLocaleGuiInt( ( variable_type_prefix + var_name ).c_str(), 0 ) ), variableState( log_none ), variableTime( 0 ) { }
OguiButton* loadButton( const std::string& name, int id = 0 ) { int x = getLocaleGuiInt( ( name + "_x" ).c_str(), 0 ); int y = getLocaleGuiInt( ( name + "_y" ).c_str(), 0 ); int w = getLocaleGuiInt( ( name + "_w" ).c_str(), 0 ); int h = getLocaleGuiInt( ( name + "_h" ).c_str(), 0 ); std::string norm = getLocaleGuiString( ( name + "_norm" ).c_str() ); std::string high = getLocaleGuiString( ( name + "_high" ).c_str() ); std::string down = getLocaleGuiString( ( name + "_down" ).c_str() ); std::string text = getLocaleGuiString( ( name + "_text" ).c_str() ); OguiButton* result; result = ogui->CreateSimpleTextButton( window, x, y, w, h, norm.c_str(), down.c_str(), high.c_str(), text.c_str(), id, NULL ); result->SetFont( font ); result->SetListener( this ); return result; }
void MainMenu::createDifficultyButtons() { int difficultButtonX = getLocaleGuiInt( "gui_mainmenu_difficult_button_x", 0 ); int difficultButtonY = getLocaleGuiInt( "gui_mainmenu_difficult_button_y", 0 ); int difficultButtonW = getLocaleGuiInt( "gui_optionsmenu_difficult_button_w", 0 ); int difficultButtonH = getLocaleGuiInt( "gui_optionsmenu_difficult_button_h", 0 ); int difficultButtonAddX = getLocaleGuiInt( "gui_optionsmenu_difficult_button_add_x", 0 ); int difficultButtonAddY = getLocaleGuiInt( "gui_optionsmenu_difficult_button_add_y", 0 ); std::string optionsDifficultButtonNormal = getLocaleGuiString( "gui_optionsmenu_difficult_image_normal" ); std::string optionsDifficultButtonDown = getLocaleGuiString( "gui_optionsmenu_difficult_image_down" ); std::string optionsDifficultButtonHigh = getLocaleGuiString( "gui_optionsmenu_difficult_image_high" ); std::string optionsEasyText = getLocaleGuiString( "gui_optionsmenu_text_easy" ); std::string optionsNormalText = getLocaleGuiString( "gui_optionsmenu_text_normal" ); std::string optionsHardText = getLocaleGuiString( "gui_optionsmenu_text_hard" ); difficultImageSelectDown = ogui->LoadOguiImage( optionsDifficultButtonHigh.c_str() ); difficultImageSelectNorm = ogui->LoadOguiImage( optionsDifficultButtonNormal.c_str() ); addDifficultButton( difficultButtonX, difficultButtonY, difficultButtonW, difficultButtonH, optionsDifficultButtonNormal, optionsDifficultButtonDown, optionsDifficultButtonHigh, fonts->little.normal, optionsEasyText, COMMANDS_EASY ); difficultButtonX += difficultButtonAddX; difficultButtonY += difficultButtonAddY; addDifficultButton( difficultButtonX, difficultButtonY, difficultButtonW, difficultButtonH, optionsDifficultButtonNormal, optionsDifficultButtonDown, optionsDifficultButtonHigh, fonts->little.normal, optionsNormalText, COMMANDS_NORMAL ); difficultButtonX += difficultButtonAddX; difficultButtonY += difficultButtonAddY; addDifficultButton( difficultButtonX, difficultButtonY, difficultButtonW, difficultButtonH, optionsDifficultButtonNormal, optionsDifficultButtonDown, optionsDifficultButtonHigh, fonts->little.normal, optionsHardText, COMMANDS_HARD ); int diff = game->gameScripting->getGlobalIntVariableValue( "general_difficulty_level" ); if( diff < 50 ) selectDifficultButton( COMMANDS_EASY ); else if ( diff >= 50 && diff < 75 ) selectDifficultButton( COMMANDS_NORMAL ); else if ( diff >= 75 ) selectDifficultButton( COMMANDS_HARD ); }
UpgradeWindow::UpgradeWindow(Ogui *ogui, game::Game *game, game::Unit *unit) { //this->selectionNumber = -1; this->game = game; this->ogui = ogui; this->unit = unit; this->visible = 1; highlightedWeaponSlot = -1; highlightedUpgradeSlot = -1; highlightedUpgradeId = -1; highlightOn = false; this->upgradesPending = new LinkedList(); this->upgradesPendingCost = 0; assert(unit != NULL); const char *l1Image = getLocaleGuiString("gui_upgrades_window_effect_layer1_image"); const char *l2Image = getLocaleGuiString("gui_upgrades_window_effect_layer2_image"); const char *l3Image = getLocaleGuiString("gui_upgrades_window_effect_layer3_image"); this->effectWindow = new GUIEffectWindow(ogui, l1Image, l2Image, l3Image); // create window { int x = getLocaleGuiInt("gui_upgrades_window_position_x", 0); int y = getLocaleGuiInt("gui_upgrades_window_position_y", 0); int sizex = getLocaleGuiInt("gui_upgrades_window_size_x", UPGRADE_WINDOW_DEFAULT_SIZE_X); int sizey = getLocaleGuiInt("gui_upgrades_window_size_y", UPGRADE_WINDOW_DEFAULT_SIZE_Y); //const char *bgimage = getLocaleGuiString("gui_upgrades_window_background_image"); win = ogui->CreateSimpleWindow(x, y, sizex, sizey, NULL); } win->StartEffect(OGUI_WINDOW_EFFECT_FADEIN, FADE_IN_TIME); win->SetEffectListener(this); effectWindow->fadeIn(FADE_IN_TIME); // title { int x = getLocaleGuiInt("gui_upgrades_title_position_x", 0); int y = getLocaleGuiInt("gui_upgrades_title_position_y", 0); int sizex = getLocaleGuiInt("gui_upgrades_title_size_x", 0); int sizey = getLocaleGuiInt("gui_upgrades_title_size_y", 0); const char *label = getLocaleGuiString("gui_upgrades_title"); const char *image = getLocaleGuiString("gui_upgrades_title_image"); titleButton = ogui->CreateSimpleTextButton(win, x, y, sizex, sizey, image, NULL, NULL, label, 0); titleButton->SetReactMask(0); titleButton->SetFont(ui::defaultIngameFont); } // parts available icon { int x = getLocaleGuiInt("gui_upgrades_parts_icon_position_x", 0); int y = getLocaleGuiInt("gui_upgrades_parts_icon_position_y", 0); int sizex = getLocaleGuiInt("gui_upgrades_parts_icon_size_x", 0); int sizey = getLocaleGuiInt("gui_upgrades_parts_icon_size_y", 0); const char *image = getLocaleGuiString("gui_upgrades_parts_icon_image"); upgradePartsIcon = ogui->CreateSimpleImageButton(win, x, y, sizex, sizey, NULL, NULL, NULL, image, 0); upgradePartsIcon->SetDisabled(true); } // parts available text { int x = getLocaleGuiInt("gui_upgrades_parts_text_position_x", 0); int y = getLocaleGuiInt("gui_upgrades_parts_text_position_y", 0); int sizex = getLocaleGuiInt("gui_upgrades_parts_text_size_x", 0); int sizey = getLocaleGuiInt("gui_upgrades_parts_text_size_y", 0); upgradePartsText = ogui->CreateTextLabel(win, x, y, sizex, sizey, ""); upgradePartsText->SetFont(ui::defaultIngameFont); } // some misc images { const char *tmp; tmp = getLocaleGuiString("gui_upgrades_slot_background_image"); upgradeBGImage = ogui->LoadOguiImage(tmp); tmp = getLocaleGuiString("gui_upgrades_slot_background_disabled_image"); upgradeBGDisabledImage = ogui->LoadOguiImage(tmp); tmp = getLocaleGuiString("gui_upgrades_weapon_highlight_image"); weaponHighlightImage = ogui->LoadOguiImage(tmp); tmp = getLocaleGuiString("gui_upgrades_upgrade_highlight_image"); upgradeHighlightImage = ogui->LoadOguiImage(tmp); tmp = getLocaleGuiString("gui_upgrades_upgrade_selected_image"); upgradeSelectedImage = ogui->LoadOguiImage(tmp); } //selectionImage = ogui->LoadOguiImage("Data/GUI/Buttons/Upgrade/selectedweapon.tga"); //selection = NULL; // first init weapon and upgrade buttons to null... { for (int i = 0; i < UPGRADEWINDOW_MAX_WEAPONS; i++) { weaponImages[i] = NULL; weaponInfoImages[i] = NULL; weaponButtons[i] = NULL; slotBGs[i] = NULL; for (int j = 0; j < UPGRADEWINDOW_MAX_UPGRADES_PER_WEAPON; j++) { upgradeImages[i][j] = NULL; //upgradeDisabledImages[i][j] = NULL; upgradeButtons[i][j] = NULL; upgradeSelections[i][j] = NULL; } } } // then create weapon and upgrade buttons... { for (int i = 0; i < UPGRADEWINDOW_MAX_WEAPONS; i++) { // NOTE: this is actually not an ok part type id! // (thus, should not use this value like this) int partTypeId = -1; partTypeId = PlayerWeaponry::getWeaponIdByUINumber(unit, i); int wnum = -1; if (partTypeId != -1) { wnum = unit->getWeaponByWeaponType(partTypeId); } // weapon image/button int wx = 0; int wy = 0; getWeaponPosition(i, &wx, &wy); { int sizex = getLocaleGuiInt("gui_upgrades_slot_size_x", 0); int sizey = getLocaleGuiInt("gui_upgrades_slot_size_y", 0); slotBGs[i] = ogui->CreateSimpleImageButton(win, wx, wy, sizex, sizey, NULL, NULL, NULL, NULL); slotBGs[i]->SetReactMask(0); slotBGs[i]->SetDisabled(true); if (wnum != -1) { slotBGs[i]->SetDisabledImage(upgradeBGImage); } else { slotBGs[i]->SetDisabledImage(upgradeBGDisabledImage); } //slotBGs[i]->SetListener(this); } if (wnum != -1) { { char buf[256]; strcpy(buf, "Data/GUI/Buttons/Upgrade/weapon_"); buf[strlen(buf) + 1] = '\0'; buf[strlen(buf)] = '0' + i; strcat(buf, ".tga"); weaponImages[i] = ogui->LoadOguiImage(buf); strcpy(buf, "Data/GUI/Buttons/Upgrade/weapon_"); buf[strlen(buf) + 1] = '\0'; buf[strlen(buf)] = '0' + i; strcat(buf, "_info.tga"); weaponInfoImages[i] = ogui->LoadOguiImage(buf); { int sizex = getLocaleGuiInt("gui_upgrades_slot_weapon_size_x", 0); int sizey = getLocaleGuiInt("gui_upgrades_slot_weapon_size_y", 0); int woffx = getLocaleGuiInt("gui_upgrades_slot_weapon_offset_x", 0); int id = UPGRADEW_WEAPONBUT_FIRST + i; weaponButtons[i] = ogui->CreateSimpleImageButton(win, wx + woffx, wy, sizex, sizey, NULL, NULL, NULL, NULL, id, (void *)partTypeId); weaponButtons[i]->SetReactMask(0); weaponButtons[i]->SetDisabled(false); weaponButtons[i]->SetImage(weaponImages[i]); weaponButtons[i]->SetListener(this); weaponButtons[i]->SetEventMask(OGUI_EMASK_CLICK | OGUI_EMASK_OVER | OGUI_EMASK_LEAVE); } } // upgrades for that weapon { const char *weapName = NULL; Weapon *w = unit->getWeaponType(wnum); if (w != NULL) { weapName = w->getPartTypeIdString(); } std::vector<int> upgIds; game->upgradeManager->getUpgradesForPart(weapName, upgIds); if (upgIds.size() > UPGRADEWINDOW_MAX_UPGRADES_PER_WEAPON) { Logger::getInstance()->error("UpgradeWindow - Weapon has too many upgrades."); Logger::getInstance()->debug(weapName); } for (int j = 0; j < (int)upgIds.size(); j++) { UpgradeType *upgType = game->upgradeManager->getUpgradeTypeById(upgIds[j]); const char *upgScript = upgType->getScript(); char buf[256]; strcpy(buf, "Data/GUI/Buttons/Upgrade/"); if (strlen(upgScript) < 64) strcat(buf, upgScript); strcat(buf, ".tga"); upgradeImages[i][j] = ogui->LoadOguiImage(buf); //strcpy(buf, "Data/GUI/Buttons/Upgrade/"); //if (strlen(upgScript) < 64) // strcat(buf, upgScript); //strcat(buf, "_disabled.tga"); //upgradeDisabledImages[i][j] = ogui->LoadOguiImage(buf); int x = 0; int y = 0; getWeaponPosition(i, &x, &y); int woffx = getLocaleGuiInt("gui_upgrades_slot_weapon_offset_x", 0); x += woffx; //y += UPGRADE_WEAPON_SELECTION_SIZE_Y; //x += j * (UPGRADE_SLOT_SIZE_X+UPGRADE_SLOT_PADDING); int firstpadx = getLocaleGuiInt("gui_upgrades_slot_upgrade_start_offset_x", 0); int padx = getLocaleGuiInt("gui_upgrades_slot_upgrade_offset_x", 0); int sizex = getLocaleGuiInt("gui_upgrades_slot_upgrade_size_x", 0); int sizey = getLocaleGuiInt("gui_upgrades_slot_upgrade_size_y", 0); x += firstpadx + j * padx; upgradeSelections[i][j] = ogui->CreateSimpleImageButton(win, x, y, sizex, sizey, NULL, NULL, NULL, NULL, NULL, NULL); upgradeSelections[i][j]->SetReactMask(0); upgradeSelections[i][j]->SetDisabled(true); int id = UPGRADEW_UPGRADEBUT_FIRST + i*UPGRADEWINDOW_MAX_UPGRADES_PER_WEAPON+j; assert(id >= UPGRADEW_UPGRADEBUT_FIRST && id <= UPGRADEW_UPGRADEBUT_LAST); int upgid = upgIds[j]; upgradeButtons[i][j] = ogui->CreateSimpleImageButton(win, x, y, sizex, sizey, NULL, NULL, NULL, NULL, id, (void *)upgid); upgradeButtons[i][j]->SetReactMask(0); upgradeButtons[i][j]->SetImage(upgradeImages[i][j]); //upgradeButtons[i][j]->SetDisabledImage(upgradeDisabledImages[i][j]); upgradeButtons[i][j]->SetListener(this); upgradeButtons[i][j]->SetEventMask(OGUI_EMASK_CLICK | OGUI_EMASK_OVER | OGUI_EMASK_LEAVE); int tmp = this->upgradesPendingCost; //if (game->upgradeManager->canUpgrade(unit, upgIds[j], &tmp)) //{ upgradeButtons[i][j]->SetDisabled(false); //} else { // upgradeButtons[i][j]->SetDisabled(true); //} } } } else { weaponImages[i] = NULL; weaponButtons[i] = NULL; } } } // info picture and text { // background int x = getLocaleGuiInt("gui_upgrades_info_position_x", 0); int y = getLocaleGuiInt("gui_upgrades_info_position_y", 0); int bgsizex = getLocaleGuiInt("gui_upgrades_info_size_x", 0); int bgsizey = getLocaleGuiInt("gui_upgrades_info_size_y", 0); const char *image = getLocaleGuiString("gui_upgrades_info_background_image"); infoBackground = ogui->CreateSimpleImageButton(win, x, y, bgsizex, bgsizey, NULL, NULL, NULL, image, 0, NULL); //infoBackground->SetListener(this); infoBackground->SetDisabled(true); // picture { int offx = getLocaleGuiInt("gui_upgrades_info_picture_offset_x", 0); int offy = getLocaleGuiInt("gui_upgrades_info_picture_offset_y", 0); int sizex = getLocaleGuiInt("gui_upgrades_info_picture_size_x", 0); int sizey = getLocaleGuiInt("gui_upgrades_info_picture_size_y", 0); infoIcon = ogui->CreateSimpleImageButton(win, x + offx, y + offy, sizex, sizey, NULL, NULL, NULL, NULL, 0, NULL); infoIcon->SetDisabled(true); } // text { int offx = getLocaleGuiInt("gui_upgrades_info_textarea_offset_x", 0); int offy = getLocaleGuiInt("gui_upgrades_info_textarea_offset_y", 0); int sizex = getLocaleGuiInt("gui_upgrades_info_textarea_size_x", 0); int sizey = getLocaleGuiInt("gui_upgrades_info_textarea_size_y", 0); infoText = new OguiFormattedText( win, ogui, x + offx, y + offy, sizex, sizey ); // infoText = ogui->CreateTextArea(win, x + offx, y + offy, sizex, sizey, ""); // infoText->SetFont(ui::defaultIngameFont); std::string name; name = "gui_upgrades_info_textarea"; fonts.push_back( ogui->LoadFont( getLocaleGuiString( ( name + "_font_default" ).c_str() ) ) ); fonts.push_back( ogui->LoadFont( getLocaleGuiString( ( name + "_font_bold" ).c_str() ) ) ); fonts.push_back( ogui->LoadFont( getLocaleGuiString( ( name + "_font_italic" ).c_str() ) ) ); fonts.push_back( ogui->LoadFont( getLocaleGuiString( ( name + "_font_underline" ).c_str() ) ) ); fonts.push_back( ogui->LoadFont( getLocaleGuiString( ( name + "_font_h1" ).c_str() ) ) ); fonts.push_back( ogui->LoadFont( getLocaleGuiString( ( name + "_font_page" ).c_str() ) ) ); infoText->setFont( fonts[ 0 ] ); infoText->registerFont( "b", fonts[ 1 ] ); infoText->registerFont( "i", fonts[ 2 ] ); infoText->registerFont( "u", fonts[ 3 ] ); infoText->registerFont( "h1", fonts[ 4 ] ); } } // finally undo button { int x = getLocaleGuiInt("gui_upgrades_undo_position_x", 0); int y = getLocaleGuiInt("gui_upgrades_undo_position_y", 0); int sizex = getLocaleGuiInt("gui_upgrades_undo_size_x", 0); int sizey = getLocaleGuiInt("gui_upgrades_undo_size_y", 0); const char *image = getLocaleGuiString("gui_upgrades_undo_image"); const char *imageDown = getLocaleGuiString("gui_upgrades_undo_down_image"); const char *imageHighlight = getLocaleGuiString("gui_upgrades_undo_highlight_image"); undoButton = ogui->CreateSimpleTextButton(win, x, y, sizex, sizey, image, imageDown, imageHighlight, "", UPGRADEW_UNDOBUT); undoButton->SetListener(this); undoButton->SetFont(ui::defaultIngameFont); } // and close button { int x = getLocaleGuiInt("gui_upgrades_close_position_x", 0); int y = getLocaleGuiInt("gui_upgrades_close_position_y", 0); int sizex = getLocaleGuiInt("gui_upgrades_close_size_x", 0); int sizey = getLocaleGuiInt("gui_upgrades_close_size_y", 0); const char *label = getLocaleGuiString("gui_upgrades_close"); const char *image = getLocaleGuiString("gui_upgrades_close_image"); const char *imageDown = getLocaleGuiString("gui_upgrades_close_down_image"); const char *imageHighlight = getLocaleGuiString("gui_upgrades_close_highlight_image"); closeButton = ogui->CreateSimpleTextButton(win, x, y, sizex, sizey, image, imageDown, imageHighlight, label, UPGRADEW_CLOSEBUT); closeButton->SetListener(this); closeButton->SetFont(ui::defaultIngameFont); } // highlight for upgrades { int sizex = getLocaleGuiInt("gui_upgrades_slot_upgrade_size_x", 0); int sizey = getLocaleGuiInt("gui_upgrades_slot_upgrade_size_y", 0); upgradeHighlight = ogui->CreateSimpleTextButton(win, 0, 0, sizex, sizey, NULL, NULL, NULL, NULL); upgradeHighlight->SetDisabled(true); } // highlight for weapons { int sizex = getLocaleGuiInt("gui_upgrades_slot_weapon_size_x", 0); int sizey = getLocaleGuiInt("gui_upgrades_slot_weapon_size_y", 0); weaponHighlight = ogui->CreateSimpleTextButton(win, 0, 0, sizex, sizey, NULL, NULL, NULL, NULL); weaponHighlight->SetDisabled(true); } update(); //game->gameUI->setGUIVisibility(game->singlePlayerNumber, false); }
void UpgradeWindow::update() { /* int selectionNumber = -1; // currently selected weapon... // solve current weapon ui-number... int curWeap = -1; int selnum = unit->getSelectedWeapon(); Weapon *wtype = NULL; if (selnum != -1) wtype = unit->getWeaponType(selnum); if (wtype != NULL) { curWeap = PlayerWeaponry::getUINumberByWeaponId(unit, wtype->getPartTypeId()); } selectionNumber = curWeap; // set selection marker to that weapon... assert(selectionNumber >= -1 && selectionNumber < UPGRADEWINDOW_MAX_WEAPONS); if (selectionNumber == -1) { if (selection != NULL) { delete selection; selection = NULL; } } else { if (weaponButtons[selectionNumber] != NULL) { if (selection == NULL) { selection = ogui->CreateSimpleImageButton(win, 0, 0, UPGRADE_WEAPON_SELECTION_SIZE_X, UPGRADE_WEAPON_SELECTION_SIZE_Y, NULL, NULL, NULL); selection->SetReactMask(0); selection->SetDisabled(true); selection->SetDisabledImage(selectionImage); } int x = 0; int y = 0; getWeaponPosition(selectionNumber, &x, &y); selection->Move(x, y); } } */ // upgrades available... for (int i = 0; i < UPGRADEWINDOW_MAX_WEAPONS; i++) { for (int j = 0; j < UPGRADEWINDOW_MAX_UPGRADES_PER_WEAPON; j++) { if (upgradeButtons[i][j] != NULL) { int upgid = (int)upgradeButtons[i][j]->GetArgument(); int tmp = this->upgradesPendingCost; //if (game->upgradeManager->canUpgrade(unit, upgid, &tmp)) //{ upgradeButtons[i][j]->SetDisabled(false); //} else { // upgradeButtons[i][j]->SetDisabled(true); //} bool alreadyUpgraded = false; if (game->upgradeManager->isUpgraded(unit, upgid)) { alreadyUpgraded = true; } bool pending = false; LinkedListIterator iter(this->upgradesPending); while (iter.iterateAvailable()) { // WARNING: void * -> int cast int other = (int)iter.iterateNext(); if (other == upgid) { pending = true; break; } } if (pending || alreadyUpgraded) { upgradeSelections[i][j]->SetDisabledImage(upgradeSelectedImage); } else { upgradeSelections[i][j]->SetDisabledImage(NULL); } } } } if (this->upgradesPendingCost > 0) { undoButton->SetDisabled(false); const char *label = getLocaleGuiString("gui_upgrades_undo"); undoButton->SetText(label); } else { undoButton->SetDisabled(true); undoButton->SetText(""); } if (highlightOn && highlightedWeaponSlot != -1 && highlightedUpgradeSlot == -1) { weaponHighlight->SetDisabledImage(weaponHighlightImage); int wx = 0; int wy = 0; getWeaponPosition(highlightedWeaponSlot, &wx, &wy); int woffx = getLocaleGuiInt("gui_upgrades_slot_weapon_offset_x", 0); wx += woffx; weaponHighlight->Move(wx,wy); } else { weaponHighlight->SetDisabledImage(NULL); } if (highlightedWeaponSlot != -1) { if (highlightOn && highlightedUpgradeSlot != -1) { upgradeHighlight->SetDisabledImage(upgradeHighlightImage); int wx = 0; int wy = 0; getWeaponPosition(highlightedWeaponSlot, &wx, &wy); int woffx = getLocaleGuiInt("gui_upgrades_slot_weapon_offset_x", 0); wx += woffx; int x = wx; int y = wy; int firstpadx = getLocaleGuiInt("gui_upgrades_slot_upgrade_start_offset_x", 0); int padx = getLocaleGuiInt("gui_upgrades_slot_upgrade_offset_x", 0); x += firstpadx + highlightedUpgradeSlot * padx; upgradeHighlight->Move(x,y); } else { upgradeHighlight->SetDisabledImage(NULL); } } else { upgradeHighlight->SetDisabledImage(NULL); } // info image & text if (highlightedWeaponSlot != -1) { infoIcon->SetDisabledImage(weaponInfoImages[highlightedWeaponSlot]); if (highlightedUpgradeSlot != -1) { fb_assert(highlightedUpgradeId != -1); int upgid = highlightedUpgradeId; UpgradeType *upgType = game->upgradeManager->getUpgradeTypeById(upgid); const char *upgScript = upgType->getScript(); char buf[128]; strcpy(buf, "upgrade_desc_"); strcat(buf, upgScript); infoText->setText(getLocaleGuiString(buf)); } else { char buf[128]; strcpy(buf, "upgrade_weapon_desc_weapon_"); strcat(buf, int2str(highlightedWeaponSlot)); infoText->setText(getLocaleGuiString(buf)); } } { int tmp = game->upgradeManager->getUpgradePartsAmount(this->unit) - this->upgradesPendingCost; upgradePartsText->SetText(int2str(tmp)); } }
MainMenu::MainMenu( MenuCollection* menu, MenuCollection::Fonts* fonts, Ogui* o_gui, Game* g, bool from_game ) : MenuBaseImpl( NULL ), menuCollection( menu ), fonts( fonts ), abortGame( NULL ), abortGameYes( NULL ), abortGameNo( NULL ), captureAllEvents( NULL ), continueButton( NULL ), currentActive( NULL ), #ifdef PROJECT_SURVIVOR numberOfButtons( 9 ), #else numberOfButtons( 7 ), #endif fromGame( from_game ), quitPressed( false ), playerName( "Pertti" ) { assert( o_gui ); assert( menu ); assert( fonts ); assert( g ); game = g; ogui = o_gui; { int x = getLocaleGuiInt( "gui_mainmenu_window_x", 0 ); int y = getLocaleGuiInt( "gui_mainmenu_window_y", 0 ); int w = getLocaleGuiInt( "gui_mainmenu_window_w", 1024 ); int h = getLocaleGuiInt( "gui_mainmenu_window_h", 150 ); win = ogui->CreateSimpleWindow( x, y, w, h, NULL ); win->Hide(); win->SetUnmovable(); } { int x = getLocaleGuiInt( "gui_mainmenu_window2_x", 0 ); int y = getLocaleGuiInt( "gui_mainmenu_window2_y", 0 ); int w = getLocaleGuiInt( "gui_mainmenu_window2_w", 0 ); int h = getLocaleGuiInt( "gui_mainmenu_window2_h", 0 ); win2 = ogui->CreateSimpleWindow( x, y, w, h, NULL ); win2->Hide(); win2->SetUnmovable(); } fromGame = game->inCombat; // Main menu buttons buttonX = getLocaleGuiInt( "gui_mainmenu_button_x", 65 ); if ( fromGame ) buttonY = getLocaleGuiInt( "gui_mainmenu_button_y_fromgame", 226 ); else buttonY = getLocaleGuiInt( "gui_mainmenu_button_y", 275 ); buttonAddX = getLocaleGuiInt( "gui_mainmenu_button_add_x", getLocaleGuiInt( "gui_menu_common_button_add_x", 0 ) ); buttonAddY = getLocaleGuiInt( "gui_mainmenu_button_add_y", getLocaleGuiInt( "gui_menu_common_button_add_y", 28 ) ); buttonW = getLocaleGuiInt( "gui_mainmenu_button_w", getLocaleGuiInt( "gui_menu_common_button_w", 0 ) ); buttonH = getLocaleGuiInt( "gui_mainmenu_button_h", getLocaleGuiInt( "gui_menu_common_button_h", 0 ) ); // Adding the buttons if ( fromGame ) { addButton( getLocaleGuiString( "gui_mm_resume" ), COMMANDS_RESUME, fonts->medium.normal, fonts->medium.highlighted ); addSeparator(); } else { continueButton = addButton( getLocaleGuiString( "gui_mm_continue" ), COMMANDS_CONTINUE, fonts->medium.normal, fonts->medium.highlighted ); checkContinue(); addSeparator(); } addButton( getLocaleGuiString( "gui_mm_new_game" ), COMMANDS_NEW_GAME, fonts->medium.normal, fonts->medium.highlighted ); addButton( getLocaleGuiString( "gui_mm_load_game" ), COMMANDS_LOAD_GAME, fonts->medium.normal, fonts->medium.highlighted ); #ifdef PROJECT_SURVIVOR addButton( getLocaleGuiString( "gui_mm_survival" ), COMMANDS_SURVIVAL, fonts->medium.normal, fonts->medium.highlighted ); addButton( getLocaleGuiString( "gui_mm_coop" ), COMMANDS_COOP, fonts->medium.normal, fonts->medium.highlighted ); #endif addButton( getLocaleGuiString( "gui_mm_profiles" ), COMMANDS_PROFILES, fonts->medium.normal, fonts->medium.highlighted ); addButton( getLocaleGuiString( "gui_mm_options" ), COMMANDS_OPTIONS, fonts->medium.normal, fonts->medium.highlighted ); addSeparator(); addButton( getLocaleGuiString( "gui_mm_credits" ), COMMANDS_CREDITS, fonts->medium.normal, fonts->medium.highlighted ); addButton( getLocaleGuiString( "gui_mm_quit" ), COMMANDS_QUIT, fonts->medium.normal, fonts->medium.highlighted ); closeMenuByEsc = false; // disable profiles menu if from coop if( game->inCombat && game->isCooperative() ) { std::list< OguiButton* >::iterator i = buttons.begin(); for( i = buttons.begin(); i != buttons.end(); ++i ) { if( (*i)->GetId() == COMMANDS_PROFILES ) { (*i)->SetDisabled( true ); #ifdef PROJECT_SURVIVOR (*i)->SetText(""); #endif } } } firstUpdate = true; }
void MainMenu::abortCurrentGame() { closeAbortMenu(); captureAllEvents = ogui->CreateSimpleWindow( 0, 0, 1024, 768, NULL ); captureAllEvents->SetUnmovable(); captureAllEvents->Show(); { int x = getLocaleGuiInt( "gui_mainmenu_abortbox_x", 0 ); int y = getLocaleGuiInt( "gui_mainmenu_abortbox_y", 0 ); int w = getLocaleGuiInt( "gui_mainmenu_abortbox_w", 0 ); int h = getLocaleGuiInt( "gui_mainmenu_abortbox_h", 0 ); int id = 0; abortGame = new OguiFormattedText( captureAllEvents, ogui, x, y, w, h, id ); abortGame->setFont( fonts->medium.normal ); abortGame->setText( getLocaleGuiString( "gui_mainmenu_abortbox_text" ) ); } { int x = getLocaleGuiInt( "gui_mainmenu_abort_yes_x", 0 ); int y = getLocaleGuiInt( "gui_mainmenu_abort_yes_y", 0 ); int w = getLocaleGuiInt( "gui_mainmenu_abort_yes_w", 0 ); int h = getLocaleGuiInt( "gui_mainmenu_abort_yes_h", 0 ); abortGameYes = ogui->CreateSimpleTextButton( captureAllEvents, x, y, w, h, getLocaleGuiString( "gui_mainmenu_abort_yes_norm" ), getLocaleGuiString( "gui_mainmenu_abort_yes_down" ), getLocaleGuiString( "gui_mainmenu_abort_yes_high" ), getLocaleGuiString( "gui_mainmenu_abort_yes_text" ), COMMANDS_YES ); abortGameYes->SetFont( fonts->medium.normal ); abortGameYes->SetListener( this ); } { int x = getLocaleGuiInt( "gui_mainmenu_abort_no_x", 0 ); int y = getLocaleGuiInt( "gui_mainmenu_abort_no_y", 0 ); int w = getLocaleGuiInt( "gui_mainmenu_abort_no_w", 0 ); int h = getLocaleGuiInt( "gui_mainmenu_abort_no_h", 0 ); abortGameNo = ogui->CreateSimpleTextButton( captureAllEvents, x, y, w, h, getLocaleGuiString( "gui_mainmenu_abort_no_norm" ), getLocaleGuiString( "gui_mainmenu_abort_no_down" ), getLocaleGuiString( "gui_mainmenu_abort_no_high" ), getLocaleGuiString( "gui_mainmenu_abort_no_text" ), COMMANDS_NO ); abortGameNo->SetFont( fonts->medium.normal ); abortGameNo->SetListener( this ); } }
AmmoWindow::AmmoWindow(Ogui *ogui, game::Game *game, int clientNum, bool coop ) { this->ogui = ogui; this->game = game; this->clientNum = clientNum; std::string prefix = "gui_ammo_"; if( coop ) { prefix = "gui_ammo_coop" + boost::lexical_cast< std::string >( clientNum ) + "_"; } int xPosition = getLocaleGuiInt( ( prefix + "position_x" ).c_str(), 0); int yPosition = getLocaleGuiInt( ( prefix + "position_y" ).c_str(), 0); this->win = ogui->CreateSimpleWindow(xPosition, yPosition, getLocaleGuiInt( ( prefix + "size_x" ).c_str(), 0), getLocaleGuiInt( ( prefix + "size_y" ).c_str(), 0), NULL); this->win->SetUnmovable(); this->ammoBackgroundImage = ogui->LoadOguiImage(getLocaleGuiString( ( prefix + "clip_image").c_str())); this->ammoTotalBackgroundImage = ogui->LoadOguiImage(getLocaleGuiString( ( prefix + "total_image").c_str())); this->fillupImage = ogui->LoadOguiImage(getLocaleGuiString( ( prefix + "clip_fillup_image").c_str())); ammoBackgroundButton = ogui->CreateSimpleImageButton(win, getLocaleGuiInt( ( prefix + "clip_offset_x" ).c_str(), 0), getLocaleGuiInt( ( prefix + "clip_offset_y" ).c_str(), 0), getLocaleGuiInt( ( prefix + "clip_size_x" ).c_str(), 0), getLocaleGuiInt( ( prefix + "clip_size_y" ).c_str(), 0), NULL, NULL, NULL); ammoBackgroundButton->SetDisabled(true); ammoBackgroundButton->SetDisabledImage(ammoBackgroundImage); ammoTotalBackgroundButton = ogui->CreateSimpleImageButton(win, getLocaleGuiInt( ( prefix + "total_offset_x" ).c_str(), 0), getLocaleGuiInt( ( prefix + "total_offset_y" ).c_str(), 0), getLocaleGuiInt( ( prefix + "total_size_x" ).c_str(), 0), getLocaleGuiInt( ( prefix + "total_size_y" ).c_str(), 0), NULL, NULL, NULL); ammoTotalBackgroundButton->SetDisabled(true); ammoTotalBackgroundButton->SetDisabledImage(ammoTotalBackgroundImage); fillupButton = ogui->CreateSimpleImageButton(win, getLocaleGuiInt( ( prefix + "clip_fillup_offset_x" ).c_str(), 0), getLocaleGuiInt( ( prefix + "clip_fillup_offset_y" ).c_str(), 0), getLocaleGuiInt( ( prefix + "clip_fillup_size_x" ).c_str(), 0), getLocaleGuiInt( ( prefix + "clip_fillup_size_y" ).c_str(), 0), NULL, NULL, NULL); fillupButton->SetDisabled(true); fillupButton->SetDisabledImage(fillupImage); fontClip = ogui->LoadFont( getLocaleGuiString( (prefix + "font_clip" ).c_str() ) ); ammoAmountText = ogui->CreateTextLabel(win, getLocaleGuiInt( ( prefix + "clip_offset_x" ).c_str(), 0), getLocaleGuiInt( ( prefix + "clip_offset_y" ).c_str(), 0), getLocaleGuiInt( ( prefix + "clip_size_x" ).c_str(), 0), getLocaleGuiInt( ( prefix + "clip_size_y" ).c_str(), 0), ""); ammoAmountText->SetFont( fontClip ? fontClip : ui::defaultIngameNumbersBoldFont ); fontTotal = ogui->LoadFont( getLocaleGuiString( (prefix + "font_total" ).c_str() ) ); ammoTotalAmountText = ogui->CreateTextLabel(win, getLocaleGuiInt( ( prefix + "total_offset_x" ).c_str(), 0), getLocaleGuiInt( ( prefix + "total_offset_y" ).c_str(), 0), getLocaleGuiInt( ( prefix + "total_size_x" ).c_str(), 0), getLocaleGuiInt( ( prefix + "total_size_y" ).c_str(), 0), ""); ammoTotalAmountText->SetFont( fontTotal ? fontTotal : ui::defaultIngameNumbersBoldSmallFont ); lastUpdateValue = -1; lastUpdateWeapon = -1; lastUpdateTotalValue = -1; win->SetEffectListener(this); int alignment = OguiAligner::WIDESCREEN_FIX_RIGHT; if(xPosition < 512) alignment = OguiAligner::WIDESCREEN_FIX_LEFT; #ifdef PROJECT_SURVIVOR OguiAligner::align(win, alignment, ogui); OguiAligner::align(ammoBackgroundButton, alignment, ogui); OguiAligner::align(ammoTotalBackgroundButton, alignment, ogui); OguiAligner::align(fillupButton, alignment, ogui); OguiAligner::align(ammoAmountText, alignment, ogui); OguiAligner::align(ammoTotalAmountText, alignment, ogui); #endif }
CreditsMenu::CreditsMenu( MenuCollection* menu, MenuCollection::Fonts* fonts, Ogui* o_gui, Game* g ) : MenuBaseImpl( NULL ), menuCollection( menu ), fonts( fonts ), textWindow( NULL ), theText( NULL ), yPosition( 768.0f ), lastYPosition( 768 ), lastUpdate( 0 ), speed( 0.0f ) { assert( o_gui ); assert( menu ); assert( fonts ); game = g; ogui = o_gui; win = ogui->CreateSimpleWindow( getLocaleGuiInt( "gui_creditsmenu_window_x", 0 ), getLocaleGuiInt( "gui_creditsmenu_window_y", 0 ), getLocaleGuiInt( "gui_creditsmenu_window_w", 1024 ), getLocaleGuiInt( "gui_creditsmenu_window_h", 768 ), NULL ); // win = ogui->CreateSimpleWindow( 0, 0, 1024, 768, NULL ); win->Hide(); win->SetUnmovable(); menu->setBackgroundImage( getLocaleGuiString( "gui_credits_background_image" ) ); /*addCloseButton( getLocaleGuiString( "gui_om_closeme" ), COMMANDS_CLOSEME, fonts->medium.normal ); textWindow = ogui->CreateSimpleWindow( 0, 768, 1024, 1024, NULL ); textWindow->SetMoveBoundaryType( OguiWindow::MOVE_BOUND_NO_PART_IN_SCREEN ); textWindow->SetReactMask( 0 ); textWindow->Hide(); */ const std::string& credits = G_UiCredits; theText = new OguiFormattedText( win, ogui, 0, 400, 1024, 3548 ); theText->setTextHAlign( OguiButton::TEXT_H_ALIGN_CENTER ); #ifdef PROJECT_SURVIVOR credits_fonts.resize(3); credits_fonts[0] = ogui->LoadFont(getLocaleGuiString( "gui_creditsmenu_font_normal" )); credits_fonts[1] = ogui->LoadFont(getLocaleGuiString( "gui_creditsmenu_font_bold" )); credits_fonts[2] = ogui->LoadFont(getLocaleGuiString( "gui_creditsmenu_font_h1" )); theText->setFont( credits_fonts[0] ); theText->registerFont( "b", credits_fonts[1] ); theText->registerFont( "h1", credits_fonts[2] ); theText->setLineHeight( (float)atof(getLocaleGuiString("gui_creditsmenu_line_height")) ); #else theText->setFont( fonts->little.normal ); theText->registerFont( "b", fonts->medium.normal ); theText->registerFont( "h1", fonts->little.normal ); theText->setLineHeight( 1.5f ); #endif theText->setText( credits ); #ifdef LEGACY_FILES maskWindow = ogui->CreateSimpleWindow( 0, 0, 1024, 768, "data/GUI/Menus/credits-hack.tga" ); #else maskWindow = ogui->CreateSimpleWindow( 0, 0, 1024, 768, "data/gui/menu/credits/window/credits_hack.tga" ); #endif maskWindow->SetUnmovable(); /* theText = ogui->CreateTextLabel( textWindow, 0, 0, 1024, 25, credits.c_str() ); theText->SetFont( fonts->medium ); theText->SetLinebreaks( true ); */ speed = 0.03f; lastUpdate = Timer::getTime(); update(); // textWindow->Show(); /////////////////////////////////////////////////////////////////////////// assert( game ); assert( game->gameUI ); assert( game->gameUI->getController(0) ); if( game->inCombat ) { closeMenuByEsc = false; } else { closeMenuByEsc = true; editHandle = game->gameUI->getController(0)->addKeyreader( this ); // debugKeyreader( editHandle, false, "CreditsMenu::CreditsMenu()" ); } }