Compare commits
No commits in common. "1ad9014fb18a124703ff3c1d3961e4cda63e0afd" and "d5147eb33aed10977f2d6836ba8d52148e260a6b" have entirely different histories.
1ad9014fb1
...
d5147eb33a
4 changed files with 27 additions and 51 deletions
|
|
@ -5,6 +5,9 @@ import "math/util" for Util
|
|||
import "globals" for Globals
|
||||
import "luxe: assets" for Strings
|
||||
import "luxe: input" for Input, MouseButton
|
||||
import "blocks/ui" for Ui
|
||||
|
||||
System.print("ui is: %(Ui)")
|
||||
|
||||
//User facing API
|
||||
//This is what the user of your modifier will interact with
|
||||
|
|
@ -47,12 +50,12 @@ class Human {
|
|||
//to do the actual work. You'll get notified when things change
|
||||
//in the world and respond to them here.
|
||||
class HumanSystem is ModifierSystem {
|
||||
|
||||
player_start{[26, 89]}
|
||||
player_size{[10, 12]}
|
||||
|
||||
construct new() {
|
||||
//called when your system is first created.
|
||||
|
||||
}
|
||||
|
||||
init(world) {
|
||||
|
|
@ -77,8 +80,8 @@ class HumanSystem is ModifierSystem {
|
|||
}
|
||||
|
||||
tick(delta) {
|
||||
//called usually once every frame.
|
||||
//called when the world that this modifier lives in, is ticked
|
||||
//called usually once every frame.
|
||||
//called when the world that this modifier lives in, is ticked
|
||||
each {|entity, data|
|
||||
if(!data.active) return
|
||||
|
||||
|
|
@ -89,19 +92,21 @@ class HumanSystem is ModifierSystem {
|
|||
_hoverEnt = entity
|
||||
Globals["Tooltip"].set(Strings.get(data.name), entity)
|
||||
}
|
||||
if(Input.mouse_state_pressed(MouseButton.left)){
|
||||
|
||||
var game = Globals["Game"]
|
||||
System.print(Ui)
|
||||
import "blocks/ui" for Ui
|
||||
if(game.ui.ui_mode == Ui.Info){
|
||||
game.Focus.value = entity
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!over && _hoverEnt == entity){
|
||||
_hoverEnt = null
|
||||
Globals["Tooltip"].clear(entity)
|
||||
}
|
||||
}
|
||||
|
||||
if(Input.mouse_state_pressed(MouseButton.left)){
|
||||
var game = Globals["Game"]
|
||||
if(game.ui.ui_mode == Ui.Info && _hoverEnt){ //remove &&hoverEnt to allow unfocussing
|
||||
game.Focus.value = _hoverEnt
|
||||
}
|
||||
}
|
||||
} //tick
|
||||
|
||||
update(){
|
||||
|
|
@ -127,5 +132,3 @@ class HumanSystem is ModifierSystem {
|
|||
} //HumanSystem
|
||||
|
||||
var Modifier = HumanSystem //required
|
||||
|
||||
import "blocks/ui" for Ui //import at the end in case of cyclic dependency
|
||||
|
|
@ -6,19 +6,16 @@ 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 "globals" for Globals
|
||||
import "blocks/ui/image_button" for ImageButton
|
||||
import "math/observable" for Observable
|
||||
import "blocks/ui/simple_text" for UISimpleText
|
||||
import "blocks/human/human" for Human
|
||||
|
||||
class Ui{
|
||||
static Planning{"planning"}
|
||||
static Info {"info"}
|
||||
|
||||
font{"assets/fonts/BabyBlocks"}
|
||||
|
||||
ui_mode{_ui_mode.value}
|
||||
ui_mode=(v){_ui_mode.value = v}
|
||||
|
||||
|
|
@ -43,6 +40,7 @@ class Ui{
|
|||
}
|
||||
|
||||
game.Focus.on_change() {|val|
|
||||
System.print(val)
|
||||
ui_mode = Ui.Info
|
||||
}
|
||||
|
||||
|
|
@ -85,12 +83,13 @@ class Ui{
|
|||
ui_mode = Ui.Planning
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//info
|
||||
button = list_button(list)
|
||||
UIImage.set_image(button, adventureButtons)
|
||||
ImageButton.set_tooltip(button, "Stats")
|
||||
ImageButton.set_tile_uv(button, tiles, [2, 0])
|
||||
Control.child_add(list, button)
|
||||
|
||||
//read diary
|
||||
button = list_button(list)
|
||||
|
|
@ -106,12 +105,6 @@ class Ui{
|
|||
}
|
||||
|
||||
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)
|
||||
UIImage.set_image(frame, Assets.image("assets/wip/Frame"))
|
||||
Control.set_pos(frame, 1, 1)
|
||||
|
|
@ -119,14 +112,16 @@ class Ui{
|
|||
Control.set_id(frame, "person info 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|
|
||||
//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])
|
||||
UIImage.set_color(portrait, Human.get_color(val) || [1, 1, 1, 1])
|
||||
}
|
||||
|
||||
var name = Control.create(_ui)
|
||||
Control.set_pos(name, 32, 1)
|
||||
}
|
||||
|
||||
setup_planning(){
|
||||
|
|
@ -196,14 +191,10 @@ class Ui{
|
|||
var i = Control.child_index(parent, button)
|
||||
Control.set_size(button, 16, 16)
|
||||
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
|
||||
}
|
||||
|
||||
test(){
|
||||
ImageButton.get_data(_test)
|
||||
}
|
||||
}
|
||||
|
||||
//this is behind the class def to make cyclic dependency happy lol
|
||||
import "blocks/human/human" for Human
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
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
|
||||
}
|
||||
|
||||
ui.debug_vis = true
|
||||
//ui.debug_vis = true
|
||||
}
|
||||
Loading…
Reference in a new issue