Update referenes to SnesColor members
This commit is contained in:
@@ -95,7 +95,7 @@ void Canvas::DrawBackground(ImVec2 canvas_size, bool can_drag) {
|
||||
}
|
||||
}
|
||||
|
||||
void Canvas::DrawContextMenu() {
|
||||
void Canvas::DrawContextMenu(gfx::Bitmap *bitmap) {
|
||||
const ImGuiIO &io = ImGui::GetIO();
|
||||
auto scaled_sz =
|
||||
ImVec2(canvas_sz_.x * global_scale_, canvas_sz_.y * global_scale_);
|
||||
@@ -122,10 +122,13 @@ void Canvas::DrawContextMenu() {
|
||||
ImGui::Text("Mouse Position: %.0f x %.0f", mouse_pos.x, mouse_pos.y);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Bitmap Properties")) {
|
||||
ImGui::Text("Bitmap Size: %.0f x %.0f", scaled_sz.x, scaled_sz.y);
|
||||
ImGui::Text("Bitmap Position: %.0f x %.0f", origin.x, origin.y);
|
||||
ImGui::EndMenu();
|
||||
if (bitmap != nullptr) {
|
||||
if (ImGui::BeginMenu("Bitmap Properties")) {
|
||||
ImGui::Text("Size: %.0f x %.0f", scaled_sz.x, scaled_sz.y);
|
||||
ImGui::Text("Pitch: %s",
|
||||
absl::StrFormat("%d", bitmap->surface()->pitch).c_str());
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginMenu("Grid Tile Size")) {
|
||||
@@ -261,7 +264,7 @@ bool Canvas::DrawSolidTilePainter(const ImVec4 &color, int tile_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Canvas::DrawTileOnBitmap(int tile_size, gfx::Bitmap &bitmap,
|
||||
void Canvas::DrawTileOnBitmap(int tile_size, gfx::Bitmap *bitmap,
|
||||
ImVec4 color) {
|
||||
const ImVec2 position = drawn_tile_pos_;
|
||||
int tile_index_x = static_cast<int>(position.x / global_scale_) / tile_size;
|
||||
@@ -274,10 +277,10 @@ void Canvas::DrawTileOnBitmap(int tile_size, gfx::Bitmap &bitmap,
|
||||
for (int x = 0; x < tile_size; ++x) {
|
||||
// Calculate the actual pixel index in the bitmap
|
||||
int pixel_index =
|
||||
(start_position.y + y) * bitmap.width() + (start_position.x + x);
|
||||
(start_position.y + y) * bitmap->width() + (start_position.x + x);
|
||||
|
||||
// Write the color to the pixel
|
||||
bitmap.WriteColor(pixel_index, color);
|
||||
bitmap->WriteColor(pixel_index, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class Canvas {
|
||||
|
||||
// Context Menu refers to what happens when the right mouse button is pressed
|
||||
// This routine also handles the scrolling for the canvas.
|
||||
void DrawContextMenu();
|
||||
void DrawContextMenu(gfx::Bitmap* bitmap = nullptr);
|
||||
|
||||
// Tile painter shows a preview of the currently selected tile
|
||||
// and allows the user to left click to paint the tile or right
|
||||
@@ -71,7 +71,7 @@ class Canvas {
|
||||
bool DrawSolidTilePainter(const ImVec4& color, int size);
|
||||
|
||||
// Draws a tile on the canvas at the specified position
|
||||
void DrawTileOnBitmap(int tile_size, gfx::Bitmap& bitmap, ImVec4 color);
|
||||
void DrawTileOnBitmap(int tile_size, gfx::Bitmap* bitmap, ImVec4 color);
|
||||
|
||||
// Dictates which tile is currently selected based on what the user clicks
|
||||
// in the canvas window. Represented and split apart into a grid of tiles.
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace app {
|
||||
namespace gui {
|
||||
|
||||
ImVec4 ConvertSNESColorToImVec4(const SnesColor& color) {
|
||||
return ImVec4(static_cast<float>(color.GetRGB().x) / 255.0f,
|
||||
static_cast<float>(color.GetRGB().y) / 255.0f,
|
||||
static_cast<float>(color.GetRGB().z) / 255.0f,
|
||||
return ImVec4(static_cast<float>(color.rgb().x) / 255.0f,
|
||||
static_cast<float>(color.rgb().y) / 255.0f,
|
||||
static_cast<float>(color.rgb().z) / 255.0f,
|
||||
1.0f // Assuming alpha is always fully opaque for SNES colors,
|
||||
// adjust if necessary
|
||||
);
|
||||
@@ -45,9 +45,9 @@ void DisplayPalette(app::gfx::SnesPalette& palette, bool loaded) {
|
||||
static ImVec4 saved_palette[32] = {};
|
||||
if (loaded && !init) {
|
||||
for (int n = 0; n < palette.size(); n++) {
|
||||
saved_palette[n].x = palette.GetColor(n).GetRGB().x / 255;
|
||||
saved_palette[n].y = palette.GetColor(n).GetRGB().y / 255;
|
||||
saved_palette[n].z = palette.GetColor(n).GetRGB().z / 255;
|
||||
saved_palette[n].x = palette.GetColor(n).rgb().x / 255;
|
||||
saved_palette[n].y = palette.GetColor(n).rgb().y / 255;
|
||||
saved_palette[n].z = palette.GetColor(n).rgb().z / 255;
|
||||
saved_palette[n].w = 255; // Alpha
|
||||
}
|
||||
init = true;
|
||||
|
||||
Reference in New Issue
Block a user