]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/menu_optimization
authorterencehill <piuntn@gmail.com>
Thu, 24 Dec 2015 00:46:46 +0000 (01:46 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 24 Dec 2015 00:46:46 +0000 (01:46 +0100)
qcsrc/menu/item/container.qc
qcsrc/menu/item/listbox.qc
qcsrc/menu/xonotic/cvarlist.qc
qcsrc/menu/xonotic/demolist.qc
qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc
qcsrc/menu/xonotic/dialog_settings_misc_cvars.qc
qcsrc/menu/xonotic/dialog_teamselect.qc
qcsrc/menu/xonotic/keybinder.qc
qcsrc/menu/xonotic/playermodel.qc
qcsrc/menu/xonotic/screenshotlist.qc
qcsrc/menu/xonotic/soundlist.qc

index 23857dcead1d04e0089347114c32dd07733889f5..17412cd0fbffef4e4c7c73a131b627d56c4cfa6b 100644 (file)
                other.parent = me;
                other.Container_origin = theOrigin;
                other.Container_size = theSize;
-               me.setAlphaOf(me, other, theAlpha);
+
+               // don't call setAlphaOf, it would uneccessarily trigger showNotify
+               //me.setAlphaOf(me, other, theAlpha);
+               other.Container_alpha = theAlpha;
 
                entity l;
                l = me.lastChild;
index 7f303fda7a17b2b891776d008ab8fe9ab56b574a..d6ea7d85958d7f994d1231e5ccd34cd5506921ee 100644 (file)
@@ -43,7 +43,7 @@
                ATTRIB(ListBox, colorF, vector, '1 1 1')
                ATTRIB(ListBox, tolerance, vector, '0 0 0') // drag tolerance
                ATTRIB(ListBox, scrollbarWidth, float, 0)   // pixels
-               ATTRIB(ListBox, nItems, float, 42)
+               ATTRIB(ListBox, nItems, float, 42) // FIXME: why?!?
                ATTRIB(ListBox, itemHeight, float, 0)
                ATTRIB(ListBox, colorBG, vector, '0 0 0')
                ATTRIB(ListBox, alphaBG, float, 0)
index 8323221daf8fe7c948290f6a749ebadc409cb1ba..11e88a4e688a6b92cb075c6f11c58419b5023c6d 100644 (file)
@@ -7,6 +7,7 @@ CLASS(XonoticCvarList, XonoticListBox)
        METHOD(XonoticCvarList, drawListBoxItem, void(entity, int, vector, bool, bool));
        METHOD(XonoticCvarList, resizeNotify, void(entity, vector, vector, vector, vector));
        METHOD(XonoticCvarList, keyDown, float(entity, float, float, float));
+       METHOD(XonoticCvarList, showNotify, void(entity));
 
        METHOD(XonoticCvarList, destroy, void(entity));
 
@@ -53,10 +54,18 @@ entity makeXonoticCvarList()
 void XonoticCvarList_configureXonoticCvarList(entity me)
 {
        me.configureXonoticListBox(me);
-
        me.handle = buf_create();
+       me.nItems = 0;
+}
+void XonoticCvarList_showNotify(entity me)
+{
+       bool force_initial_selection = false;
+       if(me.handle >= 0 && me.nItems <= 0) // me.handle not loaded yet?
+               force_initial_selection = true;
        buf_cvarlist(me.handle, "", "_");
        me.nItems = buf_getsize(me.handle);
+       if(force_initial_selection)
+               me.setSelected(me, 0);
 }
 void XonoticCvarList_destroy(entity me)
 {
@@ -151,8 +160,6 @@ void XonoticCvarList_resizeNotify(entity me, vector relOrigin, vector relSize, v
        me.columnValueSize = me.realFontSize.x * 20;
        me.columnNameSize = 1 - me.columnValueSize - me.realFontSize.x;
        me.columnValueOrigin = me.columnNameOrigin + me.columnNameSize + me.realFontSize.x;
-
-       me.setSelected(me, me.selectedItem);
 }
 void XonoticCvarList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
 {
index 2459d7ca1e9b932f04f909f1307c4954b763c982..9f8978c14b1159e7d589fb23ed7c2d561a0be8e0 100644 (file)
@@ -48,7 +48,7 @@ entity makeXonoticDemoList()
 void XonoticDemoList_configureXonoticDemoList(entity me)
 {
        me.configureXonoticListBox(me);
-       me.getDemos(me);
+       me.nItems = 0;
 }
 
 string XonoticDemoList_demoName(entity me, float i)
index e45e9595f0dab1624789b376588320237521f965..c136f901d77e4c683b195ed041413d32701d2e9a 100644 (file)
@@ -20,6 +20,7 @@ ENDCLASS(XonoticMutatorsDialog)
 #ifdef IMPLEMENTATION
 void XonoticMutatorsDialog_showNotify(entity me)
 {
+       SUPER(XonoticMutatorsDialog).showNotify(me);
        loadAllCvars(me);
 }
 
index 6ace10c1241b9cef599e3f49050f12546c84b729..8a2d489a0b9717dddd1f5f5570017c9958d1fed9 100644 (file)
@@ -15,6 +15,7 @@ ENDCLASS(XonoticCvarsDialog)
 #ifdef IMPLEMENTATION
 void XonoticCvarsDialog_showNotify(entity me)
 {
+       SUPER(XonoticCvarsDialog).showNotify(me);
        loadAllCvars(me);
 }
 void XonoticCvarsDialog_fill(entity me) // in this dialog, use SKINCOLOR_CVARLIST_CONTROLS to color ALL controls
index 3b624e2ad0bda58ed7e1c39a053569fd02d06327..9185a1f6ea15f825caeed300e5f0e0bb63238cca 100644 (file)
@@ -32,6 +32,7 @@ entity makeTeamButton(string theName, vector theColor, string commandtheName)
 
 void XonoticTeamSelectDialog_showNotify(entity me)
 {
+       SUPER(XonoticTeamSelectDialog).showNotify(me);
        float teams, nTeams;
        teams = cvar("_teams_available");
        nTeams = 0;
index 4f1c74e8156eba07a6e78ccf7637c185d39b3171..9ce18c6b0a97357bc97e28b7fcefdb897d605ed5 100644 (file)
@@ -7,9 +7,11 @@ CLASS(XonoticKeyBinder, XonoticListBox)
        METHOD(XonoticKeyBinder, drawListBoxItem, void(entity, int, vector, bool, bool));
        METHOD(XonoticKeyBinder, doubleClickListBoxItem, void(entity, float, vector));
        METHOD(XonoticKeyBinder, resizeNotify, void(entity, vector, vector, vector, vector));
+       METHOD(XonoticKeyBinder, showNotify, void(entity));
        METHOD(XonoticKeyBinder, setSelected, void(entity, float));
        METHOD(XonoticKeyBinder, keyDown, float(entity, float, float, float));
        METHOD(XonoticKeyBinder, keyGrabbed, void(entity, float, float));
+       METHOD(XonoticKeyBinder, destroy, void(entity));
 
        ATTRIB(XonoticKeyBinder, realFontSize, vector, '0 0 0')
        ATTRIB(XonoticKeyBinder, realUpperMargin, float, 0)
@@ -18,6 +20,7 @@ CLASS(XonoticKeyBinder, XonoticListBox)
        ATTRIB(XonoticKeyBinder, columnKeysOrigin, float, 0)
        ATTRIB(XonoticKeyBinder, columnKeysSize, float, 0)
 
+       METHOD(XonoticKeyBinder, loadKeyBinds, void(entity));
        ATTRIB(XonoticKeyBinder, previouslySelected, int, -1)
        ATTRIB(XonoticKeyBinder, inMouseHandler, float, 0)
        ATTRIB(XonoticKeyBinder, userbindEditButton, entity, NULL)
@@ -165,10 +168,7 @@ void replace_bind(string from, string to)
 void XonoticKeyBinder_configureXonoticKeyBinder(entity me)
 {
        me.configureXonoticListBox(me);
-       if(Xonotic_KeyBinds_Count < 0)
-               Xonotic_KeyBinds_Read();
-       me.nItems = Xonotic_KeyBinds_Count;
-       me.setSelected(me, 0);
+       me.nItems = 0;
 
        // TEMP: Xonotic 0.1 to later
        replace_bind("impulse 1", "weapon_group_1");
@@ -182,6 +182,21 @@ void XonoticKeyBinder_configureXonoticKeyBinder(entity me)
        replace_bind("impulse 9", "weapon_group_9");
        replace_bind("impulse 14", "weapon_group_0");
 }
+void XonoticKeyBinder_loadKeyBinds(entity me)
+{
+       bool force_initial_selection = false;
+       if(Xonotic_KeyBinds_Count < 0) // me.handle not loaded yet?
+               force_initial_selection = true;
+       Xonotic_KeyBinds_Read();
+       me.nItems = Xonotic_KeyBinds_Count;
+       if(force_initial_selection)
+               me.setSelected(me, 0);
+}
+void XonoticKeyBinder_showNotify(entity me)
+{
+       me.destroy(me);
+       me.loadKeyBinds(me);
+}
 void XonoticKeyBinder_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
 {
        SUPER(XonoticKeyBinder).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
@@ -194,9 +209,6 @@ void XonoticKeyBinder_resizeNotify(entity me, vector relOrigin, vector relSize,
        me.columnKeysSize = me.realFontSize.x * 12;
        me.columnFunctionSize = 1 - me.columnKeysSize - 2 * me.realFontSize.x;
        me.columnKeysOrigin = me.columnFunctionOrigin + me.columnFunctionSize + me.realFontSize.x;
-
-       if(me.userbindEditButton)
-               me.userbindEditButton.disabled = (substring(Xonotic_KeyBinds_Descriptions[me.selectedItem], 0, 1) != "$");
 }
 void KeyBinder_Bind_Change(entity btn, entity me)
 {
@@ -256,6 +268,22 @@ void XonoticKeyBinder_keyGrabbed(entity me, int key, bool ascii)
        localcmd("-zoom\n"); // to make sure we aren't in togglezoom'd state
        cvar_set("_hud_showbinds_reload", "1");
 }
+void XonoticKeyBinder_destroy(entity me)
+{
+       if(Xonotic_KeyBinds_Count < 0)
+               return;
+
+       for(int i = 0; i < MAX_KEYBINDS; ++i)
+       {
+               if(Xonotic_KeyBinds_Functions[i])
+                       strunzone(Xonotic_KeyBinds_Functions[i]);
+               Xonotic_KeyBinds_Functions[i] = string_null;
+               if(Xonotic_KeyBinds_Descriptions[i])
+                       strunzone(Xonotic_KeyBinds_Descriptions[i]);
+               Xonotic_KeyBinds_Descriptions[i] = string_null;
+       }
+       Xonotic_KeyBinds_Count = 0;
+}
 void XonoticKeyBinder_editUserbind(entity me, string theName, string theCommandPress, string theCommandRelease)
 {
        string func, descr;
index 5d58a1b03ebaf927ca1c74a1ce3bddbc3dfcd030..3af8238ddd1812f7b56c28f87309eb9fdee24de5 100644 (file)
@@ -3,6 +3,7 @@
 #include "image.qc"
 CLASS(XonoticPlayerModelSelector, XonoticImage)
        METHOD(XonoticPlayerModelSelector, configureXonoticPlayerModelSelector, void(entity));
+       METHOD(XonoticPlayerModelSelector, loadModels, void(entity));
        METHOD(XonoticPlayerModelSelector, loadCvars, void(entity));
        METHOD(XonoticPlayerModelSelector, saveCvars, void(entity));
        METHOD(XonoticPlayerModelSelector, draw, void(entity));
@@ -49,16 +50,19 @@ const float BUFMODELS_COUNT = 5;
 
 void XonoticPlayerModelSelector_configureXonoticPlayerModelSelector(entity me)
 {
-       float sortbuf, glob, i;
+       me.configureXonoticImage(me, string_null, -1);
+}
+
+void XonoticPlayerModelSelector_loadModels(entity me)
+{
+       int i;
        string fn;
 
-       glob = search_begin(language_filename(get_model_datafilename(string_null, -1, "txt")), true, true);
+       float glob = search_begin(language_filename(get_model_datafilename(string_null, -1, "txt")), true, true);
        if (glob < 0)
                return;
 
-       me.configureXonoticImage(me, string_null, -1);
-
-       sortbuf = buf_create();
+       float sortbuf = buf_create();
        for(i = 0; i < search_getsize(glob); ++i)
        {
                // select model #i!
@@ -103,10 +107,14 @@ void XonoticPlayerModelSelector_configureXonoticPlayerModelSelector(entity me)
        me.loadCvars(me); // this will select the initial model, depending on the current cvars
        me.go(me, 0); // this will set the vars for the selected model
 }
+
 void XonoticPlayerModelSelector_destroy(entity me)
 {
-       buf_del(me.bufModels);
-       me.bufModels = -1;
+       if(me.bufModels >= 0)
+       {
+               buf_del(me.bufModels);
+               me.bufModels = -1;
+       }
 }
 
 void XonoticPlayerModelSelector_loadCvars(entity me)
@@ -222,6 +230,6 @@ void XonoticPlayerModelSelector_showNotify(entity me)
 {
        // Reinitialize self.
        me.destroy(me);
-       me.configureXonoticPlayerModelSelector(me);
+       me.loadModels(me);
 }
 #endif
index 6655e8a62c1bacff3be95b2b0f88846fba30883b..900c446f31085093cfb9086e6502c0e2c5c1ff45 100644 (file)
@@ -58,7 +58,7 @@ entity makeXonoticScreenshotList()
 void XonoticScreenshotList_configureXonoticScreenshotList(entity me)
 {
        me.configureXonoticListBox(me);
-       me.getScreenshots(me);
+       me.nItems = 0;
 }
 
 string XonoticScreenshotList_screenshotName(entity me, float i)
index 159cd76c53d60a2bfe8c3b3c73c9fea6a74b9679..961c5b00be757e34c4aa6bb389cd6591594baef3 100644 (file)
@@ -7,13 +7,13 @@ CLASS(XonoticSoundList, XonoticListBox)
        METHOD(XonoticSoundList, resizeNotify, void(entity, vector, vector, vector, vector));
        METHOD(XonoticSoundList, drawListBoxItem, void(entity, int, vector, bool, bool));
        METHOD(XonoticSoundList, getSounds, void(entity));
-       METHOD(XonoticSoundList, soundName, string(entity, float));
-       METHOD(XonoticSoundList, doubleClickListBoxItem, void(entity, float, vector));
+       METHOD(XonoticSoundList, soundName, string(entity, int));
+       METHOD(XonoticSoundList, doubleClickListBoxItem, void(entity, int, vector));
        METHOD(XonoticSoundList, keyDown, float(entity, float, float, float));
        METHOD(XonoticSoundList, destroy, void(entity));
        METHOD(XonoticSoundList, showNotify, void(entity));
 
-       ATTRIB(XonoticSoundList, listSound, float, -1)
+       ATTRIB(XonoticSoundList, listSound, int, -1)
        ATTRIB(XonoticSoundList, realFontSize, vector, '0 0 0')
        ATTRIB(XonoticSoundList, columnNameOrigin, float, 0)
        ATTRIB(XonoticSoundList, columnNameSize, float, 0)
@@ -48,10 +48,10 @@ entity makeXonoticSoundList()
 void XonoticSoundList_configureXonoticSoundList(entity me)
 {
        me.configureXonoticListBox(me);
-       me.getSounds(me);
+       me.nItems = 0;
 }
 
-string XonoticSoundList_soundName(entity me, float i )
+string XonoticSoundList_soundName(entity me, int i)
 {
        string s;
        s = search_getfilename(me.listSound, i);
@@ -75,10 +75,7 @@ void XonoticSoundList_getSounds(entity me)
 
        me.listSound = search_begin(s, false, true);
 
-       if(me.listSound < 0)
-               me.nItems=0;
-       else
-               me.nItems=search_getsize(me.listSound);
+       me.nItems = (me.listSound < 0) ? 0 : search_getsize(me.listSound);
 }
 
 void XonoticSoundList_destroy(entity me)
@@ -114,7 +111,7 @@ void XonoticSoundList_drawListBoxItem(entity me, int i, vector absSize, bool isS
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
        }
 
-       s = me.soundName(me,i);
+       s = me.soundName(me, i);
        if(s == cvar_string("menu_cdtrack")) // current menu track
                draw_CenterText((me.columnNumberOrigin + 0.5 * me.columnNumberSize) * eX + me.realUpperMargin * eY, "[C]", me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
        else if(s == cvar_defstring("menu_cdtrack")) // default menu track
@@ -131,7 +128,7 @@ void XonoticSoundList_showNotify(entity me)
 
 void SoundList_Menu_Track_Change(entity box, entity me)
 {
-       cvar_set("menu_cdtrack", me.soundName(me,me.selectedItem));
+       cvar_set("menu_cdtrack", me.soundName(me, me.selectedItem));
 }
 
 void SoundList_Menu_Track_Reset(entity box, entity me)
@@ -159,12 +156,12 @@ void SoundList_Add(entity box, entity me)
 
 void SoundList_Add_All(entity box, entity me)
 {
-       float i;
+       int i;
        for(i = 0; i < me.nItems; ++i)
                me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
 }
 
-void XonoticSoundList_doubleClickListBoxItem(entity me, float i, vector where)
+void XonoticSoundList_doubleClickListBoxItem(entity me, int i, vector where)
 {
        me.playlist.addToPlayList(me.playlist, me.soundName(me, i));
 }