diff --git a/data/en.mse-locale/locale b/data/en.mse-locale/locale index d8114e17..90bbec30 100644 --- a/data/en.mse-locale/locale +++ b/data/en.mse-locale/locale @@ -190,6 +190,14 @@ help: website: 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 app language: Note: You must restart MSE for the changes to take effect. @@ -414,6 +422,7 @@ label: # Random pack panel pack selection: Pack selection pack totals: Totals + seed: Seed # Open dialogs all files All files @@ -527,6 +536,8 @@ button: # Random pack panel generate pack: &Generate Pack + random seed: &Random Seed + fixed seed: &Fixed Seed # Welcome new set: New set @@ -741,7 +752,7 @@ error: When you open it, some aspects of the file may be lost. It is recommended that you upgrade to the latest version. Visit http:://magicseteditor.sourceforge.net/ - word list type not found: The word list type %s was not found (from a tag) + word list type not found: The word list type "%s" was not found (from a tag) # Update checking checking updates failed: Checking updates failed. diff --git a/src/gui/set/cards_panel.cpp b/src/gui/set/cards_panel.cpp index bf8e238c..e690fbf5 100644 --- a/src/gui/set/cards_panel.cpp +++ b/src/gui/set/cards_panel.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -183,6 +184,7 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) { case ID_COLLAPSE_NOTES: { bool collapse = notes->GetSize().y > 0; collapse_notes->loadBitmaps(collapse ? _("btn_collapse") : _("btn_expand")); + static_cast(GetParent())->setControlStatusText(collapse_notes, collapse ? _HELP_("collapse notes") : _HELP_("expand notes")); break; } case ID_INSERT_SYMBOL: { diff --git a/src/gui/set/random_pack_panel.cpp b/src/gui/set/random_pack_panel.cpp index 9038629e..9fda41ac 100644 --- a/src/gui/set/random_pack_panel.cpp +++ b/src/gui/set/random_pack_panel.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -16,6 +17,7 @@ DECLARE_TYPEOF_COLLECTION(PackTypeP); DECLARE_TYPEOF_COLLECTION(CardP); +DECLARE_TYPEOF_COLLECTION(RandomPackPanel::PackItem_for_typeof); // ----------------------------------------------------------------------------- : RandomCardList @@ -73,6 +75,9 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id) wxRadioButton* seed_random = new wxRadioButton(this, wxID_ANY, _BUTTON_("random seed")); wxRadioButton* seed_fixed = new wxRadioButton(this, wxID_ANY, _BUTTON_("fixed seed")); seed = new wxTextCtrl(this, wxID_ANY); + static_cast(parent)->setControlStatusText(seed_random, _HELP_("random seed")); + static_cast(parent)->setControlStatusText(seed_fixed, _HELP_("fixed seed")); + static_cast(parent)->setControlStatusText(seed, _HELP_("seed")); // init sizer wxSizer* s = new wxBoxSizer(wxHORIZONTAL); s->Add(preview, 0, wxRIGHT, 2); @@ -81,7 +86,7 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id) wxSizer* s4 = new wxStaticBoxSizer(wxHORIZONTAL, this, _LABEL_("pack selection")); packsSizer = new wxFlexGridSizer(0, 2, 4, 8); packsSizer->AddGrowableCol(0); - s4->AddSpacer(2); + //s4->AddSpacer(2); s4->Add(packsSizer, 1, wxEXPAND | wxALL & ~wxTOP, 4); s3->Add(s4, 1, wxEXPAND, 8); wxSizer* s5 = new wxStaticBoxSizer(wxHORIZONTAL, this, _LABEL_("pack totals")); @@ -94,8 +99,9 @@ RandomPackPanel::RandomPackPanel(Window* parent, int id) s8->Add(seed, 1, wxLEFT, 20); s7->Add(s8, 0, wxALL & ~wxTOP, 4); s6->Add(s7, 0, 0, 8); - s6->AddStretchSpacer(); - s6->Add(generate, 0, wxTOP | wxALIGN_RIGHT, 8); + //s6->AddStretchSpacer(); + //s6->Add(generate, 0, wxTOP | wxALIGN_RIGHT, 8); + s6->Add(generate, 1, wxTOP | wxEXPAND, 8); s3->Add(s6, 0, wxEXPAND | wxLEFT, 8); s2->Add(s3, 0, wxEXPAND | wxALL & ~wxTOP, 4); s2->Add(card_list, 1, wxEXPAND); @@ -108,7 +114,15 @@ void RandomPackPanel::onChangeSet() { preview ->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 FOR_EACH(pack, set->game->pack_types) { PackItem i; diff --git a/src/gui/set/random_pack_panel.hpp b/src/gui/set/random_pack_panel.hpp index 6f34f2fe..df0fbc6a 100644 --- a/src/gui/set/random_pack_panel.hpp +++ b/src/gui/set/random_pack_panel.hpp @@ -58,6 +58,8 @@ class RandomPackPanel : public SetWindowPanel { /// Generate the cards void generate(); + public: + typedef PackItem PackItem_for_typeof; }; // ----------------------------------------------------------------------------- : EOF diff --git a/src/gui/set/window.cpp b/src/gui/set/window.cpp index f8c41b65..d68da9c0 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -245,6 +245,32 @@ void SetWindow::selectPanel(int id) { 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 vector SetWindow::set_windows; diff --git a/src/gui/set/window.hpp b/src/gui/set/window.hpp index d79e16b1..537f5565 100644 --- a/src/gui/set/window.hpp +++ b/src/gui/set/window.hpp @@ -35,7 +35,7 @@ class SetWindow : public wxFrame, public SetView { DECLARE_EVENT_TABLE(); // --------------------------------------------------- : Data - + // gui items vector panels; ///< All panels on this window SetWindowPanel* current_panel; @@ -62,13 +62,22 @@ class SetWindow : public wxFrame, public SetView { /// All opened set windows static vector set_windows; - + /// Is this the only window that has this set? bool isOnlyWithSet(); /// Switch this window to the new set, or open another window for it (depending on the settings) 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 > control_status_texts; + void onControlEnter(wxMouseEvent&); + void onControlLeave(wxMouseEvent&); + // --------------------------------------------------- : Action related protected: /// We want to respond to set changes diff --git a/src/resource/common/expected_locale_keys b/src/resource/common/expected_locale_keys index 2580af37..520b158b 100644 --- a/src/resource/common/expected_locale_keys +++ b/src/resource/common/expected_locale_keys @@ -1,6 +1,6 @@ # This file contains the keys expected to be in MSE locales # 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: add control point: 0 @@ -49,6 +49,7 @@ button: don't install package: 0 edit symbol: 0 enabled: 0 + fixed seed: 0 generate pack: 0 hide: 0 high quality: 0 @@ -67,6 +68,7 @@ button: number overwrite: 0 open set: 0 overwrite: 0 + random seed: 0 refer parameter: 0 remove group: optional, 0 remove item: 0 @@ -146,6 +148,7 @@ help: check updates: 0 click to select shape: 0 close symbol editor: 0 + collapse notes: 0 copies: 0 copy: 0 copy card: 0 @@ -169,6 +172,7 @@ help: duplicate: 0 ellipse: 0 exit: 0 + expand notes: 0 export: 0 export apprentice: 0 export html: 0 @@ -178,6 +182,7 @@ help: filename format: 0 find: 0 find next: 0 + fixed seed: 0 free point: 0 grid: 0 group: 0 @@ -210,6 +215,7 @@ help: print: 0 print preview: 0 random pack tab: 0 + random seed: 0 rectangle: 0 redo: 0 reflection: 0 @@ -232,6 +238,7 @@ help: save symbol as: 0 scatter: 0 scatter pie: 0 + seed: 0 select: 0 set code: 0 set info tab: 0 @@ -301,6 +308,7 @@ label: result: 0 rules: 0 save changes: 1 + seed: 0 select cards print: 0 select columns: 0 selection: 0 diff --git a/src/script/functions/basic.cpp b/src/script/functions/basic.cpp index 195cfb03..d14cf706 100644 --- a/src/script/functions/basic.cpp +++ b/src/script/functions/basic.cpp @@ -104,8 +104,11 @@ SCRIPT_FUNCTION(to_int) { result = (c.Red() + c.Blue() + c.Green()) / 3; } else if (t == SCRIPT_STRING) { long l; - if (input->toString().ToLong(&l)) { + String str = input->toString(); + if (str.ToLong(&l)) { result = l; + } else if (str.empty()) { + result = 0; } else { return new_intrusive1(_ERROR_3_("can't convert value", input->toString(), input->typeName(), _TYPE_("integer"))); } @@ -137,6 +140,8 @@ SCRIPT_FUNCTION(to_number) { SCRIPT_RETURN( (c.Red() + c.Blue() + c.Green()) / 3 ); } else if (t == SCRIPT_DOUBLE) { SCRIPT_RETURN((double)*input); + } else if (t == SCRIPT_NIL) { + SCRIPT_RETURN(0); } else { String s = input->toString(); long l; double d; @@ -144,6 +149,8 @@ SCRIPT_FUNCTION(to_number) { SCRIPT_RETURN((int)l); } else if (s.ToDouble(&d)) { SCRIPT_RETURN((double)d); + } else if (s.empty()) { + SCRIPT_RETURN(0); } else { return delayError(_ERROR_2_("can't convert", input->typeName(), _TYPE_("double"))); }