housekeeping
This commit is contained in:
@@ -228,6 +228,9 @@ void GfxGroupEditor::DrawSpritesetViewer(bool sheet_only) {
|
||||
|
||||
namespace {
|
||||
void DrawPaletteFromPaletteGroup(gfx::SnesPalette &palette) {
|
||||
if (palette.empty()) {
|
||||
return;
|
||||
}
|
||||
for (int n = 0; n < palette.size(); n++) {
|
||||
PushID(n);
|
||||
if ((n % 8) != 0) SameLine(0.0f, GetStyle().ItemSpacing.y);
|
||||
|
||||
@@ -183,7 +183,7 @@ void GraphicsEditor::DrawGfxEditToolset() {
|
||||
}
|
||||
|
||||
TableNextColumn();
|
||||
gui::InputHexByte("Tile Size", &tile_size_, 0x01);
|
||||
gui::InputHexByte("Tile Size", &tile_size_);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ using ImGui::TableNextRow;
|
||||
using ImGui::TableSetupColumn;
|
||||
using ImGui::Text;
|
||||
|
||||
constexpr uint16_t kOverworldMapSize = 0x200;
|
||||
|
||||
void OverworldEditor::InitializeZeml() {
|
||||
// Load zeml string from layouts/overworld.zeml
|
||||
std::string layout = gui::zeml::LoadFile("overworld.zeml");
|
||||
@@ -461,8 +463,8 @@ void OverworldEditor::DrawOverworldMaps() {
|
||||
int yy = 0;
|
||||
for (int i = 0; i < 0x40; i++) {
|
||||
int world_index = i + (current_world_ * 0x40);
|
||||
int map_x = (xx * 0x200 * ow_map_canvas_.global_scale());
|
||||
int map_y = (yy * 0x200 * ow_map_canvas_.global_scale());
|
||||
int map_x = (xx * kOverworldMapSize * ow_map_canvas_.global_scale());
|
||||
int map_y = (yy * kOverworldMapSize * ow_map_canvas_.global_scale());
|
||||
ow_map_canvas_.DrawBitmap(maps_bmp_[world_index], map_x, map_y,
|
||||
ow_map_canvas_.global_scale());
|
||||
xx++;
|
||||
@@ -531,7 +533,8 @@ void OverworldEditor::RenderUpdatedMapBitmap(const ImVec2 &click_position,
|
||||
// Update the bitmap's pixel data based on the start_position and tile_data
|
||||
for (int y = 0; y < tile_size; ++y) {
|
||||
for (int x = 0; x < tile_size; ++x) {
|
||||
int pixel_index = (start_position.y + y) * 0x200 + (start_position.x + x);
|
||||
int pixel_index =
|
||||
(start_position.y + y) * kOverworldMapSize + (start_position.x + x);
|
||||
current_bitmap.WriteToPixel(pixel_index, tile_data[y * tile_size + x]);
|
||||
}
|
||||
}
|
||||
@@ -797,7 +800,8 @@ absl::Status OverworldEditor::DrawAreaGraphics() {
|
||||
palette_ = overworld_.AreaPalette();
|
||||
gfx::Bitmap bmp;
|
||||
RETURN_IF_ERROR(rom()->CreateAndRenderBitmap(
|
||||
0x80, 0x200, 0x08, overworld_.current_graphics(), bmp, palette_));
|
||||
0x80, kOverworldMapSize, 0x08, overworld_.current_graphics(), bmp,
|
||||
palette_));
|
||||
current_graphics_set_[current_map_] = bmp;
|
||||
}
|
||||
}
|
||||
@@ -1605,7 +1609,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
palette_ = overworld_.AreaPalette();
|
||||
|
||||
// Create the area graphics image
|
||||
RETURN_IF_ERROR(rom()->CreateAndRenderBitmap(0x80, 0x200, 0x40,
|
||||
RETURN_IF_ERROR(rom()->CreateAndRenderBitmap(0x80, kOverworldMapSize, 0x40,
|
||||
overworld_.current_graphics(),
|
||||
current_gfx_bmp_, palette_));
|
||||
|
||||
@@ -1650,7 +1654,8 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
overworld_.set_current_map(i);
|
||||
auto palette = overworld_.AreaPalette();
|
||||
RETURN_IF_ERROR(rom()->CreateAndRenderBitmap(
|
||||
0x200, 0x200, 0x200, overworld_.BitmapData(), maps_bmp_[i], palette));
|
||||
kOverworldMapSize, kOverworldMapSize, 0x200, overworld_.BitmapData(),
|
||||
maps_bmp_[i], palette));
|
||||
}
|
||||
|
||||
if (flags()->overworld.kDrawOverworldSprites) {
|
||||
@@ -1977,8 +1982,8 @@ absl::Status OverworldEditor::LoadAnimatedMaps() {
|
||||
RETURN_IF_ERROR(map.BuildBitmap(blockset));
|
||||
|
||||
RETURN_IF_ERROR(rom()->CreateAndRenderBitmap(
|
||||
0x200, 0x200, 0x200, map.bitmap_data(), animated_maps_[world_index],
|
||||
*map.mutable_current_palette()));
|
||||
kOverworldMapSize, kOverworldMapSize, 0x200, map.bitmap_data(),
|
||||
animated_maps_[world_index], *map.mutable_current_palette()));
|
||||
|
||||
animated_built[world_index] = true;
|
||||
}
|
||||
|
||||
@@ -137,6 +137,7 @@ class SnesPalette {
|
||||
}
|
||||
|
||||
auto size() const { return colors.size(); }
|
||||
auto empty() const { return colors.empty(); }
|
||||
|
||||
SnesColor& operator[](int i) {
|
||||
if (i > size_) {
|
||||
|
||||
@@ -503,7 +503,7 @@ struct GfxSheetAssetBrowser {
|
||||
ImGui::GetColorU32(ImVec4(1, 1, 1, 1)));
|
||||
draw_list->AddText(
|
||||
ImVec2(box_min.x, box_max.y - ImGui::GetFontSize()),
|
||||
label_col, "ID");
|
||||
label_col, absl::StrFormat("%X", item_data->ID).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ bool InputScalarLeft(const char* label, ImGuiDataType data_type, void* p_data,
|
||||
// value_changed = DataTypeApplyFromText(buf, data_type, p_data, format);
|
||||
// } else {
|
||||
const float button_size = GetFrameHeight();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("%s", label);
|
||||
ImGui::SameLine();
|
||||
AlignTextToFramePadding();
|
||||
Text("%s", label);
|
||||
SameLine();
|
||||
BeginGroup(); // The only purpose of the group here is to allow the caller
|
||||
// to query item data e.g. IsItemActive()
|
||||
PushID(label);
|
||||
@@ -57,12 +57,12 @@ bool InputScalarLeft(const char* label, ImGuiDataType data_type, void* p_data,
|
||||
1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
|
||||
|
||||
// Place the label on the left of the input field
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,
|
||||
ImVec2{style.ItemSpacing.x, style.ItemSpacing.y});
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
|
||||
ImVec2{style.FramePadding.x, style.FramePadding.y});
|
||||
PushStyleVar(ImGuiStyleVar_ItemSpacing,
|
||||
ImVec2{style.ItemSpacing.x, style.ItemSpacing.y});
|
||||
PushStyleVar(ImGuiStyleVar_FramePadding,
|
||||
ImVec2{style.FramePadding.x, style.FramePadding.y});
|
||||
|
||||
ImGui::SetNextItemWidth(input_width);
|
||||
SetNextItemWidth(input_width);
|
||||
if (InputText("", buf, IM_ARRAYSIZE(buf),
|
||||
flags)) // PushId(label) + "" gives us the expected ID
|
||||
// from outside point of view
|
||||
@@ -173,6 +173,19 @@ bool InputHexByte(const char* label, uint8_t* data, float input_width,
|
||||
ImGuiInputTextFlags_CharsHexadecimal, no_step);
|
||||
}
|
||||
|
||||
bool InputHexByte(const char* label, uint8_t* data, uint8_t max_value,
|
||||
float input_width, bool no_step) {
|
||||
if (ImGui::InputScalarLeft(label, ImGuiDataType_U8, data, &kStepOneHex,
|
||||
&kStepFastHex, "%02X", input_width,
|
||||
ImGuiInputTextFlags_CharsHexadecimal, no_step)) {
|
||||
if (*data > max_value) {
|
||||
*data = max_value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ItemLabel(absl::string_view title, ItemLabelFlags flags) {
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
const ImVec2 lineStart = ImGui::GetCursorScreenPos();
|
||||
|
||||
@@ -31,6 +31,9 @@ IMGUI_API bool InputHexWord(const char* label, int16_t* data,
|
||||
IMGUI_API bool InputHexByte(const char* label, uint8_t* data,
|
||||
float input_width = 50.f, bool no_step = false);
|
||||
|
||||
IMGUI_API bool InputHexByte(const char* label, uint8_t* data, uint8_t max_value,
|
||||
float input_width = 50.f, bool no_step = false);
|
||||
|
||||
IMGUI_API bool ListBox(const char* label, int* current_item,
|
||||
const std::vector<std::string>& items,
|
||||
int height_in_items = -1);
|
||||
|
||||
Reference in New Issue
Block a user