gui: another pass

main
Dominik Madarász 2023-11-26 20:03:38 +01:00
parent 02ebdb77b2
commit ed13bab0b9
5 changed files with 30 additions and 10 deletions

View File

@ -3,16 +3,22 @@
int main() {
window_create(65.0, 0 );
gui_pushskin(gui_skinned("golden.ase", 4.0));
atlas_t *atlas = &C_CAST(skinned_t*, gui_userdata())->atlas;
gui_pushskin(gui_skinned("golden.ase", 4.0f));
skinned_t *skinned = C_CAST(skinned_t*, gui_userdata());
vec4 pos = vec4(100,100,850,750);
vec4 pos = vec4(400,400,100, 30);
while( window_swap() && !input(KEY_ESC) ) { // game loop
vec4 panel_pos = vec4(0, 0, window_width(), window_height());
if (ui_panel("Atlas", 0)) {
ui_atlas(atlas);
ui_atlas(&skinned->atlas);
ui_panel_end();
}
if (ui_panel("GUI", 0)) {
ui_float("Scale", &skinned->scale);
ui_panel_end();
}
@ -21,16 +27,21 @@ int main() {
pos.y = input(MOUSE_Y);
}
if (input(MOUSE_R)) {
pos.z = input(MOUSE_X);
pos.w = input(MOUSE_Y);
pos.z = input(MOUSE_X)-pos.x;
pos.w = input(MOUSE_Y)-pos.y;
}
//
gui_panel(panel_pos, 0);
if (gui_button(pos, 0)) {
printf("%s\n", "Button pressed!");
}
gui_panel(vec4(40,140, 320, 40), "vial");
gui_panel(vec4(40+9*skinned->scale,140+2*skinned->scale, 200, 64), "hp");
gui_panel(vec4(40,230, 280, 40), "vial");
gui_panel(vec4(40+9*skinned->scale,230+2*skinned->scale, 280-18*skinned->scale, 64), "mp");
}
gui_popskin();

Binary file not shown.

View File

@ -358959,7 +358959,7 @@ bool (gui_button)(int id, vec4 r, const char *skin) {
bool was_clicked=0;
entry->hover = false;
if (input(MOUSE_X) > r.x && input(MOUSE_X) < r.z && input(MOUSE_Y) > r.y && input(MOUSE_Y) < r.w) {
if (input(MOUSE_X) > r.x && input(MOUSE_X) < (r.x+r.z) && input(MOUSE_Y) > r.y && input(MOUSE_Y) < (r.y+r.w)) {
if (input_up(MOUSE_L) && entry->held) {
was_clicked=1;
}
@ -359011,6 +359011,9 @@ void skinned_draw_sprite(float scale, atlas_t *a, atlas_slice_frame_t *f, vec4 r
return;
}
r.z += r.x;
r.w += r.y;
vec4 outer = f->bounds;
vec4 core = f->core;
core.x += outer.x;

View File

@ -129,7 +129,7 @@ bool (gui_button)(int id, vec4 r, const char *skin) {
bool was_clicked=0;
entry->hover = false;
if (input(MOUSE_X) > r.x && input(MOUSE_X) < r.z && input(MOUSE_Y) > r.y && input(MOUSE_Y) < r.w) {
if (input(MOUSE_X) > r.x && input(MOUSE_X) < (r.x+r.z) && input(MOUSE_Y) > r.y && input(MOUSE_Y) < (r.y+r.w)) {
if (input_up(MOUSE_L) && entry->held) {
was_clicked=1;
}
@ -181,6 +181,9 @@ void skinned_draw_sprite(float scale, atlas_t *a, atlas_slice_frame_t *f, vec4 r
return;
}
r.z += r.x;
r.w += r.y;
vec4 outer = f->bounds;
vec4 core = f->core;
core.x += outer.x;

View File

@ -11135,7 +11135,7 @@ bool (gui_button)(int id, vec4 r, const char *skin) {
bool was_clicked=0;
entry->hover = false;
if (input(MOUSE_X) > r.x && input(MOUSE_X) < r.z && input(MOUSE_Y) > r.y && input(MOUSE_Y) < r.w) {
if (input(MOUSE_X) > r.x && input(MOUSE_X) < (r.x+r.z) && input(MOUSE_Y) > r.y && input(MOUSE_Y) < (r.y+r.w)) {
if (input_up(MOUSE_L) && entry->held) {
was_clicked=1;
}
@ -11187,6 +11187,9 @@ void skinned_draw_sprite(float scale, atlas_t *a, atlas_slice_frame_t *f, vec4 r
return;
}
r.z += r.x;
r.w += r.y;
vec4 outer = f->bounds;
vec4 core = f->core;
core.x += outer.x;