mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -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 input
|
||||
}
|
||||
suffix := [card: "card.jpg", textbox: "textbox.png", typeline: "typeline.png"]
|
||||
template := { green_template() + suffix[type] }
|
||||
template_suffix := [card: "card.jpg", textbox: "textbox.png", typeline: "typeline.png"]
|
||||
template := { green_template() + template_suffix[type] }
|
||||
land_template := {
|
||||
(if input == "a" then (
|
||||
if styling.land_style == "grey" then "e"
|
||||
else "c"
|
||||
) else green_template()) + "l" + suffix[type] }
|
||||
) else green_template()) + "l" + template_suffix[type] }
|
||||
|
||||
# Use the normal tap symbol
|
||||
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 x = 0 ; x < width ; ++x) {
|
||||
if (x==150&&y==150) {
|
||||
x=x;//break
|
||||
}
|
||||
// Filter using a kernel of the form
|
||||
/* -1 -1
|
||||
* -1 c c -1
|
||||
|
||||
@@ -90,3 +90,13 @@ Image rotate_image(const Image& image, int angle) {
|
||||
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)
|
||||
, hider (is_submenu ? nullptr : new DropDownHider(*this))
|
||||
, hider2(is_submenu ? nullptr : new DropDownHider(*this))
|
||||
, close_on_mouse_out(false)
|
||||
{
|
||||
if (is_submenu) {
|
||||
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) {
|
||||
// hide?
|
||||
bool keep_open = event && allow_veto && stayOpen();
|
||||
bool keep_open = event && allow_veto && stayOpen(selected_item);
|
||||
if (keep_open) {
|
||||
Refresh(false);
|
||||
close_on_mouse_out = true;
|
||||
} else {
|
||||
// hide root
|
||||
DropDownList* root = this;
|
||||
@@ -162,6 +163,7 @@ void DropDownList::hide(bool event, bool allow_veto) {
|
||||
// send event
|
||||
if (event && selected_item != NO_SELECTION && itemEnabled(selected_item)) {
|
||||
select(selected_item);
|
||||
if (IsShown()) Refresh(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,6 +345,17 @@ void DropDownList::onMotion(wxMouseEvent& ev) {
|
||||
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
|
||||
|
||||
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_UP (DropDownList::onLeftUp)
|
||||
EVT_MOTION (DropDownList::onMotion)
|
||||
EVT_LEAVE_WINDOW (DropDownList::onMouseLeave)
|
||||
END_EVENT_TABLE ()
|
||||
|
||||
@@ -58,7 +58,7 @@ class DropDownList : public wxPopupWindow {
|
||||
/// When the list is being opened, what should be selected?
|
||||
virtual size_t selection() const = 0;
|
||||
/** 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
|
||||
/// Number of items
|
||||
@@ -95,6 +95,7 @@ class DropDownList : public wxPopupWindow {
|
||||
DropDownList* parent_menu; ///< The parent menu, only applies to sub menus
|
||||
ValueViewer* viewer; ///< The parent viewer object (optional)
|
||||
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
|
||||
DECLARE_EVENT_TABLE();
|
||||
@@ -103,6 +104,7 @@ class DropDownList : public wxPopupWindow {
|
||||
void onLeftDown(wxMouseEvent&);
|
||||
void onLeftUp (wxMouseEvent&);
|
||||
void onMotion(wxMouseEvent&);
|
||||
void onMouseLeave(wxMouseEvent&);
|
||||
|
||||
// --------------------------------------------------- : Privates
|
||||
|
||||
|
||||
@@ -22,20 +22,14 @@ class DropDownMultipleChoiceList : public DropDownChoiceListBase {
|
||||
virtual void onShow();
|
||||
virtual void select(size_t item);
|
||||
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 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
|
||||
(Window* parent, bool is_submenu, ValueViewer& cve, ChoiceField::ChoiceP group)
|
||||
: DropDownChoiceListBase(parent, is_submenu, cve, group)
|
||||
, kept_open(false)
|
||||
{
|
||||
icon_size.width += 16;
|
||||
}
|
||||
@@ -50,7 +44,6 @@ void DropDownMultipleChoiceList::select(size_t item) {
|
||||
}
|
||||
// keep the box open
|
||||
DropDownChoiceListBase::onShow(); // update 'enabled'
|
||||
kept_open = true;
|
||||
}
|
||||
|
||||
void DropDownMultipleChoiceList::drawIcon(DC& dc, int x, int y, size_t item, bool selected) const {
|
||||
@@ -82,7 +75,6 @@ void DropDownMultipleChoiceList::onShow() {
|
||||
DropDownChoiceListBase::onShow();
|
||||
// we need thumbnail images soon
|
||||
const_cast<DropDownMultipleChoiceList*>(this)->generateThumbnailImages();
|
||||
kept_open = false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
IMPLEMENT_VALUE_EDITOR(MultipleChoice) {}
|
||||
|
||||
@@ -131,6 +131,7 @@ class DropDownWordList : public DropDownList {
|
||||
virtual DropDownList* submenu(size_t item) const;
|
||||
virtual size_t selection() const;
|
||||
virtual void select(size_t item);
|
||||
virtual bool stayOpen(size_t selection) const;
|
||||
private:
|
||||
TextValueEditor& tve;
|
||||
WordListPosP pos;
|
||||
@@ -280,7 +281,7 @@ void DropDownWordList::select(size_t item) {
|
||||
// determine new value
|
||||
String new_value;
|
||||
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];
|
||||
if (it.word->is_prefix) {
|
||||
if (it.active() != (i == item)) {
|
||||
@@ -298,6 +299,13 @@ void DropDownWordList::select(size_t item) {
|
||||
tve.fixSelection(TYPE_INDEX);
|
||||
tve.replaceSelection(escape(new_value),
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user