]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
HUD skin selector: display proper title and author for every skin (set in the skin...
authorterencehill <piuntn@gmail.com>
Thu, 26 Nov 2015 14:33:33 +0000 (15:33 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 26 Nov 2015 14:33:33 +0000 (15:33 +0100)
hud_luma.cfg
hud_luminos.cfg
hud_luminos_minimal.cfg
hud_luminos_minimal_xhair.cfg
hud_luminos_old.cfg
hud_nexuiz.cfg
qcsrc/menu/xonotic/hudskinlist.qc

index 09957c4d10ea4ddcd33adc027a1ba0e9cccb907f..226af4c1bf237ff596b4128c9621d410d1e8df5f 100644 (file)
@@ -1,3 +1,6 @@
+//title Luma
+//author sev
+
 seta hud_skin "luma"
 seta hud_panel_bg "0"
 seta hud_panel_bg_color "0 0.14 0.25"
index a51d9c2b4d7d7b4ef96dd626794bbe649cf1da9d..04902e07f8a64fee26a1dc990515730535a635e8 100644 (file)
@@ -1,3 +1,6 @@
+//title Luminos
+//author sev
+
 seta hud_skin "luminos"
 seta hud_panel_bg "0"
 seta hud_panel_bg_color "0.6875 0.84375 1"
index 6b0ef98a44f90d1c54fbbb1af0796ea16cf53856..76214f49035e9abdeae7d30ca50966f2c213f5af 100644 (file)
@@ -1,3 +1,6 @@
+//title "Luminos minimal"
+//author sev
+
 seta hud_skin "luminos"
 seta hud_panel_bg "0"
 seta hud_panel_bg_color "1 0.4375 0"
index 76f0ff1c96172f3af01855840fc532c7daa2b5e8..722a316fd0c031ff37f58f42fda32f6d9a0d8b21 100644 (file)
@@ -1,3 +1,6 @@
+//title "Luminos minimal xhair"
+//author sev
+
 seta hud_skin "luminos_xhair"
 seta hud_panel_bg "0"
 seta hud_panel_bg_color "1 0.4375 0"
index 5d4d1a039c215511ddf0f9375620d6fd71c5de8b..3138471bb798a603f2345e00d80046267efa3b00 100644 (file)
@@ -1,3 +1,6 @@
+//title "Luminos (old version)"
+//author sev
+
 seta hud_skin "luminos"
 seta hud_panel_bg "border_default"
 seta hud_panel_bg_color "1 0.4375 0"
index f960edabcf628d7858970f8bf8a6be74996447c1..791653f270a920c139feeb8d5a8170269c449a76 100644 (file)
@@ -1,3 +1,6 @@
+//title Nexuiz
+//author sev
+
 seta hud_skin "old"
 seta hud_panel_bg "border_default"
 seta hud_panel_bg_color "0.299327 1 0.81275"
index 49a3ecaa33bc5745da0d55235754eeecf23af997..ddb5acd9d33ec47f06e24560a6c1a4c0f5bfe18f 100644 (file)
@@ -11,6 +11,8 @@ CLASS(XonoticHUDSkinList, XonoticListBox)
        METHOD(XonoticHUDSkinList, setHUDSkin, void(entity));
        METHOD(XonoticHUDSkinList, hudskinName, string(entity, float));
        METHOD(XonoticHUDSkinList, hudskinPath, string(entity, float));
+       METHOD(XonoticHUDSkinList, hudskinTitle, string(entity, float));
+       METHOD(XonoticHUDSkinList, hudskinAuthor, string(entity, float));
        METHOD(XonoticHUDSkinList, doubleClickListBoxItem, void(entity, float, vector));
        METHOD(XonoticHUDSkinList, keyDown, float(entity, float, float, float));
        METHOD(XonoticHUDSkinList, destroy, void(entity));
@@ -57,7 +59,9 @@ void XonoticHUDSkinList_configureXonoticHUDSkinList(entity me)
 
 const float HUDSKINPARM_NAME = 0;
 const float HUDSKINPARM_PATH = 1;
-const float HUDSKINPARM_COUNT = 2;
+const float HUDSKINPARM_TITLE = 2;
+const float HUDSKINPARM_AUTHOR = 3;
+const float HUDSKINPARM_COUNT = 4;
 string XonoticHUDSkinList_hudskinName(entity me, float i)
 {
        return bufstr_get(me.listHUDSkin, i * HUDSKINPARM_COUNT + HUDSKINPARM_NAME);
@@ -66,6 +70,14 @@ string XonoticHUDSkinList_hudskinPath(entity me, float i)
 {
        return bufstr_get(me.listHUDSkin, i * HUDSKINPARM_COUNT + HUDSKINPARM_PATH);
 }
+string XonoticHUDSkinList_hudskinTitle(entity me, float i)
+{
+       return bufstr_get(me.listHUDSkin, i * HUDSKINPARM_COUNT + HUDSKINPARM_TITLE);
+}
+string XonoticHUDSkinList_hudskinAuthor(entity me, float i)
+{
+       return bufstr_get(me.listHUDSkin, i * HUDSKINPARM_COUNT + HUDSKINPARM_AUTHOR);
+}
 
 void getAllHUDSkins(entity me, string subdir)
 {
@@ -82,14 +94,28 @@ void getAllHUDSkins(entity me, string subdir)
        list = search_begin(s, false, true);
        if(list >= 0)
        {
+               string filename;
                n = search_getsize(list);
                int bufsize = buf_getsize(me.listHUDSkin);
                for(i = 0; i < n; ++i)
                {
                        bufstr_set(me.listHUDSkin, bufsize + i * HUDSKINPARM_COUNT + HUDSKINPARM_PATH, subdir);
-                       s = search_getfilename(list, i); // get initial full file name
-                       s = substring(s, strlen_subdir + 4, (strlen(s) - strlen_subdir - 4 - 4)); // remove "hud_" prefix and ".cfg" suffix
+                       filename = search_getfilename(list, i);
+                       s = substring(filename, strlen_subdir + 4, (strlen(filename) - strlen_subdir - 4 - 4)); // remove "hud_" prefix and ".cfg" suffix
                        bufstr_set(me.listHUDSkin, bufsize + i * HUDSKINPARM_COUNT + HUDSKINPARM_NAME, s);
+
+                       int fh = fopen(filename, FILE_READ);
+                       if(fh < 0)
+                               continue;
+                       while((s = fgets(fh)) && substring(s, 0, 2) == "//")
+                       {
+                               tokenize_console(substring(s, 2, -1));
+                               if(argv(0) == "title")
+                                       bufstr_set(me.listHUDSkin, bufsize + i * HUDSKINPARM_COUNT + HUDSKINPARM_TITLE, argv(1));
+                               else if(argv(0) == "author")
+                                       bufstr_set(me.listHUDSkin, bufsize + i * HUDSKINPARM_COUNT + HUDSKINPARM_AUTHOR, argv(1));
+                       }
+                       fclose(fh);
                }
                search_end(list);
        }
@@ -133,7 +159,7 @@ void XonoticHUDSkinList_resizeNotify(entity me, vector relOrigin, vector relSize
 
 void XonoticHUDSkinList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
 {
-       string s;
+       string s, s2;
        if(isSelected)
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
        else if(isFocused)
@@ -142,7 +168,12 @@ void XonoticHUDSkinList_drawListBoxItem(entity me, int i, vector absSize, bool i
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
        }
 
-       s = me.hudskinName(me,i);
+       s = me.hudskinTitle(me, i);
+       if(s == "")
+               s = me.hudskinName(me, i);
+       s2 = me.hudskinAuthor(me, i);
+       if(s2 != "")
+               s = strcat(s, " (", s2, ")");
        s = draw_TextShortenToWidth(s, me.columnNameSize, 0, me.realFontSize);
        draw_Text(me.realUpperMargin * eY + (me.columnNameOrigin + 0.00 * (me.columnNameSize - draw_TextWidth(s, 0, me.realFontSize))) * eX, s, me.realFontSize, SKINCOLOR_TEXT, SKINALPHA_TEXT, 1);
 }