Bunch of updates refactoring adding some sneshacking code some gui stuff
This commit is contained in:
@@ -22,20 +22,10 @@ void Editor::UpdateScreen() {
|
||||
|
||||
DrawYazeMenu();
|
||||
|
||||
if (isLoaded) {
|
||||
if (!doneLoaded) {
|
||||
overworld.Load(rom);
|
||||
overworld_texture = &overworld.owactualMapTexture;
|
||||
doneLoaded = true;
|
||||
}
|
||||
// ImGui::Image((void*)(intptr_t)overworld_texture,
|
||||
// ImVec2(overworld.overworldMapBitmap->GetWidth(),
|
||||
// overworld.overworldMapBitmap->GetHeight()));
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabBar("##TabBar")) {
|
||||
DrawOverworldEditor();
|
||||
DrawDungeonEditor();
|
||||
DrawSpriteEditor();
|
||||
DrawScreenEditor();
|
||||
DrawROMInfo();
|
||||
ImGui::EndTabBar();
|
||||
@@ -50,6 +40,7 @@ void Editor::DrawYazeMenu() {
|
||||
DrawFileMenu();
|
||||
DrawEditMenu();
|
||||
DrawViewMenu();
|
||||
DrawHelpMenu();
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
@@ -60,7 +51,8 @@ void Editor::DrawYazeMenu() {
|
||||
std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName();
|
||||
std::string filePath = ImGuiFileDialog::Instance()->GetCurrentPath();
|
||||
rom.LoadFromFile(filePathName);
|
||||
isLoaded = true;
|
||||
owEditor.SetRom(rom);
|
||||
rom_data_ = (void *)rom.GetRawData();
|
||||
}
|
||||
|
||||
// close
|
||||
@@ -137,10 +129,16 @@ void Editor::DrawEditMenu() const {
|
||||
void Editor::DrawViewMenu() const {
|
||||
static bool show_imgui_metrics = false;
|
||||
static bool show_imgui_style_editor = false;
|
||||
static bool show_memory_editor = false;
|
||||
if (show_imgui_metrics) {
|
||||
ImGui::ShowMetricsWindow(&show_imgui_metrics);
|
||||
}
|
||||
|
||||
if (show_memory_editor) {
|
||||
static MemoryEditor mem_edit;
|
||||
mem_edit.DrawWindow("Memory Editor", rom_data_, rom.getSize());
|
||||
}
|
||||
|
||||
if (show_imgui_style_editor) {
|
||||
ImGui::Begin("Style Editor (ImGui)", &show_imgui_style_editor);
|
||||
ImGui::ShowStyleEditor();
|
||||
@@ -154,6 +152,8 @@ void Editor::DrawViewMenu() const {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::MenuItem("HEX Editor", nullptr, &show_memory_editor);
|
||||
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginMenu("GUI Tools")) {
|
||||
ImGui::MenuItem("Metrics (ImGui)", nullptr, &show_imgui_metrics);
|
||||
@@ -165,6 +165,14 @@ void Editor::DrawViewMenu() const {
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::DrawHelpMenu() const {
|
||||
if (ImGui::BeginMenu("Help")) {
|
||||
if (ImGui::MenuItem("About")) {
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
// first step would be to decompress all graphics data from the game
|
||||
// (in alttp that's easy they're all located in the same location all the
|
||||
// same sheet size 128x32) have a code that convert PC address to SNES and
|
||||
@@ -235,6 +243,12 @@ void Editor::DrawDungeonEditor() {
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::DrawSpriteEditor() {
|
||||
if (ImGui::BeginTabItem("Sprites")) {
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::DrawScreenEditor() {
|
||||
if (ImGui::BeginTabItem("Screens")) {
|
||||
ImGui::EndTabItem();
|
||||
@@ -243,7 +257,7 @@ void Editor::DrawScreenEditor() {
|
||||
|
||||
void Editor::DrawROMInfo() {
|
||||
if (ImGui::BeginTabItem("ROM Info")) {
|
||||
if (isLoaded) {
|
||||
if (rom.isLoaded()) {
|
||||
ImGui::Text("Title: %s", rom.getTitle());
|
||||
ImGui::Text("Version: %d", rom.getVersion());
|
||||
ImGui::Text("ROM Size: %ld", rom.getSize());
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <memory>
|
||||
|
||||
#include "Core/Icons.h"
|
||||
#include "Data/Overworld.h"
|
||||
#include "OverworldEditor.h"
|
||||
#include "ImGuiFileDialog/ImGuiFileDialog.h"
|
||||
#include "Utils/ROM.h"
|
||||
@@ -13,6 +12,7 @@
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui/imgui_internal.h"
|
||||
#include "imgui/misc/cpp/imgui_stdlib.h"
|
||||
#include "imgui/imgui_memory_editor.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace Application {
|
||||
@@ -27,20 +27,20 @@ class Editor {
|
||||
void DrawFileMenu() const;
|
||||
void DrawEditMenu() const;
|
||||
void DrawViewMenu() const;
|
||||
void DrawHelpMenu() const;
|
||||
|
||||
void DrawOverworldEditor();
|
||||
void DrawDungeonEditor();
|
||||
void DrawSpriteEditor();
|
||||
void DrawScreenEditor();
|
||||
void DrawROMInfo();
|
||||
|
||||
bool isLoaded = false;
|
||||
bool doneLoaded = false;
|
||||
GLuint *overworld_texture;
|
||||
Data::Overworld overworld;
|
||||
::yaze::Application::Editor::OverworldEditor owEditor;
|
||||
OverworldEditor owEditor;
|
||||
Utils::ROM rom;
|
||||
|
||||
void* rom_data_;
|
||||
|
||||
bool isLoaded = true;
|
||||
ImGuiTableFlags toolset_table_flags = ImGuiTableFlags_SizingFixedFit;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "OverworldEditor.h"
|
||||
#include "Core/Icons.h"
|
||||
#include "Graphics/Bitmap.h"
|
||||
#include "Graphics/Tile.h"
|
||||
#include "imgui.h"
|
||||
#include <cmath>
|
||||
|
||||
@@ -7,6 +9,28 @@ namespace yaze {
|
||||
namespace Application {
|
||||
namespace Editor {
|
||||
void OverworldEditor::Update() {
|
||||
|
||||
if (rom_.isLoaded()) {
|
||||
if (!doneLoaded) {
|
||||
overworld.Load(rom_);
|
||||
Graphics::CreateAllGfxData(rom_.GetRawData(), allGfx16Ptr);
|
||||
|
||||
// allgfxBitmap.LoadBitmapFromROM(allGfx16Ptr, allgfx_texture,
|
||||
// &allgfx_width,
|
||||
// &allgfx_height);
|
||||
doneLoaded = true;
|
||||
}
|
||||
// Graphics::tile8 all_tiles;
|
||||
// all_tiles.id = 1;
|
||||
// all_tiles.data =
|
||||
// Graphics::export_tile_to_png(tile8 rawtile, const r_palette pal, const
|
||||
// char *filename)
|
||||
}
|
||||
|
||||
if (show_changelist_) {
|
||||
DrawChangelist();
|
||||
}
|
||||
|
||||
DrawToolset();
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginTable("#owEditTable", 2, ow_edit_flags, ImVec2(0, 0))) {
|
||||
@@ -21,7 +45,7 @@ void OverworldEditor::Update() {
|
||||
}
|
||||
|
||||
void OverworldEditor::DrawToolset() {
|
||||
if (ImGui::BeginTable("Toolset", 12, toolset_table_flags, ImVec2(0, 0))) {
|
||||
if (ImGui::BeginTable("Toolset", 14, toolset_table_flags, ImVec2(0, 0))) {
|
||||
|
||||
ImGui::TableSetupColumn("#undoTool");
|
||||
ImGui::TableSetupColumn("#redoTool");
|
||||
@@ -31,10 +55,12 @@ void OverworldEditor::DrawToolset() {
|
||||
ImGui::TableSetupColumn("#zoomInTool");
|
||||
ImGui::TableSetupColumn("#separator");
|
||||
ImGui::TableSetupColumn("#history");
|
||||
ImGui::TableSetupColumn("#entranceExitTool");
|
||||
ImGui::TableSetupColumn("#entranceTool");
|
||||
ImGui::TableSetupColumn("#exitTool");
|
||||
ImGui::TableSetupColumn("#itemTool");
|
||||
ImGui::TableSetupColumn("#spriteTool");
|
||||
ImGui::TableSetupColumn("#transportTool");
|
||||
ImGui::TableSetupColumn("#musicTool");
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_UNDO);
|
||||
@@ -43,7 +69,12 @@ void OverworldEditor::DrawToolset() {
|
||||
ImGui::Button(ICON_MD_REDO);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_MANAGE_HISTORY);
|
||||
if (ImGui::Button(ICON_MD_MANAGE_HISTORY)) {
|
||||
if (!show_changelist_)
|
||||
show_changelist_ = true;
|
||||
else
|
||||
show_changelist_ = false;
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(ICON_MD_MORE_VERT);
|
||||
@@ -61,7 +92,10 @@ void OverworldEditor::DrawToolset() {
|
||||
ImGui::Button(ICON_MD_DRAW);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_SENSOR_DOOR);
|
||||
ImGui::Button(ICON_MD_DOOR_FRONT);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_DOOR_BACK);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_GRASS);
|
||||
@@ -72,6 +106,9 @@ void OverworldEditor::DrawToolset() {
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_ADD_LOCATION);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Button(ICON_MD_MUSIC_NOTE);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
@@ -121,8 +158,8 @@ void OverworldEditor::DrawOverworldMapSettings() {
|
||||
ImGui::Text("Msg ID");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(50.f);
|
||||
ImGui::InputText("##msgid", spr_palette_, kMessageIdSize);
|
||||
|
||||
ImGui::InputText("##msgid", spr_palette_, kMessageIdSize);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Checkbox("Show grid", &opt_enable_grid);
|
||||
ImGui::EndTable();
|
||||
@@ -222,18 +259,35 @@ void OverworldEditor::DrawOverworldCanvas() {
|
||||
}
|
||||
void OverworldEditor::DrawTileSelector() {
|
||||
if (ImGui::BeginTabBar("##TabBar")) {
|
||||
if (ImGui::BeginTabItem("Tile8")) {
|
||||
if (rom_.isLoaded()) {
|
||||
ImGui::Image((void *)(intptr_t)overworld_texture,
|
||||
ImVec2(overworld.overworldMapBitmap->GetWidth(),
|
||||
overworld.overworldMapBitmap->GetHeight()));
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Tile16")) {
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Tile8")) {
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
}
|
||||
|
||||
void OverworldEditor::DrawChangelist() {
|
||||
if (!ImGui::Begin("Changelist")) {
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
ImGui::Text("Test");
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
} // namespace Editor
|
||||
} // namespace Application
|
||||
} // namespace yaze
|
||||
@@ -2,25 +2,50 @@
|
||||
#define YAZE_APPLICATION_EDITOR_OVERWORLDEDITOR_H
|
||||
|
||||
#include "Core/Icons.h"
|
||||
#include "Data/Overworld.h"
|
||||
#include "Utils/Compression.h"
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui/misc/cpp/imgui_stdlib.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace Application {
|
||||
namespace Editor {
|
||||
|
||||
using byte = unsigned char;
|
||||
|
||||
class OverworldEditor {
|
||||
public:
|
||||
void Update();
|
||||
|
||||
void SetRom(Utils::ROM & rom) { rom_ = rom; }
|
||||
|
||||
private:
|
||||
void DrawToolset();
|
||||
void DrawOverworldMapSettings();
|
||||
void DrawOverworldCanvas();
|
||||
void DrawTileSelector();
|
||||
|
||||
void DrawChangelist();
|
||||
|
||||
bool show_changelist_ = false;
|
||||
|
||||
Utils::ROM rom_;
|
||||
Data::Overworld overworld;
|
||||
Utils::ALTTPCompression alttp_compressor_;
|
||||
Graphics::Bitmap allgfxBitmap;
|
||||
int allgfx_width = 0;
|
||||
int allgfx_height = 0;
|
||||
GLuint *allgfx_texture = nullptr;
|
||||
|
||||
byte* allGfx16Ptr = new byte[(128 * 7136) / 2];
|
||||
|
||||
GLuint *overworld_texture;
|
||||
|
||||
ImGuiTableFlags toolset_table_flags = ImGuiTableFlags_SizingFixedFit;
|
||||
ImGuiTableFlags ow_map_settings_flags = ImGuiTableFlags_Borders;
|
||||
ImGuiTableFlags ow_edit_flags = ImGuiTableFlags_Reorderable | ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingStretchSame;
|
||||
ImGuiTableFlags ow_edit_flags = ImGuiTableFlags_Reorderable |
|
||||
ImGuiTableFlags_Resizable |
|
||||
ImGuiTableFlags_SizingStretchSame;
|
||||
|
||||
float canvas_table_ratio = 30.f;
|
||||
|
||||
@@ -32,6 +57,9 @@ private:
|
||||
|
||||
int current_world_ = 0;
|
||||
|
||||
bool isLoaded = false;
|
||||
bool doneLoaded = false;
|
||||
|
||||
constexpr static int kByteSize = 3;
|
||||
constexpr static int kMessageIdSize = 5;
|
||||
constexpr static float kInputFieldSize = 30.f;
|
||||
|
||||
Reference in New Issue
Block a user