* Revised and hopefully ultimate resource counters. I have to admit they look pretty damn good to me.
This was SVN commit r3619.
This commit is contained in:
parent
201aae41d9
commit
3a35ea935c
@ -169,23 +169,19 @@
|
||||
<object name="snResourceCounter_1"
|
||||
style="snCounter"
|
||||
type="button"
|
||||
>
|
||||
</object>
|
||||
/>
|
||||
<object name="snResourceCounter_2"
|
||||
style="snCounter"
|
||||
type="button"
|
||||
>
|
||||
</object>
|
||||
/>
|
||||
<object name="snResourceCounter_3"
|
||||
style="snCounter"
|
||||
type="button"
|
||||
>
|
||||
</object>
|
||||
/>
|
||||
<object name="snResourceCounter_4"
|
||||
style="snCounter"
|
||||
type="button"
|
||||
>
|
||||
</object>
|
||||
/>
|
||||
<object name="snResourceCounter_5"
|
||||
style="snCounter"
|
||||
type="button"
|
||||
@ -201,10 +197,47 @@
|
||||
// resource is updated, so at this point we don't sweat that they have the same
|
||||
// coordinates).
|
||||
addCrds (tempName, 50, 0, -200, 4,
|
||||
snConst.MiniIcon.Width+54, snConst.MiniIcon.Height-10+5);
|
||||
snConst.MiniIcon.Width+54, 32);
|
||||
}
|
||||
]]></action>
|
||||
</object>
|
||||
|
||||
<object name="snResourceCounterIcon_1"
|
||||
style="snResourceIcon"
|
||||
type="button"
|
||||
/>
|
||||
<object name="snResourceCounterIcon_2"
|
||||
style="snResourceIcon"
|
||||
type="button"
|
||||
/>
|
||||
<object name="snResourceCounterIcon_3"
|
||||
style="snResourceIcon"
|
||||
type="button"
|
||||
/>
|
||||
<object name="snResourceCounterIcon_4"
|
||||
style="snResourceIcon"
|
||||
type="button"
|
||||
/>
|
||||
<object name="snResourceCounterIcon_5"
|
||||
style="snResourceIcon"
|
||||
type="button"
|
||||
>
|
||||
<action on="Load"><![CDATA[
|
||||
// Seek through this group of buttons (determining length from last object's name).
|
||||
max = this.name.substring (this.name.lastIndexOf ("_")+1, this.name.length);
|
||||
for (loop = 1; loop <= max; loop++)
|
||||
{
|
||||
// Get name of current object in group.
|
||||
tempName = this.name.substring (0, this.name.lastIndexOf ("_")+1) + loop;
|
||||
// Create coordinates for object (the actual coordinates are refreshed when the
|
||||
// resource is updated, so at this point we don't sweat that they have the same
|
||||
// coordinates).
|
||||
addCrds (tempName, 50, 0, -200, 4,
|
||||
32, 32);
|
||||
}
|
||||
]]></action>
|
||||
</object>
|
||||
|
||||
</object>
|
||||
|
||||
<!-- GROUP: STATUS PANE -->
|
||||
|
@ -41,18 +41,20 @@ function startMap (mapName, losSetting, openWindow)
|
||||
btCode = new Array("");
|
||||
messageBox(400, 200, "The game could not be started with the given parameters. You probably have entered an invalid map name.", "Error", 0, btCaptions, btCode);
|
||||
}
|
||||
|
||||
|
||||
// Set starting UI layout.
|
||||
GUIType=rb;
|
||||
flipGUI (GUIType);
|
||||
|
||||
// Initialise Resource Pools by attaching them to the Player object.
|
||||
// (CPlayer code takes care of giving a copy to each player.)
|
||||
createResources();
|
||||
|
||||
|
||||
// Set session UI sprites to match the skin for the player's civilisation.
|
||||
// (We don't have skins for all civs yet, so we're using the standard menu skin. But it should be settable from here later.)
|
||||
setSkin ("wheat");
|
||||
|
||||
// Set GUI coordinates to starting orientation.
|
||||
flipGUI (GUIType);
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
@ -192,21 +192,26 @@ function refreshResource (resourceName, resourceIndex)
|
||||
|
||||
// Get resource readout object.
|
||||
resourceObject = getGUIObjectByName ("snResourceCounter_" + (resourceIndex + 1));
|
||||
// Get resource icon object.
|
||||
resourceIconObject = getGUIObjectByName ("snResourceCounterIcon_" + (resourceIndex + 1));
|
||||
|
||||
// Update counter caption (since we need to have up-to-date text to determine the length of the counter).
|
||||
caption
|
||||
= "[icon=iconResource" + resourceName + " displace=\"0 0\"] "
|
||||
+ localPlayer.resource.valueOf()[resourceName];
|
||||
caption = localPlayer.resource.valueOf()[resourceName];
|
||||
// The Population counter also lists the amount of available housing.
|
||||
if (resourceName == "Population")
|
||||
caption
|
||||
+= "/" + localPlayer.resource.valueOf()["Housing"];
|
||||
caption += "/" + localPlayer.resource.valueOf()["Housing"];
|
||||
resourceObject.caption = caption;
|
||||
|
||||
// Update caption tooltip.
|
||||
// Update counter tooltip.
|
||||
resourceObject.tooltip = resourceName + ": " + resourceObject.caption;
|
||||
|
||||
// Set resource icon.
|
||||
resourceIconObject.cell_id = cellGroup["Resource"][resourceName.toLowerCase()].id;
|
||||
|
||||
// Get the index of the resource readout to be resized.
|
||||
crdResult = getCrd (resourceObject.name, true);
|
||||
// Get the index of the resource icon.
|
||||
crdIconResult = getCrd (resourceIconObject.name, true);
|
||||
|
||||
// For each coordinate group stored for this control,
|
||||
for (coordGroup in Crd[crdResult].coord)
|
||||
@ -252,14 +257,32 @@ function refreshResource (resourceName, resourceIndex)
|
||||
= Crd[crdResult-1].coord[coordGroup].height;
|
||||
}
|
||||
|
||||
// Transfer to icon coordinates.
|
||||
Crd[crdIconResult].coord[coordGroup].width = 32;
|
||||
Crd[crdIconResult].coord[coordGroup].height = 32;
|
||||
Crd[crdIconResult].coord[coordGroup].x = Crd[crdResult].coord[coordGroup].x;
|
||||
Crd[crdIconResult].coord[coordGroup].y = Crd[crdResult].coord[coordGroup].y;
|
||||
|
||||
|
||||
// Recalculate readout's size coordinates.
|
||||
Crd[crdResult].size[coordGroup] = calcCrdArray (Crd[crdResult].coord[coordGroup].rx, Crd[crdResult].coord[coordGroup].ry, Crd[crdResult].coord[coordGroup].x, Crd[crdResult].coord[coordGroup].y, Crd[crdResult].coord[coordGroup].width, Crd[crdResult].coord[coordGroup].height, Crd[crdResult].coord[coordGroup].rx2, Crd[crdResult].coord[coordGroup].ry2);
|
||||
|
||||
// Recalculate icon's size coordinates.
|
||||
Crd[crdIconResult].size[coordGroup] = calcCrdArray (Crd[crdIconResult].coord[coordGroup].rx, Crd[crdIconResult].coord[coordGroup].ry, Crd[crdIconResult].coord[coordGroup].x, Crd[crdIconResult].coord[coordGroup].y, Crd[crdIconResult].coord[coordGroup].width, Crd[crdIconResult].coord[coordGroup].height, Crd[crdIconResult].coord[coordGroup].rx2, Crd[crdIconResult].coord[coordGroup].ry2);
|
||||
|
||||
// If this coordinate is part of the currently active set, update the control onscreen too.
|
||||
if (coordGroup == GUIType)
|
||||
{
|
||||
// Update counter size.
|
||||
resourceObject.size = Crd[getCrd(resourceObject.name, true)].size[GUIType];
|
||||
// resourceObject.size = Crd[getCrd(resourceObject.name, true)].size[GUIType];
|
||||
// resourceIconObject.size = Crd[getCrd(resourceIconObject.name, true)].size[GUIType];
|
||||
|
||||
resourceObject.size = Crd[crdResult].size[GUIType];
|
||||
resourceIconObject.size = Crd[crdIconResult].size[GUIType];
|
||||
|
||||
console.write (resourceName + " Counter: " + resourceObject.size);
|
||||
console.write (resourceName + " Icon: " + resourceIconObject.size);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -666,13 +666,17 @@
|
||||
|
||||
<sprite name="snCounter">
|
||||
<image texture="session/counter_tile.dds"
|
||||
real_texture_placement="0 0 21 21"
|
||||
size="0% 0% 100%-15 100%"
|
||||
real_texture_placement="0 0 32 32"
|
||||
size="0%+32 0% 100%-32 0%+32"
|
||||
/>
|
||||
<image texture="session/counter_edge.dds"
|
||||
real_texture_placement="0 0 15 21"
|
||||
size="100%-15 0% 100% 100%"
|
||||
real_texture_placement="0 0 32 32"
|
||||
size="100%-32 0% 100% 0%+32"
|
||||
/>
|
||||
<image texture="session/counter_icon.dds"
|
||||
real_texture_placement="0 0 32 32"
|
||||
size="0% 0% 0%+32 0%+32"
|
||||
/>
|
||||
</sprite>
|
||||
|
||||
<!--
|
||||
|
@ -485,9 +485,19 @@
|
||||
tooltip="(TBA)"
|
||||
/>
|
||||
|
||||
<style name="snIcon"
|
||||
ghost="true"
|
||||
/>
|
||||
|
||||
<style name="snResourceIcon"
|
||||
ghost="true"
|
||||
sprite="snIconSheetResource"
|
||||
z="100"
|
||||
/>
|
||||
|
||||
<style name="snCounter"
|
||||
sprite="snCounter"
|
||||
text_align="left"
|
||||
text_align="right"
|
||||
text_valign="center"
|
||||
font="tahoma14"
|
||||
textcolor="white"
|
||||
|
Loading…
Reference in New Issue
Block a user