From 845772ed1670fd62cc3d6a122236b8d30706ca77 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Tue, 6 Jun 2023 14:03:03 +0200 Subject: [PATCH] =?UTF-8?q?-=20Codi=20de=20UI=20mes=20clar.=20Variables=20?= =?UTF-8?q?van=20amunt=20o=20avall=20segons=20bot=C3=B3=20del=20ratol?= =?UTF-8?q?=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/jui.cpp | 11 +++++++--- source/jui.h | 2 +- source/main.cpp | 57 +++++++++++++++++-------------------------------- 3 files changed, 28 insertions(+), 42 deletions(-) diff --git a/source/jui.cpp b/source/jui.cpp index 87872e9..f47cb1c 100644 --- a/source/jui.cpp +++ b/source/jui.cpp @@ -5,11 +5,11 @@ namespace ui { - const bool button(const char *label, const int x, const int y, const int w, const int h) + const int button(const char *label, const int x, const int y, const int w, const int h) { const int mx = input::mouseX(); const int my = input::mouseY(); - const bool btnDown = input::mouseBtn(1); + const bool btnDown = input::mouseBtn(1) || input::mouseBtn(3); const bool inside = (mx>=x) && (mx=y) && (my3)room_w=0; - restart(); - } - - draw::print("ROOM HEIGHT:", 330, 28, 15, 0); - if (ui::button(SDL_itoa(room_h, buffer, 10), 380, 25, 28, 11)) - { - room_h++;if(room_h>3)room_h=0; - restart(); - } + btn("ROOM WIDTH:", 330, 10, room_w, 0, 3); + btn("ROOM HEIGHT:", 330, 25, room_h, 0, 3); - draw::print("DOOR XP:", 330, 53, 15, 0); - if (ui::button(SDL_itoa(room_xp, buffer, 10), 380, 50, 28, 11)) - { - room_xp++;if(room_xp>5)room_xp=-1; - restart(); - } - draw::print("DOOR XN:", 330, 68, 15, 0); - if (ui::button(SDL_itoa(room_xn, buffer, 10), 380, 65, 28, 11)) - { - room_xn++;if(room_xn>5)room_xn=-1; - restart(); - } - draw::print("DOOR YP:", 330, 83, 15, 0); - if (ui::button(SDL_itoa(room_yp, buffer, 10), 380, 80, 28, 11)) - { - room_yp++;if(room_yp>5)room_yp=-1; - restart(); - } - draw::print("DOOR YN:", 330, 98, 15, 0); - if (ui::button(SDL_itoa(room_yn, buffer, 10), 380, 95, 28, 11)) - { - room_yn++;if(room_yn>5)room_yn=-1; - restart(); - } + btn("DOOR XP:", 330, 50, room_xp, -1, 5); + btn("DOOR XN:", 330, 65, room_xn, -1, 5); + btn("DOOR YP:", 330, 80, room_yp, -1, 5); + btn("DOOR YN:", 330, 95, room_yn, -1, 5); draw::render();