Refactor ImTextureID casting for SDL_Texture rendering
This commit is contained in:
@@ -498,7 +498,7 @@ void DungeonEditor::DrawRoomGraphics() {
|
||||
top_left_y = room_gfx_canvas_.zero_point().y + height * current_block;
|
||||
}
|
||||
room_gfx_canvas_.draw_list()->AddImage(
|
||||
(void*)graphics_bin_[block].texture(),
|
||||
(ImTextureID)(intptr_t)graphics_bin_[block].texture(),
|
||||
ImVec2(room_gfx_canvas_.zero_point().x + 2, top_left_y),
|
||||
ImVec2(room_gfx_canvas_.zero_point().x + 0x100,
|
||||
room_gfx_canvas_.zero_point().y + offset));
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#include "app/gfx/scad_format.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/gui/modules/asset_browser.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/color.h"
|
||||
#include "app/gui/input.h"
|
||||
#include "app/gui/modules/asset_browser.h"
|
||||
#include "app/gui/style.h"
|
||||
#include "app/rom.h"
|
||||
#include "imgui/imgui.h"
|
||||
@@ -215,7 +215,7 @@ absl::Status GraphicsEditor::UpdateGfxSheetList() {
|
||||
if (value.is_active()) {
|
||||
auto texture = value.texture();
|
||||
graphics_bin_canvas_.draw_list()->AddImage(
|
||||
(void*)texture,
|
||||
(ImTextureID)(intptr_t)texture,
|
||||
ImVec2(graphics_bin_canvas_.zero_point().x + 2,
|
||||
graphics_bin_canvas_.zero_point().y + 2),
|
||||
ImVec2(graphics_bin_canvas_.zero_point().x +
|
||||
@@ -712,7 +712,8 @@ absl::Status GraphicsEditor::DrawClipboardImport() {
|
||||
if (Button("Paste From Clipboard")) {
|
||||
const char* text = ImGui::GetClipboardText();
|
||||
if (text) {
|
||||
const auto clipboard_data = std::vector<uint8_t>(text, text + strlen(text));
|
||||
const auto clipboard_data =
|
||||
std::vector<uint8_t>(text, text + strlen(text));
|
||||
ImGui::MemFree((void*)text);
|
||||
status_ = temp_rom_.LoadFromBytes(clipboard_data);
|
||||
is_open_ = true;
|
||||
|
||||
@@ -109,7 +109,7 @@ void OverworldEditor::DrawToolset() {
|
||||
status_ = Redo();
|
||||
}
|
||||
|
||||
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
|
||||
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
|
||||
|
||||
NEXT_COLUMN()
|
||||
if (Button(ICON_MD_ZOOM_OUT)) {
|
||||
@@ -127,7 +127,7 @@ void OverworldEditor::DrawToolset() {
|
||||
}
|
||||
HOVER_HINT("Fullscreen Canvas")
|
||||
|
||||
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
|
||||
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
|
||||
|
||||
NEXT_COLUMN()
|
||||
if (Selectable(ICON_MD_PAN_TOOL_ALT, current_mode == EditingMode::PAN)) {
|
||||
@@ -186,7 +186,7 @@ void OverworldEditor::DrawToolset() {
|
||||
}
|
||||
HOVER_HINT("Gfx Group Editor")
|
||||
|
||||
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
|
||||
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
|
||||
|
||||
TableNextColumn();
|
||||
if (Button(ICON_MD_CONTENT_COPY)) {
|
||||
@@ -201,10 +201,10 @@ void OverworldEditor::DrawToolset() {
|
||||
}
|
||||
HOVER_HINT("Copy Map to Clipboard");
|
||||
|
||||
TableNextColumn(); // Palette
|
||||
TableNextColumn(); // Palette
|
||||
status_ = DisplayPalette(palette_, overworld_.is_loaded());
|
||||
|
||||
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
|
||||
TEXT_COLUMN(ICON_MD_MORE_VERT) // Separator
|
||||
|
||||
TableNextColumn();
|
||||
Checkbox("Properties", &show_properties);
|
||||
@@ -514,12 +514,10 @@ void OverworldEditor::CheckForOverworldEdits() {
|
||||
int end_x = std::floor(end.x / kTile16Size) * kTile16Size;
|
||||
int end_y = std::floor(end.y / kTile16Size) * kTile16Size;
|
||||
|
||||
if (start_x > end_x)
|
||||
std::swap(start_x, end_x);
|
||||
if (start_y > end_y)
|
||||
std::swap(start_y, end_y);
|
||||
if (start_x > end_x) std::swap(start_x, end_x);
|
||||
if (start_y > end_y) std::swap(start_y, end_y);
|
||||
|
||||
constexpr int local_map_size = 512; // Size of each local map
|
||||
constexpr int local_map_size = 512; // Size of each local map
|
||||
// Number of tiles per local map (since each tile is 16x16)
|
||||
constexpr int tiles_per_local_map = local_map_size / kTile16Size;
|
||||
|
||||
@@ -670,8 +668,7 @@ void OverworldEditor::DrawOverworldCanvas() {
|
||||
if (current_mode == EditingMode::DRAW_TILE) {
|
||||
CheckForOverworldEdits();
|
||||
}
|
||||
if (IsItemHovered())
|
||||
status_ = CheckForCurrentMap();
|
||||
if (IsItemHovered()) status_ = CheckForCurrentMap();
|
||||
}
|
||||
|
||||
ow_map_canvas_.DrawGrid();
|
||||
@@ -734,7 +731,7 @@ void OverworldEditor::DrawTile8Selector() {
|
||||
}
|
||||
auto texture = value.texture();
|
||||
graphics_bin_canvas_.draw_list()->AddImage(
|
||||
(void *)texture,
|
||||
(ImTextureID)(intptr_t)texture,
|
||||
ImVec2(graphics_bin_canvas_.zero_point().x + 2, top_left_y),
|
||||
ImVec2(graphics_bin_canvas_.zero_point().x + 0x100,
|
||||
graphics_bin_canvas_.zero_point().y + offset));
|
||||
@@ -1149,8 +1146,7 @@ void OverworldEditor::RefreshOverworldMap() {
|
||||
// We need to update the map and its siblings if it's a large map
|
||||
for (int i = 1; i < 4; i++) {
|
||||
int sibling_index = overworld_.overworld_map(source_map_id)->parent() + i;
|
||||
if (i >= 2)
|
||||
sibling_index += 6;
|
||||
if (i >= 2) sibling_index += 6;
|
||||
futures.push_back(
|
||||
std::async(std::launch::async, refresh_map_async, sibling_index));
|
||||
indices[i] = sibling_index;
|
||||
@@ -1179,8 +1175,7 @@ absl::Status OverworldEditor::RefreshMapPalette() {
|
||||
// We need to update the map and its siblings if it's a large map
|
||||
for (int i = 1; i < 4; i++) {
|
||||
int sibling_index = overworld_.overworld_map(current_map_)->parent() + i;
|
||||
if (i >= 2)
|
||||
sibling_index += 6;
|
||||
if (i >= 2) sibling_index += 6;
|
||||
RETURN_IF_ERROR(
|
||||
overworld_.mutable_overworld_map(sibling_index)->LoadPalette());
|
||||
RETURN_IF_ERROR(
|
||||
@@ -1423,7 +1418,7 @@ void OverworldEditor::DrawUsageGrid() {
|
||||
int totalSquares = 128;
|
||||
int squaresWide = 8;
|
||||
int squaresTall = (totalSquares + squaresWide - 1) /
|
||||
squaresWide; // Ceiling of totalSquares/squaresWide
|
||||
squaresWide; // Ceiling of totalSquares/squaresWide
|
||||
|
||||
// Loop through each row
|
||||
for (int row = 0; row < squaresTall; ++row) {
|
||||
@@ -1438,8 +1433,9 @@ void OverworldEditor::DrawUsageGrid() {
|
||||
|
||||
// Set highlight color if needed
|
||||
if (highlight) {
|
||||
PushStyleColor(ImGuiCol_Button, ImVec4(1.0f, 0.5f, 0.0f,
|
||||
1.0f)); // Or any highlight color
|
||||
PushStyleColor(ImGuiCol_Button,
|
||||
ImVec4(1.0f, 0.5f, 0.0f,
|
||||
1.0f)); // Or any highlight color
|
||||
}
|
||||
|
||||
// Create a button or selectable for each square
|
||||
@@ -1524,6 +1520,6 @@ void OverworldEditor::InitializeZeml() {
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace editor
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
} // namespace editor
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
|
||||
Reference in New Issue
Block a user