From: terencehill Date: Thu, 26 Nov 2015 14:33:33 +0000 (+0100) Subject: HUD skin selector: display proper title and author for every skin (set in the skin... X-Git-Tag: xonotic-v0.8.2~1467^2~9 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=99c5585469004781a00bdc9492d278d3901a78ae HUD skin selector: display proper title and author for every skin (set in the skin file as comments) --- diff --git a/hud_luma.cfg b/hud_luma.cfg index 09957c4d10..226af4c1bf 100644 --- a/hud_luma.cfg +++ b/hud_luma.cfg @@ -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" diff --git a/hud_luminos.cfg b/hud_luminos.cfg index a51d9c2b4d..04902e07f8 100644 --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@ -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" diff --git a/hud_luminos_minimal.cfg b/hud_luminos_minimal.cfg index 6b0ef98a44..76214f4903 100644 --- a/hud_luminos_minimal.cfg +++ b/hud_luminos_minimal.cfg @@ -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" diff --git a/hud_luminos_minimal_xhair.cfg b/hud_luminos_minimal_xhair.cfg index 76f0ff1c96..722a316fd0 100644 --- a/hud_luminos_minimal_xhair.cfg +++ b/hud_luminos_minimal_xhair.cfg @@ -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" diff --git a/hud_luminos_old.cfg b/hud_luminos_old.cfg index 5d4d1a039c..3138471bb7 100644 --- a/hud_luminos_old.cfg +++ b/hud_luminos_old.cfg @@ -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" diff --git a/hud_nexuiz.cfg b/hud_nexuiz.cfg index f960edabcf..791653f270 100644 --- a/hud_nexuiz.cfg +++ b/hud_nexuiz.cfg @@ -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" diff --git a/qcsrc/menu/xonotic/hudskinlist.qc b/qcsrc/menu/xonotic/hudskinlist.qc index 49a3ecaa33..ddb5acd9d3 100644 --- a/qcsrc/menu/xonotic/hudskinlist.qc +++ b/qcsrc/menu/xonotic/hudskinlist.qc @@ -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); }