Added GUI library

This commit is contained in:
MaddoScientisto 2024-04-27 18:36:48 +02:00
commit be12987894
4 changed files with 778 additions and 42 deletions

View file

@ -58,6 +58,8 @@ local weapons_manager = require(make_path("weapons"))
local Barrel = require(make_path("barrel"))
local Strawberry = require(make_path("strawberry"))
include(make_path("pgui" .. ".lua"))
tile_width = 16
tile_height = 16
@ -65,10 +67,14 @@ function _init()
spawn_objects()
cirnoInstance = Cirno.init()
add(actors,cirnoInstance)
slidervalue = 10
end
function _update()
--cirno.update()
pgui:refresh()
weapons_manager.update()
@ -83,6 +89,16 @@ function _update()
for p in all(particles) do
p:update()
end
--slidervalue = pgui:component("hslider",{pos=vec(190,20),value=slidervalue})
pgui:component("vstack",{stroke=true,height=0,margin=3,gap=3,contents={
{"text_box",{text=string.format("Actors: %d", count(actors)),margin=2,stroke=true,active=false,hover=false}},
{"text_box",{text=string.format("%.4f %dfps",stat(1),stat(7)),margin=2,stroke=true,active=false,hover=false}},
{"text_box",{text=string.format("Bullets: %d", count(bullets)),margin=2,stroke=true,active=false,hover=false}},
}})
--pgui:component("text_box",{text=string.format("Actors: %d", count(actors)),margin=2,stroke=true,active=false,hover=false})
end
LAYERS = {
@ -114,18 +130,25 @@ function _draw()
foreach(LAYERS, render_layer)
local mx,my = mouse()
camera()
mouse_debug.draw(mx,my,4, tile_width, tile_height)
camera()
-- Draw UI
draw_ui()
weapons_manager.debug_draw()
--circfill(240,140,slidervalue,8)
end
function draw_ui()
print(string.format("Actors: %d", count(actors)),0,32+8)
print(string.format("%.4f %dfps",stat(1),stat(7)),2,16,5)
pgui:draw()
--print(string.format("Actors: %d", count(actors)),0,32+8)
--print(string.format("%.4f %dfps",stat(1),stat(7)),2,16,5)
end