ui bug?
This commit is contained in:
parent
a167c92d2c
commit
1ad9014fb1
3 changed files with 36 additions and 11 deletions
|
|
@ -6,16 +6,19 @@ import "luxe: ui/list" for UIList
|
||||||
import "luxe: ui/button" for UIButton
|
import "luxe: ui/button" for UIButton
|
||||||
import "luxe: ui/image" for UIImage
|
import "luxe: ui/image" for UIImage
|
||||||
import "luxe: assets" for Assets
|
import "luxe: assets" for Assets
|
||||||
|
import "luxe: ui/text" for UIText
|
||||||
|
|
||||||
import "globals" for Globals
|
import "globals" for Globals
|
||||||
import "blocks/ui/image_button" for ImageButton
|
import "blocks/ui/image_button" for ImageButton
|
||||||
import "math/observable" for Observable
|
import "math/observable" for Observable
|
||||||
import "blocks/human/human" for Human
|
import "blocks/ui/simple_text" for UISimpleText
|
||||||
|
|
||||||
class Ui{
|
class Ui{
|
||||||
static Planning{"planning"}
|
static Planning{"planning"}
|
||||||
static Info {"info"}
|
static Info {"info"}
|
||||||
|
|
||||||
|
font{"assets/fonts/BabyBlocks"}
|
||||||
|
|
||||||
ui_mode{_ui_mode.value}
|
ui_mode{_ui_mode.value}
|
||||||
ui_mode=(v){_ui_mode.value = v}
|
ui_mode=(v){_ui_mode.value = v}
|
||||||
|
|
||||||
|
|
@ -40,7 +43,6 @@ class Ui{
|
||||||
}
|
}
|
||||||
|
|
||||||
game.Focus.on_change() {|val|
|
game.Focus.on_change() {|val|
|
||||||
System.print(val)
|
|
||||||
ui_mode = Ui.Info
|
ui_mode = Ui.Info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,13 +85,12 @@ class Ui{
|
||||||
ui_mode = Ui.Planning
|
ui_mode = Ui.Planning
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//info
|
//info
|
||||||
button = list_button(list)
|
button = list_button(list)
|
||||||
UIImage.set_image(button, adventureButtons)
|
UIImage.set_image(button, adventureButtons)
|
||||||
ImageButton.set_tooltip(button, "Stats")
|
ImageButton.set_tooltip(button, "Stats")
|
||||||
ImageButton.set_tile_uv(button, tiles, [2, 0])
|
ImageButton.set_tile_uv(button, tiles, [2, 0])
|
||||||
Control.child_add(list, button)
|
|
||||||
|
|
||||||
//read diary
|
//read diary
|
||||||
button = list_button(list)
|
button = list_button(list)
|
||||||
|
|
@ -105,6 +106,12 @@ class Ui{
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_info_human(root){
|
setup_info_human(root){
|
||||||
|
var portrait = UIImage.create(_ui)
|
||||||
|
Control.set_pos(portrait, 1, 1)
|
||||||
|
Control.set_size(portrait, 30, 46)
|
||||||
|
Control.set_id(portrait, "person info portrait")
|
||||||
|
Control.child_add(root, portrait)
|
||||||
|
|
||||||
var frame = UIImage.create(_ui)
|
var frame = UIImage.create(_ui)
|
||||||
UIImage.set_image(frame, Assets.image("assets/wip/Frame"))
|
UIImage.set_image(frame, Assets.image("assets/wip/Frame"))
|
||||||
Control.set_pos(frame, 1, 1)
|
Control.set_pos(frame, 1, 1)
|
||||||
|
|
@ -112,16 +119,14 @@ class Ui{
|
||||||
Control.set_id(frame, "person info frame")
|
Control.set_id(frame, "person info frame")
|
||||||
Control.child_add(root, frame)
|
Control.child_add(root, frame)
|
||||||
|
|
||||||
var portrait = UIImage.create(_ui)
|
|
||||||
Control.set_size(portrait, 30, 46)
|
|
||||||
Control.set_id(portrait, "person info portrait")
|
|
||||||
Control.child_add(frame, portrait)
|
|
||||||
|
|
||||||
Globals["Game"].Focus.on_change(true) {|val|
|
Globals["Game"].Focus.on_change(true) {|val|
|
||||||
//todo: more sophisticated portrait generation
|
//todo: more sophisticated portrait generation
|
||||||
UIImage.set_image(portrait, Assets.image("assets/wip/Portrait"))
|
UIImage.set_image(portrait, Assets.image("assets/wip/Portrait"))
|
||||||
UIImage.set_color(portrait, Human.get_color(val) || [1, 1, 1, 1])
|
UIImage.set_color(portrait, Human.get_color(val) || [0, 0, 0, 1])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var name = Control.create(_ui)
|
||||||
|
Control.set_pos(name, 32, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_planning(){
|
setup_planning(){
|
||||||
|
|
@ -191,6 +196,7 @@ class Ui{
|
||||||
var i = Control.child_index(parent, button)
|
var i = Control.child_index(parent, button)
|
||||||
Control.set_size(button, 16, 16)
|
Control.set_size(button, 16, 16)
|
||||||
Control.set_pos(button, i*16, 0) //let list handle this in future
|
Control.set_pos(button, i*16, 0) //let list handle this in future
|
||||||
|
System.print("%(Control.get_pos_x(button)), %(Control.get_pos_y(button))")
|
||||||
return button
|
return button
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,5 +204,6 @@ class Ui{
|
||||||
ImageButton.get_data(_test)
|
ImageButton.get_data(_test)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//this is behind the class def to make cyclic dependency happy lol
|
//this is behind the class def to make cyclic dependency happy lol
|
||||||
import "blocks/human/human" for Human
|
import "blocks/human/human" for Human
|
||||||
18
Luxe/blocks/ui/simple_text.wren
Normal file
18
Luxe/blocks/ui/simple_text.wren
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import "luxe: ui/control" for Control
|
||||||
|
|
||||||
|
class UISimpleText{
|
||||||
|
|
||||||
|
static create(ent){
|
||||||
|
var text = Control.create(ent)
|
||||||
|
|
||||||
|
Control.set_render(text) {|control, state, x,y,w,h|
|
||||||
|
//System.print(control)
|
||||||
|
}
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
static set_text(con, text){
|
||||||
|
System.print(text)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -14,5 +14,5 @@ engine = {
|
||||||
depth = 0
|
depth = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
//ui.debug_vis = true
|
ui.debug_vis = true
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue