diff --git a/binaries/data/mods/mod/gui/common/modern/styles.xml b/binaries/data/mods/mod/gui/common/modern/styles.xml
index cfa4b6b..8ff04c9 100644
a
|
b
|
|
13 | 13 | ghost="false" |
14 | 14 | hidden="false" |
15 | 15 | size="0 0 100% 100%" |
| 16 | size_max="0 0 100% 100%" |
16 | 17 | z="0" |
17 | 18 | font="sans-14" |
18 | 19 | buffer_zone="5" |
diff --git a/binaries/data/mods/mod/gui/gui.rnc b/binaries/data/mods/mod/gui/gui.rnc
index 034078d..c2fb8d6 100644
a
|
b
|
base_settings =
|
43 | 43 | attribute ghost { bool }?& |
44 | 44 | attribute hidden { bool }?& |
45 | 45 | attribute size { clientarea }?& |
| 46 | attribute size_max { clientarea }?& |
46 | 47 | attribute z { xsd:decimal }? |
47 | 48 | # Defaults are not put in here, because it ruins the concept of styles. |
48 | 49 | ex_settings = |
diff --git a/binaries/data/mods/mod/gui/gui.rng b/binaries/data/mods/mod/gui/gui.rng
index fde243b..af8bca7 100644
a
|
b
|
|
160 | 160 | </attribute> |
161 | 161 | </optional> |
162 | 162 | <optional> |
| 163 | <attribute name="size_max"> |
| 164 | <ref name="clientarea"/> |
| 165 | </attribute> |
| 166 | </optional> |
| 167 | <optional> |
163 | 168 | <attribute name="z"> |
164 | 169 | <data type="decimal"/> |
165 | 170 | </attribute> |
diff --git a/binaries/data/mods/public/gui/common/styles.xml b/binaries/data/mods/public/gui/common/styles.xml
index ed3a9a0..ce1a9ff 100644
a
|
b
|
|
15 | 15 | ghost="false" |
16 | 16 | hidden="false" |
17 | 17 | size="0 0 100% 100%" |
| 18 | size_max="0 0 100% 100%" |
18 | 19 | z="0" |
19 | 20 | |
20 | 21 | font="sans-14" |
diff --git a/binaries/data/mods/public/gui/structree/draw.js b/binaries/data/mods/public/gui/structree/draw.js
index 9b94943..4527f64 100644
a
|
b
|
|
1 | 1 | var g_DrawLimits = {}; // GUI limits. Populated by predraw() |
| 2 | var g_ContentWidth = 0; |
2 | 3 | |
3 | 4 | var g_TooltipFunctions = [ |
4 | 5 | getEntityNamesFormatted, |
… |
… |
function draw()
|
40 | 41 | Engine.GetGUIObjectByName("civHistory").caption = g_CivData[g_SelectedCiv].History; |
41 | 42 | |
42 | 43 | let i = 0; |
| 44 | g_ContentWidth = 0; |
43 | 45 | for (let pha of phaseList) |
44 | 46 | { |
45 | 47 | let prodBarWidth = 0; |
… |
… |
function draw()
|
139 | 141 | hideRemaining("phase["+i+"]_struct["+s+"]_row[", r, "]"); |
140 | 142 | ++s; |
141 | 143 | prodBarWidth += eleWidth + defMargin; |
| 144 | g_ContentWidth = Math.max(y, g_ContentWidth); |
142 | 145 | } |
143 | 146 | hideRemaining("phase["+i+"]_struct[", s, "]"); |
144 | 147 | let offset = getPositionOffset(i); |
… |
… |
function draw()
|
148 | 151 | { |
149 | 152 | let prodBar = Engine.GetGUIObjectByName("phase["+i+"]_bar["+(j-1)+"]"); |
150 | 153 | let prodBarSize = prodBar.size; |
151 | | prodBarSize.right = leftMargin + prodBarWidth; |
| 154 | prodBarSize.right = leftMargin + prodBarWidth + defMargin * 2; |
152 | 155 | prodBar.size = prodBarSize; |
153 | 156 | } |
154 | 157 | |
… |
… |
function draw()
|
213 | 216 | |
214 | 217 | let size = Engine.GetGUIObjectByName("display_tree").size; |
215 | 218 | size.right = t > 0 ? -124 : -4; |
| 219 | g_ContentWidth += t > 0 ? 28 + defWidth : 4 |
216 | 220 | Engine.GetGUIObjectByName("display_tree").size = size; |
217 | 221 | |
218 | 222 | Engine.GetGUIObjectByName("display_trainers").hidden = t == 0; |
| 223 | |
| 224 | g_ContentWidth += 96; |
| 225 | updatePageMaxWidth(); |
| 226 | } |
| 227 | |
| 228 | function updatePageMaxWidth() |
| 229 | { |
| 230 | let page_maxsize = Engine.GetGUIObjectByName("structree_page").size_max; |
| 231 | let x = g_ContentWidth / 2; |
| 232 | page_maxsize.left = -x; |
| 233 | page_maxsize.right = x; |
| 234 | Engine.GetGUIObjectByName("structree_page").size_max = page_maxsize; |
219 | 235 | } |
220 | 236 | |
221 | 237 | function drawProdIcon(pha, s, r, p, prod) |
… |
… |
function predraw()
|
275 | 291 | let phaseList = g_ParsedData.phaseList; |
276 | 292 | let initIconSize = Engine.GetGUIObjectByName("phase[0]_struct[0]_row[0]_prod[0]").size; |
277 | 293 | |
| 294 | let page_maxsize = Engine.GetGUIObjectByName("structree_page").size_max; |
| 295 | page_maxsize.rleft = 50; |
| 296 | page_maxsize.rright = 50; |
| 297 | Engine.GetGUIObjectByName("structree_page").size_max = page_maxsize; |
| 298 | |
278 | 299 | let phaseCount = phaseList.length; |
279 | 300 | let i = 0; |
280 | 301 | for (let pha of phaseList) |
… |
… |
function predraw()
|
353 | 374 | hideRemaining("phase[", i, "]"); |
354 | 375 | hideRemaining("phase[", i, "]_bar"); |
355 | 376 | |
| 377 | let page_size = Engine.GetGUIObjectByName("structree_page").size; |
| 378 | let offset = getPositionOffset(i) + 196; |
| 379 | page_size.top = -offset / 2; |
| 380 | page_size.bottom = offset / 2; |
| 381 | Engine.GetGUIObjectByName("structree_page").size = page_size; |
| 382 | |
356 | 383 | let t = 0; |
357 | 384 | let ele = Engine.GetGUIObjectByName("trainer["+t+"]"); |
358 | 385 | g_DrawLimits.trainer = { |
diff --git a/binaries/data/mods/public/gui/structree/structree.xml b/binaries/data/mods/public/gui/structree/structree.xml
index dbe6e24..912a387 100644
a
|
b
|
|
13 | 13 | <!-- Add a translucent black background to fade out the menu page --> |
14 | 14 | <object type="image" z="0" sprite="BackgroundTranslucent"/> |
15 | 15 | |
16 | | <object type="image" style="ModernDialog" size="16 24 100%-16 100%-24"> |
| 16 | <object type="image" style="ModernDialog" size="16 50%-360 100%-16 50%+360" name="structree_page"> |
17 | 17 | <object style="TitleText" type="text" size="50%-128 -18 50%+128 14"> |
18 | 18 | <translatableAttribute id="caption">Structure Tree</translatableAttribute> |
19 | 19 | </object> |
diff --git a/source/gui/CTooltip.cpp b/source/gui/CTooltip.cpp
index f44dbe6..aed3cf7 100644
a
|
b
|
CTooltip::CTooltip()
|
49 | 49 | GUI<int>::SetSetting(this, "delay", 500); |
50 | 50 | GUI<EVAlign>::SetSetting(this, "anchor", EVAlign_Bottom); |
51 | 51 | GUI<EAlign>::SetSetting(this, "text_align", EAlign_Left); |
| 52 | GUI<CClientArea>::SetSetting(this, "size_max", CClientArea("0 0 100% 100%")); |
52 | 53 | |
53 | 54 | // Set up a blank piece of text, to be replaced with a more |
54 | 55 | // interesting message later |
diff --git a/source/gui/GUIbase.cpp b/source/gui/GUIbase.cpp
index 1f5b247..1f5bd11 100644
a
|
b
|
CRect CClientArea::GetClientArea(const CRect& parent) const
|
52 | 52 | return client; |
53 | 53 | } |
54 | 54 | |
| 55 | |
| 56 | CRect CClientArea::GetClientArea(const CRect& parent, const CClientArea& maxLimit) const |
| 57 | { |
| 58 | CRect limit = maxLimit.GetClientArea(parent); |
| 59 | CRect client = this->GetClientArea(parent); |
| 60 | |
| 61 | // If no limit imposed, then we don't need to restrict |
| 62 | if (parent == limit) |
| 63 | return client; |
| 64 | |
| 65 | client.left = std::max(client.left, limit.left); |
| 66 | client.top = std::max(client.top, limit.top); |
| 67 | client.right = std::min(client.right, limit.right); |
| 68 | client.bottom = std::min(client.bottom, limit.bottom); |
| 69 | |
| 70 | return client; |
| 71 | } |
| 72 | |
55 | 73 | bool CClientArea::SetClientArea(const CStr& Value) |
56 | 74 | { |
57 | 75 | /* ClientAreas contain a left, top, right, and bottom |
diff --git a/source/gui/GUIbase.h b/source/gui/GUIbase.h
index f71c733..56c1c55 100644
a
|
b
|
public:
|
177 | 177 | * Get client area rectangle when the parent is given |
178 | 178 | */ |
179 | 179 | CRect GetClientArea(const CRect& parent) const; |
| 180 | CRect GetClientArea(const CRect& parent, const CClientArea& maxLimit) const; |
180 | 181 | |
181 | 182 | /** |
182 | 183 | * The ClientArea can be set from a string looking like: |
diff --git a/source/gui/GUIutil.cpp b/source/gui/GUIutil.cpp
index 2c0f63f..752a678 100644
a
|
b
|
PSRETURN GUI<T>::SetSetting(IGUIObject* pObject, const CStr& Setting, const T& V
|
390 | 390 | // |
391 | 391 | |
392 | 392 | // If setting was "size", we need to re-cache itself and all children |
393 | | if (Setting == "size") |
| 393 | if (Setting == "size" || Setting == "size_max") |
394 | 394 | { |
395 | 395 | RecurseObject(0, pObject, &IGUIObject::UpdateCachedSize); |
396 | 396 | } |
diff --git a/source/gui/IGUIObject.cpp b/source/gui/IGUIObject.cpp
index e0efbf8..12b8135 100644
a
|
b
|
IGUIObject::IGUIObject()
|
34 | 34 | AddSetting(GUIST_bool, "enabled"); |
35 | 35 | AddSetting(GUIST_bool, "hidden"); |
36 | 36 | AddSetting(GUIST_CClientArea, "size"); |
| 37 | AddSetting(GUIST_CClientArea, "size_max"); |
37 | 38 | AddSetting(GUIST_CStr, "style"); |
38 | 39 | AddSetting(GUIST_CStr, "hotkey"); |
39 | 40 | AddSetting(GUIST_float, "z"); |
… |
… |
void IGUIObject::UpdateCachedSize()
|
307 | 308 | CClientArea ca; |
308 | 309 | GUI<CClientArea>::GetSetting(this, "size", ca); |
309 | 310 | |
| 311 | CClientArea ca_max; |
| 312 | GUI<CClientArea>::GetSetting(this, "size_max", ca_max); |
| 313 | |
310 | 314 | // If absolute="false" and the object has got a parent, |
311 | 315 | // use its cached size instead of the screen. Notice |
312 | 316 | // it must have just been cached for it to work. |
313 | 317 | if (absolute == false && m_pParent && !IsRootObject()) |
314 | | m_CachedActualSize = ca.GetClientArea(m_pParent->m_CachedActualSize); |
| 318 | m_CachedActualSize = ca.GetClientArea(m_pParent->m_CachedActualSize, ca_max); |
315 | 319 | else |
316 | | m_CachedActualSize = ca.GetClientArea(CRect(0.f, 0.f, g_xres * g_GuiScale, g_yres * g_GuiScale)); |
| 320 | m_CachedActualSize = ca.GetClientArea(CRect(0.f, 0.f, g_xres * g_GuiScale, g_yres * g_GuiScale), ca_max); |
317 | 321 | |
318 | 322 | // In a few cases, GUI objects have to resize to fill the screen |
319 | 323 | // but maintain a constant aspect ratio. |