mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
check for duplicate pack names
don't allow a new pack to be 'removed' git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1330 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -779,6 +779,11 @@ error:
|
|||||||
# Stats panel
|
# Stats panel
|
||||||
dimension not found: There is no statistics dimension '%s'
|
dimension not found: There is no statistics dimension '%s'
|
||||||
|
|
||||||
|
# Random packs
|
||||||
|
pack type duplicate name:
|
||||||
|
There is already a pack type named '%s'.
|
||||||
|
Please choose a different name.
|
||||||
|
|
||||||
# Package update window
|
# Package update window
|
||||||
# checking updates: Checking for updates.
|
# checking updates: Checking for updates.
|
||||||
can't download installer:
|
can't download installer:
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ void PackAmountPicker::destroy(wxFlexGridSizer* sizer) {
|
|||||||
|
|
||||||
class CustomPackDialog : public wxDialog {
|
class CustomPackDialog : public wxDialog {
|
||||||
public:
|
public:
|
||||||
CustomPackDialog(Window* parent, const SetP& set, const PackTypeP& edited_pack);
|
CustomPackDialog(Window* parent, const SetP& set, const PackTypeP& edited_pack, bool can_remove);
|
||||||
PackTypeP get() const { return edited_pack; }
|
PackTypeP get() const { return edited_pack; }
|
||||||
private:
|
private:
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
@@ -314,16 +314,19 @@ class CustomPackDialog : public wxDialog {
|
|||||||
void onAmountChange(wxSpinEvent&);
|
void onAmountChange(wxSpinEvent&);
|
||||||
void onOk(wxCommandEvent&);
|
void onOk(wxCommandEvent&);
|
||||||
void onRemove(wxCommandEvent&);
|
void onRemove(wxCommandEvent&);
|
||||||
|
bool isDuplicateName(const String& name);
|
||||||
};
|
};
|
||||||
|
|
||||||
CustomPackDialog::CustomPackDialog(Window* parent, const SetP& set, const PackTypeP& edited_pack)
|
CustomPackDialog::CustomPackDialog(Window* parent, const SetP& set, const PackTypeP& edited_pack, bool can_remove)
|
||||||
: wxDialog(parent, wxID_ANY, _TITLE_("custom pack"), wxDefaultPosition, wxSize(500,500))
|
: wxDialog(parent, wxID_ANY, _TITLE_("custom pack"), wxDefaultPosition, wxSize(500,500))
|
||||||
, set(set), edited_pack(edited_pack)
|
, set(set), edited_pack(edited_pack)
|
||||||
{
|
{
|
||||||
// init ui
|
// init ui
|
||||||
totals = new PackTotalsPanel(this, wxID_ANY, generator, true);
|
totals = new PackTotalsPanel(this, wxID_ANY, generator, true);
|
||||||
name = new wxTextCtrl(this, wxID_ANY, edited_pack ? edited_pack->name : _("custom pack"));
|
name = new wxTextCtrl(this, wxID_ANY, edited_pack ? edited_pack->name : _("custom pack"));
|
||||||
wxButton* remove = new wxButton(this, ID_REMOVE_ITEM, _BUTTON_("remove item"));
|
wxButton* remove =
|
||||||
|
can_remove ? new wxButton(this, ID_REMOVE_ITEM, _BUTTON_("remove item"))
|
||||||
|
: nullptr;
|
||||||
// init sizer
|
// init sizer
|
||||||
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
||||||
wxSizer* s2 = new wxStaticBoxSizer(wxHORIZONTAL, this, _LABEL_("pack name"));
|
wxSizer* s2 = new wxStaticBoxSizer(wxHORIZONTAL, this, _LABEL_("pack name"));
|
||||||
@@ -341,7 +344,9 @@ CustomPackDialog::CustomPackDialog(Window* parent, const SetP& set, const PackTy
|
|||||||
s3->Add(s5, 1, wxEXPAND | wxLEFT, 8);
|
s3->Add(s5, 1, wxEXPAND | wxLEFT, 8);
|
||||||
s->Add(s3, 0, wxEXPAND | wxALL & ~wxTOP, 8);
|
s->Add(s3, 0, wxEXPAND | wxALL & ~wxTOP, 8);
|
||||||
wxSizer* s6 = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer* s6 = new wxBoxSizer(wxHORIZONTAL);
|
||||||
s6->Add(remove, 0, wxALL & ~wxTOP & ~wxRIGHT, 8);
|
if (can_remove) {
|
||||||
|
s6->Add(remove, 0, wxALL & ~wxTOP & ~wxRIGHT, 8);
|
||||||
|
}
|
||||||
s6->Add(CreateButtonSizer(wxOK | wxCANCEL), 1, wxALL & ~wxTOP, 8);
|
s6->Add(CreateButtonSizer(wxOK | wxCANCEL), 1, wxALL & ~wxTOP, 8);
|
||||||
s->Add(s6, 0, wxEXPAND);
|
s->Add(s6, 0, wxEXPAND);
|
||||||
// add spin controls
|
// add spin controls
|
||||||
@@ -393,7 +398,23 @@ void CustomPackDialog::storePack() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CustomPackDialog::isDuplicateName(const String& name) {
|
||||||
|
FOR_EACH_CONST(pack, set->game->pack_types) {
|
||||||
|
if (pack->name == name) return true;
|
||||||
|
}
|
||||||
|
FOR_EACH_CONST(pack, set->pack_types) {
|
||||||
|
if (pack->name == name) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CustomPackDialog::onOk(wxCommandEvent&) {
|
void CustomPackDialog::onOk(wxCommandEvent&) {
|
||||||
|
// check for duplicates
|
||||||
|
if (isDuplicateName(name->GetValue())) {
|
||||||
|
wxMessageBox(_ERROR_1_("pack type duplicate name",name->GetValue()),_TITLE_("custom pack"),wxOK|wxICON_EXCLAMATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// done
|
||||||
storePack();
|
storePack();
|
||||||
EndModal(wxID_OK);
|
EndModal(wxID_OK);
|
||||||
}
|
}
|
||||||
@@ -579,7 +600,7 @@ void RandomPackPanel::onCommand(int id) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ID_CUSTOM_PACK: {
|
case ID_CUSTOM_PACK: {
|
||||||
CustomPackDialog dlg(this, set, PackTypeP());
|
CustomPackDialog dlg(this, set, PackTypeP(), false);
|
||||||
if (dlg.ShowModal() == wxID_OK) {
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
set->actions.addAction( new AddPackAction(ADD,*set,dlg.get()) );
|
set->actions.addAction( new AddPackAction(ADD,*set,dlg.get()) );
|
||||||
}
|
}
|
||||||
@@ -591,7 +612,7 @@ void RandomPackPanel::onPackTypeClick(wxCommandEvent& ev) {
|
|||||||
FOR_EACH(pick, pickers) {
|
FOR_EACH(pick, pickers) {
|
||||||
if (pick.label == ev.GetEventObject()) {
|
if (pick.label == ev.GetEventObject()) {
|
||||||
// edit this pack type
|
// edit this pack type
|
||||||
CustomPackDialog dlg(this, set, pick.pack);
|
CustomPackDialog dlg(this, set, pick.pack, true);
|
||||||
if (dlg.ShowModal() == wxID_OK) {
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
if (dlg.get()) {
|
if (dlg.get()) {
|
||||||
// update pack
|
// update pack
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 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 Sat Jan 10 02:30:34 2009
|
# Generated on Sat Jan 10 02:51:15 2009
|
||||||
|
|
||||||
action:
|
action:
|
||||||
add control point: 0
|
add control point: 0
|
||||||
@@ -124,6 +124,7 @@ error:
|
|||||||
no stylesheet specified for the set: 0
|
no stylesheet specified for the set: 0
|
||||||
no updates: 0
|
no updates: 0
|
||||||
pack item not found: 1
|
pack item not found: 1
|
||||||
|
pack type duplicate name: 1
|
||||||
pack type not found: 1
|
pack type not found: 1
|
||||||
package not found: 1
|
package not found: 1
|
||||||
package out of date: 3
|
package out of date: 3
|
||||||
|
|||||||
Reference in New Issue
Block a user