must test if the texture doesnt shift if i change the resolution and sutch things
the rest is transparancy. its simple to use and modify though i changed the recource disposition so its diferent than the normal one
so i just changed the border colour and the background colour to look transparent and its a fairly easy process
x and y coordinates that are mentioned on regrest buildbar menu lua files and some more stuff.........
the lua file that contains the new recource management and the background image as i call it is below
Code: Select all
function gadget:GetInfo()
return {
name = "Simple GUI",
desc = "AR GUI",
author = "scifi",
date = "March 2009",
license = "Free",
layer = 0,
enabled = true,
}
end
local InitialWait = 0
local Frame, TeamNum, TeamSide
local currentLevelEnergy, storageEnergy, pullEnergy, incomeEnergy, expenseEnergy
local currentLevelMetal, storageMetal, pullMetal, incomeMetal, expenseMetal
local eco
if (gadgetHandler:IsSyncedCode()) then
function gadget:GameFrame(f)
if (f < InitialWait) then return
else
local temp = Spring.GetTeamList()
for _,Team in ipairs(temp) do
currentLevelEnergy, storageEnergy, pullEnergy, incomeEnergy, expenseEnergy = Spring.GetTeamResources(Team, 'energy')
currentLevelMetal, storageMetal, pullMetal, incomeMetal, expenseMetal = Spring.GetTeamResources(Team, 'metal')
eco = Spring.SendCommands("tooltip 0", "resbar 0")
currentLevelEnergy = math.floor(currentLevelEnergy)
currentLevelMetal = math.floor(currentLevelMetal)
incomeEnergy = math.floor(incomeEnergy)
incomeMetal = math.floor(incomeMetal)
Frame = f
SendToUnsynced("Resources", Team, 0, 0, incomeEnergy, incomeMetal, currentLevelEnergy, currentLevelMetal, storageEnergy, storageMetal, Frame)
end
if InitialWait == 1 then InitialWait = InitialWait + 31 else InitialWait = InitialWait + 32 end
end
end
else
local team, metalPercent, energyPercent, metalChange, energyChange, oldMetal, oldEnergy, metalStorage, energyStorage = 0,0,0,0,0,0,0,0,0
local metal, energy, energySent, metalSent = 0,0,0,0
local IncomeEnergy, IncomeMetal = 0,0
local MetalValueRed, MetalValueGreen
local EnergyValueBlue, EnergyValueRed, EnergyValueGreen
local MetalXMin, MetalXMax, MetalYMin, MetalYMax
local EnergyXMin, EnergyXMax, EnergyYMin, EnergyYMax
local BackGroundXMin, BackGroundYMin, BackGroundXMax, BackGroundYMax
local buttonBackXMin, buttonBackYMin, buttonBackXMax, buttonBackYMax
local EnergyStorageX, EnergyStorageY, MetalStorageX, MetalStorageY
local EnergyChangeX, EnergyChangeY, MetalChangeX, MetalChangeY
local textSize, background, buttonBack
local backgroundoffset = 0
local backgroundheight = 0
local frame = 0
local GL_ONE = GL.ONE
local GL_ZERO = GL.ZERO
local GL_DST_COLOR = GL.DST_COLOR
local GL_LESS = GL.LESS
local glTexRect = gl.TexRect
local glColor = gl.Color
local glDepthTest = gl.DepthTest
local glTexture = gl.Texture
local glText = gl.Text
local glBlending = gl.Blending
local glGetViewSizes = gl.GetViewSizes
local IsGUIHidden = Spring.IsGUIHidden
local GetLocalTeamID = Spring.GetLocalTeamID
buttonBack = ':anl:bitmaps/ui/ButtonTop.png'
background = ':anl:bitmaps/ui/NewGUItex.png'
backgroundheight = 1.396667 --current height in pixels, divided by 1200
function gadget:RecvFromSynced(name, Team, TeamNum, TeamSide, incomeEnergy, incomeMetal, currentLevelEnergy, currentLevelMetal, storageEnergy, storageMetal, Frame)
if (name == 'Resources') then
team = GetLocalTeamID()
if team == Team then
local x,y = glGetViewSizes()
textSize = 15 * (x / 1600)
IncomeEnergy = incomeEnergy
IncomeMetal = incomeMetal
metalStorage = storageMetal
energyStorage = storageEnergy
metal = currentLevelMetal
energy = currentLevelEnergy
metalPercent = metal / metalStorage
energyPercent = energy / energyStorage
metalChange = oldMetal - metal
energyChange = oldEnergy - energy
frame = Frame
if energyChange < 0 then energyChange = (energyChange * -1) else energyChange = energy - oldEnergy end
if metalChange < 0 then metalChange = (metalChange * -1) else metalChange = metal - oldMetal end
BackGroundXMin = 0
BackGroundXMax = x
BackGroundYMin = 0
BackGroundYMax = y * backgroundheight
buttonBackXMin = x * 0.84 -- 1600 - 256 / 1600
buttonBackYMin = y * backgroundheight
buttonBackXMax = x
buttonBackYMax = y * (backgroundheight * 2)
MetalChangeX = x * 0.513
MetalChangeY = y * 0.0785
EnergyChangeX = x * 0.513
EnergyChangeY = y * 0.0335
MetalX = x * 0.668
MetalY = y * 0.0785
EnergyX = x * 0.668
EnergyY = y * 0.0335
MetalStorageX = x * 0.752
MetalStorageY = y * 0.0565
EnergyStorageX = x * 0.752
EnergyStorageY = y * 0.0125
MetalXMin = x * (0.405)
MetalXMax = x * (0.405 + (0.328 * metalPercent))--0.015
MetalYMin = y * (0.0615)
MetalYMax = y * (0.0675) --0.0045
--if (metalPercent) > 0.5 then MetalValueRed = 1.0 - (metalPercent) else MetalValueRed = 1.0 end
--if (metalPercent) < 0.5 then MetalValueGreen = 0.0 + (metalPercent) else MetalValueGreen = 1.0 end
EnergyXMin = x * (0.405)
EnergyXMax = x * (0.405 + (0.328 * energyPercent))
EnergyYMin = y * (0.0175)
EnergyYMax = y * (0.0235)
--if (energyPercent) > 0.5 then EnergyValueGreen = 1.0 - (energyPercent) else EnergyValueGreen = 1.0 end
--if (energyPercent) < 0.5 then EnergyValueBlue = 0.0 + (energyPercent) else EnergyValueBlue = 1.0 end
oldMetal = metal
oldEnergy = energy
end
end
end
function gadget:DrawScreenEffects()
if frame > 30 then
if IsGUIHidden() == false then
-------------------------------------------------------------BackGround
glColor(1,1,1,1)
glTexture(background)
glTexRect(BackGroundXMin,BackGroundYMin,BackGroundXMax,BackGroundYMax)
glTexture(buttonBack)
glTexRect(buttonBackXMin,buttonBackYMin,buttonBackXMax,buttonBackYMax)
-------------------------------------------------------------BackGround
-------------------------------------------------------------Resource Bars
glTexture('bitmaps/ui_bar.tga')
glColor(0.0, 1.0, 1.0, 1.0)
glTexRect(MetalXMin, MetalYMin, MetalXMax, MetalYMax)
glColor(1.0, 0.9, 0.0, 1.0)
glTexRect(EnergyXMin, EnergyYMin, EnergyXMax, EnergyYMax)
-------------------------------------------------------------Resource Bars
-------------------------------------------------------------Text
glColor(1.0,0.6,0,1.0)
glText(metal, MetalX, MetalY, textSize, "n")
glColor(1.0,0.6,0,1.0)
glText(metalStorage, MetalStorageX, MetalStorageY, textSize, "n")
glColor(1.0,0.6,0,1.0)
--concatenate operation ".." == "concatenate these two things"
glText(metalChange.." / "..IncomeMetal, MetalChangeX, MetalChangeY, textSize, "n")
glColor(0.0,0.8,1.0,1.0)
glText(energy, EnergyX, EnergyY, textSize, "n")
glColor(0.0,0.8,1.0,1.0)
glText(energyStorage, EnergyStorageX, EnergyStorageY, textSize, "n")
glColor(0.0,0.8,1.0,1.0)
--another concatenate operation
glText(energyChange.." / "..IncomeEnergy, EnergyChangeX, EnergyChangeY, textSize, "n")
end
end
end
end