2023-11-05 14:34:20 -05:00
|
|
|
#ifndef __RECOMP_UI__
|
|
|
|
#define __RECOMP_UI__
|
|
|
|
|
2023-11-11 17:42:07 -05:00
|
|
|
#include <memory>
|
2024-01-01 22:36:06 -05:00
|
|
|
#include <string>
|
2025-01-19 21:00:05 -05:00
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
// TODO move this file into src/ui
|
2023-11-11 17:42:07 -05:00
|
|
|
|
2023-11-05 14:34:20 -05:00
|
|
|
#include "SDL.h"
|
2024-04-20 13:25:46 -05:00
|
|
|
#include "RmlUi/Core.h"
|
2023-11-05 14:34:20 -05:00
|
|
|
|
2024-07-11 12:33:03 -05:00
|
|
|
#include "../src/ui/util/hsv.h"
|
2024-09-13 10:13:52 -05:00
|
|
|
#include "../src/ui/util/bem.h"
|
2024-07-11 12:33:03 -05:00
|
|
|
|
2025-01-19 21:00:05 -05:00
|
|
|
#include "../src/ui/core/ui_context.h"
|
|
|
|
|
2023-11-11 17:42:07 -05:00
|
|
|
namespace Rml {
|
2025-01-19 21:00:05 -05:00
|
|
|
class ElementDocument;
|
|
|
|
class EventListenerInstancer;
|
|
|
|
class Context;
|
|
|
|
class Event;
|
2023-11-11 17:42:07 -05:00
|
|
|
}
|
|
|
|
|
2024-06-05 01:12:43 +02:00
|
|
|
namespace recompui {
|
2025-01-19 21:00:05 -05:00
|
|
|
class UiEventListenerInstancer;
|
|
|
|
|
|
|
|
// TODO remove this once the UI has been ported over to the new system.
|
|
|
|
class MenuController {
|
|
|
|
public:
|
|
|
|
virtual ~MenuController() {}
|
|
|
|
virtual Rml::ElementDocument* load_document(Rml::Context* context) = 0;
|
|
|
|
virtual void register_events(UiEventListenerInstancer& listener) = 0;
|
|
|
|
virtual void make_bindings(Rml::Context* context) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::unique_ptr<MenuController> create_launcher_menu();
|
|
|
|
std::unique_ptr<MenuController> create_config_menu();
|
|
|
|
|
|
|
|
using event_handler_t = void(const std::string& param, Rml::Event&);
|
|
|
|
|
|
|
|
void queue_event(const SDL_Event& event);
|
|
|
|
bool try_deque_event(SDL_Event& out);
|
|
|
|
|
|
|
|
std::unique_ptr<UiEventListenerInstancer> make_event_listener_instancer();
|
|
|
|
void register_event(UiEventListenerInstancer& listener, const std::string& name, event_handler_t* handler);
|
|
|
|
|
|
|
|
void show_context(ContextId context, std::string_view param);
|
|
|
|
void hide_context(ContextId context);
|
|
|
|
void hide_all_contexts();
|
|
|
|
bool is_context_open(ContextId context);
|
|
|
|
bool is_context_taking_input();
|
|
|
|
bool is_any_context_open();
|
|
|
|
|
|
|
|
ContextId get_launcher_context_id();
|
|
|
|
ContextId get_config_context_id();
|
2025-01-20 03:55:22 -05:00
|
|
|
ContextId get_config_sub_menu_context_id();
|
2025-01-19 21:00:05 -05:00
|
|
|
ContextId get_close_prompt_context_id();
|
|
|
|
|
2025-01-20 12:38:33 -05:00
|
|
|
enum class ConfigTab {
|
|
|
|
General,
|
|
|
|
Controls,
|
|
|
|
Graphics,
|
|
|
|
Sound,
|
|
|
|
Mods,
|
|
|
|
Debug,
|
|
|
|
};
|
|
|
|
|
|
|
|
void set_config_tab(ConfigTab tab);
|
|
|
|
|
2025-01-19 21:00:05 -05:00
|
|
|
enum class ButtonVariant {
|
|
|
|
Primary,
|
|
|
|
Secondary,
|
|
|
|
Tertiary,
|
|
|
|
Success,
|
|
|
|
Error,
|
|
|
|
Warning,
|
|
|
|
NumVariants,
|
|
|
|
};
|
|
|
|
|
|
|
|
void open_prompt(
|
|
|
|
const std::string& headerText,
|
|
|
|
const std::string& contentText,
|
|
|
|
const std::string& confirmLabelText,
|
|
|
|
const std::string& cancelLabelText,
|
|
|
|
std::function<void()> confirmCb,
|
|
|
|
std::function<void()> cancelCb,
|
|
|
|
ButtonVariant _confirmVariant = ButtonVariant::Success,
|
|
|
|
ButtonVariant _cancelVariant = ButtonVariant::Error,
|
|
|
|
bool _focusOnCancel = true,
|
|
|
|
const std::string& _returnElementId = ""
|
|
|
|
);
|
|
|
|
bool is_prompt_open();
|
|
|
|
|
|
|
|
void apply_color_hack();
|
|
|
|
void get_window_size(int& width, int& height);
|
|
|
|
void set_cursor_visible(bool visible);
|
|
|
|
void update_supported_options();
|
|
|
|
void toggle_fullscreen();
|
|
|
|
|
|
|
|
bool get_cont_active(void);
|
|
|
|
void set_cont_active(bool active);
|
|
|
|
void activate_mouse();
|
|
|
|
|
|
|
|
void message_box(const char* msg);
|
|
|
|
|
|
|
|
void set_render_hooks();
|
|
|
|
|
|
|
|
Rml::ElementPtr create_custom_element(Rml::Element* parent, std::string tag);
|
2025-01-20 03:55:22 -05:00
|
|
|
Rml::ElementDocument* load_document(const std::filesystem::path& path);
|
2025-01-20 18:26:50 -05:00
|
|
|
Rml::ElementDocument* create_empty_document();
|
2025-01-28 22:34:03 -03:00
|
|
|
void queue_image_from_bytes(const std::string &src, const std::vector<char> &bytes);
|
|
|
|
void release_image(const std::string &src);
|
2023-11-24 17:10:21 -05:00
|
|
|
}
|
2023-11-11 17:42:07 -05:00
|
|
|
|
2023-11-05 14:34:20 -05:00
|
|
|
#endif
|