mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
localize card links, add_link, remove_links
This commit is contained in:
+35
-5
@@ -156,8 +156,7 @@ void Card::link(const Set& set, const vector<CardP>& linked_cards, const String&
|
||||
ss << all_missed_cards[pos]->identification();
|
||||
if (pos < all_missed_cards.size() - 1) ss << ", ";
|
||||
};
|
||||
String wxString(ss.str().c_str(), wxConvUTF8);
|
||||
queue_message(MESSAGE_WARNING, wxString);
|
||||
queue_message(MESSAGE_WARNING, wxString(ss.str().c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,7 +283,7 @@ vector<pair<CardP, String>> Card::getLinkedCards(const Set& set) {
|
||||
return getLinkedCards(set.cards);
|
||||
}
|
||||
|
||||
CardP Card::getOtherFace(const vector<CardP>& cards) {
|
||||
CardP Card::getLinkedOtherFace(const vector<CardP>& cards) {
|
||||
unordered_set<String> faces;
|
||||
if (linked_relation_1 == _("Front Face") || linked_relation_1 == _("Back Face")) faces.emplace(linked_card_1);
|
||||
if (linked_relation_2 == _("Front Face") || linked_relation_2 == _("Back Face")) faces.emplace(linked_card_2);
|
||||
@@ -295,8 +294,39 @@ CardP Card::getOtherFace(const vector<CardP>& cards) {
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
CardP Card::getOtherFace(const Set& set) {
|
||||
return getOtherFace(set.cards);
|
||||
CardP Card::getLinkedOtherFace(const Set& set) {
|
||||
return getLinkedOtherFace(set.cards);
|
||||
}
|
||||
|
||||
vector<CardP> Card::getLinkedCardsFromLink(const vector<CardP>& cards, const String& link, bool erase_if_no_card) {
|
||||
vector<CardP> other_cards;
|
||||
THIS_LINKED_PAIRS(this_linked_pairs);
|
||||
FOR_EACH(this_linked_pair, this_linked_pairs) {
|
||||
String& this_linked_uid = this_linked_pair.first.get();
|
||||
String& this_linked_relation = this_linked_pair.second.get();
|
||||
if (this_linked_relation == link) {
|
||||
CardP other_card = getCardFromUid(cards, this_linked_uid);
|
||||
if (other_card) other_cards.push_back(other_card);
|
||||
else if (erase_if_no_card) {
|
||||
this_linked_relation = _("");
|
||||
this_linked_uid = _("");
|
||||
}
|
||||
}
|
||||
}
|
||||
return other_cards;
|
||||
}
|
||||
vector<CardP> Card::getLinkedCardsFromLink(const Set& set, const String& link, bool erase_if_no_card) {
|
||||
return getLinkedCardsFromLink(set.cards, link, erase_if_no_card);
|
||||
}
|
||||
|
||||
CardP Card::getCardFromUid(const vector<CardP>& cards, const String& uid) {
|
||||
FOR_EACH(card, cards) {
|
||||
if (card->uid == uid) return card;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
CardP Card::getCardFromUid(const Set& set, const String& uid) {
|
||||
return getCardFromUid(set.cards, uid);
|
||||
}
|
||||
|
||||
IndexMap<FieldP, ValueP>& Card::extraDataFor(const StyleSheet& stylesheet) {
|
||||
|
||||
+10
-3
@@ -90,9 +90,16 @@ public:
|
||||
void updateLink(String old_uid, String new_uid);
|
||||
|
||||
vector<pair<CardP, String>> getLinkedCards(const vector<CardP>& cards);
|
||||
vector<pair<CardP, String>> getLinkedCards(const Set& set);
|
||||
CardP getOtherFace(const vector<CardP>& cards);
|
||||
CardP getOtherFace(const Set& set);
|
||||
vector<pair<CardP, String>> getLinkedCards(const Set& set);
|
||||
|
||||
vector<CardP> getLinkedCardsFromLink(const vector<CardP>& cards, const String& link, bool erase_if_no_card);
|
||||
vector<CardP> getLinkedCardsFromLink(const Set& set, const String& link, bool erase_if_no_card);
|
||||
|
||||
CardP getLinkedOtherFace(const vector<CardP>& cards);
|
||||
CardP getLinkedOtherFace(const Set& set);
|
||||
|
||||
static CardP getCardFromUid(const vector<CardP>& cards, const String& uid);
|
||||
static CardP getCardFromUid(const Set& set, const String& uid);
|
||||
|
||||
/// Find a value in the data by name and type
|
||||
template <typename T> T& value(const String& name) {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) Twan van Laarhoven and the other MSE developers |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <data/card_link.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : CardLink
|
||||
|
||||
CardLink::CardLink() {}
|
||||
|
||||
String CardLink::name() {
|
||||
return selected.get() + _(" // ") + linked.get();
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_NO_GET_MEMBER(CardLink) {
|
||||
REFLECT_LOCALIZED(selected);
|
||||
REFLECT_LOCALIZED(linked);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) Twan van Laarhoven and the other MSE developers |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#pragma once
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <util/reflect.hpp>
|
||||
#include <data/localized_string.hpp>
|
||||
|
||||
DECLARE_POINTER_TYPE(CardLink);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Card Link
|
||||
|
||||
/// Information on a link between two cards in a set
|
||||
class CardLink : public IntrusivePtrBase<CardLink> {
|
||||
public:
|
||||
CardLink();
|
||||
|
||||
LocalizedString selected; ///< Type of link for the selected card
|
||||
LocalizedString linked; ///< Type of link for the linked card
|
||||
|
||||
String name();
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
+56
-1
@@ -1,4 +1,4 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) Twan van Laarhoven and the other MSE developers |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <data/game.hpp>
|
||||
#include <data/field.hpp>
|
||||
#include <data/field/choice.hpp>
|
||||
#include <data/card_link.hpp>
|
||||
#include <data/keyword.hpp>
|
||||
#include <data/statistics.hpp>
|
||||
#include <data/pack.hpp>
|
||||
@@ -122,6 +123,60 @@ void Game::validate(Version v) {
|
||||
card_fields_alt_names.emplace(unified_name, field->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
// front face/back face card link
|
||||
card_links.insert(card_links.begin(), make_intrusive<CardLink>());
|
||||
card_links[0]->selected.default_ = _("Front Face");
|
||||
card_links[0]->selected.translations = std::unordered_map<String, String>{
|
||||
{_("ch-s"), _("卡片正面")},
|
||||
{_("ch-t"), _("卡片正面")},
|
||||
{_("da"), _("Forside")},
|
||||
{_("de"), _("Vorderseite")},
|
||||
{_("en"), _("Front Face")},
|
||||
{_("es"), _("Cara frontal")},
|
||||
{_("fr"), _("Face Avant")},
|
||||
{_("it"), _("Fronte")},
|
||||
{_("jp"), _("カードの表面")},
|
||||
{_("ko"), _("카드 앞면")},
|
||||
{_("pl"), _("Przód")},
|
||||
{_("pt-br"), _("Frente")},
|
||||
{_("ru"), _("Лицевая сторона")}
|
||||
};
|
||||
card_links[0]->linked.default_ = _("Back Face");
|
||||
card_links[0]->linked.translations = std::unordered_map<String, String>{
|
||||
{_("ch-s"), _("卡片背面")},
|
||||
{_("ch-t"), _("卡片背面")},
|
||||
{_("da"), _("Bagside")},
|
||||
{_("de"), _("Rückseite")},
|
||||
{_("en"), _("Back Face")},
|
||||
{_("es"), _("Cara posterior")},
|
||||
{_("fr"), _("Face Arrière")},
|
||||
{_("it"), _("Retro")},
|
||||
{_("jp"), _("カードの裏面")},
|
||||
{_("ko"), _("카드 뒷면")},
|
||||
{_("pl"), _("Tył")},
|
||||
{_("pt-br"), _("Verso")},
|
||||
{_("ru"), _("Обратная сторона")}
|
||||
};
|
||||
// localized card link names map
|
||||
for (auto it = card_links.begin(); it != card_links.end(); ++it) {
|
||||
CardLinkP link = *it;
|
||||
String selected_default = link->selected.default_;
|
||||
for (auto selected_it = link->selected.translations.begin(); selected_it != link->selected.translations.end(); selected_it++) {
|
||||
String selected_tr = unified_form(selected_it->second);
|
||||
if (card_links_alt_names.find(selected_tr) != card_links_alt_names.end() && card_links_alt_names[selected_tr] != selected_default) {
|
||||
queue_message(MESSAGE_WARNING, _ERROR_3_("link duplicate", selected_tr, card_links_alt_names[selected_tr], selected_default));
|
||||
}
|
||||
card_links_alt_names.emplace(selected_tr, selected_default);
|
||||
}
|
||||
String linked_default = link->linked.default_;
|
||||
for (auto linked_it = link->linked.translations.begin(); linked_it != link->linked.translations.end(); linked_it++) {
|
||||
String linked_tr = unified_form(linked_it->second);
|
||||
if (card_links_alt_names.find(linked_tr) != card_links_alt_names.end() && card_links_alt_names[linked_tr] != linked_default) {
|
||||
queue_message(MESSAGE_WARNING, _ERROR_3_("link duplicate", linked_tr, card_links_alt_names[linked_tr], linked_default));
|
||||
}
|
||||
card_links_alt_names.emplace(linked_tr, linked_default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -19,6 +19,7 @@ DECLARE_POINTER_TYPE(Style);
|
||||
DECLARE_POINTER_TYPE(Game);
|
||||
DECLARE_POINTER_TYPE(StatsDimension);
|
||||
DECLARE_POINTER_TYPE(StatsCategory);
|
||||
DECLARE_POINTER_TYPE(CardLink);
|
||||
DECLARE_POINTER_TYPE(PackType);
|
||||
DECLARE_POINTER_TYPE(KeywordParam);
|
||||
DECLARE_POINTER_TYPE(KeywordMode);
|
||||
@@ -41,7 +42,7 @@ public:
|
||||
vector<FieldP> set_fields; ///< Fields for set information
|
||||
IndexMap<FieldP,StyleP> default_set_style; ///< Default style for the set fields, because it is often the same
|
||||
vector<FieldP> card_fields; ///< Fields on each card
|
||||
vector<String> card_links; ///< Possible links between cards
|
||||
vector<CardLinkP> card_links; ///< Possible links between cards
|
||||
OptionalScript card_list_color_script; ///< Script that determines the color of items in the card list
|
||||
OptionalScript import_script; ///< Script applied as the last step of the new_card function
|
||||
vector<String> json_paths; ///< Paths inside JSON files to find the card array
|
||||
@@ -52,6 +53,7 @@ public:
|
||||
vector<AddCardsScriptP> add_cards_scripts; ///< Scripts for adding multiple cards to the set
|
||||
vector<AutoReplaceP> auto_replaces; ///< Things to autoreplace in textboxes
|
||||
map<String,String> card_fields_alt_names; ///< Other names that fields might go by, for example in CSV files
|
||||
map<String,String> card_links_alt_names; ///< Localized names that card links go by
|
||||
bool has_keywords; ///< Does this game use keywords?
|
||||
OptionalScript keyword_match_script; ///< For the keyword editor
|
||||
vector<KeywordParamP> keyword_parameter_types;///< Types of keyword parameters
|
||||
|
||||
Reference in New Issue
Block a user