ugly fix for ugly bug
This commit is contained in:
parent
3ed3736631
commit
63da634e7d
5 changed files with 60 additions and 4 deletions
|
|
@ -4,23 +4,44 @@
|
|||
//probably better to do when I have a procgen text engine
|
||||
|
||||
"Amelia"
|
||||
"Bertine"
|
||||
"Bob"
|
||||
"Bug"
|
||||
"Chloe"
|
||||
"Chris"
|
||||
"Claus"
|
||||
"Cloud"
|
||||
"Duck"
|
||||
"Elliott"
|
||||
"Freya"
|
||||
"Ida"
|
||||
"Innes"
|
||||
"Jess"
|
||||
"Jules"
|
||||
"Karl"
|
||||
"Karo"
|
||||
"Lara"
|
||||
"Laura"
|
||||
"Lauren"
|
||||
"Leibi"
|
||||
"Levi"
|
||||
"Mandy"
|
||||
"Mara"
|
||||
"Mercedes"
|
||||
"Merryl"
|
||||
"Niels"
|
||||
"Nina"
|
||||
"Rami"
|
||||
"Richard"
|
||||
"Rob"
|
||||
"Robin"
|
||||
"Ronja"
|
||||
"Sandra"
|
||||
"Simon"
|
||||
"Steve"
|
||||
"Sven"
|
||||
"Sy"
|
||||
"Ty"
|
||||
"Wocky"
|
||||
"Zoe"
|
||||
]
|
||||
|
|
@ -4,7 +4,7 @@ import "luxe: world" for UILayout, UILayoutBehave, UILayoutContain
|
|||
import "luxe: ui/control" for Control
|
||||
import "luxe: ui/label" for UILabel
|
||||
import "luxe: ui/image" for UIImage
|
||||
import "luxe: assets" for Assets
|
||||
import "luxe: assets" for Assets, Strings
|
||||
import "luxe: render" for Material, TextAlign
|
||||
import "luxe: color" for Color
|
||||
import "luxe: game" for Frame
|
||||
|
|
@ -226,10 +226,15 @@ class UiAdventure{
|
|||
UILayout.set_contain(_ent, item, UILayoutContain.row | UILayoutContain.start)//|
|
||||
Control.set_size(item, -1, 12)
|
||||
Control.set_allow_input(item, true)
|
||||
Control.set_id(item, "Person %(i)")
|
||||
Control.set_id(item, "Person %(i) : %(Human.get_name(adventurer))")
|
||||
System.print(Strings.get(Control.get_id(item)))
|
||||
Control.set_events(item) {|event|
|
||||
if(UI.event_cancelled(_ent, event.id)) return
|
||||
if(!Util.valid_event(event)) return
|
||||
if(event.type == UIEvent.press){
|
||||
System.print("entity: %(Strings.get(Control.get_id(item)))")
|
||||
System.print("focussed: %(UI.get_focused(_ent))")
|
||||
System.print("event: %(event)")
|
||||
_ui.ui_mode = Ui.Info
|
||||
_ui.info.page.value = UiInfo.human
|
||||
_game.focus.value = adventurer
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import "luxe: world" for UIEvent, UI
|
|||
import "luxe: ui/control" for Control
|
||||
|
||||
import "globals" for Globals
|
||||
import "math/util" for Util
|
||||
|
||||
class ImageButton{
|
||||
static create(ent){
|
||||
|
|
@ -16,6 +17,7 @@ class ImageButton{
|
|||
Control.set_state_data(button, data)
|
||||
|
||||
Control.set_events(button) {|event|
|
||||
if(!Util.valid_event(event)) return
|
||||
var data = null
|
||||
if(event.type == UIEvent.enter){
|
||||
data = Control.get_state_data(button)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import "math/vector" for Vector
|
||||
import "math/math" for M
|
||||
|
||||
class AABB{
|
||||
x{_x}
|
||||
|
|
@ -51,6 +50,11 @@ class AABB{
|
|||
return M.inv_lerp(min, max, vector)
|
||||
}
|
||||
|
||||
contains_point(vector){
|
||||
return vector.x > min_x && vector.y > min_y &&
|
||||
vector.x < max_x && vector.y < max_y
|
||||
}
|
||||
|
||||
static ONE(){
|
||||
return new(0, 0, 1, 1)
|
||||
}
|
||||
|
|
@ -66,6 +70,10 @@ class AABB{
|
|||
_height = max_y - min_y
|
||||
}
|
||||
|
||||
static from_list(list){
|
||||
return new(list.x, list.y, list.z, list.w)
|
||||
}
|
||||
|
||||
static intersects(one, other){
|
||||
return one.max > other.min && one.min < other.max
|
||||
}
|
||||
|
|
@ -89,4 +97,6 @@ class AABB{
|
|||
var half_amount = [amount.x/2, amount.y/2]
|
||||
return AABB.new(rect.pos - half_amount, rect.size + amount)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
import "math/math" for M
|
||||
|
|
@ -1,7 +1,11 @@
|
|||
import "luxe: assets" for Assets
|
||||
import "luxe: render" for Material
|
||||
import "luxe: ui/control" for Control
|
||||
import "luxe: world" for UIEvent
|
||||
|
||||
import "math/math" for M
|
||||
import "math/Vector" for Vector
|
||||
import "math/rect" for AABB
|
||||
|
||||
class Util{
|
||||
static material_from_image_path(path){
|
||||
|
|
@ -86,6 +90,20 @@ class Util{
|
|||
}
|
||||
}
|
||||
|
||||
static valid_event(event){
|
||||
//events without a position are always valid
|
||||
if(![UIEvent.press, UIEvent.release, UIEvent.move].contains(event.type)) return true
|
||||
|
||||
//System.print("type: %(UIEvent.name(event.type))")
|
||||
var valid = event.y > 0 //ugly bugs need ugly fixes
|
||||
return valid
|
||||
|
||||
//those are the remains of a cleaner solution
|
||||
/*var bounds = [0,0,0,0]
|
||||
Control.get_bounds_abs(event.control, bounds)
|
||||
var rect = AABB.from_list(bounds)*/
|
||||
}
|
||||
|
||||
//hue value saturation to rgb colors. all values in 0-1 range
|
||||
static hsv(h, s, v){
|
||||
//hue to rgb
|
||||
|
|
|
|||
Loading…
Reference in a new issue