Cgx preview works finally
This commit is contained in:
@@ -50,8 +50,9 @@ absl::Status GraphicsEditor::Update() {
|
||||
status_ = DrawPaletteControls();
|
||||
|
||||
NEXT_COLUMN()
|
||||
core::BitmapCanvasPipeline(0x200, 0x200, 0x20, scr_loaded_, cgx_bitmap_,
|
||||
core::BitmapCanvasPipeline(0x200, 0x200, 0x20, scr_loaded_, scr_bitmap_,
|
||||
false, 0);
|
||||
status_ = DrawScrImport();
|
||||
|
||||
NEXT_COLUMN()
|
||||
if (super_donkey_) {
|
||||
@@ -105,6 +106,7 @@ absl::Status GraphicsEditor::DrawToolset() {
|
||||
|
||||
absl::Status GraphicsEditor::DrawCgxImport() {
|
||||
gui::TextWithSeparators("Cgx Import");
|
||||
ImGui::InputInt("BPP", ¤t_bpp_);
|
||||
|
||||
ImGui::InputText("##CGXFile", cgx_file_name_, sizeof(cgx_file_name_));
|
||||
ImGui::SameLine();
|
||||
@@ -116,10 +118,6 @@ absl::Status GraphicsEditor::DrawCgxImport() {
|
||||
strncpy(cgx_file_name_,
|
||||
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
||||
sizeof(cgx_file_name_));
|
||||
// status_ = temp_rom_.LoadFromFile(cgx_file_path_, /*z3_load=*/false);
|
||||
status_ = gfx::DecodeCgxFile(cgx_file_path_, cgx_data_, extra_cgx_data_,
|
||||
decoded_cgx_);
|
||||
auto cgx_header = gfx::ExtractCgxHeader(extra_cgx_data_);
|
||||
is_open_ = true;
|
||||
cgx_loaded_ = true;
|
||||
});
|
||||
@@ -127,18 +125,10 @@ absl::Status GraphicsEditor::DrawCgxImport() {
|
||||
[this]() { ImGui::SetClipboardText(cgx_file_path_); });
|
||||
|
||||
core::ButtonPipe("Decompress CGX Data", [this]() {
|
||||
/*
|
||||
cgx_viewer_.LoadCgx(temp_rom_);
|
||||
auto all_tiles_data = cgx_viewer_.GetCgxData();
|
||||
*/
|
||||
// cgx_surface_ = gfx::CreateCgxPreviewImage(current_palette_index_,
|
||||
// cgx_data_,
|
||||
// extra_cgx_data_, decoded_col_);
|
||||
// cgx_bitmap_.CreateFromSurface(cgx_surface_);
|
||||
|
||||
status_ = gfx::LoadCgx(current_bpp_, cgx_file_path_, cgx_data_,
|
||||
decoded_cgx_, extra_cgx_data_);
|
||||
cgx_bitmap_.Create(0x80, 0x200, 8, decoded_cgx_);
|
||||
if (col_file_) {
|
||||
// cgx_bitmap_.ApplyPalette(col_file_palette_);
|
||||
cgx_bitmap_.ApplyPalette(decoded_col_);
|
||||
rom_.RenderBitmap(&cgx_bitmap_);
|
||||
}
|
||||
@@ -147,6 +137,39 @@ absl::Status GraphicsEditor::DrawCgxImport() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::DrawScrImport() {
|
||||
ImGui::InputText("##ScrFile", scr_file_name_, sizeof(scr_file_name_));
|
||||
|
||||
core::FileDialogPipeline("ImportScrKey", ".SCR,.scr\0", "Open SCR", [this]() {
|
||||
strncpy(scr_file_path_,
|
||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(scr_file_path_));
|
||||
strncpy(scr_file_name_,
|
||||
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
||||
sizeof(scr_file_name_));
|
||||
is_open_ = true;
|
||||
scr_loaded_ = true;
|
||||
});
|
||||
|
||||
ImGui::InputInt("SCR Mod", &scr_mod_value_);
|
||||
|
||||
core::ButtonPipe("Load Scr Data", [this]() {
|
||||
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_);
|
||||
|
||||
scr_bitmap_.Create(0x100, 0x100, 8, decoded_scr_data_);
|
||||
if (scr_loaded_) {
|
||||
scr_bitmap_.ApplyPalette(decoded_col_);
|
||||
rom_.RenderBitmap(&scr_bitmap_);
|
||||
}
|
||||
});
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::DrawPaletteControls() {
|
||||
gui::TextWithSeparators("COL Import");
|
||||
ImGui::InputText("##ColFile", col_file_name_, sizeof(col_file_name_));
|
||||
|
||||
@@ -68,6 +68,7 @@ class GraphicsEditor {
|
||||
private:
|
||||
absl::Status DrawToolset();
|
||||
absl::Status DrawCgxImport();
|
||||
absl::Status DrawScrImport();
|
||||
absl::Status DrawFileImport();
|
||||
absl::Status DrawPaletteControls();
|
||||
absl::Status DrawClipboardImport();
|
||||
@@ -83,6 +84,10 @@ class GraphicsEditor {
|
||||
int current_palette_ = 0;
|
||||
uint64_t current_palette_index_ = 0;
|
||||
|
||||
int current_bpp_ = 0;
|
||||
|
||||
int scr_mod_value_ = 0;
|
||||
|
||||
uint64_t num_sheets_to_load_ = 1;
|
||||
|
||||
uint64_t bin_size_ = 0;
|
||||
@@ -106,6 +111,9 @@ class GraphicsEditor {
|
||||
char cgx_file_path_[256] = "";
|
||||
char cgx_file_name_[256] = "";
|
||||
|
||||
char scr_file_path_[256] = "";
|
||||
char scr_file_name_[256] = "";
|
||||
|
||||
ROM rom_;
|
||||
ROM temp_rom_;
|
||||
Bytes import_data_;
|
||||
@@ -116,7 +124,8 @@ class GraphicsEditor {
|
||||
std::vector<uint8_t> extra_cgx_data_;
|
||||
std::vector<SDL_Color> decoded_col_;
|
||||
|
||||
SDL_Surface* cgx_surface_;
|
||||
std::vector<uint8_t> scr_data_;
|
||||
std::vector<uint8_t> decoded_scr_data_;
|
||||
|
||||
MemoryEditor cgx_memory_editor_;
|
||||
MemoryEditor col_memory_editor_;
|
||||
@@ -124,6 +133,7 @@ class GraphicsEditor {
|
||||
PaletteEditor palette_editor_;
|
||||
|
||||
gfx::Bitmap cgx_bitmap_;
|
||||
gfx::Bitmap scr_bitmap_;
|
||||
|
||||
gfx::Bitmap bitmap_;
|
||||
gui::Canvas import_canvas_;
|
||||
|
||||
Reference in New Issue
Block a user