mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 13:37:00 -04:00
'suffix' is no longer a safe global variable name in scripts;
Drop down list for word lists stay open after clicking on a prefix choice. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@663 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -18,13 +18,13 @@ init script:
|
|||||||
else "g"
|
else "g"
|
||||||
) else input
|
) else input
|
||||||
}
|
}
|
||||||
suffix := [card: "card.jpg", textbox: "textbox.png", typeline: "typeline.png"]
|
template_suffix := [card: "card.jpg", textbox: "textbox.png", typeline: "typeline.png"]
|
||||||
template := { green_template() + suffix[type] }
|
template := { green_template() + template_suffix[type] }
|
||||||
land_template := {
|
land_template := {
|
||||||
(if input == "a" then (
|
(if input == "a" then (
|
||||||
if styling.land_style == "grey" then "e"
|
if styling.land_style == "grey" then "e"
|
||||||
else "c"
|
else "c"
|
||||||
) else green_template()) + "l" + suffix[type] }
|
) else green_template()) + "l" + template_suffix[type] }
|
||||||
|
|
||||||
# Use the normal tap symbol
|
# Use the normal tap symbol
|
||||||
mana_t := {
|
mana_t := {
|
||||||
|
|||||||
@@ -202,9 +202,6 @@ void sharp_downsample(const Image& img_in, Image& img_out, int amount) {
|
|||||||
|
|
||||||
for (int y = 0 ; y < height ; ++y) {
|
for (int y = 0 ; y < height ; ++y) {
|
||||||
for (int x = 0 ; x < width ; ++x) {
|
for (int x = 0 ; x < width ; ++x) {
|
||||||
if (x==150&&y==150) {
|
|
||||||
x=x;//break
|
|
||||||
}
|
|
||||||
// Filter using a kernel of the form
|
// Filter using a kernel of the form
|
||||||
/* -1 -1
|
/* -1 -1
|
||||||
* -1 c c -1
|
* -1 c c -1
|
||||||
|
|||||||
@@ -90,3 +90,13 @@ Image rotate_image(const Image& image, int angle) {
|
|||||||
default: return image;
|
default: return image;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*Bitmap rotate_bitmap(const Bitmap& bitmap, int angle) {
|
||||||
|
switch (angle % 360) {
|
||||||
|
case 90:
|
||||||
|
case 180:
|
||||||
|
case 270:
|
||||||
|
default: return bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer)
|
|||||||
, viewer(viewer)
|
, viewer(viewer)
|
||||||
, hider (is_submenu ? nullptr : new DropDownHider(*this))
|
, hider (is_submenu ? nullptr : new DropDownHider(*this))
|
||||||
, hider2(is_submenu ? nullptr : new DropDownHider(*this))
|
, hider2(is_submenu ? nullptr : new DropDownHider(*this))
|
||||||
|
, close_on_mouse_out(false)
|
||||||
{
|
{
|
||||||
if (is_submenu) {
|
if (is_submenu) {
|
||||||
parent_menu = &dynamic_cast<DropDownList&>(*GetParent());
|
parent_menu = &dynamic_cast<DropDownList&>(*GetParent());
|
||||||
@@ -148,9 +149,9 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) {
|
|||||||
|
|
||||||
void DropDownList::hide(bool event, bool allow_veto) {
|
void DropDownList::hide(bool event, bool allow_veto) {
|
||||||
// hide?
|
// hide?
|
||||||
bool keep_open = event && allow_veto && stayOpen();
|
bool keep_open = event && allow_veto && stayOpen(selected_item);
|
||||||
if (keep_open) {
|
if (keep_open) {
|
||||||
Refresh(false);
|
close_on_mouse_out = true;
|
||||||
} else {
|
} else {
|
||||||
// hide root
|
// hide root
|
||||||
DropDownList* root = this;
|
DropDownList* root = this;
|
||||||
@@ -162,6 +163,7 @@ void DropDownList::hide(bool event, bool allow_veto) {
|
|||||||
// send event
|
// send event
|
||||||
if (event && selected_item != NO_SELECTION && itemEnabled(selected_item)) {
|
if (event && selected_item != NO_SELECTION && itemEnabled(selected_item)) {
|
||||||
select(selected_item);
|
select(selected_item);
|
||||||
|
if (IsShown()) Refresh(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,6 +345,17 @@ void DropDownList::onMotion(wxMouseEvent& ev) {
|
|||||||
hideSubMenu();
|
hideSubMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DropDownList::onMouseLeave(wxMouseEvent& ev) {
|
||||||
|
if (close_on_mouse_out) {
|
||||||
|
wxSize cs = GetClientSize();
|
||||||
|
if (ev.GetX() < 0 || ev.GetY() < 0 || ev.GetX() >= cs.x || ev.GetY() >= cs.y) {
|
||||||
|
hide(false); // outside box; hide it
|
||||||
|
ev.Skip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : DropDownList : Parent events
|
// ----------------------------------------------------------------------------- : DropDownList : Parent events
|
||||||
|
|
||||||
bool DropDownList::onMouseInParent(wxMouseEvent& ev, bool open_in_place) {
|
bool DropDownList::onMouseInParent(wxMouseEvent& ev, bool open_in_place) {
|
||||||
@@ -429,4 +442,5 @@ BEGIN_EVENT_TABLE(DropDownList,wxPopupWindow)
|
|||||||
EVT_LEFT_DOWN (DropDownList::onLeftDown)
|
EVT_LEFT_DOWN (DropDownList::onLeftDown)
|
||||||
EVT_LEFT_UP (DropDownList::onLeftUp)
|
EVT_LEFT_UP (DropDownList::onLeftUp)
|
||||||
EVT_MOTION (DropDownList::onMotion)
|
EVT_MOTION (DropDownList::onMotion)
|
||||||
|
EVT_LEAVE_WINDOW (DropDownList::onMouseLeave)
|
||||||
END_EVENT_TABLE ()
|
END_EVENT_TABLE ()
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class DropDownList : public wxPopupWindow {
|
|||||||
/// When the list is being opened, what should be selected?
|
/// When the list is being opened, what should be selected?
|
||||||
virtual size_t selection() const = 0;
|
virtual size_t selection() const = 0;
|
||||||
/** Should the list stay open after selecting something? */
|
/** Should the list stay open after selecting something? */
|
||||||
virtual bool stayOpen() const { return false; }
|
virtual bool stayOpen(size_t selection) const { return false; }
|
||||||
|
|
||||||
// --------------------------------------------------- : Item information
|
// --------------------------------------------------- : Item information
|
||||||
/// Number of items
|
/// Number of items
|
||||||
@@ -95,6 +95,7 @@ class DropDownList : public wxPopupWindow {
|
|||||||
DropDownList* parent_menu; ///< The parent menu, only applies to sub menus
|
DropDownList* parent_menu; ///< The parent menu, only applies to sub menus
|
||||||
ValueViewer* viewer; ///< The parent viewer object (optional)
|
ValueViewer* viewer; ///< The parent viewer object (optional)
|
||||||
DropDownHider* hider, *hider2; ///< Class to hide this window when we lose focus
|
DropDownHider* hider, *hider2; ///< Class to hide this window when we lose focus
|
||||||
|
bool close_on_mouse_out; ///< Was the list kept open after selecting a choice, if so, be eager to close it
|
||||||
|
|
||||||
// --------------------------------------------------- : Events
|
// --------------------------------------------------- : Events
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
@@ -103,6 +104,7 @@ class DropDownList : public wxPopupWindow {
|
|||||||
void onLeftDown(wxMouseEvent&);
|
void onLeftDown(wxMouseEvent&);
|
||||||
void onLeftUp (wxMouseEvent&);
|
void onLeftUp (wxMouseEvent&);
|
||||||
void onMotion(wxMouseEvent&);
|
void onMotion(wxMouseEvent&);
|
||||||
|
void onMouseLeave(wxMouseEvent&);
|
||||||
|
|
||||||
// --------------------------------------------------- : Privates
|
// --------------------------------------------------- : Privates
|
||||||
|
|
||||||
|
|||||||
@@ -22,20 +22,14 @@ class DropDownMultipleChoiceList : public DropDownChoiceListBase {
|
|||||||
virtual void onShow();
|
virtual void onShow();
|
||||||
virtual void select(size_t item);
|
virtual void select(size_t item);
|
||||||
virtual size_t selection() const;
|
virtual size_t selection() const;
|
||||||
virtual bool stayOpen() const { return true; }
|
virtual bool stayOpen(size_t selection) const { return true; }
|
||||||
virtual DropDownList* createSubMenu(ChoiceField::ChoiceP group) const;
|
virtual DropDownList* createSubMenu(ChoiceField::ChoiceP group) const;
|
||||||
virtual void drawIcon(DC& dc, int x, int y, size_t item, bool selected) const;
|
virtual void drawIcon(DC& dc, int x, int y, size_t item, bool selected) const;
|
||||||
|
|
||||||
virtual void onMouseLeave(wxMouseEvent&);
|
|
||||||
private:
|
|
||||||
DECLARE_EVENT_TABLE();
|
|
||||||
bool kept_open; ///< Was the list kept open after selecting a choice, if so, be eager to close it
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DropDownMultipleChoiceList::DropDownMultipleChoiceList
|
DropDownMultipleChoiceList::DropDownMultipleChoiceList
|
||||||
(Window* parent, bool is_submenu, ValueViewer& cve, ChoiceField::ChoiceP group)
|
(Window* parent, bool is_submenu, ValueViewer& cve, ChoiceField::ChoiceP group)
|
||||||
: DropDownChoiceListBase(parent, is_submenu, cve, group)
|
: DropDownChoiceListBase(parent, is_submenu, cve, group)
|
||||||
, kept_open(false)
|
|
||||||
{
|
{
|
||||||
icon_size.width += 16;
|
icon_size.width += 16;
|
||||||
}
|
}
|
||||||
@@ -50,7 +44,6 @@ void DropDownMultipleChoiceList::select(size_t item) {
|
|||||||
}
|
}
|
||||||
// keep the box open
|
// keep the box open
|
||||||
DropDownChoiceListBase::onShow(); // update 'enabled'
|
DropDownChoiceListBase::onShow(); // update 'enabled'
|
||||||
kept_open = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropDownMultipleChoiceList::drawIcon(DC& dc, int x, int y, size_t item, bool selected) const {
|
void DropDownMultipleChoiceList::drawIcon(DC& dc, int x, int y, size_t item, bool selected) const {
|
||||||
@@ -82,7 +75,6 @@ void DropDownMultipleChoiceList::onShow() {
|
|||||||
DropDownChoiceListBase::onShow();
|
DropDownChoiceListBase::onShow();
|
||||||
// we need thumbnail images soon
|
// we need thumbnail images soon
|
||||||
const_cast<DropDownMultipleChoiceList*>(this)->generateThumbnailImages();
|
const_cast<DropDownMultipleChoiceList*>(this)->generateThumbnailImages();
|
||||||
kept_open = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t DropDownMultipleChoiceList::selection() const {
|
size_t DropDownMultipleChoiceList::selection() const {
|
||||||
@@ -93,21 +85,6 @@ DropDownList* DropDownMultipleChoiceList::createSubMenu(ChoiceField::ChoiceP gro
|
|||||||
return new DropDownMultipleChoiceList(const_cast<DropDownMultipleChoiceList*>(this), true, cve, group);
|
return new DropDownMultipleChoiceList(const_cast<DropDownMultipleChoiceList*>(this), true, cve, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropDownMultipleChoiceList::onMouseLeave(wxMouseEvent& ev) {
|
|
||||||
if (kept_open) {
|
|
||||||
wxSize cs = GetClientSize();
|
|
||||||
if (ev.GetX() < 0 || ev.GetY() < 0 || ev.GetX() >= cs.x || ev.GetY() >= cs.y) {
|
|
||||||
hide(false); // outside box; hide it
|
|
||||||
ev.Skip();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(DropDownMultipleChoiceList, DropDownChoiceListBase)
|
|
||||||
EVT_LEAVE_WINDOW(DropDownMultipleChoiceList::onMouseLeave)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : MultipleChoiceValueEditor
|
// ----------------------------------------------------------------------------- : MultipleChoiceValueEditor
|
||||||
|
|
||||||
IMPLEMENT_VALUE_EDITOR(MultipleChoice) {}
|
IMPLEMENT_VALUE_EDITOR(MultipleChoice) {}
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ class DropDownWordList : public DropDownList {
|
|||||||
virtual DropDownList* submenu(size_t item) const;
|
virtual DropDownList* submenu(size_t item) const;
|
||||||
virtual size_t selection() const;
|
virtual size_t selection() const;
|
||||||
virtual void select(size_t item);
|
virtual void select(size_t item);
|
||||||
|
virtual bool stayOpen(size_t selection) const;
|
||||||
private:
|
private:
|
||||||
TextValueEditor& tve;
|
TextValueEditor& tve;
|
||||||
WordListPosP pos;
|
WordListPosP pos;
|
||||||
@@ -280,7 +281,7 @@ void DropDownWordList::select(size_t item) {
|
|||||||
// determine new value
|
// determine new value
|
||||||
String new_value;
|
String new_value;
|
||||||
bool toggling_prefix = items[item].word->is_prefix;
|
bool toggling_prefix = items[item].word->is_prefix;
|
||||||
for (size_t i = 0 ; i < words->words.size() ; ++i) {
|
for (size_t i = 0 ; i < items.size() ; ++i) {
|
||||||
const DropDownWordListItem& it = items[i];
|
const DropDownWordListItem& it = items[i];
|
||||||
if (it.word->is_prefix) {
|
if (it.word->is_prefix) {
|
||||||
if (it.active() != (i == item)) {
|
if (it.active() != (i == item)) {
|
||||||
@@ -298,6 +299,13 @@ void DropDownWordList::select(size_t item) {
|
|||||||
tve.fixSelection(TYPE_INDEX);
|
tve.fixSelection(TYPE_INDEX);
|
||||||
tve.replaceSelection(escape(new_value),
|
tve.replaceSelection(escape(new_value),
|
||||||
format_string(_ACTION_("change"), tve.field().name));
|
format_string(_ACTION_("change"), tve.field().name));
|
||||||
|
// stay open?
|
||||||
|
if (IsShown()) selection(); // update 'enabled'
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DropDownWordList::stayOpen(size_t selection) const {
|
||||||
|
if (selection == NO_SELECTION) return false;
|
||||||
|
return items[selection].word->is_prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropDownWordList::redrawArrowOnParent() {
|
void DropDownWordList::redrawArrowOnParent() {
|
||||||
|
|||||||
Reference in New Issue
Block a user