mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -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
|
||||
|
||||
Reference in New Issue
Block a user