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 }
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 ) { }
UpgradeAvailableWindow::UpgradeAvailableWindow(Ogui *ogui, game::Game *game, int player) { this->ogui = ogui; this->game = game; this->player = player; int xPosition = getLocaleGuiInt("gui_upgrade_available_position_x", 0); int yPosition = getLocaleGuiInt("gui_upgrade_available_position_y", 0); this->win = ogui->CreateSimpleWindow(xPosition, yPosition, getLocaleGuiInt("gui_upgrade_available_size_x", 0), getLocaleGuiInt("gui_upgrade_available_size_y", 0), NULL); this->win->SetUnmovable(); this->upgradeAvailableImage = ogui->LoadOguiImage(getLocaleGuiString("gui_upgrade_available_image")); upgradeAvailableButton = ogui->CreateSimpleImageButton(win, 0, 0, getLocaleGuiInt("gui_upgrade_available_size_x", 0), getLocaleGuiInt("gui_upgrade_available_size_y", 0), NULL, NULL, NULL); upgradeAvailableButton->SetDisabled(true); upgradeAvailableButton->SetDisabledImage(upgradeAvailableImage); lastUpdateValue = -1; lastUpdateWasAvailable = false; win->SetEffectListener(this); #ifdef PROJECT_SURVIVOR OguiAligner::align(win, OguiAligner::WIDESCREEN_FIX_RIGHT, ogui); OguiAligner::align(upgradeAvailableButton, OguiAligner::WIDESCREEN_FIX_RIGHT, ogui); #endif }
void init() { int x = getLocaleGuiInt( "gui_tabs_window_x", 0 ); int y = getLocaleGuiInt( "gui_tabs_window_y", 0 ); int w = getLocaleGuiInt( "gui_tabs_window_w", 0 ); int h = getLocaleGuiInt( "gui_tabs_window_h", 0 ); window = ogui->CreateSimpleWindow( x, y, w, h, NULL, 0 ); window->SetUnmovable(); buttonsUp.resize( 3 ); buttonsDown.resize( 3 ); buttons.resize( 3 ); font = ogui->LoadFont( getLocaleGuiString( "gui_tabs_font" ) ); buttonsUp[ GameUI::WINDOW_TYPE_LOG ] = ( "gui_tabs_log_normal" ); buttonsUp[ GameUI::WINDOW_TYPE_UPGRADE ] = ( "gui_tabs_upgrade_normal" ); buttonsUp[ GameUI::WINDOW_TYPE_MAP ] = ( "gui_tabs_map_normal" ); buttonsDown[ GameUI::WINDOW_TYPE_LOG ] = ( "gui_tabs_log_down" ); buttonsDown[ GameUI::WINDOW_TYPE_UPGRADE ] = ( "gui_tabs_upgrade_down" ); buttonsDown[ GameUI::WINDOW_TYPE_MAP ] = ( "gui_tabs_map_down" ); buttons[ GameUI::WINDOW_TYPE_LOG ] = NULL; #ifndef PROJECT_SURVIVOR buttons[ GameUI::WINDOW_TYPE_LOG ] = loadButton( buttonsUp[ GameUI::WINDOW_TYPE_LOG ], GameUI::WINDOW_TYPE_LOG ); #endif buttons[ GameUI::WINDOW_TYPE_UPGRADE ] = loadButton( buttonsUp[ GameUI::WINDOW_TYPE_UPGRADE ], GameUI::WINDOW_TYPE_UPGRADE ); buttons[ GameUI::WINDOW_TYPE_MAP ] = loadButton( buttonsUp[ GameUI::WINDOW_TYPE_MAP ], GameUI::WINDOW_TYPE_MAP ); visible = true; }
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::checkContinue() { if( continueButton ) { if( DoWeHaveAnySaveGames( game ) ) { continueButton->SetDisabled( false ); continueButton->SetText( getLocaleGuiString( "gui_mm_continue" ) ); } else { continueButton->SetDisabled( true ); continueButton->SetText( "" ); } } }
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 ); } }
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 ); }
void UpgradeWindow::CursorEvent(OguiButtonEvent *eve) { int id = eve->triggerButton->GetId(); if (eve->eventType == OguiButtonEvent::EVENT_TYPE_LEAVE) { if (id >= UPGRADEW_WEAPONBUT_FIRST && id <= UPGRADEW_WEAPONBUT_LAST) { highlightOn = false; } if (id >= UPGRADEW_UPGRADEBUT_FIRST && id <= UPGRADEW_UPGRADEBUT_LAST) { highlightOn = false; } } if (eve->eventType == OguiButtonEvent::EVENT_TYPE_OVER) { if (id >= UPGRADEW_WEAPONBUT_FIRST && id <= UPGRADEW_WEAPONBUT_LAST) { highlightedWeaponSlot = eve->triggerButton->GetId() - UPGRADEW_WEAPONBUT_FIRST; highlightedUpgradeSlot = -1; highlightedUpgradeId = -1; highlightOn = true; } if (id >= UPGRADEW_UPGRADEBUT_FIRST && id <= UPGRADEW_UPGRADEBUT_LAST) { highlightedWeaponSlot = (eve->triggerButton->GetId() - UPGRADEW_UPGRADEBUT_FIRST) / UPGRADEWINDOW_MAX_UPGRADES_PER_WEAPON; highlightedUpgradeSlot = (eve->triggerButton->GetId() - UPGRADEW_UPGRADEBUT_FIRST) % UPGRADEWINDOW_MAX_UPGRADES_PER_WEAPON; highlightedUpgradeId = (int)eve->extraArgument; highlightOn = true; } } if (eve->eventType == OguiButtonEvent::EVENT_TYPE_CLICK) { /* if (id >= UPGRADEW_WEAPONBUT_FIRST && id <= UPGRADEW_WEAPONBUT_LAST) { int weapId = (int)eve->extraArgument; PlayerWeaponry::selectWeapon(game, unit, weapId); } */ if (id == UPGRADEW_CLOSEBUT) { game->gameUI->playGUISound(getLocaleGuiString("gui_upgrades_sound_close")); this->applyUpgrades(); game->setPaused(false); // NOTE: must return here as this UpgradeWindow object HAS BEEN DELETED! //game->gameUI->closeUpgradeWindow(this->unit); fadeOut(); return; } if (id == UPGRADEW_UNDOBUT) { game->gameUI->playGUISound(getLocaleGuiString("gui_upgrades_sound_undo")); this->undoUpgrades(); } if (id >= UPGRADEW_UPGRADEBUT_FIRST && id <= UPGRADEW_UPGRADEBUT_LAST) { bool playDoneSound = false; // upgrade button int upgid = (int)eve->extraArgument; bool alreadyPending = false; LinkedListIterator iter(this->upgradesPending); while (iter.iterateAvailable()) { // WARNING: void * -> int cast int other = (int)iter.iterateNext(); if (other == upgid) { alreadyPending = true; break; } } if (!alreadyPending) { int tmp = this->upgradesPendingCost; if (game->upgradeManager->canUpgrade(unit, upgid, &tmp)) { fb_assert(tmp > this->upgradesPendingCost); //game->upgradeManager->upgrade(unit, upgid); // WARNING: int -> void * cast upgradesPending->append((void *)upgid); this->upgradesPendingCost = tmp; playDoneSound = true; } } else // undo by clicking { this->upgradesPendingCost -= game->upgradeManager->getUpgradePartCost( upgid ); LinkedListIterator iter(this->upgradesPending); while (iter.iterateAvailable()) { // WARNING: void * -> int cast void* ptr = iter.iterateNext(); if ( (int)ptr == upgid) { upgradesPending->remove( ptr ); } } } if (playDoneSound) { game->gameUI->playGUISound(getLocaleGuiString("gui_upgrades_sound_upgrade_done")); } else { game->gameUI->playGUISound(getLocaleGuiString("gui_upgrades_sound_upgrade_failed")); } } } update(); }
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)); } }
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()" ); } }
void OptionScripting::process(util::ScriptProcess *sp, int command, int intData, char *stringData, ScriptLastValueType *lastValue, GameScriptData *gsd, Game *game, bool *pause) { switch(command) { case GS_CMD_GETOPTIONVALUE: if (stringData != NULL) { game::GameOptionManager *oman = game::GameOptionManager::getInstance(); game::GameOption *opt = oman->getOptionByName(stringData); if (opt != NULL) { int tmp; VariableScriptingUtils vsutils; vsutils.getVariableValueToInt(opt, &tmp); *lastValue = tmp; } else { sp->error("OptionScripting::process - getOptionValue, No option with given name."); sp->debug(stringData); } } else { sp->error("OptionScripting::process - getOptionValue parameter missing."); } break; case GS_CMD_SETOPTIONVALUE: if (stringData != NULL) { game::GameOptionManager *oman = game::GameOptionManager::getInstance(); game::GameOption *opt = oman->getOptionByName(stringData); if (opt != NULL) { VariableScriptingUtils vsutils; vsutils.setVariableValueToInt(opt, *lastValue); if (opt->doesNeedApply()) ::apply_options_request = true; } else { sp->error("OptionScripting::process - setOptionValue, no option with given name."); sp->debug(stringData); } } else { sp->error("OptionScripting::process - setOptionValue parameter missing."); } break; case GS_CMD_PRINTOPTIONVALUE: if (stringData != NULL) { game::GameOptionManager *oman = game::GameOptionManager::getInstance(); game::GameOption *opt = oman->getOptionByName(stringData); if (opt != NULL) { VariableScriptingUtils vsutils; vsutils.logVariableValue(opt); } else { sp->error("OptionScripting::process - printOptionValue, no option with given name."); sp->debug(stringData); } } else { sp->error("OptionScripting::process - printOptionValue parameter missing."); } break; case GS_CMD_LISTOPTIONS: { game::GameOptionManager *oman = game::GameOptionManager::getInstance(); const LinkedList *optlist = oman->getOptionsList(); LinkedListIterator iter(optlist); while (iter.iterateAvailable()) { game::GameOption *opt = (game::GameOption *)iter.iterateNext(); Logger::getInstance()->warning(oman->getOptionNameForId(opt->getId())); } } break; case GS_CMD_SETOPTIONSTRINGVALUETO: // TODO //if (opt->doesNeedApply()) // ::apply_options_request = true; assert(!"TODO"); break; case GS_CMD_SETOPTIONSTRINGVALUE: if (stringData != NULL) { game::GameOptionManager *oman = game::GameOptionManager::getInstance(); game::GameOption *opt = oman->getOptionByName(stringData); if (opt != NULL) { if (opt->getVariableType() == IScriptVariable::VARTYPE_STRING) { if (gsd->stringValue != NULL) { opt->setStringValue(gsd->stringValue); if (opt->doesNeedApply()) ::apply_options_request = true; } else { sp->error("OptionScripting::process - Attempt to setOptionStringValue for null string."); sp->debug(stringData); } } else { sp->error("OptionScripting::process - setOptionStringValue, option is not of string type."); sp->debug(stringData); } } else { sp->error("OptionScripting::process - setOptionStringValue, no option with given name."); sp->debug(stringData); } } else { sp->error("OptionScripting::process - setOptionStringValue parameter missing."); } break; case GS_CMD_SETOPTIONFLOATVALUETO: // TODO //if (opt->doesNeedApply()) // ::apply_options_request = true; assert(!"TODO"); break; case GS_CMD_SETOPTIONINTVALUETO: // TODO //if (opt->doesNeedApply()) // ::apply_options_request = true; assert(!"TODO"); break; case GS_CMD_SETOPTIONBOOLVALUETO: // TODO //if (opt->doesNeedApply()) // ::apply_options_request = true; assert(!"TODO"); break; case GS_CMD_TOGGLEOPTION: if (stringData != NULL) { game::GameOptionManager *oman = game::GameOptionManager::getInstance(); game::GameOption *opt = oman->getOptionByName(stringData); if (opt != NULL) { if (!opt->isReadOnly()) { if (opt->isToggleable()) { opt->toggleValue(); if (opt->doesNeedApply()) ::apply_options_request = true; Logger::getInstance()->info("Toggled option value, new value follows..."); VariableScriptingUtils vsutils; vsutils.logVariableValue(opt); } else { sp->error("OptionScripting::process - Attempt to toggleOption a non-toggleable option."); } } else { sp->error("OptionScripting::process - Attempt to toggleOption a read-only option."); } } else { sp->error("OptionScripting::process - toggleOption, no option with given name."); sp->debug(stringData); } } else { sp->error("OptionScripting::process - toggleOption parameter missing."); } break; case GS_CMD_APPLYOPTIONS: ::apply_options_request = true; break; case GS_CMD_unlockBonusOption: if(stringData != NULL) { #ifdef PROJECT_SURVIVOR if(game && game->bonusManager) { std::string name = stringData; if(name == "*") { game->bonusManager->unlockAllOptions(); break; } bool already_unlocked = game->bonusManager->isOptionUnlocked(name); game->bonusManager->unlockOption(name); if(game->gameUI->getCombatWindow( 0 )) { ElaborateHintMessageWindow* win = ((ElaborateHintMessageWindow*)game->gameUI->getCombatWindow( 0 )->getSubWindow( "ElaborateHintMessageWindow" )); if(win && !already_unlocked) { win->setStyle("upgradeunlock"); std::string msg = "<h1>" + std::string(getLocaleGuiString("gui_elaboratehint_bonus_unlocked")) + "</h1>" + std::string(getLocaleGuiString("gui_elaboratehint_bonus_unlocked_image")) + std::string( getLocaleGuiString( ("gui_newgamemenu_bonus_" + name).c_str() ) ); if(!game->bonusManager->areOptionsAvailable()) { msg += "<br><br><i>" + std::string(getLocaleGuiString("gui_elaboratehint_bonus_complete")) + "</i> "; } else { msg += " "; } win->showMessage(msg); } } *lastValue = already_unlocked ? 0 : 1; } #endif } else { sp->error("OptionScripting::process - unlockBonusOption parameter missing."); } break; case GS_CMD_makeBonusOptionsAvailable: { #ifdef PROJECT_SURVIVOR if(game && game->bonusManager) { game->bonusManager->makeOptionsAvailable(true); } #endif } break; case GS_CMD_getBonusOptionsAvailable: { #ifdef PROJECT_SURVIVOR *lastValue = 0; if(game && game->bonusManager) { if(game->bonusManager->areOptionsAvailable()) { *lastValue = 1; } } #endif } break; default: sp->error("OptionsScripting::process - Unknown command."); assert(0); } }
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; }
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 }
CommandWindow::CommandWindow(Ogui *ogui, game::Game *game, int player) { this->player = player; this->game = game; this->ogui = ogui; this->quitPressed = false; buttons = new LinkedList(); win = ogui->CreateSimpleWindow(0, 0, 1024, 768, "Data/GUI/Windows/menu_nebula_background.tga"); win->Hide(); OguiButton *b; /* b = ogui->CreateSimpleTextButton(win, 16, 16, 200, 50, "Data/Buttons/mainmenu.tga", "Data/Buttons/mainmenu_down.tga", "Data/Buttons/mainmenu_highlight.tga", "Main menu", COMMANDW_MAINMENU); b->SetListener(this); buttons->append(b); */ //b = ogui->CreateSimpleTextButton(win, 512-250, 700, 250, 50, // "Data/GUI/Buttons/armormod.tga", "Data/GUI/Buttons/armormod_down.tga", // "Data/GUI/Buttons/armormod_highlight.tga", "Modify armors", COMMANDW_ARMOR); //b->SetListener(this); //b->SetDisabled(true); // disable armor modification button //buttons->append(b); //b = ogui->CreateSimpleTextButton(win, 512, 700, 250, 50, // "Data/GUI/Buttons/storage.tga", "Data/GUI/Buttons/storage_down.tga", // "Data/GUI/Buttons/storage_highlight.tga", "Storage", COMMANDW_STORAGE); //b->SetListener(this); //b->SetDisabled(true); // disable storage button //buttons->append(b); font = ogui->LoadFont( "Data/Fonts/mainmenu_big.ogf" ); b = ogui->CreateSimpleTextButton( win, 65, 315, 573, 27, "Data/GUI/Buttons/mainmenu_button_normal.tga", "Data/GUI/Buttons/mainmenu_button_high.tga", "Data/GUI/Buttons/mainmenu_button_high.tga", getLocaleGuiString( "gui_mm_new_game" ), COMMANDW_COMBAT ); b->SetListener( this ); buttons->append( b ); b->SetFont( font ); startButton = b; b->SetTextHAlign( OguiButton::TEXT_H_ALIGN_LEFT ); int i; for( i = 1; i <= 3; i++ ) { b = ogui->CreateSimpleTextButton( win, 65, 315+(28*i), 573, 27, "Data/GUI/Buttons/mainmenu_button_normal.tga", "Data/GUI/Buttons/mainmenu_button_high.tga", "Data/GUI/Buttons/mainmenu_button_high.tga", getLocaleGuiString( "gui_mm_options" ), COMMANDW_COMBAT ); b->SetListener( this ); buttons->append( b ); b->SetFont( font ); b->SetTextHAlign( OguiButton::TEXT_H_ALIGN_LEFT ); } b = ogui->CreateSimpleTextButton( win, 65, 462, 573, 27, "Data/GUI/Buttons/mainmenu_button_normal.tga", "Data/GUI/Buttons/mainmenu_button_high.tga", "Data/GUI/Buttons/mainmenu_button_high.tga", getLocaleGuiString( "gui_mm_credits" ), COMMANDW_COMBAT ); b->SetListener( this ); buttons->append( b ); b->SetFont( font ); b->SetTextHAlign( OguiButton::TEXT_H_ALIGN_LEFT ); b = ogui->CreateSimpleTextButton( win, 65, 462+28, 573, 27, "Data/GUI/Buttons/mainmenu_button_normal.tga", "Data/GUI/Buttons/mainmenu_button_high.tga", "Data/GUI/Buttons/mainmenu_button_high.tga", getLocaleGuiString( "gui_mm_quit" ), COMMANDW_QUIT ); b->SetListener( this ); buttons->append( b ); b->SetFont( font ); b->SetTextHAlign( OguiButton::TEXT_H_ALIGN_LEFT ); /* b = ogui->CreateSimpleTextButton(win, 512-250*2, 710, 250, 50, "Data/GUI/Buttons/mainquit.tga", "Data/GUI/Buttons/mainquit_down.tga", "Data/GUI/Buttons/mainquit_highlight.tga", getLocaleGuiString("gui_quit"), COMMANDW_QUIT); b->SetListener(this); buttons->append(b); b = ogui->CreateSimpleTextButton(win, 512+250, 710, 250, 50, "Data/GUI/Buttons/combat.tga", "Data/GUI/Buttons/combat_down.tga", "Data/GUI/Buttons/combat_highlight.tga", getLocaleGuiString("gui_mission_start_mission"), COMMANDW_COMBAT); b->SetListener(this); buttons->append(b); startButton = b; */ /* int chksum1 = 1280806280; int chksize1 = 11701276; chksum1 ^= 3000100245; chksize1 ^= 11000300; if (!util::Checksummer::doesChecksumAndSizeMatchFile(chksum1, chksize1, "Data/GUI/Windows/command.dds")) { b->SetDisabled(true); } */ ogui->SetCursorImageState(0, DH_CURSOR_ARROW); optionsWindow = new OptionsWindow(game, ogui, player); // Foreground foreground = ogui->CreateSimpleWindow( 0, 0, 1024, 768, "Data/GUI/Windows/menu_planet_foreground.tga" ); foreground->SetReactMask( 0 ); }
OptionsWindow::OptionsWindow(game::Game *game, Ogui *ogui, int player) { this->ogui = ogui; this->game = game; this->player = player; // win = ogui->CreateSimpleWindow(1024-256, 768-128-16-40, 256, 120, NULL); win = ogui->CreateSimpleWindow(1024-220, 16, 220, 120, NULL); win->SetUnmovable(); win->SetReactMask(OGUI_WIN_REACT_MASK_CURSOR_1); for (int ci = 0; ci < MAX_PLAYERS_PER_CLIENT; ci++) { playerTextLabel[ci] = NULL; playerEnabledButton[ci] = NULL; playerControllerButton[ci] = NULL; } OguiButton *b; /* //TEMP! only 1 player //for (int i = 0; i < MAX_PLAYERS_PER_CLIENT; i++) for (int i = 0; i < 1; i++) { const char *pltxt = "?"; if (i == 0) pltxt = getLocaleGuiString("gui_options_player_1"); //"Player 1"; if (i == 1) pltxt = getLocaleGuiString("gui_options_player_2"); //"Player 2"; if (i == 2) pltxt = getLocaleGuiString("gui_options_player_3"); //"Player 3"; if (i == 3) pltxt = getLocaleGuiString("gui_options_player_4"); //"Player 4"; playerTextLabel[i] = ogui->CreateTextLabel(win, 0, i * 20, 64, 18, pltxt); playerTextLabel[i]->SetFont(ui::defaultMediumIngameFont); playerTextLabel[i]->SetTextHAlign(OguiButton::TEXT_H_ALIGN_RIGHT); // player on/off button b = ogui->CreateSimpleTextButton(win, 64, i * 20, 32, 20, "Data/GUI/Buttons/playerenabled.tga", "Data/GUI/Buttons/playerenabled_down.tga", "Data/GUI/Buttons/playerenabled_highlight.tga", "", OPTIONSW_PLAYERENABLED_FIRST + i); b->SetReactMask(OGUI_REACT_MASK_OVER | OGUI_REACT_MASK_BUT_1); b->SetListener(this); b->SetEventMask(OGUI_EMASK_CLICK); b->SetFont(ui::defaultMediumIngameFont); b->SetTextHAlign(OguiButton::TEXT_H_ALIGN_CENTER); b->SetTextVAlign(OguiButton::TEXT_V_ALIGN_MIDDLE); playerEnabledButton[i] = b; // player controller button b = ogui->CreateSimpleTextButton(win, 64+32, i * 20, 96, 20, "Data/GUI/Buttons/playercontroller.tga", "Data/GUI/Buttons/playercontroller_down.tga", "Data/GUI/Buttons/playercontroller_highlight.tga", "", OPTIONSW_PLAYERCONTROLLER_FIRST + i); b->SetReactMask(OGUI_REACT_MASK_OVER | OGUI_REACT_MASK_BUT_1); b->SetListener(this); b->SetEventMask(OGUI_EMASK_CLICK); b->SetFont(ui::defaultMediumIngameFont); b->SetTextHAlign(OguiButton::TEXT_H_ALIGN_LEFT); b->SetTextVAlign(OguiButton::TEXT_V_ALIGN_MIDDLE); playerControllerButton[i] = b; } */ // difficulty label difficultyTextLabel = ogui->CreateTextLabel(win, 0, 3 * 20, 64, 18, getLocaleGuiString("gui_options_difficulty")); difficultyTextLabel->SetFont(ui::defaultMediumIngameFont); difficultyTextLabel->SetTextHAlign(OguiButton::TEXT_H_ALIGN_RIGHT); // autoadjust difficulty label /* autoadjustTextLabel = ogui->CreateTextLabel(win, 0, 4 * 20, 64, 18, getLocaleGuiString("gui_options_auto_balance")); autoadjustTextLabel->SetFont(ui::defaultMediumIngameFont); autoadjustTextLabel->SetTextHAlign(OguiButton::TEXT_H_ALIGN_RIGHT); */ // difficulty level b = ogui->CreateSimpleTextButton(win, 64, 3 * 20, 96, 20, "Data/GUI/Buttons/playercontroller.tga", "Data/GUI/Buttons/playercontroller_down.tga", "Data/GUI/Buttons/playercontroller_highlight.tga", "", OPTIONSW_DIFFICULTY_LEVEL); b->SetReactMask(OGUI_REACT_MASK_OVER | OGUI_REACT_MASK_BUT_1); b->SetListener(this); b->SetEventMask(OGUI_EMASK_CLICK); b->SetFont(ui::defaultMediumIngameFont); b->SetTextHAlign(OguiButton::TEXT_H_ALIGN_CENTER); b->SetTextVAlign(OguiButton::TEXT_V_ALIGN_MIDDLE); difficultyButton = b; // autoadjust difficulty /* b = ogui->CreateSimpleTextButton(win, 64, 4 * 20, 20, 20, "Data/GUI/Buttons/playerenabled.tga", "Data/GUI/Buttons/playerenabled_down.tga", "Data/GUI/Buttons/playerenabled_highlight.tga", "", OPTIONSW_AUTOADJUST); b->SetReactMask(OGUI_REACT_MASK_OVER | OGUI_REACT_MASK_BUT_1); b->SetListener(this); b->SetEventMask(OGUI_EMASK_CLICK); b->SetFont(ui::defaultMediumIngameFont); b->SetTextHAlign(OguiButton::TEXT_H_ALIGN_CENTER); b->SetTextVAlign(OguiButton::TEXT_V_ALIGN_MIDDLE); autoadjustButton = b; */ // HACK: SET DEFAULT DIFFICULTY TO EASY int difficultyLevel = 25; game->gameScripting->setGlobalIntVariableValue("general_difficulty_level", difficultyLevel); game->gameScripting->setGlobalIntVariableValue("damage_amount_level", difficultyLevel); game->gameScripting->setGlobalIntVariableValue("item_amount_level", difficultyLevel); game->gameScripting->setGlobalIntVariableValue("hostile_amount_level", difficultyLevel); refresh(); }
void OptionsWindow::refresh() { for (int i = 0; i < MAX_PLAYERS_PER_CLIENT; i++) { bool playerOn = false; if (playerEnabledButton[i] != NULL) { const char *txt = getLocaleGuiString("gui_options_off");//"Off"; if ((i == 0 && game::SimpleOptions::getBool(DH_OPT_B_1ST_PLAYER_ENABLED)) || (i == 1 && game::SimpleOptions::getBool(DH_OPT_B_2ND_PLAYER_ENABLED)) || (i == 2 && game::SimpleOptions::getBool(DH_OPT_B_3RD_PLAYER_ENABLED)) || (i == 3 && game::SimpleOptions::getBool(DH_OPT_B_4TH_PLAYER_ENABLED))) { txt = getLocaleGuiString("gui_options_on");//"On"; playerOn = true; } playerEnabledButton[i]->SetText(txt); } if (playerControllerButton[i] != NULL) { const char *txt = getLocaleGuiString("gui_options_none");//" None"; const char *keybinds = ""; if (i == 0) keybinds = game::SimpleOptions::getString(DH_OPT_S_1ST_PLAYER_KEYBINDS); if (i == 1) keybinds = game::SimpleOptions::getString(DH_OPT_S_2ND_PLAYER_KEYBINDS); if (i == 2) keybinds = game::SimpleOptions::getString(DH_OPT_S_3RD_PLAYER_KEYBINDS); if (i == 3) keybinds = game::SimpleOptions::getString(DH_OPT_S_4TH_PLAYER_KEYBINDS); if (keybinds != NULL && keybinds[0] != '\0') { txt = getLocaleGuiString("gui_options_custom"); //" Custom"; if (strcmp(keybinds, "Config/keybinds_mouse.txt") == 0) txt = getLocaleGuiString("gui_options_kb_mouse");//" Kb+Mouse"; if (strcmp(keybinds, "Config/keybinds_joypad1.txt") == 0) txt = getLocaleGuiString("gui_options_joypad1");//" Joypad 1"; if (strcmp(keybinds, "Config/keybinds_joypad2.txt") == 0) txt = getLocaleGuiString("gui_options_joypad2");//" Joypad 2"; } if (!playerOn) { txt = getLocaleGuiString("gui_options_disabled"); //" Disabled"; playerControllerButton[i]->SetDisabled(true); } else { playerControllerButton[i]->SetDisabled(false); } playerControllerButton[i]->SetText(txt); } } const char *lvlName = getLocaleGuiString("gui_custom"); int difficultyLevel = game->gameScripting->getGlobalIntVariableValue("general_difficulty_level"); if (difficultyLevel < 25) { lvlName = getLocaleGuiString("gui_options_very_easy"); } else if (difficultyLevel < 50) { lvlName = getLocaleGuiString("gui_options_easy"); } else if (difficultyLevel < 75) { lvlName = getLocaleGuiString("gui_options_normal"); } else if (difficultyLevel < 100) { lvlName = getLocaleGuiString("gui_options_hard"); } else if (difficultyLevel == 100) { lvlName = getLocaleGuiString("gui_options_very_hard"); } difficultyButton->SetText(lvlName); /* int autoadjust = game->gameScripting->getGlobalIntVariableValue("autoadjust_difficulty_level"); if (autoadjust != 0) autoadjustButton->SetText("X"); else autoadjustButton->SetText(""); */ }