2020-08-21 14:37:13 +00:00
|
|
|
import "luxe: world" for Entity, Text, Transform
|
|
|
|
|
import "luxe: assets" for Assets
|
|
|
|
|
|
|
|
|
|
import "globals" for Globals
|
|
|
|
|
import "math/vector" for Vector
|
|
|
|
|
|
|
|
|
|
class Tooltip{
|
2020-08-29 06:14:01 +00:00
|
|
|
depth{100}
|
|
|
|
|
|
2020-08-21 14:37:13 +00:00
|
|
|
construct new(app){
|
|
|
|
|
_ent = Entity.create(app.ui)
|
|
|
|
|
_mat_font = Assets.material("luxe: material/font")
|
2020-08-29 06:14:01 +00:00
|
|
|
Text.create(_ent, _mat_font, 8, "assets/fonts/BabyBlocks", [0.2, 0.01, 0.05, 1])
|
2020-08-21 14:37:13 +00:00
|
|
|
|
|
|
|
|
Transform.create(_ent)
|
2020-08-29 06:14:01 +00:00
|
|
|
Transform.set_pos(_ent, 64, 128, depth)
|
2020-08-21 14:37:13 +00:00
|
|
|
Transform.set_snap(_ent, 1, 1, 0)
|
|
|
|
|
|
2020-08-29 06:14:01 +00:00
|
|
|
Globals["Tooltip"] = this
|
2020-08-21 14:37:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tick(){
|
|
|
|
|
var pos = Vector.new(Globals["UiMouse"])
|
|
|
|
|
if(_active && pos){
|
2020-08-29 06:14:01 +00:00
|
|
|
if(_x){
|
|
|
|
|
pos.x = _x
|
|
|
|
|
}
|
|
|
|
|
if(_y){
|
|
|
|
|
pos.y = _y
|
|
|
|
|
}
|
|
|
|
|
Transform.set_pos(_ent, pos.x, pos.y, depth)
|
2020-08-21 14:37:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-29 06:14:01 +00:00
|
|
|
set(text) {
|
|
|
|
|
set(text, null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fix_y(value){
|
|
|
|
|
_y = value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fix_x(value){
|
|
|
|
|
_x = value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set(text, source){
|
2020-08-21 14:37:13 +00:00
|
|
|
Text.set_text_buffer(_ent, text)
|
|
|
|
|
Text.commit(_ent)
|
|
|
|
|
_active = true
|
2020-08-29 06:14:01 +00:00
|
|
|
_source = source
|
|
|
|
|
_x = null
|
|
|
|
|
_y = null
|
2020-08-21 14:37:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clear(){
|
2020-08-29 06:14:01 +00:00
|
|
|
clear(_source)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clear(source){
|
|
|
|
|
if(_source != source) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2020-08-21 14:37:13 +00:00
|
|
|
Text.set_text_buffer(_ent, "")
|
|
|
|
|
Text.commit(_ent)
|
|
|
|
|
_active = false
|
|
|
|
|
}
|
|
|
|
|
}
|