void Instance::InsertMod(size_t index, const wxFileName &source) { wxFileName dest(Path::Combine(GetInstModsDir().GetFullPath(), source.GetFullName())); if (!source.SameAs(dest)) { wxCopyFile(source.GetFullPath(), dest.GetFullPath()); } dest.MakeRelativeTo(); SetNeedsRebuild(); int oldIndex = Find(modList.begin(), modList.end(), [&dest] (Mod mod) -> bool { return mod.GetFileName().SameAs(dest); }); if (oldIndex != -1) { modList.erase(modList.begin() + oldIndex); } if (index >= modList.size()) modList.push_back(Mod(dest)); else modList.insert(modList.begin() + index, Mod(dest)); SaveModList(); }