Browse Source

Little polishing of Unjustified Points module

TheSumm 5 years ago
parent
commit
a8f2bb19db
1 changed files with 19 additions and 6 deletions
  1. 19
    6
      modules/game_unjustifiedpoints/unjustifiedpoints.lua

+ 19
- 6
modules/game_unjustifiedpoints/unjustifiedpoints.lua View File

@@ -112,6 +112,16 @@ function onOpenPvpSituationsChange(amount)
112 112
   openPvpSituationsLabel:setText(amount)
113 113
 end
114 114
 
115
+local function getColorByKills(kills)
116
+  if kills < 2 then
117
+    return 'red'
118
+  elseif kills < 3 then
119
+    return 'yellow'
120
+  end
121
+
122
+  return 'green'
123
+end
124
+
115 125
 function onUnjustifiedPointsChange(unjustifiedPoints)
116 126
   if unjustifiedPoints.skullTime == 0 then
117 127
     skullTimeLabel:setText('No skull')
@@ -122,14 +132,17 @@ function onUnjustifiedPointsChange(unjustifiedPoints)
122 132
   end
123 133
 
124 134
   dayProgressBar:setValue(unjustifiedPoints.killsDay, 0, 100)
125
-  dayProgressBar:setTooltip(string.format('Unjustified points gained during the last 24 hours.\n%i kills left.', unjustifiedPoints.killsDayRemaining))
126
-  dayProgressBar:setText(unjustifiedPoints.killsDayRemaining .. ' kills left')
135
+  dayProgressBar:setBackgroundColor(getColorByKills(unjustifiedPoints.killsDayRemaining))
136
+  dayProgressBar:setTooltip(string.format('Unjustified points gained during the last 24 hours.\n%i kill%s left.', unjustifiedPoints.killsDayRemaining, (unjustifiedPoints.killsDayRemaining == 1 and '' or 's')))
137
+  dayProgressBar:setText(string.format('%i kill%s left',  unjustifiedPoints.killsDayRemaining, (unjustifiedPoints.killsDayRemaining == 1 and '' or 's')))
127 138
 
128 139
   weekProgressBar:setValue(unjustifiedPoints.killsWeek, 0, 100)
129
-  weekProgressBar:setTooltip(string.format('Unjustified points gained during the last 7 days.\n%i kills left.', unjustifiedPoints.killsWeekRemaining))
130
-  weekProgressBar:setText(unjustifiedPoints.killsWeekRemaining .. ' kills left')
140
+  weekProgressBar:setBackgroundColor(getColorByKills(unjustifiedPoints.killsWeekRemaining))
141
+  weekProgressBar:setTooltip(string.format('Unjustified points gained during the last 7 days.\n%i kill%s left.', unjustifiedPoints.killsWeekRemaining, (unjustifiedPoints.killsWeekRemaining == 1 and '' or 's')))
142
+  weekProgressBar:setText(string.format('%i kill%s left',  unjustifiedPoints.killsWeekRemaining, (unjustifiedPoints.killsWeekRemaining == 1 and '' or 's')))
131 143
 
132 144
   monthProgressBar:setValue(unjustifiedPoints.killsMonth, 0, 100)
133
-  monthProgressBar:setTooltip(string.format('Unjustified points gained during the last 30 days.\n%i kills left.', unjustifiedPoints.killsMonthRemaining))
134
-  monthProgressBar:setText(unjustifiedPoints.killsMonthRemaining .. ' kills left')
145
+  monthProgressBar:setBackgroundColor(getColorByKills(unjustifiedPoints.killsMonthRemaining))
146
+  monthProgressBar:setTooltip(string.format('Unjustified points gained during the last 30 days.\n%i kill%s left.', unjustifiedPoints.killsMonthRemaining, (unjustifiedPoints.killsMonthRemaining == 1 and '' or 's')))
147
+  monthProgressBar:setText(string.format('%i kill%s left',  unjustifiedPoints.killsMonthRemaining, (unjustifiedPoints.killsMonthRemaining == 1 and '' or 's')))
135 148
 end

Loading…
Cancel
Save