From 8028d0533be9bf07828631007f28cb0df5779385 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Mon, 17 Nov 2025 22:31:48 +0100 Subject: [PATCH] - [NEW] menu i menu::popup - [WIP] toolbar - [WIP] treeview --- source/main.cpp | 26 ++++++++++- source/menu.cpp | 107 ++++++++++++++++++++++++++++++-------------- source/menu.h | 1 + source/toolbar.cpp | 26 +++++++++++ source/toolbar.h | 9 ++++ source/treeview.cpp | 44 ++++++++++++++++++ source/treeview.h | 8 ++++ 7 files changed, 186 insertions(+), 35 deletions(-) create mode 100644 source/toolbar.cpp create mode 100644 source/toolbar.h create mode 100644 source/treeview.cpp create mode 100644 source/treeview.h diff --git a/source/main.cpp b/source/main.cpp index 96776b9..5b2278f 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -2,6 +2,8 @@ #include "japi/game.h" #include "japi/font.h" #include "menu.h" +#include "toolbar.h" +#include "treeview.h" bool loop(); @@ -10,15 +12,17 @@ void game::init() draw::init("DILEMMAKER v0.1", 800, 600); game::setState(loop); font::load("font/8bithud"); + draw::cls(0x00000000); } bool loop() { - draw::cls(0x00000000); - menu::start(); if (menu::option("FILE")) { menu::popup::start(); + menu::popup::option("New..."); + menu::popup::option("Load..."); + menu::popup::option("Save..."); menu::popup::end(); } if (menu::option("EDIT")) { @@ -33,6 +37,24 @@ bool loop() menu::popup::start(); menu::popup::end(); } + if (menu::end()) { draw::render(); return true; } + + toolbar::start(); + + treeview::start(); + if (treeview::option("room01", 0)) { + treeview::option("abad", 1); + treeview::option("Jailer", 1); + } + if (treeview::option("room02", 0)) { + treeview::option("abad", 1); + treeview::option("Jailer", 1); + } + if (treeview::option("room03", 0)) { + treeview::option("abad", 1); + treeview::option("Jailer", 1); + } + treeview::end(); /*x1 += 6; x2 = x1 + font::len("FILE")+6; font::print("FILE", x1, 5); x1=x2; diff --git a/source/menu.cpp b/source/menu.cpp index 56332a8..a56a433 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -2,17 +2,71 @@ #include "japi/input.h" #include "japi/draw.h" #include "japi/font.h" +#include namespace menu { int x1, x2, m; int menu_shown = -1; + bool must_stop = false; + bool changing = false; + namespace popup + { + int x=0, y=0, width=0, height=0; + + void start() + { + popup::x = x1-8; + draw::setColor(0xff3c3c3c); + draw::fillrect(popup::x,24,popup::width,popup::height); + + int mx = input::mouseX(); + int my = input::mouseY(); + if (mx>=popup::x && my>=24 && mx=popup::x && my>=popup::y && mx=x1 && my>=0 && mx=x1-8 && my>=24 && mx + +namespace toolbar +{ + void start(); + bool button(SDL_Texture* surf, const int sx, const int sy); + bool pushbutton(SDL_Texture* surf, const int sx, const int sy, const bool pushed); +} diff --git a/source/treeview.cpp b/source/treeview.cpp new file mode 100644 index 0000000..af805a3 --- /dev/null +++ b/source/treeview.cpp @@ -0,0 +1,44 @@ +#include "treeview.h" +#include "japi/draw.h" +#include "japi/font.h" +#include "japi/input.h" + +namespace treeview +{ + int width = 200; + int scroll = 0; + int current = -1; + int selected = -1; + + void start() + { + draw::setColor(0xff181818); + draw::fillrect(0,48,treeview::width, draw::getWindowSize().y-48); + current = 0; + } + + bool option(const char* label, const int level) + { + int mx = input::mouseX(); + int my = input::mouseY(); + const int opt_y = (48+current*24); + if (mx>=0 && my>=opt_y && mx