// ----------------------------------------------------------------------------- // Called when the 'modify offsets' button is clicked // ----------------------------------------------------------------------------- void GfxEntryPanel::onBtnAutoOffset(wxCommandEvent& e) { ModifyOffsetsDialog dlg; dlg.SetParent(theMainWindow); dlg.CenterOnParent(); if (dlg.ShowModal() == wxID_OK) { // Calculate new offsets Vec2i offsets = dlg.calculateOffsets( spin_xoffset_->GetValue(), spin_yoffset_->GetValue(), gfx_canvas_->image().width(), gfx_canvas_->image().height()); // Change offsets spin_xoffset_->SetValue(offsets.x); spin_yoffset_->SetValue(offsets.y); image()->setXOffset(offsets.x); image()->setYOffset(offsets.y); refreshPanel(); // Set changed setModified(); } }
// ----------------------------------------------------------------------------- // Changes the offsets for each selected texture. Only for ZDoom! // ----------------------------------------------------------------------------- bool TextureXPanel::modifyOffsets() { if (!tx_entry_) return false; // saveTEXTUREX(); // Create modify offsets dialog ModifyOffsetsDialog mod; mod.SetParent(this); mod.CenterOnParent(); // Run the dialog if (mod.ShowModal() == wxID_CANCEL) return false; // Go through selection vector<long> selec_num = list_textures_->getSelection(true); for (unsigned a = 0; a < selec_num.size(); ++a) { // Get texture bool current = false; CTexture* ctex = texturex_.getTexture(selec_num[a]); if (ctex == tex_current_) { // Texture is currently open in the editor ctex = texture_editor_->texture(); current = true; } // Calculate and apply new offsets point2_t offsets = mod.calculateOffsets(ctex->getOffsetX(), ctex->getOffsetY(), ctex->getWidth(), ctex->getHeight()); ctex->setOffsetX(offsets.x); ctex->setOffsetY(offsets.y); ctex->setState(1); modified_ = true; // If it was the current texture, update controls if (current) texture_editor_->updateTextureControls(); } return true; }