Compare commits
2 commits
d5147eb33a
...
1ad9014fb1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ad9014fb1 | ||
|
|
a167c92d2c |
4 changed files with 51 additions and 27 deletions
|
|
@ -5,9 +5,6 @@ import "math/util" for Util
|
||||||
import "globals" for Globals
|
import "globals" for Globals
|
||||||
import "luxe: assets" for Strings
|
import "luxe: assets" for Strings
|
||||||
import "luxe: input" for Input, MouseButton
|
import "luxe: input" for Input, MouseButton
|
||||||
import "blocks/ui" for Ui
|
|
||||||
|
|
||||||
System.print("ui is: %(Ui)")
|
|
||||||
|
|
||||||
//User facing API
|
//User facing API
|
||||||
//This is what the user of your modifier will interact with
|
//This is what the user of your modifier will interact with
|
||||||
|
|
@ -50,12 +47,12 @@ class Human {
|
||||||
//to do the actual work. You'll get notified when things change
|
//to do the actual work. You'll get notified when things change
|
||||||
//in the world and respond to them here.
|
//in the world and respond to them here.
|
||||||
class HumanSystem is ModifierSystem {
|
class HumanSystem is ModifierSystem {
|
||||||
|
|
||||||
player_start{[26, 89]}
|
player_start{[26, 89]}
|
||||||
player_size{[10, 12]}
|
player_size{[10, 12]}
|
||||||
|
|
||||||
construct new() {
|
construct new() {
|
||||||
//called when your system is first created.
|
//called when your system is first created.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init(world) {
|
init(world) {
|
||||||
|
|
@ -80,8 +77,8 @@ class HumanSystem is ModifierSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
tick(delta) {
|
tick(delta) {
|
||||||
//called usually once every frame.
|
//called usually once every frame.
|
||||||
//called when the world that this modifier lives in, is ticked
|
//called when the world that this modifier lives in, is ticked
|
||||||
each {|entity, data|
|
each {|entity, data|
|
||||||
if(!data.active) return
|
if(!data.active) return
|
||||||
|
|
||||||
|
|
@ -92,21 +89,19 @@ class HumanSystem is ModifierSystem {
|
||||||
_hoverEnt = entity
|
_hoverEnt = entity
|
||||||
Globals["Tooltip"].set(Strings.get(data.name), 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){
|
if(!over && _hoverEnt == entity){
|
||||||
_hoverEnt = null
|
_hoverEnt = null
|
||||||
Globals["Tooltip"].clear(entity)
|
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
|
} //tick
|
||||||
|
|
||||||
update(){
|
update(){
|
||||||
|
|
@ -132,3 +127,5 @@ class HumanSystem is ModifierSystem {
|
||||||
} //HumanSystem
|
} //HumanSystem
|
||||||
|
|
||||||
var Modifier = HumanSystem //required
|
var Modifier = HumanSystem //required
|
||||||
|
|
||||||
|
import "blocks/ui" for Ui //import at the end in case of cyclic dependency
|
||||||
|
|
@ -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,10 +196,14 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
test(){
|
test(){
|
||||||
ImageButton.get_data(_test)
|
ImageButton.get_data(_test)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//this is behind the class def to make cyclic dependency happy lol
|
||||||
|
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