# HG changeset patch # User sbr # Date 1375042890 -7200 # Sun Jul 28 22:21:30 2013 +0200 # Node ID 3c74e9f9b3f8e66e13fdc3c202732963b1965010 # Parent 8127c5e6272cfa417d7a63e66b6f5bad12223e89 -Feature (devel): Add an option to switch text direction between LTR and RTL without changing the current language. OpenTTD support both LTR and RTL languages. In order to tests the GUI in RTL mode, it's necessary to switch to a language in that direction like Arabic or Hebrew. However testing the GUI in a language we don't understand isn't really convenient. This patch allow to switch the text-direction without changing the current language. If the 'gui.developer' setting is set in openttd.cfg, a new entry 'Toggle text direction' is added to the Help dropdown in the main toolbar. diff --git a/src/lang/english.txt b/src/lang/english.txt --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -467,6 +467,7 @@ STR_ABOUT_MENU_ABOUT_OPENTTD STR_ABOUT_MENU_SPRITE_ALIGNER :Sprite aligner STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Toggle bounding boxes STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :Toggle colouring of dirty blocks +STR_HELP_MENU_TOGGLE_TEXT_DIRECTION :Toggle text direction ############ range ends here ############ range for days starts (also used for the place in the highscore window) diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -1031,6 +1031,7 @@ enum HelpMenuEntries { HME_SPRITE_ALIGNER, HME_TOGGLE_BOUNDING_BOXES, HME_TOGGLE_DIRTY_BLOCKS, + HME_TOGGLE_TEXT_DIRECTION, }; static CallBackFunction ToolbarHelpClick(Window *w) @@ -1050,6 +1051,9 @@ static CallBackFunction ToolbarHelpClick list->push_back(new DropDownListStringItem(STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES, HME_TOGGLE_BOUNDING_BOXES, false)); list->push_back(new DropDownListStringItem(STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS, HME_TOGGLE_DIRTY_BLOCKS, false)); } + if (_settings_client.gui.developer) { + list->push_back(new DropDownListStringItem(STR_HELP_MENU_TOGGLE_TEXT_DIRECTION, HME_TOGGLE_TEXT_DIRECTION, false)); + } ShowDropDownList(w, list, 0, WID_TN_HELP, 140, true, true); return CBF_NONE; @@ -1126,6 +1130,23 @@ void ToggleDirtyBlocks() } /** + * Toggle the text direction. + * @note has only effect when \c developer setting is set. + * + * \c ReInit() is called for all windows to redraw them in the new text direction. + */ +void ToggleTextDirection() +{ + if (_settings_client.gui.developer) { + _current_text_dir = (_current_text_dir == TD_LTR) ? TD_RTL : TD_LTR; + Window *w; + FOR_ALL_WINDOWS_FROM_BACK(w) { + w->ReInit(); + } + } +} + +/** * Choose the proper callback function for the main toolbar's help menu. * @param index The menu index which was selected. * @return CBF_NONE @@ -1144,6 +1165,7 @@ static CallBackFunction MenuClickHelp(in case HME_SPRITE_ALIGNER: ShowSpriteAlignerWindow(); break; case HME_TOGGLE_BOUNDING_BOXES: ToggleBoundingBoxes(); break; case HME_TOGGLE_DIRTY_BLOCKS: ToggleDirtyBlocks(); break; + case HME_TOGGLE_TEXT_DIRECTION: ToggleTextDirection(); break; } return CBF_NONE; }