Integrating Status return types into GUI
This commit is contained in:
@@ -43,9 +43,33 @@ void NewMasterFrame() {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
bool BeginCentered(const char *name) {
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
ImVec2 pos(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f);
|
||||
ImGui::SetNextWindowPos(pos, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
ImGuiWindowFlags flags =
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration |
|
||||
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings;
|
||||
return ImGui::Begin(name, nullptr, flags);
|
||||
}
|
||||
|
||||
MasterEditor::~MasterEditor() { rom_.Close(); }
|
||||
void DisplayStatus(absl::Status &status) {
|
||||
if (BeginCentered("StatusWindow")) {
|
||||
ImGui::Text(status.ToString().data());
|
||||
ImGui::Spacing();
|
||||
ImGui::NextColumn();
|
||||
ImGui::Columns(1);
|
||||
ImGui::Separator();
|
||||
ImGui::NewLine();
|
||||
ImGui::SameLine(270);
|
||||
if (ImGui::Button("OK", ImVec2(200, 0))) {
|
||||
status = absl::OkStatus();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void MasterEditor::SetupScreen(std::shared_ptr<SDL_Renderer> renderer) {
|
||||
sdl_renderer_ = renderer;
|
||||
@@ -65,7 +89,6 @@ void MasterEditor::UpdateScreen() {
|
||||
DrawSpriteEditor();
|
||||
DrawScreenEditor();
|
||||
END_TAB_BAR()
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
@@ -73,8 +96,7 @@ void MasterEditor::DrawFileDialog() {
|
||||
if (ImGuiFileDialog::Instance()->Display("ChooseFileDlgKey")) {
|
||||
if (ImGuiFileDialog::Instance()->IsOk()) {
|
||||
std::string filePathName = ImGuiFileDialog::Instance()->GetFilePathName();
|
||||
rom_.LoadFromFile(filePathName);
|
||||
status_ = rom_.OpenFromFile(filePathName);
|
||||
status_ = rom_.LoadFromFile(filePathName);
|
||||
overworld_editor_.SetupROM(rom_);
|
||||
}
|
||||
ImGuiFileDialog::Instance()->Close();
|
||||
@@ -83,7 +105,7 @@ void MasterEditor::DrawFileDialog() {
|
||||
|
||||
void MasterEditor::DrawStatusPopup() {
|
||||
if (!status_.ok()) {
|
||||
gui::widgets::DisplayStatus(status_);
|
||||
DisplayStatus(status_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace editor {
|
||||
|
||||
class MasterEditor {
|
||||
public:
|
||||
~MasterEditor();
|
||||
void SetupScreen(std::shared_ptr<SDL_Renderer> renderer);
|
||||
void UpdateScreen();
|
||||
|
||||
|
||||
@@ -186,25 +186,15 @@ void OverworldEditor::DrawOverworldCanvas() {
|
||||
overworld_map_canvas_.DrawBackground();
|
||||
overworld_map_canvas_.UpdateContext();
|
||||
overworld_map_canvas_.DrawGrid(64.f);
|
||||
// if (all_gfx_loaded_) {
|
||||
// static bool tiles_made = false;
|
||||
// static std::vector<gfx::Bitmap> tiles;
|
||||
// if (!tiles_made) {
|
||||
// tiles = graphics_bin_.at(0).CreateTiles();
|
||||
// auto renderer = rom_.Renderer();
|
||||
// for (auto &tile : tiles) {
|
||||
// tile.CreateTexture(renderer);
|
||||
// }
|
||||
// }
|
||||
|
||||
// for (auto &map : overworld_.GetOverworldMaps()) {
|
||||
// overworld_map_canvas_.GetDrawList()->AddImage(
|
||||
// (void *)tiles[0].GetTexture(),
|
||||
// (void *)map.GetBitmap().GetTexture(),
|
||||
// ImVec2(overworld_map_canvas_.GetZeroPoint().x + 2,
|
||||
// overworld_map_canvas_.GetZeroPoint().y + 2),
|
||||
// ImVec2(
|
||||
// overworld_map_canvas_.GetZeroPoint().x + (tiles[0].GetWidth() *
|
||||
// 2), overworld_map_canvas_.GetZeroPoint().y +
|
||||
// (tiles[0].GetHeight() * 2)));
|
||||
// ImVec2(overworld_map_canvas_.GetZeroPoint().x +
|
||||
// (map.GetBitmap().GetWidth() * 2),
|
||||
// overworld_map_canvas_.GetZeroPoint().y +
|
||||
// (map.GetBitmap().GetHeight() * 2)));
|
||||
// }
|
||||
overworld_map_canvas_.DrawOverlay();
|
||||
}
|
||||
@@ -262,7 +252,7 @@ void OverworldEditor::DrawTile8Selector() {
|
||||
ImVec2(256 + 1, kNumSheetsToLoad * 64 + 1));
|
||||
graphics_bin_canvas_.UpdateContext();
|
||||
if (all_gfx_loaded_) {
|
||||
for (const auto &[key, value] : graphics_bin_v2_) {
|
||||
for (const auto &[key, value] : graphics_bin_) {
|
||||
int offset = 64 * (key + 1);
|
||||
int top_left_y = graphics_bin_canvas_.GetZeroPoint().y + 2;
|
||||
if (key >= 1) {
|
||||
@@ -289,7 +279,6 @@ void OverworldEditor::DrawAreaGraphics() {
|
||||
}
|
||||
current_gfx_canvas_.DrawBackground(ImVec2(256 + 1, 16 * 64 + 1));
|
||||
current_gfx_canvas_.UpdateContext();
|
||||
current_gfx_canvas_.DrawGrid();
|
||||
for (const auto &[key, value] : current_graphics_set_) {
|
||||
int offset = 64 * (key + 1);
|
||||
int top_left_y = current_gfx_canvas_.GetZeroPoint().y + 2;
|
||||
@@ -302,6 +291,7 @@ void OverworldEditor::DrawAreaGraphics() {
|
||||
ImVec2(current_gfx_canvas_.GetZeroPoint().x + 256,
|
||||
current_gfx_canvas_.GetZeroPoint().y + offset));
|
||||
}
|
||||
current_gfx_canvas_.DrawGrid(32.0f);
|
||||
current_gfx_canvas_.DrawOverlay();
|
||||
}
|
||||
}
|
||||
@@ -314,11 +304,11 @@ void OverworldEditor::LoadGraphics() {
|
||||
current_palette_[i].w = 1.f;
|
||||
}
|
||||
|
||||
absl::Status graphics_data_status = rom_.LoadAllGraphicsDataV2();
|
||||
absl::Status graphics_data_status = rom_.LoadAllGraphicsData();
|
||||
if (!graphics_data_status.ok()) {
|
||||
std::cout << "Error " << graphics_data_status.ToString() << std::endl;
|
||||
}
|
||||
graphics_bin_v2_ = rom_.GetGraphicsBinV2();
|
||||
graphics_bin_ = rom_.GetGraphicsBin();
|
||||
|
||||
tile16_blockset_bmp_.Create(128 * 2, 8192 * 2, 8, 1048576);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/status/status.h"
|
||||
@@ -70,8 +69,7 @@ class OverworldEditor {
|
||||
ImGuiTableFlags_Resizable |
|
||||
ImGuiTableFlags_SizingStretchSame;
|
||||
|
||||
std::unordered_map<unsigned int, gfx::Bitmap> graphics_bin_;
|
||||
absl::flat_hash_map<int, gfx::Bitmap> graphics_bin_v2_;
|
||||
absl::flat_hash_map<int, gfx::Bitmap> graphics_bin_;
|
||||
absl::flat_hash_map<int, gfx::Bitmap> current_graphics_set_;
|
||||
|
||||
ROM rom_;
|
||||
|
||||
Reference in New Issue
Block a user