Jump to content

bug with latest update?


Recommended Posts

Hi,

 

after the Update with the betabuild i get now this error ?

 

self.curResolution = Vec2(FG_window:GetWidth(), FG_window:GetHeight())

 

"fg_manager.lua" : 45 : attempt to call method 'GetWidth' (a nil value)"

 

I haven't had a problem before the update. Is there something i have to change?

 

 

Script.curResolution = Vec2(0,0)
Script.scalar = Vec2(0,0)
Script.engineFont = nil
FG_window = nil
FG_context = nil
FG_LDown = false
FG_LHit = false
FG_DRAGITEMSLOT = nil
FG_activeDropdown = nil
FG_guiElements = {}
FG_Types =
{
button = 1,
label = 2,
checkbox = 3,
slider = 4,
panel = 5,
radio = 6,
textbox = 7,
dropdown = 8,
image = 9,
itemslot = 10,
panel = 11,
arealabel = 12
}
FG_Layer =
{
background = 3,
default = 10,
front = 20
}
function Script:Start()
if FG_loadedTexts == nil then
FG_loadedTexts = {}
end

FG_window = Window:GetCurrent()
FG_context = Context:GetCurrent()
self.engineFont = FG_context:GetFont()
self.curResolution = Vec2(FG_window:GetWidth(), FG_window:GetHeight())
self:CalculateScalar()
end
function Script:GetResolution()
return self.curResolution
end
function Script:SetResolution(res, changeScreenResolution)
if changeScreenResolution then
FG_window:SetLayout(0,0,res.x, res.y)
end

self.curResolution = Vec2(res.x, res.y)
self:CalculateScalar()
self:ApplyScalarToElements()
end
function Script:CalculateScalar()
self.scalar = Vec2(self.curResolution.x / 1920, self.curResolution.y / 1080)
end
function Script:ApplyScalarToElements()
for key, guiElement in pairs(FG_guiElements) do
if guiElement:GetResolutionScaling()then
guiElement:ApplyScalar(self.scalar)
end
end
end
function Script:AddElement(guiElement)
local newLayer = guiElement:GetLayer()
local guiCount = 0
for _ in pairs(FG_guiElements) do guiCount = guiCount + 1 end

if guiCount > 0 then
for i = 1, guiCount do
if newLayer < FG_guiElements[i]:GetLayer() then
table.insert(FG_guiElements, i, guiElement)
break
end

if i == guiCount then
table.insert(FG_guiElements, guiElement)
end
end
else
table.insert(FG_guiElements, guiElement)
end
end
function Script:RemoveElement(guiElement)
for i = 1, #FG_guiElements do
if FG_guiElements[i] == guiElement then
FG_guiElements[i]:Release()
table.remove(FG_guiElements, i)
break
end
end
end
function GetGuiElements(guiType)
local elementsOfType = {}
for key, guiElement in pairs(FG_guiElements) do
if guiElement.type == guiType then
table.insert(elementsOfType, guiElement)
end

--look through the panel items
if guiElement.type == FG_Types.panel then
for key, panelGUIElement in pairs(guiElement.children) do
if panelGUIElement.type == guiType then
 table.insert(elementsOfType, panelGUIElement)
end
end
end
end
return elementsOfType
end
function Script:UpdateWorld()
FG_LDown = false
FG_LHit = false
if FG_window:MouseHit(1) then FG_LHit = true end
if FG_window:MouseDown(1) then FG_LDown = true end

for key, guiElement in pairs(FG_guiElements) do
if guiElement.enabled then
guiElement:Update()
end
end
--You can incomment these code lines for quick testing of resolution swapping
--SetLayout will change the window but not the guielements
--SetResolution will change the window and the guielements
if FG_window:KeyHit(Key.Q) then
--FG_window:SetLayout(0,0,1920, 1080);
self:SetResolution(Vec2(1920, 1080))
elseif FG_window:KeyHit(Key.E) then
--FG_window:SetLayout(0,0,1440, 900);
self:SetResolution(Vec2(1440, 900))
end
end
function Script:PostRender(context)
for key, guiElement in ipairs(FG_guiElements) do
if guiElement.enabled then
guiElement:Draw()
end
end

FG_context:SetFont(self.engineFont)
end
function Script:HideGroup(group)
for key, guiElement in pairs(FG_guiElements) do
if guiElement.group == group then
guiElement.enabled = false
end
end
end
function Script:ShowGroup(group)
for key, guiElement in pairs(FG_guiElements) do
if guiElement.group == group then
guiElement.enabled = true
end
end
end
function Script:Detach()
for key, guiElement in ipairs(FG_guiElements) do
guiElement:Release()
end
end

Link to comment
Share on other sites

Thanks for finding that. The Window class is being rewritten to add new functionality. I went through the documentation and made sure all documented commands are exposed to Lua. Until I upload a new build, use context:GetWidth() / Height() to get the resolution. This is the correct way to do it anyways, since the width of the window will include extra space for the borders and titlebar.

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...