Skip to content

Commit

Permalink
Add simplified resource bar as default
Browse files Browse the repository at this point in the history
Add option in settings to toggle resource bar styles
  • Loading branch information
ForbodingAngel committed Mar 14, 2018
1 parent ad1c995 commit d81c01b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
3 changes: 3 additions & 0 deletions LuaUI/Widgets_Evo/gui_options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,8 @@ function applyOptionValue(i, skipRedrawWindow)
end
elseif id == 'resourceprompts' then
Spring.SetConfigInt("evo_resourceprompts",value)
elseif id == 'simplifiedresourcebar' then
Spring.SetConfigInt("evo_simplifiedresourcebar",value)
elseif id == 'buildpichelp' then
Spring.SetConfigInt("evo_buildpichelp",value)
elseif id == 'dynamicmusic' then
Expand Down Expand Up @@ -1823,6 +1825,7 @@ function init()
{id="buildpichelp", group="ui", name="Flashing Buildpic Help", type="bool", value=tonumber(Spring.GetConfigInt("evo_buildpichelp",1) or 1) == 1, description="Flashes relevant build menu items when resources are in a crisis situation"},

{id="resourceprompts", group="ui", name="Audio/Visual Resource Prompts", type="bool", value=tonumber(Spring.GetConfigInt("evo_resourceprompts",1) or 1) == 1, description="If enabled, messages will be sent to the chat as well as\naudio cues when your resources need attention"},
{id="simplifiedresourcebar", group="ui", name="Simplified Resource Bar", type="bool", value=tonumber(Spring.GetConfigInt("evo_simplifiedresourcebar",1) or 1) == 1, description="Removes extra information from the resource bar"},

--{id="fancyselunits", group="gfx", widget="Fancy Selected Units", name="Fancy Selected Units", type="bool", value=GetWidgetToggleValue("Fancy Selected Units"), description=''},

Expand Down
51 changes: 47 additions & 4 deletions LuaUI/Widgets_Evo/gui_resourceBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ local supplyWarning = false
local energyWarning = false
local metalWarning = false

simplifiedResourceBar = Spring.GetConfigInt("evo_simplifiedresourcebar", 1)

-- Avoids spamming of income increased notification
local incomeIncreased = false

Expand Down Expand Up @@ -156,6 +158,7 @@ function widget:GameFrame(n)
if n%450 == 4 then
local _, _, spectator = Spring.GetPlayerInfo(Spring.GetMyTeamID())
resourcePrompts = Spring.GetConfigInt("evo_resourceprompts", 1)
simplifiedResourceBar = Spring.GetConfigInt("evo_simplifiedresourcebar", 1)

--Assume that if it isn't set, resourcePrompts is true
if resourcePrompts == nil then
Expand Down Expand Up @@ -381,6 +384,10 @@ function generateDisplayList()
end

function generateDisplayList2()
local energyIncomeColor = green
local metalIncomeColor = green
local energyPosNeg = "+"
local metalPosNeg = "+"
if displayList2 ~= nil then
gl.DeleteList(displayList2)
end
Expand Down Expand Up @@ -434,8 +441,21 @@ function generateDisplayList2()
end
gl.TexRect(supplyOffset,0,supplyOffset+(supplyBarWidth*percentage),height/6)

supplyStr = white .. su .. "/" .. sm .. " (" .. orange .. "±" .. tostring(sm - su) .. white .. "/" .. green .. maxSupply .. white .. ") "
gl.Text(supplyStr, supplyOffset+supplyBarWidth, textOffsetY, FontSize, "onr")
if simplifiedResourceBar == 1 then
if su < (sm * 0.50) then
supplyUsedColor = green
elseif su > (sm * 0.50) then
supplyUsedColor = orange
if su >= (sm * 0.75) then
supplyUsedColor = red
end
end
supplyStr = supplyUsedColor .. su .. white .. "/" .. sm .. " "
else
supplyStr = white .. su .. "/" .. sm .. " (" .. orange .. "±" .. tostring(sm - su) .. white .. "/" .. green .. maxSupply .. white .. ") "
end
gl.Text(supplyStr, supplyOffset+supplyBarWidth, textOffsetY, FontSize, "onr")


-- energy bar
r, g, b = 0, 0, 0
Expand Down Expand Up @@ -465,7 +485,19 @@ function generateDisplayList2()
gl.TexRect(energyOffset+(energyBarWidth*energyPercentage)+glowSize+glowSize,-glowSize,energyOffset+(energyBarWidth*energyPercentage),(height/6)+glowSize)

gl.Texture(barTexture)
energyStr = green .. "+" .. tostring(math.round(ei,1)) .. white .. "/" .. red .. "-" .. tostring(math.round(ep,1)) .. white .. " (" .. yellow .. tostring(math.round(ec)).. white .. "/" .. tostring(math.round(es)) .. ") "

if simplifiedResourceBar == 1 then
if ei > ep then
energyIncomeColor = green
energyPosNeg = "+"
else
energyIncomeColor = red
energyPosNeg = ""
end
energyStr = energyIncomeColor .. energyPosNeg .. tostring(math.round(ei - ep,1)) .. white .. " (" .. yellow .. tostring(math.round(ec)).. white .. "/" .. tostring(math.round(es)) .. ") "
else
energyStr = green .. "+" .. tostring(math.round(ei,1)) .. white .. "/" .. red .. "-" .. tostring(math.round(ep,1)) .. white .. " (" .. yellow .. tostring(math.round(ec)).. white .. "/" .. tostring(math.round(es)) .. ") "
end
gl.Text(energyStr, energyOffset+energyBarWidth, textOffsetY, FontSize, "onr")

-- metal bar
Expand Down Expand Up @@ -517,7 +549,18 @@ function generateDisplayList2()
end
end

metalStr = orange .. "±" .. tostring(math.round(mi - me)) .. green .. " +" .. tostring(math.round(mi,1)) .. white .. "/" .. red .. "-" .. tostring(math.round(mp)) .. white .. " (" .. skyblue .. tostring(math.round(mc)) .. white .. "/" .. tostring(math.round(ms)) .. ") "
if simplifiedResourceBar == 1 then
if mi > mp then
metalIncomeColor = green
metalPosNeg = "+"
else
metalIncomeColor = red
metalPosNeg = ""
end
metalStr = metalIncomeColor .. metalPosNeg .. tostring(math.round(mi - mp,1)) .. white .. " (" .. skyblue .. tostring(math.round(mc)) .. white .. "/" .. tostring(math.round(ms)) .. ") "
else
metalStr = orange .. "±" .. tostring(math.round(mi - me)) .. green .. " +" .. tostring(math.round(mi,1)) .. white .. "/" .. red .. "-" .. tostring(math.round(mp)) .. white .. " (" .. skyblue .. tostring(math.round(mc)) .. white .. "/" .. tostring(math.round(ms)) .. ") "
end
gl.Text(metalStr, metalOffset+metalBarWidth, textOffsetY, FontSize, "onr")

gl.Texture(false)
Expand Down

0 comments on commit d81c01b

Please sign in to comment.