]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/skinlist.qc
Merge branch 'master' into martin-t/effects
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / skinlist.qc
index 46babc3f9517f5c9ae63c390e68e9d4bfdaa0960..4683c45207a018753df987f7d26f1c98ceda86be 100644 (file)
@@ -1,39 +1,4 @@
-#ifndef SKINLIST_H
-#define SKINLIST_H
-#include "listbox.qc"
-CLASS(XonoticSkinList, XonoticListBox)
-       METHOD(XonoticSkinList, configureXonoticSkinList, void(entity))
-       ATTRIB(XonoticSkinList, rowsPerItem, float, 4)
-       METHOD(XonoticSkinList, resizeNotify, void(entity, vector, vector, vector, vector))
-       METHOD(XonoticSkinList, drawListBoxItem, void(entity, int, vector, bool, bool))
-       METHOD(XonoticSkinList, getSkins, void(entity))
-       METHOD(XonoticSkinList, setSkin, void(entity))
-       METHOD(XonoticSkinList, loadCvars, void(entity))
-       METHOD(XonoticSkinList, saveCvars, void(entity))
-       METHOD(XonoticSkinList, skinParameter, string(entity, float, float))
-       METHOD(XonoticSkinList, doubleClickListBoxItem, void(entity, float, vector))
-       METHOD(XonoticSkinList, keyDown, float(entity, float, float, float))
-       METHOD(XonoticSkinList, destroy, void(entity))
-
-       ATTRIB(XonoticSkinList, skinlist, float, -1)
-       ATTRIB(XonoticSkinList, realFontSize, vector, '0 0 0')
-       ATTRIB(XonoticSkinList, columnPreviewOrigin, float, 0)
-       ATTRIB(XonoticSkinList, columnPreviewSize, float, 0)
-       ATTRIB(XonoticSkinList, columnNameOrigin, float, 0)
-       ATTRIB(XonoticSkinList, columnNameSize, float, 0)
-       ATTRIB(XonoticSkinList, realUpperMargin1, float, 0)
-       ATTRIB(XonoticSkinList, realUpperMargin2, float, 0)
-       ATTRIB(XonoticSkinList, origin, vector, '0 0 0')
-       ATTRIB(XonoticSkinList, itemAbsSize, vector, '0 0 0')
-
-       ATTRIB(XonoticSkinList, name, string, "skinselector")
-ENDCLASS(XonoticSkinList)
-
-entity makeXonoticSkinList();
-void SetSkin_Click(entity btn, entity me);
-#endif
-
-#ifdef IMPLEMENTATION
+#include "skinlist.qh"
 
 const float SKINPARM_NAME = 0;
 const float SKINPARM_TITLE = 1;
@@ -66,7 +31,7 @@ void XonoticSkinList_loadCvars(entity me)
        {
                if(me.skinParameter(me, i, SKINPARM_NAME) == s)
                {
-                       me.selectedItem = i;
+                       me.setSelected(me, i);
                        break;
                }
        }
@@ -85,7 +50,7 @@ string XonoticSkinList_skinParameter(entity me, float i, float key)
 void XonoticSkinList_getSkins(entity me)
 {
        float glob, buf, i, n, fh;
-       string s;
+       string s, name;
 
        buf = buf_create();
        glob = search_begin("gfx/menu/*/skinvalues.txt", true, true);
@@ -100,24 +65,30 @@ void XonoticSkinList_getSkins(entity me)
        for(i = 0; i < n; ++i)
        {
                s = search_getfilename(glob, i);
-               bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_NAME, substring(s, 9, strlen(s) - 24)); // the * part
+               name = substring(s, 9, strlen(s) - 24); // the * part
+               bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_NAME, name);
                bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_TITLE, _("<TITLE>"));
                bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_AUTHOR, _("<AUTHOR>"));
                if(draw_PictureSize(strcat("/gfx/menu/", substring(s, 9, strlen(s) - 24), "/skinpreview")) == '0 0 0')
                        bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_PREVIEW, "nopreview_menuskin");
                else
                        bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_PREVIEW, strcat("/gfx/menu/", substring(s, 9, strlen(s) - 24), "/skinpreview"));
-               fh = fopen(language_filename(s), FILE_READ);
+               fh = fopen(s, FILE_READ);
                if(fh < 0)
                {
-                       print("Warning: can't open skinvalues.txt file\n");
+                       LOG_INFO("Warning: can't open skinvalues.txt file");
                        continue;
                }
                while((s = fgets(fh)))
                {
                        // these two are handled by skinlist.qc
                        if(substring(s, 0, 6) == "title ")
-                               bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_TITLE, substring(s, 6, strlen(s) - 6));
+                       {
+                               if (name == cvar_defstring("menu_skin"))
+                                       bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_TITLE, strcat(substring(s, 6, strlen(s) - 6), " (", _("Default"), ")"));
+                               else
+                                       bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_TITLE, substring(s, 6, strlen(s) - 6));
+                       }
                        else if(substring(s, 0, 7) == "author ")
                                bufstr_set(buf, i * SKINPARM_COUNT + SKINPARM_AUTHOR, substring(s, 7, strlen(s) - 7));
                }
@@ -140,8 +111,10 @@ void XonoticSkinList_resizeNotify(entity me, vector relOrigin, vector relSize, v
        me.itemAbsSize = '0 0 0';
        SUPER(XonoticSkinList).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
 
-       me.realFontSize_y = me.fontSize / (me.itemAbsSize_y = (absSize.y * me.itemHeight));
-       me.realFontSize_x = me.fontSize / (me.itemAbsSize_x = (absSize.x * (1 - me.controlWidth)));
+       me.itemAbsSize.y = absSize.y * me.itemHeight;
+       me.itemAbsSize.x = absSize.x * (1 - me.controlWidth);
+       me.realFontSize.y = me.fontSize / me.itemAbsSize.y;
+       me.realFontSize.x = me.fontSize / me.itemAbsSize.x;
        me.realUpperMargin1 = 0.5 * (1 - 2.5 * me.realFontSize.y);
        me.realUpperMargin2 = me.realUpperMargin1 + 1.5 * me.realFontSize.y;
 
@@ -203,4 +176,3 @@ float XonoticSkinList_keyDown(entity me, float scan, float ascii, float shift)
        else
                return SUPER(XonoticSkinList).keyDown(me, scan, ascii, shift);
 }
-#endif