]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/itemstime/itemstime.qc
HUD: allow panels to define in their own files their own saved cvars
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / itemstime / itemstime.qc
index 1379d586f10fd4da14b9f82d98571cd00bbe6c78..5ee7faae8494022623fd047dbdcf7f773ae7875c 100644 (file)
@@ -28,16 +28,12 @@ NET_HANDLE(itemstime, bool isNew)
 #endif
 
 #ifdef CSQC
-void Item_ItemsTime_Init()
-{
-    FOREACH(Items, true, {
-        ItemsTime_time[it.m_id] = -1;
-    });
-    ItemsTime_time[Items_MAX] = -1;
-}
 
 STATIC_INIT(ItemsTime_Init) {
-    Item_ItemsTime_Init();
+       FOREACH(Items, true, {
+               ItemsTime_time[it.m_id] = -1;
+       });
+       ItemsTime_time[Items_MAX] = -1;
 }
 
 int autocvar_hud_panel_itemstime = 2;
@@ -77,17 +73,11 @@ bool Item_ItemsTime_Allow(GameItem it)
 // reserve one more spot for superweapons time
 float it_times[Items_MAX + 1];
 
-void Item_ItemsTime_Init()
-{
-    FOREACH(Items, Item_ItemsTime_Allow(it), {
-        it_times[it.m_id] = -1;
-    });
-    it_times[Items_MAX] = -1;
-}
-
 STATIC_INIT(ItemsTime_Init) {
-    // items time
-    Item_ItemsTime_Init();
+       FOREACH(Items, Item_ItemsTime_Allow(it), {
+               it_times[it.m_id] = -1;
+       });
+       it_times[Items_MAX] = -1;
 }
 
 void Item_ItemsTime_ResetTimes()
@@ -195,6 +185,20 @@ MUTATOR_HOOKFUNCTION(itemstime, PlayerSpawn)
 
 #ifdef CSQC
 
+// ItemsTime (#22)
+
+void HUD_ItemsTime_Export(entity panel, int fh)
+{
+       // allow saving cvars that aesthetically change the panel into hud skin files
+       HUD_Write_Cvar("hud_panel_itemstime_iconalign");
+       HUD_Write_Cvar("hud_panel_itemstime_progressbar");
+       HUD_Write_Cvar("hud_panel_itemstime_progressbar_name");
+       HUD_Write_Cvar("hud_panel_itemstime_progressbar_reduced");
+       HUD_Write_Cvar("hud_panel_itemstime_text");
+       HUD_Write_Cvar("hud_panel_itemstime_ratio");
+       HUD_Write_Cvar("hud_panel_itemstime_dynamicsize");
+}
+
 void DrawItemsTimeItem(vector myPos, vector mySize, float ar, string item_icon, float item_time, bool item_available, float item_availableTime)
 {
     float t = 0;
@@ -204,12 +208,7 @@ void DrawItemsTimeItem(vector myPos, vector mySize, float ar, string item_icon,
     if (autocvar_hud_panel_itemstime_hidespawned == 2)
         picalpha = 1;
     else if (item_available)
-    {
-        float BLINK_FACTOR = 0.15;
-        float BLINK_BASE = 0.85;
-        float BLINK_FREQ = 5;
-        picalpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
-    }
+        picalpha = blink(0.85, 0.15, 5);
     else
         picalpha = 0.5;
     t = floor(item_time - time + 0.999);