Commit b61d3401 authored by twanvl's avatar twanvl

- Added SetWindow::setControlStatusText function for setting the status text...

- Added SetWindow::setControlStatusText function for setting the status text of child controls, since wx lacks a feature for doing it automatically.
- RandomPackPanel's spin controls are cleaned up when the set is reloaded
- to_int script function now converts empty string: to_int("") == 0
parent 8c90f3b9
...@@ -190,6 +190,14 @@ help: ...@@ -190,6 +190,14 @@ help:
website: website:
about: about:
# Cards panel
collapse notes: Hide the card notes box
expand notes: Show the card notes box
# Random pack panel
random seed: Different packs will be generated each time.
fixed seed: Using the same seed number gives the same 'random' packs.
seed: Seed number for the random generator. Using the same seed number gives the same 'random' packs.
# Preferences # Preferences
app language: app language:
Note: You must restart MSE for the changes to take effect. Note: You must restart MSE for the changes to take effect.
...@@ -414,6 +422,7 @@ label: ...@@ -414,6 +422,7 @@ label:
# Random pack panel # Random pack panel
pack selection: Pack selection pack selection: Pack selection
pack totals: Totals pack totals: Totals
seed: Seed
# Open dialogs # Open dialogs
all files All files all files All files
...@@ -527,6 +536,8 @@ button: ...@@ -527,6 +536,8 @@ button:
# Random pack panel # Random pack panel
generate pack: &Generate Pack generate pack: &Generate Pack
random seed: &Random Seed
fixed seed: &Fixed Seed
# Welcome # Welcome
new set: New set new set: New set
...@@ -741,7 +752,7 @@ error: ...@@ -741,7 +752,7 @@ error:
When you open it, some aspects of the file may be lost. When you open it, some aspects of the file may be lost.
It is recommended that you upgrade to the latest version. It is recommended that you upgrade to the latest version.
Visit http:://magicseteditor.sourceforge.net/ Visit http:://magicseteditor.sourceforge.net/
word list type not found: The word list type %s was not found (from a <word-list> tag) word list type not found: The word list type "%s" was not found (from a <word-list> tag)
# Update checking # Update checking
checking updates failed: Checking updates failed. checking updates failed: Checking updates failed.
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <util/prec.hpp> #include <util/prec.hpp>
#include <gui/set/cards_panel.hpp> #include <gui/set/cards_panel.hpp>
#include <gui/set/window.hpp>
#include <gui/control/image_card_list.hpp> #include <gui/control/image_card_list.hpp>
#include <gui/control/card_editor.hpp> #include <gui/control/card_editor.hpp>
#include <gui/control/text_ctrl.hpp> #include <gui/control/text_ctrl.hpp>
...@@ -183,6 +184,7 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) { ...@@ -183,6 +184,7 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
case ID_COLLAPSE_NOTES: { case ID_COLLAPSE_NOTES: {
bool collapse = notes->GetSize().y > 0; bool collapse = notes->GetSize().y > 0;
collapse_notes->loadBitmaps(collapse ? _("btn_collapse") : _("btn_expand")); collapse_notes->loadBitmaps(collapse ? _("btn_collapse") : _("btn_expand"));
static_cast<SetWindow*>(GetParent())->setControlStatusText(collapse_notes, collapse ? _HELP_("collapse notes") : _HELP_("expand notes"));
break; break;
} }
case ID_INSERT_SYMBOL: { case ID_INSERT_SYMBOL: {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <util/prec.hpp> #include <util/prec.hpp>
#include <gui/set/random_pack_panel.hpp> #include <gui/set/random_pack_panel.hpp>
#include <gui/set/window.hpp>
#include <gui/control/card_viewer.hpp> #include <gui/control/card_viewer.hpp>
#include <gui/control/filtered_card_list.hpp> #include <gui/control/filtered_card_list.hpp>
#include <data/game.hpp> #include <data/game.hpp>
...@@ -16,6 +17,7 @@ ...@@ -16,6 +17,7 @@
DECLARE_TYPEOF_COLLECTION(PackTypeP); DECLARE_TYPEOF_COLLECTION(PackTypeP);
DECLARE_TYPEOF_COLLECTION(CardP); DECLARE_TYPEOF_COLLECTION(CardP);
DECLARE_TYPEOF_COLLECTION(RandomPackPanel::PackItem_for_typeof);
// ----------------------------------------------------------------------------- : RandomCardList // ----------------------------------------------------------------------------- : RandomCardList
...@@ -73,6 +75,9 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id) ...@@ -73,6 +75,9 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id)
wxRadioButton* seed_random = new wxRadioButton(this, wxID_ANY, _BUTTON_("random seed")); wxRadioButton* seed_random = new wxRadioButton(this, wxID_ANY, _BUTTON_("random seed"));
wxRadioButton* seed_fixed = new wxRadioButton(this, wxID_ANY, _BUTTON_("fixed seed")); wxRadioButton* seed_fixed = new wxRadioButton(this, wxID_ANY, _BUTTON_("fixed seed"));
seed = new wxTextCtrl(this, wxID_ANY); seed = new wxTextCtrl(this, wxID_ANY);
static_cast<SetWindow*>(parent)->setControlStatusText(seed_random, _HELP_("random seed"));
static_cast<SetWindow*>(parent)->setControlStatusText(seed_fixed, _HELP_("fixed seed"));
static_cast<SetWindow*>(parent)->setControlStatusText(seed, _HELP_("seed"));
// init sizer // init sizer
wxSizer* s = new wxBoxSizer(wxHORIZONTAL); wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
s->Add(preview, 0, wxRIGHT, 2); s->Add(preview, 0, wxRIGHT, 2);
...@@ -81,7 +86,7 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id) ...@@ -81,7 +86,7 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id)
wxSizer* s4 = new wxStaticBoxSizer(wxHORIZONTAL, this, _LABEL_("pack selection")); wxSizer* s4 = new wxStaticBoxSizer(wxHORIZONTAL, this, _LABEL_("pack selection"));
packsSizer = new wxFlexGridSizer(0, 2, 4, 8); packsSizer = new wxFlexGridSizer(0, 2, 4, 8);
packsSizer->AddGrowableCol(0); packsSizer->AddGrowableCol(0);
s4->AddSpacer(2); //s4->AddSpacer(2);
s4->Add(packsSizer, 1, wxEXPAND | wxALL & ~wxTOP, 4); s4->Add(packsSizer, 1, wxEXPAND | wxALL & ~wxTOP, 4);
s3->Add(s4, 1, wxEXPAND, 8); s3->Add(s4, 1, wxEXPAND, 8);
wxSizer* s5 = new wxStaticBoxSizer(wxHORIZONTAL, this, _LABEL_("pack totals")); wxSizer* s5 = new wxStaticBoxSizer(wxHORIZONTAL, this, _LABEL_("pack totals"));
...@@ -94,8 +99,9 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id) ...@@ -94,8 +99,9 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id)
s8->Add(seed, 1, wxLEFT, 20); s8->Add(seed, 1, wxLEFT, 20);
s7->Add(s8, 0, wxALL & ~wxTOP, 4); s7->Add(s8, 0, wxALL & ~wxTOP, 4);
s6->Add(s7, 0, 0, 8); s6->Add(s7, 0, 0, 8);
s6->AddStretchSpacer(); //s6->AddStretchSpacer();
s6->Add(generate, 0, wxTOP | wxALIGN_RIGHT, 8); //s6->Add(generate, 0, wxTOP | wxALIGN_RIGHT, 8);
s6->Add(generate, 1, wxTOP | wxEXPAND, 8);
s3->Add(s6, 0, wxEXPAND | wxLEFT, 8); s3->Add(s6, 0, wxEXPAND | wxLEFT, 8);
s2->Add(s3, 0, wxEXPAND | wxALL & ~wxTOP, 4); s2->Add(s3, 0, wxEXPAND | wxALL & ~wxTOP, 4);
s2->Add(card_list, 1, wxEXPAND); s2->Add(card_list, 1, wxEXPAND);
...@@ -108,7 +114,15 @@ void RandomPackPanel::onChangeSet() { ...@@ -108,7 +114,15 @@ void RandomPackPanel::onChangeSet() {
preview ->setSet(set); preview ->setSet(set);
card_list->setSet(set); card_list->setSet(set);
// TODO: remove or reuse old pack controls if there are any. // remove old pack controls
FOR_EACH(i, packs) {
packsSizer->Detach(i.label);
packsSizer->Detach(i.value);
delete i.label;
delete i.value;
}
packs.clear();
// add pack controls // add pack controls
FOR_EACH(pack, set->game->pack_types) { FOR_EACH(pack, set->game->pack_types) {
PackItem i; PackItem i;
......
...@@ -58,6 +58,8 @@ class RandomPackPanel : public SetWindowPanel { ...@@ -58,6 +58,8 @@ class RandomPackPanel : public SetWindowPanel {
/// Generate the cards /// Generate the cards
void generate(); void generate();
public:
typedef PackItem PackItem_for_typeof;
}; };
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
......
...@@ -245,6 +245,32 @@ void SetWindow::selectPanel(int id) { ...@@ -245,6 +245,32 @@ void SetWindow::selectPanel(int id) {
current_panel->SetFocus(); current_panel->SetFocus();
} }
// ----------------------------------------------------------------------------- : Status text for controls
void SetWindow::setControlStatusText(wxWindow* control, const String& text) {
for (size_t i = 0 ; i < control_status_texts.size() ; ++i) {
if (control_status_texts[i].first == control) {
control_status_texts[i].second = text;
return;
}
}
control_status_texts.push_back(make_pair(control,text));
control->Connect(wxEVT_ENTER_WINDOW,(wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)onControlEnter,nullptr,this);
control->Connect(wxEVT_LEAVE_WINDOW,(wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)onControlLeave,nullptr,this);
}
void SetWindow::onControlEnter(wxMouseEvent& ev) {
for (size_t i = 0 ; i < control_status_texts.size() ; ++i) {
if (control_status_texts[i].first == ev.GetEventObject()) {
SetStatusText(control_status_texts[i].second);
}
}
ev.Skip();
}
void SetWindow::onControlLeave(wxMouseEvent& ev) {
SetStatusText(wxEmptyString);
ev.Skip();
}
// ----------------------------------------------------------------------------- : Window managment // ----------------------------------------------------------------------------- : Window managment
vector<SetWindow*> SetWindow::set_windows; vector<SetWindow*> SetWindow::set_windows;
......
...@@ -35,7 +35,7 @@ class SetWindow : public wxFrame, public SetView { ...@@ -35,7 +35,7 @@ class SetWindow : public wxFrame, public SetView {
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
// --------------------------------------------------- : Data // --------------------------------------------------- : Data
// gui items // gui items
vector<SetWindowPanel*> panels; ///< All panels on this window vector<SetWindowPanel*> panels; ///< All panels on this window
SetWindowPanel* current_panel; SetWindowPanel* current_panel;
...@@ -62,13 +62,22 @@ class SetWindow : public wxFrame, public SetView { ...@@ -62,13 +62,22 @@ class SetWindow : public wxFrame, public SetView {
/// All opened set windows /// All opened set windows
static vector<SetWindow*> set_windows; static vector<SetWindow*> set_windows;
/// Is this the only window that has this set? /// Is this the only window that has this set?
bool isOnlyWithSet(); bool isOnlyWithSet();
/// Switch this window to the new set, or open another window for it (depending on the settings) /// Switch this window to the new set, or open another window for it (depending on the settings)
void switchSet(const SetP& new_set); void switchSet(const SetP& new_set);
// --------------------------------------------------- : Status text for controls
public:
/// Set the status text of a control
void setControlStatusText(wxWindow* control, const String& text);
private:
vector<pair<wxWindow*,String> > control_status_texts;
void onControlEnter(wxMouseEvent&);
void onControlLeave(wxMouseEvent&);
// --------------------------------------------------- : Action related // --------------------------------------------------- : Action related
protected: protected:
/// We want to respond to set changes /// We want to respond to set changes
......
# This file contains the keys expected to be in MSE locales # This file contains the keys expected to be in MSE locales
# It was automatically generated by tools/locale/locale.pl # It was automatically generated by tools/locale/locale.pl
# Generated on Wed Jun 18 16:31:33 2008 # Generated on Sun Aug 3 21:57:37 2008
action: action:
add control point: 0 add control point: 0
...@@ -49,6 +49,7 @@ button: ...@@ -49,6 +49,7 @@ button:
don't install package: 0 don't install package: 0
edit symbol: 0 edit symbol: 0
enabled: 0 enabled: 0
fixed seed: 0
generate pack: 0 generate pack: 0
hide: 0 hide: 0
high quality: 0 high quality: 0
...@@ -67,6 +68,7 @@ button: ...@@ -67,6 +68,7 @@ button:
number overwrite: 0 number overwrite: 0
open set: 0 open set: 0
overwrite: 0 overwrite: 0
random seed: 0
refer parameter: 0 refer parameter: 0
remove group: optional, 0 remove group: optional, 0
remove item: 0 remove item: 0
...@@ -146,6 +148,7 @@ help: ...@@ -146,6 +148,7 @@ help:
check updates: 0 check updates: 0
click to select shape: 0 click to select shape: 0
close symbol editor: 0 close symbol editor: 0
collapse notes: 0
copies: 0 copies: 0
copy: 0 copy: 0
copy card: 0 copy card: 0
...@@ -169,6 +172,7 @@ help: ...@@ -169,6 +172,7 @@ help:
duplicate: 0 duplicate: 0
ellipse: 0 ellipse: 0
exit: 0 exit: 0
expand notes: 0
export: 0 export: 0
export apprentice: 0 export apprentice: 0
export html: 0 export html: 0
...@@ -178,6 +182,7 @@ help: ...@@ -178,6 +182,7 @@ help:
filename format: 0 filename format: 0
find: 0 find: 0
find next: 0 find next: 0
fixed seed: 0
free point: 0 free point: 0
grid: 0 grid: 0
group: 0 group: 0
...@@ -210,6 +215,7 @@ help: ...@@ -210,6 +215,7 @@ help:
print: 0 print: 0
print preview: 0 print preview: 0
random pack tab: 0 random pack tab: 0
random seed: 0
rectangle: 0 rectangle: 0
redo: 0 redo: 0
reflection: 0 reflection: 0
...@@ -232,6 +238,7 @@ help: ...@@ -232,6 +238,7 @@ help:
save symbol as: 0 save symbol as: 0
scatter: 0 scatter: 0
scatter pie: 0 scatter pie: 0
seed: 0
select: 0 select: 0
set code: 0 set code: 0
set info tab: 0 set info tab: 0
...@@ -301,6 +308,7 @@ label: ...@@ -301,6 +308,7 @@ label:
result: 0 result: 0
rules: 0 rules: 0
save changes: 1 save changes: 1
seed: 0
select cards print: 0 select cards print: 0
select columns: 0 select columns: 0
selection: 0 selection: 0
......
...@@ -104,8 +104,11 @@ SCRIPT_FUNCTION(to_int) { ...@@ -104,8 +104,11 @@ SCRIPT_FUNCTION(to_int) {
result = (c.Red() + c.Blue() + c.Green()) / 3; result = (c.Red() + c.Blue() + c.Green()) / 3;
} else if (t == SCRIPT_STRING) { } else if (t == SCRIPT_STRING) {
long l; long l;
if (input->toString().ToLong(&l)) { String str = input->toString();
if (str.ToLong(&l)) {
result = l; result = l;
} else if (str.empty()) {
result = 0;
} else { } else {
return new_intrusive1<ScriptDelayedError>(_ERROR_3_("can't convert value", input->toString(), input->typeName(), _TYPE_("integer"))); return new_intrusive1<ScriptDelayedError>(_ERROR_3_("can't convert value", input->toString(), input->typeName(), _TYPE_("integer")));
} }
...@@ -137,6 +140,8 @@ SCRIPT_FUNCTION(to_number) { ...@@ -137,6 +140,8 @@ SCRIPT_FUNCTION(to_number) {
SCRIPT_RETURN( (c.Red() + c.Blue() + c.Green()) / 3 ); SCRIPT_RETURN( (c.Red() + c.Blue() + c.Green()) / 3 );
} else if (t == SCRIPT_DOUBLE) { } else if (t == SCRIPT_DOUBLE) {
SCRIPT_RETURN((double)*input); SCRIPT_RETURN((double)*input);
} else if (t == SCRIPT_NIL) {
SCRIPT_RETURN(0);
} else { } else {
String s = input->toString(); String s = input->toString();
long l; double d; long l; double d;
...@@ -144,6 +149,8 @@ SCRIPT_FUNCTION(to_number) { ...@@ -144,6 +149,8 @@ SCRIPT_FUNCTION(to_number) {
SCRIPT_RETURN((int)l); SCRIPT_RETURN((int)l);
} else if (s.ToDouble(&d)) { } else if (s.ToDouble(&d)) {
SCRIPT_RETURN((double)d); SCRIPT_RETURN((double)d);
} else if (s.empty()) {
SCRIPT_RETURN(0);
} else { } else {
return delayError(_ERROR_2_("can't convert", input->typeName(), _TYPE_("double"))); return delayError(_ERROR_2_("can't convert", input->typeName(), _TYPE_("double")));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment