Started writing mosaic assembly generation routine
This commit is contained in:
@@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "absl/status/statusor.h"
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
#include "app/core/constants.h"
|
#include "app/core/constants.h"
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
@@ -12,10 +20,32 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
absl::StatusOr<absl::string_view> GenerateMosaicChangeAssembly(
|
||||||
|
MosaicArray mosaic_tiles) {
|
||||||
|
std::fstream file("assets/asm/mosaic_change.asm",
|
||||||
|
std::ios::out | std::ios::in);
|
||||||
|
if (!file.is_open()) {
|
||||||
|
return absl::InvalidArgumentError(
|
||||||
|
"Couldn't open mosaic change template file");
|
||||||
|
}
|
||||||
|
std::stringstream assembly;
|
||||||
|
|
||||||
|
assembly << absl::StrCat("org ", kDefaultMosaicHook);
|
||||||
|
assembly << file.rdbuf();
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
return assembly.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
ScreenEditor::ScreenEditor() { screen_canvas_.SetCanvasSize(ImVec2(512, 512)); }
|
ScreenEditor::ScreenEditor() { screen_canvas_.SetCanvasSize(ImVec2(512, 512)); }
|
||||||
|
|
||||||
void ScreenEditor::Update() {
|
void ScreenEditor::Update() {
|
||||||
TAB_BAR("##TabBar")
|
TAB_BAR("##TabBar")
|
||||||
|
DrawMosaicEditor();
|
||||||
DrawTitleScreenEditor();
|
DrawTitleScreenEditor();
|
||||||
DrawNamingScreenEditor();
|
DrawNamingScreenEditor();
|
||||||
DrawOverworldMapEditor();
|
DrawOverworldMapEditor();
|
||||||
@@ -25,6 +55,20 @@ void ScreenEditor::Update() {
|
|||||||
END_TAB_BAR()
|
END_TAB_BAR()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenEditor::DrawMosaicEditor() {
|
||||||
|
TAB_ITEM("Mosaic Transitions")
|
||||||
|
if (ImGui::Button("GenerateMosaicChangeAssembly")) {
|
||||||
|
auto mosaic = GenerateMosaicChangeAssembly(mosaic_tiles_);
|
||||||
|
if (!mosaic.ok()) {
|
||||||
|
std::cout << "Failed to generate mosaic change assembly";
|
||||||
|
} else {
|
||||||
|
std::cout << "Successfully generated mosaic change assembly";
|
||||||
|
std::cout << mosaic.value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END_TAB_ITEM()
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenEditor::DrawTitleScreenEditor() {
|
void ScreenEditor::DrawTitleScreenEditor() {
|
||||||
TAB_ITEM("Title Screen")
|
TAB_ITEM("Title Screen")
|
||||||
END_TAB_ITEM()
|
END_TAB_ITEM()
|
||||||
|
|||||||
@@ -12,12 +12,16 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
|
using MosaicArray = std::array<int, core::kNumOverworldMaps>;
|
||||||
|
constexpr char kDefaultMosaicHook[] = "$02AADB";
|
||||||
|
|
||||||
class ScreenEditor {
|
class ScreenEditor {
|
||||||
public:
|
public:
|
||||||
ScreenEditor();
|
ScreenEditor();
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void DrawMosaicEditor();
|
||||||
void DrawTitleScreenEditor();
|
void DrawTitleScreenEditor();
|
||||||
void DrawNamingScreenEditor();
|
void DrawNamingScreenEditor();
|
||||||
void DrawOverworldMapEditor();
|
void DrawOverworldMapEditor();
|
||||||
@@ -28,6 +32,8 @@ class ScreenEditor {
|
|||||||
void DrawCanvas();
|
void DrawCanvas();
|
||||||
void DrawToolset();
|
void DrawToolset();
|
||||||
|
|
||||||
|
MosaicArray mosaic_tiles_;
|
||||||
|
|
||||||
zelda3::Screen current_screen_;
|
zelda3::Screen current_screen_;
|
||||||
gui::Canvas screen_canvas_;
|
gui::Canvas screen_canvas_;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user