From 2b01a18bb3fdf8e21ac332a2b00c833c07549690 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 25 Nov 2024 19:12:42 -0600 Subject: [PATCH] make text-size an optional attribute of button --- rsrc/dialogs/preferences.xml | 2 +- rsrc/schemas/dialog.xsd | 1 + src/dialogxml/widgets/button.cpp | 15 +++++++++++---- src/dialogxml/widgets/button.hpp | 2 +- src/game/boe.dlgutil.cpp | 2 -- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/rsrc/dialogs/preferences.xml b/rsrc/dialogs/preferences.xml index ed0a6961..9f7a286e 100644 --- a/rsrc/dialogs/preferences.xml +++ b/rsrc/dialogs/preferences.xml @@ -47,7 +47,7 @@ Fewer wandering monsters Skip splash screen on startup Never show instant help - diff --git a/rsrc/schemas/dialog.xsd b/rsrc/schemas/dialog.xsd index 653c44b4..4856b152 100644 --- a/rsrc/schemas/dialog.xsd +++ b/rsrc/schemas/dialog.xsd @@ -207,6 +207,7 @@ + diff --git a/src/dialogxml/widgets/button.cpp b/src/dialogxml/widgets/button.cpp index b43b606a..b5ac6502 100644 --- a/src/dialogxml/widgets/button.cpp +++ b/src/dialogxml/widgets/button.cpp @@ -44,6 +44,8 @@ cButton::cButton(cDialog& parent,eControlType t) : } void cButton::defaultTextSize() { + if(textSize != 0) return; + if(type == BTN_TINY) textSize = 9; else if(type == BTN_PUSH) textSize = 10; else textSize = 12; @@ -129,7 +131,7 @@ bool cButton::manageFormat(eFormat prop, bool set, boost::any* val) { bool cButton::parseAttribute(ticpp::Attribute& attr, std::string tagName, std::string fname) { std::string name = attr.Name(); - if(name == "type") { + if(name == "type"){ std::string val = attr.Value(); if(val == "small") setBtnType(BTN_SM); else if(val == "regular") setBtnType(BTN_REG); @@ -146,11 +148,16 @@ bool cButton::parseAttribute(ticpp::Attribute& attr, std::string tagName, std::s else if(val == "push") setBtnType(BTN_PUSH); else throw xBadVal(tagName, name, val, attr.Row(), attr.Column(), fname); return true; - } else if(name == "def-key") { + }else if(name == "text-size"){ std::string val = attr.Value(); - try { + short size = std::stoi(val); + textSize = size; + return true; + }else if(name == "def-key"){ + std::string val = attr.Value(); + try{ attachKey(parseKey(val)); - } catch(int) { + }catch(int){ throw xBadVal(tagName, name, val, attr.Row(), attr.Column(), fname); } return true; diff --git a/src/dialogxml/widgets/button.hpp b/src/dialogxml/widgets/button.hpp index f9d40813..a7d31b47 100644 --- a/src/dialogxml/widgets/button.hpp +++ b/src/dialogxml/widgets/button.hpp @@ -80,7 +80,7 @@ private: static rectangle btnRects[13][2]; protected: /// Size of the button's descriptive text - short textSize; + short textSize = 0; /// Determines whether the button's label should be word wrapped. bool wrapLabel; /// The button's text colour; only used by LED and tiny buttons diff --git a/src/game/boe.dlgutil.cpp b/src/game/boe.dlgutil.cpp index b36c9c3a..845ab1a0 100644 --- a/src/game/boe.dlgutil.cpp +++ b/src/game/boe.dlgutil.cpp @@ -1256,9 +1256,7 @@ void pick_preferences(bool record) { cDialog prefsDlog(*ResMgr::dialogs.get("preferences")); prefsDlog.attachClickHandlers(&prefs_event_filter, {"okay", "cancel"}); - prefsDlog.attachClickHandlers(&reset_help, {"resethelp"}); - dynamic_cast(prefsDlog["resethelp"]).setTextSize(10); cLedGroup& displayMode = dynamic_cast(prefsDlog["display"]); switch(get_int_pref("DisplayMode")) {