Tile16Editor housekeeping
This commit is contained in:
@@ -21,61 +21,38 @@ namespace yaze {
|
||||
namespace app {
|
||||
namespace editor {
|
||||
|
||||
using ImGui::BeginChild;
|
||||
using ImGui::BeginTabBar;
|
||||
using ImGui::BeginTabItem;
|
||||
using ImGui::BeginTable;
|
||||
using ImGui::Combo;
|
||||
using ImGui::EndChild;
|
||||
using ImGui::EndTabBar;
|
||||
using ImGui::EndTabItem;
|
||||
using ImGui::TableHeadersRow;
|
||||
using ImGui::TableNextColumn;
|
||||
using ImGui::TableNextRow;
|
||||
using ImGui::TableSetupColumn;
|
||||
|
||||
absl::Status Tile16Editor::Update() {
|
||||
// Create a tab bar for Tile16 Editing and Tile16 Transfer
|
||||
if (ImGui::BeginTabBar("Tile16 Editor Tabs")) {
|
||||
if (BeginTabBar("Tile16 Editor Tabs")) {
|
||||
// Create a tab for Tile16 Editing
|
||||
if (ImGui::BeginTabItem("Tile16 Editing")) {
|
||||
if (ImGui::BeginTable("#Tile16EditorTable", 2,
|
||||
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable,
|
||||
ImVec2(0, 0))) {
|
||||
ImGui::TableSetupColumn("Tiles", ImGuiTableColumnFlags_WidthFixed,
|
||||
ImGui::GetContentRegionAvail().x);
|
||||
ImGui::TableSetupColumn("Properties",
|
||||
ImGuiTableColumnFlags_WidthStretch,
|
||||
ImGui::GetContentRegionAvail().x);
|
||||
ImGui::TableHeadersRow();
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
// Create a canvas for the Tile16
|
||||
core::BitmapCanvasPipeline(blockset_canvas_, tile16_blockset_bmp_,
|
||||
0x100, (8192 * 2), 0x20,
|
||||
map_blockset_loaded_, true, 1);
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
// Create various options for the Tile16 Editor
|
||||
if (ImGuiID child_id = ImGui::GetID((void*)(intptr_t)27);
|
||||
ImGui::BeginChild(child_id,
|
||||
ImVec2(ImGui::GetContentRegionAvail().x, 0x100),
|
||||
true)) {
|
||||
tile16_edit_canvas_.DrawBackground(ImVec2(0x40, 0x40));
|
||||
tile16_edit_canvas_.DrawContextMenu();
|
||||
if (!blockset_canvas_.Points().empty()) {
|
||||
int x = blockset_canvas_.Points().front().x / 32;
|
||||
int y = blockset_canvas_.Points().front().y / 32;
|
||||
current_tile16_ = x + (y * 8);
|
||||
if (tile16_edit_canvas_.DrawTilePainter(
|
||||
tile16_individual_[current_tile16_], 16)) {
|
||||
// Update the tile16
|
||||
}
|
||||
}
|
||||
tile16_edit_canvas_.DrawGrid(64.0f);
|
||||
tile16_edit_canvas_.DrawOverlay();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
if (BeginTabItem("Tile16 Editing")) {
|
||||
if (BeginTable("#Tile16EditorTable", 2, TABLE_BORDERS_RESIZABLE,
|
||||
ImVec2(0, 0))) {
|
||||
TableSetupColumn("Tiles", ImGuiTableColumnFlags_WidthFixed,
|
||||
ImGui::GetContentRegionAvail().x);
|
||||
TableSetupColumn("Properties", ImGuiTableColumnFlags_WidthStretch,
|
||||
ImGui::GetContentRegionAvail().x);
|
||||
TableHeadersRow();
|
||||
TableNextRow();
|
||||
TableNextColumn();
|
||||
RETURN_IF_ERROR(UpdateBlockset());
|
||||
|
||||
TableNextColumn();
|
||||
RETURN_IF_ERROR(UpdateTile16Edit());
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Options:");
|
||||
ImGui::Checkbox("X Flip", &x_flip);
|
||||
ImGui::Checkbox("Y Flip", &y_flip);
|
||||
ImGui::Checkbox("Priority Tile", &priority_tile);
|
||||
ImGui::SliderInt("Tile Size", &tile_size, 8, 16);
|
||||
static const char* items[] = {"Item 1", "Item 2", "Item 3"};
|
||||
static int item_current = 0;
|
||||
ImGui::Combo("Combo", &item_current, items, IM_ARRAYSIZE(items));
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
@@ -83,62 +60,23 @@ absl::Status Tile16Editor::Update() {
|
||||
}
|
||||
|
||||
// Create a tab for Tile16 Transfer
|
||||
if (ImGui::BeginTabItem("Tile16 Transfer")) {
|
||||
if (ImGui::BeginTable("#Tile16TransferTable", 2,
|
||||
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable,
|
||||
ImVec2(0, 0))) {
|
||||
ImGui::TableSetupColumn("Current ROM Tiles",
|
||||
ImGuiTableColumnFlags_WidthFixed,
|
||||
ImGui::GetContentRegionAvail().x / 2);
|
||||
ImGui::TableSetupColumn("Transfer ROM Tiles",
|
||||
ImGuiTableColumnFlags_WidthFixed,
|
||||
ImGui::GetContentRegionAvail().x / 2);
|
||||
ImGui::TableHeadersRow();
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
// Create a canvas for holding the tiles which will be imported
|
||||
core::BitmapCanvasPipeline(blockset_canvas_, tile16_blockset_bmp_,
|
||||
0x100, (8192 * 2), 0x20,
|
||||
map_blockset_loaded_, true, 2);
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
// Create a button for loading another ROM
|
||||
if (ImGui::Button("Load ROM")) {
|
||||
ImGuiFileDialog::Instance()->OpenDialog("ChooseTransferFileDlgKey",
|
||||
"Open Transfer ROM",
|
||||
".sfc,.smc", ".");
|
||||
}
|
||||
core::FileDialogPipeline(
|
||||
"ChooseTransferFileDlgKey", ".sfc,.smc", std::nullopt, [&]() {
|
||||
std::string filePathName =
|
||||
ImGuiFileDialog::Instance()->GetFilePathName();
|
||||
transfer_status_ = transfer_rom_.LoadFromFile(filePathName);
|
||||
transfer_started_ = true;
|
||||
});
|
||||
if (BeginTabItem("Tile16 Transfer")) {
|
||||
if (BeginTable("#Tile16TransferTable", 2,
|
||||
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable,
|
||||
ImVec2(0, 0))) {
|
||||
TableSetupColumn("Current ROM Tiles", ImGuiTableColumnFlags_WidthFixed,
|
||||
ImGui::GetContentRegionAvail().x / 2);
|
||||
TableSetupColumn("Transfer ROM Tiles", ImGuiTableColumnFlags_WidthFixed,
|
||||
ImGui::GetContentRegionAvail().x / 2);
|
||||
TableHeadersRow();
|
||||
TableNextRow();
|
||||
|
||||
if (transfer_started_ && !transfer_blockset_loaded_) {
|
||||
PRINT_IF_ERROR(transfer_rom_.LoadAllGraphicsData())
|
||||
graphics_bin_ = transfer_rom_.graphics_bin();
|
||||
TableNextColumn();
|
||||
RETURN_IF_ERROR(UpdateBlockset());
|
||||
|
||||
// Load the Link to the Past overworld.
|
||||
PRINT_IF_ERROR(transfer_overworld_.Load(transfer_rom_))
|
||||
transfer_overworld_.SetCurrentMap(0);
|
||||
palette_ = transfer_overworld_.AreaPalette();
|
||||
TableNextColumn();
|
||||
RETURN_IF_ERROR(UpdateTransferTileCanvas());
|
||||
|
||||
// Create the tile16 blockset image
|
||||
core::BuildAndRenderBitmapPipeline(
|
||||
0x80, 0x2000, 0x80, transfer_overworld_.Tile16Blockset(),
|
||||
*rom(), transfer_blockset_bmp_, palette_);
|
||||
transfer_blockset_loaded_ = true;
|
||||
}
|
||||
|
||||
// Create a canvas for holding the tiles which will be exported
|
||||
core::BitmapCanvasPipeline(transfer_canvas_, transfer_blockset_bmp_,
|
||||
0x100, (8192 * 2), 0x20,
|
||||
transfer_blockset_loaded_, true, 3);
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
@@ -151,6 +89,79 @@ absl::Status Tile16Editor::Update() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Tile16Editor::UpdateBlockset() { // Create a canvas for the Tile16
|
||||
core::BitmapCanvasPipeline(blockset_canvas_, tile16_blockset_bmp_, 0x100,
|
||||
(8192 * 2), 0x20, map_blockset_loaded_, true, 1);
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Tile16Editor::UpdateTile16Edit() { // Create various options for
|
||||
// the Tile16 Editor
|
||||
if (ImGui::BeginChild(core::ImGuiIdIssuer::GetNewID(),
|
||||
ImVec2(ImGui::GetContentRegionAvail().x, 0x100),
|
||||
true)) {
|
||||
tile16_edit_canvas_.DrawBackground(ImVec2(0x40, 0x40));
|
||||
tile16_edit_canvas_.DrawContextMenu();
|
||||
if (!blockset_canvas_.Points().empty()) {
|
||||
int x = blockset_canvas_.Points().front().x / 32;
|
||||
int y = blockset_canvas_.Points().front().y / 32;
|
||||
current_tile16_ = x + (y * 8);
|
||||
if (tile16_edit_canvas_.DrawTilePainter(
|
||||
tile16_individual_[current_tile16_], 16)) {
|
||||
// Update the tile16
|
||||
}
|
||||
}
|
||||
tile16_edit_canvas_.DrawGrid(64.0f);
|
||||
tile16_edit_canvas_.DrawOverlay();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Options:");
|
||||
ImGui::Checkbox("X Flip", &x_flip);
|
||||
ImGui::Checkbox("Y Flip", &y_flip);
|
||||
ImGui::Checkbox("Priority Tile", &priority_tile);
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Tile16Editor::UpdateTransferTileCanvas() {
|
||||
// Create a button for loading another ROM
|
||||
if (ImGui::Button("Load ROM")) {
|
||||
ImGuiFileDialog::Instance()->OpenDialog(
|
||||
"ChooseTransferFileDlgKey", "Open Transfer ROM", ".sfc,.smc", ".");
|
||||
}
|
||||
core::FileDialogPipeline(
|
||||
"ChooseTransferFileDlgKey", ".sfc,.smc", std::nullopt, [&]() {
|
||||
std::string filePathName =
|
||||
ImGuiFileDialog::Instance()->GetFilePathName();
|
||||
transfer_status_ = transfer_rom_.LoadFromFile(filePathName);
|
||||
transfer_started_ = true;
|
||||
});
|
||||
|
||||
if (transfer_started_ && !transfer_blockset_loaded_) {
|
||||
PRINT_IF_ERROR(transfer_rom_.LoadAllGraphicsData())
|
||||
graphics_bin_ = transfer_rom_.graphics_bin();
|
||||
|
||||
// Load the Link to the Past overworld.
|
||||
PRINT_IF_ERROR(transfer_overworld_.Load(transfer_rom_))
|
||||
transfer_overworld_.SetCurrentMap(0);
|
||||
palette_ = transfer_overworld_.AreaPalette();
|
||||
|
||||
// Create the tile16 blockset image
|
||||
core::BuildAndRenderBitmapPipeline(
|
||||
0x80, 0x2000, 0x80, transfer_overworld_.Tile16Blockset(), *rom(),
|
||||
transfer_blockset_bmp_, palette_);
|
||||
transfer_blockset_loaded_ = true;
|
||||
}
|
||||
|
||||
// Create a canvas for holding the tiles which will be exported
|
||||
core::BitmapCanvasPipeline(transfer_canvas_, transfer_blockset_bmp_, 0x100,
|
||||
(8192 * 2), 0x20, transfer_blockset_loaded_, true,
|
||||
3);
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Tile16Editor::InitBlockset(
|
||||
gfx::Bitmap tile16_blockset_bmp, std::vector<gfx::Bitmap> tile16_individual,
|
||||
std::vector<gfx::Bitmap> tile8_individual_) {
|
||||
|
||||
Reference in New Issue
Block a user