e.onChangeEntity = hudskinlist;
hudskinlist.controlledTextbox = e;
me.TR(me);
- me.TD(me, 13.5, 4, hudskinlist);
- me.gotoRC(me, me.rows - 2.5, 0);
+ me.TD(me, 12.5, 4, hudskinlist);
+ me.gotoRC(me, me.rows - 3.5, 0);
me.TDempty(me, 0.75);
me.TD(me, 1, 2.5, e = makeXonoticButton(_("Set skin"), '0 0 0'));
e.onClick = SetHUDSkin_Click;
e.onClickEntity = hudskinlist;
+ me.TR(me);
+ me.TDempty(me, 0.75);
+ me.TD(me, 1, 2.5, e = makeXonoticButton(_("Save current skin"), '0 0 0'));
+ e.onClick = SaveHUDSkin_Click;
+ e.onClickEntity = hudskinlist;
me.gotoRC(me, 0, 4.2); me.setFirstColumn(me, me.currentColumn);
me.TD(me, 1, 4, makeXonoticTextLabel(0, _("Panel background defaults:")));
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));
ATTRIB(XonoticHUDSkinList, itemAbsSize, vector, '0 0 0')
ATTRIB(XonoticHUDSkinList, filterString, string, string_null)
+ ATTRIB(XonoticHUDSkinList, delayedRefreshTime, float, 0)
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);
return s;
}
-void getAllHUDSkins(entity me)
+void getAllHUDSkins(entity me, string subdir)
{
string s;
if(me.filterString)
s = me.filterString;
else
s = "*";
- s = strcat("hud_", s, ".cfg");
+ s = strcat(subdir, "hud_", s, ".cfg");
+ float strlen_subdir = strlen(subdir);
float list, i, n;
list = search_begin(s, false, true);
for(i = 0; i < n; ++i)
{
s = search_getfilename(list, i); // get initial full file name
- s = substring(s, 4, (strlen(s) - 4 - 4)); // remove "hud_" prefix and ".cfg" suffix
+ s = substring(s, strlen_subdir + 4, (strlen(s) - strlen_subdir - 4 - 4)); // remove "hud_" prefix and ".cfg" suffix
bufstr_add(me.listHUDSkin, s, true);
}
search_end(list);
me.nItems = 0;
return;
}
- getAllHUDSkins(me);
+ getAllHUDSkins(me, "");
+ getAllHUDSkins(me, "data/");
me.nItems = buf_getsize(me.listHUDSkin);
if(me.nItems > 0)
buf_sort(me.listHUDSkin, 128, false);
me.getHUDSkins(me);
}
+void SaveHUDSkin_Click(entity btn, entity me)
+{
+ localcmd("hud save myconfig\n");
+ 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 s = me.hudskinName(me, me.selectedItem);
-
localcmd("exec \"hud_", s, ".cfg\"\n");
}