Expand ScreenEditor and Screen class

This commit is contained in:
Justin Scofield
2022-07-19 20:22:17 -04:00
parent 1e2579acc8
commit 8af096c1ae
5 changed files with 301 additions and 62 deletions

View File

@@ -1,9 +1,83 @@
#include "app/editor/screen_editor.h"
#include <imgui/imgui.h>
#include "app/core/common.h"
#include "app/core/constants.h"
#include "app/gfx/bitmap.h"
#include "app/gfx/snes_tile.h"
#include "gui/canvas.h"
namespace yaze {
namespace app {
namespace editor {
void ScreenEditor::Update() {}
ScreenEditor::ScreenEditor() { screen_canvas_.SetCanvasSize(ImVec2(512, 512)); }
void ScreenEditor::Update() {
TAB_BAR("##TabBar")
DrawTitleScreenEditor();
DrawNamingScreenEditor();
DrawOverworldMapEditor();
DrawDungeonMapsEditor();
DrawGameMenuEditor();
DrawHUDEditor();
END_TAB_BAR()
}
void ScreenEditor::DrawTitleScreenEditor() {
TAB_ITEM("Title Screen")
END_TAB_ITEM()
}
void ScreenEditor::DrawNamingScreenEditor() {
TAB_ITEM("Naming Screen")
END_TAB_ITEM()
}
void ScreenEditor::DrawOverworldMapEditor() {
TAB_ITEM("Overworld Map")
END_TAB_ITEM()
}
void ScreenEditor::DrawDungeonMapsEditor() {
TAB_ITEM("Dungeon Maps")
END_TAB_ITEM()
}
void ScreenEditor::DrawGameMenuEditor() {
TAB_ITEM("Game Menu")
END_TAB_ITEM()
}
void ScreenEditor::DrawHUDEditor() {
TAB_ITEM("Heads-up Display")
END_TAB_ITEM()
}
void ScreenEditor::DrawCanvas() {
screen_canvas_.DrawBackground();
screen_canvas_.UpdateContext();
screen_canvas_.DrawGrid();
screen_canvas_.DrawOverlay();
}
void ScreenEditor::DrawToolset() {
static bool show_bg1 = true;
static bool show_bg2 = true;
static bool show_bg3 = true;
static bool drawing_bg1 = true;
static bool drawing_bg2 = false;
static bool drawing_bg3 = false;
ImGui::Checkbox("Show BG1", &show_bg1);
ImGui::SameLine();
ImGui::Checkbox("Show BG2", &show_bg2);
ImGui::Checkbox("Draw BG1", &drawing_bg1);
ImGui::SameLine();
ImGui::Checkbox("Draw BG2", &drawing_bg2);
ImGui::SameLine();
ImGui::Checkbox("Draw BG3", &drawing_bg3);
}
} // namespace editor
} // namespace app
} // namespace yaze

View File

@@ -1,7 +1,12 @@
#ifndef YAZE_APP_EDITOR_SCREEN_EDITOR_H
#define YAZE_APP_EDITOR_SCREEN_EDITOR_H
#include <imgui/imgui.h>
#include "app/gfx/bitmap.h"
#include "app/gfx/snes_tile.h"
#include "app/zelda3/screen.h"
#include "gui/canvas.h"
namespace yaze {
namespace app {
@@ -9,67 +14,22 @@ namespace editor {
class ScreenEditor {
public:
ScreenEditor();
void Update();
private:
int sword_x_ = 0;
int mx_click_ = 0;
int my_click_ = 0;
int mx_dist_ = 0;
int my_dist_ = 0;
int last_x_ = 0;
int last_y_ = 0;
int x_in_ = 0;
int y_in_ = 0;
int dungmap_selected_tile_ = 0;
int dungmap_selected_ = 0;
int selected_palette_ = 0;
int total_floors_ = 0;
int current_floor_ = 0;
int num_basement_ = 0;
int num_floor_ = 0;
int selected_map_tile = 0;
int current_floor_rooms; // [1][];
int current_floor_gfx; // [1][];
int copied_data_rooms; // 25
int copied_data_gfx; // 25
int addresses[] = {0x53de4, 0x53e2c, 0x53e08, 0x53e50,
0x53e74, 0x53e98, 0x53ebc};
int addressesgfx[] = {0x53ee0, 0x53f04, 0x53ef2, 0x53f16,
0x53f28, 0x53f3a, 0x53f4c};
void DrawTitleScreenEditor();
void DrawNamingScreenEditor();
void DrawOverworldMapEditor();
void DrawDungeonMapsEditor();
void DrawGameMenuEditor();
void DrawHUDEditor();
ushort bossRoom = 0x000F;
ushort selected_tile = 0;
ushort tilesBG1Buffer = new ushort[0x1000];
ushort tilesBG2Buffer = new ushort[0x1000];
uchar mapdata = new uchar[64 * 64];
uchar dwmapdata = new uchar[64 * 64];
void DrawCanvas();
void DrawToolset();
bool mDown = false;
bool swordSelected = false;
bool darkWorld = false;
bool currentDungeonChanged = false;
bool editedFromEditor = false;
bool mouseDown = false;
bool mdown = false;
std::vector<MapIcon> all_map_icons_;
OAMTile oam_data[10];
OAMTile selected_oam_tile = nullptr;
OAMTile last_selected_oam_tile = nullptr;
gfx::Bitmap tilesBG1Bitmap; // 0x80000
gfx::Bitmap tilesBG2Bitmap; // 0x80000
gfx::Bitmap oamBGBitmap; // 0x80000
gfx::Bitmap dungeon_map_tiles8_bmp; // 0x8000
gfx::Bitmap dungmaptiles16Bitmap; // 0x20000
gfx::Bitmap tiles8Bitmap; // 0x20000
gfx::Bitmap floor_selector;
// DungeonMap dungeon_maps_[14];
// MapIcon selectedMapIcon;
zelda3::Screen current_screen_;
gui::Canvas screen_canvas_;
};
} // namespace editor