Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Adoptive size of minimap based on screen size
Browse files Browse the repository at this point in the history
  • Loading branch information
LangLangBart committed Mar 8, 2022
1 parent 2b2f8df commit 84f3938
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 40 deletions.
Binary file modified art/textures/ui/session/background_minimap_circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions gui/session/boonGUI_XML/sprites.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@
<image texture="session/panel_shader_light.png" size="0 0 100% 100%" />
</sprite>

<!-- Minimap Hover Panel -->
<sprite name="minimapHoverPanel">
<!-- sides -->
<image texture="global/border/line_horiz.png" texture_size="0 0 64 4" size="4 0 14%-2 4" />
<image texture="global/border/line_horiz.png" texture_size="0 0 64 4" size="86%+2 0 100% 4" />
<image texture="global/border/line_vert.png" texture_size="0 0 4 64" size="100%-4 4 100% 100%-4" />
<image texture="global/border/line_horiz.png" texture_size="0 0 64 4" size="4 100%-4 100%-4 100%" />
<image texture="global/border/line_vert.png" texture_size="0 0 4 64" size="0 4 4 100%-4" />

<!-- corners -->
<image texture="global/border/line_corner_top_right.png" texture_size="0 0 4 4" size="100%-4 0 100% 4" />
<image texture="global/border/line_corner_bottom_right.png" texture_size="0 0 4 4" size="100%-4 100%-4 100% 100%" />
<image texture="global/border/line_corner_bottom_left.png" texture_size="0 0 4 4" size="0 100%-4 4 100%" />
<image texture="global/border/line_corner_top_left.png" texture_size="0 0 4 4" size="0 0 4 4" />
<!-- background -->
<image texture="session/background_hover_panel_black.png" texture_size="0 0 100% 100%" size="4 4 100%-4 100%-4" />
</sprite>

<!-- Bottom Left Panel -->
<sprite name="supplementalDetailsPanelAdjusted">
<!-- sides -->
Expand Down
2 changes: 1 addition & 1 deletion gui/session/boonGUI_XML/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<styles>
<!-- RESOURCE PANEL -->
<style name="resourceTextCounter" textcolor="white" font="sans-stroke-20" ghost="true" text_align="center" text_valign="center" />
<style name="resourceTextCounter" textcolor="white" font="sans-stroke-18" ghost="true" text_align="center" text_valign="center" />
<style name="resourceGathererCounts" textcolor="200 200 200" font="sans-stroke-18" ghost="true" text_align="center" text_valign="bottom" sprite="backcolor: 0 0 0 195" />
<style name="resourceTimeCounter" textcolor="white" font="sans-bold-stroke-18" ghost="true" text_align="center" text_valign="center" />
<style name="resourceIdleWorker" textcolor="red" font="sans-bold-stroke-20" ghost="true" text_align="center" text_valign="center" />
Expand Down
40 changes: 30 additions & 10 deletions gui/session/counters/BoonGUICounterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ class BoonGUICounterManager
{
this.counters = [];
this.minimapPanel = Engine.GetGUIObjectByName("minimapPanel");
this.supplementalSelectionDetails = Engine.GetGUIObjectByName("supplementalSelectionDetails");
this.hoverPanel = Engine.GetGUIObjectByName("hoverPanel");
this.resourceCountsBoon = Engine.GetGUIObjectByName("resourceCountsBoon");
// bandbox has no size defined, it serves to get the screen size, maybe there is a better way.
this.bandbox = Engine.GetGUIObjectByName("bandbox");

this.addCounter("population", CounterPopulation);
for (const resCode of g_ResourceData.GetCodes())
this.addCounter(resCode, CounterResource);
this.resourceCountsBoon.onWindowResized = this.onWindowResized.bind(this);
this.minimapPanel.onWindowResized = this.onWindowResized.bind(this);

this.init();

Expand All @@ -34,7 +36,7 @@ class BoonGUICounterManager

init()
{
verticallySpaceObjects("resourceCountsBoon", 40);
verticallySpaceObjects("resourceCountsBoon", 41);
for (const counter of this.counters)
{
counter.icon.sprite = "stretched:session/icons/resources/" + counter.resCode + ".png";
Expand All @@ -43,14 +45,32 @@ class BoonGUICounterManager

onWindowResized()
{
const widthMinimap = this.minimapPanel.getComputedSize().right;
const heightMinimap = this.minimapPanel.getComputedSize().top;
const dimensionsCounterPanel = `0 ${heightMinimap - 180} 140 ${heightMinimap+20}`;

if (Math.abs(widthMinimap - this.supplementalSelectionDetails.getComputedSize().left) >= 100)
this.resourceCountsBoon.size = `${widthMinimap - 42} 100%-200 ${widthMinimap + 98} 100%`;
const dimensionsMiniPanel = "0 100%-276 250 100%-26";
const dimensionsHoverPanel = "0 100%-63 251 100%";
const screenSize = this.bandbox.getComputedSize().right;
// arbitrarily set to 1600, just felt right
if (screenSize >= 1600)
{
this.minimapPanel.size = "0 100%-332 300 100%-32";
this.hoverPanel.size = "0 100%-76 301 100%";
}
else
this.resourceCountsBoon.size = dimensionsCounterPanel;
{
this.minimapPanel.size = dimensionsMiniPanel;
this.hoverPanel.size = dimensionsHoverPanel;
}
const widthMinimap = this.minimapPanel.getComputedSize().right;
this.resourceCountsBoon.size = `${widthMinimap} 100%-205 ${widthMinimap + 144} 100%`;
// Testing for good dimensions, width&height should be the same or very close
// const testSizes = ["idleWorkerButton", "minimapPanel"];
// for (let i = 0; i < testSizes.length; i++)
// {
// const objects = Engine.GetGUIObjectByName(testSizes[i]).getComputedSize();
// const width = objects.right - objects.left;
// const height = objects.bottom - objects.top;
// warn(uneval(`${testSizes[i]}` + "width" + width));
// warn(uneval(`${testSizes[i]}` + "height" + height));
// }
}

rebuild()
Expand Down
2 changes: 1 addition & 1 deletion gui/session/counters/Counters.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- This list encompasses resources and population -->
<object name="resourceCountsBoon" type="image" sprite="genericPanel">
<object name="resourceCountsBoon" z="50" type="image" sprite="genericPanel">
<repeat count="5">
<object name="resourceBoon[n]" type="button" style="resourceCounter" tooltip_style="sessionToolTipCircleBottom">
<object size="5 2 40 40" type="image" name="resourceBoon[n]_icon" ghost="true" />
Expand Down
51 changes: 25 additions & 26 deletions gui/session/minimap/MiniMap.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<object name="minimapPanel" size="-7 100%-350 350 100%">
<!-- Black background circle-->
<object type="image" size="10 24 100%-47 100%-33" sprite="stretched:session/background_circle.png" ghost="true" />
<!-- Background hover panel below the minimap -->
<object type="image" size="6 75%+15 100%-43 100%" sprite="stretched:session/background_hover_panel.png" ghost="true" />

<!-- MiniMap -->
<object name="minimap" size="9 22 100%-44 100%-31" type="minimap" mask="true" flare_texture_count="16" flare_render_size="32" flare_animation_speed="11" flare_interleave="true" flare_lifetime_seconds="6" />

<!-- Minimap circle -->
<object type="image" sprite="stretched:session/background_minimap_circle.png" size="7 20 100%-42 100%-29" ghost="true" />

<!-- Idle Worker Button -->
<object name="idleWorkerButton" type="button" size="74%+4 75%+19 89%-8 90%+7" tooltip_style="sessionToolTipCircleBottom" hotkey="selection.idleworker" sprite="stretched:session/minimap-idle.png" sprite_over="stretched:session/minimap-idle-highlight.png" sprite_disabled="stretched:session/minimap-idle-disabled.png" mouse_event_mask="texture:session/minimap-idle.png" sound_pressed="audio/interface/ui/ui_button_click.ogg" />
<!-- Total number of idle workers -->
<object name="totalNumberIdleWorkers" type="text" size="74%+4 75%+19 89%-8 90%+7" style="resourceIdleWorker" />

<!-- Flare Button -->
<object name="flareButton" type="button" size="62%+9 85%+8 77%-3 100%-4" tooltip_style="sessionToolTipCircleBottom" hotkey="session.flareactivate" sprite="stretched:session/minimap-flare.png" sprite_over="stretched:session/minimap-flare-highlight.png" mouse_event_mask="texture:session/minimap-flare.png" sprite_disabled="stretched:session/minimap-flare-disabled.png" sound_pressed="audio/interface/ui/ui_button_click.ogg" />

<!-- Score Button -->
<object name="scoreButton" type="button" size="1%+8 75%+19 16%-4 90%+7" tooltip_style="sessionToolTipCircleBottom" sprite="stretched:session/minimap-score.png" sprite_over="stretched:session/minimap-score-highlight.png" mouse_event_mask="texture:session/minimap-score.png" sound_pressed="audio/interface/ui/ui_button_click.ogg">
<action on="Press">g_stats.toggle();</action>
<object>
<!-- Circle-->
<object name="minimapPanel">
<!-- Black background circle-->
<object type="image" size="3 3 100% 100%" sprite="stretched:session/background_circle.png" ghost="true"/>
<!-- MiniMap -->
<object name="minimap" size="2 2 100% 100%" type="minimap" mask="true" flare_texture_count="16" flare_render_size="32" flare_animation_speed="11" flare_interleave="true" flare_lifetime_seconds="6" />
<!-- Minimap circle -->
<object type="image" sprite="stretched:session/background_minimap_circle.png" size="0 0 100% 100%" ghost="true" />
</object>
<!-- Hover panel below the minimap -->
<object name="hoverPanel" type="image" sprite="minimapHoverPanel">
<!-- Idle Worker Button -->
<object name="idleWorkerButton" type="button" size="84% 6% 98% 60%+1" tooltip_style="sessionToolTipCircleBottom" hotkey="selection.idleworker" sprite="stretched:session/minimap-idle.png" sprite_over="stretched:session/minimap-idle-highlight.png" sprite_disabled="stretched:session/minimap-idle-disabled.png" mouse_event_mask="texture:session/minimap-idle.png" sound_pressed="audio/interface/ui/ui_button_click.ogg">
<!-- Total number of idle workers -->
<object name="totalNumberIdleWorkers" type="text" style="resourceIdleWorker" />
</object>
<!-- Flare Button -->
<object name="flareButton" type="button" size="72% 40%-1 86% 94%" tooltip_style="sessionToolTipCircleBottom" hotkey="session.flareactivate" sprite="stretched:session/minimap-flare.png" sprite_over="stretched:session/minimap-flare-highlight.png" mouse_event_mask="texture:session/minimap-flare.png" sprite_disabled="stretched:session/minimap-flare-disabled.png" sound_pressed="audio/interface/ui/ui_button_click.ogg" />
<!-- Score Button -->
<object name="scoreButton" type="button" size="2%-1 6% 16%-1 60%+1" tooltip_style="sessionToolTipCircleBottom" sprite="stretched:session/minimap-score.png" sprite_over="stretched:session/minimap-score-highlight.png" mouse_event_mask="texture:session/minimap-score.png" sound_pressed="audio/interface/ui/ui_button_click.ogg">
<action on="Press">g_stats.toggle();</action>
</object>
<!-- Diplomacy Colors Button -->
<object name="diplomacyColorsButton" type="button" size="14% 40%-1 28% 94%" tooltip_style="sessionToolTipCircleBottom" hotkey="session.diplomacycolors" sound_pressed="audio/interface/ui/ui_button_click.ogg" />
</object>

<!-- Diplomacy Colors Button -->
<object name="diplomacyColorsButton" type="button" size="13%+3 85%+8 28%-9 100%-4" tooltip_style="sessionToolTipCircleBottom" hotkey="session.diplomacycolors" sound_pressed="audio/interface/ui/ui_button_click.ogg" />
</object>
1 change: 0 additions & 1 deletion gui/session/session.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
size="50%-316 100%-166 50%-110 100%"
sprite="supplementalDetailsPanelAdjusted"
type="image"
z="200"
>
<include directory="gui/session/selection_panels_left/"/>
</object>
Expand Down
2 changes: 1 addition & 1 deletion gui/session/top_panel/CounterPopulation~boongui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CounterPopulation.prototype.rebuild = function(playerState, diploColor)
{
this.count.caption = sprintf(this.CounterCaption, playerState);
const cCL = this.count.caption.length;
const font = cCL <= 41 ? "sans-stroke-20" : cCL <= 42 ?"sans-stroke-18": "sans-stroke-16";
const font = cCL <= 41 ? "sans-stroke-18" : "sans-stroke-16";
this.count.caption = setStringTags(this.count.caption, { font });
let total = 0;
for (const resCode of g_ResourceData.GetCodes())
Expand Down

0 comments on commit 84f3938

Please sign in to comment.