yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
entity.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_OVERWORLD_ENTITY_H
2#define YAZE_APP_EDITOR_OVERWORLD_ENTITY_H
3
4#include "imgui/imgui.h"
5
6#include "app/zelda3/common.h"
8
9namespace yaze {
10namespace app {
11namespace editor {
12
13bool IsMouseHoveringOverEntity(const zelda3::GameEntity &entity,
14 ImVec2 canvas_p0, ImVec2 scrolling);
15
16void MoveEntityOnGrid(zelda3::GameEntity *entity, ImVec2 canvas_p0,
17 ImVec2 scrolling, bool free_movement = false);
18
19void HandleEntityDragging(zelda3::GameEntity *entity, ImVec2 canvas_p0,
20 ImVec2 scrolling, bool &is_dragging_entity,
21 zelda3::GameEntity *&dragged_entity,
22 zelda3::GameEntity *&current_entity,
23 bool free_movement = false);
24
26bool DrawOverworldEntrancePopup(zelda3::overworld::OverworldEntrance &entrance);
27
29bool DrawExitEditorPopup(zelda3::overworld::OverworldExit &exit);
30
32
33bool DrawItemEditorPopup(zelda3::overworld::OverworldItem &item);
34
42
43struct SpriteItem {
44 int id;
45 const char *name;
46 static const ImGuiTableSortSpecs *s_current_sort_specs;
47
48 static void SortWithSortSpecs(ImGuiTableSortSpecs *sort_specs,
49 std::vector<SpriteItem> &items) {
51 sort_specs; // Store for access by the compare function.
52 if (items.size() > 1)
53 std::sort(items.begin(), items.end(), SpriteItem::CompareWithSortSpecs);
54 s_current_sort_specs = nullptr;
55 }
56
57 static bool CompareWithSortSpecs(const SpriteItem &a, const SpriteItem &b) {
58 for (int n = 0; n < s_current_sort_specs->SpecsCount; n++) {
59 const ImGuiTableColumnSortSpecs *sort_spec =
60 &s_current_sort_specs->Specs[n];
61 int delta = 0;
62 switch (sort_spec->ColumnUserID) {
64 delta = (a.id - b.id);
65 break;
67 delta = strcmp(a.name + 2, b.name + 2);
68 break;
69 }
70 if (delta != 0)
71 return (sort_spec->SortDirection == ImGuiSortDirection_Ascending)
72 ? delta < 0
73 : delta > 0;
74 }
75 return a.id < b.id; // Fallback
76 }
77};
78
79void DrawSpriteTable(std::function<void(int)> onSpriteSelect);
82
83} // namespace editor
84} // namespace app
85} // namespace yaze
86
87#endif // YAZE_APP_EDITOR_OVERWORLD_ENTITY_H
A class for managing sprites in the overworld and underworld.
Definition sprite.h:280
void DrawSpriteInserterPopup()
Definition entity.cc:431
bool IsMouseHoveringOverEntity(const zelda3::GameEntity &entity, ImVec2 canvas_p0, ImVec2 scrolling)
Definition entity.cc:21
bool DrawEntranceInserterPopup()
Definition entity.cc:105
bool DrawExitEditorPopup(zelda3::overworld::OverworldExit &exit)
Definition entity.cc:181
@ MyItemColumnID_Description
Definition entity.h:40
@ MyItemColumnID_Action
Definition entity.h:38
@ MyItemColumnID_Quantity
Definition entity.h:39
bool DrawOverworldEntrancePopup(zelda3::overworld::OverworldEntrance &entrance)
Definition entity.cc:130
bool DrawSpriteEditorPopup(zelda3::Sprite &sprite)
Definition entity.cc:455
void DrawItemInsertPopup()
Definition entity.cc:313
void DrawExitInserterPopup()
Definition entity.cc:163
void MoveEntityOnGrid(zelda3::GameEntity *entity, ImVec2 canvas_p0, ImVec2 scrolling, bool free_movement)
Definition entity.cc:36
void DrawSpriteTable(std::function< void(int)> onSpriteSelect)
Definition entity.cc:382
void HandleEntityDragging(zelda3::GameEntity *entity, ImVec2 canvas_p0, ImVec2 scrolling, bool &is_dragging_entity, zelda3::GameEntity *&dragged_entity, zelda3::GameEntity *&current_entity, bool free_movement)
Definition entity.cc:56
bool DrawItemEditorPopup(zelda3::overworld::OverworldItem &item)
Definition entity.cc:344
Definition common.cc:22
static const ImGuiTableSortSpecs * s_current_sort_specs
Definition entity.h:46
static bool CompareWithSortSpecs(const SpriteItem &a, const SpriteItem &b)
Definition entity.h:57
static void SortWithSortSpecs(ImGuiTableSortSpecs *sort_specs, std::vector< SpriteItem > &items)
Definition entity.h:48