Skip to content

Commit

Permalink
cleanup object widgets header
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz-h committed Dec 27, 2024
1 parent 6d6f7ed commit 69c91f1
Showing 1 changed file with 47 additions and 26 deletions.
73 changes: 47 additions & 26 deletions map/src/MapWindow/UI/ObjectWidgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace s = SatisfactorySave;

namespace Satisfactory3DMap::UI {

// Property Table
bool BeginEditorTable();
void EndEditorTable();
// Need extra Push/Pop for style, because style must be set before BeginTable() and EndEditorTable() must be only
Expand All @@ -33,7 +34,52 @@ namespace Satisfactory3DMap::UI {
void PopEditorTableStyle();

template<typename Callable>
inline void EditorSectionWrap(const char* label, Callable callable) {
void EditorSectionWrap(const char* label, Callable callable);

// Tree Utils
bool TreeNodeSmall(const char* label, ImGuiTreeNodeFlags flags = 0);
bool EditorTreeNode(const char* label, ImGuiTreeNodeFlags flags = 0);
bool EditorTreeStartLeaf(const char* label, ImGuiTreeNodeFlags flags = 0);
void EditorTreeEndLeaf();

// Container Utils
template<typename T, typename Callable>
void EditorList(const char* label, std::vector<T>& list, Callable itemHandler);
template<typename Key_T, typename Value_T, typename Key_Callable, typename Value_Callable>
void EditorMap(const char* label, s::TMap<Key_T, Value_T>& map, Key_Callable keyHandler,
Value_Callable valueHandler);
template<typename T, typename Callable>
void EditorOptional(const char* label, std::optional<T>& opt, Callable itemHandler);

// Text Widgets
void ClassOrPathButton(const std::string& name, const EventContext& ctx = {});
void EditorShowSelectable(const char* label, const std::string& name, const EventContext& ctx = {});
void EditorShowText(const char* label, const char* text);

// Arithmetic Type Widgets
bool EditorBool(const char* label, bool& v);
bool EditorScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step = nullptr,
const void* p_step_fast = nullptr, const char* format = nullptr, ImGuiInputTextFlags flags = 0);

// UE Core Type Widgets
bool EditorName(const char* label, s::FName& name);
bool EditorObjectReference(const char* label, s::FObjectReferenceDisc& r, const EventContext& ctx = {});

// UE Math Type Widgets
bool EditorVector(const char* label, s::FVector& v);
bool EditorQuat(const char* label, s::FQuat& q);
template<typename T>
bool EditorTransform(s::TTransform<T>& t);

// Struct Widgets
bool EditorLinearColor(const char* label, s::FLinearColor& c);
bool EditorInventoryItem(const char* label, s::FInventoryItem& i, const EventContext& ctx = {});
bool EditorConveyorBeltItem(const char* label, s::FConveyorBeltItem& i, const EventContext& ctx = {});

// Template implementations

template<typename Callable>
void EditorSectionWrap(const char* label, Callable callable) {
if (ImGui::CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen)) {
PushEditorTableStyle();
if (BeginEditorTable()) {
Expand All @@ -44,11 +90,6 @@ namespace Satisfactory3DMap::UI {
}
}

bool TreeNodeSmall(const char* label, ImGuiTreeNodeFlags flags = 0);
bool EditorTreeNode(const char* label, ImGuiTreeNodeFlags flags = 0);
bool EditorTreeStartLeaf(const char* label, ImGuiTreeNodeFlags flags = 0);
void EditorTreeEndLeaf();

template<typename T, typename Callable>
void EditorList(const char* label, std::vector<T>& list, Callable itemHandler) {
if (EditorTreeNode(label, ImGuiTreeNodeFlags_DefaultOpen)) {
Expand Down Expand Up @@ -93,26 +134,6 @@ namespace Satisfactory3DMap::UI {
}
}

void ClassOrPathButton(const std::string& name, const EventContext& ctx = {});
void EditorShowSelectable(const char* label, const std::string& name, const EventContext& ctx = {});
void EditorShowText(const char* label, const char* text);

bool EditorBool(const char* label, bool& v);
bool EditorScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step = nullptr,
const void* p_step_fast = nullptr, const char* format = nullptr, ImGuiInputTextFlags flags = 0);

bool EditorName(const char* label, s::FName& name);
bool EditorObjectReference(const char* label, s::FObjectReferenceDisc& r, const EventContext& ctx = {});

bool EditorVector(const char* label, s::FVector& v);
bool EditorQuat(const char* label, s::FQuat& q);

bool EditorLinearColor(const char* label, s::FLinearColor& c);

bool EditorInventoryItem(const char* label, s::FInventoryItem& i, const EventContext& ctx = {});

bool EditorConveyorBeltItem(const char* label, s::FConveyorBeltItem& i, const EventContext& ctx = {});

template<typename T>
bool EditorTransform(s::TTransform<T>& t) {
// For better UX we want to show euler angles in the UI with the full range of 0 to 360 degree on
Expand Down

0 comments on commit 69c91f1

Please sign in to comment.