wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth data/themes/editor.cfg src/hotkeys.cpp ...


From: Bram Ridder
Subject: [Wesnoth-cvs-commits] wesnoth data/themes/editor.cfg src/hotkeys.cpp ...
Date: Sat, 17 Sep 2005 10:01:49 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Bram Ridder <address@hidden>    05/09/17 14:01:49

Modified files:
        data/themes    : editor.cfg 
        src            : hotkeys.cpp hotkeys.hpp 
        src/editor     : editor.cpp editor.hpp 

Log message:
        First attempt to fix bug #11966, it is now possible to change the 
language in the
        editor by pressing alt-l. The only problem are the menu buttons, they 
will only
        show the right language after a restart. I'm not sure if it'll be fixed 
before
        the 1.0 release...propably not.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/data/themes/editor.cfg.diff?tr1=1.38&tr2=1.39&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/hotkeys.cpp.diff?tr1=1.81&tr2=1.82&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/hotkeys.hpp.diff?tr1=1.62&tr2=1.63&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/editor/editor.cpp.diff?tr1=1.114&tr2=1.115&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/editor/editor.hpp.diff?tr1=1.48&tr2=1.49&r1=text&r2=text

Patches:
Index: wesnoth/data/themes/editor.cfg
diff -u wesnoth/data/themes/editor.cfg:1.38 wesnoth/data/themes/editor.cfg:1.39
--- wesnoth/data/themes/editor.cfg:1.38 Wed Jul 20 06:51:01 2005
+++ wesnoth/data/themes/editor.cfg      Sat Sep 17 14:01:48 2005
@@ -212,6 +212,14 @@
         shift=no
         [/hotkey]
 
+       [hotkey]
+       command="changelanguage"
+       key="l"
+       cmd=no
+       alt=yes
+       shift=no
+       [/hotkey]
+
 #else
        [hotkey]
        command="zoomin"
@@ -410,6 +418,14 @@
        key="e"
        ctrl=yes
        alt=no
+       shift=no
+       [/hotkey]
+
+       [hotkey]
+       command="changelanguage"
+       key="l"
+       ctrl=no
+       alt=yes
        shift=no
        [/hotkey]
 #endif
Index: wesnoth/src/editor/editor.cpp
diff -u wesnoth/src/editor/editor.cpp:1.114 wesnoth/src/editor/editor.cpp:1.115
--- wesnoth/src/editor/editor.cpp:1.114 Tue Sep  6 14:00:05 2005
+++ wesnoth/src/editor/editor.cpp       Sat Sep 17 14:01:49 2005
@@ -21,6 +21,7 @@
 #include "../game_config.hpp"
 #include "../gettext.hpp"
 #include "../key.hpp"
+#include "../language.hpp"
 #include "../widgets/menu.hpp"
 #include "../pathfind.hpp"
 #include "../playlevel.hpp"
@@ -42,6 +43,7 @@
 #include <cctype>
 #include <iostream>
 #include <map>
+#include <vector>
 #include <string>
 #include <cmath>
 
@@ -155,7 +157,7 @@
                std::string text = "";
 
                const std::vector<std::string> &menu_items = (*it).items();
-       if (menu_items.size() == 1) {
+               if (menu_items.size() == 1) {
                        if(menu_items.back() == "editdraw")
                                text = _("Draw tiles");
                        else if(menu_items.back() == "editfloodfill")
@@ -357,6 +359,39 @@
        }
 }
 
+// Set the language...
+void map_editor::change_language() {
+       std::vector<language_def> langdefs = get_languages();
+
+       // this only works because get_languages() returns a fresh vector at 
each calls
+       // unless show_gui cleans the "*" flag
+       const std::vector<language_def>::iterator current = 
std::find(langdefs.begin(),langdefs.end(),get_language());
+       if(current != langdefs.end()) {
+               (*current).language = "*" + (*current).language;
+       }
+
+       // prepare a copy with just the labels for the list to be displayed
+       std::vector<std::string> langs;
+       langs.reserve(langdefs.size());
+       
std::transform(langdefs.begin(),langdefs.end(),std::back_inserter(langs),languagedef_name);
+
+       const int res = gui::show_dialog(gui_,NULL,_("Language"),
+                                _("Choose your preferred language:"),
+                                gui::OK_CANCEL,&langs);
+       if(size_t(res) < langs.size()) {
+               ::set_language(known_languages[res]);
+               preferences::set_language(known_languages[res].localename);
+
+               game_config_.reset_translation();
+
+               // Reload tooltips and menu items
+               load_tooltips();
+       }
+
+       font::load_font_config();
+       hotkey::load_descriptions();
+}
+
 
 void map_editor::edit_save_as() {
        const std::string default_dir =
@@ -698,6 +733,7 @@
        case hotkey::HOTKEY_EDIT_SELECT_ALL:
        case hotkey::HOTKEY_EDIT_DRAW:
        case hotkey::HOTKEY_EDIT_REFRESH:
+       case hotkey::HOTKEY_LANGUAGE:
                return true;
        default:
                return false;
Index: wesnoth/src/editor/editor.hpp
diff -u wesnoth/src/editor/editor.hpp:1.48 wesnoth/src/editor/editor.hpp:1.49
--- wesnoth/src/editor/editor.hpp:1.48  Wed Jul 20 08:22:37 2005
+++ wesnoth/src/editor/editor.hpp       Sat Sep 17 14:01:49 2005
@@ -91,6 +91,9 @@
        /// Recalculate layout and redraw everything.
        void redraw_everything();
 
+       // Change the language in_game
+       virtual void change_language();
+
        // Methods inherited from command_executor. Used to perform
        // operations on menu/hotkey commands.
        virtual void toggle_grid();
Index: wesnoth/src/hotkeys.cpp
diff -u wesnoth/src/hotkeys.cpp:1.81 wesnoth/src/hotkeys.cpp:1.82
--- wesnoth/src/hotkeys.cpp:1.81        Wed Jul 20 17:18:13 2005
+++ wesnoth/src/hotkeys.cpp     Sat Sep 17 14:01:49 2005
@@ -1,4 +1,4 @@
-/* $Id: hotkeys.cpp,v 1.81 2005/07/20 17:18:13 ott Exp $ */
+/* $Id: hotkeys.cpp,v 1.82 2005/09/17 14:01:49 morloth Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -107,6 +107,8 @@
        { hotkey::HOTKEY_CHAT_LOG, "chatlog", N_("View Chat Log"), false },
        { hotkey::HOTKEY_USER_CMD, "command", N_("Enter user command"), false },
 
+       { hotkey::HOTKEY_LANGUAGE, "changelanguage", N_("Change language"), 
true },
+
        { hotkey::HOTKEY_NULL, NULL, NULL, true }
 };
 
@@ -643,6 +645,10 @@
                 case HOTKEY_EDIT_REFRESH:
                        if(executor)
                                executor->edit_refresh();
+                       break;
+                case HOTKEY_LANGUAGE:
+                       if(executor)
+                               executor->change_language();
                        break;
                default:
                        std::cerr << "command_executor: unknown command number 
" << command << ", ignoring.\n";
Index: wesnoth/src/hotkeys.hpp
diff -u wesnoth/src/hotkeys.hpp:1.62 wesnoth/src/hotkeys.hpp:1.63
--- wesnoth/src/hotkeys.hpp:1.62        Sat Jul  2 21:37:19 2005
+++ wesnoth/src/hotkeys.hpp     Sat Sep 17 14:01:49 2005
@@ -1,4 +1,4 @@
-/* $Id: hotkeys.hpp,v 1.62 2005/07/02 21:37:19 ott Exp $ */
+/* $Id: hotkeys.hpp,v 1.63 2005/09/17 14:01:49 morloth Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -41,7 +41,7 @@
        HOTKEY_LABEL_TERRAIN, HOTKEY_SHOW_ENEMY_MOVES, HOTKEY_BEST_ENEMY_MOVES,
        HOTKEY_DELAY_SHROUD, HOTKEY_UPDATE_SHROUD, HOTKEY_CONTINUE_MOVE,
        HOTKEY_SEARCH, HOTKEY_SPEAK_ALLY, HOTKEY_SPEAK_ALL, HOTKEY_HELP,
-       HOTKEY_CHAT_LOG,
+       HOTKEY_CHAT_LOG, HOTKEY_LANGUAGE,
 
        //editing specific commands
        HOTKEY_EDIT_SET_TERRAIN,
@@ -162,6 +162,7 @@
        virtual void show_help() {}
        virtual void show_chat_log() {}
        virtual void user_command() {}
+       virtual void change_language() {}
 
        // Map editor stuff.
        virtual void edit_set_terrain() {}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]