import "luxe: draw" for Draw, PathStyle import "luxe: world" for Entity, Transform, UI, UIRenderMode import "luxe: world" for UILayout, UILayoutBehave, UILayoutContain 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: ui/text" for UIText import "luxe: render" for Material import "globals" for Globals import "blocks/ui/image_button" for ImageButton import "math/observable" for Observable import "math/stringUtil" for StringUtil import "blocks/ui/simple_text" for UISimpleText import "blocks/ui" for Ui import "blocks/human/human" for Human class UiInfo{ root{_root} static human{"human"} static diary{"diary"} static resources{"resources"} construct new(ent, ui){ _ent = ent _ui = ui _page = Observable.new(UiInfo.human) setup() } setup(){ var ui_rect = Globals["UiRect"] _root = Control.create(_ent) UILayout.set_behave(_ent, _root, UILayoutBehave.fill) UILayout.set_margin(_ent, _root, 0, 0, 0, 0) toolbar() human() diary() } toolbar(){ var ui_rect = Globals["UiRect"] //list var list = Control.create(_ent) Control.set_id(list, "info list") Control.child_add(_root, list) //make list span bottom area UILayout.set_behave(_ent, list, UILayoutBehave.left | UILayoutBehave.right | UILayoutBehave.bottom) //| UILayout.set_margin(_ent, list, 0, 0, 0, 0) UILayout.set_contain(_ent, list, UILayoutContain.row | UILayoutContain.start) //| Control.set_size(list, 16, 16) var adventureButtons = Assets.image("assets/AdventureButtons") var tiles = [10, 1] var button //plan adventure button = _ui.list_button(list) UIImage.set_image(button, adventureButtons) ImageButton.set_tooltip(button, "Adventure!") ImageButton.set_tile_uv(button, tiles, [1, 0]) ImageButton.set_state_change(button) { |data| if(data["press"]){ _ui.ui_mode = Ui.Planning } } //info button = _ui.list_button(list) UIImage.set_image(button, adventureButtons) ImageButton.set_tooltip(button, "Stats") ImageButton.set_tile_uv(button, tiles, [2, 0]) ImageButton.set_state_change(button) { |data| if(data["press"]){ _page.value = UiInfo.human } } //read diary button = _ui.list_button(list) UIImage.set_image(button, adventureButtons) ImageButton.set_tooltip(button, "Diary") ImageButton.set_tile_uv(button, tiles, [1, 0]) ImageButton.set_state_change(button) { |data| if(data["press"]){ _page.value = UiInfo.diary } } //resources button = _ui.list_button(list) UIImage.set_image(button, adventureButtons) ImageButton.set_tooltip(button, "Resources") ImageButton.set_tile_uv(button, tiles, [4, 0]) ImageButton.set_state_change(button) { |data| if(data["press"]){ _page.value = UiInfo.resources } } } human(){ var page = Control.create(_ent) Control.child_add(_root, page) UILayout.set_behave(_ent, page, UILayoutBehave.fill) UILayout.set_margin(_ent, page, 0, 0, 0, 16) _page.on_change(true){|val| Control.set_visible(page, val == UiInfo.human) } var portrait = UIImage.create(_ent) Control.set_size(portrait, 30, 46) Control.set_id(portrait, "person info portrait") Control.child_add(page, portrait) UILayout.set_behave(_ent, portrait, UILayoutBehave.left | UILayoutBehave.top) //| UILayout.set_margin(_ent, portrait, 1, 1, 0, 0) var frame = UIImage.create(_ent) UIImage.set_image(frame, Assets.image("assets/wip/Frame")) Control.set_pos(frame, 1, 1) Control.set_size(frame, 30, 46) Control.set_id(frame, "person info frame") Control.child_add(portrait, frame) Globals["Game"].Focus.on_change(true) {|val| //todo: more sophisticated portrait generation UIImage.set_image(portrait, Assets.image("assets/wip/Portrait")) UIImage.set_color(portrait, Human.get_color(val) || [0, 0, 0, 1]) } var statBlock = Control.create(_ent) Control.child_add(page, statBlock) UILayout.set_behave(_ent, statBlock, UILayoutBehave.fill) UILayout.set_margin(_ent, statBlock, 33, 1, 0, 16) UILayout.set_contain(_ent, statBlock, UILayoutContain.column | UILayoutContain.start) //| var name = UISimpleText.create(_ent) Control.child_add(statBlock, name) Control.set_id(name, "human name info") Globals["Game"].Focus.on_change(true) {|val| var name_string = Human.get_name(val) || "-" UISimpleText.set_text(name, name_string) } var adventures = UISimpleText.create(_ent) Control.child_add(statBlock, adventures) Control.set_id(name, "human adventure count") Globals["Game"].Focus.on_change(true) {|val| var count = Human.get_adventure_count(val) var text = count ? "Adventures: %(count)" : "" UISimpleText.set_text(adventures, text) } } diary(){ var page = Control.create(_ent) Control.child_add(_root, page) UILayout.set_behave(_ent, page, UILayoutBehave.fill) UILayout.set_margin(_ent, page, 0, 0, 0, 16) _page.on_change(true){|val| Control.set_visible(page, val == UiInfo.diary) } var title = UISimpleText.create(_ent) Control.child_add(page, title) Control.set_id(title, "human name info") UILayout.set_behave(_ent, title, UILayoutBehave.left | UILayoutBehave.top) //| UILayout.set_margin(_ent, title, 1, 1, 0, 0) Globals["Game"].Focus.on_change(true) {|val| var name = Human.get_name(val) var diary_title = name ? "%(StringUtil.possesive(name)) Diary" : "Diary" UISimpleText.set_text(title, diary_title) } } }