diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ca8a5d3..a7ccb85d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,29 @@ -# CMake Specifications ------------------------------------------------------------------------------------------- +# CMake Specifications -------------------------------------------------------- cmake_minimum_required(VERSION 3.10) # Yet Another Zelda3 Editor # by scawful project(yaze VERSION 0.01) -# C++ Standard Specifications ------------------------------------------------------------------------------------ -set(CMAKE_CXX_STANDARD 20) +# C++ Standard Specifications ------------------------------------------------- +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS ON) set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMAKE_MODULE_LINKER_FLAGS \"-Wl,--no-undefined -Wl,--no-undefined\") +set(BUILD_SHARED_LIBS ON) + +# Abseil Standard Specifications ---------------------------------------------- +set(ABSL_PROPAGATE_CXX_STD ON) +set(ABSL_CXX_STANDARD 17) +set(ABSL_USE_GOOGLETEST_HEAD ON) +set(ABSL_ENABLE_INSTALL ON) + +add_subdirectory(src/lib/abseil-cpp) # Project Files add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7377fc6f..367e8a48 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,26 +36,25 @@ target_include_directories(NintendoCompression PUBLIC "/usr/local/Cellar/libpng/ add_executable( yaze yaze.cc + app/core/common.cc + app/core/controller.cc + app/editor/assembly_editor.cc + app/editor/dungeon_editor.cc + app/editor/master_editor.cc + app/editor/overworld_editor.cc + app/editor/screen_editor.cc + app/gfx/bitmap.cc + app/gfx/pseudo_vram.cc + app/gfx/snes_palette.cc + app/gfx/snes_tile.cc + app/zelda3/overworld_map.cc + app/zelda3/overworld.cc + app/zelda3/screen.cc + app/rom.cc + gui/canvas.cc gui/input.cc gui/style.cc gui/widgets.cc - gui/canvas.cc - app/editor/master_editor.cc - app/editor/assembly_editor.cc - app/editor/dungeon_editor.cc - app/editor/overworld_editor.cc - app/editor/screen_editor.cc - app/rom.cc - app/core/common.cc - app/core/constants.cc - app/core/controller.cc - app/gfx/bitmap.cc - app/gfx/pseudo_vram.cc - app/gfx/snes_tile.cc - app/gfx/snes_palette.cc - app/zelda3/overworld.cc - app/zelda3/overworld_map.cc - app/zelda3/screen.cc # GUI libraries ${IMGUI_PATH}/imgui.cpp ${IMGUI_PATH}/imgui_demo.cpp @@ -80,9 +79,6 @@ target_include_directories( ${CMAKE_SOURCE_DIR}/src/ lib/ app/ - "C:/msys64/mingw64/include/libpng16" - "C:/msys64/mingw64/include/SDL2" - "C:/msys64/mingw64/include" ${SNESHACKING_PATH} ${PNG_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR} @@ -91,6 +87,10 @@ target_include_directories( target_link_libraries( yaze + absl::strings + absl::flags + absl::status + absl::statusor SDL2main ${PNG_LIBRARIES} ${SDL2_LIBRARIES} diff --git a/src/app/core/constants.cc b/src/app/core/constants.cc deleted file mode 100644 index 2568033d..00000000 --- a/src/app/core/constants.cc +++ /dev/null @@ -1 +0,0 @@ -#include "app/core/constants.h" \ No newline at end of file diff --git a/src/app/core/constants.h b/src/app/core/constants.h index fa279b7f..2b2895f0 100644 --- a/src/app/core/constants.h +++ b/src/app/core/constants.h @@ -1,8 +1,9 @@ #ifndef YAZE_APP_CORE_CONSTANTS_H #define YAZE_APP_CORE_CONSTANTS_H -#include -#include +#include + +#include "absl/strings/string_view.h" #define BASIC_BUTTON(w) if (ImGui::Button(w)) @@ -24,6 +25,7 @@ using ushort = unsigned short; using uint = unsigned int; using uchar = unsigned char; +using Bytes = std::vector; namespace yaze { namespace app { @@ -433,86 +435,86 @@ constexpr int crystalVertices = 0x04FF98; //=========================================================================================== // Names //=========================================================================================== -static const std::string RoomEffect[] = {"Nothing", - "Nothing", - "Moving Floor", - "Moving Water", - "Trinexx Shell", - "Red Flashes", - "Light Torch to See Floor", - "Ganon's Darkness"}; +static const absl::string_view RoomEffect[] = {"Nothing", + "Nothing", + "Moving Floor", + "Moving Water", + "Trinexx Shell", + "Red Flashes", + "Light Torch to See Floor", + "Ganon's Darkness"}; -static const std::string RoomTag[] = {"Nothing", +static const absl::string_view RoomTag[] = {"Nothing", - "NW Kill Enemy to Open", - "NE Kill Enemy to Open", - "SW Kill Enemy to Open", - "SE Kill Enemy to Open", - "W Kill Enemy to Open", - "E Kill Enemy to Open", - "N Kill Enemy to Open", - "S Kill Enemy to Open", - "Clear Quadrant to Open", - "Clear Full Tile to Open", + "NW Kill Enemy to Open", + "NE Kill Enemy to Open", + "SW Kill Enemy to Open", + "SE Kill Enemy to Open", + "W Kill Enemy to Open", + "E Kill Enemy to Open", + "N Kill Enemy to Open", + "S Kill Enemy to Open", + "Clear Quadrant to Open", + "Clear Full Tile to Open", - "NW Push Block to Open", - "NE Push Block to Open", - "SW Push Block to Open", - "SE Push Block to Open", - "W Push Block to Open", - "E Push Block to Open", - "N Push Block to Open", - "S Push Block to Open", - "Push Block to Open", - "Pull Lever to Open", - "Collect Prize to Open", + "NW Push Block to Open", + "NE Push Block to Open", + "SW Push Block to Open", + "SE Push Block to Open", + "W Push Block to Open", + "E Push Block to Open", + "N Push Block to Open", + "S Push Block to Open", + "Push Block to Open", + "Pull Lever to Open", + "Collect Prize to Open", - "Hold Switch Open Door", - "Toggle Switch to Open Door", - "Turn off Water", - "Turn on Water", - "Water Gate", - "Water Twin", - "Moving Wall Right", - "Moving Wall Left", - "Crash", - "Crash", - "Push Switch Exploding Wall", - "Holes 0", - "Open Chest (Holes 0)", - "Holes 1", - "Holes 2", - "Defeat Boss for Dungeon Prize", + "Hold Switch Open Door", + "Toggle Switch to Open Door", + "Turn off Water", + "Turn on Water", + "Water Gate", + "Water Twin", + "Moving Wall Right", + "Moving Wall Left", + "Crash", + "Crash", + "Push Switch Exploding Wall", + "Holes 0", + "Open Chest (Holes 0)", + "Holes 1", + "Holes 2", + "Defeat Boss for Dungeon Prize", - "SE Kill Enemy to Push Block", - "Trigger Switch Chest", - "Pull Lever Exploding Wall", - "NW Kill Enemy for Chest", - "NE Kill Enemy for Chest", - "SW Kill Enemy for Chest", - "SE Kill Enemy for Chest", - "W Kill Enemy for Chest", - "E Kill Enemy for Chest", - "N Kill Enemy for Chest", - "S Kill Enemy for Chest", - "Clear Quadrant for Chest", - "Clear Full Tile for Chest", + "SE Kill Enemy to Push Block", + "Trigger Switch Chest", + "Pull Lever Exploding Wall", + "NW Kill Enemy for Chest", + "NE Kill Enemy for Chest", + "SW Kill Enemy for Chest", + "SE Kill Enemy for Chest", + "W Kill Enemy for Chest", + "E Kill Enemy for Chest", + "N Kill Enemy for Chest", + "S Kill Enemy for Chest", + "Clear Quadrant for Chest", + "Clear Full Tile for Chest", - "Light Torches to Open", - "Holes 3", - "Holes 4", - "Holes 5", - "Holes 6", - "Agahnim Room", - "Holes 7", - "Holes 8", - "Open Chest for Holes 8", - "Push Block for Chest", - "Clear Room for Triforce Door", - "Light Torches for Chest", - "Kill Boss Again"}; + "Light Torches to Open", + "Holes 3", + "Holes 4", + "Holes 5", + "Holes 6", + "Agahnim Room", + "Holes 7", + "Holes 8", + "Open Chest for Holes 8", + "Push Block for Chest", + "Clear Room for Triforce Door", + "Light Torches for Chest", + "Kill Boss Again"}; -static const std::string SecretItemNames[] = { +static const absl::string_view SecretItemNames[] = { "Nothing", "Green Rupee", "Rock hoarder", "Bee", "Health pack", "Bomb", "Heart ", "Blue Rupee", @@ -524,7 +526,7 @@ static const std::string SecretItemNames[] = { "Hole", "Warp", "Staircase", "Bombable", "Switch"}; -static const std::string Type1RoomObjectNames[] = { +static const absl::string_view Type1RoomObjectNames[] = { "Ceiling ↔", "Wall (top, north) ↔", "Wall (top, south) ↔", @@ -775,7 +777,7 @@ static const std::string Type1RoomObjectNames[] = { "Nothing", }; -static const std::string Type2RoomObjectNames[] = { +static const absl::string_view Type2RoomObjectNames[] = { "Corner (top, concave) ▛", "Corner (top, concave) ▙", "Corner (top, concave) ▜", @@ -842,7 +844,7 @@ static const std::string Type2RoomObjectNames[] = { "Magic bat altar", }; -static const std::string Type3RoomObjectNames[] = { +static const absl::string_view Type3RoomObjectNames[] = { "Waterfall face (empty)", "Waterfall face (short)", "Waterfall face (long)", @@ -973,7 +975,7 @@ static const std::string Type3RoomObjectNames[] = { "Nothing", }; -static const std::string TileTypeNames[] = { +static const absl::string_view TileTypeNames[] = { "$00 Nothing (standard floor)", "$01 Collision", "$02 Collision", diff --git a/src/app/editor/master_editor.cc b/src/app/editor/master_editor.cc index 702daaf2..8bf6b4a8 100644 --- a/src/app/editor/master_editor.cc +++ b/src/app/editor/master_editor.cc @@ -6,6 +6,7 @@ #include #include +#include "absl/status/status.h" #include "app/core/constants.h" #include "app/editor/assembly_editor.h" #include "app/editor/dungeon_editor.h" @@ -22,15 +23,6 @@ namespace yaze { namespace app { namespace editor { -MasterEditor::MasterEditor() { - for (int i = 0; i < 8; i++) { - current_palette_[i].x = (i * 0.21f); - current_palette_[i].y = (i * 0.21f); - current_palette_[i].z = (i * 0.21f); - current_palette_[i].w = 1.f; - } -} - MasterEditor::~MasterEditor() { rom_.Close(); } void MasterEditor::SetupScreen(std::shared_ptr renderer) { @@ -59,6 +51,10 @@ void MasterEditor::UpdateScreen() { DrawScreenEditor(); END_TAB_BAR() + if (!status_.ok()) { + gui::widgets::DisplayStatus(status_); + } + ImGui::End(); } @@ -75,6 +71,7 @@ void MasterEditor::DrawYazeMenu() { std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName(); std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath(); rom_.LoadFromFile(filePathName); + status_ = rom_.OpenFromFile(filePathName); overworld_editor_.SetupROM(rom_); } ImGuiFileDialog::Instance()->Close(); diff --git a/src/app/editor/master_editor.h b/src/app/editor/master_editor.h index cbac0e20..debc2e42 100644 --- a/src/app/editor/master_editor.h +++ b/src/app/editor/master_editor.h @@ -7,6 +7,7 @@ #include #include +#include "absl/status/status.h" #include "app/core/constants.h" #include "app/editor/assembly_editor.h" #include "app/editor/dungeon_editor.h" @@ -25,7 +26,6 @@ namespace editor { class MasterEditor { public: - MasterEditor(); ~MasterEditor(); void SetupScreen(std::shared_ptr renderer); void UpdateScreen(); @@ -48,6 +48,8 @@ class MasterEditor { DungeonEditor dungeon_editor_; ScreenEditor screen_editor_; + absl::Status status_; + ImVec4 current_palette_[8]; ImGuiWindowFlags main_editor_flags_ = diff --git a/src/app/editor/overworld_editor.cc b/src/app/editor/overworld_editor.cc index ece5b183..458de3ed 100644 --- a/src/app/editor/overworld_editor.cc +++ b/src/app/editor/overworld_editor.cc @@ -198,26 +198,26 @@ void OverworldEditor::DrawOverworldCanvas() { overworld_map_canvas_.DrawBackground(); overworld_map_canvas_.UpdateContext(); overworld_map_canvas_.DrawGrid(64.f); - if (all_gfx_loaded_) { - static bool tiles_made = false; - static std::vector tiles; - if (!tiles_made) { - tiles = graphics_bin_.at(0).CreateTiles(); - auto renderer = rom_.Renderer(); - for (auto &tile : tiles) { - tile.CreateTexture(renderer); - } - } + // if (all_gfx_loaded_) { + // static bool tiles_made = false; + // static std::vector tiles; + // if (!tiles_made) { + // tiles = graphics_bin_.at(0).CreateTiles(); + // auto renderer = rom_.Renderer(); + // for (auto &tile : tiles) { + // tile.CreateTexture(renderer); + // } + // } - overworld_map_canvas_.GetDrawList()->AddImage( - (void *)tiles[0].GetTexture(), - ImVec2(overworld_map_canvas_.GetZeroPoint().x + 2, - overworld_map_canvas_.GetZeroPoint().y + 2), - ImVec2( - overworld_map_canvas_.GetZeroPoint().x + (tiles[0].GetWidth() * 2), - overworld_map_canvas_.GetZeroPoint().y + - (tiles[0].GetHeight() * 2))); - } + // overworld_map_canvas_.GetDrawList()->AddImage( + // (void *)tiles[0].GetTexture(), + // ImVec2(overworld_map_canvas_.GetZeroPoint().x + 2, + // overworld_map_canvas_.GetZeroPoint().y + 2), + // ImVec2( + // overworld_map_canvas_.GetZeroPoint().x + (tiles[0].GetWidth() * + // 2), overworld_map_canvas_.GetZeroPoint().y + + // (tiles[0].GetHeight() * 2))); + // } overworld_map_canvas_.DrawOverlay(); } @@ -309,6 +309,13 @@ void OverworldEditor::DrawAreaGraphics() { } void OverworldEditor::LoadGraphics() { + for (int i = 0; i < 8; i++) { + current_palette_[i].x = (i * 0.21f); + current_palette_[i].y = (i * 0.21f); + current_palette_[i].z = (i * 0.21f); + current_palette_[i].w = 1.f; + } + rom_.LoadAllGraphicsData(); graphics_bin_ = rom_.GetGraphicsBin(); tile16_blockset_bmp_.Create(128 * 2, 8192 * 2, 8, 1048576); diff --git a/src/app/rom.cc b/src/app/rom.cc index 03386a0d..19b6d6a3 100644 --- a/src/app/rom.cc +++ b/src/app/rom.cc @@ -9,6 +9,11 @@ #include #include +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" #include "app/core/common.h" #include "app/core/constants.h" #include "app/gfx/pseudo_vram.h" @@ -17,6 +22,24 @@ namespace yaze { namespace app { +absl::Status ROM::OpenFromFile(const absl::string_view &filename) { + std::ifstream file(filename.data(), std::ios::binary); + if (!file.is_open()) { + return absl::InternalError( + absl::StrCat("Could not open ROM file ", filename)); + } + size_ = std::filesystem::file_size(filename); + rom_data_.resize(size_); + for (auto i = 0; i < size_; ++i) { + char byte_to_read = ' '; + file.read(&byte_to_read, sizeof(char)); + rom_data_[i] = byte_to_read; + } + file.close(); + is_loaded_ = true; + return absl::OkStatus(); +} + void ROM::Close() { if (is_loaded_) { delete[] current_rom_; @@ -187,6 +210,137 @@ uchar *ROM::Decompress(int pos, int size, bool reversed) { return buffer; } +absl::StatusOr ROM::DecompressV2(int offset, int size, bool reversed) { + Bytes buffer(size); + uint length = 0; + uint buffer_pos = 0; + uchar cmd = 0; + + uchar databyte = rom_data_[offset]; + while (databyte != 0xFF) { // End of decompression + databyte = rom_data_[offset]; + + // Expanded Command + if ((databyte & 0xE0) == 0xE0) { + cmd = ((databyte >> 2) & 0x07); + length = (((rom_data_[offset] << 8) | rom_data_[offset + 1]) & 0x3FF); + offset += 2; // Advance 2 bytes in ROM + } else { // Normal Command + cmd = ((databyte >> 5) & 0x07); + length = (databyte & 0x1F); + offset += 1; // Advance 1 byte in ROM + } + length += 1; // each commands is at least of size 1 even if index 00 + + switch (cmd) { + case kCommandDirectCopy: + for (int i = 0; i < length; i++) { + buffer[buffer_pos++] = rom_data_[offset++]; + } + // Do not advance in the ROM + break; + case kCommandByteFill: + for (int i = 0; i < length; i++) { + buffer[buffer_pos++] = rom_data_[offset]; + } + offset += 1; // Advance 1 byte in the ROM + break; + case kCommandWordFill: + for (int i = 0; i < length; i += 2) { + buffer[buffer_pos++] = rom_data_[offset]; + buffer[buffer_pos++] = rom_data_[offset + 1]; + } + offset += 2; // Advance 2 byte in the ROM + break; + case kCommandIncreasingFill: { + uchar inc_byte = rom_data_[offset]; + for (int i = 0; i < length; i++) { + buffer[buffer_pos++] = inc_byte++; + } + offset += 1; // Advance 1 byte in the ROM + } break; + case kCommandRepeatingBytes: { + ushort s1 = ((rom_data_[offset + 1] & 0xFF) << 8); + ushort s2 = ((rom_data_[offset] & 0xFF)); + // Reversed byte order for overworld maps + if (reversed) { + auto addr = (rom_data_[offset + 2]) | ((rom_data_[offset + 1]) << 8); + + if (addr > buffer_pos) { + return absl::InternalError( + absl::StrFormat("DecompressOverworldV2: Offset for command " + "copy existing is larger than the current " + "position (Offset : %#04x | Pos %#06x\n", + addr, buffer_pos)); + } + + if (buffer_pos + length >= size) { + size *= 2; + buffer.resize(size); + std::cout << "DecompressOverworldV2: Reallocating buffer"; + } + memcpy(buffer.data() + buffer_pos, rom_data_.data() + offset, length); + offset += 2; + } else { + auto addr = (ushort)(s1 | s2); + for (int i = 0; i < length; i++) { + buffer[buffer_pos] = buffer[addr + i]; + buffer_pos++; + } + offset += 2; // Advance 2 bytes in the ROM + } + } break; + default: { + return absl::InternalError( + "DecompressV2: Invalid command in the header for decompression"); + } + } + } + + return buffer; +} + +absl::StatusOr ROM::Convert3bppTo8bppSheet(Bytes sheet, int size) { + Bytes sheet_buffer_out(size); + int xx = 0; // positions where we are at on the sheet + int yy = 0; + int pos = 0; + int ypos = 0; + + // for each tiles, 16 per line + for (int i = 0; i < 64; i++) { + // for each line + for (int y = 0; y < 8; y++) { + //[0] + [1] + [16] + for (int x = 0; x < 8; x++) { + auto b1 = ((sheet[(y * 2) + (24 * pos)] & (kGraphicsBitmap[x]))); + auto b2 = (sheet[((y * 2) + (24 * pos)) + 1] & (kGraphicsBitmap[x])); + auto b3 = (sheet[(16 + y) + (24 * pos)] & (kGraphicsBitmap[x])); + unsigned char b = 0; + if (b1 != 0) { + b |= 1; + } + if (b2 != 0) { + b |= 2; + } + if (b3 != 0) { + b |= 4; + } + sheet_buffer_out[x + (xx) + (y * 128) + (yy * 1024)] = b; + } + } + pos++; + ypos++; + xx += 8; + if (ypos >= 16) { + yy++; + xx = 0; + ypos = 0; + } + } + return sheet_buffer_out; +} + // 128x32 uchar *ROM::SNES3bppTo8bppSheet(uchar *buffer_in, int sheet_id, int size) { // 8bpp sheet out diff --git a/src/app/rom.h b/src/app/rom.h index 66976e71..879590f1 100644 --- a/src/app/rom.h +++ b/src/app/rom.h @@ -10,6 +10,11 @@ #include #include +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include "absl/strings/string_view.h" #include "app/core/common.h" #include "app/core/constants.h" #include "app/gfx/pseudo_vram.h" @@ -18,12 +23,6 @@ namespace yaze { namespace app { -struct OWMapTiles { - std::vector> light_world; // 64 maps * (32*32 tiles) - std::vector> dark_world; // 64 maps * (32*32 tiles) - std::vector> special_world; // 32 maps * (32*32 tiles) -} typedef OWMapTiles; - constexpr int kCommandDirectCopy = 0; constexpr int kCommandByteFill = 1; constexpr int kCommandWordFill = 2; @@ -31,8 +30,17 @@ constexpr int kCommandIncreasingFill = 3; constexpr int kCommandRepeatingBytes = 4; constexpr uchar kGraphicsBitmap[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; + +struct OWMapTiles { + std::vector> light_world; // 64 maps * (32*32 tiles) + std::vector> dark_world; // 64 maps * (32*32 tiles) + std::vector> special_world; // 32 maps * (32*32 tiles) +} typedef OWMapTiles; + class ROM { public: + absl::Status OpenFromFile(const absl::string_view& filename); + void Close(); void SetupRenderer(std::shared_ptr renderer); void LoadFromFile(const std::string& path); @@ -44,6 +52,11 @@ class ROM { uchar* DecompressGraphics(int pos, int size); uchar* DecompressOverworld(int pos, int size); uchar* Decompress(int pos, int size = 0x800, bool reversed = false); + + absl::StatusOr DecompressV2(int offset, int size = 0x800, + bool reversed = false); + absl::StatusOr Convert3bppTo8bppSheet(Bytes sheet, int size = 0x1000); + uchar* SNES3bppTo8bppSheet(uchar* buffer_in, int sheet_id = 0, int size = 0x1000); @@ -69,6 +82,8 @@ class ROM { ImVec4 display_palette_[8]; gfx::pseudo_vram pseudo_vram_; + std::vector rom_data_; + std::vector decompressed_graphic_sheets_; std::vector converted_graphic_sheets_; std::shared_ptr sdl_renderer_; diff --git a/src/gui/widgets.cc b/src/gui/widgets.cc index a3259ece..66fb06fe 100644 --- a/src/gui/widgets.cc +++ b/src/gui/widgets.cc @@ -1,15 +1,53 @@ #include "widgets.h" +#include + +#include "absl/status/status.h" #include "app/core/constants.h" namespace yaze { namespace gui { namespace widgets { +bool BeginCentered(const char *name) { + ImGuiIO &io = ImGui::GetIO(); + ImVec2 pos(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f); + ImGui::SetNextWindowPos(pos, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); + ImGuiWindowFlags flags = ImGuiWindowFlags_NoMove | + ImGuiWindowFlags_NoDecoration | + ImGuiWindowFlags_AlwaysAutoResize; + return ImGui::Begin(name, nullptr, flags); +} + +void DisplayStatus(const absl::Status &status) { + static bool display_open = true; + if (display_open) { + auto title = absl::StrCat("StatusWindow_", status.ToString()).data(); + if (BeginCentered(title)) { + ImGui::Text(status.ToString().data()); + + ImGui::Spacing(); + ImGui::NextColumn(); + + ImGui::Columns(1); + ImGui::Separator(); + + ImGui::NewLine(); + + ImGui::SameLine(270); + // click ok when finished adjusting + if (ImGui::Button("OK", ImVec2(200, 0))) { + display_open = false; + } + + ImGui::End(); + } + } +} + TextEditor::LanguageDefinition GetAssemblyLanguageDef() { TextEditor::LanguageDefinition language_65816; - for (auto &k : app::core::kKeywords) - language_65816.mKeywords.emplace(k); + for (auto &k : app::core::kKeywords) language_65816.mKeywords.emplace(k); for (auto &k : app::core::kIdentifiers) { TextEditor::Identifier id; diff --git a/src/gui/widgets.h b/src/gui/widgets.h index 305d84f7..b230250e 100644 --- a/src/gui/widgets.h +++ b/src/gui/widgets.h @@ -3,13 +3,18 @@ #include +#include "absl/status/status.h" +#include "app/core/constants.h" + namespace yaze { namespace gui { namespace widgets { +void DisplayStatus(const absl::Status& status); + TextEditor::LanguageDefinition GetAssemblyLanguageDef(); -} +} // namespace widgets } // namespace gui } // namespace yaze diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 35ffbff0..12df25f4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,12 +4,12 @@ FetchContent_Declare( googletest URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip ) + # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) enable_testing() -find_package(PNG REQUIRED) find_package(SDL2 REQUIRED) set(SNESHACKING_PATH "../src/lib/sneshacking/src") @@ -26,7 +26,6 @@ add_executable( ${SNESHACKING_PATH}/compressions/alttpcompression.c ${SNESHACKING_PATH}/compressions/stdnintendo.c ${SNESHACKING_PATH}/tile.c - ${SNESHACKING_PATH}/tilepng.c ${SNESHACKING_PATH}/palette.c ${SNESHACKING_PATH}/rommapping.c ${SNESHACKING_PATH}/mapping_lorom.c @@ -42,7 +41,10 @@ target_include_directories( target_link_libraries( yaze_test - ${PNG_LIBRARIES} + absl::strings + absl::flags + absl::status + absl::statusor ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES} NintendoCompression