mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Reduce coupling between ValueEditors/Viewers and Set and StyleSheet.
- Adding of actions is done with an addAction function
- Files are read from
- getStylePackage for styling stuff (this is stylesheet)
- getLocalPackage for symbol and image values (this was the set)
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@970 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -69,7 +69,6 @@ BEGIN_EVENT_TABLE(TextValueEditorScrollBar, wxEvtHandler)
|
||||
END_EVENT_TABLE ()
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : WordListPos
|
||||
|
||||
class WordListPos : public IntrusivePtrBase<WordListPos> {
|
||||
@@ -770,19 +769,19 @@ void TextValueEditor::doFormat(int type) {
|
||||
size_t ss = selection_start, se = selection_end;
|
||||
switch (type) {
|
||||
case ID_FORMAT_BOLD: {
|
||||
perform(toggle_format_action(card(), valueP(), _("b"), selection_start_i, selection_end_i, selection_start, selection_end, _("Bold")));
|
||||
addAction(toggle_format_action(valueP(), _("b"), selection_start_i, selection_end_i, selection_start, selection_end, _("Bold")));
|
||||
break;
|
||||
}
|
||||
case ID_FORMAT_ITALIC: {
|
||||
perform(toggle_format_action(card(), valueP(), _("i"), selection_start_i, selection_end_i, selection_start, selection_end, _("Italic")));
|
||||
addAction(toggle_format_action(valueP(), _("i"), selection_start_i, selection_end_i, selection_start, selection_end, _("Italic")));
|
||||
break;
|
||||
}
|
||||
case ID_FORMAT_SYMBOL: {
|
||||
perform(toggle_format_action(card(), valueP(), _("sym"), selection_start_i, selection_end_i, selection_start, selection_end, _("Symbols")));
|
||||
addAction(toggle_format_action(valueP(), _("sym"), selection_start_i, selection_end_i, selection_start, selection_end, _("Symbols")));
|
||||
break;
|
||||
}
|
||||
case ID_FORMAT_REMINDER: {
|
||||
perform(new TextToggleReminderAction(card(), valueP(), selection_start_i));
|
||||
addAction(new TextToggleReminderAction(valueP(), selection_start_i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -907,7 +906,7 @@ void TextValueEditor::replaceSelection(const String& replacement, const String&
|
||||
fixSelection();
|
||||
// execute the action before adding it to the stack,
|
||||
// because we want to run scripts before action listeners see the action
|
||||
TextValueAction* action = typing_action(card(), valueP(), selection_start_i, selection_end_i, select_on_undo ? selection_start : selection_end, selection_end, replacement, name);
|
||||
TextValueAction* action = typing_action(valueP(), selection_start_i, selection_end_i, select_on_undo ? selection_start : selection_end, selection_end, replacement, name);
|
||||
if (!action) {
|
||||
// nothing changes, but move the selection anyway
|
||||
moveSelection(TYPE_CURSOR, selection_end);
|
||||
@@ -918,7 +917,7 @@ void TextValueEditor::replaceSelection(const String& replacement, const String&
|
||||
size_t expected_cursor = min(selection_start, selection_end) + untag(replacement).size();
|
||||
// perform the action
|
||||
// NOTE: this calls our onAction, invalidating the text viewer and moving the selection around the new text
|
||||
perform(action);
|
||||
addAction(action);
|
||||
// move cursor
|
||||
{
|
||||
String real_value = untag_for_cursor(value().value());
|
||||
@@ -964,7 +963,7 @@ void TextValueEditor::replaceSelection(const String& replacement, const String&
|
||||
|
||||
void TextValueEditor::tryAutoReplace() {
|
||||
size_t end = selection_start_i;
|
||||
GameSettings& gs = settings.gameSettingsFor(*getSet().game);
|
||||
GameSettings& gs = settings.gameSettingsFor(viewer.getGame());
|
||||
if (!gs.use_auto_replace) return;
|
||||
FOR_EACH(ar, gs.auto_replaces) {
|
||||
if (ar->enabled && ar->match.size() <= end) {
|
||||
@@ -1279,7 +1278,7 @@ void TextValueEditor::findWordLists() {
|
||||
String name = str.substr(pos + 11, type_end - pos - 11);
|
||||
WordListP word_list;
|
||||
// find word list type
|
||||
FOR_EACH(wl, getSet().game->word_lists) {
|
||||
FOR_EACH(wl, viewer.getGame().word_lists) {
|
||||
if (wl->name == name) {
|
||||
word_list = wl;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user