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")); }
TradeInterface::TradeInterface() : _view_mode(SHOP_VIEW_MODE_INVALID), _selected_object(NULL), _trade_deal_types(0), _current_category(0) { _category_header.SetStyle(TextStyle("title24")); _category_header.SetText(UTranslate("Category")); _name_header.SetStyle(TextStyle("title24")); _name_header.SetText(UTranslate("Name")); _properties_header.SetDimensions(300.0f, 30.0f, 3, 1, 3, 1); _properties_header.SetOptionAlignment(VIDEO_X_RIGHT, VIDEO_Y_CENTER); _properties_header.SetTextStyle(TextStyle("title24")); _properties_header.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN); _properties_header.AddOption(UTranslate("Price")); _properties_header.AddOption(UTranslate("Stock")); _properties_header.AddOption(UTranslate("Own")); _selected_name.SetStyle(TextStyle("text22")); _selected_properties.SetOwner(ShopMode::CurrentInstance()->GetBottomWindow()); _selected_properties.SetPosition(480.0f, 70.0f); _selected_properties.SetDimensions(300.0f, 30.0f, 3, 1, 3, 1); _selected_properties.SetOptionAlignment(VIDEO_X_RIGHT, VIDEO_Y_CENTER); _selected_properties.SetTextStyle(TextStyle("text22")); _selected_properties.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN); _selected_properties.AddOption(ustring()); _selected_properties.AddOption(ustring()); _selected_properties.AddOption(ustring()); }
BattleMenu::BattleMenu(): _explanation_window(vt_utils::ustring(), -1.0f, 650.0f, 750.0f, 100.0f), _auto_battle_active(false), _open(false) { _window.Create(WINDOW_SIZE_X, WINDOW_SIZE_Y); _window.SetPosition(WINDOW_POS_X, WINDOW_POS_Y); _window.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); _window.Show(); _options_list.SetPosition(OPTION_LIST_POS_X, OPTION_LIST_POS_Y); _options_list.SetDimensions(WINDOW_SIZE_X - 25.0f, WINDOW_SIZE_Y - 25.0f, 3, 2, 3, 2); _options_list.SetTextStyle(TextStyle("text22")); _options_list.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _options_list.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _options_list.SetSelectMode(VIDEO_SELECT_SINGLE); _options_list.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _options_list.SetSkipDisabled(true); _options_list.SetCursorState(vt_gui::VIDEO_CURSOR_STATE_HIDDEN); _options_selected_list.SetPosition(OPTION_LIST_POS_X - 35.0f, OPTION_LIST_POS_Y); _options_selected_list.SetDimensions(WINDOW_SIZE_X - 25.0f, WINDOW_SIZE_Y - 25.0f, 3, 2, 3, 2); _options_selected_list.SetTextStyle(TextStyle("text22")); _options_selected_list.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _options_selected_list.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _options_selected_list.SetSelectMode(VIDEO_SELECT_SINGLE); _options_selected_list.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _options_selected_list.SetCursorOffset(-52.0f, -28.0f); _options_selected_list.SetSkipDisabled(true); _options_selected_list.SetCursorState(vt_gui::VIDEO_CURSOR_STATE_VISIBLE); _explanation_window.SetDisplaySpeed(vt_system::SystemManager->GetMessageSpeed()); _RefreshOptions(); }
DialogueWindow::DialogueWindow() { if (_parchment_image.Load("img/menus/black_sleet_parch.png") == false) cerr << "MAP ERROR: failed to load image: " << _parchment_image.GetFilename() << endl; if (_nameplate_image.Load("img/menus/dialogue_nameplate.png") == false) cerr << "MAP ERROR: failed to load image: " << _nameplate_image.GetFilename() << endl; VideoManager->PushState(); VideoManager->SetCoordSys(0, 1024, 768, 0); _display_textbox.SetDisplaySpeed(30); _display_textbox.SetPosition(260.0f, 596.0f); _display_textbox.SetDimensions(700.0f, 126.0f); _display_textbox.SetTextStyle(TextStyle("text20", Color::black, VIDEO_TEXT_SHADOW_LIGHT)); _display_textbox.SetDisplayMode(VIDEO_TEXT_FADECHAR); _display_textbox.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); _display_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); _display_options.SetPosition(300.0f, 630.0f); _display_options.SetDimensions(660.0f, 90.0f, 1, 255, 1, 3); _display_options.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _display_options.SetTextStyle(TextStyle("title20", Color::black, VIDEO_TEXT_SHADOW_LIGHT)); _display_options.SetSelectMode(VIDEO_SELECT_SINGLE); _display_options.SetCursorOffset(-55.0f, -25.0f); _display_options.SetVerticalWrapMode(VIDEO_WRAP_MODE_NONE); _display_options.SetSelection(0); VideoManager->PopState(); }
PauseMode::PauseMode(bool quit_state, bool pause_audio) : GameMode(MODE_MANAGER_PAUSE_MODE), _quit_state(quit_state), _audio_paused(pause_audio), _music_volume(1.0f), _dim_color(0.35f, 0.35f, 0.35f, 1.0f), // A grayish opaque color _option_selected(false), _options_handler(this) { // Save a copy of the current screen to use as the backdrop. try { _screen_capture = VideoManager->CaptureScreen(); } catch (const Exception &e) { IF_PRINT_WARNING(PAUSE_DEBUG) << e.ToString() << std::endl; } // Render the paused string in white text _paused_text.SetStyle(TextStyle("title28", Color::white, VIDEO_TEXT_SHADOW_BLACK)); _paused_text.SetText(UTranslate("Paused")); // Initialize the quit options box _quit_options.SetPosition(512.0f, 384.0f); _quit_options.SetDimensions(220.0f, 300.0f, 1, 4, 1, 4); _quit_options.SetTextStyle(TextStyle("title24", Color::white, VIDEO_TEXT_SHADOW_BLACK)); _quit_options.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _quit_options.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _quit_options.SetSelectMode(VIDEO_SELECT_SINGLE); _quit_options.SetCursorOffset(-58.0f, -18.0f); _SetupOptions(); }
TextStyle styleFromName(const char *name) { for (int i = 0; i < C_LAST_STYLE_SENTINEL; ++i) { if (qstrcmp(name, nameForStyle(TextStyle(i))) == 0) return TextStyle(i); } return C_LAST_STYLE_SENTINEL; }
TreasureSupervisor::TreasureSupervisor() : _treasure(nullptr), _selection(ACTION_SELECTED), _window_title(UTranslate("You obtain"), TextStyle("title24", Color::white, VIDEO_TEXT_SHADOW_DARK, 1, -2)), _selection_name(), _selection_icon(nullptr), _is_key_item(false) { // Create the menu windows and option boxes used for the treasure menu and // align them at the appropriate locations on the screen _action_window.Create(768.0f, 64.0f, ~VIDEO_MENU_EDGE_BOTTOM); _action_window.SetPosition(512.0f, 460.0f); _action_window.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_TOP); _list_window.Create(768.0f, 236.0f); _list_window.SetPosition(512.0f, 516.0f); _list_window.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_TOP); _action_options.SetPosition(30.0f, 18.0f); _action_options.SetDimensions(726.0f, 32.0f, 1, 1, 1, 1); _action_options.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); _action_options.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _action_options.SetHorizontalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _action_options.SetSelectMode(VIDEO_SELECT_SINGLE); _action_options.SetCursorOffset(-50.0f, -25.0f); _action_options.SetTextStyle(TextStyle("title22", Color::white, VIDEO_TEXT_SHADOW_DARK, 1, -2)); _action_options.AddOption(UTranslate("Ok")); _action_options.SetSelection(0); _action_options.SetOwner(&_action_window); _list_options.SetPosition(20.0f, 20.0f); _list_options.SetDimensions(726.0f, 200.0f, 1, 255, 1, 5); _list_options.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); _list_options.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _list_options.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _list_options.SetSelectMode(VIDEO_SELECT_SINGLE); _list_options.SetCursorOffset(-50.0f, -25.0f); _list_options.SetTextStyle(TextStyle("text22", Color::white, VIDEO_TEXT_SHADOW_DARK, 1, -2)); _list_options.SetOwner(&_list_window); _detail_textbox.SetPosition(20.0f, 90.0f); _detail_textbox.SetDimensions(726.0f, 128.0f); _detail_textbox.SetDisplaySpeed(SystemManager->GetMessageSpeed()); _detail_textbox.SetTextStyle(TextStyle("text22", Color::white, VIDEO_TEXT_SHADOW_DARK, 1, -2)); _detail_textbox.SetDisplayMode(VIDEO_TEXT_REVEAL); _detail_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); _detail_textbox.SetOwner(&_list_window); _selection_name.SetStyle(TextStyle("text22", Color::white, VIDEO_TEXT_SHADOW_DARK, 1, -2)); } // TreasureSupervisor::TreasureSupervisor()
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 DialogueWindow::Draw(ustring* name, StillImage* portrait) { // MenuWindow::Draw(); // Temporarily change the coordinate system to 1024x768 and draw the contents of the dialogue window VideoManager->PushState(); VideoManager->SetCoordSys(0.0f, 1024.0f, 768.0f, 0.0f); VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0); VideoManager->Move(18.0f, 744.0f); _parchment_image.Draw(); // VideoManager->Move(47.0f, 726.0f); // if (name != NULL) // _nameplate_image.Draw(); VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_BOTTOM, 0); VideoManager->MoveRelative(120.0f, -20.0f); if (name != NULL) VideoManager->Text()->Draw(*name, TextStyle("title22", Color::black, VIDEO_TEXT_SHADOW_LIGHT)); if (portrait != NULL) { VideoManager->MoveRelative(0.0f, -20.0f); portrait->Draw(); } _display_textbox.Draw(); _display_options.Draw(); VideoManager->PopState(); }
void BootMode::_SetupJoySettingsMenu() { _joy_settings_menu.ClearOptions(); _joy_settings_menu.SetPosition(512.0f, 468.0f); _joy_settings_menu.SetDimensions(250.0f, 500.0f, 1, 9, 1, 9); _joy_settings_menu.SetTextStyle(TextStyle("title22")); _joy_settings_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _joy_settings_menu.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _joy_settings_menu.SetSelectMode(VIDEO_SELECT_SINGLE); _joy_settings_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _joy_settings_menu.SetCursorOffset(-50.0f, -28.0f); _joy_settings_menu.SetSkipDisabled(true); ustring dummy; _joy_settings_menu.AddOption(dummy, &BootMode::_OnToggleJoystickEnabled, NULL, NULL, &BootMode::_OnToggleJoystickEnabled, &BootMode::_OnToggleJoystickEnabled); _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineXAxisJoy); _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineYAxisJoy); _joy_settings_menu.AddOption(dummy, NULL, NULL, NULL, &BootMode::_OnThresholdJoyLeft, &BootMode::_OnThresholdJoyRight); _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineConfirmJoy); _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineCancelJoy); _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineMenuJoy); _joy_settings_menu.AddOption(dummy, &BootMode::_RedefinePauseJoy); _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineQuitJoy); _joy_settings_menu.AddOption(UTranslate("Restore defaults"), &BootMode::_OnRestoreDefaultJoyButtons); }
void VideoEngine::DrawFPS() { if(!_fps_display) return; uint32 frame_time = vt_system::SystemManager->GetUpdateTime(); SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, VIDEO_X_NOFLIP, VIDEO_Y_NOFLIP, VIDEO_BLEND, 0); // Calculate the FPS for the current frame uint32 current_fps = 1000; if(frame_time) { current_fps /= frame_time; } // The number of times to insert the current FPS sample into the fps_samples array uint32 number_insertions; if(_number_samples == 0) { // If the FPS display is uninitialized, set the entire FPS array to the current FPS _number_samples = FPS_SAMPLES; number_insertions = FPS_SAMPLES; } else if(current_fps >= 500) { // If the game is going at 500 fps or faster, 1 insertion is enough number_insertions = 1; } else { // Find if there's a discrepancy between the current frame time and the averaged one. // If there's a large difference, add extra samples so the FPS display "catches up" more quickly. float avg_frame_time = 1000.0f * FPS_SAMPLES / _fps_sum; int32 time_difference = static_cast<int32>(avg_frame_time) - static_cast<int32>(frame_time); if(time_difference < 0) time_difference = -time_difference; if(time_difference <= static_cast<int32>(MAX_FTIME_DIFF)) number_insertions = 1; else number_insertions = FPS_CATCHUP; // Take more samples to catch up to the current FPS } // Insert the current_fps samples into the fps_samples array for the number of times specified for(uint32 j = 0; j < number_insertions; j++) { _fps_sum -= _fps_samples[_current_sample]; _fps_sum += current_fps; _fps_samples[_current_sample] = current_fps; _current_sample = (_current_sample + 1) % FPS_SAMPLES; } uint32 avg_fps = _fps_sum / FPS_SAMPLES; // The text to display to the screen char fps_text[16]; sprintf(fps_text, "FPS: %d", avg_fps); Move(930.0f, 720.0f); // Upper right hand corner of the screen Text()->Draw(fps_text, TextStyle("text20", Color::white)); } // void GUISystem::_DrawFPS(uint32 frame_time)
RootInterface::RootInterface() { // Initialize text properties and set default text where appropriate _shop_name.SetStyle(TextStyle("title28")); _shop_name.SetText(UTranslate("Shop Name")); // This default name should be overwritten _buy_price_text.SetStyle(TextStyle("text22")); _buy_price_text.SetText(UTranslate("Buy prices")); _sell_price_text.SetStyle(TextStyle("text22")); _sell_price_text.SetText(UTranslate("Sell prices")); _greeting_text.SetOwner(ShopMode::CurrentInstance()->GetBottomWindow()); _greeting_text.SetPosition(40.0f, 100.0f); _greeting_text.SetDimensions(600.0f, 50.0f); _greeting_text.SetTextStyle(TextStyle("text22")); _greeting_text.SetDisplayMode(VIDEO_TEXT_INSTANT); _greeting_text.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); _greeting_text.SetDisplayText(UTranslate("\"Welcome! Take a look around.\"")); // Default greeting, should usually be overwritten }
DialogueWindow::DialogueWindow() : _pos_x(512.0f), _pos_y(512.0f), _indicator_symbol(DIALOGUE_NO_INDICATOR), _blink_time(0), _blink_state(true), _portrait_image(nullptr) { //TODO: Makes this part of the themes if(_parchment_image.Load("data/gui/black_sleet_parch.png") == false) PRINT_ERROR << "failed to load dialogue image: " << _parchment_image.GetFilename() << std::endl; if(_nameplate_image.Load("data/gui/dialogue_nameplate.png") == false) PRINT_ERROR << "failed to load dialogue image: " << _nameplate_image.GetFilename() << std::endl; if(_next_line_image.Load("data/gui/dialogue_cont_arrow.png") == false) PRINT_ERROR << "failed to load dialogue image: " << _next_line_image.GetFilename() << std::endl; if(_last_line_image.Load("data/gui/dialogue_last_ind.png") == false) PRINT_ERROR << "failed to load dialogue image: " << _last_line_image.GetFilename() << std::endl; VideoManager->PushState(); VideoManager->SetStandardCoordSys(); _display_textbox.SetDisplaySpeed(SystemManager->GetMessageSpeed()); _display_textbox.SetPosition(260.0f, 596.0f); _display_textbox.SetDimensions(640.0f, 126.0f); _display_textbox.SetTextStyle(TextStyle("text20", Color::black, VIDEO_TEXT_SHADOW_LIGHT)); _display_textbox.SetDisplayMode(VIDEO_TEXT_FADECHAR); _display_textbox.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _display_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); _display_optionbox.SetPosition(300.0f, 630.0f); _display_optionbox.SetDimensions(640.0f, 90.0f, 1, 255, 1, 4); _display_optionbox.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _display_optionbox.SetTextStyle(TextStyle("title20", Color::black, VIDEO_TEXT_SHADOW_LIGHT)); _display_optionbox.SetSelectMode(VIDEO_SELECT_SINGLE); _display_optionbox.SetCursorOffset(-55.0f, -25.0f); _display_optionbox.SetVerticalWrapMode(VIDEO_WRAP_MODE_NONE); _name_text.SetStyle(TextStyle("title22", Color::black, VIDEO_TEXT_SHADOW_LIGHT)); VideoManager->PopState(); }
WorldMapState::WorldMapState(MenuMode *menu_mode): AbstractMenuState("WorldMapState", menu_mode), _location_image(NULL) { _location_text.SetPosition(102, 556); _location_text.SetDimensions(500.0f, 50.0f); _location_text.SetTextStyle(TextStyle("title22")); _location_text.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); }
// 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() == hoa_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; }
//! \brief Functions that initialize the numerous option boxes static void SetupOptionBoxCommonSettings(OptionBox *ob) { // Set all the default options ob->SetTextStyle(TextStyle("title22")); ob->SetPosition(142.0f, 85.0f); ob->SetDimensions(115.0f, 50.0f, 1, 1, 1, 1); ob->SetAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); ob->SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); ob->SetSelectMode(VIDEO_SELECT_SINGLE); ob->SetHorizontalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); ob->SetCursorOffset(-52.0f, -20.0f); }
ObjectListDisplay::ObjectListDisplay() { _identify_list.SetOwner(ShopMode::CurrentInstance()->GetMiddleWindow()); _identify_list.SetPosition(180.0f, 330.0f); _identify_list.SetDimensions(300.0f, 300.0f, 1, 255, 1, 8); _identify_list.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _identify_list.SetTextStyle(TextStyle("text22")); _identify_list.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE); _identify_list.SetSelectMode(VIDEO_SELECT_SINGLE); _identify_list.SetCursorOffset(-50.0f, 20.0f); _identify_list.SetHorizontalWrapMode(VIDEO_WRAP_MODE_NONE); _identify_list.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _property_list.SetOwner(ShopMode::CurrentInstance()->GetMiddleWindow()); _property_list.SetPosition(480.0f, 330.0f); _property_list.SetDimensions(300.0f, 300.0f, 4, 255, 4, 8); _property_list.SetOptionAlignment(VIDEO_X_RIGHT, VIDEO_Y_CENTER); _property_list.SetTextStyle(TextStyle("text22")); _property_list.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN); _property_list.SetHorizontalWrapMode(VIDEO_WRAP_MODE_NONE); _property_list.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); }
CreditsWindow::CreditsWindow() : _active(false), _loaded(false), _scroll_offset(0.0f) { _window.Create(880.0f, 640.0f); _window.SetPosition(512.0f, 384.0f); _window.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _window.SetDisplayMode(VIDEO_MENU_EXPAND_FROM_CENTER); _credits_text.SetStyle(TextStyle("text22")); }
ObjectCategoryDisplay::ObjectCategoryDisplay() : _view_mode(SHOP_VIEW_MODE_LIST), _selected_object(NULL), _current_icon(NULL), _last_icon(NULL), _object_icon(NULL) { _name_text.SetStyle(TextStyle("text22")); _name_textbox.SetOwner(ShopMode::CurrentInstance()->GetMiddleWindow()); _name_textbox.SetPosition(25.0f, 175.0f); _name_textbox.SetDimensions(125.0f, 30.0f); _name_textbox.SetTextStyle(TextStyle("text22")); _name_textbox.SetDisplayMode(VIDEO_TEXT_FADECHAR); _name_textbox.SetDisplaySpeed(TRANSITION_TIME_TEXT); _name_textbox.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); // TODO: Alignment should be VIDEO_X_CENTER, but a bug is preventing it from working correctly right now _name_textbox.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); _transition_timer.Initialize(TRANSITION_TIME_ICON, SYSTEM_TIMER_NO_LOOPS); _transition_timer.EnableAutoUpdate(ShopMode::CurrentInstance()); }
void BootMode::_SetupAudioOptionsMenu() { _audio_options_menu.ClearOptions(); _audio_options_menu.SetPosition(512.0f, 468.0f); _audio_options_menu.SetDimensions(300.0f, 200.0f, 1, 2, 1, 2); _audio_options_menu.SetTextStyle(TextStyle("title22")); _audio_options_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _audio_options_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _audio_options_menu.SetSelectMode(VIDEO_SELECT_SINGLE); _audio_options_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _audio_options_menu.SetCursorOffset(-50.0f, -28.0f); _audio_options_menu.SetSkipDisabled(true); _audio_options_menu.AddOption(UTranslate("Sound Volume: "), NULL, NULL, NULL, &BootMode::_OnSoundLeft, &BootMode::_OnSoundRight); _audio_options_menu.AddOption(UTranslate("Music Volume: "), NULL, NULL, NULL, &BootMode::_OnMusicLeft, &BootMode::_OnMusicRight); _audio_options_menu.SetSelection(0); }
void BootMode::_SetupVideoOptionsMenu() { _video_options_menu.ClearOptions(); _video_options_menu.SetPosition(512.0f, 468.0f); _video_options_menu.SetDimensions(300.0f, 400.0f, 1, 4, 1, 4); _video_options_menu.SetTextStyle(TextStyle("title22")); _video_options_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _video_options_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _video_options_menu.SetSelectMode(VIDEO_SELECT_SINGLE); _video_options_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _video_options_menu.SetCursorOffset(-50.0f, -28.0f); _video_options_menu.SetSkipDisabled(true); _video_options_menu.AddOption(UTranslate("Resolution:"), &BootMode::_OnResolution); // Left & right will change window mode as well as confirm _video_options_menu.AddOption(UTranslate("Window mode:"), &BootMode::_OnToggleFullscreen, NULL, NULL, &BootMode::_OnToggleFullscreen, &BootMode::_OnToggleFullscreen); _video_options_menu.AddOption(UTranslate("Brightness:"), NULL, NULL, NULL, &BootMode::_OnBrightnessLeft, &BootMode::_OnBrightnessRight); _video_options_menu.AddOption(UTranslate("Map tiles: "), &BootMode::_OnTogglePixelArtSmoothed, NULL, NULL, &BootMode::_OnTogglePixelArtSmoothed, &BootMode::_OnTogglePixelArtSmoothed); _video_options_menu.SetSelection(0); }
void BootMode::_SetupOptionsMenu() { _options_menu.ClearOptions(); _options_menu.SetPosition(512.0f, 468.0f); _options_menu.SetDimensions(300.0f, 600.0f, 1, 5, 1, 5); _options_menu.SetTextStyle(TextStyle("title22")); _options_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _options_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _options_menu.SetSelectMode(VIDEO_SELECT_SINGLE); _options_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _options_menu.SetCursorOffset(-50.0f, -28.0f); _options_menu.SetSkipDisabled(true); _options_menu.AddOption(UTranslate("Video"), &BootMode::_OnVideoOptions); _options_menu.AddOption(UTranslate("Audio"), &BootMode::_OnAudioOptions); _options_menu.AddOption(UTranslate("Language"), &BootMode::_OnLanguageOptions); _options_menu.AddOption(UTranslate("Key Settings"), &BootMode::_OnKeySettings); _options_menu.AddOption(UTranslate("Joystick Settings"), &BootMode::_OnJoySettings); _options_menu.SetSelection(0); }
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(); }
void BootMode::_SetupMainMenu() { _main_menu.ClearOptions(); _main_menu.SetPosition(512.0f, 688.0f); _main_menu.SetTextStyle(TextStyle("title24")); _main_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _main_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _main_menu.SetSelectMode(VIDEO_SELECT_SINGLE); _main_menu.SetHorizontalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _main_menu.SetCursorOffset(-50.0f, -28.0f); _main_menu.SetSkipDisabled(true); _main_menu.AddOption(UTranslate("New Game"), &BootMode::_OnNewGame); _main_menu.AddOption(UTranslate("Load Game"), &BootMode::_OnLoadGame); _main_menu.AddOption(UTranslate("Options"), &BootMode::_OnOptions); // Insert the debug options #ifdef DEBUG_FEATURES _main_menu.SetDimensions(1000.0f, 50.0f, 7, 1, 7, 1); _main_menu.AddOption(UTranslate("Battle"), &BootMode::_DEBUG_OnBattle); _main_menu.AddOption(UTranslate("Menu"), &BootMode::_DEBUG_OnMenu); _main_menu.AddOption(UTranslate("Shop"), &BootMode::_DEBUG_OnShop); #else _main_menu.SetDimensions(800.0f, 50.0f, 4, 1, 4, 1); #endif _main_menu.AddOption(UTranslate("Quit"), &BootMode::_OnQuit); if(!_SavesAvailable()) { _main_menu.EnableOption(1, false); _main_menu.SetSelection(0); } else { _main_menu.SetSelection(1); } _f1_help_text.SetText(VTranslate("Press '%s' to get to know about the game keys.", InputManager->GetHelpKeyName())); }
void BootMode::_SetupKeySettingsMenu() { _key_settings_menu.ClearOptions(); _key_settings_menu.SetPosition(512.0f, 468.0f); _key_settings_menu.SetDimensions(250.0f, 500.0f, 1, 8, 1, 8); _key_settings_menu.SetTextStyle(TextStyle("title22")); _key_settings_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _key_settings_menu.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER); _key_settings_menu.SetSelectMode(VIDEO_SELECT_SINGLE); _key_settings_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _key_settings_menu.SetCursorOffset(-50.0f, -28.0f); _key_settings_menu.SetSkipDisabled(true); _key_settings_menu.AddOption(UTranslate("Up: "), &BootMode::_RedefineUpKey); _key_settings_menu.AddOption(UTranslate("Down: "), &BootMode::_RedefineDownKey); _key_settings_menu.AddOption(UTranslate("Left: "), &BootMode::_RedefineLeftKey); _key_settings_menu.AddOption(UTranslate("Right: "), &BootMode::_RedefineRightKey); _key_settings_menu.AddOption(UTranslate("Confirm: "), &BootMode::_RedefineConfirmKey); _key_settings_menu.AddOption(UTranslate("Cancel: "), &BootMode::_RedefineCancelKey); _key_settings_menu.AddOption(UTranslate("Menu: "), &BootMode::_RedefineMenuKey); _key_settings_menu.AddOption(UTranslate("Pause: "), &BootMode::_RedefinePauseKey); _key_settings_menu.AddOption(UTranslate("Restore defaults"), &BootMode::_OnRestoreDefaultKeys); }
void BootMode::_SetupMainMenu() { _main_menu.ClearOptions(); _main_menu.SetPosition(512.0f, 688.0f); _main_menu.SetTextStyle(TextStyle("title24")); _main_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _main_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _main_menu.SetSelectMode(VIDEO_SELECT_SINGLE); _main_menu.SetHorizontalWrapMode(VIDEO_WRAP_MODE_STRAIGHT); _main_menu.SetCursorOffset(-50.0f, -28.0f); _main_menu.SetSkipDisabled(true); _main_menu.AddOption(UTranslate("New Game")); _main_menu.AddOption(UTranslate("Load Game")); _main_menu.AddOption(UTranslate("Options")); // Insert the debug options #ifdef DEBUG_FEATURES _main_menu.SetDimensions(1000.0f, 50.0f, 5, 1, 5, 1); _main_menu.AddOption(vt_utils::MakeUnicodeString("Debug scripts")); if (_debug_scripts.empty()) _main_menu.EnableOption(3, false); #else _main_menu.SetDimensions(800.0f, 50.0f, 4, 1, 4, 1); #endif _main_menu.AddOption(UTranslate("Quit")); if(_GetNbSavesAvailable() == 0) { _main_menu.EnableOption(1, false); _main_menu.SetSelection(0); } else { _main_menu.SetSelection(1); } _f1_help_text.SetText(VTranslate("Press '%s' to get to know about the game keys.", InputManager->GetHelpKeyName())); }
BootMode::BootMode() : _boot_state(BOOT_STATE_INTRO), _exiting_to_new_game(false), _has_modified_settings(false), _first_run(false), _key_setting_function(NULL), _joy_setting_function(NULL), _joy_axis_setting_function(NULL), _message_window(ustring(), 210.0f, 733.0f), _menu_bar_alpha(0.0f), _help_text_alpha(0.0f) { // Remove potential previous ambient overlays VideoManager->DisableFadeEffect(); IF_PRINT_DEBUG(BOOT_DEBUG) << "BootMode constructor invoked" << std::endl; mode_type = MODE_MANAGER_BOOT_MODE; // Note: Not translated on purpose. _version_text.SetStyle(TextStyle("text18")); std::string version_string = "Development Release - "; 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("dat/config/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("dat/config/boot.lua"); GetScriptSupervisor().Initialize(this); _options_window.Create(300.0f, 550.0f); _options_window.SetPosition(360.0f, 188.0f); _options_window.SetDisplayMode(VIDEO_MENU_INSTANT); _options_window.Hide(); // Setup all boot menu options and properties _SetupMainMenu(); _SetupOptionsMenu(); _SetupVideoOptionsMenu(); _SetupAudioOptionsMenu(); _SetupLanguageOptionsMenu(); _SetupKeySettingsMenu(); _SetupJoySettingsMenu(); _SetupResolutionMenu(); _active_menu = &_main_menu; // make sure message window is not visible _message_window.Hide(); // Load the menu bar and the help text _menu_bar.Load("img/menus/battle_bottom_menu.png", 1024, 128); _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 test sound AudioManager->LoadSound("snd/volume_test.wav", this); // Preload main sounds AudioManager->LoadSound("snd/confirm.wav", this); AudioManager->LoadSound("snd/cancel.wav", this); AudioManager->LoadSound("snd/bump.wav", this); AudioManager->LoadSound("snd/new_game.wav", this); } // BootMode::BootMode()
WelcomeWindow::WelcomeWindow() : _active(false) { _window.Create(880.0f, 640.0f); _window.SetPosition(512.0f, 384.0f); _window.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER); _text_header.SetStyle(TextStyle("text20")); _text_header.SetText(UTranslate("The table below lists the default game controls.\n") + UTranslate("The control mappings can be changed in the options menu on the next screen.")); _key_table_header.SetOwner(&_window); _key_table_header.SetPosition(50.0f, 540.0f); _key_table_header.SetDimensions(600.0f, 30.0f, 3, 1, 3, 1); _key_table_header.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); _key_table_header.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); _key_table_header.SetTextStyle(TextStyle("title24")); _key_table_header.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN); _key_table_header.AddOption(UTranslate("Command")); _key_table_header.AddOption(UTranslate("Default Key")); _key_table_header.AddOption(UTranslate("General Purpose")); _key_table.SetOwner(&_window); _key_table.SetPosition(50.0f, 500.0f); _key_table.SetDimensions(600.0f, 380.0f, 3, 12, 3, 12); _key_table.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); _key_table.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP); _key_table.SetTextStyle(TextStyle("text22")); _key_table.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN); _key_table.AddOption(UTranslate("Up")); _key_table.AddOption(UTranslate("Up Arrow")); _key_table.AddOption(UTranslate("Move position or cursor upwards")); _key_table.AddOption(UTranslate("Down")); _key_table.AddOption(UTranslate("Down Arrow")); _key_table.AddOption(UTranslate("Move position or cursor downwards")); _key_table.AddOption(UTranslate("Left")); _key_table.AddOption(UTranslate("Left Arrow")); _key_table.AddOption(UTranslate("Move position or cursor to the left")); _key_table.AddOption(UTranslate("Right")); _key_table.AddOption(UTranslate("Right Arrow")); _key_table.AddOption(UTranslate("Move position or cursor to the right")); _key_table.AddOption(UTranslate("Confirm")); _key_table.AddOption(UTranslate("F")); _key_table.AddOption(UTranslate("Confirm an action or menu command")); _key_table.AddOption(UTranslate("Cancel")); _key_table.AddOption(UTranslate("D")); _key_table.AddOption(UTranslate("Cancel an action or menu command")); _key_table.AddOption(UTranslate("Menu")); _key_table.AddOption(UTranslate("S")); _key_table.AddOption(UTranslate("Display the character menu")); _key_table.AddOption(UTranslate("Swap")); _key_table.AddOption(UTranslate("A")); _key_table.AddOption(UTranslate("Swaps active menu or character")); _key_table.AddOption(UTranslate("Left Select")); _key_table.AddOption(UTranslate("W")); _key_table.AddOption(UTranslate("Select multiple or backward page scroll")); _key_table.AddOption(UTranslate("Right Select")); _key_table.AddOption(UTranslate("E")); _key_table.AddOption(UTranslate("Select multiple or forward page scroll")); _key_table.AddOption(UTranslate("Pause")); _key_table.AddOption(UTranslate("Spacebar")); _key_table.AddOption(UTranslate("Pauses the game")); _key_table.AddOption(UTranslate("Quit")); _key_table.AddOption(UTranslate("Esc")); _key_table.AddOption(UTranslate("Quit the application")); _text_additional.SetStyle(TextStyle("text20")); _text_additional.SetText(UTranslate("There are additional commands available which can be found in the MANUAL file.")); _text_continue.SetStyle(TextStyle("title24")); _text_continue.SetText(UTranslate("Press F1 to continue.")); } // WelcomeWindow::WelcomeWindow()
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); }
string Driver::GetNextTextElement(string& text,TextStyle& style,int& w,int& h,int maxwidth) { size_t n=0; string ret; if(text=="") return ""; // Return blank space as is. while(n < text.length() && IsSpace(text[n]) && text[n]!='\n') n++; if(n) { } // Get a tag if found. else if(text[0]=='{') { while(n < text.length()) if(text[n]=='}') { n++; break; } else n++; } // Cut from the next word break. else { while(n < text.length()) if(text[n]=='.' || text[n]==',' || text[n]==';' || text[n]==':' || text[n]=='!' || text[n]=='?' || text[n]=='\n' || text[n]=='-' || text[n]=='/') { n++; break; } else if(text[n]=='{' || IsSpace(text[n])) break; else n++; } // Extract the next element from the text. if(n==text.length()) { ret=text; text=""; } else { ret=text.substr(0,n); text=text.substr(n); } w=0; h=0; // Compute the size for normal text. if(ret[0]!='{') { w=TextWidth(style.font,style.pointsize,ret); // Shorten the word if it does not fit. while(w > maxwidth && ret.length()) { w-=TextWidth(style.font,style.pointsize,ret.substr(ret.length()-1,1)); text=ret.substr(ret.length()-1,1)+text; ret=ret.substr(0,ret.length()-1); } h=TextHeight(style.font,style.pointsize,ret); } // Compute the size for tags. else if(ret=="{|}") { w=3; h=TextHeight(style.font,style.pointsize,"|"); } else if(ret=="{hr}") { w=w-2*style.margin; h=1; } else if(ret=="{lb}") { w=TextWidth(style.font,style.pointsize,"{"); h=TextHeight(style.font,style.pointsize,"{"); } else if(ret=="{rb}") { w=TextWidth(style.font,style.pointsize,"}"); h=TextHeight(style.font,style.pointsize,"}"); } else if(inlineimage.find(ret)!=inlineimage.end()) { w=ImageWidth(inlineimage[ret]); h=ImageHeight(inlineimage[ret]); } else if(ret.substr(0,3)=="{sz" && ret.substr(ret.length()-1,1)=="}") { int sz=atoi(ret.substr(3,ret.length()-4).c_str()); if(sz < 6) sz=6; else if(sz > 255) sz=255; style.pointsize=sz; } else if(ret.substr(0,5)=="{font" && ret.substr(ret.length()-1,1)=="}") { int n=atoi(ret.substr(5,ret.length()-6).c_str()); if(n < 0) n=0; else if(n > 6) n=6; style.font=n; } else if(ret.substr(0,5)=="{card" && ret.substr(ret.length()-1,1)=="}") { int n=atoi(ret.substr(5,ret.length()-6).c_str()); string name="_unknown_"; if(n >= 0 && n < Database::cards.Cards()) name=Database::cards.Name(n); w=TextWidth(style.font,style.pointsize,name); h=TextHeight(style.font,style.pointsize,name); } else if(ret=="{red}") style.color=RED; else if(ret=="{green}") style.color=GREEN; else if(ret=="{black}") style.color=BLACK; else if(ret=="{blue}") style.color=BLUE; else if(ret=="{yellow}") style.color=YELLOW; else if(ret=="{white}") style.color=WHITE; else if(ret=="{brown}") style.color=Color(149,79,29); else if(ret=="{gold}") style.color=Color(205,173,0); else if(ret=="{gray}") style.color=Color(77,77,77); else if(ret=="{magenta}") style.color=Color(205,0,205); else if(ret=="{orange}") style.color=Color(255,127,0); else if(ret=="{cyan}") style.color=Color(4,197,204); else if(ret=="{shadow}") style.shadow=true; else if(ret=="{noshadow}") style.shadow=false; else if(ret=="{reset}") { bool old=style.shadow; style=TextStyle(); style.shadow=old; } else { int r=atoi(ret.substr(1).c_str()); int g=-1; int b=-1; if(r>0 || ret.substr(1,2)=="0,") { for(size_t n=0; n < ret.length(); n++) { if(ret[n]==',') { n++; g=atoi(ret.substr(n).c_str()); for(; n < ret.length(); n++) if(ret[n]==',') { b=atoi(ret.substr(n+1).c_str()); break; } break; } } if(r>=0 && g>=0 && b>=0 && r<256 && g<256 && b<256) { style.color.r=r; style.color.g=g; style.color.b=b; } } } return ret; }