rename ApplyPalette with SetPalette
This commit is contained in:
@@ -123,7 +123,7 @@ absl::Status DungeonEditor::RefreshGraphics() {
|
||||
std::for_each_n(
|
||||
rooms_[current_room_id_].blocks().begin(), 8,
|
||||
[this](int block) -> absl::Status {
|
||||
RETURN_IF_ERROR(graphics_bin_[block].ApplyPaletteWithTransparent(
|
||||
RETURN_IF_ERROR(graphics_bin_[block].SetPaletteWithTransparent(
|
||||
current_palette_group_[current_palette_id_], 0));
|
||||
Renderer::GetInstance().UpdateBitmap(&graphics_bin_[block]);
|
||||
return absl::OkStatus();
|
||||
@@ -133,7 +133,7 @@ absl::Status DungeonEditor::RefreshGraphics() {
|
||||
std::for_each_n(
|
||||
rooms_[current_room_id_].blocks().begin() + 8, 8,
|
||||
[this, &sprites_aux1_pal_group](int block) -> absl::Status {
|
||||
RETURN_IF_ERROR(graphics_bin_[block].ApplyPaletteWithTransparent(
|
||||
RETURN_IF_ERROR(graphics_bin_[block].SetPaletteWithTransparent(
|
||||
sprites_aux1_pal_group[current_palette_id_], 0));
|
||||
Renderer::GetInstance().UpdateBitmap(&graphics_bin_[block]);
|
||||
return absl::OkStatus();
|
||||
|
||||
@@ -45,7 +45,8 @@ absl::Status GraphicsEditor::Update() {
|
||||
status_ = UpdateGfxEdit();
|
||||
TAB_ITEM("Sheet Browser")
|
||||
if (asset_browser_.Initialized == false) {
|
||||
asset_browser_.Initialize(GraphicsSheetManager::GetInstance().gfx_sheets());
|
||||
asset_browser_.Initialize(
|
||||
GraphicsSheetManager::GetInstance().gfx_sheets());
|
||||
}
|
||||
asset_browser_.Draw(GraphicsSheetManager::GetInstance().gfx_sheets());
|
||||
END_TAB_ITEM()
|
||||
@@ -115,8 +116,10 @@ void GraphicsEditor::DrawGfxEditToolset() {
|
||||
|
||||
TableNextColumn();
|
||||
if (Button(ICON_MD_CONTENT_COPY)) {
|
||||
std::vector<uint8_t> png_data =
|
||||
GraphicsSheetManager::GetInstance().gfx_sheets().at(current_sheet_).GetPngData();
|
||||
std::vector<uint8_t> png_data = GraphicsSheetManager::GetInstance()
|
||||
.gfx_sheets()
|
||||
.at(current_sheet_)
|
||||
.GetPngData();
|
||||
core::CopyImageToClipboard(png_data);
|
||||
}
|
||||
HOVER_HINT("Copy to Clipboard");
|
||||
@@ -127,11 +130,13 @@ void GraphicsEditor::DrawGfxEditToolset() {
|
||||
int width, height;
|
||||
core::GetImageFromClipboard(png_data, width, height);
|
||||
if (png_data.size() > 0) {
|
||||
GraphicsSheetManager::GetInstance().mutable_gfx_sheets()
|
||||
GraphicsSheetManager::GetInstance()
|
||||
.mutable_gfx_sheets()
|
||||
->at(current_sheet_)
|
||||
.Create(width, height, 8, png_data);
|
||||
Renderer::GetInstance().UpdateBitmap(
|
||||
&GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(current_sheet_));
|
||||
&GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(
|
||||
current_sheet_));
|
||||
}
|
||||
}
|
||||
HOVER_HINT("Paste from Clipboard");
|
||||
@@ -151,7 +156,8 @@ void GraphicsEditor::DrawGfxEditToolset() {
|
||||
}
|
||||
|
||||
TableNextColumn();
|
||||
auto bitmap = GraphicsSheetManager::GetInstance().gfx_sheets()[current_sheet_];
|
||||
auto bitmap =
|
||||
GraphicsSheetManager::GetInstance().gfx_sheets()[current_sheet_];
|
||||
auto palette = bitmap.palette();
|
||||
for (int i = 0; i < palette.size(); i++) {
|
||||
ImGui::SameLine();
|
||||
@@ -279,7 +285,9 @@ absl::Status GraphicsEditor::UpdateGfxTabView() {
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar |
|
||||
ImGuiWindowFlags_AlwaysHorizontalScrollbar);
|
||||
|
||||
gfx::Bitmap& current_bitmap = GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(sheet_id);
|
||||
gfx::Bitmap& current_bitmap =
|
||||
GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(
|
||||
sheet_id);
|
||||
|
||||
auto draw_tile_event = [&]() {
|
||||
current_sheet_canvas_.DrawTileOnBitmap(tile_size_, ¤t_bitmap,
|
||||
@@ -288,8 +296,9 @@ absl::Status GraphicsEditor::UpdateGfxTabView() {
|
||||
};
|
||||
|
||||
current_sheet_canvas_.UpdateColorPainter(
|
||||
GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(sheet_id), current_color_,
|
||||
draw_tile_event, tile_size_, current_scale_);
|
||||
GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(
|
||||
sheet_id),
|
||||
current_color_, draw_tile_event, tile_size_, current_scale_);
|
||||
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
@@ -321,7 +330,8 @@ absl::Status GraphicsEditor::UpdateGfxTabView() {
|
||||
current_sheet_ = id;
|
||||
// ImVec2(0x100, 0x40),
|
||||
current_sheet_canvas_.UpdateColorPainter(
|
||||
GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(id), current_color_,
|
||||
GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->at(id),
|
||||
current_color_,
|
||||
[&]() {
|
||||
|
||||
},
|
||||
@@ -358,11 +368,13 @@ absl::Status GraphicsEditor::UpdatePaletteColumn() {
|
||||
|
||||
if (refresh_graphics_ && !open_sheets_.empty()) {
|
||||
RETURN_IF_ERROR(
|
||||
GraphicsSheetManager::GetInstance().mutable_gfx_sheets()
|
||||
GraphicsSheetManager::GetInstance()
|
||||
.mutable_gfx_sheets()
|
||||
->data()[current_sheet_]
|
||||
.ApplyPaletteWithTransparent(palette, edit_palette_sub_index_));
|
||||
Renderer::GetInstance().UpdateBitmap(
|
||||
&GraphicsSheetManager::GetInstance().mutable_gfx_sheets()->data()[current_sheet_]);
|
||||
.SetPaletteWithTransparent(palette, edit_palette_sub_index_));
|
||||
Renderer::GetInstance().UpdateBitmap(&GraphicsSheetManager::GetInstance()
|
||||
.mutable_gfx_sheets()
|
||||
->data()[current_sheet_]);
|
||||
refresh_graphics_ = false;
|
||||
}
|
||||
}
|
||||
@@ -458,7 +470,7 @@ absl::Status GraphicsEditor::UpdateScadView() {
|
||||
// TODO: Implement the Super Donkey 1 graphics decompression
|
||||
// if (refresh_graphics_) {
|
||||
// for (int i = 0; i < kNumGfxSheets; i++) {
|
||||
// status_ = graphics_bin_[i].ApplyPalette(
|
||||
// status_ = graphics_bin_[i].SetPalette(
|
||||
// col_file_palette_group_[current_palette_index_]);
|
||||
// Renderer::GetInstance().UpdateBitmap(&graphics_bin_[i]);
|
||||
// }
|
||||
@@ -530,11 +542,11 @@ absl::Status GraphicsEditor::DrawCgxImport() {
|
||||
|
||||
if (ImGui::Button("Load CGX Data")) {
|
||||
status_ = gfx::LoadCgx(current_bpp_, cgx_file_path_, cgx_data_,
|
||||
decoded_cgx_, extra_cgx_data_);
|
||||
decoded_cgx_, extra_cgx_data_);
|
||||
|
||||
cgx_bitmap_.Create(0x80, 0x200, 8, decoded_cgx_);
|
||||
if (col_file_) {
|
||||
cgx_bitmap_.ApplyPalette(decoded_col_);
|
||||
cgx_bitmap_.SetPalette(decoded_col_);
|
||||
Renderer::GetInstance().RenderBitmap(&cgx_bitmap_);
|
||||
}
|
||||
}
|
||||
@@ -556,16 +568,15 @@ absl::Status GraphicsEditor::DrawScrImport() {
|
||||
InputInt("SCR Mod", &scr_mod_value_);
|
||||
|
||||
if (ImGui::Button("Load Scr Data")) {
|
||||
status_ =
|
||||
gfx::LoadScr(scr_file_path_, scr_mod_value_, scr_data_);
|
||||
status_ = gfx::LoadScr(scr_file_path_, scr_mod_value_, scr_data_);
|
||||
|
||||
decoded_scr_data_.resize(0x100 * 0x100);
|
||||
status_ = gfx::DrawScrWithCgx(current_bpp_, scr_data_,
|
||||
decoded_scr_data_, decoded_cgx_);
|
||||
status_ = gfx::DrawScrWithCgx(current_bpp_, scr_data_, decoded_scr_data_,
|
||||
decoded_cgx_);
|
||||
|
||||
scr_bitmap_.Create(0x100, 0x100, 8, decoded_scr_data_);
|
||||
if (scr_loaded_) {
|
||||
scr_bitmap_.ApplyPalette(decoded_col_);
|
||||
scr_bitmap_.SetPalette(decoded_col_);
|
||||
Renderer::GetInstance().RenderBitmap(&scr_bitmap_);
|
||||
}
|
||||
}
|
||||
@@ -762,9 +773,9 @@ absl::Status GraphicsEditor::DecompressImportData(int size) {
|
||||
auto palette_group = rom()->palette_group().overworld_animated;
|
||||
z3_rom_palette_ = palette_group[current_palette_];
|
||||
if (col_file_) {
|
||||
status_ = bin_bitmap_.ApplyPalette(col_file_palette_);
|
||||
status_ = bin_bitmap_.SetPalette(col_file_palette_);
|
||||
} else {
|
||||
status_ = bin_bitmap_.ApplyPalette(z3_rom_palette_);
|
||||
status_ = bin_bitmap_.SetPalette(z3_rom_palette_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -786,7 +797,7 @@ absl::Status GraphicsEditor::DecompressSuperDonkey() {
|
||||
gfx_sheets_[i] = gfx::Bitmap(gfx::kTilesheetWidth, gfx::kTilesheetHeight,
|
||||
gfx::kTilesheetDepth, converted_sheet);
|
||||
if (col_file_) {
|
||||
status_ = gfx_sheets_[i].ApplyPalette(
|
||||
status_ = gfx_sheets_[i].SetPalette(
|
||||
col_file_palette_group_[current_palette_index_]);
|
||||
} else {
|
||||
// ROM palette
|
||||
@@ -794,7 +805,7 @@ absl::Status GraphicsEditor::DecompressSuperDonkey() {
|
||||
auto palette_group = rom()->palette_group().get_group(
|
||||
kPaletteGroupAddressesKeys[current_palette_]);
|
||||
z3_rom_palette_ = *palette_group->mutable_palette(current_palette_index_);
|
||||
status_ = gfx_sheets_[i].ApplyPalette(z3_rom_palette_);
|
||||
status_ = gfx_sheets_[i].SetPalette(z3_rom_palette_);
|
||||
}
|
||||
|
||||
Renderer::GetInstance().RenderBitmap(&gfx_sheets_[i]);
|
||||
@@ -811,14 +822,14 @@ absl::Status GraphicsEditor::DecompressSuperDonkey() {
|
||||
gfx_sheets_[i] = gfx::Bitmap(gfx::kTilesheetWidth, gfx::kTilesheetHeight,
|
||||
gfx::kTilesheetDepth, converted_sheet);
|
||||
if (col_file_) {
|
||||
status_ = gfx_sheets_[i].ApplyPalette(
|
||||
status_ = gfx_sheets_[i].SetPalette(
|
||||
col_file_palette_group_[current_palette_index_]);
|
||||
} else {
|
||||
// ROM palette
|
||||
auto palette_group = rom()->palette_group().get_group(
|
||||
kPaletteGroupAddressesKeys[current_palette_]);
|
||||
z3_rom_palette_ = *palette_group->mutable_palette(current_palette_index_);
|
||||
status_ = gfx_sheets_[i].ApplyPalette(z3_rom_palette_);
|
||||
status_ = gfx_sheets_[i].SetPalette(z3_rom_palette_);
|
||||
}
|
||||
|
||||
Renderer::GetInstance().RenderBitmap(&gfx_sheets_[i]);
|
||||
|
||||
@@ -123,11 +123,10 @@ absl::Status ScreenEditor::LoadDungeonMaps() {
|
||||
rom()->ReadWord(zelda3::kDungeonMapRoomsPtr + (d * 2)));
|
||||
ASSIGN_OR_RETURN(int ptr_gfx,
|
||||
rom()->ReadWord(zelda3::kDungeonMapGfxPtr + (d * 2)));
|
||||
ptr |= 0x0A0000; // Add bank to the short ptr
|
||||
ptr_gfx |= 0x0A0000; // Add bank to the short ptr
|
||||
int pc_ptr = SnesToPc(ptr); // Contains data for the next 25 rooms
|
||||
int pc_ptr_gfx =
|
||||
SnesToPc(ptr_gfx); // Contains data for the next 25 rooms
|
||||
ptr |= 0x0A0000; // Add bank to the short ptr
|
||||
ptr_gfx |= 0x0A0000; // Add bank to the short ptr
|
||||
int pc_ptr = SnesToPc(ptr); // Contains data for the next 25 rooms
|
||||
int pc_ptr_gfx = SnesToPc(ptr_gfx); // Contains data for the next 25 rooms
|
||||
|
||||
ASSIGN_OR_RETURN(uint16_t boss_room_d,
|
||||
rom()->ReadWord(zelda3::kDungeonMapBossRooms + (d * 2)));
|
||||
@@ -230,7 +229,7 @@ absl::Status ScreenEditor::LoadDungeonMapTile16(
|
||||
tile16_sheet_.ComposeTile16(gfx_data, t1, t2, t3, t4, sheet_offset);
|
||||
}
|
||||
|
||||
RETURN_IF_ERROR(tile16_sheet_.mutable_bitmap()->ApplyPalette(
|
||||
RETURN_IF_ERROR(tile16_sheet_.mutable_bitmap()->SetPalette(
|
||||
*rom()->mutable_dungeon_palette(3)));
|
||||
Renderer::GetInstance().RenderBitmap(&*tile16_sheet_.mutable_bitmap().get());
|
||||
|
||||
@@ -238,7 +237,7 @@ absl::Status ScreenEditor::LoadDungeonMapTile16(
|
||||
auto tile = tile16_sheet_.GetTile16(i);
|
||||
tile16_individual_[i] = tile;
|
||||
RETURN_IF_ERROR(
|
||||
tile16_individual_[i].ApplyPalette(*rom()->mutable_dungeon_palette(3)));
|
||||
tile16_individual_[i].SetPalette(*rom()->mutable_dungeon_palette(3)));
|
||||
Renderer::GetInstance().RenderBitmap(&tile16_individual_[i]);
|
||||
}
|
||||
|
||||
@@ -424,7 +423,7 @@ void ScreenEditor::DrawDungeonMapsRoomGfx() {
|
||||
current_tile16_info.tiles[3], selected_tile16_, 212);
|
||||
tile16_individual_[selected_tile16_] =
|
||||
tile16_sheet_.GetTile16(selected_tile16_);
|
||||
RETURN_VOID_IF_ERROR(tile16_individual_[selected_tile16_].ApplyPalette(
|
||||
RETURN_VOID_IF_ERROR(tile16_individual_[selected_tile16_].SetPalette(
|
||||
*rom()->mutable_dungeon_palette(3)));
|
||||
Renderer::GetInstance().RenderBitmap(
|
||||
&tile16_individual_[selected_tile16_]);
|
||||
@@ -455,7 +454,7 @@ void ScreenEditor::DrawDungeonMapsEditor() {
|
||||
int y = (j / 8) * 8;
|
||||
sheets_[i].Get8x8Tile(tile_index, 0, 0, tile_data, tile_data_offset);
|
||||
tile8_individual_.emplace_back(gfx::Bitmap(8, 8, 4, tile_data));
|
||||
RETURN_VOID_IF_ERROR(tile8_individual_.back().ApplyPalette(
|
||||
RETURN_VOID_IF_ERROR(tile8_individual_.back().SetPalette(
|
||||
*rom()->mutable_dungeon_palette(3)));
|
||||
Renderer::GetInstance().RenderBitmap(&tile8_individual_.back());
|
||||
}
|
||||
@@ -556,7 +555,7 @@ void ScreenEditor::LoadBinaryGfx() {
|
||||
gfx_sheets.emplace_back(converted_bin.begin() + (i * 0x1000),
|
||||
converted_bin.begin() + ((i + 1) * 0x1000));
|
||||
sheets_.emplace(i, gfx::Bitmap(128, 32, 8, gfx_sheets[i]));
|
||||
status_ = sheets_[i].ApplyPalette(*rom()->mutable_dungeon_palette(3));
|
||||
status_ = sheets_[i].SetPalette(*rom()->mutable_dungeon_palette(3));
|
||||
if (status_.ok()) {
|
||||
Renderer::GetInstance().RenderBitmap(&sheets_[i]);
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ absl::Status OverworldEditor::Update() {
|
||||
status_ = absl::OkStatus();
|
||||
if (rom_.is_loaded() && !all_gfx_loaded_) {
|
||||
RETURN_IF_ERROR(
|
||||
tile16_editor_.InitBlockset(tile16_blockset_bmp_, current_gfx_bmp_,
|
||||
*overworld_.mutable_all_tiles_types()));
|
||||
tile16_editor_.Initialize(tile16_blockset_bmp_, current_gfx_bmp_,
|
||||
*overworld_.mutable_all_tiles_types()));
|
||||
ASSIGN_OR_RETURN(entrance_tiletypes_, zelda3::LoadEntranceTileTypes(rom_));
|
||||
all_gfx_loaded_ = true;
|
||||
}
|
||||
@@ -1059,7 +1059,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_IF_ERROR(tile16_individual_[i].ApplyPalette(palette_));
|
||||
RETURN_IF_ERROR(tile16_individual_[i].SetPalette(palette_));
|
||||
Renderer::GetInstance().RenderBitmap(&tile16_individual_[i]);
|
||||
}
|
||||
|
||||
@@ -1100,7 +1100,7 @@ absl::Status OverworldEditor::LoadSpriteGraphics() {
|
||||
}
|
||||
sprite_previews_[sprite.id()].Create(width, height, depth,
|
||||
*sprite.preview_graphics());
|
||||
RETURN_IF_ERROR(sprite_previews_[sprite.id()].ApplyPalette(palette_));
|
||||
RETURN_IF_ERROR(sprite_previews_[sprite.id()].SetPalette(palette_));
|
||||
Renderer::GetInstance().RenderBitmap(&(sprite_previews_[sprite.id()]));
|
||||
}
|
||||
return absl::OkStatus();
|
||||
@@ -1169,12 +1169,11 @@ absl::Status OverworldEditor::RefreshMapPalette() {
|
||||
if (i >= 2) sibling_index += 6;
|
||||
RETURN_IF_ERROR(
|
||||
overworld_.mutable_overworld_map(sibling_index)->LoadPalette());
|
||||
RETURN_IF_ERROR(
|
||||
maps_bmp_[sibling_index].ApplyPalette(current_map_palette));
|
||||
RETURN_IF_ERROR(maps_bmp_[sibling_index].SetPalette(current_map_palette));
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_IF_ERROR(maps_bmp_[current_map_].ApplyPalette(current_map_palette));
|
||||
RETURN_IF_ERROR(maps_bmp_[current_map_].SetPalette(current_map_palette));
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
@@ -1210,7 +1209,7 @@ absl::Status OverworldEditor::RefreshTile16Blockset() {
|
||||
palette_ = overworld_.current_area_palette();
|
||||
// Create the tile16 blockset image
|
||||
Renderer::GetInstance().UpdateBitmap(&tile16_blockset_bmp_);
|
||||
RETURN_IF_ERROR(tile16_blockset_bmp_.ApplyPalette(palette_));
|
||||
RETURN_IF_ERROR(tile16_blockset_bmp_.SetPalette(palette_));
|
||||
|
||||
// Copy the tile16 data into individual tiles.
|
||||
const auto tile16_data = overworld_.tile16_blockset_data();
|
||||
@@ -1232,7 +1231,7 @@ absl::Status OverworldEditor::RefreshTile16Blockset() {
|
||||
}
|
||||
}
|
||||
tile16_individual_[index].set_data(tile_data);
|
||||
RETURN_IF_ERROR(tile16_individual_[index].ApplyPalette(palette_));
|
||||
RETURN_IF_ERROR(tile16_individual_[index].SetPalette(palette_));
|
||||
return absl::OkStatus();
|
||||
},
|
||||
i));
|
||||
|
||||
Reference in New Issue
Block a user