2025-07-06 20:43:53 +03:00
|
|
|
#pragma once
|
2026-04-01 22:28:48 +03:00
|
|
|
#include "GUIStuff/Elements/ScrollArea.hpp"
|
2026-04-09 16:30:28 +03:00
|
|
|
#include "GUIStuff/Elements/TextParagraph.hpp"
|
2025-07-06 20:43:53 +03:00
|
|
|
#include "GUIStuff/GUIManager.hpp"
|
|
|
|
|
#include "DrawData.hpp"
|
2025-10-01 20:08:01 +03:00
|
|
|
#include "Helpers/FileDownloader.hpp"
|
2025-07-06 20:43:53 +03:00
|
|
|
#include <filesystem>
|
2025-10-16 09:38:58 +03:00
|
|
|
#include <modules/skparagraph/include/Paragraph.h>
|
2025-07-06 20:43:53 +03:00
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
#include <Helpers/Serializers.hpp>
|
|
|
|
|
#include <SDL3/SDL_dialog.h>
|
2025-11-17 16:08:42 +03:00
|
|
|
#include <Helpers/VersionNumber.hpp>
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
class MainProgram;
|
|
|
|
|
|
|
|
|
|
class Toolbar {
|
|
|
|
|
public:
|
|
|
|
|
struct LogMessage {
|
2026-04-05 22:01:30 +03:00
|
|
|
static constexpr float DISPLAY_TIME = 8.0f;
|
|
|
|
|
static constexpr float FADE_START_TIME = 7.0f;
|
2025-07-06 20:43:53 +03:00
|
|
|
std::string text;
|
|
|
|
|
enum {
|
|
|
|
|
COLOR_NORMAL = 0,
|
|
|
|
|
COLOR_ERROR
|
|
|
|
|
} color;
|
|
|
|
|
TimePoint time;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ChatMessage {
|
2026-04-09 16:30:28 +03:00
|
|
|
static constexpr float DISPLAY_TIME = 8.0f;
|
|
|
|
|
static constexpr float FADE_START_TIME = 7.0f;
|
2025-10-16 09:38:58 +03:00
|
|
|
std::string name;
|
|
|
|
|
std::string message;
|
|
|
|
|
enum Type {
|
|
|
|
|
NORMAL = 0,
|
|
|
|
|
JOIN
|
|
|
|
|
} type;
|
2025-07-06 20:43:53 +03:00
|
|
|
TimePoint time;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ExtensionFilter {
|
|
|
|
|
std::string name;
|
|
|
|
|
std::string extensions;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::string chatMessageInput;
|
|
|
|
|
|
|
|
|
|
Toolbar(MainProgram& initMain);
|
2026-04-05 22:01:30 +03:00
|
|
|
void update();
|
2026-03-27 09:51:53 +03:00
|
|
|
void layout_run();
|
2026-04-04 19:53:45 +03:00
|
|
|
struct ColorSelectorData {
|
|
|
|
|
std::function<void()> onChange;
|
|
|
|
|
std::function<void()> onSelect;
|
|
|
|
|
std::function<void()> onDeselect;
|
|
|
|
|
};
|
|
|
|
|
struct ColorSelectorButtonData {
|
|
|
|
|
std::function<void()> onSelectorButtonClick;
|
|
|
|
|
std::function<void()> onChange;
|
|
|
|
|
std::function<void()> onSelect;
|
|
|
|
|
std::function<void()> onDeselect;
|
|
|
|
|
};
|
2026-04-06 12:23:46 +03:00
|
|
|
void color_selector_left(GUIStuff::Element* button, Vector4f* color, const ColorSelectorData& colorSelectorData = {});
|
|
|
|
|
void color_selector_right(GUIStuff::Element* button, Vector4f* color, const ColorSelectorData& colorSelectorData = {});
|
2026-04-04 19:53:45 +03:00
|
|
|
void color_button_left(const char* id, Vector4f* color, const ColorSelectorButtonData& colorSelectorData = {});
|
|
|
|
|
void color_button_right(const char* id, Vector4f* color, const ColorSelectorButtonData& colorSelectorData = {});
|
2026-04-02 18:23:36 +03:00
|
|
|
|
2025-12-01 17:33:14 +03:00
|
|
|
void paint_popup(Vector2f popupPos);
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
typedef std::function<void(const std::filesystem::path&, const ExtensionFilter& extensionSelected)> OpenFileSelectorCallback;
|
|
|
|
|
void open_file_selector(const std::string& filePickerName, const std::vector<ExtensionFilter>& extensionFilters, OpenFileSelectorCallback postSelectionFunc, const std::string& fileName = "", bool isSaving = false);
|
|
|
|
|
void save_func();
|
|
|
|
|
void save_as_func();
|
|
|
|
|
std::filesystem::path& file_selector_path();
|
|
|
|
|
|
|
|
|
|
void save_palettes();
|
|
|
|
|
void load_palettes();
|
|
|
|
|
void load_licenses();
|
|
|
|
|
|
2026-04-09 16:30:28 +03:00
|
|
|
void open_chatbox();
|
|
|
|
|
void close_chatbox();
|
|
|
|
|
|
2026-04-06 12:23:46 +03:00
|
|
|
GUIStuff::Element* colorLeftButton;
|
2025-07-06 20:43:53 +03:00
|
|
|
Vector4f* colorLeft = nullptr;
|
2026-04-04 19:53:45 +03:00
|
|
|
ColorSelectorData colorLeftData;
|
2026-04-02 21:57:26 +03:00
|
|
|
|
2026-04-06 12:23:46 +03:00
|
|
|
GUIStuff::Element* colorRightButton;
|
2025-07-06 20:43:53 +03:00
|
|
|
Vector4f* colorRight = nullptr;
|
2026-04-04 19:53:45 +03:00
|
|
|
ColorSelectorData colorRightData;
|
2025-11-05 18:21:49 +03:00
|
|
|
|
2026-01-18 13:39:49 +03:00
|
|
|
bool app_close_requested();
|
2025-07-06 20:43:53 +03:00
|
|
|
private:
|
|
|
|
|
static void sdl_open_file_dialog_callback(void* userData, const char * const * fileList, int filter);
|
|
|
|
|
|
2026-03-27 09:51:53 +03:00
|
|
|
void text_button_wide(const char* id, const char* str, const std::function<void()>& onClick);
|
2025-07-06 20:43:53 +03:00
|
|
|
void reload_theme_list();
|
|
|
|
|
void player_list();
|
|
|
|
|
void chat_box();
|
|
|
|
|
void global_log();
|
|
|
|
|
void top_toolbar();
|
2026-04-06 12:23:46 +03:00
|
|
|
void grid_menu(GUIStuff::Element* gridMenuButton);
|
|
|
|
|
void add_grid();
|
2025-09-12 09:54:49 +03:00
|
|
|
void stop_displaying_grid_menu();
|
2026-04-06 20:16:25 +03:00
|
|
|
void stop_displaying_bookmark_menu();
|
2026-04-07 16:57:11 +03:00
|
|
|
void stop_displaying_layer_menu();
|
2026-04-06 20:16:25 +03:00
|
|
|
void bookmark_menu(GUIStuff::Element* bookmarkMenuButton);
|
2026-04-07 16:57:11 +03:00
|
|
|
void layer_menu(GUIStuff::Element* layerMenuButton);
|
2025-07-06 20:43:53 +03:00
|
|
|
void drawing_program_gui();
|
|
|
|
|
void options_menu();
|
2026-03-27 09:51:53 +03:00
|
|
|
void file_picker_gui_refresh_entries();
|
|
|
|
|
void file_picker_gui_done();
|
2025-07-06 20:43:53 +03:00
|
|
|
void file_picker_gui();
|
|
|
|
|
void performance_metrics();
|
2026-04-06 12:23:46 +03:00
|
|
|
void color_picker_window(const char* id, Vector4f** color, GUIStuff::Element* b, const ColorSelectorData& colorSelectorData);
|
2026-04-03 09:52:45 +03:00
|
|
|
void color_palette(const char* id, Vector4f* color, const std::function<void()>& onChange);
|
2026-01-01 22:46:02 +03:00
|
|
|
void open_world_file(bool isClient, const std::string& netSource, const std::string& serverLocalID);
|
2025-07-06 20:43:53 +03:00
|
|
|
void load_default_palette();
|
|
|
|
|
void load_default_theme();
|
2026-03-27 09:51:53 +03:00
|
|
|
void about_menu_inner_gui();
|
2025-07-06 20:43:53 +03:00
|
|
|
void web_version_welcome();
|
2026-01-09 21:56:58 +03:00
|
|
|
void still_connecting_center_message();
|
|
|
|
|
void no_layers_being_edited_message();
|
2026-01-18 13:39:49 +03:00
|
|
|
void close_popup_gui();
|
|
|
|
|
void add_world_to_close_popup_data(const std::shared_ptr<World>& w);
|
2026-03-27 09:51:53 +03:00
|
|
|
void general_settings_inner_gui();
|
|
|
|
|
void center_obstructing_window_gui(const char* id, Clay_SizingAxis x, Clay_SizingAxis y, const std::function<void()>& innerContent);
|
2026-01-18 13:39:49 +03:00
|
|
|
|
|
|
|
|
struct ClosePopupData {
|
|
|
|
|
struct CloseWorldData {
|
|
|
|
|
std::weak_ptr<World> w;
|
|
|
|
|
bool setToSave = true;
|
|
|
|
|
};
|
|
|
|
|
std::vector<CloseWorldData> worldsToClose; // Using a vector to ensure that the worlds are in proper order
|
|
|
|
|
bool closeAppWhenDone = false;
|
|
|
|
|
} closePopupData;
|
2025-07-06 20:43:53 +03:00
|
|
|
|
2025-10-01 20:08:01 +03:00
|
|
|
#ifndef __EMSCRIPTEN__
|
|
|
|
|
void update_notification_gui();
|
|
|
|
|
void update_notification_check();
|
|
|
|
|
struct UpdateCheckerData {
|
|
|
|
|
bool showGui = false;
|
|
|
|
|
bool updateCheckDone = false;
|
|
|
|
|
std::string newVersionStr;
|
|
|
|
|
std::shared_ptr<FileDownloader::DownloadData> versionFile;
|
|
|
|
|
} updateCheckerData;
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
std::string ownLicenseText;
|
|
|
|
|
std::vector<std::pair<std::string, std::string>> thirdPartyLicenses;
|
|
|
|
|
int selectedLicense = -1;
|
|
|
|
|
|
|
|
|
|
std::string downloadNameSet;
|
|
|
|
|
|
|
|
|
|
struct PaletteData {
|
|
|
|
|
struct Palette {
|
|
|
|
|
std::string name;
|
|
|
|
|
std::vector<Vector3f> colors;
|
|
|
|
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Palette, name, colors)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
size_t selectedPalette = 0;
|
|
|
|
|
std::vector<Palette> palettes;
|
|
|
|
|
bool addingPalette = false;
|
|
|
|
|
std::string newPaletteStr;
|
|
|
|
|
} paletteData;
|
|
|
|
|
|
|
|
|
|
struct ThemeData {
|
|
|
|
|
std::vector<std::string> themeDirList;
|
|
|
|
|
std::optional<size_t> selectedThemeIndex;
|
|
|
|
|
bool openedSaveAsMenu = false;
|
|
|
|
|
} themeData;
|
|
|
|
|
|
|
|
|
|
bool showPerformance = false;
|
|
|
|
|
|
|
|
|
|
bool menuPopUpOpen = false;
|
|
|
|
|
bool optionsMenuOpen = false;
|
|
|
|
|
bool playerMenuOpen = false;
|
|
|
|
|
|
2025-09-27 17:59:56 +03:00
|
|
|
float finalCalculatedGuiScale = 1.0f;
|
2025-08-17 16:49:30 +03:00
|
|
|
|
2026-04-09 16:30:28 +03:00
|
|
|
bool chatboxOpen = false;
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
enum OptionsMenuType {
|
|
|
|
|
HOST_MENU,
|
|
|
|
|
CONNECT_MENU,
|
|
|
|
|
GENERAL_SETTINGS_MENU,
|
|
|
|
|
LOBBY_INFO_MENU,
|
2025-08-01 10:58:45 +03:00
|
|
|
CANVAS_SETTINGS_MENU,
|
2025-07-06 20:43:53 +03:00
|
|
|
SET_DOWNLOAD_NAME,
|
|
|
|
|
ABOUT_MENU
|
|
|
|
|
} optionsMenuType;
|
|
|
|
|
enum GeneralSettingsOptions {
|
|
|
|
|
GSETTINGS_GENERAL = 0,
|
|
|
|
|
GSETTINGS_TABLET,
|
|
|
|
|
GSETTINGS_THEME,
|
|
|
|
|
GSETTINGS_KEYBINDS,
|
|
|
|
|
GSETTINGS_DEBUG
|
|
|
|
|
} generalSettingsOptions = GSETTINGS_GENERAL;
|
|
|
|
|
|
2025-12-23 17:17:33 +03:00
|
|
|
bool bookmarkMenuPopupOpen = false;
|
2025-12-25 17:18:28 +03:00
|
|
|
bool layerMenuPopupOpen = false;
|
2025-07-06 20:43:53 +03:00
|
|
|
|
2025-09-06 19:06:30 +03:00
|
|
|
struct GridMenu {
|
|
|
|
|
bool popupOpen = false;
|
|
|
|
|
std::string newName;
|
2025-12-10 13:06:45 +03:00
|
|
|
uint32_t selectedGrid = std::numeric_limits<uint32_t>::max();
|
2025-09-06 19:06:30 +03:00
|
|
|
} gridMenu;
|
|
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
struct FilePicker {
|
|
|
|
|
bool isOpen = false;
|
|
|
|
|
std::string filePickerWindowName;
|
|
|
|
|
std::vector<ExtensionFilter> extensionFiltersComplete;
|
|
|
|
|
std::vector<std::string> extensionFilters;
|
|
|
|
|
std::vector<std::filesystem::path> entries;
|
|
|
|
|
std::filesystem::path currentSearchPath;
|
|
|
|
|
std::filesystem::path currentSelectedPath;
|
2026-04-01 21:49:44 +03:00
|
|
|
std::string fileName = "";
|
|
|
|
|
bool isSaving = false;
|
2025-07-06 20:43:53 +03:00
|
|
|
size_t extensionSelected;
|
2026-04-01 22:28:48 +03:00
|
|
|
GUIStuff::ScrollArea* entriesScrollArea = nullptr;
|
2025-07-06 20:43:53 +03:00
|
|
|
OpenFileSelectorCallback postSelectionFunc;
|
|
|
|
|
} filePicker;
|
|
|
|
|
|
|
|
|
|
struct NativeFilePicker {
|
|
|
|
|
std::atomic<bool> isOpen = false;
|
|
|
|
|
std::vector<ExtensionFilter> extensionFiltersComplete;
|
|
|
|
|
std::vector<SDL_DialogFileFilter> sdlFileFilters;
|
|
|
|
|
OpenFileSelectorCallback postSelectionFunc;
|
|
|
|
|
};
|
|
|
|
|
static NativeFilePicker nativeFilePicker;
|
|
|
|
|
|
2026-04-09 16:30:28 +03:00
|
|
|
RichText::TextData build_paragraph_from_chat_message(const ChatMessage& message, float alpha);
|
2025-10-16 09:38:58 +03:00
|
|
|
|
2025-11-21 10:36:46 +03:00
|
|
|
void load_icons_at(const std::filesystem::path& pathToLoad);
|
|
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
std::string serverToConnectTo;
|
|
|
|
|
std::string serverLocalID;
|
|
|
|
|
|
|
|
|
|
MainProgram& main;
|
|
|
|
|
};
|