void ModEditWindow::MLModListCtrl::DeleteMod() { if (GetItemCount() <= 0) return; wxArrayInt indices; long item = -1; while (true) { item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (item == -1) break; indices.Add(item); } //FIXME: this looks like lazy code. it can be done better. for (int i = indices.GetCount() -1; i >= 0; i--) { m_inst->GetMLModList()->DeleteMod(indices[i]); } auto mllist = m_inst->GetMLModList(); mllist->UpdateModList(); UpdateItems(); }
void ModEditWindow::MLModListCtrl::PasteMod() { wxFileDataObject data; // Get data from the clipboard. if (wxTheClipboard->Open()) { if (wxTheClipboard->IsSupported(wxDF_FILENAME)) { wxTheClipboard->GetData(data); } else { wxTheClipboard->Close(); return; } wxTheClipboard->Close(); } // Add the given mods. wxArrayString filenames = data.GetFilenames(); for (wxArrayString::iterator iter = filenames.begin(); iter != filenames.end(); ++iter) { wxFileName file(*iter); wxCopyFile(file.GetFullPath(), Path::Combine(m_inst->GetMLModsDir(), file.GetFullName())); } //FIXME: this looks like lazy code. it can be done better. auto mllist = m_inst->GetMLModList(); mllist->UpdateModList(); UpdateItems(); }
void ModEditWindow::CoreModListCtrl::PasteMod() { wxFileDataObject data; // Get data from the clipboard. if (wxTheClipboard->Open()) { if (wxTheClipboard->IsSupported(wxDF_FILENAME)) { wxTheClipboard->GetData(data); } else { wxTheClipboard->Close(); return; } wxTheClipboard->Close(); } // Add the given mods. wxArrayString filenames = data.GetFilenames(); CopyFiles(filenames,m_inst->GetCoreModsDir().GetFullPath()); //FIXME: this looks like lazy code. it can be done better. auto mllist = m_inst->GetCoreModList(); mllist->UpdateModList(); UpdateItems(); }
bool ModEditWindow::CoreModsDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames) { m_owner->CopyFiles(filenames, m_inst->GetCoreModsDir().GetFullPath()); auto mllist = m_inst->GetCoreModList(); mllist->UpdateModList(); m_owner->UpdateItems(); return true; }
Instance::Instance(const wxFileName &rootDir) { this->rootDir = rootDir; config = new wxFileConfig(wxEmptyString, wxEmptyString, GetConfigPath().GetFullPath(), wxEmptyString, wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH); evtHandler = NULL; MkDirs(); UpdateModList(); LoadMLModList(); }
bool ModEditWindow::MLModsDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames) { for (wxArrayString::const_iterator iter = filenames.begin(); iter != filenames.end(); ++iter) { wxFileName dest(Path::Combine(m_inst->GetMLModsDir().GetFullPath(), *iter)); wxCopyFile(*iter, dest.GetFullPath()); } auto mllist = m_inst->GetMLModList(); mllist->UpdateModList(); m_owner->UpdateItems(); return true; }
void ModEditWindow::OnAddCoreMod(wxCommandEvent &event) { wxFileDialog addTPDialog (this, "Choose a file to add.", settings->GetModsDir().GetFullPath(), wxEmptyString, wxFileSelectorDefaultWildcardStr,wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE ); if (addTPDialog.ShowModal() == wxID_OK) { wxArrayString allfiles; addTPDialog.GetPaths(allfiles); CopyFiles(allfiles, m_inst->GetCoreModsDir().GetFullPath()); auto corelist = m_inst->GetCoreModList(); corelist->UpdateModList(); coreModList->UpdateItems(); } }