Created DungeonEditor and Canvas
This commit is contained in:
58
src/app/editor/dungeon_editor.cc
Normal file
58
src/app/editor/dungeon_editor.cc
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "dungeon_editor.h"
|
||||
|
||||
#include "gui/icons.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
namespace editor {
|
||||
|
||||
void DungeonEditor::Update() {
|
||||
DrawToolset();
|
||||
canvas_.Update();
|
||||
}
|
||||
|
||||
void DungeonEditor::DrawToolset() {
|
||||
if (ImGui::BeginTable("DWToolset", 9, toolset_table_flags_, ImVec2(0, 0))) {
|
||||
ImGui::TableSetupColumn("#undoTool");
|
||||
ImGui::TableSetupColumn("#redoTool");
|
||||
ImGui::TableSetupColumn("#history");
|
||||
ImGui::TableSetupColumn("#separator");
|
||||
ImGui::TableSetupColumn("#bg1Tool");
|
||||
ImGui::TableSetupColumn("#bg2Tool");
|
||||
ImGui::TableSetupColumn("#bg3Tool");
|
||||
ImGui::TableSetupColumn("#itemTool");
|
||||
ImGui::TableSetupColumn("#spriteTool");
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_UNDO);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_REDO);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_MANAGE_HISTORY);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(ICON_MD_MORE_VERT);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_FILTER_1);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_FILTER_2);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_FILTER_3);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_GRASS);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_PEST_CONTROL_RODENT);
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace editor
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
26
src/app/editor/dungeon_editor.h
Normal file
26
src/app/editor/dungeon_editor.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef YAZE_APP_EDITOR_DUNGEONEDITOR_H
|
||||
#define YAZE_APP_EDITOR_DUNGEONEDITOR_H
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include "gui/icons.h"
|
||||
#include "gui/canvas.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
namespace editor {
|
||||
class DungeonEditor {
|
||||
public:
|
||||
void Update();
|
||||
|
||||
private:
|
||||
void DrawToolset();
|
||||
|
||||
gui::Canvas canvas_;
|
||||
ImGuiTableFlags toolset_table_flags_ = ImGuiTableFlags_SizingFixedFit;
|
||||
};
|
||||
} // namespace editor
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
|
||||
#endif
|
||||
@@ -7,10 +7,13 @@
|
||||
#include <imgui/misc/cpp/imgui_stdlib.h>
|
||||
|
||||
#include "app/core/constants.h"
|
||||
#include "app/editor/assembly_editor.h"
|
||||
#include "app/editor/dungeon_editor.h"
|
||||
#include "app/editor/overworld_editor.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/tile.h"
|
||||
#include "app/rom.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "gui/input.h"
|
||||
#include "gui/widgets.h"
|
||||
@@ -20,9 +23,6 @@ namespace app {
|
||||
namespace editor {
|
||||
|
||||
Editor::Editor() {
|
||||
asm_editor_.SetLanguageDefinition(gui::widgets::GetAssemblyLanguageDef());
|
||||
asm_editor_.SetPalette(TextEditor::GetDarkPalette());
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
current_palette_[i].x = (i * 0.21f);
|
||||
current_palette_[i].y = (i * 0.21f);
|
||||
@@ -346,67 +346,25 @@ void Editor::DrawProjectEditor() {
|
||||
}
|
||||
|
||||
void Editor::DrawOverworldEditor() {
|
||||
if (ImGui::BeginTabItem("Overworld")) {
|
||||
overworld_editor_.Update();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
TAB_ITEM("Overworld")
|
||||
overworld_editor_.Update();
|
||||
END_TAB_ITEM()
|
||||
}
|
||||
|
||||
void Editor::DrawDungeonEditor() {
|
||||
if (ImGui::BeginTabItem("Dungeon")) {
|
||||
if (ImGui::BeginTable("DWToolset", 9, toolset_table_flags_, ImVec2(0, 0))) {
|
||||
ImGui::TableSetupColumn("#undoTool");
|
||||
ImGui::TableSetupColumn("#redoTool");
|
||||
ImGui::TableSetupColumn("#history");
|
||||
ImGui::TableSetupColumn("#separator");
|
||||
ImGui::TableSetupColumn("#bg1Tool");
|
||||
ImGui::TableSetupColumn("#bg2Tool");
|
||||
ImGui::TableSetupColumn("#bg3Tool");
|
||||
ImGui::TableSetupColumn("#itemTool");
|
||||
ImGui::TableSetupColumn("#spriteTool");
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_UNDO);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_REDO);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_MANAGE_HISTORY);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(ICON_MD_MORE_VERT);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_FILTER_1);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_FILTER_2);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_FILTER_3);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_GRASS);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_PEST_CONTROL_RODENT);
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
TAB_ITEM("Dungeon")
|
||||
dungeon_editor_.Update();
|
||||
END_TAB_ITEM()
|
||||
}
|
||||
|
||||
void Editor::DrawGraphicsEditor() {
|
||||
if (ImGui::BeginTabItem("Graphics")) {
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
TAB_ITEM("Graphics")
|
||||
END_TAB_ITEM()
|
||||
}
|
||||
|
||||
void Editor::DrawSpriteEditor() {
|
||||
if (ImGui::BeginTabItem("Sprites")) {
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
TAB_ITEM("Sprites")
|
||||
END_TAB_ITEM()
|
||||
}
|
||||
|
||||
} // namespace editor
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
#include <imgui/misc/cpp/imgui_stdlib.h>
|
||||
|
||||
#include "app/core/constants.h"
|
||||
#include "app/editor/overworld_editor.h"
|
||||
#include "app/gfx/tile.h"
|
||||
#include "app/editor/assembly_editor.h"
|
||||
#include "app/editor/dungeon_editor.h"
|
||||
#include "app/editor/overworld_editor.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/tile.h"
|
||||
#include "app/rom.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/icons.h"
|
||||
#include "gui/input.h"
|
||||
|
||||
@@ -40,14 +43,15 @@ class Editor {
|
||||
void DrawDungeonEditor();
|
||||
void DrawGraphicsEditor();
|
||||
void DrawSpriteEditor();
|
||||
|
||||
|
||||
bool is_loaded_ = true;
|
||||
bool asm_is_loaded = false;
|
||||
|
||||
rom::ROM rom_;
|
||||
TextEditor asm_editor_;
|
||||
gui::Canvas canvas_;
|
||||
AssemblyEditor assembly_editor_;
|
||||
OverworldEditor overworld_editor_;
|
||||
DungeonEditor dungeon_editor_;
|
||||
std::shared_ptr<SDL_Renderer> sdl_renderer_;
|
||||
std::unordered_map<uint, SDL_Texture *> image_cache_;
|
||||
|
||||
|
||||
@@ -10,24 +10,26 @@
|
||||
#include "app/zelda3/overworld.h"
|
||||
#include "gui/icons.h"
|
||||
|
||||
// 1) find the gfx pointers (you could use ZS constant file)
|
||||
// 2) decompress all the gfx with your lz2 decompressor
|
||||
// 3) convert the 3bpp snes data into PC 4bpp (probably the hardest part)
|
||||
// 4) get the tiles32 data
|
||||
// 5) get the tiles16 data
|
||||
// 6) get the map32 data (they must be decompressed as well with a lz2
|
||||
// variant not the same as gfx compression but pretty similar) 7) get the
|
||||
// gfx data of the map yeah i forgot that one and load 4bpp in a pseudo vram
|
||||
// and use that to render tiles on screen 8) try to render the tiles on the
|
||||
// bitmap in black & white to start 9) get the palettes data and try to find
|
||||
// how they're loaded in the game that's a big puzzle to solve then 9 you'll
|
||||
// have an overworld map viewer, in less than few hours if are able to
|
||||
// understand the data quickly
|
||||
/**
|
||||
* Drawing the Overworld
|
||||
* Tips by Zarby
|
||||
*
|
||||
* 1) Find the graphics pointers (constants.h)
|
||||
* 2) Convert the 3bpp SNES data into PC 4bpp (Hard)
|
||||
* 3) Get the tiles32 data
|
||||
* 4) Get the tiles16 data
|
||||
* 5) Get the map32 data using lz2 variant decompression
|
||||
* 6) Get the graphics data of the map
|
||||
* 7) Load 4bpp into Pseudo VRAM for rendering tiles to screen
|
||||
* 8) Render the tiles to a bitmap with a B&W palette to start
|
||||
* 9) Get the palette data and find how it's loaded in game
|
||||
*
|
||||
*/
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
namespace editor {
|
||||
|
||||
void OverworldEditor::SetupROM(app::rom::ROM &rom) { rom_ = rom; }
|
||||
void OverworldEditor::SetupROM(rom::ROM &rom) { rom_ = rom; }
|
||||
|
||||
void OverworldEditor::Update() {
|
||||
if (rom_.isLoaded() && !all_gfx_loaded_) {
|
||||
@@ -114,7 +116,7 @@ void OverworldEditor::DrawToolset() {
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Button(ICON_MD_UPDATE)) {
|
||||
overworld_.Load(rom_, allGfx16Ptr);
|
||||
overworld_.Load(rom_, allgfxBitmap.GetData());
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
@@ -302,7 +304,7 @@ void OverworldEditor::DrawTileSelector() {
|
||||
}
|
||||
}
|
||||
|
||||
void OverworldEditor::DrawTile16Selector() {
|
||||
void OverworldEditor::DrawTile16Selector() const {
|
||||
static ImVec2 scrolling(0.0f, 0.0f);
|
||||
ImVec2 canvas_p0 = ImGui::GetCursorScreenPos();
|
||||
auto canvas_sz = ImVec2(256 + 1, kNumSheetsToLoad * 64 + 1);
|
||||
@@ -359,7 +361,7 @@ void OverworldEditor::DrawTile16Selector() {
|
||||
draw_list->PopClipRect();
|
||||
}
|
||||
|
||||
void OverworldEditor::DrawTile8Selector() {
|
||||
void OverworldEditor::DrawTile8Selector() const {
|
||||
static ImVec2 scrolling(0.0f, 0.0f);
|
||||
ImVec2 canvas_p0 = ImGui::GetCursorScreenPos();
|
||||
auto canvas_sz = ImVec2(256 + 1, kNumSheetsToLoad * 64 + 1);
|
||||
|
||||
@@ -25,25 +25,25 @@ class OverworldEditor {
|
||||
void DrawOverworldMapSettings();
|
||||
void DrawOverworldCanvas();
|
||||
void DrawTileSelector();
|
||||
void DrawTile16Selector();
|
||||
void DrawTile8Selector();
|
||||
void DrawTile16Selector() const;
|
||||
void DrawTile8Selector() const;
|
||||
|
||||
void LoadBlockset();
|
||||
void LoadGraphics();
|
||||
|
||||
rom::ROM rom_;
|
||||
|
||||
zelda3::Overworld overworld_;
|
||||
gfx::SNESPalette palette_;
|
||||
|
||||
rom::ROM rom_;
|
||||
|
||||
// pointer size 1048576
|
||||
gfx::Bitmap tile16_blockset_bmp_;
|
||||
uchar *tile16_blockset_ptr_ = new uchar[1048576];
|
||||
|
||||
// pointer size 32768
|
||||
gfx::Bitmap current_gfx_bmp_;
|
||||
uchar *current_gfx_ptr_ = new uchar[(128 * 512) / 2];
|
||||
|
||||
// pointer size 456704
|
||||
gfx::Bitmap allgfxBitmap;
|
||||
uchar *allGfx16Ptr = new uchar[(128 * 7136) / 2];
|
||||
|
||||
gfx::Bitmap mapblockset16Bitmap;
|
||||
|
||||
@@ -62,14 +62,14 @@ class OverworldEditor {
|
||||
bool all_gfx_loaded_ = false;
|
||||
bool map_blockset_loaded_ = false;
|
||||
|
||||
ImVec4 current_palette_[8];
|
||||
|
||||
constexpr static int kByteSize = 3;
|
||||
constexpr static int kMessageIdSize = 5;
|
||||
constexpr static int kNumSheetsToLoad = 100;
|
||||
constexpr static int kTile8DisplayHeight = 64;
|
||||
constexpr static float kInputFieldSize = 30.f;
|
||||
|
||||
ImVec4 current_palette_[8];
|
||||
|
||||
ImGuiTableFlags toolset_table_flags = ImGuiTableFlags_SizingFixedFit;
|
||||
ImGuiTableFlags ow_map_flags = ImGuiTableFlags_Borders;
|
||||
ImGuiTableFlags ow_edit_flags = ImGuiTableFlags_Reorderable |
|
||||
|
||||
@@ -20,6 +20,7 @@ class Bitmap {
|
||||
int GetWidth() const { return width_; }
|
||||
int GetHeight() const { return height_; }
|
||||
void CreateTexture(std::shared_ptr<SDL_Renderer> renderer);
|
||||
uchar *GetData() const { return pixel_data_; }
|
||||
SDL_Texture *GetTexture() const { return texture_; }
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user