From 4d1c7aae96e76f15145faa62ba8dae3b74941b64 Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Thu, 9 Apr 2026 19:30:17 +0200 Subject: [PATCH] prevent dropdown from closing when moving to parent or child --- CMakeLists.txt | 2 +- data/ch-s.mse-locale/locale | 3 ++- data/ch-t.mse-locale/locale | 3 ++- data/da.mse-locale/locale | 4 ++-- data/de.mse-locale/locale | 4 ++-- data/en.mse-locale/locale | 4 ++-- data/es.mse-locale/locale | 3 ++- data/fr.mse-locale/locale | 4 ++-- data/it.mse-locale/locale | 8 ++++---- data/jp.mse-locale/locale | 3 ++- data/ko.mse-locale/locale | 3 ++- data/pl.mse-locale/locale | 3 ++- data/pt-br.mse-locale/locale | 4 ++-- data/ru.mse-locale/locale | 4 ++-- src/data/format/clipboard.cpp | 4 ++-- src/gfx/blend_image.cpp | 2 +- src/gfx/combine_image.cpp | 2 +- src/gui/drop_down_list.cpp | 18 +++++++++++++++--- src/gui/drop_down_list.hpp | 7 +++++-- src/script/functions/image.cpp | 18 ++++++++++++------ 20 files changed, 65 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c47fdd1..0725971e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ endif() # You will most likely get a message about being unable to open hunspell-1.7.lib because pkgconf forgets to add the actual path to # HUNSPELL_LIBRARIES. If so, uncomment the below line and point it to the correct vcpkg root folder/library. -#set(HUNSPELL_LIBRARIES "C:\\PATH\\TO\\ROOT\\vcpkg\\installed\\${VCPKG_TARGET_TRIPLET}\\lib\\hunspell-1.7.lib") +set(HUNSPELL_LIBRARIES "C:\\src\\vcpkg\\installed\\${VCPKG_TARGET_TRIPLET}\\lib\\hunspell-1.7.lib") message("-- Does this have a full path? If not, and it's just a file name, it's broken: Found Hunspell at ${HUNSPELL_LIBRARIES}") include_directories("${PROJECT_BINARY_DIR}/src") diff --git a/data/ch-s.mse-locale/locale b/data/ch-s.mse-locale/locale index 1d2794ae..1476ab5e 100644 --- a/data/ch-s.mse-locale/locale +++ b/data/ch-s.mse-locale/locale @@ -1129,7 +1129,8 @@ error: # image stuff coordinates for blending overlap: 坐标混合重叠 - images used for blending must have the same size: 边框用图像必须使用相同大小 + #TODO: Localize + blending different sizes: Images used for blending must have the same size in function '%s' #TODO: Localize negative image width: Image with zero or negative width created in function '%s' #TODO: Localize diff --git a/data/ch-t.mse-locale/locale b/data/ch-t.mse-locale/locale index 3372ff0d..8d0b3186 100644 --- a/data/ch-t.mse-locale/locale +++ b/data/ch-t.mse-locale/locale @@ -1127,7 +1127,8 @@ error: # image stuff coordinates for blending overlap: 坐標混合重疊 - images used for blending must have the same size: 邊框用圖像必須使用相同大小 + #TODO: Localize + blending different sizes: Images used for blending must have the same size in function '%s' #TODO: Localize negative image width: Image with zero or negative width created in function '%s' #TODO: Localize diff --git a/data/da.mse-locale/locale b/data/da.mse-locale/locale index 17ceb40e..9f6f6dce 100644 --- a/data/da.mse-locale/locale +++ b/data/da.mse-locale/locale @@ -1152,9 +1152,9 @@ error: # image stuff #TODO: Localize - coordinates for blending overlap: Coordinates for blending overlap + coordinates for blending overlap: Coordinates for blending overlap. Space them out. #TODO: Localize - images used for blending must have the same size: Images used for blending must have the same size + blending different sizes: Images used for blending must have the same size in function '%s' #TODO: Localize negative image width: Image with zero or negative width created in function '%s' #TODO: Localize diff --git a/data/de.mse-locale/locale b/data/de.mse-locale/locale index 761049b9..d2dc0f38 100644 --- a/data/de.mse-locale/locale +++ b/data/de.mse-locale/locale @@ -1046,8 +1046,8 @@ error: im Reminder-Text der Fähigkeit '%s' # image stuff - coordinates for blending overlap: Koordinaten zum Blenden überlappen sich - images used for blending must have the same size: Bilder müssen zum Mischen die selbe Größe haben. + coordinates for blending overlap: Die Koordinaten für die Überblendung überlappen sich. + blending different sizes: Die für die Überblendung verwendeten Bilder müssen in der Funktion '%s' die gleiche Größe haben. negative image width: Bild mit Breite Null oder negativer Breite, erstellt in der Funktion '%s' negative image height: Bild mit Höhe Null oder negativer Höhe, erstellt in der Funktion '%s' can't load image: Bild konnte nicht geladen werden. Stelle sicher, dass das tatsächliche Format des Bildes mit der gespeicherten Dateiendung übereinstimmt. diff --git a/data/en.mse-locale/locale b/data/en.mse-locale/locale index 885bf3b6..5abf33dc 100644 --- a/data/en.mse-locale/locale +++ b/data/en.mse-locale/locale @@ -1047,8 +1047,8 @@ error: in reminder text of keyword '%s' # image stuff - coordinates for blending overlap: Coordinates for blending overlap - images used for blending must have the same size: Images used for blending must have the same size + coordinates for blending overlap: Coordinates for blending overlap. Space them out. + blending different sizes: Images used for blending must have the same size in function '%s' negative image width: Image with zero or negative width created in function '%s' negative image height: Image with zero or negative height created in function '%s' can't load image: Failed to load image. Ensure the image's actual format matches its saved extension. diff --git a/data/es.mse-locale/locale b/data/es.mse-locale/locale index 95b0f23e..ca08119f 100644 --- a/data/es.mse-locale/locale +++ b/data/es.mse-locale/locale @@ -1130,7 +1130,8 @@ error: # image stuff coordinates for blending overlap: Coordenadas para la mezcla (blending) solapada - images used for blending must have the same size: Las imagenes utilizadas para la mezcla (blending) deben tener el mismo tamaño + #TODO: Localize + blending different sizes: Images used for blending must have the same size in function '%s' #TODO: Localize negative image width: Image with zero or negative width created in function '%s' #TODO: Localize diff --git a/data/fr.mse-locale/locale b/data/fr.mse-locale/locale index 42e8284f..7e526f2e 100644 --- a/data/fr.mse-locale/locale +++ b/data/fr.mse-locale/locale @@ -1046,8 +1046,8 @@ error: dans le texte de rappel du mot-clef '%s' # image stuff - coordinates for blending overlap: Coordonnées pour la superposition du mélange - images used for blending must have the same size: Les images utilisées pour le mélange doivent avoir la même taille + coordinates for blending overlap: Les coordonnées pour le mélange sont superposées. Espacez-les. + blending different sizes: Les images utilisées pour le mélange doivent avoir la même taille dans la fonction '%s'. negative image width: Image de largeur nulle ou négative créée par la fonction '%s' negative image height: Image de hauteur nulle ou négative créée par la fonction '%s' can't load image: Échec du chargement de l'image. Assurez-vous que le format réel de l'image corresponde à son extension enregistrée. diff --git a/data/it.mse-locale/locale b/data/it.mse-locale/locale index 07697844..9b88682e 100644 --- a/data/it.mse-locale/locale +++ b/data/it.mse-locale/locale @@ -1046,10 +1046,10 @@ error: in promemoria della parola-chiave '%s' # image stuff - coordinates for blending overlap: Coordinate per sovrapposizione - images used for blending must have the same size: Le immagini sovrapposte devono avere le stesse misure - negative image width: Immagine con larghezza zero o negativa creata nella funzione '%s' - negative image height: Immagine con altezza zero o negativa creata nella funzione '%s' + coordinates for blending overlap: Le coordinate per la fusione si sovrappongono. + blending different sizes: Le immagini utilizzate per la fusione devono avere le stesse dimensioni nella funzione '%s'. + negative image width: Immagine con larghezza zero o negativa creata nella funzione '%s'. + negative image height: Immagine con altezza zero o negativa creata nella funzione '%s'. can't load image: Impossibile caricare l'immagine. Assicurarsi che il formato effettivo dell'immagine corrisponda all'estensione salvata. symbol image has alpha: Per ottenere risultati ottimali, l'immagine dovrebbe essere in bianco e nero, senza trasparenza. diff --git a/data/jp.mse-locale/locale b/data/jp.mse-locale/locale index e8329c6e..6aae9206 100644 --- a/data/jp.mse-locale/locale +++ b/data/jp.mse-locale/locale @@ -1130,7 +1130,8 @@ error: # image stuff coordinates for blending overlap: オーバーラップを混ぜることのための座標 - images used for blending must have the same size: 混ざることのために使われたイメージは同じサイズを持たなければなりません + #TODO: Localize + blending different sizes: Images used for blending must have the same size in function '%s' #TODO: Localize negative image width: Image with zero or negative width created in function '%s' #TODO: Localize diff --git a/data/ko.mse-locale/locale b/data/ko.mse-locale/locale index 14ab7f1f..b192eea5 100644 --- a/data/ko.mse-locale/locale +++ b/data/ko.mse-locale/locale @@ -1136,7 +1136,8 @@ error: # image stuff coordinates for blending overlap: 블렌딩 오버랩을 위한 좌표 - images used for blending must have the same size: 블렌딩에 사용되는 이미지의 크기는 동일해야 합니다. + #TODO: Localize + blending different sizes: Images used for blending must have the same size in function '%s' #TODO: Localize negative image width: Image with zero or negative width created in function '%s' #TODO: Localize diff --git a/data/pl.mse-locale/locale b/data/pl.mse-locale/locale index 916aae25..fe2953ea 100644 --- a/data/pl.mse-locale/locale +++ b/data/pl.mse-locale/locale @@ -1186,7 +1186,8 @@ error: # image stuff coordinates for blending overlap: Współrzędne scalania (blending) nachodzą na siebie - images used for blending must have the same size: Obrazy użyte do scalania (blending) muszą mieć ten sam rozmiar + #TODO: Localize + blending different sizes: Images used for blending must have the same size in function '%s' #TODO: Localize negative image width: Image with zero or negative width created in function '%s' #TODO: Localize diff --git a/data/pt-br.mse-locale/locale b/data/pt-br.mse-locale/locale index 2eefdc75..5f2990b0 100644 --- a/data/pt-br.mse-locale/locale +++ b/data/pt-br.mse-locale/locale @@ -1047,8 +1047,8 @@ error: lembrete de palavra-chave no texto '%s' # image stuff - coordinates for blending overlap: Cordenadas para mistura sobreposição - images used for blending must have the same size: Imagens utilizados para a mistura deve ter o mesmo tamanho + coordinates for blending overlap: As coordenadas para a mistura se sobrepõem. + blending different sizes: As imagens usadas para mesclagem devem ter o mesmo tamanho na função '%s'. negative image width: Imagem com largura zero ou negativa criada na função '%s' negative image height: Imagem com altura zero ou negativa criada na função '%s' can't load image: Falha ao carregar a imagem. Verifique se o formato real da imagem corresponde à extensão salva. diff --git a/data/ru.mse-locale/locale b/data/ru.mse-locale/locale index 14315436..4ccdffd8 100644 --- a/data/ru.mse-locale/locale +++ b/data/ru.mse-locale/locale @@ -1180,9 +1180,9 @@ error: # image stuff #TODO: Localize - coordinates for blending overlap: Coordinates for blending overlap + coordinates for blending overlap: Coordinates for blending overlap. Space them out. #TODO: Localize - images used for blending must have the same size: Images used for blending must have the same size + blending different sizes: Images used for blending must have the same size in function '%s' #TODO: Localize negative image width: Image with zero or negative width created in function '%s' #TODO: Localize diff --git a/src/data/format/clipboard.cpp b/src/data/format/clipboard.cpp index 19d1cfb5..7e2fa930 100644 --- a/src/data/format/clipboard.cpp +++ b/src/data/format/clipboard.cpp @@ -61,7 +61,7 @@ IMPLEMENT_REFLECTION(WrappedCards) { } -wxDataFormat CardsDataObject::format = _("application/x-mse-cards"); +wxDataFormat CardsDataObject::format(wxString("application/x-mse-cards")); CardsDataObject::CardsDataObject(const SetP& set, const String id, const vector& cards) { // set the stylesheet, so when deserializing we know whos style options we are reading @@ -121,7 +121,7 @@ IMPLEMENT_REFLECTION(WrappedKeyword) { } -wxDataFormat KeywordDataObject::format = _("application/x-mse-keyword"); +wxDataFormat KeywordDataObject::format(wxString("application/x-mse-keyword")); KeywordDataObject::KeywordDataObject(const SetP& set, const KeywordP& keyword) { WrappedKeyword data = { set->game.get(), set->game->name(), keyword }; diff --git a/src/gfx/blend_image.cpp b/src/gfx/blend_image.cpp index 0468cd72..85085d4d 100644 --- a/src/gfx/blend_image.cpp +++ b/src/gfx/blend_image.cpp @@ -19,7 +19,7 @@ template inline T sqr(T x) { return x * x; } void linear_blend(Image& img1, const Image& img2, double x1,double y1, double x2,double y2) { int width = img1.GetWidth(), height = img1.GetHeight(); if (img2.GetWidth() != width || img2.GetHeight() != height) { - throw Error(_ERROR_("images used for blending must have the same size")); + throw Error(_ERROR_1_("blending different sizes", "linear_blend")); } const int fixed = 1<<16; // fixed point multiplier diff --git a/src/gfx/combine_image.cpp b/src/gfx/combine_image.cpp index de75e14c..6a14bf16 100644 --- a/src/gfx/combine_image.cpp +++ b/src/gfx/combine_image.cpp @@ -439,7 +439,7 @@ void combine_image_do(Image& a, Image b) { void combine_image(Image& a, const Image& b, ImageCombine combine) { // Images must have same size if (a.GetWidth() != b.GetWidth() || a.GetHeight() != b.GetHeight()) { - throw Error(_ERROR_("images used for combine blending must have the same size")); + throw Error(_ERROR_1_("blending different sizes", "combine_blend")); } // Copy alpha channel? if (b.HasAlpha()) { diff --git a/src/gui/drop_down_list.cpp b/src/gui/drop_down_list.cpp index 5e0663f2..562f339b 100644 --- a/src/gui/drop_down_list.cpp +++ b/src/gui/drop_down_list.cpp @@ -471,9 +471,13 @@ void DropDownList::onMotion(wxMouseEvent& ev) { } 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) { + if (close_on_mouse_out) { + wxPoint screen_pos = ClientToScreen(ev.GetPosition()); + bool in_parent = parent_menu ? parent_menu->isInRect(screen_pos) : false; + bool in_child = open_sub_menu ? open_sub_menu->isInRect(screen_pos) : false; + wxSize cs = GetClientSize(); + bool in_self = !(ev.GetX() < 0 || ev.GetY() < 0 || ev.GetX() >= cs.x || ev.GetY() >= cs.y); + if (!(in_parent || in_child || in_self)) { hide(false); // outside box; hide it ev.Skip(); return; @@ -481,6 +485,14 @@ void DropDownList::onMouseLeave(wxMouseEvent& ev) { } } +bool DropDownList::isInRect(wxPoint screen_pos) { + wxRect rect = GetRect(); + if (screen_pos.x < rect.x || screen_pos.y < rect.y || screen_pos.x > rect.x+rect.width || screen_pos.y > rect.y+rect.height) { + return false; + } + return true; +} + void DropDownList::onMouseWheel(wxMouseEvent& ev) { scrollTo(visible_start - item_size.height * ev.GetWheelRotation() / ev.GetWheelDelta()); } diff --git a/src/gui/drop_down_list.hpp b/src/gui/drop_down_list.hpp index f64607ad..742eb509 100644 --- a/src/gui/drop_down_list.hpp +++ b/src/gui/drop_down_list.hpp @@ -116,9 +116,12 @@ private: void onMouseLeave(wxMouseEvent&); void onMouseWheel(wxMouseEvent& ev); void onScroll(wxScrollWinEvent&); - + // --------------------------------------------------- : Privates - + + /// Is the given screen coordinate inside this menu's rect? + bool isInRect(wxPoint screen_pos); + /// Return the y coordinate of an item (in scrolled coordinates) int itemPosition(size_t item) const; diff --git a/src/script/functions/image.cpp b/src/script/functions/image.cpp index 4b637a05..06c567ec 100644 --- a/src/script/functions/image.cpp +++ b/src/script/functions/image.cpp @@ -81,22 +81,28 @@ SCRIPT_FUNCTION(set_metadata) { SCRIPT_FUNCTION(width_of) { SCRIPT_PARAM(Set*, set); - SCRIPT_PARAM(GeneratedImageP, input); - Image image = input->generate(GeneratedImage::Options(0, 0, set->stylesheet.get())); + SCRIPT_PARAM(CardP, card); + SCRIPT_PARAM(GeneratedImageP, input); + StyleSheet* stylesheet = card && card->stylesheet ? card->stylesheet.get() : set->stylesheet.get(); + Image image = input->generate(GeneratedImage::Options(0, 0, stylesheet)); SCRIPT_RETURN(image.GetWidth()); } SCRIPT_FUNCTION(height_of) { SCRIPT_PARAM(Set*, set); - SCRIPT_PARAM(GeneratedImageP, input); - Image image = input->generate(GeneratedImage::Options(0, 0, set->stylesheet.get())); + SCRIPT_PARAM(CardP, card); + SCRIPT_PARAM(GeneratedImageP, input); + StyleSheet* stylesheet = card && card->stylesheet ? card->stylesheet.get() : set->stylesheet.get(); + Image image = input->generate(GeneratedImage::Options(0, 0, stylesheet)); SCRIPT_RETURN(image.GetHeight()); } SCRIPT_FUNCTION(dimensions_of) { SCRIPT_PARAM(Set*, set); - SCRIPT_PARAM(GeneratedImageP, input); - Image image = input->generate(GeneratedImage::Options(0, 0, set->stylesheet.get())); + SCRIPT_PARAM(CardP, card); + SCRIPT_PARAM(GeneratedImageP, input); + StyleSheet* stylesheet = card && card->stylesheet ? card->stylesheet.get() : set->stylesheet.get(); + Image image = input->generate(GeneratedImage::Options(0, 0, stylesheet)); ScriptCustomCollectionP ret(new ScriptCustomCollection()); ret->value.push_back(to_script(image.GetWidth())); ret->value.push_back(to_script(image.GetHeight()));