void TextureLumpArea::onRemovePatch(wxCommandEvent &event) { if (list_textures->GetSelection() == -1 || list_patches->GetSelection() == -1) return; removePatch(list_patches->GetSelection()); }
/* TextureEditorPanel::handleAction * Handles the action [id]. Returns true if the action was handled, * false otherwise *******************************************************************/ bool TextureEditorPanel::handleAction(string id) { // Don't handle actions if hidden if (!IsShown()) return false; // Only interested in actions beginning with txed_ if (!id.StartsWith("txed_")) return false; // Add Patch if (id == "txed_patch_add") addPatch(); // Remove Patch else if (id == "txed_patch_remove") removePatch(); // Send Patch Back else if (id == "txed_patch_back") patchBack(); // Bring Patch Forward else if (id == "txed_patch_forward") patchForward(); // Replace Patch else if (id == "txed_patch_replace") replacePatch(); // Duplicate Patch else if (id == "txed_patch_duplicate") duplicatePatch(); // Unknown action else return false; // Action was handled return true; }
/* TextureEditorPanel::onTexCanvasKeyDown * Called when a key is pressed within the texture canvas *******************************************************************/ void TextureEditorPanel::onTexCanvasKeyDown(wxKeyEvent& e) { // Check if keypress matches any keybinds wxArrayString binds = KeyBind::getBinds(KeyBind::asKeyPress(e.GetKeyCode(), e.GetModifiers())); // Check for alt key if (e.GetKeyCode() == WXK_ALT) alt_press = true; // Go through matching binds int x_movement = 0; int y_movement = 0; bool handled = false; for (unsigned a = 0; a < binds.size(); a++) { string name = binds[a]; // Move patch left if (name == "txed_patch_left") x_movement = -1; else if (name == "txed_patch_left8") x_movement = -8; // Move patch up else if (name == "txed_patch_up") y_movement = -1; else if (name == "txed_patch_up8") y_movement = -8; // Move patch right else if (name == "txed_patch_right") x_movement = 1; else if (name == "txed_patch_right8") x_movement = 8; // Move patch down else if (name == "txed_patch_down") y_movement = 1; else if (name == "txed_patch_down8") y_movement = 8; // Add patch else if (name == "txed_patch_add") { hack_nodrag = true; addPatch(); handled = true; } // Delete patch else if (name == "txed_patch_delete") { removePatch(); handled = true; } // Replace patch else if (name == "txed_patch_replace") { hack_nodrag = true; replacePatch(); handled = true; } // Duplicate patch else if (name == "txed_patch_duplicate") { duplicatePatch(); handled = true; } // Bring patch forward else if (name == "txed_patch_forward") { patchForward(); handled = true; } // Send patch back else if (name == "txed_patch_back") { patchBack(); handled = true; } } // Move patches if needed if (x_movement != 0 || y_movement != 0) { // Do patch duplicate if alt is pressed if (e.GetModifiers() == wxMOD_ALT && alt_press) { duplicatePatch(0, 0); alt_press = false; } wxArrayInt selected_patches = list_patches->selectedItems(); for (size_t a = 0; a < selected_patches.size(); a++) { CTPatch* patch = tex_current->getPatch(selected_patches[a]); if (!patch) continue; int16_t cx = patch->xOffset(); int16_t cy = patch->yOffset(); patch->setOffsetX(cx + x_movement); patch->setOffsetY(cy + y_movement); tex_modified = true; } tex_canvas->redraw(true); handled = true; } if (!e.AltDown()) alt_press = false; if (!handled) e.Skip(); }
/* TextureEditorPanel::onBtnPatchRemove * Called when the 'remove patch' button is pressed *******************************************************************/ void TextureEditorPanel::onBtnPatchRemove(wxCommandEvent& e) { removePatch(); }