Refactor code to remove unused headers and unnecessary includes

This commit is contained in:
scawful
2024-09-25 00:37:23 -04:00
parent 0e32fe89e1
commit c31f3b81be
5 changed files with 35 additions and 25 deletions

View File

@@ -2,9 +2,7 @@
#include "absl/status/status.h" #include "absl/status/status.h"
#include "app/gfx/snes_palette.h" #include "app/gfx/snes_palette.h"
#include "app/gui/canvas.h"
#include "app/gui/color.h" #include "app/gui/color.h"
#include "app/gui/icons.h"
#include "app/gui/style.h" #include "app/gui/style.h"
#include "imgui/imgui.h" #include "imgui/imgui.h"

View File

@@ -8,7 +8,6 @@ namespace app {
namespace editor { namespace editor {
using ImGui::BeginChild; using ImGui::BeginChild;
using ImGui::BeginGroup;
using ImGui::Button; using ImGui::Button;
using ImGui::Checkbox; using ImGui::Checkbox;
using ImGui::EndChild; using ImGui::EndChild;

View File

@@ -202,7 +202,7 @@ void OverworldEditor::DrawToolset() {
HOVER_HINT("Copy Map to Clipboard"); HOVER_HINT("Copy Map to Clipboard");
TableNextColumn(); // Palette TableNextColumn(); // Palette
DisplayPalette(palette_, overworld_.is_loaded()); status_ = DisplayPalette(palette_, overworld_.is_loaded());
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
@@ -514,8 +514,10 @@ void OverworldEditor::CheckForOverworldEdits() {
int end_x = std::floor(end.x / kTile16Size) * kTile16Size; int end_x = std::floor(end.x / kTile16Size) * kTile16Size;
int end_y = std::floor(end.y / kTile16Size) * kTile16Size; int end_y = std::floor(end.y / kTile16Size) * kTile16Size;
if (start_x > end_x) std::swap(start_x, end_x); if (start_x > end_x)
if (start_y > end_y) std::swap(start_y, end_y); std::swap(start_x, end_x);
if (start_y > end_y)
std::swap(start_y, end_y);
constexpr int local_map_size = 512; // Size of each local map constexpr int local_map_size = 512; // Size of each local map
// Number of tiles per local map (since each tile is 16x16) // Number of tiles per local map (since each tile is 16x16)
@@ -668,7 +670,8 @@ void OverworldEditor::DrawOverworldCanvas() {
if (current_mode == EditingMode::DRAW_TILE) { if (current_mode == EditingMode::DRAW_TILE) {
CheckForOverworldEdits(); CheckForOverworldEdits();
} }
if (IsItemHovered()) status_ = CheckForCurrentMap(); if (IsItemHovered())
status_ = CheckForCurrentMap();
} }
ow_map_canvas_.DrawGrid(); ow_map_canvas_.DrawGrid();
@@ -1146,7 +1149,8 @@ void OverworldEditor::RefreshOverworldMap() {
// We need to update the map and its siblings if it's a large map // We need to update the map and its siblings if it's a large map
for (int i = 1; i < 4; i++) { for (int i = 1; i < 4; i++) {
int sibling_index = overworld_.overworld_map(source_map_id)->parent() + i; int sibling_index = overworld_.overworld_map(source_map_id)->parent() + i;
if (i >= 2) sibling_index += 6; if (i >= 2)
sibling_index += 6;
futures.push_back( futures.push_back(
std::async(std::launch::async, refresh_map_async, sibling_index)); std::async(std::launch::async, refresh_map_async, sibling_index));
indices[i] = sibling_index; indices[i] = sibling_index;
@@ -1175,7 +1179,8 @@ absl::Status OverworldEditor::RefreshMapPalette() {
// We need to update the map and its siblings if it's a large map // We need to update the map and its siblings if it's a large map
for (int i = 1; i < 4; i++) { for (int i = 1; i < 4; i++) {
int sibling_index = overworld_.overworld_map(current_map_)->parent() + i; int sibling_index = overworld_.overworld_map(current_map_)->parent() + i;
if (i >= 2) sibling_index += 6; if (i >= 2)
sibling_index += 6;
RETURN_IF_ERROR( RETURN_IF_ERROR(
overworld_.mutable_overworld_map(sibling_index)->LoadPalette()); overworld_.mutable_overworld_map(sibling_index)->LoadPalette());
RETURN_IF_ERROR( RETURN_IF_ERROR(
@@ -1433,9 +1438,8 @@ void OverworldEditor::DrawUsageGrid() {
// Set highlight color if needed // Set highlight color if needed
if (highlight) { if (highlight) {
PushStyleColor( PushStyleColor(ImGuiCol_Button, ImVec4(1.0f, 0.5f, 0.0f,
ImGuiCol_Button, 1.0f)); // Or any highlight color
ImVec4(1.0f, 0.5f, 0.0f, 1.0f)); // Or any highlight color
} }
// Create a button or selectable for each square // Create a button or selectable for each square

View File

@@ -66,13 +66,17 @@ constexpr absl::string_view kTileSelectorTab = "##TileSelectorTabBar";
constexpr absl::string_view kOWEditTable = "##OWEditTable"; constexpr absl::string_view kOWEditTable = "##OWEditTable";
constexpr absl::string_view kOWMapTable = "#MapSettingsTable"; constexpr absl::string_view kOWMapTable = "#MapSettingsTable";
constexpr int kEntranceTileTypePtrLow = 0xDB8BF;
constexpr int kEntranceTileTypePtrHigh = 0xDB917;
constexpr int kNumEntranceTileTypes = 0x2C;
class EntranceContext { class EntranceContext {
public: public:
absl::Status LoadEntranceTileTypes(Rom& rom) { absl::Status LoadEntranceTileTypes(Rom& rom) {
int offset_low = 0xDB8BF; int offset_low = kEntranceTileTypePtrLow;
int offset_high = 0xDB917; int offset_high = kEntranceTileTypePtrHigh;
for (int i = 0; i < 0x2C; i++) { for (int i = 0; i < kNumEntranceTileTypes; i++) {
// Load entrance tile types // Load entrance tile types
ASSIGN_OR_RETURN(auto value_low, rom.ReadWord(offset_low + i)); ASSIGN_OR_RETURN(auto value_low, rom.ReadWord(offset_low + i));
entrance_tile_types_low_.push_back(value_low); entrance_tile_types_low_.push_back(value_low);
@@ -157,6 +161,10 @@ class OverworldEditor : public Editor,
* @brief Draws the overworld map settings. Graphics, palettes, etc. * @brief Draws the overworld map settings. Graphics, palettes, etc.
*/ */
void DrawOverworldMapSettings(); void DrawOverworldMapSettings();
/**
* @brief Draw the overworld settings for ZSCustomOverworld.
*/
void DrawCustomOverworldMapSettings(); void DrawCustomOverworldMapSettings();
void RefreshChildMap(int i); void RefreshChildMap(int i);

View File

@@ -13,6 +13,7 @@ class Command {
public: public:
virtual ~Command() = default; virtual ~Command() = default;
virtual void Execute() = 0; virtual void Execute() = 0;
virtual std::string GetDescription() const = 0;
}; };
class CommandManager { class CommandManager {