Allow automatically calculating both the width and height of a text label

This fixes welcome dialog links triggering when you hit OK in the right place
This commit is contained in:
2020-12-19 18:10:25 -05:00
parent 99ac7531a8
commit 81c2a084e3
2 changed files with 12 additions and 10 deletions

View File

@@ -9,7 +9,7 @@
Blades of Exile game developed by Spiderweb Software in Blades of Exile game developed by Spiderweb Software in
1997 and released as Free Open-Source Software in 2005. 1997 and released as Free Open-Source Software in 2005.
</text> </text>
<text name='spidweb' relative='pos-in pos' rel-anchor='prev' top='0' left='16' width='390' height='12' colour='link' underline='true'> <text name='spidweb' relative='pos-in pos' rel-anchor='prev' top='0' left='16' colour='link' underline='true'>
http://www.spidweb.com/blades/opensource.html http://www.spidweb.com/blades/opensource.html
</text> </text>
<text relative='neg pos' rel-anchor='prev' top='12' left='16' width='413'> <text relative='neg pos' rel-anchor='prev' top='12' left='16' width='413'>
@@ -18,7 +18,7 @@
In addition to these, hundreds more written by In addition to these, hundreds more written by
community members, are available for download online! community members, are available for download online!
</text> </text>
<text name='scen' relative='pos-in pos' rel-anchor='prev' top='0' left='16' width='390' height='12' colour='link' underline='true'> <text name='scen' relative='pos-in pos' rel-anchor='prev' top='0' left='16' colour='link' underline='true'>
http://openboe.com/scenarios http://openboe.com/scenarios
</text> </text>
<text relative='neg pos' rel-anchor='prev' top='12' left='16' width='413'> <text relative='neg pos' rel-anchor='prev' top='12' left='16' width='413'>
@@ -33,7 +33,7 @@
You can also find playing hints and related discussion You can also find playing hints and related discussion
at the Spiderweb Software game forums. at the Spiderweb Software game forums.
</text> </text>
<text name='forum' relative='pos-in pos' rel-anchor='prev' top = '0' left='16' width='390' height='12' colour='link' underline='true'> <text name='forum' relative='pos-in pos' rel-anchor='prev' top = '0' left='16' colour='link' underline='true'>
http://spiderwebforums.ipbhost.com/ http://spiderwebforums.ipbhost.com/
</text> </text>
<text relative='neg pos' rel-anchor='prev' top='12' left='16' width='413'> <text relative='neg pos' rel-anchor='prev' top='12' left='16' width='413'>
@@ -41,16 +41,16 @@
you can change animation speed, game difficulty, display you can change animation speed, game difficulty, display
options and special effects settings. options and special effects settings.
<br/><br/> <br/><br/>
Blades of Exile Game/Editor/Character Editor are released Blades of Exile is released
under the terms of the GNU General Public License V2. under the terms of the GNU General Public License V2.
See the file LICENSE.txt for details. See the file LICENSE.txt for details.
<br/><br/> <br/><br/>
The Open Blades of Exile team The Open Blades of Exile team
</text> </text>
<text name='home' relative='pos-in pos' rel-anchor='prev' top='0' left='16' width='390' height='12' colour='link' underline='true'> <text name='home' relative='pos-in pos' rel-anchor='prev' top='0' left='16' colour='link' underline='true'>
http://openboe.com http://openboe.com
</text> </text>
<text name='src' relative='pos-in pos' rel-anchor='prev' top='0' left='0' width='390' height='12' colour='link' underline='true'> <text name='src' relative='pos-in pos' rel-anchor='prev' top='0' left='0' colour='link' underline='true'>
https://github.com/calref/cboe https://github.com/calref/cboe
</text> </text>
<button name='okay' relative='neg' type='regular' top='30' left='70'>OK</button> <button name='okay' relative='neg' type='regular' top='30' left='70'>OK</button>

View File

@@ -123,10 +123,11 @@ void cTextMsg::recalcRect() {
if(!fixedHeight) { if(!fixedHeight) {
// Fix the width and calculate the height // Fix the width and calculate the height
calc_rect.height() = lines * style.lineHeight * 10; calc_rect.height() = lines * style.lineHeight * 10;
} else if(!fixedWidth) { }
if(!fixedWidth) {
// Fix the height and calculate the width // Fix the height and calculate the width
calc_rect.width() = 100 * max_line_chars; calc_rect.width() = 100 * max_line_chars;
} else return; // This case should be impossible, but just in case... }
sf::RenderTexture temp; sf::RenderTexture temp;
temp.create(frame.width(), frame.height()); temp.create(frame.width(), frame.height());
rectangle test_rect = calc_rect; rectangle test_rect = calc_rect;
@@ -140,8 +141,9 @@ void cTextMsg::recalcRect() {
} }
if(!fixedHeight) { if(!fixedHeight) {
calc_rect.height() = combo.height() + 8; calc_rect.height() = combo.height() + 8;
} else if(!fixedWidth) { }
calc_rect.width() = combo.width() + 8; if(!fixedWidth) {
calc_rect.width() = combo.width() + 16;
} }
frame = calc_rect; frame = calc_rect;
} }