mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
- 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
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1042 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/set/cards_panel.hpp>
|
||||
#include <gui/set/window.hpp>
|
||||
#include <gui/control/image_card_list.hpp>
|
||||
#include <gui/control/card_editor.hpp>
|
||||
#include <gui/control/text_ctrl.hpp>
|
||||
@@ -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<SetWindow*>(GetParent())->setControlStatusText(collapse_notes, collapse ? _HELP_("collapse notes") : _HELP_("expand notes"));
|
||||
break;
|
||||
}
|
||||
case ID_INSERT_SYMBOL: {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/set/random_pack_panel.hpp>
|
||||
#include <gui/set/window.hpp>
|
||||
#include <gui/control/card_viewer.hpp>
|
||||
#include <gui/control/filtered_card_list.hpp>
|
||||
#include <data/game.hpp>
|
||||
@@ -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<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
|
||||
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;
|
||||
|
||||
@@ -58,6 +58,8 @@ class RandomPackPanel : public SetWindowPanel {
|
||||
|
||||
/// Generate the cards
|
||||
void generate();
|
||||
public:
|
||||
typedef PackItem PackItem_for_typeof;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
@@ -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*> SetWindow::set_windows;
|
||||
|
||||
+11
-2
@@ -35,7 +35,7 @@ class SetWindow : public wxFrame, public SetView {
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
// --------------------------------------------------- : Data
|
||||
|
||||
|
||||
// gui items
|
||||
vector<SetWindowPanel*> 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<SetWindow*> 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<pair<wxWindow*,String> > control_status_texts;
|
||||
void onControlEnter(wxMouseEvent&);
|
||||
void onControlLeave(wxMouseEvent&);
|
||||
|
||||
// --------------------------------------------------- : Action related
|
||||
protected:
|
||||
/// We want to respond to set changes
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<ScriptDelayedError>(_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")));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user