mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
Working on the keywords panel;
Correct styling data now shown on style panel git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@259 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -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,
|
||||
_("<param>"), _("‹")),
|
||||
_("</param>"), _("›"))
|
||||
_("<atom-param>"), _("‹")),
|
||||
_("</atom-param>"), _("›"))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -12,12 +12,15 @@
|
||||
#include <gui/icon_menu.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/keyword.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/action/value.hpp>
|
||||
#include <data/action/keyword.hpp>
|
||||
#include <data/field/text.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/splitter.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/artprov.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : 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<KeywordTextValue> (keyword->getFieldP(), &kw, &kw.keyword, !kw.fixed, true));
|
||||
match ->setValue(new_shared4<KeywordTextValue> (match->getFieldP(), &kw, &kw.match, !kw.fixed));
|
||||
rules ->setValue(new_shared4<KeywordTextValue> (rules->getFieldP(), &kw, &kw.rules, !kw.fixed));
|
||||
shared_ptr<KeywordReminderTextValue> 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);
|
||||
|
||||
@@ -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<ParamEditor> params;
|
||||
|
||||
// --------------------------------------------------- : Events
|
||||
void onKeywordSelect(KeywordSelectEvent& ev);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user