ugly fix for ugly bug

This commit is contained in:
Ronja 2020-10-11 20:18:48 +02:00
parent 3ed3736631
commit 63da634e7d
5 changed files with 60 additions and 4 deletions

View file

@ -4,23 +4,44 @@
//probably better to do when I have a procgen text engine //probably better to do when I have a procgen text engine
"Amelia" "Amelia"
"Bertine"
"Bob" "Bob"
"Bug" "Bug"
"Chloe" "Chloe"
"Chris"
"Claus" "Claus"
"Cloud"
"Duck"
"Elliott"
"Freya"
"Ida" "Ida"
"Innes" "Innes"
"Jess"
"Jules" "Jules"
"Karl" "Karl"
"Karo"
"Lara" "Lara"
"Laura"
"Lauren" "Lauren"
"Leibi"
"Levi" "Levi"
"Mandy"
"Mara"
"Mercedes" "Mercedes"
"Merryl"
"Niels" "Niels"
"Nina"
"Rami" "Rami"
"Richard" "Richard"
"Rob"
"Robin"
"Ronja" "Ronja"
"Sandra" "Sandra"
"Simon" "Simon"
"Steve" "Steve"
"Sven"
"Sy"
"Ty"
"Wocky"
"Zoe"
] ]

View file

@ -4,7 +4,7 @@ import "luxe: world" for UILayout, UILayoutBehave, UILayoutContain
import "luxe: ui/control" for Control import "luxe: ui/control" for Control
import "luxe: ui/label" for UILabel import "luxe: ui/label" for UILabel
import "luxe: ui/image" for UIImage 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: render" for Material, TextAlign
import "luxe: color" for Color import "luxe: color" for Color
import "luxe: game" for Frame import "luxe: game" for Frame
@ -226,10 +226,15 @@ class UiAdventure{
UILayout.set_contain(_ent, item, UILayoutContain.row | UILayoutContain.start)//| UILayout.set_contain(_ent, item, UILayoutContain.row | UILayoutContain.start)//|
Control.set_size(item, -1, 12) Control.set_size(item, -1, 12)
Control.set_allow_input(item, true) 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| Control.set_events(item) {|event|
if(UI.event_cancelled(_ent, event.id)) return if(UI.event_cancelled(_ent, event.id)) return
if(!Util.valid_event(event)) return
if(event.type == UIEvent.press){ 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.ui_mode = Ui.Info
_ui.info.page.value = UiInfo.human _ui.info.page.value = UiInfo.human
_game.focus.value = adventurer _game.focus.value = adventurer

View file

@ -3,6 +3,7 @@ import "luxe: world" for UIEvent, UI
import "luxe: ui/control" for Control import "luxe: ui/control" for Control
import "globals" for Globals import "globals" for Globals
import "math/util" for Util
class ImageButton{ class ImageButton{
static create(ent){ static create(ent){
@ -16,6 +17,7 @@ class ImageButton{
Control.set_state_data(button, data) Control.set_state_data(button, data)
Control.set_events(button) {|event| Control.set_events(button) {|event|
if(!Util.valid_event(event)) return
var data = null var data = null
if(event.type == UIEvent.enter){ if(event.type == UIEvent.enter){
data = Control.get_state_data(button) data = Control.get_state_data(button)

View file

@ -1,5 +1,4 @@
import "math/vector" for Vector import "math/vector" for Vector
import "math/math" for M
class AABB{ class AABB{
x{_x} x{_x}
@ -51,6 +50,11 @@ class AABB{
return M.inv_lerp(min, max, vector) 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(){ static ONE(){
return new(0, 0, 1, 1) return new(0, 0, 1, 1)
} }
@ -66,6 +70,10 @@ class AABB{
_height = max_y - min_y _height = max_y - min_y
} }
static from_list(list){
return new(list.x, list.y, list.z, list.w)
}
static intersects(one, other){ static intersects(one, other){
return one.max > other.min && one.min < other.max return one.max > other.min && one.min < other.max
} }
@ -89,4 +97,6 @@ class AABB{
var half_amount = [amount.x/2, amount.y/2] var half_amount = [amount.x/2, amount.y/2]
return AABB.new(rect.pos - half_amount, rect.size + amount) return AABB.new(rect.pos - half_amount, rect.size + amount)
} }
} }
import "math/math" for M

View file

@ -1,7 +1,11 @@
import "luxe: assets" for Assets import "luxe: assets" for Assets
import "luxe: render" for Material import "luxe: render" for Material
import "luxe: ui/control" for Control
import "luxe: world" for UIEvent
import "math/math" for M import "math/math" for M
import "math/Vector" for Vector import "math/Vector" for Vector
import "math/rect" for AABB
class Util{ class Util{
static material_from_image_path(path){ 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 //hue value saturation to rgb colors. all values in 0-1 range
static hsv(h, s, v){ static hsv(h, s, v){
//hue to rgb //hue to rgb