17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-30 21:20:28 +01:00

feat(editor): user-defined model sets, random insert from set, tabbed editor panel

This commit is contained in:
2026-10-01 18:41:35 +02:00
parent 39dd1c057f
commit 1497d081ff
10 changed files with 1033 additions and 271 deletions

View File

@@ -11,6 +11,8 @@ http://mozilla.org/MPL/2.0/.
#include "application/uilayer.h"
#include "utilities/Classes.h"
#include <functional>
/*
// helper, associated bool is set when the primary value was changed and expects processing at the observer's leisure
template<typename Type_>
@@ -37,6 +39,8 @@ class itemproperties_panel : public ui_panel
// are still treated as read-only.
void update(scene::basic_node *Node);
void render() override;
// panel content without the window, also drawn inside the toolset window
void render_body();
private:
// methods
@@ -53,22 +57,35 @@ class itemproperties_panel : public ui_panel
std::vector<text_line> m_grouplines;
};
class brush_object_list : public ui_panel
// reference to a set of node templates, used by the random insert, the brush and the area fill
struct model_set_ref
{
enum class source
{
manual, // list assembled by hand in the tool itself (or no set, where the tool has no such list)
user, // user-defined set (see EditorModelSets), id == set id
nodebank // node bank group, id == group index (as returned by nodebank_panel::group_names())
};
source kind{source::manual};
int id{-1};
};
class nodebank_panel;
// brush settings, drawn inside the node bank window when the brush mode is active
class brush_object_list
{
private:
int idx;
static bool VectorGetter(void *data, int idx, const char **out_text);
std::string Template;
int idx{-1};
public:
brush_object_list(std::string const &Name, bool const Isopen);
void render() override;
void update(std::string nodeTemplate);
void render_options(nodebank_panel &Bank);
// class use
std::vector<std::string> Objects;
std::vector<std::string> Objects; // manual list, used when source is set to manual
std::string *GetRandomObject();
bool useRandom = {false};
model_set_ref source;
float spacing{1.0f};
};
@@ -96,13 +113,39 @@ class nodebank_panel : public ui_panel
// node templates of the group with specified index (as returned by group_names())
std::vector<std::string> group_templates(std::size_t const Group) const;
// model sets (user-defined sets and node bank groups)
// combo selecting a set. Manuallabel names the tool's own hand-made list; nullptr hides that choice. returns: true on change
bool set_combo(char const *Label, model_set_ref &Ref, char const *Manuallabel);
// list of templates assembled by hand, with buttons to add the node bank selection, remove entries and save it as a user set
void manual_list(char const *Id, std::vector<std::string> &List, int &Selected);
// node templates of referenced set; empty for the manual list or a set which no longer exists
std::vector<std::string const *> set_entries(model_set_ref const &Ref) const;
// random template from referenced set, or nullptr if the set is empty
std::string const *random_template(model_set_ref const &Ref) const;
std::string set_name(model_set_ref const &Ref, char const *Manuallabel) const;
// shows the set manager window, optionally with specified user set selected
void open_sets_window(int const Setid = 0);
// draws settings of the active edit mode inside its tab
std::function<void(edit_mode)> mode_options;
// draws sections attached above the mode tabs (gizmo, node properties)
std::function<void()> header_sections;
private:
// methods:
std::string generate_node_label(std::string Input) const;
void render_sets_window();
// members:
std::vector<std::pair<std::string, std::shared_ptr<std::string>>> m_nodebank;
char m_nodesearch[128];
std::shared_ptr<std::string> m_selectedtemplate;
// set manager window
bool m_setsopen{false};
int m_setsselected{0}; // id of the user set being edited
int m_setsentry{-1}; // selected template of the edited set
int m_setsnameid{0}; // id of the set whose name is held in the edit buffer
char m_setsname[128]{};
model_set_ref m_setsgroup{model_set_ref::source::nodebank, 0}; // node bank group to append to the edited set
};
class functions_panel : public ui_panel
@@ -124,6 +167,8 @@ class functions_panel : public ui_panel
void update(scene::basic_node const *Node);
void render() override;
// rotation settings widgets, also drawn inside the node bank window
void render_controls();
private:
// methods