Add GfxContext, Load all gfx from MasterEditor
This commit is contained in:
@@ -18,6 +18,7 @@ set(
|
|||||||
app/editor/modules/assembly_editor.cc
|
app/editor/modules/assembly_editor.cc
|
||||||
app/editor/modules/tile16_editor.cc
|
app/editor/modules/tile16_editor.cc
|
||||||
app/editor/modules/gfx_group_editor.cc
|
app/editor/modules/gfx_group_editor.cc
|
||||||
|
app/editor/context/gfx_context.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
set(
|
set(
|
||||||
|
|||||||
35
src/app/editor/context/gfx_context.cc
Normal file
35
src/app/editor/context/gfx_context.cc
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include "app/editor/context/gfx_context.h"
|
||||||
|
|
||||||
|
#include <imgui/imgui.h>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
#include "absl/status/status.h"
|
||||||
|
#include "absl/status/statusor.h"
|
||||||
|
#include "app/core/editor.h"
|
||||||
|
#include "app/core/pipeline.h"
|
||||||
|
#include "app/editor/modules/palette_editor.h"
|
||||||
|
#include "app/gfx/bitmap.h"
|
||||||
|
#include "app/gfx/snes_palette.h"
|
||||||
|
#include "app/gfx/snes_tile.h"
|
||||||
|
#include "app/gui/canvas.h"
|
||||||
|
#include "app/gui/icons.h"
|
||||||
|
#include "app/rom.h"
|
||||||
|
#include "app/zelda3/overworld.h"
|
||||||
|
|
||||||
|
namespace yaze {
|
||||||
|
namespace app {
|
||||||
|
namespace editor {
|
||||||
|
|
||||||
|
absl::Status GfxContext::Update() { return absl::OkStatus(); }
|
||||||
|
|
||||||
|
gfx::Bitmap GfxContext::current_ow_gfx_bmp_;
|
||||||
|
gfx::SNESPalette GfxContext::current_ow_palette_;
|
||||||
|
gfx::Bitmap GfxContext::tile16_blockset_bmp_;
|
||||||
|
gfx::Bitmap GfxContext::tile8_blockset_bmp_;
|
||||||
|
std::vector<gfx::Bitmap> GfxContext::tile16_individual_bmp_;
|
||||||
|
std::vector<gfx::Bitmap> GfxContext::tile8_individual_bmp_;
|
||||||
|
|
||||||
|
} // namespace editor
|
||||||
|
} // namespace app
|
||||||
|
} // namespace yaze
|
||||||
56
src/app/editor/context/gfx_context.h
Normal file
56
src/app/editor/context/gfx_context.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
#ifndef YAZE_APP_EDITOR_VRAM_CONTEXT_H
|
||||||
|
#define YAZE_APP_EDITOR_VRAM_CONTEXT_H
|
||||||
|
|
||||||
|
#include <imgui/imgui.h>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/status/status.h"
|
||||||
|
#include "absl/status/statusor.h"
|
||||||
|
#include "app/core/editor.h"
|
||||||
|
#include "app/core/pipeline.h"
|
||||||
|
#include "app/editor/modules/palette_editor.h"
|
||||||
|
#include "app/gfx/bitmap.h"
|
||||||
|
#include "app/gfx/snes_palette.h"
|
||||||
|
#include "app/gfx/snes_tile.h"
|
||||||
|
#include "app/gui/canvas.h"
|
||||||
|
#include "app/gui/icons.h"
|
||||||
|
#include "app/rom.h"
|
||||||
|
#include "app/zelda3/overworld.h"
|
||||||
|
|
||||||
|
// Create a class which manages the current VRAM state of Link to the Past,
|
||||||
|
// including static members for the Bitmaps and Palettes as well as the current
|
||||||
|
// blockset as to update all of the overworld maps with the new blockset when it
|
||||||
|
// is changed. This class will also manage the current tile16 and tile8
|
||||||
|
// selection, as well as the current palette selection.
|
||||||
|
|
||||||
|
namespace yaze {
|
||||||
|
namespace app {
|
||||||
|
namespace editor {
|
||||||
|
|
||||||
|
class GfxContext {
|
||||||
|
public:
|
||||||
|
absl::Status Update();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static gfx::Bitmap current_ow_gfx_bmp_;
|
||||||
|
|
||||||
|
static gfx::SNESPalette current_ow_palette_;
|
||||||
|
|
||||||
|
static gfx::Bitmap tile16_blockset_bmp_;
|
||||||
|
|
||||||
|
static gfx::Bitmap tile8_blockset_bmp_;
|
||||||
|
|
||||||
|
// Bitmaps for the tile16 individual tiles
|
||||||
|
static std::vector<gfx::Bitmap> tile16_individual_bmp_;
|
||||||
|
|
||||||
|
// Bitmaps for the tile8 individual tiles
|
||||||
|
static std::vector<gfx::Bitmap> tile8_individual_bmp_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace editor
|
||||||
|
} // namespace app
|
||||||
|
} // namespace yaze
|
||||||
|
|
||||||
|
#endif // YAZE_APP_EDITOR_VRAM_CONTEXT_H
|
||||||
@@ -128,6 +128,12 @@ absl::Status MasterEditor::Update() {
|
|||||||
DrawAboutPopup();
|
DrawAboutPopup();
|
||||||
DrawInfoPopup();
|
DrawInfoPopup();
|
||||||
|
|
||||||
|
if (rom()->isLoaded() && !rom_assets_loaded_) {
|
||||||
|
// Initialize overworld graphics, maps, and palettes
|
||||||
|
RETURN_IF_ERROR(overworld_editor_.LoadGraphics());
|
||||||
|
rom_assets_loaded_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
TAB_BAR("##TabBar")
|
TAB_BAR("##TabBar")
|
||||||
|
|
||||||
gui::RenderTabItem("Overworld", [&]() {
|
gui::RenderTabItem("Overworld", [&]() {
|
||||||
@@ -249,7 +255,7 @@ void MasterEditor::DrawYazeMenu() {
|
|||||||
}
|
}
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
|
|
||||||
Text(absl::StrCat("yaze v", core::kYazeVersion).c_str());
|
Text("%s", absl::StrCat("yaze v", core::kYazeVersion).c_str());
|
||||||
|
|
||||||
END_MENU_BAR()
|
END_MENU_BAR()
|
||||||
|
|
||||||
@@ -277,16 +283,9 @@ void MasterEditor::DrawFileMenu() {
|
|||||||
auto file_name = FileDialogWrapper::ShowOpenFileDialog();
|
auto file_name = FileDialogWrapper::ShowOpenFileDialog();
|
||||||
PRINT_IF_ERROR(rom()->LoadFromFile(file_name));
|
PRINT_IF_ERROR(rom()->LoadFromFile(file_name));
|
||||||
static RecentFilesManager manager("recent_files.txt");
|
static RecentFilesManager manager("recent_files.txt");
|
||||||
|
|
||||||
// Load existing recent files
|
|
||||||
manager.Load();
|
manager.Load();
|
||||||
|
|
||||||
// Add a new file
|
|
||||||
manager.AddFile(file_name);
|
manager.AddFile(file_name);
|
||||||
|
|
||||||
// Save the updated list
|
|
||||||
manager.Save();
|
manager.Save();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Open ROM",
|
ImGuiFileDialog::Instance()->OpenDialog("ChooseFileDlgKey", "Open ROM",
|
||||||
".sfc,.smc", ".");
|
".sfc,.smc", ".");
|
||||||
@@ -322,6 +321,8 @@ void MasterEditor::DrawFileMenu() {
|
|||||||
ImGui::MenuItem("Backup ROM", "", &backup_rom_);
|
ImGui::MenuItem("Backup ROM", "", &backup_rom_);
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
Text("Experiment Flags");
|
Text("Experiment Flags");
|
||||||
|
ImGui::Checkbox("Enable Texture Streaming",
|
||||||
|
&mutable_flags()->kLoadTexturesAsStreaming);
|
||||||
ImGui::Checkbox("Enable Overworld Sprites",
|
ImGui::Checkbox("Enable Overworld Sprites",
|
||||||
&mutable_flags()->kDrawOverworldSprites);
|
&mutable_flags()->kDrawOverworldSprites);
|
||||||
ImGui::Checkbox("Use Bitmap Manager",
|
ImGui::Checkbox("Use Bitmap Manager",
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
#include "app/core/constants.h"
|
#include "app/core/constants.h"
|
||||||
#include "app/core/pipeline.h"
|
#include "app/core/pipeline.h"
|
||||||
|
#include "app/editor/context/gfx_context.h"
|
||||||
#include "app/editor/dungeon_editor.h"
|
#include "app/editor/dungeon_editor.h"
|
||||||
#include "app/editor/graphics_editor.h"
|
#include "app/editor/graphics_editor.h"
|
||||||
#include "app/editor/modules/assembly_editor.h"
|
#include "app/editor/modules/assembly_editor.h"
|
||||||
@@ -31,7 +32,9 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
class MasterEditor : public SharedROM, public core::ExperimentFlags {
|
class MasterEditor : public SharedROM,
|
||||||
|
public GfxContext,
|
||||||
|
public core::ExperimentFlags {
|
||||||
public:
|
public:
|
||||||
MasterEditor() { current_editor_ = &overworld_editor_; }
|
MasterEditor() { current_editor_ = &overworld_editor_; }
|
||||||
|
|
||||||
@@ -56,6 +59,7 @@ class MasterEditor : public SharedROM, public core::ExperimentFlags {
|
|||||||
bool rom_info_ = false;
|
bool rom_info_ = false;
|
||||||
bool backup_rom_ = true;
|
bool backup_rom_ = true;
|
||||||
bool show_status_ = false;
|
bool show_status_ = false;
|
||||||
|
bool rom_assets_loaded_ = false;
|
||||||
|
|
||||||
absl::Status status_;
|
absl::Status status_;
|
||||||
absl::Status prev_status_;
|
absl::Status prev_status_;
|
||||||
|
|||||||
Reference in New Issue
Block a user