Browse Source

Merge pull request #990 from EgzoT/EgzoT-Show_more_information_in_stamina_bar_2

Show more information in stamina bar
Konrad Kuśnierz 1 year ago
parent
commit
d563aafbc9
No account linked to committer's email address
1 changed files with 31 additions and 3 deletions
  1. 31
    3
      modules/game_skills/skills.lua

+ 31
- 3
modules/game_skills/skills.lua View File

@@ -120,7 +120,7 @@ function setSkillTooltip(id, value)
120 120
   widget:setTooltip(value)
121 121
 end
122 122
 
123
-function setSkillPercent(id, percent, tooltip)
123
+function setSkillPercent(id, percent, tooltip, color)
124 124
   local skill = skillsWindow:recursiveGetChildById(id)
125 125
   local widget = skill:getChildById('percent')
126 126
   if widget then
@@ -129,6 +129,10 @@ function setSkillPercent(id, percent, tooltip)
129 129
     if tooltip then
130 130
       widget:setTooltip(tooltip)
131 131
     end
132
+
133
+    if color then
134
+    	widget:setBackgroundColor(color)
135
+    end
132 136
   end
133 137
 end
134 138
 
@@ -333,10 +337,34 @@ function onStaminaChange(localPlayer, stamina)
333 337
   if minutes < 10 then
334 338
     minutes = '0' .. minutes
335 339
   end
336
-  local percent = math.floor(100 * stamina / (42 * 60)) -- max is 42 hours
340
+  local percent = math.floor(100 * stamina / (42 * 60)) -- max is 42 hours --TODO not in all client versions
337 341
 
338 342
   setSkillValue('stamina', hours .. ":" .. minutes)
339
-  setSkillPercent('stamina', percent, tr('You have %s percent', percent))
343
+
344
+  --TODO not all client versions have premium time
345
+  if stamina > 2400 and g_game.getClientVersion() >= 1038 and localPlayer:isPremium() then
346
+  	local text = tr("You have %s hours and %s minutes left", hours, minutes) .. '\n' ..
347
+		tr("Now you will gain 50%% more experience")
348
+		setSkillPercent('stamina', percent, text, 'green')
349
+	elseif stamina > 2400 and g_game.getClientVersion() >= 1038 and not localPlayer:isPremium() then
350
+		local text = tr("You have %s hours and %s minutes left", hours, minutes) .. '\n' ..
351
+		tr("You will not gain 50%% more experience because you aren't premium player, now you receive only 1x experience points")
352
+		setSkillPercent('stamina', percent, text, '#89F013')
353
+	elseif stamina > 2400 and g_game.getClientVersion() < 1038 then
354
+		local text = tr("You have %s hours and %s minutes left", hours, minutes) .. '\n' ..
355
+		tr("If you are premium player, you will gain 50%% more experience")
356
+		setSkillPercent('stamina', percent, text, 'green')
357
+	elseif stamina <= 2400 and stamina > 840 then
358
+		setSkillPercent('stamina', percent, tr("You have %s hours and %s minutes left", hours, minutes), 'orange')
359
+	elseif stamina <= 840 and stamina > 0 then
360
+		local text = tr("You have %s hours and %s minutes left", hours, minutes) .. "\n" ..
361
+		tr("You gain only 50%% experience and you don't may gain loot from monsters")
362
+		setSkillPercent('stamina', percent, text, 'red')
363
+	elseif stamina == 0 then
364
+		local text = tr("You have %s hours and %s minutes left", hours, minutes) .. "\n" ..
365
+		tr("You don't may receive experience and loot from monsters")
366
+		setSkillPercent('stamina', percent, text, 'black')
367
+	end
340 368
 end
341 369
 
342 370
 function onOfflineTrainingChange(localPlayer, offlineTrainingTime)

Loading…
Cancel
Save