// ----------------------------------------------------------------------------- // Handles the action [id]. // Returns true if the action was handled, false otherwise // ----------------------------------------------------------------------------- bool TextEntryPanel::handleAction(string id) { // Don't handle actions if hidden if (!isActivePanel()) return false; // Jump To Line if (id == "ptxt_jump_to_line") text_area_->jumpToLine(); // Find+Replace else if (id == "ptxt_find_replace") text_area_->showFindReplacePanel(); // Word Wrapping toggle else if (id == "ptxt_wrap") { SAction* action = SAction::fromId("ptxt_wrap"); bool m = isModified(); if (action->isChecked()) text_area_->SetWrapMode(wxSTC_WRAP_WORD); else text_area_->SetWrapMode(wxSTC_WRAP_NONE); setModified(m); } // Fold All else if (id == "ptxt_fold_foldall") text_area_->foldAll(true); // Unfold All else if (id == "ptxt_fold_unfoldall") text_area_->foldAll(false); // compileACS else if (id == "arch_scripts_compileacs") EntryOperations::compileACS(entry_, false, nullptr, nullptr); else if (id == "arch_scripts_compilehacs") EntryOperations::compileACS(entry_, true, nullptr, nullptr); // Not handled else return false; return true; }
/* SwitchesEntryPanel::handleAction * Handles the action [id]. Returns true if the action was handled, * false otherwise *******************************************************************/ bool SwitchesEntryPanel::handleAction(string id) { // Don't handle actions if hidden if (!isActivePanel()) return false; // We're only interested in "anim_" actions if (!id.StartsWith("swch_")) return false; if (id == "swch_new") { add(); } else if (id == "swch_delete") { remove(); } else if (id == "swch_up") { moveUp(); } else if (id == "swch_down") { moveDown(); } // Unknown action else return false; // Action handled return true; }
/* GfxEntryPanel::handleAction * Handles the action [id]. Returns true if the action was handled, * false otherwise *******************************************************************/ bool GfxEntryPanel::handleAction(string id) { // Don't handle actions if hidden if (!isActivePanel()) return false; // We're only interested in "pgfx_" actions if (!id.StartsWith("pgfx_")) return false; // Mirror if (id == "pgfx_mirror") { // Mirror X getImage()->mirror(false); // Update UI gfx_canvas->updateImageTexture(); gfx_canvas->Refresh(); // Update variables image_data_modified = true; setModified(); } // Flip else if (id == "pgfx_flip") { // Mirror Y getImage()->mirror(true); // Update UI gfx_canvas->updateImageTexture(); gfx_canvas->Refresh(); // Update variables image_data_modified = true; setModified(); } // Rotate else if (id == "pgfx_rotate") { // Prompt for rotation angle string angles[] = { "90", "180", "270" }; int choice = wxGetSingleChoiceIndex("Select rotation angle", "Rotate", 3, angles, 0); // Rotate image switch (choice) { case 0: getImage()->rotate(90); break; case 1: getImage()->rotate(180); break; case 2: getImage()->rotate(270); break; default: break; } // Update UI gfx_canvas->updateImageTexture(); gfx_canvas->Refresh(); // Update variables image_data_modified = true; setModified(); } // Translate else if (id == "pgfx_translate") { // Create translation editor dialog Palette8bit* pal = theMainWindow->getPaletteChooser()->getSelectedPalette(); TranslationEditorDialog ted(theMainWindow, pal, " Colour Remap", gfx_canvas->getImage()); // Create translation to edit ted.openTranslation(prev_translation); // Show the dialog if (ted.ShowModal() == wxID_OK) { // Apply translation to image getImage()->applyTranslation(&ted.getTranslation(), pal); // Update UI gfx_canvas->updateImageTexture(); gfx_canvas->Refresh(); // Update variables image_data_modified = true; gfx_canvas->updateImageTexture(); setModified(); prev_translation.copy(ted.getTranslation()); } } // Colourise else if (id == "pgfx_colourise") { Palette8bit* pal = theMainWindow->getPaletteChooser()->getSelectedPalette(); GfxColouriseDialog gcd(theMainWindow, entry, pal); gcd.setColour(last_colour); // Show colourise dialog if (gcd.ShowModal() == wxID_OK) { // Colourise image getImage()->colourise(gcd.getColour(), pal); // Update UI gfx_canvas->updateImageTexture(); gfx_canvas->Refresh(); // Update variables image_data_modified = true; Refresh(); setModified(); } rgba_t gcdcol = gcd.getColour(); last_colour = S_FMT("RGB(%d, %d, %d)", gcdcol.r, gcdcol.g, gcdcol.b); } // Tint else if (id == "pgfx_tint") { Palette8bit* pal = theMainWindow->getPaletteChooser()->getSelectedPalette(); GfxTintDialog gtd(theMainWindow, entry, pal); gtd.setValues(last_tint_colour, last_tint_amount); // Show tint dialog if (gtd.ShowModal() == wxID_OK) { // Tint image getImage()->tint(gtd.getColour(), gtd.getAmount(), pal); // Update UI gfx_canvas->updateImageTexture(); gfx_canvas->Refresh(); // Update variables image_data_modified = true; Refresh(); setModified(); } rgba_t gtdcol = gtd.getColour(); last_tint_colour = S_FMT("RGB(%d, %d, %d)", gtdcol.r, gtdcol.g, gtdcol.b); last_tint_amount = (int)(gtd.getAmount() * 100.0); } // Crop else if (id == "pgfx_crop") { Palette8bit* pal = theMainWindow->getPaletteChooser()->getSelectedPalette(); GfxCropDialog gcd(theMainWindow, entry, pal); // Show crop dialog if (gcd.ShowModal() == wxID_OK) { // stuff } } // alPh/tRNS else if (id == "pgfx_alph" || id == "pgfx_trns") { setModified(); Refresh(); } // Optimize PNG else if (id == "pgfx_pngopt") { // This is a special case. If we set the entry as modified, SLADE will prompt // to save it, rewriting the entry and cancelling the optimization done... if (EntryOperations::optimizePNG(entry)) setModified(false); else wxMessageBox("Warning: Couldn't optimize this image, check console log for info", "Warning", wxOK|wxCENTRE|wxICON_WARNING); Refresh(); } // Extract all else if (id == "pgfx_extract") { extractAll(); } // Convert else if (id == "pgfx_convert") { GfxConvDialog gcd(theMainWindow); gcd.CenterOnParent(); gcd.openEntry(entry); gcd.ShowModal(); if (gcd.itemModified(0)) { // Get image and conversion info SImage* image = gcd.getItemImage(0); SIFormat* format = gcd.getItemFormat(0); // Write converted image back to entry format->saveImage(*image, entry_data, gcd.getItemPalette(0)); // This makes the "save" button (and the setModified stuff) redundant and confusing! // The alternative is to save to entry effectively (uncomment the importMemChunk line) // but remove the setModified and image_data_modified lines, and add a call to refresh // to get the PNG tRNS status back in sync. //entry->importMemChunk(entry_data); image_data_modified = true; setModified(); // Fix tRNS status if we converted to paletted PNG int MENU_GFXEP_PNGOPT = theApp->getAction("pgfx_pngopt")->getWxId(); int MENU_GFXEP_ALPH = theApp->getAction("pgfx_alph")->getWxId(); int MENU_GFXEP_TRNS = theApp->getAction("pgfx_trns")->getWxId(); int MENU_ARCHGFX_EXPORTPNG = theApp->getAction("arch_gfx_exportpng")->getWxId(); if (format->getName() == "PNG") { ArchiveEntry temp; temp.importMemChunk(entry_data); temp.setType(EntryType::getType("png")); menu_custom->Enable(MENU_GFXEP_ALPH, true); menu_custom->Enable(MENU_GFXEP_TRNS, true); menu_custom->Check(MENU_GFXEP_TRNS, EntryOperations::gettRNSChunk(&temp)); menu_custom->Enable(MENU_ARCHGFX_EXPORTPNG, false); menu_custom->Enable(MENU_GFXEP_PNGOPT, true); toolbar->enableGroup("PNG", true); } else { menu_custom->Enable(MENU_GFXEP_ALPH, false); menu_custom->Enable(MENU_GFXEP_TRNS, false); menu_custom->Enable(MENU_ARCHGFX_EXPORTPNG, true); menu_custom->Enable(MENU_GFXEP_PNGOPT, false); toolbar->enableGroup("PNG", false); } // Refresh getImage()->open(entry_data, 0, format->getId()); gfx_canvas->Refresh(); } } // Unknown action else return false; // Action handled return true; }
/* PaletteEntryPanel::handleAction * Handles the action [id]. Returns true if the action was handled, * false otherwise *******************************************************************/ bool PaletteEntryPanel::handleAction(string id) { // Ignore if hidden if (!isActivePanel()) return false; // Only interested in "ppal_" events if (!id.StartsWith("ppal_")) return false; // Add to custom palettes if (id == "ppal_addcustom") { addCustomPalette(); return true; } // Test palette else if (id == "ppal_test") { testPalette(); return true; } // Export As else if (id == "ppal_exportas") { exportAs(); return true; } // Import From else if (id == "ppal_importfrom") { importFrom(); return true; } // Generate Palettes if (id == "ppal_generate") { generatePalettes(); return true; } // Generate Colormaps if (id == "ppal_colormap") { generateColormaps(); return true; } // Colourise else if (id == "ppal_colourise") { colourise(); return true; } // Tint else if (id == "ppal_tint") { tint(); return true; } // Tweak else if (id == "ppal_tweak") { tweak(); return true; } // Invert else if (id == "ppal_invert") { invert(); return true; } // Move Up else if (id == "ppal_moveup") { move(true); return true; } // Move Down else if (id == "ppal_movedown") { move(false); return true; } // Duplicate else if (id == "ppal_duplicate") { duplicate(); return true; } // Remove else if (id == "ppal_remove") { clearOne(); return true; } // Remove Others else if (id == "ppal_removeothers") { clearOthers(); return true; } // Some debug/reverse engineering stuff else if (id == "ppal_report") { analysePalettes(); return true; } return false; }