Moving tiles related stuff into the project window

This commit is contained in:
Justin Scofield
2022-06-12 13:17:59 -04:00
parent 9b905a48e4
commit 9d7f0aa0b4
5 changed files with 47 additions and 74 deletions

View File

@@ -4,6 +4,12 @@
#include <array>
#include <string>
#define TAB_BAR(w) if (ImGui::BeginTabBar(w)) {
#define END_TAB_BAR() ImGui::EndTabBar(); }
#define MENU_BAR() if (ImGui::BeginMenuBar()) {
#define END_MENU_BAR() ImGui::EndMenuBar(); }
namespace yaze {
namespace Application {
namespace Core {

View File

@@ -7,7 +7,6 @@
#include <memory>
#include "Editor/Editor.h"
#include "Events/Event.h"
#include "Renderer.h"
#include "Window.h"
#include "imgui/backends/imgui_impl_sdl.h"

View File

@@ -82,6 +82,14 @@ Editor::Editor() {
}
asm_editor_.SetLanguageDefinition(language65816Def);
asm_editor_.SetPalette(TextEditor::GetDarkPalette());
current_set_.bpp = 3;
current_set_.pcTilesLocation = 0x8000;
current_set_.SNESTilesLocation = 0;
current_set_.length = 1000;
current_set_.pcPaletteLocation = 0;
current_set_.SNESPaletteLocation = 0;
current_set_.compression = "zelda3";
}
void Editor::UpdateScreen() {
@@ -102,28 +110,25 @@ void Editor::UpdateScreen() {
DrawYazeMenu();
if (ImGui::BeginTabBar("##TabBar")) {
TAB_BAR("##TabBar");
DrawProjectEditor();
DrawOverworldEditor();
DrawDungeonEditor();
DrawGraphicsEditor();
DrawSpriteEditor();
DrawScreenEditor();
ImGui::EndTabBar();
}
END_TAB_BAR();
ImGui::End();
}
void Editor::DrawYazeMenu() {
if (ImGui::BeginMenuBar()) {
MENU_BAR();
DrawFileMenu();
DrawEditMenu();
DrawViewMenu();
DrawHelpMenu();
ImGui::EndMenuBar();
}
END_MENU_BAR();
// display
if (ImGuiFileDialog::Instance()->Display("ChooseFileDlgKey")) {
@@ -283,13 +288,40 @@ void Editor::DrawHelpMenu() const {
}
void Editor::DrawProjectEditor() {
static bool inited = false;
if (ImGui::BeginTabItem("Project")) {
if (rom.isLoaded()) {
ImGui::InputInt("PC Tile Location", &current_set_.pcTilesLocation);
ImGui::InputScalar("SNES Tile Location", ImGuiDataType_U32, (void*)&current_set_.SNESTilesLocation);
ImGui::InputScalar("Tile Preset Length", ImGuiDataType_U32, (void*)&current_set_.length);
ImGui::InputScalar("Bits per Pixel", ImGuiDataType_U32, (void*)&current_set_.bpp);
ImGui::InputScalar("PC Palette Location", ImGuiDataType_U32, (void*)&current_set_.pcPaletteLocation);
ImGui::InputScalar("SNES Palette Location", ImGuiDataType_U32, (void*)&current_set_.SNESPaletteLocation);
if (rom.isLoaded()) {
ImGui::Text("Title: %s", rom.getTitle());
ImGui::Text("Version: %d", rom.getVersion());
ImGui::Text("ROM Size: %ld", rom.getSize());
if (!inited) {
current_palette_.colors.push_back(ImVec4(0.0f, 0.0f, 0.0f, 1.0f));
current_palette_.colors.push_back(ImVec4(0.0f, 0.5f, 0.0f, 1.0f));
current_palette_.colors.push_back(ImVec4(0.0f, 0.0f, 0.4f, 1.0f));
current_palette_.colors.push_back(ImVec4(0.3f, 0.0f, 0.0f, 1.0f));
current_palette_.colors.push_back(ImVec4(0.3f, 0.7f, 0.9f, 1.0f));
current_palette_.colors.push_back(ImVec4(0.5f, 0.5f, 0.5f, 1.0f));
current_scene_.buildSurface(rom.ExtractTiles(current_set_), current_palette_, current_set_.tilesPattern);
inited = true;
}
for (const auto & [key, value] : current_scene_.imagesCache) {
ImGui::Image((void *)(SDL_Texture*)value, ImVec2(8, 8));
}
}
ImGui::EndTabItem();
}
}

View File

@@ -33,65 +33,6 @@ void OverworldEditor::Update() {
if (rom_.isLoaded()) {
if (!doneLoaded) {
//overworld.Load(rom_);
// name=The Legend of Zelda - Link Sprites
// [rom]
// name=
// type=LoROM
// [tiles]
// pc_location=80000
// snes_location=0
// length=28672
// bpp=4
// compression=None
// pattern=normal
// [tiles_arrangement]
// tiles_per_row=16
// [palette]
// pc_location=dd308
// snes_location=0
// nozerocolor=true
// name="The Legend of Zelda - Action Sprites, shields, shovel and book"
// [rom]
// name=
// type=LoROM
// [tiles]
// pc_location=c0d64
// snes_location=0
// length=1081
// bpp=3
// compression=zelda3
// [tiles_arrangement]
// tiles_per_row=16
// [palette]
// pc_location=0
// snes_location=0
// nozerocolor=true
current_set_.pcTilesLocation = 0x8000;
current_set_.SNESTilesLocation = 0;
current_set_.length = 1000;
current_set_.bpp = 3;
current_set_.compression = "zelda3";
current_set_.pcPaletteLocation = 0;
current_set_.SNESPaletteLocation = 0;
palette_.colors.push_back(ImVec4(0.0f, 0.0f, 0.0f, 1.0f));
palette_.colors.push_back(ImVec4(0.0f, 0.5f, 0.0f, 1.0f));
palette_.colors.push_back(ImVec4(0.0f, 0.0f, 0.4f, 1.0f));
palette_.colors.push_back(ImVec4(0.3f, 0.0f, 0.0f, 1.0f));
palette_.colors.push_back(ImVec4(0.3f, 0.7f, 0.9f, 1.0f));
palette_.colors.push_back(ImVec4(0.5f, 0.5f, 0.5f, 1.0f));
current_scene_.buildSurface(rom_.ExtractTiles(current_set_), palette_, current_set_.tilesPattern);
doneLoaded = true;
}
}
@@ -325,11 +266,6 @@ void OverworldEditor::DrawOverworldCanvas() {
void OverworldEditor::DrawTileSelector() {
if (ImGui::BeginTabBar("##TabBar", ImGuiTabBarFlags_FittingPolicyScroll)) {
if (ImGui::BeginTabItem("Tile8")) {
if (rom_.isLoaded()) {
for (const auto & [key, value] : current_scene_.imagesCache) {
ImGui::Image((void *)(SDL_Texture*)value, ImVec2(8, 8));
}
}
ImGui::EndTabItem();
}

View File

@@ -25,7 +25,7 @@ void ROM::LoadFromFile(const std::string &path) {
int bytes_read = fread(current_rom_, sizeof(unsigned char), size, file);
fclose(file);
memcpy(title, current_rom_ + 32704, 21);
memcpy(title, rom_data_ + 32704, 21);
type = LoROM;
version = current_rom_[27];
loaded = true;