11using ImGui::BeginChild;
16using ImGui::Selectable;
22 ImVec2 canvas_p0, ImVec2 scrolling) {
24 const ImGuiIO &io = ImGui::GetIO();
25 const ImVec2 origin(canvas_p0.x + scrolling.x, canvas_p0.y + scrolling.y);
26 const ImVec2 mouse_pos(io.MousePos.x - origin.x, io.MousePos.y - origin.y);
29 if (mouse_pos.x >= entity.
x_ && mouse_pos.x <= entity.
x_ + 16 &&
30 mouse_pos.y >= entity.
y_ && mouse_pos.y <= entity.
y_ + 16) {
37 ImVec2 scrolling,
bool free_movement) {
39 const ImGuiIO &io = ImGui::GetIO();
40 const ImVec2 origin(canvas_p0.x + scrolling.x, canvas_p0.y + scrolling.y);
41 const ImVec2 mouse_pos(io.MousePos.x - origin.x, io.MousePos.y - origin.y);
44 int new_x =
static_cast<int>(mouse_pos.x) / 16 * 16;
45 int new_y =
static_cast<int>(mouse_pos.y) / 16 * 16;
47 new_x =
static_cast<int>(mouse_pos.x) / 8 * 8;
48 new_y =
static_cast<int>(mouse_pos.y) / 8 * 8;
59 bool set_done =
false;
63 if (ImGui::BeginPopup(
"Entrance Inserter")) {
64 static int entrance_id = 0;
69 ImGui::CloseCurrentPopup();
74 ImGui::CloseCurrentPopup();
83 static bool set_done =
false;
89 if (ImGui::BeginPopupModal(
"Entrance Editor", NULL,
90 ImGuiWindowFlags_AlwaysAutoResize)) {
100 ImGui::Checkbox(
"Is Hole", &entrance.
is_hole_);
104 if (Button(
"Save")) {
106 ImGui::CloseCurrentPopup();
109 if (Button(
"Delete")) {
112 ImGui::CloseCurrentPopup();
115 if (Button(
"Cancel")) {
116 ImGui::CloseCurrentPopup();
125 if (ImGui::BeginPopup(
"Exit Inserter")) {
126 static int exit_id = 0;
127 static int room_id = 0;
128 static int x_pos = 0;
129 static int y_pos = 0;
131 ImGui::Text(
"Insert New Exit");
139 if (Button(
"Create Exit")) {
141 ImGui::CloseCurrentPopup();
145 if (Button(
"Cancel")) {
146 ImGui::CloseCurrentPopup();
154 static bool set_done =
false;
158 if (ImGui::BeginPopupModal(
"Exit editor", NULL,
159 ImGuiWindowFlags_AlwaysAutoResize)) {
169 static int centerY = 0;
170 static int centerX = 0;
173 static int linkPosture = 0;
174 static int spriteGFX = 0;
175 static int bgGFX = 0;
176 static int palette = 0;
177 static int sprPal = 0;
179 static int bottom = 0;
181 static int right = 0;
182 static int leftEdgeOfMap = 0;
205 static bool show_properties =
false;
206 Checkbox(
"Show properties", &show_properties);
207 if (show_properties) {
208 Text(
"Deleted? %s", exit.
deleted_ ?
"true" :
"false");
209 Text(
"Hole? %s", exit.
is_hole_ ?
"true" :
"false");
210 Text(
"Large Map? %s", exit.
large_map_ ?
"true" :
"false");
215 ImGui::RadioButton(
"None", &doorType, 0);
217 ImGui::RadioButton(
"Wooden", &doorType, 1);
219 ImGui::RadioButton(
"Bombable", &doorType, 2);
226 ImGui::RadioButton(
"None##Fancy", &fancyDoorType, 0);
228 ImGui::RadioButton(
"Sanctuary", &fancyDoorType, 1);
230 ImGui::RadioButton(
"Palace", &fancyDoorType, 2);
232 if (fancyDoorType != 0) {
239 static bool special_exit =
false;
240 Checkbox(
"Special exit", &special_exit);
263 ImGui::CloseCurrentPopup();
270 ImGui::CloseCurrentPopup();
276 ImGui::CloseCurrentPopup();
287 if (ImGui::BeginPopup(
"Item Inserter")) {
288 static size_t new_item_id = 0;
290 BeginChild(
"ScrollRegion", ImVec2(150, 150),
true,
291 ImGuiWindowFlags_AlwaysVerticalScrollbar);
302 ImGui::CloseCurrentPopup();
307 ImGui::CloseCurrentPopup();
316 static bool set_done =
false;
320 if (ImGui::BeginPopupModal(
"Item editor", NULL,
321 ImGuiWindowFlags_AlwaysAutoResize)) {
322 BeginChild(
"ScrollRegion", ImVec2(150, 150),
true,
323 ImGuiWindowFlags_AlwaysVerticalScrollbar);
337 ImGui::CloseCurrentPopup();
342 ImGui::CloseCurrentPopup();
353 static ImGuiTextFilter filter;
354 static int selected_id = 0;
355 static std::vector<SpriteItem> items;
359 for (
int i = 0; i < 256; ++i) {
360 items.push_back(
SpriteItem{i, zelda3::kSpriteDefaultNames[i].data()});
364 filter.Draw(
"Filter", 180);
366 if (ImGui::BeginTable(
"##sprites", 2,
367 ImGuiTableFlags_Sortable | ImGuiTableFlags_Resizable)) {
368 ImGui::TableSetupColumn(
"ID", ImGuiTableColumnFlags_DefaultSort, 0.0f,
371 ImGui::TableHeadersRow();
374 if (ImGuiTableSortSpecs *sort_specs = ImGui::TableGetSortSpecs()) {
375 if (sort_specs->SpecsDirty) {
377 sort_specs->SpecsDirty =
false;
382 for (
const auto &item : items) {
383 if (filter.PassFilter(item.name)) {
384 ImGui::TableNextRow();
385 ImGui::TableSetColumnIndex(0);
387 ImGui::TableSetColumnIndex(1);
389 if (Selectable(item.name, selected_id == item.id,
390 ImGuiSelectableFlags_SpanAllColumns)) {
391 selected_id = item.id;
392 onSpriteSelect(item.id);
401 if (ImGui::BeginPopup(
"Sprite Inserter")) {
402 static int new_sprite_id = 0;
403 static int x_pos = 0;
404 static int y_pos = 0;
406 ImGui::Text(
"Add New Sprite");
409 BeginChild(
"ScrollRegion", ImVec2(250, 200),
true,
410 ImGuiWindowFlags_AlwaysVerticalScrollbar);
415 ImGui::Text(
"Position:");
419 if (Button(
"Add Sprite")) {
424 ImGui::CloseCurrentPopup();
428 if (Button(
"Cancel")) {
429 ImGui::CloseCurrentPopup();
437 static bool set_done =
false;
441 if (ImGui::BeginPopupModal(
"Sprite editor", NULL,
442 ImGuiWindowFlags_AlwaysAutoResize)) {
443 BeginChild(
"ScrollRegion", ImVec2(350, 350),
true,
444 ImGuiWindowFlags_AlwaysVerticalScrollbar);
446 Text(
"%s", sprite.
name().c_str());
449 sprite.
set_id(selected_id);
459 ImGui::CloseCurrentPopup();
464 ImGui::CloseCurrentPopup();
Base class for all overworld and dungeon entities.
A class for managing sprites in the overworld and underworld.
void UpdateMapProperties(uint16_t map_id) override
auto set_deleted(bool deleted)
void DrawExitInserterPopup()
void MoveEntityOnGrid(zelda3::GameEntity *entity, ImVec2 canvas_p0, ImVec2 scrolling, bool free_movement)
bool DrawSpriteEditorPopup(zelda3::Sprite &sprite)
void DrawItemInsertPopup()
bool DrawEntranceInserterPopup()
void DrawSpriteInserterPopup()
void DrawSpriteTable(std::function< void(int)> onSpriteSelect)
bool DrawOverworldEntrancePopup(zelda3::OverworldEntrance &entrance)
bool IsMouseHoveringOverEntity(const zelda3::GameEntity &entity, ImVec2 canvas_p0, ImVec2 scrolling)
bool DrawItemEditorPopup(zelda3::OverworldItem &item)
constexpr float kInputFieldSize
@ SpriteItemColumnID_Name
bool DrawExitEditorPopup(zelda3::OverworldExit &exit)
bool InputHexWord(const char *label, uint16_t *data, float input_width, bool no_step)
bool InputHex(const char *label, uint64_t *data)
bool InputHexByte(const char *label, uint8_t *data, float input_width, bool no_step)
void TextWithSeparators(const absl::string_view &text)
const std::vector< std::string > kSecretItemNames
Main namespace for the application.
static const ImGuiTableSortSpecs * s_current_sort_specs
static void SortWithSortSpecs(ImGuiTableSortSpecs *sort_specs, std::vector< SpriteItem > &items)