mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
convert to CRLF line endings
This commit is contained in:
+109
-109
@@ -764,7 +764,7 @@ SCRIPT_FUNCTION(get_card_export_settings) {
|
||||
ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(input.get());
|
||||
ScriptObject<Set*>* s = dynamic_cast<ScriptObject<Set*>*>(set.get());
|
||||
if (s && c) {
|
||||
Settings::ExportSettings card_settings = settings.exportSettingsFor(s->getValue()->stylesheetFor(c->getValue()));
|
||||
Settings::ExportSettings card_settings = settings.exportSettingsFor(s->getValue()->stylesheetFor(c->getValue()));
|
||||
ScriptCustomCollectionP ret(new ScriptCustomCollection());
|
||||
ret->value.push_back(to_script(lround(card_settings.zoom * 100)));
|
||||
ret->value.push_back(to_script(lround(rad_to_deg(card_settings.angle_radians))));
|
||||
@@ -782,148 +782,148 @@ SCRIPT_FUNCTION(get_card_from_uid) {
|
||||
|
||||
SCRIPT_FUNCTION(get_cards_from_link) {
|
||||
SCRIPT_PARAM_C(Set*, set);
|
||||
SCRIPT_PARAM_C(ScriptValueP, input);
|
||||
CardP input_card = nullptr;
|
||||
if (ScriptObject<CardP>* ic = dynamic_cast<ScriptObject<CardP>*>(input.get())) {
|
||||
input_card = ic->getValue();
|
||||
}
|
||||
else if (input->type() == SCRIPT_STRING) {
|
||||
input_card = Card::getCardFromUid(*set, input->toString());
|
||||
}
|
||||
if (!input_card) {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("could not find input"));
|
||||
return script_nil;
|
||||
SCRIPT_PARAM_C(ScriptValueP, input);
|
||||
CardP input_card = nullptr;
|
||||
if (ScriptObject<CardP>* ic = dynamic_cast<ScriptObject<CardP>*>(input.get())) {
|
||||
input_card = ic->getValue();
|
||||
}
|
||||
else if (input->type() == SCRIPT_STRING) {
|
||||
input_card = Card::getCardFromUid(*set, input->toString());
|
||||
}
|
||||
if (!input_card) {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("could not find input"));
|
||||
return script_nil;
|
||||
}
|
||||
SCRIPT_PARAM(String, linked_relation);
|
||||
ScriptCustomCollectionP ret(new ScriptCustomCollection());
|
||||
vector<CardP> other_cards = input_card->getLinkedCardsFromLink(*set, linked_relation, true);
|
||||
if (other_cards.size() > 0) {
|
||||
FOR_EACH(other_card, other_cards) {
|
||||
ret->value.push_back(to_script(other_card));
|
||||
}
|
||||
ScriptCustomCollectionP ret(new ScriptCustomCollection());
|
||||
vector<CardP> other_cards = input_card->getLinkedCardsFromLink(*set, linked_relation, true);
|
||||
if (other_cards.size() > 0) {
|
||||
FOR_EACH(other_card, other_cards) {
|
||||
ret->value.push_back(to_script(other_card));
|
||||
}
|
||||
}
|
||||
else if (set->game->card_links_alt_names.find(linked_relation) != set->game->card_links_alt_names.end()) {
|
||||
other_cards = input_card->getLinkedCardsFromLink(*set, set->game->card_links_alt_names[linked_relation], true);
|
||||
FOR_EACH(other_card, other_cards) {
|
||||
ret->value.push_back(to_script(other_card));
|
||||
}
|
||||
}
|
||||
else if (set->game->card_links_alt_names.find(linked_relation) != set->game->card_links_alt_names.end()) {
|
||||
other_cards = input_card->getLinkedCardsFromLink(*set, set->game->card_links_alt_names[linked_relation], true);
|
||||
FOR_EACH(other_card, other_cards) {
|
||||
ret->value.push_back(to_script(other_card));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(get_front_face) {
|
||||
SCRIPT_PARAM_C(Set*, set);
|
||||
SCRIPT_PARAM_C(ScriptValueP, input);
|
||||
CardP input_card = nullptr;
|
||||
if (ScriptObject<CardP>* ic = dynamic_cast<ScriptObject<CardP>*>(input.get())) {
|
||||
input_card = ic->getValue();
|
||||
}
|
||||
else if (input->type() == SCRIPT_STRING) {
|
||||
input_card = Card::getCardFromUid(*set, input->toString());
|
||||
}
|
||||
if (!input_card) {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("could not find input"));
|
||||
return script_nil;
|
||||
}
|
||||
vector<CardP> other_cards = input_card->getLinkedCardsFromLink(*set, "Front Face", true);
|
||||
if (other_cards.size() == 0) return script_nil;
|
||||
SCRIPT_PARAM_C(ScriptValueP, input);
|
||||
CardP input_card = nullptr;
|
||||
if (ScriptObject<CardP>* ic = dynamic_cast<ScriptObject<CardP>*>(input.get())) {
|
||||
input_card = ic->getValue();
|
||||
}
|
||||
else if (input->type() == SCRIPT_STRING) {
|
||||
input_card = Card::getCardFromUid(*set, input->toString());
|
||||
}
|
||||
if (!input_card) {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("could not find input"));
|
||||
return script_nil;
|
||||
}
|
||||
vector<CardP> other_cards = input_card->getLinkedCardsFromLink(*set, "Front Face", true);
|
||||
if (other_cards.size() == 0) return script_nil;
|
||||
if (other_cards.size() > 1) queue_message(MESSAGE_WARNING, _ERROR_1_("multiple front faces", input_card->identification()));
|
||||
SCRIPT_RETURN(other_cards[0]);
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(get_back_face) {
|
||||
SCRIPT_PARAM_C(Set*, set);
|
||||
SCRIPT_PARAM_C(ScriptValueP, input);
|
||||
CardP input_card = nullptr;
|
||||
if (ScriptObject<CardP>* ic = dynamic_cast<ScriptObject<CardP>*>(input.get())) {
|
||||
input_card = ic->getValue();
|
||||
}
|
||||
else if (input->type() == SCRIPT_STRING) {
|
||||
input_card = Card::getCardFromUid(*set, input->toString());
|
||||
}
|
||||
if (!input_card) {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("could not find input"));
|
||||
return script_nil;
|
||||
}
|
||||
vector<CardP> other_cards = input_card->getLinkedCardsFromLink(*set, "Back Face", true);
|
||||
if (other_cards.size() == 0) return script_nil;
|
||||
SCRIPT_PARAM_C(ScriptValueP, input);
|
||||
CardP input_card = nullptr;
|
||||
if (ScriptObject<CardP>* ic = dynamic_cast<ScriptObject<CardP>*>(input.get())) {
|
||||
input_card = ic->getValue();
|
||||
}
|
||||
else if (input->type() == SCRIPT_STRING) {
|
||||
input_card = Card::getCardFromUid(*set, input->toString());
|
||||
}
|
||||
if (!input_card) {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("could not find input"));
|
||||
return script_nil;
|
||||
}
|
||||
vector<CardP> other_cards = input_card->getLinkedCardsFromLink(*set, "Back Face", true);
|
||||
if (other_cards.size() == 0) return script_nil;
|
||||
if (other_cards.size() > 1) queue_message(MESSAGE_WARNING, _ERROR_1_("multiple back faces", input_card->identification()));
|
||||
SCRIPT_RETURN(other_cards[0]);
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(add_link) {
|
||||
SCRIPT_PARAM_C(Set*, set);
|
||||
SCRIPT_PARAM_C(ScriptValueP, input);
|
||||
CardP input_card = nullptr;
|
||||
if (ScriptObject<CardP>* ic = dynamic_cast<ScriptObject<CardP>*>(input.get())) {
|
||||
input_card = ic->getValue();
|
||||
}
|
||||
else if (input->type() == SCRIPT_STRING) {
|
||||
input_card = Card::getCardFromUid(*set, input->toString());
|
||||
}
|
||||
if (!input_card) {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("could not find input"));
|
||||
return script_nil;
|
||||
SCRIPT_PARAM_C(ScriptValueP, input);
|
||||
CardP input_card = nullptr;
|
||||
if (ScriptObject<CardP>* ic = dynamic_cast<ScriptObject<CardP>*>(input.get())) {
|
||||
input_card = ic->getValue();
|
||||
}
|
||||
SCRIPT_PARAM(ScriptValueP, linked_card);
|
||||
else if (input->type() == SCRIPT_STRING) {
|
||||
input_card = Card::getCardFromUid(*set, input->toString());
|
||||
}
|
||||
if (!input_card) {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("could not find input"));
|
||||
return script_nil;
|
||||
}
|
||||
SCRIPT_PARAM(ScriptValueP, linked_card);
|
||||
CardP other_card = nullptr;
|
||||
if (ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(linked_card.get())) {
|
||||
other_card = c->getValue();
|
||||
}
|
||||
else if (linked_card->type() == SCRIPT_STRING) {
|
||||
other_card = Card::getCardFromUid(*set, linked_card->toString());
|
||||
}
|
||||
if (!other_card) {
|
||||
queue_message(MESSAGE_WARNING, _ERROR_("could not find linked"));
|
||||
return script_nil;
|
||||
if (ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(linked_card.get())) {
|
||||
other_card = c->getValue();
|
||||
}
|
||||
else if (linked_card->type() == SCRIPT_STRING) {
|
||||
other_card = Card::getCardFromUid(*set, linked_card->toString());
|
||||
}
|
||||
if (!other_card) {
|
||||
queue_message(MESSAGE_WARNING, _ERROR_("could not find linked"));
|
||||
return script_nil;
|
||||
}
|
||||
SCRIPT_PARAM(String, selected_relation);
|
||||
SCRIPT_PARAM(String, linked_relation);
|
||||
input_card->link(*set, other_card, selected_relation, linked_relation);
|
||||
SCRIPT_PARAM(String, linked_relation);
|
||||
input_card->link(*set, other_card, selected_relation, linked_relation);
|
||||
SCRIPT_RETURN(other_card);
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(remove_links) {
|
||||
SCRIPT_PARAM_C(Set*, set);
|
||||
ScriptCustomCollectionP ret(new ScriptCustomCollection());
|
||||
SCRIPT_PARAM_C(ScriptValueP, input);
|
||||
CardP input_card = nullptr;
|
||||
if (ScriptObject<CardP>* ic = dynamic_cast<ScriptObject<CardP>*>(input.get())) {
|
||||
input_card = ic->getValue();
|
||||
}
|
||||
else if (input->type() == SCRIPT_STRING) {
|
||||
input_card = Card::getCardFromUid(*set, input->toString());
|
||||
}
|
||||
if (!input_card) {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("could not find input"));
|
||||
return ret;
|
||||
}
|
||||
SCRIPT_PARAM_C(ScriptValueP, input);
|
||||
CardP input_card = nullptr;
|
||||
if (ScriptObject<CardP>* ic = dynamic_cast<ScriptObject<CardP>*>(input.get())) {
|
||||
input_card = ic->getValue();
|
||||
}
|
||||
else if (input->type() == SCRIPT_STRING) {
|
||||
input_card = Card::getCardFromUid(*set, input->toString());
|
||||
}
|
||||
if (!input_card) {
|
||||
queue_message(MESSAGE_ERROR, _ERROR_("could not find input"));
|
||||
return ret;
|
||||
}
|
||||
vector<CardP> other_cards;
|
||||
SCRIPT_PARAM_DEFAULT(ScriptValueP, linked_card, script_nil);
|
||||
if (linked_card != script_nil) {
|
||||
SCRIPT_PARAM_DEFAULT(ScriptValueP, linked_card, script_nil);
|
||||
if (linked_card != script_nil) {
|
||||
CardP other_card = nullptr;
|
||||
if (ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(linked_card.get())) {
|
||||
other_card = c->getValue();
|
||||
}
|
||||
else if (linked_card->type() == SCRIPT_STRING) {
|
||||
other_card = Card::getCardFromUid(*set, linked_card->toString());
|
||||
}
|
||||
if (!other_card) {
|
||||
queue_message(MESSAGE_WARNING, _ERROR_("could not find linked"));
|
||||
}
|
||||
else other_cards.push_back(other_card);
|
||||
if (ScriptObject<CardP>* c = dynamic_cast<ScriptObject<CardP>*>(linked_card.get())) {
|
||||
other_card = c->getValue();
|
||||
}
|
||||
else if (linked_card->type() == SCRIPT_STRING) {
|
||||
other_card = Card::getCardFromUid(*set, linked_card->toString());
|
||||
}
|
||||
if (!other_card) {
|
||||
queue_message(MESSAGE_WARNING, _ERROR_("could not find linked"));
|
||||
}
|
||||
else other_cards.push_back(other_card);
|
||||
}
|
||||
SCRIPT_PARAM_DEFAULT(ScriptValueP, linked_relation, script_nil);
|
||||
if (linked_relation != script_nil) {
|
||||
if (linked_relation->type() == SCRIPT_STRING) {
|
||||
vector<CardP> other_other_cards = input_card->getLinkedCardsFromLink(*set, linked_relation->toString(), true);
|
||||
other_cards.insert(other_cards.end(), other_other_cards.begin(), other_other_cards.end());
|
||||
if (linked_relation != script_nil) {
|
||||
if (linked_relation->type() == SCRIPT_STRING) {
|
||||
vector<CardP> other_other_cards = input_card->getLinkedCardsFromLink(*set, linked_relation->toString(), true);
|
||||
other_cards.insert(other_cards.end(), other_other_cards.begin(), other_other_cards.end());
|
||||
}
|
||||
}
|
||||
input_card->unlink(other_cards);
|
||||
FOR_EACH(other_card, other_cards) {
|
||||
ret->value.push_back(to_script(other_card));
|
||||
}
|
||||
}
|
||||
input_card->unlink(other_cards);
|
||||
FOR_EACH(other_card, other_cards) {
|
||||
ret->value.push_back(to_script(other_card));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,16 +29,16 @@ SCRIPT_FUNCTION(new_card) {
|
||||
// create a new card object
|
||||
CardP new_card = make_intrusive<Card>(*game);
|
||||
// iterate on the given key/value pairs
|
||||
SCRIPT_PARAM(ScriptValueP, input);
|
||||
// check for a stylesheet first, since other things depend on it
|
||||
SCRIPT_PARAM(ScriptValueP, input);
|
||||
// check for a stylesheet first, since other things depend on it
|
||||
ScriptValueP it = input->makeIterator();
|
||||
ScriptValueP key;
|
||||
while (ScriptValueP value = it->next(&key)) {
|
||||
assert(key);
|
||||
if (key == script_nil || value == script_nil) continue;
|
||||
String key_name = key->toString();
|
||||
if (set_stylesheet_container(*game, new_card, value, key_name, ignore_field_not_found)) break;
|
||||
}
|
||||
if (set_stylesheet_container(*game, new_card, value, key_name, ignore_field_not_found)) break;
|
||||
}
|
||||
// set the rest of the key/value pairs
|
||||
it = input->makeIterator();
|
||||
while (ScriptValueP value = it->next(&key)) {
|
||||
@@ -60,7 +60,7 @@ SCRIPT_FUNCTION(new_card) {
|
||||
ScriptValueP script_input = field->import_script.invoke(ctx, true);
|
||||
// if the script result is a collection, iterate on the key/value pairs
|
||||
// treat the keys as field names and the values as what to populate those fields with
|
||||
if (script_input->type() == SCRIPT_COLLECTION) {
|
||||
if (script_input->type() == SCRIPT_COLLECTION) {
|
||||
// check for a stylesheet first, since other things depend on it
|
||||
ScriptValueP script_it = script_input->makeIterator();
|
||||
ScriptValueP script_key;
|
||||
@@ -68,8 +68,8 @@ SCRIPT_FUNCTION(new_card) {
|
||||
assert(script_key);
|
||||
if (script_key == script_nil || script_value == script_nil) continue;
|
||||
String script_key_name = script_key->toString();
|
||||
if (set_stylesheet_container(*game, new_card, script_value, script_key_name, ignore_field_not_found)) break;
|
||||
}
|
||||
if (set_stylesheet_container(*game, new_card, script_value, script_key_name, ignore_field_not_found)) break;
|
||||
}
|
||||
// iterate on the rest of the key/value pairs given by the script
|
||||
script_it = script_input->makeIterator();
|
||||
while (ScriptValueP script_value = script_it->next(&script_key)) {
|
||||
@@ -103,7 +103,7 @@ SCRIPT_FUNCTION(new_card) {
|
||||
ScriptValueP ctx_card = ctx.getVariableOpt(SCRIPT_VAR_card);
|
||||
ctx.setVariable(SCRIPT_VAR_card, to_script(new_card));
|
||||
ScriptValueP script_input = game->import_script.invoke(ctx, true);
|
||||
if (script_input->type() == SCRIPT_COLLECTION) {
|
||||
if (script_input->type() == SCRIPT_COLLECTION) {
|
||||
// check for a stylesheet first, since other things depend on it
|
||||
ScriptValueP script_it = script_input->makeIterator();
|
||||
ScriptValueP script_key;
|
||||
@@ -111,7 +111,7 @@ SCRIPT_FUNCTION(new_card) {
|
||||
assert(script_key);
|
||||
if (script_key == script_nil || script_value == script_nil) continue;
|
||||
String script_key_name = script_key->toString();
|
||||
if (set_stylesheet_container(*game, new_card, script_value, script_key_name, ignore_field_not_found)) break;
|
||||
if (set_stylesheet_container(*game, new_card, script_value, script_key_name, ignore_field_not_found)) break;
|
||||
}
|
||||
// iterate on the rest of the key/value pairs given by the script
|
||||
script_it = script_input->makeIterator();
|
||||
|
||||
@@ -440,7 +440,7 @@ SCRIPT_FUNCTION(write_image_file) {
|
||||
// get image
|
||||
Image img;
|
||||
SCRIPT_PARAM(Set*, set);
|
||||
SCRIPT_PARAM_C(ScriptValueP, input);
|
||||
SCRIPT_PARAM_C(ScriptValueP, input);
|
||||
ScriptObject<CardP>* card = dynamic_cast<ScriptObject<CardP>*>(input.get()); // is the input a card or image?
|
||||
if (card) {
|
||||
SCRIPT_PARAM_DEFAULT(double, zoom, 100.0);
|
||||
|
||||
@@ -39,12 +39,12 @@ SCRIPT_FUNCTION(to_card_image) {
|
||||
if (use_user_settings) {
|
||||
// Use the User's Preferences for Export Zoom, Angle and Bleed settings.
|
||||
Settings::ExportSettings card_settings = settings.exportSettingsFor(set->stylesheetFor(input));
|
||||
zoom = card_settings.zoom;
|
||||
angle = card_settings.angle_radians;
|
||||
zoom = card_settings.zoom;
|
||||
angle = card_settings.angle_radians;
|
||||
bleed = card_settings.bleed_pixels;
|
||||
} else {
|
||||
// Use the provided (or defaulted) Zoom, Angle and Bleed.
|
||||
zoom = zoom / 100.0;
|
||||
zoom = zoom / 100.0;
|
||||
angle = deg_to_rad(angle);
|
||||
}
|
||||
return make_intrusive<ArbitraryImage>(export_image(set, input, true, zoom, angle, bleed));
|
||||
@@ -56,7 +56,7 @@ SCRIPT_FUNCTION(import_image) {
|
||||
return make_intrusive<ImportedImage>(set, input);
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(download_image) {
|
||||
SCRIPT_FUNCTION(download_image) {
|
||||
if (!settings.allow_image_download) return script_nil;
|
||||
SCRIPT_PARAM(Set*, set);
|
||||
SCRIPT_PARAM(String, input);
|
||||
|
||||
Reference in New Issue
Block a user