housekeeping
This commit is contained in:
@@ -119,10 +119,10 @@ void MasterEditor::DrawAboutPopup() {
|
||||
if (about_) ImGui::OpenPopup("About");
|
||||
if (ImGui::BeginPopupModal("About", nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::Text("Yet Another Zelda3 Editor - v0.01");
|
||||
ImGui::Text("Yet Another Zelda3 Editor - v0.02");
|
||||
ImGui::Text("Written by: scawful");
|
||||
ImGui::Spacing();
|
||||
ImGui::Text("Special Thanks: Zarby89");
|
||||
ImGui::Text("Special Thanks: Zarby89, JaredBrian");
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Close", ImVec2(200, 0))) {
|
||||
|
||||
@@ -120,63 +120,6 @@ void Bitmap::ApplyPalette(const SNESPalette &palette) {
|
||||
}
|
||||
}
|
||||
|
||||
void Bitmap::SetPaletteColor(int id, gfx::SNESColor color) {
|
||||
surface_->format->palette->colors[id].r = color.rgb.x;
|
||||
surface_->format->palette->colors[id].g = color.rgb.y;
|
||||
surface_->format->palette->colors[id].b = color.rgb.z;
|
||||
}
|
||||
|
||||
// Creates a vector of bitmaps which are individual 8x8 tiles.
|
||||
absl::StatusOr<std::vector<Bitmap>> Bitmap::CreateTiles() {
|
||||
std::vector<Bitmap> tiles;
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
Bitmap bmp;
|
||||
bmp.Create(8, 8, 8, 32);
|
||||
auto surface = bmp.GetSurface();
|
||||
SDL_Rect src_rect = {i, j, 8, 8};
|
||||
if (SDL_BlitSurface(surface_.get(), &src_rect, surface, nullptr) != 0)
|
||||
return absl::InternalError(
|
||||
absl::StrCat("Failed to blit surface: ", SDL_GetError()));
|
||||
tiles.push_back(bmp);
|
||||
}
|
||||
}
|
||||
return tiles;
|
||||
}
|
||||
|
||||
// Converts a vector of 8x8 tiles into a tilesheet.
|
||||
absl::Status Bitmap::CreateFromTiles(const std::vector<Bitmap> &tiles) {
|
||||
if (tiles.empty())
|
||||
return absl::InvalidArgumentError(
|
||||
"Failed to create bitmap: `tiles` is empty.");
|
||||
|
||||
SDL_Rect tile_rect = {0, 0, 8, 8};
|
||||
SDL_Rect dest_rect = {0, 0, 8, 8};
|
||||
for (const auto &tile : tiles) {
|
||||
auto src = tile.GetSurface();
|
||||
if (SDL_BlitSurface(src, &tile_rect, surface_.get(), &dest_rect) != 0)
|
||||
return absl::InternalError(
|
||||
absl::StrCat("Failed to blit surface: ", SDL_GetError()));
|
||||
|
||||
dest_rect.x++;
|
||||
if (dest_rect.x == 15) {
|
||||
dest_rect.x = 0;
|
||||
dest_rect.y++;
|
||||
}
|
||||
}
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status Bitmap::WritePixel(int pos, uchar pixel) {
|
||||
if (!surface_) {
|
||||
return absl::InternalError("Surface not loaded");
|
||||
}
|
||||
auto pixels = (char *)surface_->pixels;
|
||||
pixels[pos] = pixel;
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
|
||||
@@ -31,12 +31,6 @@ class Bitmap {
|
||||
void CreateTexture(std::shared_ptr<SDL_Renderer> renderer);
|
||||
|
||||
void ApplyPalette(const SNESPalette &palette);
|
||||
void SetPaletteColor(int id, gfx::SNESColor color);
|
||||
|
||||
absl::StatusOr<std::vector<Bitmap>> CreateTiles();
|
||||
absl::Status CreateFromTiles(const std::vector<Bitmap> &tiles);
|
||||
|
||||
absl::Status WritePixel(int pos, uchar pixel);
|
||||
|
||||
int GetWidth() const { return width_; }
|
||||
int GetHeight() const { return height_; }
|
||||
|
||||
@@ -46,7 +46,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current,
|
||||
int k = 0;
|
||||
for (int y = 2; y < 7; y++) {
|
||||
for (int x = 1; x < 8; x++) {
|
||||
new_palette[x + (16 * y)] = main[k++];
|
||||
new_palette[x + (16 * y)] = main[k];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +62,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current,
|
||||
k = 0;
|
||||
for (int y = 2; y < 5; y++) {
|
||||
for (int x = 9; x < 16; x++) {
|
||||
new_palette[x + (16 * y)] = aux1[k++];
|
||||
new_palette[x + (16 * y)] = aux1[k];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +71,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current,
|
||||
k = 0;
|
||||
for (int y = 5; y < 8; y++) {
|
||||
for (int x = 9; x < 16; x++) {
|
||||
new_palette[x + (16 * y)] = aux2[k++];
|
||||
new_palette[x + (16 * y)] = aux2[k];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +91,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current,
|
||||
k = 0;
|
||||
for (int y = 8; y < 9; y++) {
|
||||
for (int x = 1; x < 8; x++) {
|
||||
new_palette[x + (16 * y)] = rom.GetPaletteGroup("sprites_aux1")[1][k++];
|
||||
new_palette[x + (16 * y)] = rom.GetPaletteGroup("sprites_aux1")[1][k];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +100,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current,
|
||||
k = 0;
|
||||
for (int y = 8; y < 9; y++) {
|
||||
for (int x = 9; x < 16; x++) {
|
||||
new_palette[x + (16 * y)] = rom.GetPaletteGroup("sprites_aux3")[0][k++];
|
||||
new_palette[x + (16 * y)] = rom.GetPaletteGroup("sprites_aux3")[0][k];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +109,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current,
|
||||
k = 0;
|
||||
for (int y = 9; y < 13; y++) {
|
||||
for (int x = 1; x < 16; x++) {
|
||||
new_palette[x + (16 * y)] = rom.GetPaletteGroup("global_sprites")[0][k++];
|
||||
new_palette[x + (16 * y)] = rom.GetPaletteGroup("global_sprites")[0][k];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +118,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current,
|
||||
k = 0;
|
||||
for (int y = 13; y < 14; y++) {
|
||||
for (int x = 1; x < 8; x++) {
|
||||
new_palette[x + (16 * y)] = spr[k++];
|
||||
new_palette[x + (16 * y)] = spr[k];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +127,8 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current,
|
||||
k = 0;
|
||||
for (int y = 14; y < 15; y++) {
|
||||
for (int x = 1; x < 8; x++) {
|
||||
new_palette[x + (16 * y)] = spr2[k++];
|
||||
new_palette[x + (16 * y)] = spr2[k];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,20 +136,15 @@ void SetColorsPalette(ROM& rom, int index, gfx::SNESPalette& current,
|
||||
k = 0;
|
||||
for (int y = 15; y < 16; y++) {
|
||||
for (int x = 1; x < 16; x++) {
|
||||
new_palette[x + (16 * y)] = rom.GetPaletteGroup("armors")[0][k++];
|
||||
new_palette[x + (16 * y)] = rom.GetPaletteGroup("armors")[0][k];
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
current.Create(new_palette);
|
||||
// ColorPalette pal = GFX.editort16Bitmap.Palette;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
current[(i / 16) * 16].setTransparent(true);
|
||||
}
|
||||
|
||||
// GFX.mapgfx16Bitmap.Palette = pal;
|
||||
// GFX.mapblockset16Bitmap.Palette = pal;
|
||||
|
||||
// gfxBitmap.Palette = pal;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user