mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 21:27:01 -04:00
Rename 'cannocial_name_form' to 'canonical_name_form'
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1433 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+1
-1
@@ -50,7 +50,7 @@ IMPLEMENT_REFLECTION(Field) {
|
|||||||
REFLECT(type);
|
REFLECT(type);
|
||||||
}
|
}
|
||||||
REFLECT(name);
|
REFLECT(name);
|
||||||
REFLECT_IF_READING name = cannocial_name_form(name);
|
REFLECT_IF_READING name = canonical_name_form(name);
|
||||||
REFLECT(description);
|
REFLECT(description);
|
||||||
REFLECT_N("icon", icon_filename);
|
REFLECT_N("icon", icon_filename);
|
||||||
REFLECT(editable);
|
REFLECT(editable);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ ChoiceThumbnailRequest::ChoiceThumbnailRequest(ValueViewer* viewer, int id, bool
|
|||||||
|
|
||||||
Image ChoiceThumbnailRequest::generate() {
|
Image ChoiceThumbnailRequest::generate() {
|
||||||
ChoiceStyle& s = style();
|
ChoiceStyle& s = style();
|
||||||
String name = cannocial_name_form(s.field().choices->choiceName(id));
|
String name = canonical_name_form(s.field().choices->choiceName(id));
|
||||||
ScriptableImage& img = s.choice_images[name];
|
ScriptableImage& img = s.choice_images[name];
|
||||||
return img.isReady()
|
return img.isReady()
|
||||||
? img.generate(GeneratedImage::Options(16,16, &viewer().getStylePackage(), &viewer().getLocalPackage(), ASPECT_BORDER, true))
|
? img.generate(GeneratedImage::Options(16,16, &viewer().getStylePackage(), &viewer().getLocalPackage(), ASPECT_BORDER, true))
|
||||||
@@ -181,7 +181,7 @@ void DropDownChoiceListBase::generateThumbnailImages() {
|
|||||||
if (style().choice_images.empty() && style().image.isScripted()) {
|
if (style().choice_images.empty() && style().image.isScripted()) {
|
||||||
for (int i = 0 ; i < end ; ++i) {
|
for (int i = 0 ; i < end ; ++i) {
|
||||||
try {
|
try {
|
||||||
String name = cannocial_name_form(field().choices->choiceName(i));
|
String name = canonical_name_form(field().choices->choiceName(i));
|
||||||
ctx.setVariable(_("input"), to_script(name));
|
ctx.setVariable(_("input"), to_script(name));
|
||||||
GeneratedImageP img = image_from_script(style().image.getValidScriptP()->eval(ctx));
|
GeneratedImageP img = image_from_script(style().image.getValidScriptP()->eval(ctx));
|
||||||
style().choice_images.insert(make_pair(name, ScriptableImage(img)));
|
style().choice_images.insert(make_pair(name, ScriptableImage(img)));
|
||||||
@@ -197,7 +197,7 @@ void DropDownChoiceListBase::generateThumbnailImages() {
|
|||||||
if (i >= image_count || status != THUMB_OK) {
|
if (i >= image_count || status != THUMB_OK) {
|
||||||
// update image
|
// update image
|
||||||
ChoiceStyle& s = style();
|
ChoiceStyle& s = style();
|
||||||
String name = cannocial_name_form(s.field().choices->choiceName(i));
|
String name = canonical_name_form(s.field().choices->choiceName(i));
|
||||||
ScriptableImage& img = s.choice_images[name];
|
ScriptableImage& img = s.choice_images[name];
|
||||||
if (!img.update(ctx) && status == THUMB_CHANGED) {
|
if (!img.update(ctx) && status == THUMB_CHANGED) {
|
||||||
status = THUMB_OK; // no need to rebuild
|
status = THUMB_OK; // no need to rebuild
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const
|
|||||||
size = add_horizontal(size, RealSize(14,16));
|
size = add_horizontal(size, RealSize(14,16));
|
||||||
}
|
}
|
||||||
if (style().render_style & RENDER_IMAGE) {
|
if (style().render_style & RENDER_IMAGE) {
|
||||||
map<String,ScriptableImage>::iterator it = style().choice_images.find(cannocial_name_form(choice));
|
map<String,ScriptableImage>::iterator it = style().choice_images.find(canonical_name_form(choice));
|
||||||
if (it != style().choice_images.end() && it->second.isReady()) {
|
if (it != style().choice_images.end() && it->second.isReady()) {
|
||||||
// TODO: caching
|
// TODO: caching
|
||||||
GeneratedImage::Options options(0,0, &getStylePackage(), &getLocalPackage());
|
GeneratedImage::Options options(0,0, &getStylePackage(), &getLocalPackage());
|
||||||
|
|||||||
@@ -443,6 +443,12 @@ SCRIPT_FUNCTION(write_set_file) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCRIPT_FUNCTION(sanitize) {
|
||||||
|
SCRIPT_PARAM_C(String, input);
|
||||||
|
//TODO
|
||||||
|
SCRIPT_RETURN(input);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Init
|
// ----------------------------------------------------------------------------- : Init
|
||||||
|
|
||||||
void init_script_export_functions(Context& ctx) {
|
void init_script_export_functions(Context& ctx) {
|
||||||
@@ -453,4 +459,5 @@ void init_script_export_functions(Context& ctx) {
|
|||||||
ctx.setVariable(_("write text file"), script_write_text_file);
|
ctx.setVariable(_("write text file"), script_write_text_file);
|
||||||
ctx.setVariable(_("write image file"), script_write_image_file);
|
ctx.setVariable(_("write image file"), script_write_image_file);
|
||||||
ctx.setVariable(_("write set file"), script_write_set_file);
|
ctx.setVariable(_("write set file"), script_write_set_file);
|
||||||
|
ctx.setVariable(_("sanitize"), script_sanitize);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ void TokenIterator::readToken() {
|
|||||||
// name, or a number after a . token, as in array.0
|
// name, or a number after a . token, as in array.0
|
||||||
size_t start = pos - 1;
|
size_t start = pos - 1;
|
||||||
while (pos < input.size() && isAlnum_(input.GetChar(pos))) ++pos;
|
while (pos < input.size() && isAlnum_(input.GetChar(pos))) ++pos;
|
||||||
addToken(TOK_NAME, cannocial_name_form(input.substr(start, pos-start)), start); // convert name to cannocial form
|
addToken(TOK_NAME, canonical_name_form(input.substr(start, pos-start)), start); // convert name to cannocial form
|
||||||
} else if (isDigit(c)) {
|
} else if (isDigit(c)) {
|
||||||
// number
|
// number
|
||||||
size_t start = pos - 1;
|
size_t start = pos - 1;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ Variable string_to_variable(const String& s) {
|
|||||||
if (it == variables.end()) {
|
if (it == variables.end()) {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
variable_names.push_back(s);
|
variable_names.push_back(s);
|
||||||
assert(s == cannocial_name_form(s)); // only use cannocial names
|
assert(s == canonical_name_form(s)); // only use cannocial names
|
||||||
#endif
|
#endif
|
||||||
Variable v = (Variable)variables.size();
|
Variable v = (Variable)variables.size();
|
||||||
variables.insert(make_pair(s,v));
|
variables.insert(make_pair(s,v));
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ void Reader::readLine(bool in_string) {
|
|||||||
indent += 1;
|
indent += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
key = cannocial_name_form(trim(key));
|
key = canonical_name_form(trim(key));
|
||||||
value = pos == String::npos ? _("") : trim_left(line.substr(pos+1));
|
value = pos == String::npos ? _("") : trim_left(line.substr(pos+1));
|
||||||
if (key.empty() && pos!=String::npos) key = _(" "); // we don't want an empty key if there was a colon
|
if (key.empty() && pos!=String::npos) key = _(" "); // we don't want an empty key if there was a colon
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void Writer::writePending() {
|
|||||||
}
|
}
|
||||||
indentation += 1;
|
indentation += 1;
|
||||||
writeIndentation();
|
writeIndentation();
|
||||||
writeUTF8(stream, cannocial_name_form(pending_opened[i]));
|
writeUTF8(stream, canonical_name_form(pending_opened[i]));
|
||||||
}
|
}
|
||||||
pending_opened.clear();
|
pending_opened.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -178,7 +178,7 @@ String capitalize_sentence(const String& s) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
String cannocial_name_form(const String& str) {
|
String canonical_name_form(const String& str) {
|
||||||
String ret;
|
String ret;
|
||||||
ret.reserve(str.size());
|
ret.reserve(str.size());
|
||||||
bool leading = true;
|
bool leading = true;
|
||||||
|
|||||||
+2
-2
@@ -152,12 +152,12 @@ String capitalize(const String&);
|
|||||||
/** for use in dialogs */
|
/** for use in dialogs */
|
||||||
String capitalize_sentence(const String&);
|
String capitalize_sentence(const String&);
|
||||||
|
|
||||||
/// Convert a field name to cannocial form
|
/// Convert a field name to canonical form
|
||||||
/** - lower case and ' ' instead of '_'.
|
/** - lower case and ' ' instead of '_'.
|
||||||
* - non alphanumeric characters are droped
|
* - non alphanumeric characters are droped
|
||||||
* - "camalCase" is converted to words "camel case" (TODO)
|
* - "camalCase" is converted to words "camel case" (TODO)
|
||||||
*/
|
*/
|
||||||
String cannocial_name_form(const String&);
|
String canonical_name_form(const String&);
|
||||||
|
|
||||||
/// Returns the singular form of a string
|
/// Returns the singular form of a string
|
||||||
/** Used for reflection, for example "vector<T> apples" is written with keys
|
/** Used for reflection, for example "vector<T> apples" is written with keys
|
||||||
|
|||||||
Reference in New Issue
Block a user