void SmallCharacterWindow::SetCharacter(GlobalCharacter* character) { delete _character; _character = character; if(!_character || _character->GetID() == vt_global::GLOBAL_CHARACTER_INVALID) { _character_name.Clear(); _character_data.Clear(); _portrait = StillImage(); return; } _portrait = character->GetPortrait(); // Only size up valid portraits if(!_portrait.GetFilename().empty()) _portrait.SetDimensions(100.0f, 100.0f); // the characters' name is already translated. _character_name.SetText(_character->GetName(), TextStyle("title22")); // And the rest of the data /// tr: level ustring char_data = UTranslate("Lv: ") + MakeUnicodeString(NumberToString(_character->GetExperienceLevel()) + "\n"); /// tr: hit points char_data += UTranslate("HP: ") + MakeUnicodeString(NumberToString(_character->GetHitPoints()) + " / " + NumberToString(_character->GetMaxHitPoints()) + "\n"); /// tr: skill points char_data += UTranslate("SP: ") + MakeUnicodeString(NumberToString(_character->GetSkillPoints()) + " / " + NumberToString(_character->GetMaxSkillPoints())); _character_data.SetText(char_data, TextStyle("text20")); }
void TradeInterface::_ChangeViewMode(SHOP_VIEW_MODE new_mode) { if(_view_mode == new_mode) return; if(new_mode == SHOP_VIEW_MODE_LIST) { _view_mode = new_mode; ShopMode::CurrentInstance()->ObjectViewer()->ChangeViewMode(_view_mode); _category_display.ChangeViewMode(_view_mode); _properties_header.SetOwner(ShopMode::CurrentInstance()->GetMiddleWindow()); _properties_header.SetPosition(480.0f, 10.0f); } else if(new_mode == SHOP_VIEW_MODE_INFO) { _view_mode = new_mode; ShopMode::CurrentInstance()->ObjectViewer()->ChangeViewMode(_view_mode); _category_display.ChangeViewMode(_view_mode); _category_display.SetSelectedObject(_selected_object); _properties_header.SetOwner(ShopMode::CurrentInstance()->GetBottomWindow()); _properties_header.SetPosition(480.0f, 15.0f); _selected_name.SetText(_selected_object->GetObject()->GetName()); _selected_icon = _selected_object->GetObject()->GetIconImage(); _selected_icon.SetDimensions(30.0f, 30.0f); _selected_properties.SetOptionText(0, MakeUnicodeString(NumberToString(_selected_object->GetTradePrice()))); _selected_properties.SetOptionText(1, MakeUnicodeString("×" + NumberToString(_selected_object->GetStockCount()))); _selected_properties.SetOptionText(2, MakeUnicodeString("×" + NumberToString(_selected_object->GetOwnCount()))); } else { IF_PRINT_WARNING(SHOP_DEBUG) << "tried to change to an invalid/unsupported view mode: " << new_mode << std::endl; } }
void BootMode::_SetupResolutionMenu() { _resolution_menu.SetPosition(512.0f, 468.0f); _resolution_menu.SetDimensions(300.0f, 200.0f, 1, 4, 1, 4); _resolution_menu.SetTextStyle(TextStyle("title22")); _resolution_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _resolution_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _resolution_menu.SetSelectMode(VIDEO_SELECT_SINGLE); _resolution_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _resolution_menu.SetCursorOffset(-50.0f, -28.0f); _resolution_menu.SetSkipDisabled(true); _resolution_menu.AddOption(MakeUnicodeString("640 x 480"), &BootMode::_OnResolution640x480); _resolution_menu.AddOption(MakeUnicodeString("800 x 600"), &BootMode::_OnResolution800x600); _resolution_menu.AddOption(MakeUnicodeString("1024 x 768"), &BootMode::_OnResolution1024x768); _resolution_menu.AddOption(MakeUnicodeString("1280 x 1024"), &BootMode::_OnResolution1280x1024); if(VideoManager->GetScreenWidth() == 640) _resolution_menu.SetSelection(0); else if(VideoManager->GetScreenWidth() == 800) _resolution_menu.SetSelection(1); else if(VideoManager->GetScreenWidth() == 1024) _resolution_menu.SetSelection(2); else if(VideoManager->GetScreenWidth() == 1280) _resolution_menu.SetSelection(3); }
void TreasureSupervisor::Initialize(MapTreasure* treasure) { if (!treasure) { IF_PRINT_WARNING(MAP_DEBUG) << "function argument was NULL" << std::endl; return; } _treasure = treasure; MapMode::CurrentInstance()->PushState(STATE_TREASURE); // Construct the object list, including any drunes that were contained within the treasure if (_treasure->_drunes != 0) { _list_options.AddOption(MakeUnicodeString("<img/icons/drunes.png> Drunes<R>" + NumberToString(_treasure->_drunes))); _coins_snd.Play(); } else { _items_snd.Play(); } for (uint32 i = 0; i < _treasure->_objects_list.size(); i++) { if (_treasure->_objects_list[i]->GetCount() > 1) { _list_options.AddOption(MakeUnicodeString("<" + _treasure->_objects_list[i]->GetIconImage().GetFilename() + "> ") + _treasure->_objects_list[i]->GetName() + MakeUnicodeString("<R>x" + NumberToString(_treasure->_objects_list[i]->GetCount()))); } else { _list_options.AddOption(MakeUnicodeString("<" + _treasure->_objects_list[i]->GetIconImage().GetFilename() + "> ") + _treasure->_objects_list[i]->GetName()); } } for (uint32 i = 0; i < _list_options.GetNumberOptions(); i++) { _list_options.GetEmbeddedImage(i)->SetDimensions(30.0f, 30.0f); } _action_options.SetSelection(0); _action_options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE); _list_options.SetSelection(0); _list_options.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN); _selection = ACTION_SELECTED; _action_window.Show(); _list_window.Show(); // Immediately add the drunes and objects to the player's inventory GlobalManager->AddDrunes(_treasure->_drunes); for (uint32 i = 0; i < _treasure->_objects_list.size(); ++i) { GlobalObject* obj = _treasure->_objects_list[i]; if (!obj) continue; if (!GlobalManager->IsObjectInInventory(obj->GetID())) { // Pass a copy to the inventory, the treasure object will delete its content on destruction. hoa_global::GlobalObject* obj_copy = GlobalCreateNewObject(obj->GetID(), obj->GetCount()); GlobalManager->AddToInventory(obj_copy); } else { GlobalManager->IncrementObjectCount(obj->GetID(), obj->GetCount()); } } } // void TreasureSupervisor::Initialize(MapTreasure* treasure)
void TreasureSupervisor::Initialize(MapTreasure *treasure) { if(!treasure) { IF_PRINT_WARNING(MAP_DEBUG) << "function argument was nullptr" << std::endl; return; } _treasure = treasure; MapMode::CurrentInstance()->PushState(STATE_TREASURE); // Construct the object list, including any drunes that were contained within the treasure if(_treasure->_drunes != 0) { _list_options.AddOption(MakeUnicodeString("<data/inventory/drunes.png> ") + UTranslate("Drunes") + MakeUnicodeString("<R>" + NumberToString(_treasure->_drunes))); GlobalManager->Media().PlaySound("coins"); } else { GlobalManager->Media().PlaySound("item_pickup"); } for(uint32_t i = 0; i < _treasure->_items_list.size(); i++) { if(_treasure->_items_list[i]->GetCount() > 1) { _list_options.AddOption(MakeUnicodeString("<" + _treasure->_items_list[i]->GetIconImage().GetFilename() + "> ") + _treasure->_items_list[i]->GetName() + MakeUnicodeString("<R>x" + NumberToString(_treasure->_items_list[i]->GetCount()))); } else { _list_options.AddOption(MakeUnicodeString("<" + _treasure->_items_list[i]->GetIconImage().GetFilename() + "> ") + _treasure->_items_list[i]->GetName()); } } for(uint32_t i = 0; i < _list_options.GetNumberOptions(); i++) { _list_options.GetEmbeddedImage(i)->SetDimensions(30.0f, 30.0f); } _action_options.SetSelection(0); _action_options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE); _list_options.SetSelection(0); _list_options.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN); _selection = ACTION_SELECTED; _action_window.Show(); _list_window.Show(); // Immediately add the drunes and objects to the player's inventory GlobalManager->AddDrunes(_treasure->_drunes); for (uint32_t i = 0; i < _treasure->_items_list.size(); ++i) { std::shared_ptr<GlobalObject> obj = _treasure->_items_list[i]; if (!obj) continue; if (!GlobalManager->IsItemInInventory(obj->GetID())) { std::shared_ptr<vt_global::GlobalObject> obj_copy = GlobalCreateNewObject(obj->GetID(), obj->GetCount()); GlobalManager->AddToInventory(obj_copy); } else { GlobalManager->IncrementItemCount(obj->GetID(), obj->GetCount()); } } }
void GlobalObject::_LoadObjectData(hoa_script::ReadScriptDescriptor& script) { _name = MakeUnicodeString(script.ReadString("name")); _description = MakeUnicodeString(script.ReadString("description")); _price = script.ReadUInt("standard_price"); string icon_file = script.ReadString("icon"); if (_icon_image.Load(icon_file) == false) { IF_PRINT_WARNING(GLOBAL_DEBUG) << "failed to load icon image for item: " << _id << endl; _InvalidateObject(); } }
void TreasureSupervisor::_UpdateList() { if (InputManager->CancelPress() || _list_options.GetNumberOptions() == 0) { _selection = ACTION_SELECTED; _action_options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE); _list_options.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN); } else if (InputManager->ConfirmPress()) { _selection = DETAIL_SELECTED; _list_options.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN); uint32 list_selection = _list_options.GetSelection(); if (list_selection == 0 && _treasure->_drunes != 0) { // If true, the drunes have been selected _selection_name.SetText(UTranslate("Drunes")); _selection_icon = &_drunes_icon; _detail_textbox.SetDisplayText(UTranslate("With the additional ") + MakeUnicodeString(NumberToString(_treasure->_drunes)) + UTranslate(" drunes found in this treasure added, the party now holds a total of ") + MakeUnicodeString(NumberToString(GlobalManager->GetDrunes())) + MakeUnicodeString(" drunes.")); } else { // Otherwise, a GlobalObject is selected if (_treasure->_drunes != 0) list_selection--; _selection_name.SetText(_treasure->_objects_list[list_selection]->GetName()); // TODO: this is not good practice. We should probably either remove the const status from the GetIconImage() call _selection_icon = const_cast<StillImage*>(&_treasure->_objects_list[list_selection]->GetIconImage()); _detail_textbox.SetDisplayText(_treasure->_objects_list[list_selection]->GetDescription()); } } else if (InputManager->UpPress()) { if (_list_options.GetSelection() == 0) { _selection = ACTION_SELECTED; _action_options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE); _list_options.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN); } else { _list_options.InputUp(); } } else if (InputManager->DownPress()) { if (static_cast<uint32>(_list_options.GetSelection()) == (_list_options.GetNumberOptions() - 1)) { _selection = ACTION_SELECTED; _action_options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE); _list_options.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN); } else { _list_options.InputDown(); } } }
ustring UTranslate(const std::string& text) { // Don't translate an empty string as it will return the PO meta data. if (text.empty()) return ustring(); return MakeUnicodeString(Translate(text)); }
void GlobalObject::_LoadObjectData(vt_script::ReadScriptDescriptor &script) { _name = MakeUnicodeString(script.ReadString("name")); _description = MakeUnicodeString(script.ReadString("description")); _price = script.ReadUInt("standard_price"); _LoadTradeConditions(script); std::string icon_file = script.ReadString("icon"); if (script.DoesBoolExist("key_item")) _is_key_item = script.ReadBool("key_item"); if(!_icon_image.Load(icon_file)) { PRINT_WARNING << "failed to load icon image for item: " << _id << std::endl; // try a default icon in that case _icon_image.Load("img/icons/battle/default_special.png"); } }
TextImage::TextImage(const std::string &string, TextStyle style) : ImageDescriptor(), _string(MakeUnicodeString(string)), _style(style) { _Regenerate(); }
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; }
void BootMode::_RefreshJoySettings() { int32 i = 0; if(InputManager->GetJoysticksEnabled()) _joy_settings_menu.SetOptionText(i++, UTranslate("Input enabled: ") + MakeUnicodeString("<r>") + UTranslate("Yes")); else _joy_settings_menu.SetOptionText(i++, UTranslate("Input enabled: ") + MakeUnicodeString("<r>") + UTranslate("No")); _joy_settings_menu.SetOptionText(i++, UTranslate("X Axis") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetXAxisJoy()))); _joy_settings_menu.SetOptionText(i++, UTranslate("Y Axis") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetYAxisJoy()))); _joy_settings_menu.SetOptionText(i++, UTranslate("Threshold") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetThresholdJoy()))); _joy_settings_menu.SetOptionText(i++, UTranslate("Confirm: Button") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetConfirmJoy()))); _joy_settings_menu.SetOptionText(i++, UTranslate("Cancel: Button") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetCancelJoy()))); _joy_settings_menu.SetOptionText(i++, UTranslate("Menu: Button") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetMenuJoy()))); _joy_settings_menu.SetOptionText(i++, UTranslate("Pause: Button") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetPauseJoy()))); _joy_settings_menu.SetOptionText(i++, UTranslate("Quit: Button") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetQuitJoy()))); }
void Dialogue::AddLineTimed(const std::string& text, int32_t next_line, uint32_t display_time) { ++_line_count; _text.push_back(MakeUnicodeString(text)); _next_lines.push_back(next_line); _display_times.push_back(display_time); _options.push_back(nullptr); }
void Dialogue::AddLine(const std::string& text, int32_t next_line) { ++_line_count; _text.push_back(MakeUnicodeString(text)); _next_lines.push_back(next_line); _display_times.push_back(DIALOGUE_NO_TIMER); _options.push_back(nullptr); }
void MenuMode::UpdateTimeAndDrunes() { // Only update the time every 900ms _update_of_time -= (int32) vt_system::SystemManager->GetUpdateTime(); if (_update_of_time > 0) return; _update_of_time = 900; std::ostringstream os_time; uint8 hours = SystemManager->GetPlayHours(); uint8 minutes = SystemManager->GetPlayMinutes(); uint8 seconds = SystemManager->GetPlaySeconds(); os_time << (hours < 10 ? "0" : "") << static_cast<uint32>(hours) << ":"; os_time << (minutes < 10 ? "0" : "") << static_cast<uint32>(minutes) << ":"; os_time << (seconds < 10 ? "0" : "") << static_cast<uint32>(seconds); _time_text.SetDisplayText(MakeUnicodeString(os_time.str())); _drunes_text.SetDisplayText(MakeUnicodeString(NumberToString(GlobalManager->GetDrunes()))); }
void BootMode::_RefreshKeySettings() { // Update key names _key_settings_menu.SetOptionText(0, UTranslate("Move Up") + MakeUnicodeString("<r>" + InputManager->GetUpKeyName())); _key_settings_menu.SetOptionText(1, UTranslate("Move Down") + MakeUnicodeString("<r>" + InputManager->GetDownKeyName())); _key_settings_menu.SetOptionText(2, UTranslate("Move Left") + MakeUnicodeString("<r>" + InputManager->GetLeftKeyName())); _key_settings_menu.SetOptionText(3, UTranslate("Move Right") + MakeUnicodeString("<r>" + InputManager->GetRightKeyName())); _key_settings_menu.SetOptionText(4, UTranslate("Confirm") + MakeUnicodeString("<r>" + InputManager->GetConfirmKeyName())); _key_settings_menu.SetOptionText(5, UTranslate("Cancel") + MakeUnicodeString("<r>" + InputManager->GetCancelKeyName())); _key_settings_menu.SetOptionText(6, UTranslate("Menu") + MakeUnicodeString("<r>" + InputManager->GetMenuKeyName())); _key_settings_menu.SetOptionText(7, UTranslate("Pause") + MakeUnicodeString("<r>" + InputManager->GetPauseKeyName())); }
// Draw the window to the screen void SmallCharacterWindow::Draw() { // Call parent Draw method, if failed pass on fail result MenuWindow::Draw(); // check to see if this window is an actual character if(_character == NULL) return; if(_character->GetID() == vt_global::GLOBAL_CHARACTER_INVALID) return; // Get the window metrics float x, y, w, h; GetPosition(x, y); GetDimensions(w, h); // Adjust the current position to make it look better y -= 5; //Draw character portrait VideoManager->Move(x + 50, y + 110); _portrait.Draw(); // Write character name VideoManager->MoveRelative(125, -75); VideoManager->Text()->Draw(_character->GetName(), TextStyle("title22")); // Level VideoManager->MoveRelative(0, 20); VideoManager->Text()->Draw(UTranslate("Lv: ") + MakeUnicodeString(NumberToString(_character->GetExperienceLevel())), TextStyle("text20")); // HP VideoManager->MoveRelative(0, 20); VideoManager->Text()->Draw(UTranslate("HP: ") + MakeUnicodeString(NumberToString(_character->GetHitPoints()) + " / " + NumberToString(_character->GetMaxHitPoints())), TextStyle("text20")); // SP VideoManager->MoveRelative(0, 20); VideoManager->Text()->Draw(UTranslate("SP: ") + MakeUnicodeString(NumberToString(_character->GetSkillPoints()) + " / " + NumberToString(_character->GetMaxSkillPoints())), TextStyle("text20")); return; }
void MapDialogue::AddOption(string text, int32 next_line, uint32 event) { int32 current_line = _line_count - 1; // Current line that options will belong to. // If the line the options will be added to currently has no options, create a new instance of the MapDialogueOptions class to store the options in. if (_options[current_line] == NULL) { MapDialogueOptions* option = new MapDialogueOptions(); _options[current_line] = option; } _options[current_line]->AddOption(MakeUnicodeString(text), next_line, event); }
void BootMode::_RefreshVideoOptions() { // Update resolution text std::ostringstream resolution(""); resolution << VideoManager->GetScreenWidth() << " x " << VideoManager->GetScreenHeight(); _video_options_menu.SetOptionText(0, UTranslate("Resolution: ") + MakeUnicodeString(resolution.str())); // Update text on current video mode if(VideoManager->IsFullscreen()) _video_options_menu.SetOptionText(1, UTranslate("Window mode: ") + UTranslate("Fullscreen")); else _video_options_menu.SetOptionText(1, UTranslate("Window mode: ") + UTranslate("Windowed")); // Update brightness _video_options_menu.SetOptionText(2, UTranslate("Brightness: ") + MakeUnicodeString(NumberToString(VideoManager->GetGamma() * 50.0f + 0.5f) + " %")); // Update the image quality text if(VideoManager->ShouldSmoothPixelArt()) _video_options_menu.SetOptionText(3, UTranslate("Map tiles: ") + UTranslate("Smoothed")); else _video_options_menu.SetOptionText(3, UTranslate("Map tiles: ") + UTranslate("Normal")); }
void MenuMode::UpdateTimeAndDrunes() { // Only update the time every 900ms _update_of_time -= (int32) vt_system::SystemManager->GetUpdateTime(); if (_update_of_time > 0) return; _update_of_time = 900; std::ostringstream os_time; uint8 hours = SystemManager->GetPlayHours(); uint8 minutes = SystemManager->GetPlayMinutes(); uint8 seconds = SystemManager->GetPlaySeconds(); os_time << (hours < 10 ? "0" : "") << static_cast<uint32>(hours) << ":"; os_time << (minutes < 10 ? "0" : "") << static_cast<uint32>(minutes) << ":"; os_time << (seconds < 10 ? "0" : "") << static_cast<uint32>(seconds); // TODO: vt_utils::ustring should be able to take const modifiers in its operators.... static vt_utils::ustring time_ustr_base = UTranslate("Time: "); static vt_utils::ustring drunes_ustr_base = UTranslate("Drunes: "); _time_text.SetDisplayText(time_ustr_base + MakeUnicodeString(os_time.str())); _drunes_text.SetDisplayText(drunes_ustr_base + MakeUnicodeString(NumberToString(GlobalManager->GetDrunes()))); }
void TradeListDisplay::ReconstructList() { _identify_list.ClearOptions(); _property_list.ClearOptions(); for(uint32 i = 0; i < _objects.size(); ++i) { ShopObject* obj = _objects[i]; // Add an entry with the icon image of the object (scaled down by 4x to 30x30 pixels) followed by the object name _identify_list.AddOption(MakeUnicodeString("<" + obj->GetObject()->GetIconImage().GetFilename() + "><30>") + obj->GetObject()->GetName()); _identify_list.GetEmbeddedImage(i)->SetDimensions(30.0f, 30.0f); _property_list.AddOption(MakeUnicodeString(NumberToString(obj->GetTradePrice()))); _property_list.AddOption(MakeUnicodeString("×" + NumberToString(obj->GetStockCount()))); uint32 own_count = GlobalManager->HowManyObjectsInInventory(obj->GetObject()->GetID()); _property_list.AddOption(MakeUnicodeString("×" + NumberToString(own_count))); } if(_objects.empty() == false) { _identify_list.SetSelection(0); _property_list.SetSelection(0); } }
void DialogueSupervisor::ChangeSpeakerName(uint32 id, const std::string& name) { std::map<uint32, BattleSpeaker>::iterator speaker = _speakers.find(id); if (speaker == _speakers.end()) { IF_PRINT_WARNING(BATTLE_DEBUG) << "no speaker found with requested id: " << id << std::endl; return; } speaker->second.name = MakeUnicodeString(name); if (_current_dialogue != NULL) { if (_current_dialogue->GetLineSpeaker(_line_counter) == id) { _dialogue_window.GetNameText().SetText(speaker->second.name); } } }
void MapDialogue::AddText(std::string text, uint32 speaker_id, int32 next_line, uint32 event, bool display_timer) { _text.push_back(MakeUnicodeString(text)); _speakers.push_back(speaker_id); _next_lines.push_back(next_line); _options.push_back(NULL); _events.push_back(event); _line_count++; if (display_timer == true) { // TODO: replace 5000 with a function call that will calculate the display time based on text length and player's speed setting _display_times.push_back(5000); } else { _display_times.push_back(-1); } }
void DialogueSupervisor::AddCustomSpeaker(uint32 id, string name, string portrait) { if (_speakers.find(id) != _speakers.end()) { IF_PRINT_WARNING(BATTLE_DEBUG) << "speaker already existed with requsted id: " << id << endl; return; } BattleSpeaker new_speaker; new_speaker.name = MakeUnicodeString(name); if (portrait != "") { if (new_speaker.portrait.Load(portrait) == false) { IF_PRINT_WARNING(BATTLE_DEBUG) << "invalid image filename for new portrait: " << portrait << endl; } } _speakers[id] = new_speaker; }
void DialogueSupervisor::ChangeSpeakerName(const std::string& speaker_id, const std::string& name) { std::map<std::string, Speaker>::iterator it = _speakers.find(speaker_id); if(it == _speakers.end()) { PRINT_WARNING << "No speaker found with requested id: " << speaker_id << std::endl; return; } it->second.name = MakeUnicodeString(name); if(_current_dialogue != nullptr) { if(_current_dialogue->GetLineSpeaker(_line_counter) == speaker_id) { _dialogue_window.GetNameText().SetText(it->second.name); } } }
void CreditsWindow::Show() { _active = true; _window.Show(); _scroll_offset = 0.0f; if (_loaded == true) return; // Load the credits text from the Lua file ReadScriptDescriptor credits_file; if (credits_file.OpenFile("dat/credits.lua") == false) { IF_PRINT_WARNING(BOOT_DEBUG) << "failed to open the Lua credits file" << endl; } _credits_text.SetText(MakeUnicodeString(credits_file.ReadString("credits_text"))); credits_file.CloseFile(); _loaded = true; }
void DialogueSupervisor::AddCustomSpeaker(uint32 id, const std::string& name, const std::string& portrait) { if (_speakers.find(id) != _speakers.end()) { IF_PRINT_WARNING(BATTLE_DEBUG) << "speaker already existed with requsted id: " << id << std::endl; return; } BattleSpeaker new_speaker; new_speaker.name = MakeUnicodeString(name); if (!portrait.empty()) { if (!new_speaker.portrait.Load(portrait)) { IF_PRINT_WARNING(BATTLE_DEBUG) << "invalid image filename for new portrait: " << portrait << std::endl; } // Make sure the portrait doesn't go over the screen edge. if (new_speaker.portrait.GetHeight() > 130.0f) new_speaker.portrait.SetHeightKeepRatio(130.0f); } _speakers[id] = new_speaker; }
void BootMode::_SetupLanguageOptionsMenu() { _language_options_menu.SetPosition(512.0f, 468.0f); _language_options_menu.SetTextStyle(TextStyle("title22")); _language_options_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _language_options_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _language_options_menu.SetSelectMode(VIDEO_SELECT_SINGLE); _language_options_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _language_options_menu.SetCursorOffset(-50.0f, -28.0f); _language_options_menu.SetSkipDisabled(true); // Get the list of languages from the Lua file. ReadScriptDescriptor read_data; if(!read_data.OpenFile(_LANGUAGE_FILE)) { PRINT_ERROR << "Failed to load language file: " << _LANGUAGE_FILE << std::endl; PRINT_ERROR << "The language list will be empty." << std::endl; return; } read_data.OpenTable("languages"); uint32 table_size = read_data.GetTableSize(); // Set up the dimensions of the window according to how many languages are available. _language_options_menu.SetDimensions(300.0f, 200.0f, 1, table_size, 1, table_size); _po_files.clear(); for(uint32 i = 1; i <= table_size; i++) { read_data.OpenTable(i); _po_files.push_back(read_data.ReadString(2)); _language_options_menu.AddOption(MakeUnicodeString(read_data.ReadString(1)), &BootMode::_OnLanguageSelect); read_data.CloseTable(); } read_data.CloseTable(); if(read_data.IsErrorDetected()) PRINT_ERROR << "Error occurred while loading language list: " << read_data.GetErrorMessages() << std::endl; read_data.CloseFile(); }
BootMode::BootMode() : GameMode(MODE_MANAGER_BOOT_MODE), _boot_state(BOOT_STATE_INTRO), _exiting_to_new_game(false), _new_game_called(false), _menu_handler(this), _menu_bar_alpha(0.0f), _help_text_alpha(0.0f) { _current_instance = this; #ifdef DEBUG_FEATURES _debug_script_menu_open = false; // List the debug scripts _debug_scripts = vt_utils::ListDirectory("data/debug", ".lua"); _debug_script_menu.SetPosition(512.0f, 128.0f); _debug_script_menu.SetTextStyle(TextStyle("text24")); _debug_script_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _debug_script_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _debug_script_menu.SetSelectMode(VIDEO_SELECT_SINGLE); _debug_script_menu.SetHorizontalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _debug_script_menu.SetCursorOffset(-50.0f, -28.0f); _debug_script_menu.SetSkipDisabled(true); _debug_script_menu.ClearOptions(); float debug_win_height = 20.0f * static_cast<float>(_debug_scripts.size()); _debug_script_menu.SetDimensions(300.0f, debug_win_height > 600.0f ? 600.0f : debug_win_height, 1, 255, 1, _debug_scripts.size()); for (std::string file : _debug_scripts) _debug_script_menu.AddOption(vt_utils::MakeUnicodeString(file)); // Create the debug window used as background _debug_scripts_window.Create(400.0f, 550.0f); _debug_scripts_window.SetPosition(310.0f, 58.0f); _debug_scripts_window.Hide(); #endif // Remove potential previous ambient overlays VideoManager->DisableFadeEffect(); // Note: Not translated on purpose. _version_text.SetStyle(TextStyle("text18")); std::string version_string = "Version 1.0.0 - Development version"; // NOTE: Only leave the " - " part for releases. version_string.append(" - "); version_string.append(__DATE__); _version_text.SetText(MakeUnicodeString(version_string)); // Get rid of the old table to make sure no old data is used. ScriptManager->DropGlobalTable("boot"); // Test the existence and validity of the boot script. ReadScriptDescriptor boot_script; if(!boot_script.OpenFile("data/boot_menu/boot.lua")) { PRINT_ERROR << "Failed to load boot data file" << std::endl; SystemManager->ExitGame(); return; } // Open the boot table spacename if(boot_script.OpenTablespace().empty()) { PRINT_ERROR << "The boot script file has not set a correct tablespace" << std::endl; SystemManager->ExitGame(); return; } boot_script.CloseTable(); // The namespace boot_script.CloseFile(); // Trigger the Initialize functions in the scene script component GetScriptSupervisor().AddScript("data/boot_menu/boot.lua"); GetScriptSupervisor().Initialize(this); // Load the menu bar and the help text _menu_bar.Load("data/gui/battle/battle_bottom_menu.png", 1024, 128); _SetupMainMenu(); _f1_help_text.SetStyle(TextStyle("text18")); // The timer that will be used to display the menu bar and the help text _boot_timer.Initialize(14000); _boot_timer.EnableManualUpdate(); _boot_timer.Run(); // Preload new game sound AudioManager->LoadSound("data/sounds/new_game.wav", this); }
void BootMode::_RefreshAudioOptions() { _audio_options_menu.SetOptionText(0, UTranslate("Sound Volume: ") + MakeUnicodeString(NumberToString(static_cast<int32>(AudioManager->GetSoundVolume() * 100.0f + 0.5f)) + " %")); _audio_options_menu.SetOptionText(1, UTranslate("Music Volume: ") + MakeUnicodeString(NumberToString(static_cast<int32>(AudioManager->GetMusicVolume() * 100.0f + 0.5f)) + " %")); }