mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Added 'insert symbol' menu for SymbolFonts;
Added scriptable 'enabled' to symbols in symbol font, used instead of scripted filenames. This means changing the tap symbol style now works; Added localisation for games, stylesheets and symbolfonts; Warnings from Reader are now shown onIdle; git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@198 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+24
-6
@@ -24,7 +24,8 @@ String Error::what() const {
|
||||
|
||||
// Errors for which a message box was already shown
|
||||
vector<String> previous_errors;
|
||||
String pending_error;
|
||||
String pending_errors;
|
||||
String pending_warnings;
|
||||
DECLARE_TYPEOF_COLLECTION(String);
|
||||
|
||||
void handle_error(const String& e, bool allow_duplicate = true, bool now = true) {
|
||||
@@ -38,8 +39,8 @@ void handle_error(const String& e, bool allow_duplicate = true, bool now = true)
|
||||
}
|
||||
// Only show errors in the main thread
|
||||
if (!now || !wxThread::IsMain()) {
|
||||
if (!pending_error.empty()) pending_error += _("\n\n");
|
||||
pending_error += e;
|
||||
if (!pending_errors.empty()) pending_errors += _("\n\n");
|
||||
pending_errors += e;
|
||||
return;
|
||||
}
|
||||
// show message
|
||||
@@ -50,10 +51,27 @@ void handle_error(const Error& e, bool allow_duplicate, bool now) {
|
||||
handle_error(e.what(), allow_duplicate, now);
|
||||
}
|
||||
|
||||
void handle_warning(const String& w, bool now) {
|
||||
// Check duplicates
|
||||
// TODO: thread safety
|
||||
// Only show errors in the main thread
|
||||
if (!now || !wxThread::IsMain()) {
|
||||
if (!pending_warnings.empty()) pending_warnings += _("\n\n");
|
||||
pending_warnings += w;
|
||||
return;
|
||||
}
|
||||
// show message
|
||||
wxMessageBox(w, _("Warning"), wxOK | wxICON_EXCLAMATION);
|
||||
}
|
||||
|
||||
void handle_pending_errors() {
|
||||
assert(wxThread::IsMain());
|
||||
if (!pending_error.empty()) {
|
||||
handle_error(pending_error);
|
||||
pending_error.clear();
|
||||
if (!pending_errors.empty()) {
|
||||
handle_error(pending_errors);
|
||||
pending_errors.clear();
|
||||
}
|
||||
if (!pending_warnings.empty()) {
|
||||
handle_warning(pending_warnings);
|
||||
pending_warnings.clear();
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -96,7 +96,10 @@ class ScriptError : public Error {
|
||||
*/
|
||||
void handle_error(const Error& e, bool allow_duplicate = true, bool now = true);
|
||||
|
||||
/// Handle errors that were not handled immediatly in handleError
|
||||
/// Handle a warning by showing a message box
|
||||
void handle_warning(const String& w, bool now = true);
|
||||
|
||||
/// Handle errors and warnings that were not handled immediatly in handleError
|
||||
/** Should be called repeatedly (e.g. in an onIdle event handler) */
|
||||
void handle_pending_errors();
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class Package {
|
||||
bool needSaveAs() const;
|
||||
/// Determines the short name of this package: the filename without path or extension
|
||||
String name() const;
|
||||
/// Return the full name of this package, by default equal to name()
|
||||
/// Return the (user friendly) full name of this package, by default equal to name()
|
||||
virtual String fullName() const;
|
||||
/// Return the absolute filename of this file
|
||||
const String& absoluteFilename() const;
|
||||
|
||||
@@ -41,7 +41,7 @@ void Reader::handleAppVersion() {
|
||||
if (enterBlock(_("mse_version"))) {
|
||||
handle(file_app_version);
|
||||
if (app_version < file_app_version) {
|
||||
wxMessageBox(_ERROR_2_("newer version", filename, file_app_version.toString()), _("Warning"), wxOK | wxICON_EXCLAMATION);
|
||||
handle_warning(_ERROR_2_("newer version", filename, file_app_version.toString()), false);
|
||||
}
|
||||
exitBlock();
|
||||
}
|
||||
@@ -53,7 +53,7 @@ void Reader::warning(const String& msg) {
|
||||
|
||||
void Reader::showWarnings() {
|
||||
if (!warnings.empty()) {
|
||||
wxMessageBox(_("Warnings while reading file:\n") + filename + _("\n") + warnings, _("Warning"), wxOK | wxICON_EXCLAMATION);
|
||||
handle_warning(_("Warnings while reading file:\n") + filename + _("\n") + warnings, false);
|
||||
warnings.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <util/string.hpp>
|
||||
|
||||
class Game;
|
||||
class StyleSheet;
|
||||
class SymbolFont;
|
||||
|
||||
// ----------------------------------------------------------------------------- : Localisation macros
|
||||
|
||||
enum LocaleCategory
|
||||
@@ -37,6 +41,24 @@ enum LocaleCategory
|
||||
/// Translate 'key' in the category 'cat' using the current locale
|
||||
String tr(LocaleCategory cat, const String& key);
|
||||
|
||||
/// Translate 'key' in the for a Game using the current locale
|
||||
String tr(const Game&, const String& key);
|
||||
/// Translate 'key' in the for a StyleSheet using the current locale
|
||||
String tr(const StyleSheet&, const String& key);
|
||||
/// Translate 'key' in the for a SymbolFont using the current locale
|
||||
String tr(const SymbolFont&, const String& key);
|
||||
|
||||
/// Translate 'key' in the for a Game using the current locale
|
||||
/** If the key is not found, use the default value */
|
||||
String tr(const Game&, const String& key, const String& def);
|
||||
/// Translate 'key' in the for a StyleSheet using the current locale
|
||||
/** If the key is not found, use the default value */
|
||||
String tr(const StyleSheet&, const String& key, const String& def);
|
||||
/// Translate 'key' in the for a SymbolFont using the current locale
|
||||
/** If the key is not found, use the default value */
|
||||
String tr(const SymbolFont&, const String& key, const String& def);
|
||||
|
||||
|
||||
/// A localized string for menus/toolbar buttons
|
||||
#define _MENU_(s) tr(LOCALE_CAT_MENU, _(s))
|
||||
/// A localized string for help/statusbar text
|
||||
|
||||
+7
-3
@@ -141,13 +141,17 @@ String cannocial_name_form(const String& str) {
|
||||
ret.reserve(str.size());
|
||||
bool leading = true;
|
||||
FOR_EACH_CONST(c, str) {
|
||||
if ((c == _('_') || c == _(' ')) && !leading) {
|
||||
ret += _(' ');
|
||||
if ((c == _('_') || c == _(' '))) {
|
||||
if (!leading) ret += _(' ');
|
||||
} else {
|
||||
ret += c;
|
||||
leading = false;
|
||||
/*
|
||||
} else if (isAlnum(c) || c == _('-')) {
|
||||
ret += toLower(c);
|
||||
leading = false;
|
||||
} else {
|
||||
// ignore non alpha numeric
|
||||
// ignore non alpha numeric*/
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -331,7 +331,7 @@ String tagged_substr_replace(const String& input, size_t start, size_t end, cons
|
||||
return simplify_tagged(
|
||||
substr_replace(input, start, end,
|
||||
get_tags(input, start, end, true) + // close tags
|
||||
escape(replacement) +
|
||||
replacement +
|
||||
get_tags(input, start, end, false) // open tags
|
||||
));
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ String remove_tag_contents(const String& str, const String& tag);
|
||||
* This function makes sure tags still match. It also attempts to cancel out tags.
|
||||
* This means that when removing "<x>a</x>" nothing is left,
|
||||
* but with input "<x>a" -> "<x>" and "</>a" -> "</>".
|
||||
* Escapes the replacement, i.e. all < in become \1.
|
||||
* Does not escape the replacement.
|
||||
*/
|
||||
String tagged_substr_replace(const String& input, size_t start, size_t end, const String& replacement);
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ enum MenuID {
|
||||
enum ChildMenuID {
|
||||
|
||||
ID_CHILD_MIN = 1000
|
||||
, ID_CHILD_MAX = 2999
|
||||
, ID_CHILD_MAX = 3999
|
||||
|
||||
// Cards menu
|
||||
, ID_CARD_ADD = 1001
|
||||
@@ -106,6 +106,7 @@ enum ChildMenuID {
|
||||
, ID_FORMAT_ITALIC
|
||||
, ID_FORMAT_SYMBOL
|
||||
, ID_FORMAT_REMINDER
|
||||
, ID_INSERT_SYMBOL
|
||||
|
||||
// SymbolSelectEditor toolbar/menu
|
||||
, ID_PART = 2001
|
||||
@@ -146,6 +147,10 @@ enum ChildMenuID {
|
||||
|
||||
// Style
|
||||
, ID_STYLE_USE_FOR_ALL = 3201
|
||||
|
||||
// SymbolFont (Format menu)
|
||||
, ID_INSERT_SYMBOL_MENU_MIN = 3301
|
||||
, ID_INSERT_SYMBOL_MENU_MAX = 3999
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user