Add context info about bitmaps to canvas
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
|
#include "app/gfx/tilesheet.h"
|
||||||
#include "app/gui/canvas.h"
|
#include "app/gui/canvas.h"
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
#include "app/gui/input.h"
|
#include "app/gui/input.h"
|
||||||
@@ -89,6 +90,7 @@ absl::Status Tile16Editor::DrawTile16Editor() {
|
|||||||
|
|
||||||
TableNextColumn();
|
TableNextColumn();
|
||||||
RETURN_IF_ERROR(UpdateTile16Edit());
|
RETURN_IF_ERROR(UpdateTile16Edit());
|
||||||
|
RETURN_IF_ERROR(DrawTileEditControls());
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
@@ -172,7 +174,7 @@ absl::Status Tile16Editor::UpdateTile16Edit() {
|
|||||||
ImVec2(ImGui::GetContentRegionAvail().x, 0x175),
|
ImVec2(ImGui::GetContentRegionAvail().x, 0x175),
|
||||||
true)) {
|
true)) {
|
||||||
tile8_source_canvas_.DrawBackground();
|
tile8_source_canvas_.DrawBackground();
|
||||||
tile8_source_canvas_.DrawContextMenu();
|
tile8_source_canvas_.DrawContextMenu(¤t_gfx_bmp_);
|
||||||
if (tile8_source_canvas_.DrawTileSelector(32)) {
|
if (tile8_source_canvas_.DrawTileSelector(32)) {
|
||||||
RETURN_IF_ERROR(
|
RETURN_IF_ERROR(
|
||||||
current_gfx_individual_[current_tile8_].ApplyPaletteWithTransparent(
|
current_gfx_individual_[current_tile8_].ApplyPaletteWithTransparent(
|
||||||
@@ -200,7 +202,7 @@ absl::Status Tile16Editor::UpdateTile16Edit() {
|
|||||||
if (ImGui::BeginChild("Tile16 Editor Options",
|
if (ImGui::BeginChild("Tile16 Editor Options",
|
||||||
ImVec2(ImGui::GetContentRegionAvail().x, 0x50), true)) {
|
ImVec2(ImGui::GetContentRegionAvail().x, 0x50), true)) {
|
||||||
tile16_edit_canvas_.DrawBackground();
|
tile16_edit_canvas_.DrawBackground();
|
||||||
tile16_edit_canvas_.DrawContextMenu();
|
tile16_edit_canvas_.DrawContextMenu(¤t_tile16_bmp_);
|
||||||
tile16_edit_canvas_.DrawBitmap(current_tile16_bmp_, 0, 0, 4.0f);
|
tile16_edit_canvas_.DrawBitmap(current_tile16_bmp_, 0, 0, 4.0f);
|
||||||
if (!tile8_source_canvas_.points().empty()) {
|
if (!tile8_source_canvas_.points().empty()) {
|
||||||
if (tile16_edit_canvas_.DrawTilePainter(
|
if (tile16_edit_canvas_.DrawTilePainter(
|
||||||
@@ -214,7 +216,6 @@ absl::Status Tile16Editor::UpdateTile16Edit() {
|
|||||||
tile16_edit_canvas_.DrawOverlay();
|
tile16_edit_canvas_.DrawOverlay();
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
RETURN_IF_ERROR(DrawTileEditControls());
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +278,7 @@ absl::Status Tile16Editor::LoadTile8() {
|
|||||||
int gfx_position = x + (y * 0x100);
|
int gfx_position = x + (y * 0x100);
|
||||||
|
|
||||||
// Get the pixel value from the current gfx data
|
// Get the pixel value from the current gfx data
|
||||||
uint8_t value = tile8_gfx_data_[gfx_position];
|
uint8_t value = current_gfx_bmp_.data()[gfx_position];
|
||||||
|
|
||||||
if (value & 0x80) {
|
if (value & 0x80) {
|
||||||
value -= 0x88;
|
value -= 0x88;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
|
#include "app/gfx/tilesheet.h"
|
||||||
#include "app/gui/canvas.h"
|
#include "app/gui/canvas.h"
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
#include "app/gui/pipeline.h"
|
#include "app/gui/pipeline.h"
|
||||||
@@ -106,6 +107,7 @@ class Tile16Editor : public GfxContext, public SharedROM {
|
|||||||
ImVec2(core::kTilesheetWidth * 4, core::kTilesheetHeight * 0x10 * 4),
|
ImVec2(core::kTilesheetWidth * 4, core::kTilesheetHeight * 0x10 * 4),
|
||||||
gui::CanvasGridSize::k32x32};
|
gui::CanvasGridSize::k32x32};
|
||||||
gfx::Bitmap current_gfx_bmp_;
|
gfx::Bitmap current_gfx_bmp_;
|
||||||
|
std::vector<gfx::Tilesheet> current_tilesheets_;
|
||||||
|
|
||||||
gui::Canvas transfer_canvas_;
|
gui::Canvas transfer_canvas_;
|
||||||
gfx::Bitmap transfer_blockset_bmp_;
|
gfx::Bitmap transfer_blockset_bmp_;
|
||||||
@@ -129,8 +131,6 @@ class Tile16Editor : public GfxContext, public SharedROM {
|
|||||||
|
|
||||||
ROM transfer_rom_;
|
ROM transfer_rom_;
|
||||||
absl::Status transfer_status_;
|
absl::Status transfer_status_;
|
||||||
|
|
||||||
core::TaskManager<std::function<void(int)>> task_manager_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace editor
|
} // namespace editor
|
||||||
|
|||||||
@@ -48,10 +48,11 @@ class Bitmap {
|
|||||||
int height);
|
int height);
|
||||||
|
|
||||||
absl::Status ApplyPalette(const SnesPalette &palette);
|
absl::Status ApplyPalette(const SnesPalette &palette);
|
||||||
absl::Status ApplyPaletteWithTransparent(const SnesPalette &palette, int index,
|
absl::Status ApplyPaletteWithTransparent(const SnesPalette &palette,
|
||||||
int length = 7);
|
int index, int length = 7);
|
||||||
void ApplyPalette(const std::vector<SDL_Color> &palette);
|
void ApplyPalette(const std::vector<SDL_Color> &palette);
|
||||||
absl::Status ApplyPaletteFromPaletteGroup(const SnesPalette &palette, int palette_id);
|
absl::Status ApplyPaletteFromPaletteGroup(const SnesPalette &palette,
|
||||||
|
int palette_id);
|
||||||
|
|
||||||
void WriteToPixel(int position, uchar value) {
|
void WriteToPixel(int position, uchar value) {
|
||||||
if (pixel_data_ == nullptr) {
|
if (pixel_data_ == nullptr) {
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ void Canvas::DrawContextMenu(gfx::Bitmap *bitmap) {
|
|||||||
scrolling_.y = 0;
|
scrolling_.y = 0;
|
||||||
}
|
}
|
||||||
ImGui::MenuItem("Show Grid", nullptr, &enable_grid_);
|
ImGui::MenuItem("Show Grid", nullptr, &enable_grid_);
|
||||||
ImGui::Selectable("Show Labels", &enable_hex_tile_labels_);
|
ImGui::Selectable("Show Position Labels", &enable_hex_tile_labels_);
|
||||||
if (ImGui::BeginMenu("Canvas Properties")) {
|
if (ImGui::BeginMenu("Canvas Properties")) {
|
||||||
ImGui::Text("Canvas Size: %.0f x %.0f", canvas_sz_.x, canvas_sz_.y);
|
ImGui::Text("Canvas Size: %.0f x %.0f", canvas_sz_.x, canvas_sz_.y);
|
||||||
ImGui::Text("Global Scale: %.1f", global_scale_);
|
ImGui::Text("Global Scale: %.1f", global_scale_);
|
||||||
@@ -127,6 +127,10 @@ void Canvas::DrawContextMenu(gfx::Bitmap *bitmap) {
|
|||||||
ImGui::Text("Size: %.0f x %.0f", scaled_sz.x, scaled_sz.y);
|
ImGui::Text("Size: %.0f x %.0f", scaled_sz.x, scaled_sz.y);
|
||||||
ImGui::Text("Pitch: %s",
|
ImGui::Text("Pitch: %s",
|
||||||
absl::StrFormat("%d", bitmap->surface()->pitch).c_str());
|
absl::StrFormat("%d", bitmap->surface()->pitch).c_str());
|
||||||
|
ImGui::Text("BitsPerPixel: %d",
|
||||||
|
bitmap->surface()->format->BitsPerPixel);
|
||||||
|
ImGui::Text("BytesPerPixel: %d",
|
||||||
|
bitmap->surface()->format->BytesPerPixel);
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user