Jump to content

ui:SetScale(1.25) Crash App


Go to solution Solved by Josh,

Recommended Posts

Posted

The command when put in an event or in a main loop crashes the application. It is to change the size of the Ui in real time.


 

  elseif ev.source == _cmbBixUIScale then
                    UpdateApplyButton()
                    ui:SetScale(1.25) --<<< crash app.
              
                elseif ev.source == _tabOptions then

 

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

Posted

Here is an example that shows it working:

-- Get the displays
local displays = GetDisplays()

-- Create window
local window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[1], WINDOW_TITLEBAR | WINDOW_RESIZABLE)
window:SetMinSize(640, 480)

-- Create user interface
local ui = CreateInterface(window)

-- Create widgets
local sz = ui.background:ClientSize()

local leftpanel = CreatePanel(10, 10, 200, sz.y - 20, ui.background)
leftpanel:SetLayout(1, 0, 1, 1)
leftpanel:SetColor(0, 0, 0, 1)

local rightpanel = CreatePanel(sz.x - 10 - 200, 10, 200, sz.y - 20, ui.background)
rightpanel:SetLayout(0, 1, 1, 1)
rightpanel:SetColor(0, 0, 0, 1)

local mainpanel = CreatePanel(10 + 200 + 10, 10, sz.x - 10 * 4 - 200 * 2, sz.y - 10 * 3 - 100, ui.background)
mainpanel:SetLayout(1, 1, 1, 1)
mainpanel:SetColor(0, 0, 0, 1)

local bottompanel = CreatePanel(10 + 200 + 10, sz.y - 10 - 100, sz.x - 10 * 4 - 200 * 2, 100, ui.background)
bottompanel:SetLayout(1, 1, 0, 1)
bottompanel:SetColor(0, 0, 0, 1)

while true do
    local ev = WaitEvent()
	if ev.id == EVENT_KEYDOWN and ev.data == KEY_SPACE then
		ui:SetScale(1.25)
	end	
    if ev.id == EVENT_WINDOWCLOSE and ev.source == window then
        break
    end
end

 

  • Like 1

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

  • Solution
Posted

Here is another working example that uses 3D rendering:

--Get the displays
local displays = GetDisplays()

--Create window
local window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[1])

--Create framebuffer
local framebuffer = CreateFramebuffer(window)

--Create world
local world = CreateWorld()

--Create camera
local camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC)
camera:SetPosition(framebuffer.size.x * 0.5, framebuffer.size.y * 0.5, 0)

--Load a font
local font = LoadFont("Fonts/arial.ttf")

--Create user interface
local ui = CreateInterface(camera, font, framebuffer.size)

--Create widget
local sz = ui.background:ClientSize()
local button = CreateButton("Button", sz.x / 2 - 75, sz.y / 2 - 15, 150, 30, ui.background)

while not window:KeyDown(KEY_ESCAPE) do
    while (PeekEvent()) do
        local ev = WaitEvent()
		if ev.id == EVENT_KEYDOWN and ev.data == KEY_SPACE then
			ui:SetScale(1.25)
		end
        if (ev.id == EVENT_WINDOWCLOSE and ev.source == window) then
            return 0
        else
            ui:ProcessEvent(ev)
        end
    end

    world:Update()
    world:Render(framebuffer)
end

 

  • Like 1

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...