void SaveMode::_InitSaveSlots() { // Check all available slots for saves and autosaves. bool available_saves = false; // When in load mode, check the saves validity and skip invalid slots _file_list.SetSkipDisabled(true); for (uint32_t i = 0; i < SystemManager->GetGameSaveSlots(); ++i) { _file_list.AddOption(MakeUnicodeString(" " + VTranslate("Slot %d", i + 1))); // Add a key to slots with valid autosaves if (_IsAutoSaveValid(i)) { _file_list.AddOptionElementImage(i, GlobalManager->Media().GetKeyItemIcon()); _file_list.GetEmbeddedImage(i)->SetHeightKeepRatio(25); _file_list.AddOptionElementPosition(i, 30); } if (!_PreviewGame(_BuildSaveFilename(i))) { _file_list.EnableOption(i, false); // If the current selection is disabled, reset it. if (static_cast<int32_t>(i) == _file_list.GetSelection()) _file_list.SetSelection(i + 1); } else { available_saves = true; } } if (!available_saves) _current_state = SAVE_MODE_NO_VALID_SAVES; }
bool SaveMode::_IsAutoSaveValid(uint32_t id) { std::string autosave_filename = _BuildSaveFilename(id, true); std::string save_filename = _BuildSaveFilename(id, false); if (!vt_utils::DoesFileExist(autosave_filename) || !vt_utils::DoesFileExist(save_filename)) return false; // Check whether the autosave is strictly more recent than the save. if (vt_utils::GetFileModTime(autosave_filename) <= vt_utils::GetFileModTime(_BuildSaveFilename(id))) return false; // And check whether the autosave is valid. if (!_PreviewGame(autosave_filename)) return false; return true; }
bool SaveMode::_CheckSavesValidity() { // check all available slots bool available_saves = false; for (uint32 i = 0; i < _file_list.GetNumberOptions(); ++i) { if (!_PreviewGame(i)) { _file_list.EnableOption(i, false); // If the current selection is disabled, reset it. if ((int32)i == _file_list.GetSelection()) _file_list.SetSelection(i + 1); } else { available_saves = true; } } return available_saves; }
SaveMode::SaveMode(bool save_mode, uint32 x_position, uint32 y_position) : GameMode(), _current_state(SAVE_MODE_LOADING), _dim_color(0.35f, 0.35f, 0.35f, 1.0f), // A grayish opaque color _x_position(x_position), _y_position(y_position), _save_mode(save_mode) { mode_type = MODE_MANAGER_SAVE_MODE; _window.Create(600.0f, 500.0f); _window.SetPosition(212.0f, 630.0f); _window.SetDisplayMode(VIDEO_MENU_EXPAND_FROM_CENTER); _window.Hide(); _left_window.Create(150.0f, 500.0f); _left_window.SetPosition(212.0f, 630.0f); _left_window.SetDisplayMode(VIDEO_MENU_EXPAND_FROM_CENTER); _left_window.Show(); _title_window.Create(600.0f, 50.0f); _title_window.SetPosition(212.0f, 680.0f); _title_window.SetDisplayMode(VIDEO_MENU_EXPAND_FROM_CENTER); _title_window.Show(); // Initialize the save successful message box _title_textbox.SetPosition(552.0f, 665.0f); _title_textbox.SetDimensions(200.0f, 50.0f); _title_textbox.SetTextStyle(TextStyle("title22")); _title_textbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); if (_save_mode) _title_textbox.SetDisplayText(UTranslate("Save Game")); else _title_textbox.SetDisplayText(UTranslate("Load Game")); for (int i = 0; i < 4; i++) { _character_window[i].Create(450.0f, 100.0f); _character_window[i].SetDisplayMode(VIDEO_MENU_EXPAND_FROM_CENTER); _character_window[i].Show(); } _character_window[0].SetPosition(355.0f, 630.0f); _character_window[1].SetPosition(355.0f, 530.0f); _character_window[2].SetPosition(355.0f, 430.0f); _character_window[3].SetPosition(355.0f, 330.0f); // Initialize the save options box _file_list.SetPosition(315.0f, 384.0f); _file_list.SetDimensions(150.0f, 500.0f, 1, 6, 1, 6); _file_list.SetTextStyle(TextStyle("title22")); _file_list.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _file_list.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _file_list.SetSelectMode(VIDEO_SELECT_SINGLE); _file_list.SetCursorOffset(-58.0f, 18.0f); _file_list.AddOption(UTranslate("Slot 1")); _file_list.AddOption(UTranslate("Slot 2")); _file_list.AddOption(UTranslate("Slot 3")); _file_list.AddOption(UTranslate("Slot 4")); _file_list.AddOption(UTranslate("Slot 5")); _file_list.AddOption(UTranslate("Slot 6")); // Restore the cursor position to the last load/save position. uint32 slot_id = GlobalManager->GetGameSlotId(); _file_list.SetSelection(slot_id); // Initialize the confirmation option box _confirm_save_optionbox.SetPosition(512.0f, 384.0f); _confirm_save_optionbox.SetDimensions(250.0f, 200.0f, 1, 2, 1, 2); _confirm_save_optionbox.SetTextStyle(TextStyle("title22")); _confirm_save_optionbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _confirm_save_optionbox.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _confirm_save_optionbox.SetSelectMode(VIDEO_SELECT_SINGLE); _confirm_save_optionbox.SetCursorOffset(-58.0f, 18.0f); _confirm_save_optionbox.AddOption(UTranslate("Confirm Save")); _confirm_save_optionbox.AddOption(UTranslate("Cancel")); _confirm_save_optionbox.SetSelection(0); // Initialize the save successful message box _save_success_message.SetPosition(552.0f, 454.0f); _save_success_message.SetDimensions(250.0f, 100.0f); _save_success_message.SetTextStyle(TextStyle("title22")); _save_success_message.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _save_success_message.SetDisplayText(UTranslate("Save successful!")); // Initialize the save failure message box _save_failure_message.SetPosition(512.0f, 384.0f); _save_failure_message.SetDimensions(250.0f, 100.0f); _save_failure_message.SetTextStyle(TextStyle("title22")); _save_failure_message.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _save_failure_message.SetDisplayText(UTranslate("Unable to save game!\nSave FAILED!")); // Initialize the save preview text boxes _map_name_textbox.SetPosition(600.0f, 215.0f); _map_name_textbox.SetDimensions(250.0f, 26.0f); _map_name_textbox.SetTextStyle(TextStyle("title22")); _map_name_textbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _map_name_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _map_name_textbox.SetDisplayText(" "); _time_textbox.SetPosition(600.0f, 185.0f); _time_textbox.SetDimensions(250.0f, 26.0f); _time_textbox.SetTextStyle(TextStyle("title22")); _time_textbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _time_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _time_textbox.SetDisplayText(" "); _drunes_textbox.SetPosition(600.0f, 155.0f); _drunes_textbox.SetDimensions(250.0f, 26.0f); _drunes_textbox.SetTextStyle(TextStyle("title22")); _drunes_textbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _drunes_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _drunes_textbox.SetDisplayText(" "); if (_save_mode) _current_state = SAVE_MODE_SAVING; _window.Show(); // Load the first slot data _PreviewGame(_file_list.GetSelection()); }
void SaveMode::Update() { if (InputManager->QuitPress() == true) { ModeManager->Pop(); return; } _file_list.Update(); // Screen is in the process of fading out, in order to load a game if (_current_state == SAVE_MODE_FADING_OUT) { return; } // Otherwise, it's time to start handling events. else if (InputManager->ConfirmPress()) { switch (_current_state) { case SAVE_MODE_SAVING: if (_file_list.GetSelection() > -1) { _current_state = SAVE_MODE_CONFIRMING_SAVE; } break; case SAVE_MODE_CONFIRMING_SAVE: if (_confirm_save_optionbox.GetSelection() == 0) { // note: using int here, because uint8 will NOT work // do not change unless you understand this and can test it properly! int id = _file_list.GetSelection(); std::ostringstream f; f << GetUserDataPath(true) + "saved_game_" << id << ".lua"; std::string filename = f.str(); // now, attempt to save the game. If failure, we need to tell the user that! if (GlobalManager->SaveGame(filename, (uint32)id, _x_position, _y_position)) { _current_state = SAVE_MODE_SAVE_COMPLETE; AudioManager->PlaySound("snd/save_successful_nick_bowler_oga.wav"); } else { _current_state = SAVE_MODE_SAVE_FAILED; AudioManager->PlaySound("snd/cancel.wav"); } } else { _current_state = SAVE_MODE_SAVING; } break; case SAVE_MODE_SAVE_COMPLETE: case SAVE_MODE_SAVE_FAILED: _current_state = SAVE_MODE_SAVING; _PreviewGame(_file_list.GetSelection()); break; case SAVE_MODE_LOADING: if (_file_list.GetSelection() > -1) { _LoadGame(_file_list.GetSelection()); } else { // Leave right away where there is nothing else // to do than loading. ModeManager->Pop(); } break; } // end switch (_current_state) } // end if (InputManager->ConfirmPress()) else if (InputManager->CancelPress()) { switch (_current_state) { case SAVE_MODE_SAVING: case SAVE_MODE_LOADING: // Leave right away where there is nothing else to do than // loading. ModeManager->Pop(); break; case SAVE_MODE_CONFIRMING_SAVE: _current_state = SAVE_MODE_SAVING; _PreviewGame(_file_list.GetSelection()); break; } // end switch (_current_state) } // end if (InputManager->CancelPress()) else if (InputManager->UpPress()) { switch (_current_state) { case SAVE_MODE_SAVING: case SAVE_MODE_LOADING: _file_list.InputUp(); if (_file_list.GetSelection() > -1) { _PreviewGame(_file_list.GetSelection()); } else { _map_name_textbox.SetDisplayText(" "); _time_textbox.SetDisplayText(" "); _drunes_textbox.SetDisplayText(" "); } break; case SAVE_MODE_CONFIRMING_SAVE: _confirm_save_optionbox.InputUp(); break; } // end switch (_current_state) } // end if (InputManager->UpPress()) else if (InputManager->DownPress()) { switch (_current_state) { case SAVE_MODE_SAVING: case SAVE_MODE_LOADING: _file_list.InputDown(); if (_file_list.GetSelection() > -1) { _PreviewGame(_file_list.GetSelection()); } break; case SAVE_MODE_CONFIRMING_SAVE: _confirm_save_optionbox.InputDown(); break; } // end switch (_current_state) } // end if (InputManager->DownPress()) } // void SaveMode::Update()
SaveMode::SaveMode(bool save_mode, uint32_t x_position, uint32_t y_position) : GameMode(MODE_MANAGER_SAVE_MODE), _current_state(SAVE_MODE_LOADING), _dim_color(0.35f, 0.35f, 0.35f, 1.0f), // A grayish opaque color _x_position(x_position), _y_position(y_position), _save_mode(save_mode) { _window.Create(600.0f, 500.0f); _window.SetPosition(212.0f, 138.0f); _window.Hide(); _left_window.Create(150.0f, 500.0f); _left_window.SetPosition(212.0f, 138.0f); _left_window.Show(); _title_window.Create(600.0f, 50.0f); _title_window.SetPosition(212.0f, 88.0f); _title_window.Show(); const float centered_text_xpos = _window.GetXPosition() + 50.0f; const float centered_text_width = _window.GetWidth() - 100.f; // Initialize the save successful message box _title_textbox.SetPosition(centered_text_xpos, 103.0f); _title_textbox.SetDimensions(centered_text_width, 50.0f); _title_textbox.SetTextStyle(TextStyle("title22")); _title_textbox.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _title_textbox.SetTextAlignment(VIDEO_X_CENTER, VIDEO_Y_BOTTOM); if(_save_mode) _title_textbox.SetDisplayText(UTranslate("Save Game")); else _title_textbox.SetDisplayText(UTranslate("Load Game")); for(uint32_t i = 0; i < CHARACTERS_SHOWN_SLOTS; ++i) { _character_window[i].Create(450.0f, 100.0f); _character_window[i].Show(); } _character_window[0].SetPosition(355.0f, 138.0f); _character_window[1].SetPosition(355.0f, 238.0f); _character_window[2].SetPosition(355.0f, 338.0f); _character_window[3].SetPosition(355.0f, 438.0f); // Initialize the save options box _file_list.SetPosition(315.0f, 384.0f); _file_list.SetDimensions(150.0f, 500.0f, 1, SystemManager->GetGameSaveSlots(), 1, SystemManager->GetGameSaveSlots() > 6 ? 6 : SystemManager->GetGameSaveSlots()); _file_list.SetTextStyle(TextStyle("title22")); _file_list.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _file_list.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _file_list.SetSelectMode(VIDEO_SELECT_SINGLE); _file_list.SetCursorOffset(-58.0f, -18.0f); // Initialize the confirmation option box _confirm_save_optionbox.SetPosition(512.0f, 384.0f); _confirm_save_optionbox.SetDimensions(centered_text_width, 200.0f, 1, 2, 1, 2); _confirm_save_optionbox.SetTextStyle(TextStyle("title22")); _confirm_save_optionbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _confirm_save_optionbox.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _confirm_save_optionbox.SetSelectMode(VIDEO_SELECT_SINGLE); _confirm_save_optionbox.SetCursorOffset(-58.0f, -18.0f); _confirm_save_optionbox.AddOption(UTranslate("Confirm Save")); _confirm_save_optionbox.AddOption(UTranslate("Cancel")); _confirm_save_optionbox.SetSelection(0); // Initialize the auto-save option box _load_auto_save_optionbox.SetPosition(512.0f, 384.0f); _load_auto_save_optionbox.SetDimensions(centered_text_width, 200.0f, 1, 3, 1, 3); _load_auto_save_optionbox.SetTextStyle(TextStyle("title22")); _load_auto_save_optionbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _load_auto_save_optionbox.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _load_auto_save_optionbox.SetSelectMode(VIDEO_SELECT_SINGLE); _load_auto_save_optionbox.SetCursorOffset(-58.0f, -18.0f); _load_auto_save_optionbox.AddOption(UTranslate("Load Auto-Save")); _load_auto_save_optionbox.AddOption(UTranslate("Load Save")); _load_auto_save_optionbox.AddOption(UTranslate("Cancel")); _load_auto_save_optionbox.SetSelection(0); // Initialize the save successful message box _save_success_message.SetPosition(centered_text_xpos, 314.0f); _save_success_message.SetDimensions(centered_text_width, 100.0f); _save_success_message.SetTextStyle(TextStyle("title22")); _save_success_message.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _save_success_message.SetTextAlignment(VIDEO_X_CENTER, VIDEO_Y_BOTTOM); _save_success_message.SetDisplayText(UTranslate("Save successful!")); // Initialize the save failure message box _save_failure_message.SetPosition(centered_text_xpos, 314.0f); _save_failure_message.SetDimensions(centered_text_width, 100.0f); _save_failure_message.SetTextStyle(TextStyle("title22")); _save_failure_message.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _save_failure_message.SetTextAlignment(VIDEO_X_CENTER, VIDEO_Y_BOTTOM); _save_failure_message.SetDisplayText(UTranslate("Unable to save game!\nSave FAILED!")); _no_valid_saves_message.SetPosition(centered_text_xpos, 314.0f); _no_valid_saves_message.SetDimensions(centered_text_width, 100.0f); _no_valid_saves_message.SetTextStyle(TextStyle("title22")); _no_valid_saves_message.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _no_valid_saves_message.SetTextAlignment(VIDEO_X_CENTER, VIDEO_Y_BOTTOM); _no_valid_saves_message.SetDisplayText(UTranslate("No valid saves found!")); // Initialize the save preview text boxes _map_name_textbox.SetPosition(600.0f, 558.0f); _map_name_textbox.SetDimensions(320.0f, 26.0f); _map_name_textbox.SetTextStyle(TextStyle("title22")); _map_name_textbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _map_name_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _map_name_textbox.SetDisplayText(" "); _time_textbox.SetPosition(600.0f, 583.0f); _time_textbox.SetDimensions(250.0f, 26.0f); _time_textbox.SetTextStyle(TextStyle("title22")); _time_textbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _time_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _time_textbox.ClearText(); _drunes_textbox.SetPosition(600.0f, 613.0f); _drunes_textbox.SetDimensions(250.0f, 26.0f); _drunes_textbox.SetTextStyle(TextStyle("title22")); _drunes_textbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _drunes_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _drunes_textbox.ClearText(); _clock_icon = vt_global::GlobalManager->Media().GetClockIcon(); _clock_icon->SetWidthKeepRatio(30.0f); _drunes_icon = vt_global::GlobalManager->Media().GetDrunesIcon(); _drunes_icon->SetWidthKeepRatio(30.0f); if(_save_mode) { for (uint32_t i = 0; i < SystemManager->GetGameSaveSlots(); ++i) { _file_list.AddOption(MakeUnicodeString(VTranslate("Slot %d", i + 1))); } // Restore the cursor position to the last load/save position. uint32_t game_slot_id = GlobalManager->GetGameSlotId(); // Propose the first slot when none where chosen yet if (game_slot_id == std::numeric_limits<uint32_t>::max()) game_slot_id = 0; _file_list.SetSelection(game_slot_id); _current_state = SAVE_MODE_SAVING; } else { _InitSaveSlots(); } _window.Show(); // Load the first slot data if(_file_list.GetSelection() > -1) _PreviewGame(_BuildSaveFilename(_file_list.GetSelection())); }
void SaveMode::Update() { if(InputManager->QuitPress()) { ModeManager->Pop(); return; } // Screen is in the process of fading out, in order to load a game if(_current_state == SAVE_MODE_FADING_OUT) { return; } _file_list.Update(); _confirm_save_optionbox.Update(); _load_auto_save_optionbox.Update(); GlobalMedia& media = GlobalManager->Media(); // Otherwise, it's time to start handling events. if(InputManager->ConfirmPress()) { media.PlaySound("confirm"); switch(_current_state) { case SAVE_MODE_SAVING: if(_file_list.GetSelection() > -1) { _current_state = SAVE_MODE_CONFIRMING_SAVE; } break; case SAVE_MODE_CONFIRMING_SAVE: if(_confirm_save_optionbox.GetSelection() == 0) { uint32_t id = static_cast<uint32_t>(_file_list.GetSelection()); uint32_t stamina = MapMode::CurrentInstance() ? MapMode::CurrentInstance()->GetStamina() : 0; GlobalManager->GetMapData().SetSaveStamina(stamina); // Attempt to save the game if(GlobalManager->SaveGame(_BuildSaveFilename(id), id, _x_position, _y_position)) { _current_state = SAVE_MODE_SAVE_COMPLETE; AudioManager->PlaySound("data/sounds/save_successful_nick_bowler_oga.wav"); // Remove the autosave in that case. _DeleteAutoSave(id); } else { _current_state = SAVE_MODE_SAVE_FAILED; AudioManager->PlaySound("data/sounds/cancel.wav"); } } else { _current_state = SAVE_MODE_SAVING; } break; case SAVE_MODE_SAVE_COMPLETE: case SAVE_MODE_SAVE_FAILED: _current_state = SAVE_MODE_SAVING; _PreviewGame(_BuildSaveFilename(_file_list.GetSelection())); break; case SAVE_MODE_CONFIRM_AUTOSAVE: switch (_load_auto_save_optionbox.GetSelection()) { case 0: // Load autosave _LoadGame(_BuildSaveFilename(_file_list.GetSelection(), true)); break; case 1: // Load save _LoadGame(_BuildSaveFilename(_file_list.GetSelection())); break; case 2: // Cancel default: _current_state = SAVE_MODE_LOADING; } break; case SAVE_MODE_LOADING: if(_file_list.GetSelection() > -1) { // Check whether a more recent autosave file exists uint32_t id = static_cast<uint32_t>(_file_list.GetSelection()); if (_IsAutoSaveValid(id)) { _current_state = SAVE_MODE_CONFIRM_AUTOSAVE; } else { _LoadGame(_BuildSaveFilename(id)); } } else { // Leave right away where there is nothing else // to do than loading. ModeManager->Pop(); } break; default: case SAVE_MODE_NO_VALID_SAVES: // Leave right away as there is nothing else to do ModeManager->Pop(); break; } } else if(InputManager->CancelPress()) { media.PlaySound("cancel"); switch(_current_state) { default: case SAVE_MODE_NO_VALID_SAVES: case SAVE_MODE_SAVING: case SAVE_MODE_LOADING: // Leave right away where there is nothing else to do ModeManager->Pop(); break; case SAVE_MODE_CONFIRM_AUTOSAVE: _current_state = SAVE_MODE_LOADING; _PreviewGame(_BuildSaveFilename(_file_list.GetSelection())); break; case SAVE_MODE_CONFIRMING_SAVE: _current_state = SAVE_MODE_SAVING; _PreviewGame(_BuildSaveFilename(_file_list.GetSelection())); break; } } else if(InputManager->UpPress()) { media.PlaySound("bump"); switch(_current_state) { case SAVE_MODE_SAVING: case SAVE_MODE_LOADING: _file_list.InputUp(); if(_file_list.GetSelection() > -1) { _PreviewGame(_BuildSaveFilename(_file_list.GetSelection())); } else { _ClearSaveData(false); } break; case SAVE_MODE_CONFIRMING_SAVE: _confirm_save_optionbox.InputUp(); break; case SAVE_MODE_CONFIRM_AUTOSAVE: _load_auto_save_optionbox.InputUp(); break; } } else if(InputManager->DownPress()) { media.PlaySound("bump"); switch(_current_state) { case SAVE_MODE_SAVING: case SAVE_MODE_LOADING: _file_list.InputDown(); if(_file_list.GetSelection() > -1) { _PreviewGame(_BuildSaveFilename(_file_list.GetSelection())); } else { _ClearSaveData(false); } break; case SAVE_MODE_CONFIRMING_SAVE: _confirm_save_optionbox.InputDown(); break; case SAVE_MODE_CONFIRM_AUTOSAVE: _load_auto_save_optionbox.InputDown(); break; } } }
SaveMode::SaveMode(bool save_mode, uint32 x_position, uint32 y_position) : GameMode(), _current_state(SAVE_MODE_LOADING), _dim_color(0.35f, 0.35f, 0.35f, 1.0f), // A grayish opaque color _x_position(x_position), _y_position(y_position), _save_mode(save_mode) { mode_type = MODE_MANAGER_SAVE_MODE; _window.Create(600.0f, 500.0f); _window.SetPosition(212.0f, 138.0f); _window.SetDisplayMode(VIDEO_MENU_EXPAND_FROM_CENTER); _window.Hide(); _left_window.Create(150.0f, 500.0f); _left_window.SetPosition(212.0f, 138.0f); _left_window.SetDisplayMode(VIDEO_MENU_EXPAND_FROM_CENTER); _left_window.Show(); _title_window.Create(600.0f, 50.0f); _title_window.SetPosition(212.0f, 88.0f); _title_window.SetDisplayMode(VIDEO_MENU_EXPAND_FROM_CENTER); _title_window.Show(); // Initialize the save successful message box _title_textbox.SetPosition(552.0f, 103.0f); _title_textbox.SetDimensions(200.0f, 50.0f); _title_textbox.SetTextStyle(TextStyle("title22")); _title_textbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); if(_save_mode) _title_textbox.SetDisplayText(UTranslate("Save Game")); else _title_textbox.SetDisplayText(UTranslate("Load Game")); for(uint32 i = 0; i < 4; ++i) { _character_window[i].Create(450.0f, 100.0f); _character_window[i].SetDisplayMode(VIDEO_MENU_EXPAND_FROM_CENTER); _character_window[i].Show(); } _character_window[0].SetPosition(355.0f, 138.0f); _character_window[1].SetPosition(355.0f, 238.0f); _character_window[2].SetPosition(355.0f, 338.0f); _character_window[3].SetPosition(355.0f, 438.0f); // Initialize the save options box _file_list.SetPosition(315.0f, 384.0f); _file_list.SetDimensions(150.0f, 500.0f, 1, 6, 1, 6); _file_list.SetTextStyle(TextStyle("title22")); _file_list.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _file_list.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _file_list.SetSelectMode(VIDEO_SELECT_SINGLE); _file_list.SetCursorOffset(-58.0f, -18.0f); _file_list.AddOption(UTranslate("Slot 1")); _file_list.AddOption(UTranslate("Slot 2")); _file_list.AddOption(UTranslate("Slot 3")); _file_list.AddOption(UTranslate("Slot 4")); _file_list.AddOption(UTranslate("Slot 5")); _file_list.AddOption(UTranslate("Slot 6")); // Restore the cursor position to the last load/save position. uint32 slot_id = GlobalManager->GetGameSlotId(); _file_list.SetSelection(slot_id); // Initialize the confirmation option box _confirm_save_optionbox.SetPosition(512.0f, 384.0f); _confirm_save_optionbox.SetDimensions(250.0f, 200.0f, 1, 2, 1, 2); _confirm_save_optionbox.SetTextStyle(TextStyle("title22")); _confirm_save_optionbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _confirm_save_optionbox.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _confirm_save_optionbox.SetSelectMode(VIDEO_SELECT_SINGLE); _confirm_save_optionbox.SetCursorOffset(-58.0f, -18.0f); _confirm_save_optionbox.AddOption(UTranslate("Confirm Save")); _confirm_save_optionbox.AddOption(UTranslate("Cancel")); _confirm_save_optionbox.SetSelection(0); // Initialize the save successful message box _save_success_message.SetPosition(552.0f, 314.0f); _save_success_message.SetDimensions(250.0f, 100.0f); _save_success_message.SetTextStyle(TextStyle("title22")); _save_success_message.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _save_success_message.SetDisplayText(UTranslate("Save successful!")); // Initialize the save failure message box _save_failure_message.SetPosition(512.0f, 384.0f); _save_failure_message.SetDimensions(250.0f, 100.0f); _save_failure_message.SetTextStyle(TextStyle("title22")); _save_failure_message.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _save_failure_message.SetDisplayText(UTranslate("Unable to save game!\nSave FAILED!")); _no_valid_saves_message.SetPosition(512.0f, 384.0f); _no_valid_saves_message.SetDimensions(250.0f, 100.0f); _no_valid_saves_message.SetTextStyle(TextStyle("title22")); _no_valid_saves_message.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _no_valid_saves_message.SetDisplayText(UTranslate("No valid saves found!")); // Initialize the save preview text boxes _map_name_textbox.SetPosition(600.0f, 553.0f); _map_name_textbox.SetDimensions(300.0f, 26.0f); _map_name_textbox.SetTextStyle(TextStyle("title22")); _map_name_textbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _map_name_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _map_name_textbox.SetDisplayText(" "); _time_textbox.SetPosition(600.0f, 583.0f); _time_textbox.SetDimensions(250.0f, 26.0f); _time_textbox.SetTextStyle(TextStyle("title22")); _time_textbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _time_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _time_textbox.SetDisplayText(" "); _drunes_textbox.SetPosition(600.0f, 613.0f); _drunes_textbox.SetDimensions(250.0f, 26.0f); _drunes_textbox.SetTextStyle(TextStyle("title22")); _drunes_textbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _drunes_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _drunes_textbox.SetDisplayText(" "); _clock_icon = vt_global::GlobalManager->Media().GetClockIcon(); _clock_icon->SetWidthKeepRatio(30.0f); _drunes_icon = vt_global::GlobalManager->Media().GetDrunesIcon(); _drunes_icon->SetWidthKeepRatio(30.0f); if(_save_mode) { _current_state = SAVE_MODE_SAVING; } else { // When in load mode, check the saves validity and skip invalid slots _file_list.SetSkipDisabled(true); if (!_CheckSavesValidity()) _current_state = SAVE_MODE_NO_VALID_SAVES; } _window.Show(); // Load the first slot data if(_file_list.GetSelection() > -1) _PreviewGame(_file_list.GetSelection()); }