]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Apply the selected language, restarting the menu, only if it's different from the...
authorterencehill <piuntn@gmail.com>
Mon, 3 Mar 2014 22:12:08 +0000 (23:12 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 3 Mar 2014 22:12:08 +0000 (23:12 +0100)
qcsrc/menu/classes.c
qcsrc/menu/xonotic/dialog_firstrun.c
qcsrc/menu/xonotic/dialog_settings_user_languagewarning.c [new file with mode: 0644]
qcsrc/menu/xonotic/languagelist.c
qcsrc/menu/xonotic/mainwindow.c

index 1de86b6474fe51e529d809a0eeeb69bd9738e572..ff1210c74780fe2d6a512854a75723748c60ba13 100644 (file)
@@ -35,6 +35,7 @@
 #include "xonotic/dialog_settings_effects.c"
 #include "xonotic/dialog_settings_audio.c"
 #include "xonotic/dialog_settings_user.c"
+#include "xonotic/dialog_settings_user_languagewarning.c"
 #include "xonotic/dialog_settings_misc.c"
 #include "xonotic/dialog_multiplayer.c"
 #include "xonotic/dialog_multiplayer_playersetup.c"
index 01ce7ba4347edba58ea9fc77a97f5d4d11dd2c86..1b975da2b188c8fd27098897d5553fc1d80b3245 100644 (file)
@@ -29,6 +29,12 @@ float CheckFirstRunButton(entity me)
        return 0;
 }
 
+void firstRun_setLanguage(entity me)
+{
+       if(prvm_language != cvar_string("_menu_prvm_language"))
+               localcmd("\nprvm_language \"$_menu_prvm_language\"; saveconfig; menu_restart\n");
+}
+
 void XonoticFirstRunDialog_fill(entity me)
 {
        entity e;
@@ -69,7 +75,7 @@ void XonoticFirstRunDialog_fill(entity me)
        me.TR(me);
                me.TD(me, 6, 2, e = makeXonoticLanguageList());
                        e.name = "languageselector_firstrun";
-                       e.doubleClickCommand = "prvm_language \"$_menu_prvm_language\"; saveconfig; menu_restart";
+                       e.setLanguage = firstRun_setLanguage;
        me.TR(me);
        me.TR(me);
 
diff --git a/qcsrc/menu/xonotic/dialog_settings_user_languagewarning.c b/qcsrc/menu/xonotic/dialog_settings_user_languagewarning.c
new file mode 100644 (file)
index 0000000..c830b55
--- /dev/null
@@ -0,0 +1,26 @@
+#ifdef INTERFACE
+CLASS(XonoticLanguageWarningDialog) EXTENDS(XonoticDialog)
+       METHOD(XonoticLanguageWarningDialog, fill, void(entity)) // to be overridden by user to fill the dialog with controls
+       ATTRIB(XonoticLanguageWarningDialog, title, string, _("Warning"))
+       ATTRIB(XonoticLanguageWarningDialog, color, vector, SKINCOLOR_DIALOG_HUDCONFIRM)
+       ATTRIB(XonoticLanguageWarningDialog, intendedWidth, float, 0.6)
+       ATTRIB(XonoticLanguageWarningDialog, rows, float, 5)
+       ATTRIB(XonoticLanguageWarningDialog, columns, float, 4)
+ENDCLASS(XonoticLanguageWarningDialog)
+#endif
+
+#ifdef IMPLEMENTATION
+void XonoticLanguageWarningDialog_fill(entity me)
+{
+       entity e;
+       me.TR(me);
+               me.TD(me, 1, 4, e = makeXonoticTextLabel(0, _("While connected language changes will be applied only to the menu,")));
+       me.TR(me);
+               me.TD(me, 1, 4, e = makeXonoticTextLabel(0, _("full language changes will take effect starting from the next game")));
+       me.TR(me);
+       me.TR(me);
+               // reconnect command doesn't work properly, otherwise it would replace disconnect
+               me.TD(me, 1, 2, e = makeXonoticCommandButton(_("Disconnect now"), '0 0 0', "disconnect", 0));
+               me.TD(me, 1, 2, e = makeXonoticCommandButton(_("Switch language"), '0 0 0', "prvm_language \"$_menu_prvm_language\"; menu_restart; menu_cmd languageselect", 0));
+}
+#endif
index 5be639a07559ec27058539e8c838b3526f8e8d43..6e18506db8e22fe7979bef9285ad2d8bb7d91271 100644 (file)
@@ -26,8 +26,6 @@ CLASS(XonoticLanguageList) EXTENDS(XonoticListBox)
        METHOD(XonoticLanguageList, languageParameter, string(entity, float, float))
 
        ATTRIB(XonoticLanguageList, name, string, "languageselector") // change this to make it noninteractive (for first run dialog)
-
-       ATTRIB(XonoticLanguageList, doubleClickCommand, string, "prvm_language \"$_menu_prvm_language\"\nmenu_restart\nmenu_cmd languageselect")
 ENDCLASS(XonoticLanguageList)
 
 entity makeXonoticLanguageList();
@@ -172,7 +170,13 @@ void XonoticLanguageList_getLanguages(entity me)
 
 void XonoticLanguageList_setLanguage(entity me)
 {
-       localcmd(sprintf("\n%s\n", me.doubleClickCommand));
+       if(prvm_language != cvar_string("_menu_prvm_language"))
+       {
+               if(!(gamestatus & GAME_CONNECTED))
+                       localcmd("\nprvm_language \"$_menu_prvm_language\"; menu_restart; menu_cmd languageselect\n");
+               else
+                       DialogOpenButton_Click(me, main.languageWarningDialog);
+       }
 }
 
 string XonoticLanguageList_languageParameter(entity me, float i, float key)
index 72cecea19cfce5ce4e9627e2adcad594eb79fa93..debe6bd975c0f5dcfe3fde58b185c595363358fe 100644 (file)
@@ -16,6 +16,7 @@ CLASS(MainWindow) EXTENDS(ModalController)
        ATTRIB(MainWindow, crosshairDialog, entity, NULL)
        ATTRIB(MainWindow, hudDialog, entity, NULL)
        ATTRIB(MainWindow, hudconfirmDialog, entity, NULL)
+       ATTRIB(MainWindow, languageWarningDialog, entity, NULL)
        ATTRIB(MainWindow, mainNexposee, entity, NULL)
        ATTRIB(MainWindow, fadedAlpha, float, SKINALPHA_BEHIND)
        ATTRIB(MainWindow, dialogToShow, entity, NULL)
@@ -135,6 +136,10 @@ void MainWindow_configureMainWindow(entity me)
        i.configureDialog(i);
        me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
 
+       me.languageWarningDialog = i = spawnXonoticLanguageWarningDialog();
+       i.configureDialog(i);
+       me.addItemCentered(me, i, i.intendedWidth * eX + i.intendedHeight * eY, SKINALPHAS_MAINMENU_z);
+
 
        // dialog used by singleplayer
        me.winnerDialog = i = spawnXonoticWinnerDialog();