import "luxe: draw" for Draw, PathStyle import "luxe: world" for Entity, Transform, UI, UIRenderMode import "luxe: world" for UIBehave, UIContain import "luxe: ui/control" for Control import "luxe: ui/panel" for UIPanel import "luxe: ui/list" for UIList import "luxe: ui/button" for UIButton import "luxe: ui/image" for UIImage import "luxe: assets" for Assets import "luxe: asset" for Asset import "luxe: ui/text" for UIText import "luxe: render" for Material import "globals" for Globals import "blocks/ui/clickable" for Clickable import "blocks/ui/image_util" for UiImageUtil import "math/observable" for Observable import "blocks/ui/simple_text" for UISimpleText class Ui{ static Planning{"planning"} static Info {"info"} font{Asset.font("assets/fonts/BabyBlocks")} ui_mode{_ui_mode.value} ui_mode=(v){_ui_mode.value = v} planning{_planning} info{_info} entity{_ent} construct new(app){ var game = Globals["Game"] var ui_rect = Globals["UiRect"] _ui_mode = Observable.new(Ui.Info) _ent = Entity.create(app.ui, "UI Root") UI.create(_ent, ui_rect.x, ui_rect.y, ui_rect.width, ui_rect.height, 0, app.ui_camera) UI.set_render_mode(_ent, UIRenderMode.world) //UI.set_material_basis(_ent, "luxe: material_basis/ui_solid", "shaders/pixel_text_ui") _info = UiInfo.new(_ent, this) _planning = UiAdventure.new(_ent, this) _ui_mode.on_change(true) {|val| Control.set_visible(_planning.root, val == Ui.Planning) Control.set_visible(_info.root, val == Ui.Info) UI.commit(_ent) } UI.commit(_ent) } list_button(parent){ var button = UIImage.create(_ent) Clickable.make_clickable(button) Control.set_size(button, 16, 16) Control.child_add(parent, button) var adventureButtons = Assets.image("assets/wip/AdventureButtons") UIImage.set_image(button, adventureButtons) return button } list_button(parent, tile){ var tiles = [10, 1] var button = list_button(parent) UiImageUtil.set_tile_uv(button, tiles, tile) return button } list_button(parent, tile, tooltip){ var button = list_button(parent, tile) Clickable.set_tooltip(button, tooltip) return button } list_button(parent, tile, tooltip, pressFn){ var button = list_button(parent, tile, tooltip) Clickable.set_on_click(button) { pressFn.call() } return button } } //this is behind the class def to make cyclic dependency happy ^^ import "blocks/ui/info" for UiInfo import "blocks/ui/adventure" for UiAdventure