fix copy pasting bugs

This commit is contained in:
GenevensiS
2026-05-04 04:57:31 +02:00
parent 8cc17abecc
commit db1fd4f343
6 changed files with 25 additions and 19 deletions
+9 -8
View File
@@ -58,14 +58,15 @@ AddCardAction::AddCardAction(AddingOrRemoving ar, Set& set, const vector<CardP>&
// Otherwise, if it's an existing card, create an action to copy the link // Otherwise, if it's an existing card, create an action to copy the link
else if (set.card_uids.find(linked_uid) != set.card_uids.end()) { else if (set.card_uids.find(linked_uid) != set.card_uids.end()) {
CardP linked_card = set.card_uids.at(linked_uid); CardP linked_card = set.card_uids.at(linked_uid);
int linked_index = linked_card->findFreeLink(new_uid, set.card_uids); int selected_index = linked_card->findUIDLink(old_uid);
if (linked_index < 0) { if (selected_index < 0) continue;
int free_index = linked_card->findFreeLink(new_uid, set.card_uids);
if (free_index < 0) {
queue_message(MESSAGE_WARNING, _ERROR_1_("not enough free links", linked_card->identification())); queue_message(MESSAGE_WARNING, _ERROR_1_("not enough free links", linked_card->identification()));
continue;
} }
else { String selected_relation(linked_card->getLinkedRelation(selected_index));
String relation(linked_card->getLinkedRelation(linked_index)); card_link_actions.push_back(make_intrusive<OneWayLinkCardsAction>(linked_card, new_uid, selected_relation, free_index));
card_link_actions.push_back(make_intrusive<OneWayLinkCardsAction>(linked_card, new_uid, relation, linked_index));
}
} }
} }
} }
@@ -83,7 +84,7 @@ void AddCardAction::perform(bool to_undo) {
card_link_actions[i]->perform(to_undo); card_link_actions[i]->perform(to_undo);
} }
// Update uid map // Update uid map
set.buildUidMap(); set.buildUIDMap();
} }
// ----------------------------------------------------------------------------- : Reorder cards // ----------------------------------------------------------------------------- : Reorder cards
@@ -245,7 +246,7 @@ void ChangeCardUIDAction::perform(bool to_undo) {
c->updateLinkedUID(card->uid, uid); c->updateLinkedUID(card->uid, uid);
} }
swap(card->uid, uid); swap(card->uid, uid);
set.buildUidMap(); set.buildUIDMap();
} }
// ----------------------------------------------------------------------------- : Pack types // ----------------------------------------------------------------------------- : Pack types
+2 -2
View File
@@ -68,7 +68,7 @@ void Set::updateStyles(const CardP& card, bool only_content_dependent) {
void Set::updateDelayed() { void Set::updateDelayed() {
script_manager->updateDelayed(); script_manager->updateDelayed();
} }
void Set::buildUidMap() { void Set::buildUIDMap() {
card_uids.clear(); card_uids.clear();
FOR_EACH(c, cards) { FOR_EACH(c, cards) {
while (card_uids.find(c->uid) != card_uids.end()) { while (card_uids.find(c->uid) != card_uids.end()) {
@@ -201,7 +201,7 @@ void Set::validate(Version file_app_version) {
// update scripts // update scripts
script_manager->updateAll(); script_manager->updateAll();
// build uid map // build uid map
buildUidMap(); buildUIDMap();
} }
void reflect_version_check(Reader& handler, const Char* key, intrusive_ptr<Packaged> const& package) { void reflect_version_check(Reader& handler, const Char* key, intrusive_ptr<Packaged> const& package) {
+1 -1
View File
@@ -73,7 +73,7 @@ public:
/// Update scripts that were delayed /// Update scripts that were delayed
void updateDelayed(); void updateDelayed();
/// Update uid map /// Update uid map
void buildUidMap(); void buildUIDMap();
/// A context for performing scripts /// A context for performing scripts
/** Should only be used from the thumbnail thread! */ /** Should only be used from the thumbnail thread! */
Context& getContextForThumbnails(); Context& getContextForThumbnails();
+10 -6
View File
@@ -320,11 +320,14 @@ bool CardListBase::parseUrl(String& url, vector<CardP>& out) {
bool CardListBase::parseFiles(wxArrayString& filenames, vector<CardP>& out) { bool CardListBase::parseFiles(wxArrayString& filenames, vector<CardP>& out) {
size_t j = out.size(); size_t j = out.size();
for (size_t i = 0; i < filenames.size(); i++) { for (size_t i = 0; i < filenames.size(); i++) {
// if it's an image file, try to get meta_data if (wxImage::CanRead(filenames[i])) {
Image image_file; // if it's an image file, try to get meta_data
image_file.SetLoadFlags(image_file.GetLoadFlags() & ~wxImage::Load_Verbose); Image image_file;
if (image_file.LoadFile(filenames[i])) { image_file.SetLoadFlags(image_file.GetLoadFlags() & ~wxImage::Load_Verbose);
parseImage(image_file, out); if (image_file.LoadFile(filenames[i])) {
parseImage(image_file, out);
}
else queue_message(MESSAGE_ERROR, _ERROR_("can't load image"));
} else { } else {
// if it's an url, request the data // if it's an url, request the data
std::ifstream ifs(filenames[i].ToStdString()); std::ifstream ifs(filenames[i].ToStdString());
@@ -653,7 +656,8 @@ void CardListBase::onChar(wxKeyEvent& ev) {
} }
} }
void CardListBase::onBeginDrag(wxListEvent&) { void CardListBase::onBeginDrag(wxListEvent& ev) {
ev.Skip();
drop_timer.Start(200, wxTIMER_ONE_SHOT); drop_timer.Start(200, wxTIMER_ONE_SHOT);
} }
+1
View File
@@ -656,6 +656,7 @@ CardP CardsPanel::selectedCard() const {
void CardsPanel::selectCard(const CardP& card) { void CardsPanel::selectCard(const CardP& card) {
if (!set) return; // we want onChangeSet first if (!set) return; // we want onChangeSet first
card_list->SetFocus();
card_list->setCard(card); card_list->setCard(card);
editor->setCard(card); editor->setCard(card);
+1 -1
View File
@@ -309,7 +309,7 @@ void SetWindow::onChangeSet() {
// make sure there is always at least one card // make sure there is always at least one card
// some things need this // some things need this
if (set->cards.empty()) set->cards.push_back(make_intrusive<Card>(*set->game)); if (set->cards.empty()) set->cards.push_back(make_intrusive<Card>(*set->game));
set->buildUidMap(); set->buildUIDMap();
// all panels view the same set // all panels view the same set
FOR_EACH(p, panels) { FOR_EACH(p, panels) {
p->setSet(set); p->setSet(set);