diff --git a/src/data/action/keyword.cpp b/src/data/action/keyword.cpp index 3ae6dd05..39d81d41 100644 --- a/src/data/action/keyword.cpp +++ b/src/data/action/keyword.cpp @@ -160,7 +160,7 @@ void KeywordReminderTextValue::highlight(const String& code) { size_t end = code.find_first_not_of(_("0123456789"), pos + 5); if (end == String::npos) end = code.size(); String param = code.substr(pos, end-pos); - new_value += _("<") + param + _(">") + param + _(""); + new_value += _("") + param + _(""); pos = end; } else { new_value += c; diff --git a/src/data/field/text.cpp b/src/data/field/text.cpp index 27cd803a..970ce3ad 100644 --- a/src/data/field/text.cpp +++ b/src/data/field/text.cpp @@ -115,20 +115,24 @@ FakeTextValue::FakeTextValue(const TextFieldP& field, String* underlying, bool e {} void FakeTextValue::store() { - if (editable) { - *underlying = untagged ? untag(value) : value; - } else { - retrieve(); + if (underlying) { + if (editable) { + *underlying = untagged ? untag(value) : value; + } else { + retrieve(); + } } } void FakeTextValue::retrieve() { - value.assign(untagged ? escape(*underlying) : *underlying); + if (underlying) { + value.assign(untagged ? escape(*underlying) : *underlying); + } else { + value.assign(wxEmptyString); + } } void FakeTextValue::onAction(Action& a, bool undone) { - if (underlying) { - store(); - } + store(); } bool FakeTextValue::equals(const Value* that) { diff --git a/src/data/keyword.cpp b/src/data/keyword.cpp index 7cf6a144..84598163 100644 --- a/src/data/keyword.cpp +++ b/src/data/keyword.cpp @@ -52,7 +52,7 @@ void read_compat(Reader& tag, Keyword* k) { k->match += separator.substr(start + 1, end - start - 1); } if (!parameter.empty()) { - k->match += _("") + parameter + _(""); + k->match += _("") + parameter + _(""); } } @@ -120,7 +120,7 @@ void Keyword::prepare(const vector& param_types, bool force) { // Parse the 'match' string for (size_t i = 0 ; i < match.size() ;) { Char c = match.GetChar(i); - if (is_substr(match, i, _("insertAnyStar(); for (size_t i = 0 ; i < kw.match.size() ;) { Char c = kw.match.GetChar(i); - if (is_substr(kw.match, i, _("insertAnyStar(); i = match_close_tag_end(kw.match, i); diff --git a/src/data/keyword.hpp b/src/data/keyword.hpp index 6ac88ce7..63f5ce65 100644 --- a/src/data/keyword.hpp +++ b/src/data/keyword.hpp @@ -58,7 +58,7 @@ class Keyword { String keyword; ///< The keyword, only for human use String rules; ///< Rules/explanation - String match; ///< String to match, tags are used for parameters + String match; ///< String to match, tags are used for parameters vector parameters; ///< The types of parameters StringScript reminder; ///< Reminder text of the keyword String mode; ///< Mode of use, can be used by scripts (only gives the name) diff --git a/src/gui/control/keyword_list.cpp b/src/gui/control/keyword_list.cpp index 9fe8465a..56a3d200 100644 --- a/src/gui/control/keyword_list.cpp +++ b/src/gui/control/keyword_list.cpp @@ -99,8 +99,8 @@ void KeywordList::onAction(const Action& action, bool undone) { String match_string(const Keyword& a) { return untag(replace_all(replace_all( a.match, - _(""), _("‹")), - _(""), _("›")) + _(""), _("‹")), + _(""), _("›")) ); } diff --git a/src/gui/control/native_look_editor.cpp b/src/gui/control/native_look_editor.cpp index 387c9026..91b63f8f 100644 --- a/src/gui/control/native_look_editor.cpp +++ b/src/gui/control/native_look_editor.cpp @@ -91,6 +91,7 @@ void NativeLookEditor::resizeViewers() { } void NativeLookEditor::onInit() { + DataEditor::onInit(); // Give viewers a chance to show/hide controls (scrollbar) when selecting other editors FOR_EACH_EDITOR { e->onShow(true); @@ -191,7 +192,6 @@ StylingEditor::StylingEditor(Window* parent, int id, long style) {} void StylingEditor::showStylesheet(const StyleSheetP& stylesheet) { - this->stylesheet = stylesheet; setStyles(set->stylesheet, stylesheet->styling_style); setData(set->stylingDataFor(*stylesheet)); } diff --git a/src/gui/control/native_look_editor.hpp b/src/gui/control/native_look_editor.hpp index dd9bf93b..a1a90d71 100644 --- a/src/gui/control/native_look_editor.hpp +++ b/src/gui/control/native_look_editor.hpp @@ -72,8 +72,6 @@ class StylingEditor : public NativeLookEditor { protected: virtual void onChangeSet(); - private: - StyleSheetP stylesheet; ///< The stylesheet for which we are showing the styling data }; // ----------------------------------------------------------------------------- : EOF diff --git a/src/gui/set/keywords_panel.cpp b/src/gui/set/keywords_panel.cpp index 1209c81c..d4971291 100644 --- a/src/gui/set/keywords_panel.cpp +++ b/src/gui/set/keywords_panel.cpp @@ -12,12 +12,15 @@ #include #include #include +#include #include #include #include #include #include #include +#include +#include // ----------------------------------------------------------------------------- : KeywordsPanel @@ -32,25 +35,42 @@ KeywordsPanel::KeywordsPanel(Window* parent, int id) match = new TextCtrl(panel, wxID_ANY, false); reminder = new TextCtrl(panel, wxID_ANY, true); // allow multiline for wordwrap rules = new TextCtrl(panel, wxID_ANY, true); - fixed = new wxStaticText(panel, wxID_ANY, _("This is a standard $game keyword, you can not edit it. ") - _("If you make a copy of the keyword your copy will take precedent.")); errors = new wxStaticText(panel, wxID_ANY, _("")); + // warning about fixed keywords + fixedL = new wxStaticText(panel, wxID_ANY, _("")); + wxStaticBitmap* fixedI = new wxStaticBitmap(panel, wxID_ANY, wxArtProvider::GetBitmap(wxART_WARNING)); + fixed = new wxBoxSizer(wxVERTICAL); + wxSizer* s0 = new wxBoxSizer(wxHORIZONTAL); + s0->Add(fixedI, 0, wxALIGN_CENTER | wxRIGHT, 10); + s0->Add(fixedL, 0, wxALIGN_CENTER_VERTICAL); + fixed->Add(new wxStaticLine(panel), 0, wxEXPAND | wxBOTTOM, 8); + fixed->Add(s0, 0, wxALL & ~wxTOP | wxALIGN_CENTER, 8); + fixed->Add(new wxStaticLine(panel), 0, wxEXPAND | wxBOTTOM, 8); // init sizer for panel sp = new wxBoxSizer(wxVERTICAL); - sp->Add(fixed, 0, wxALL, 6); - sp->Add(new wxStaticText(panel, wxID_ANY, _("Keyword:")), 0, wxALL, 6); - sp->Add(keyword, 0, wxEXPAND | wxALL & ~wxTOP, 6); - wxSizer* s2 = new wxStaticBoxSizer(wxVERTICAL, panel, _("Match")); - s2->Add(new wxStaticText(panel, wxID_ANY, _("Keyword format:")), 0, wxALL, 6); - s2->Add(match, 0, wxEXPAND | wxALL & ~wxTOP, 6); - s2->Add(new wxStaticText(panel, wxID_ANY, _("Parameters:")), 0, wxALL, 6); - sp->Add(s2, 0, wxEXPAND | wxALL, 6); - sp->Add(new wxStaticText(panel, wxID_ANY, _("Reminder:")), 0, wxALL, 6); - sp->Add(reminder, 1, wxEXPAND | wxALL & ~wxTOP, 6); - sp->Add(errors, 0, wxALL & ~wxTOP, 6); - sp->Add(new wxStaticText(panel, wxID_ANY, _("Example:")), 0, wxALL, 6); - sp->Add(new wxStaticText(panel, wxID_ANY, _("Rules:")), 0, wxALL, 6); - sp->Add(rules, 1, wxEXPAND | wxALL & ~wxTOP, 6); + sp->Add(fixed, 0, wxEXPAND); sp->Show(fixed,false); + wxSizer* s1 = new wxBoxSizer(wxVERTICAL); + s1->Add(new wxStaticText(panel, wxID_ANY, _("Keyword:")), 0); + s1->Add(keyword, 0, wxEXPAND | wxTOP, 2); + sp->Add(s1, 0, wxEXPAND | wxLEFT, 2); + sp->Add(new wxStaticLine(panel), 0, wxEXPAND | wxTOP | wxBOTTOM, 8); + wxSizer* s2 = new wxBoxSizer(wxVERTICAL); + s2->Add(new wxStaticText(panel, wxID_ANY, _("Match:")), 0); + s2->Add(match, 0, wxEXPAND | wxTOP, 2); + s2->Add(new wxStaticText(panel, wxID_ANY, _("Parameters:")), 0, wxTOP, 6); + sp->Add(s2, 0, wxEXPAND | wxLEFT, 2); + sp->Add(new wxStaticLine(panel), 0, wxEXPAND | wxTOP | wxBOTTOM, 8); + wxSizer* s3 = new wxBoxSizer(wxVERTICAL); + s3->Add(new wxStaticText(panel, wxID_ANY, _("Reminder:")), 0); + s3->Add(reminder, 1, wxEXPAND | wxTOP, 2); + s3->Add(errors, 0, wxEXPAND | wxTOP, 4); + s3->Add(new wxStaticText(panel, wxID_ANY, _("Example:")), 0, wxTOP, 6); + sp->Add(s3, 1, wxEXPAND | wxLEFT, 2); + sp->Add(new wxStaticLine(panel), 0, wxEXPAND | wxTOP | wxBOTTOM, 8); + wxSizer* s4 = new wxBoxSizer(wxVERTICAL); + s4->Add(new wxStaticText(panel, wxID_ANY, _("Rules:")), 0); + s4->Add(rules, 1, wxEXPAND | wxTOP, 2); + sp->Add(s4, 1, wxEXPAND | wxLEFT, 2); panel->SetSizer(sp); // init splitter splitter->SetMinimumPaneSize(100); @@ -135,6 +155,8 @@ void KeywordsPanel::onCommand(int id) { void KeywordsPanel::onChangeSet() { list->setSet(set); + // warning label (depends on game name) + fixedL->SetLabel(format_string(_LABEL_("standard keyword"), set->game->short_name)); // init text controls keyword ->setSet(set); keyword ->getStyle().font.size = 16; @@ -169,17 +191,14 @@ void KeywordsPanel::onAction(const Action& action, bool undone) { void KeywordsPanel::onKeywordSelect(KeywordSelectEvent& ev) { if (ev.keyword) { Keyword& kw = *ev.keyword; - //sp->Show(fixed, kw.fixed); - fixed->SetLabel(kw.fixed ? _("This is a standard $game keyword, you can not edit it. ") - _("If you make a copy of the keyword your copy will take precedent.") - : _("")); - Layout(); + sp->Show(fixed, kw.fixed); keyword ->setValue(new_shared5 (keyword->getFieldP(), &kw, &kw.keyword, !kw.fixed, true)); match ->setValue(new_shared4 (match->getFieldP(), &kw, &kw.match, !kw.fixed)); rules ->setValue(new_shared4 (rules->getFieldP(), &kw, &kw.rules, !kw.fixed)); shared_ptr reminder_value(new KeywordReminderTextValue(reminder->getFieldP(), &kw, !kw.fixed)); reminder->setValue(reminder_value); errors->SetLabel(reminder_value->errors); + sp->Layout(); } else { keyword ->setValue(nullptr); match ->setValue(nullptr); diff --git a/src/gui/set/keywords_panel.hpp b/src/gui/set/keywords_panel.hpp index 46f0d961..1dbd3f39 100644 --- a/src/gui/set/keywords_panel.hpp +++ b/src/gui/set/keywords_panel.hpp @@ -49,8 +49,16 @@ class KeywordsPanel : public SetWindowPanel { TextCtrl* reminder; TextCtrl* rules; IconMenu* menuKeyword; - wxStaticText* fixed; + wxStaticText* fixedL; + wxSizer* fixed; wxStaticText* errors; + /// Controls to edit a parameter + struct ParamEditor { + wxStaticText* label; + wxChoice* type; + bool shown; + }; + vector params; // --------------------------------------------------- : Events void onKeywordSelect(KeywordSelectEvent& ev); diff --git a/src/gui/set/style_panel.cpp b/src/gui/set/style_panel.cpp index f82c60e8..53185bd2 100644 --- a/src/gui/set/style_panel.cpp +++ b/src/gui/set/style_panel.cpp @@ -53,10 +53,12 @@ void StylePanel::onChangeSet() { void StylePanel::onAction(const Action& action, bool undone) { TYPE_CASE_(action, ChangeSetStyleAction) { list->select(set->stylesheetFor(card)->name(), false); + editor->showStylesheet(set->stylesheetFor(card)); } TYPE_CASE(action, ChangeCardStyleAction) { if (action.card == card) { list->select(set->stylesheetFor(card)->name(), false); + editor->showStylesheet(set->stylesheetFor(card)); } } use_for_all->Enable(card && card->stylesheet); @@ -67,6 +69,7 @@ void StylePanel::onAction(const Action& action, bool undone) { void StylePanel::selectCard(const CardP& card) { this->card = card; preview->setCard(card); + editor->showStylesheet(set->stylesheetFor(card)); list->select(set->stylesheetFor(card)->name(), false); use_for_all->Enable(card && card->stylesheet); } diff --git a/src/render/text/element.cpp b/src/render/text/element.cpp index 3e58c0ff..e233cf9e 100644 --- a/src/render/text/element.cpp +++ b/src/render/text/element.cpp @@ -57,7 +57,7 @@ double TextElements::scaleStep() const { return m; } -// Colors for tags +// Colors for tags Color param_colors[] = { Color(0,170,0) , Color(0,0,200) @@ -109,19 +109,19 @@ struct TextElementsFromString { else if (is_substr(text, tag_start, _(" + // from a tag if (pos != String::npos) { - String ref = text.substr(tag_start + 6, pos - tag_start - 7); + String ref = text.substr(tag_start + 10, pos - tag_start - 11); long ref_n; if (ref.ToLong(&ref_n)) { - param_id = ref_n; + param_id = (ref_n - 1)%param_colors_count + param_colors_count; } } param_ref += 1; } else if (is_substr(text, tag_start, _("