]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/menu_hudskin_selector
authorterencehill <piuntn@gmail.com>
Tue, 8 Dec 2015 14:33:21 +0000 (15:33 +0100)
committerterencehill <piuntn@gmail.com>
Tue, 8 Dec 2015 14:33:21 +0000 (15:33 +0100)
13 files changed:
hud_luma.cfg
hud_luminos.cfg
hud_luminos_minimal.cfg
hud_luminos_minimal_xhair.cfg
hud_luminos_old.cfg
hud_nexuiz.cfg
qcsrc/client/hud/hud_config.qc
qcsrc/menu/classes.inc
qcsrc/menu/xonotic/dialog_hudsetup_exit.qc
qcsrc/menu/xonotic/dialog_multiplayer_create.qc
qcsrc/menu/xonotic/dialog_multiplayer_media_demo.qc
qcsrc/menu/xonotic/dialog_multiplayer_media_musicplayer.qc
qcsrc/menu/xonotic/hudskinlist.qc [new file with mode: 0644]

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 be76d465376fe3e6c2c65227631f6bf43c8c6037..9ca2a0ab5226f529c42af92c81777f13644c71f0 100644 (file)
@@ -13,6 +13,9 @@ void HUD_Panel_ExportCfg(string cfgname)
        fh = fopen(filename, FILE_WRITE);
        if(fh >= 0)
        {
+               HUD_Write("//title \n");
+               HUD_Write("//author \n");
+               HUD_Write("\n");
                HUD_Write_Cvar("hud_skin");
                HUD_Write_Cvar("hud_panel_bg");
                HUD_Write_Cvar("hud_panel_bg_color");
index 08563a118ac7f486ddb1955887e8a8ef54294f03..3aa3e43057447ea63b43a8bb996d5881b36369f4 100644 (file)
 #include "xonotic/dialog_singleplayer_winner.qc"
 #include "xonotic/dialog_teamselect.qc"
 #include "xonotic/gametypelist.qc"
+#include "xonotic/hudskinlist.qc"
 #include "xonotic/image.qc"
 #include "xonotic/inputbox.qc"
 #include "xonotic/keybinder.qc"
index b9d4c34b7ec7375e6e9a583a62eecdf0ed8919ae..2a4180f3eef727a496aeecc1cd23ea89a36763f6 100644 (file)
@@ -5,9 +5,9 @@ CLASS(XonoticHUDExitDialog, XonoticRootDialog)
        METHOD(XonoticHUDExitDialog, fill, void(entity));
        ATTRIB(XonoticHUDExitDialog, title, string, _("Panel HUD Setup"))
        ATTRIB(XonoticHUDExitDialog, color, vector, SKINCOLOR_DIALOG_TEAMSELECT)
-       ATTRIB(XonoticHUDExitDialog, intendedWidth, float, 0.4)
+       ATTRIB(XonoticHUDExitDialog, intendedWidth, float, 0.8)
        ATTRIB(XonoticHUDExitDialog, rows, float, 18)
-       ATTRIB(XonoticHUDExitDialog, columns, float, 4)
+       ATTRIB(XonoticHUDExitDialog, columns, float, 8.2)
        ATTRIB(XonoticHUDExitDialog, name, string, "HUDExit")
        ATTRIB(XonoticHUDExitDialog, requiresConnection, float, true)
 ENDCLASS(XonoticHUDExitDialog)
@@ -18,9 +18,37 @@ ENDCLASS(XonoticHUDExitDialog)
 void XonoticHUDExitDialog_fill(entity me)
 {
        entity e;
-       float i;
+       int i;
+       hudskinlist = makeXonoticHUDSkinList();
 
        me.TR(me);
+               me.TD(me, 1, 4, makeXonoticHeaderLabel(_("HUD skins")));
+       me.TR(me);
+               me.TDempty(me, 0.2);
+               me.TD(me, 1, 0.7, e = makeXonoticTextLabel(0.5, _("Filter:")));
+               me.TD(me, 1, 2.9, e = makeXonoticInputBox(0, string_null));
+                       e.onChange = HUDSkinList_Filter_Change;
+                       e.onChangeEntity = hudskinlist;
+       me.TR(me);
+               me.TD(me, 12, 4, hudskinlist);
+       me.gotoRC(me, me.rows - 4, 0);
+               me.TDempty(me, 0.2);
+               me.TD(me, 1, 1.4, e = makeXonoticButton(_("Refresh"), '0 0 0'));
+                       e.onClick = HUDSkinList_Refresh_Click;
+                       e.onClickEntity = hudskinlist;
+               me.TD(me, 1, 2.2, e = makeXonoticButton(_("Set skin"), '0 0 0'));
+                       e.onClick = SetHUDSkin_Click;
+                       e.onClickEntity = hudskinlist;
+       me.gotoRC(me, me.rows - 2.5, 0);
+               me.TD(me, 1, 2, e = makeXonoticButton_T(_("Save current skin"), '0 0 0',
+                       "Note: HUD skins are saved in data/data/ directory and can be manually renamed/deleted from there"));
+                       e.onClick = SaveHUDSkin_Click;
+                       e.onClickEntity = hudskinlist;
+               me.TD(me, 1, 2, e = makeXonoticInputBox(0, string_null));
+                       e.onChange = HUDSkinList_SavedName_Change;
+                       e.onChangeEntity = hudskinlist;
+
+       me.gotoRC(me, 0, 4.2); me.setFirstColumn(me, me.currentColumn);
                me.TD(me, 1, 4, makeXonoticTextLabel(0, _("Panel background defaults:")));
        me.TR(me);
                me.TD(me, 1, 1.4, e = makeXonoticTextLabel(0, _("Background:")));
@@ -103,18 +131,21 @@ void XonoticHUDExitDialog_fill(entity me)
        me.TR(me);
                me.TDempty(me, 0.2);
                me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Grid size:")));
+                       setDependent(e, "hud_configure_grid", 1, 1);
                me.TD(me, 1, 0.2, e = makeXonoticTextLabel(0, _("X:")));
+                       setDependent(e, "hud_configure_grid", 1, 1);
                        me.TD(me, 1, 1.1, e = makeXonoticTextSlider("hud_configure_grid_xsize"));
                                for(i = 1; i <= 14; ++i)
-                                       e.addValue(e, strzone(ftos_decimals(i/200, 3)), strzone(ftos(i/200)));
+                                       e.addValue(e, strzone(sprintf("%.1f%%", i/2)), strzone(ftos(i/200)));
                                e.configureXonoticTextSliderValues(e);
-                       setDependent(e, "hud_configure_grid", 1, 1);
+                               setDependent(e, "hud_configure_grid", 1, 1);
                me.TD(me, 1, 0.2, e = makeXonoticTextLabel(0, _("Y:")));
+                       setDependent(e, "hud_configure_grid", 1, 1);
                        me.TD(me, 1, 1.1, e = makeXonoticTextSlider("hud_configure_grid_ysize"));
                                for(i = 1; i <= 14; ++i)
-                                       e.addValue(e, strzone(ftos_decimals(i/200, 3)), strzone(ftos(i/200)));
+                                       e.addValue(e, strzone(sprintf("%.1f%%", i/2)), strzone(ftos(i/200)));
                                e.configureXonoticTextSliderValues(e);
-                       setDependent(e, "hud_configure_grid", 1, 1);
+                               setDependent(e, "hud_configure_grid", 1, 1);
 
        me.gotoRC(me, me.rows - 1, 0);
                me.TD(me, 1, me.columns, e = makeXonoticCommandButton(_("Exit setup"), '0 0 0', "_hud_configure 0", 1));
index f165d992381c1df1b52767a132e5de513fed9925..689a8f6308fc6de28562d7b26b2d89d20248d567 100644 (file)
@@ -185,7 +185,6 @@ void XonoticServerCreateTab_fill(entity me)
                        e.onChange = MapList_StringFilterBox_Change;
                        e.keyDown = MapList_StringFilterBox_keyDown;
                        e.onChangeEntity = me.mapListBox;
-                       me.mapListBox.controlledTextbox = e;
 
        me.gotoRC(me, me.rows - 3.5, me.firstColumn);
                // the selection buttons
index d48ad77d54bb5539f5008515112325e94294a5aa..b7f3884a80bd4284e69da513b03ae72f7ae51452 100644 (file)
@@ -50,7 +50,6 @@ void XonoticDemoBrowserTab_fill(entity me)
                me.TD(me, 1, 2.9, e = makeXonoticInputBox(0, string_null));
                        e.onChange = DemoList_Filter_Change;
                        e.onChangeEntity = demolist;
-                       demolist.controlledTextbox = e;
 
        me.gotoRC(me, 0, 3.7);
                me.TD(me, 1, 1.5, e = makeXonoticCheckBox(0, "cl_autodemo", _("Auto record demos")));
index d78b5b6575645912206f8a0fb29cf20c45d86f33..9346dfdbd53d6d1d82e9de18825b5548a7a54a2c 100644 (file)
@@ -31,7 +31,6 @@ void XonoticMusicPlayerTab_fill(entity me)
                        soundList = makeXonoticSoundList();
                        e.onChange = SoundList_Filter_Change;
                        e.onChangeEntity = soundList;
-                       soundList.controlledTextbox = e;
                        playList = makeXonoticPlayList();
                        soundList.playlist = playList;
 
diff --git a/qcsrc/menu/xonotic/hudskinlist.qc b/qcsrc/menu/xonotic/hudskinlist.qc
new file mode 100644 (file)
index 0000000..65bdba1
--- /dev/null
@@ -0,0 +1,272 @@
+#ifndef HUDSKINLIST_H
+#define HUDSKINLIST_H
+#include "listbox.qc"
+CLASS(XonoticHUDSkinList, XonoticListBox)
+       METHOD(XonoticHUDSkinList, configureXonoticHUDSkinList, void(entity));
+       ATTRIB(XonoticHUDSkinList, rowsPerItem, float, 1)
+       METHOD(XonoticHUDSkinList, resizeNotify, void(entity, vector, vector, vector, vector));
+       METHOD(XonoticHUDSkinList, draw, void(entity));
+       METHOD(XonoticHUDSkinList, drawListBoxItem, void(entity, int, vector, bool, bool));
+       METHOD(XonoticHUDSkinList, getHUDSkins, void(entity));
+       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));
+       METHOD(XonoticHUDSkinList, showNotify, void(entity));
+
+       ATTRIB(XonoticHUDSkinList, listHUDSkin, float, -1)
+       ATTRIB(XonoticHUDSkinList, realFontSize, vector, '0 0 0')
+       ATTRIB(XonoticHUDSkinList, columnNameOrigin, float, 0)
+       ATTRIB(XonoticHUDSkinList, columnNameSize, float, 0)
+       ATTRIB(XonoticHUDSkinList, realUpperMargin, float, 0)
+       ATTRIB(XonoticHUDSkinList, origin, vector, '0 0 0')
+       ATTRIB(XonoticHUDSkinList, itemAbsSize, vector, '0 0 0')
+
+       ATTRIB(XonoticHUDSkinList, filterString, string, string_null)
+       ATTRIB(XonoticHUDSkinList, delayedRefreshTime, float, 0)
+       ATTRIB(XonoticHUDSkinList, savedName, string, string_null)
+ENDCLASS(XonoticHUDSkinList)
+
+#ifndef IMPLEMENTATION
+// public:
+entity hudskinlist;
+entity makeXonoticHUDSkinList();
+void SaveHUDSkin_Click(entity btn, entity me);
+void SetHUDSkin_Click(entity btn, entity me);
+#endif
+void HUDSkinList_Refresh_Click(entity btn, entity me);
+void HUDSkinList_Filter_Change(entity box, entity me);
+void HUDSkinList_SavedName_Change(entity box, entity me);
+#endif
+
+#ifdef IMPLEMENTATION
+
+entity makeXonoticHUDSkinList()
+{
+       entity me;
+       me = NEW(XonoticHUDSkinList);
+       me.configureXonoticHUDSkinList(me);
+       return me;
+}
+
+void XonoticHUDSkinList_configureXonoticHUDSkinList(entity me)
+{
+       me.configureXonoticListBox(me);
+       me.getHUDSkins(me);
+}
+
+const float HUDSKINPARM_NAME = 0;
+const float HUDSKINPARM_PATH = 1;
+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);
+}
+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)
+{
+       string s;
+       if(me.filterString)
+               s = me.filterString;
+       else
+               s = "*";
+       s = strcat(subdir, "hud_", s, ".cfg");
+       float strlen_subdir = strlen(subdir);
+       subdir = strzone(subdir);
+
+       float list, i, n;
+       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);
+                       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);
+       }
+       if(subdir)
+               strunzone(subdir);
+}
+
+void XonoticHUDSkinList_getHUDSkins(entity me)
+{
+       if (me.listHUDSkin >= 0)
+               buf_del(me.listHUDSkin);
+       me.listHUDSkin = buf_create();
+       if (me.listHUDSkin < 0)
+       {
+               me.nItems = 0;
+               return;
+       }
+       getAllHUDSkins(me, "");
+       getAllHUDSkins(me, "data/");
+       me.nItems = buf_getsize(me.listHUDSkin) / HUDSKINPARM_COUNT;
+}
+
+void XonoticHUDSkinList_destroy(entity me)
+{
+       if(me.nItems > 0)
+               buf_del(me.listHUDSkin);
+}
+
+void XonoticHUDSkinList_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
+{
+       me.itemAbsSize = '0 0 0';
+       SUPER(XonoticHUDSkinList).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.realUpperMargin = 0.5 * (1 - me.realFontSize.y);
+
+       me.columnNameOrigin = me.realFontSize.x;
+       me.columnNameSize = 1 - 2 * me.realFontSize.x;
+}
+
+void XonoticHUDSkinList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
+{
+       string s, s2;
+       if(isSelected)
+               draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
+       else if(isFocused)
+       {
+               me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
+               draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
+       }
+
+       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);
+}
+
+void XonoticHUDSkinList_showNotify(entity me)
+{
+       me.getHUDSkins(me);
+}
+
+void HUDSkinList_Refresh_Click(entity btn, entity me)
+{
+       me.getHUDSkins(me);
+       me.setSelected(me, 0); //always select the first element after a list update
+}
+
+void HUDSkinList_SavedName_Change(entity box, entity me)
+{
+       if(me.savedName)
+               strunzone(me.savedName);
+
+       if(box.text != "")
+               me.savedName = strzone(box.text);
+       else
+               me.savedName = string_null;
+}
+
+void HUDSkinList_Filter_Change(entity box, entity me)
+{
+       if(me.filterString)
+               strunzone(me.filterString);
+
+       if(box.text != "")
+       {
+               if (strstrofs(box.text, "*", 0) >= 0 || strstrofs(box.text, "?", 0) >= 0)
+                       me.filterString = strzone(box.text);
+               else
+                       me.filterString = strzone(strcat("*", box.text, "*"));
+       }
+       else
+               me.filterString = string_null;
+
+       me.getHUDSkins(me);
+}
+
+void SaveHUDSkin_Click(entity btn, entity me)
+{
+       string s = me.savedName;
+       if(s == "")
+               s = "myconfig";
+       localcmd(sprintf("hud save \"%s\"\n", s));
+       me.delayedRefreshTime = time + 1;
+}
+
+void XonoticHUDSkinList_draw(entity me)
+{
+       if(me.delayedRefreshTime > 0 && me.delayedRefreshTime < time)
+       {
+               HUDSkinList_Refresh_Click(NULL, me);
+               me.delayedRefreshTime = 0;
+       }
+       SUPER(XonoticHUDSkinList).draw(me);
+}
+
+void XonoticHUDSkinList_setHUDSkin(entity me)
+{
+       string cfg = strcat(me.hudskinPath(me, me.selectedItem), "hud_", me.hudskinName(me, me.selectedItem), ".cfg");
+       localcmd("exec \"", cfg, "\"\n");
+}
+
+void SetHUDSkin_Click(entity btn, entity me)
+{
+       me.setHUDSkin(me);
+}
+
+void XonoticHUDSkinList_doubleClickListBoxItem(entity me, float i, vector where)
+{
+       m_play_click_sound(MENU_SOUND_EXECUTE);
+       me.setHUDSkin(me);
+}
+
+float XonoticHUDSkinList_keyDown(entity me, float scan, float ascii, float shift)
+{
+       if(scan == K_ENTER || scan == K_KP_ENTER)
+       {
+               me.setHUDSkin(me);
+               return 1;
+       }
+       else
+       {
+               return SUPER(XonoticHUDSkinList).keyDown(me, scan, ascii, shift);
+       }
+}
+#endif
+