Revert f5ab6255d0. I accidentally somehow committed my whole working tree on this computer....

This was SVN commit r13772.
This commit is contained in:
alpha123
2013-08-26 04:15:36 +00:00
parent f5ab6255d0
commit b10a01645f
14 changed files with 816 additions and 979 deletions
-1
View File
@@ -135,7 +135,6 @@
sprite_bar_vertical_pressed CDATA #IMPLIED
sprite_back_vertical CDATA #IMPLIED
minimum_bar_size CDATA #IMPLIED
maximum_bar_size CDATA #IMPLIED
>
<!--
@@ -35,19 +35,19 @@ function displaySingle(entState, template)
// Rank
if (entState.identity && entState.identity.rank && entState.identity.classes)
{
getGUIObjectByName("rankIcon").tooltip = entState.identity.rank + " Rank";
getGUIObjectByName("rankIcon").sprite = getRankIconSprite(entState);
getGUIObjectByName("rankIcon").hidden = false;
}
{
getGUIObjectByName("rankIcon").tooltip = entState.identity.rank + " Rank";
getGUIObjectByName("rankIcon").sprite = getRankIconSprite(entState);
getGUIObjectByName("rankIcon").hidden = false;
}
else
{
getGUIObjectByName("rankIcon").hidden = true;
getGUIObjectByName("rankIcon").tooltip = "";
}
// Hitpoints
if (entState.hitpoints)
getGUIObjectByName("rankIcon").tooltip = "";
}
// Hitpoints
if (entState.hitpoints)
{
var unitHealthBar = getGUIObjectByName("healthBar");
var healthSize = unitHealthBar.size;
@@ -60,11 +60,11 @@ function displaySingle(entState, template)
}
else
{
getGUIObjectByName("healthSection").hidden = true;
}
// TODO: Stamina
var player = Engine.GetPlayerID();
getGUIObjectByName("healthSection").hidden = true;
}
// TODO: Stamina
var player = Engine.GetPlayerID();
if (entState.stamina && (entState.player == player || g_DevSettings.controlAll))
{
getGUIObjectByName("staminaSection").hidden = false;
@@ -79,11 +79,11 @@ function displaySingle(entState, template)
{
var experienceBar = getGUIObjectByName("experienceBar");
var experienceSize = experienceBar.size;
experienceSize.rtop = 100 - (100 * Math.max(0, Math.min(1, 1.0 * +entState.promotion.curr / +entState.promotion.req)));
experienceBar.size = experienceSize;
var experience = "[font=\"serif-bold-13\"]Experience: [/font]" + Math.floor(entState.promotion.curr);
if (entState.promotion.curr < entState.promotion.req)
experienceSize.rtop = 100 - (100 * Math.max(0, Math.min(1, 1.0 * +entState.promotion.curr / +entState.promotion.req)));
experienceBar.size = experienceSize;
var experience = "[font=\"serif-bold-13\"]Experience: [/font]" + Math.floor(entState.promotion.curr);
if (entState.promotion.curr < entState.promotion.req)
experience += " / " + entState.promotion.req;
getGUIObjectByName("experience").tooltip = experience;
getGUIObjectByName("experience").hidden = false;
@@ -120,14 +120,10 @@ function displaySingle(entState, template)
}
else
{
getGUIObjectByName("resourceSection").hidden = true;
}
var activeResource = entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints)
getGUIObjectByName("resourceThroughputIcon").hidden = !activeResource;
getGUIObjectByName("resourceThroughputText").hidden = !activeResource;
// Resource carrying
getGUIObjectByName("resourceSection").hidden = true;
}
// Resource carrying
if (entState.resourceCarrying && entState.resourceCarrying.length)
{
// We should only be carrying one resource type at once, so just display the first
@@ -151,32 +147,26 @@ function displaySingle(entState, template)
if (entState.trader.goods.amount.market2Gain)
totalGain += entState.trader.goods.amount.market2Gain;
getGUIObjectByName("resourceCarryingText").caption = totalGain;
getGUIObjectByName("resourceCarryingIcon").tooltip = "Gain: " + getTradingTooltip(entState.trader.goods.amount);
}
else if (entState.foundation)
{
// Number of builders
getGUIObjectByName("resourceCarryingIcon").hidden = false;
getGUIObjectByName("resourceCarryingText").hidden = false;
getGUIObjectByName("resourceCarryingIcon").tooltip = "Gain: " + getTradingTooltip(entState.trader.goods.amount);
}
// And for number of workers
else if (entState.foundation)
{
getGUIObjectByName("resourceCarryingIcon").hidden = false;
getGUIObjectByName("resourceCarryingText").hidden = false;
getGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png";
getGUIObjectByName("resourceCarryingText").caption = entState.foundation.numBuilders + " ";
getGUIObjectByName("resourceCarryingIcon").tooltip = "Number of builders";
}
else if (activeResource)
{
// Number of gatherers
getGUIObjectByName("resourceCarryingIcon").hidden = false;
getGUIObjectByName("resourceCarryingText").hidden = false;
getGUIObjectByName("resourceCarryingIcon").tooltip = "Number of builders";
}
else if (entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints))
{
getGUIObjectByName("resourceCarryingIcon").hidden = false;
getGUIObjectByName("resourceCarryingText").hidden = false;
getGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png";
getGUIObjectByName("resourceCarryingText").caption = entState.resourceSupply.gatherers.length + " / " + entState.resourceSupply.maxGatherers + " ";
getGUIObjectByName("resourceCarryingIcon").tooltip = "Current/max gatherers";
// Current total resource output in resources/second
getGUIObjectByName("resourceThroughputIcon").sprite = "stretched:session/icons/production.png";
getGUIObjectByName("resourceThroughputText").caption = entState.resourceSupply.throughput.toFixed(2);
getGUIObjectByName("resourceThroughputIcon").tooltip = "Currently producing " + entState.resourceSupply.throughput.toFixed(2) + " resources/second.";
}
else
getGUIObjectByName("resourceCarryingText").caption = entState.resourceSupply.gatherers.length + " / " + entState.resourceSupply.maxGatherers + " ";
getGUIObjectByName("resourceCarryingIcon").tooltip = "Current/max gatherers";
}
else
{
getGUIObjectByName("resourceCarryingIcon").hidden = true;
getGUIObjectByName("resourceCarryingText").hidden = true;
@@ -184,11 +174,11 @@ function displaySingle(entState, template)
// Set Player details
getGUIObjectByName("specific").caption = specificName;
getGUIObjectByName("player").caption = playerName;
getGUIObjectByName("playerColorBackground").sprite = "colour: " + playerColor;
if (genericName)
{
getGUIObjectByName("player").caption = playerName;
getGUIObjectByName("playerColorBackground").sprite = "colour: " + playerColor;
if (genericName)
{
getGUIObjectByName("generic").caption = "(" + genericName + ")";
}
else
@@ -229,25 +219,25 @@ function displaySingle(entState, template)
// Show max attack range if ranged attack, also convert to tiles (4m per tile)
if (entState.attack.type == "Ranged")
{
var realRange = entState.attack.elevationAdaptedRange;
var range = entState.attack.maxRange;
attack += ", [font=\"serif-bold-13\"]Range:[/font] " +
Math.round(range/4);
if (Math.round((realRange - range)/4) > 0)
{
attack += " (+" + Math.round((realRange - range)/4) + ")";
}
var realRange = entState.attack.elevationAdaptedRange;
var range = entState.attack.maxRange;
attack += ", [font=\"serif-bold-13\"]Range:[/font] " +
Math.round(range/4);
if (Math.round((realRange - range)/4) > 0)
{
attack += " (+" + Math.round((realRange - range)/4) + ")";
}
else if (Math.round((realRange - range)/4) < 0)
{
attack += " (" + Math.round((realRange - range)/4) + ")";
} // don't show when it's 0
}
}
getGUIObjectByName("attackAndArmorStats").tooltip = attack + "\n[font=\"serif-bold-13\"]Armor:[/font] " + armorTypeDetails(entState.armour);
}
}
getGUIObjectByName("attackAndArmorStats").tooltip = attack + "\n[font=\"serif-bold-13\"]Armor:[/font] " + armorTypeDetails(entState.armour);
// Icon Tooltip
var iconTooltip = "";
@@ -284,11 +274,11 @@ function displayMultiple(selection, template)
}
if (averageHealth > 0)
{
var unitHealthBar = getGUIObjectByName("healthBarMultiple");
var healthSize = unitHealthBar.size;
healthSize.rtop = 100-100*Math.max(0, Math.min(1, averageHealth / maxHealth));
unitHealthBar.size = healthSize;
{
var unitHealthBar = getGUIObjectByName("healthBarMultiple");
var healthSize = unitHealthBar.size;
healthSize.rtop = 100-100*Math.max(0, Math.min(1, averageHealth / maxHealth));
unitHealthBar.size = healthSize;
var hitpoints = "[font=\"serif-bold-13\"]Hitpoints [/font]" + averageHealth + " / " + maxHealth;
var healthMultiple = getGUIObjectByName("healthMultiple");
@@ -297,11 +287,11 @@ function displayMultiple(selection, template)
}
else
{
getGUIObjectByName("healthMultiple").hidden = true;
}
// TODO: Stamina
// getGUIObjectByName("staminaBarMultiple");
getGUIObjectByName("healthMultiple").hidden = true;
}
// TODO: Stamina
// getGUIObjectByName("staminaBarMultiple");
getGUIObjectByName("numberOfUnits").caption = selection.length;
@@ -317,17 +307,17 @@ function updateSelectionDetails()
var detailsPanel = getGUIObjectByName("selectionDetails");
var commandsPanel = getGUIObjectByName("unitCommands");
g_Selection.update();
var selection = g_Selection.toList();
if (selection.length == 0)
{
g_Selection.update();
var selection = g_Selection.toList();
if (selection.length == 0)
{
getGUIObjectByName("detailsAreaMultiple").hidden = true;
getGUIObjectByName("detailsAreaSingle").hidden = true;
hideUnitCommands();
supplementalDetailsPanel.hidden = true;
detailsPanel.hidden = true;
getGUIObjectByName("detailsAreaSingle").hidden = true;
hideUnitCommands();
supplementalDetailsPanel.hidden = true;
detailsPanel.hidden = true;
commandsPanel.hidden = true;
return;
}
@@ -177,12 +177,12 @@
<object hotkey="camera.jump.set.10">
<action on="Press">setJumpCamera(10);</action>
</object>
<!-- Stop the selected units -->
<object hotkey="session.stop">
<action on="Press">stopUnits(g_Selection.toList());</action>
</object>
<!-- queue first unit in the training queue -->
<object hotkey="session.queueunit.1">
<action on="Press">addTrainingByPosition(0);</action>
@@ -202,7 +202,7 @@
<object hotkey="session.queueunit.4">
<action on="Press">addTrainingByPosition(3);</action>
</object>
<!-- queue 5th unit in the training queue -->
<object hotkey="session.queueunit.5">
<action on="Press">addTrainingByPosition(4);</action>
@@ -315,7 +315,7 @@
<!-- ================================ ================================ -->
<!-- Time elapsed counter -->
<!-- ================================ ================================ -->
<object size="100%-120 45 100%-10 65" type="text" name="timeElapsedCounter" style="SettingsText" hotkey="timeelapsedcounter.toggle" hidden="true">
<action on="Press">this.hidden = !this.hidden;</action>
</object>
@@ -442,7 +442,7 @@
z="200"
>
<object type="text" style="TitleText" size="50%-96 -16 50%+96 16">Settings</object>
<object style="TranslucentPanelThinBorder"
type="image"
size="32 32 100%-32 100%-70"
@@ -453,21 +453,21 @@
<action on="Load">if (renderer.shadows) this.checked = true; else this.checked = false;</action>
<action on="Press">renderer.shadows = this.checked;</action>
</object>
<!-- Settings / Shadow PCF -->
<object size="0 35 100%-80 60" type="text" style="RightLabelText" ghost="true">Enable Shadow Filtering</object>
<object name="shadowPCFCheckbox" size="100%-56 40 100%-30 65" type="checkbox" style="StoneCrossBox" checked="true">
<action on="Load">if (renderer.shadowPCF) this.checked = true; else this.checked = false;</action>
<action on="Press">renderer.shadowPCF = this.checked;</action>
</object>
<!-- Settings / Water Normals -->
<object size="0 60 100%-80 85" type="text" style="RightLabelText" ghost="true">Water - HQ Waviness</object>
<object name="waterNormalCheckox" size="100%-56 65 100%-30 90" type="checkbox" style="StoneCrossBox" checked="true">
<action on="Load">if (renderer.waternormal) this.checked = true; else this.checked = false;</action>
<action on="Press">renderer.waternormal = this.checked;</action>
</object>
<!-- Settings / Real Depth -->
<object size="0 85 100%-80 110" type="text" style="RightLabelText" ghost="true">Water - Use Actual Depth</object>
<object name="waterRealDepthCheckbox" size="100%-56 90 100%-30 115" type="checkbox" style="StoneCrossBox" checked="true">
@@ -481,28 +481,28 @@
<action on="Load">if (renderer.waterreflection) this.checked = true; else this.checked = false;</action>
<action on="Press">renderer.waterreflection = this.checked; </action>
</object>
<!-- Settings / Refraction -->
<object size="0 135 100%-80 160" type="text" style="RightLabelText" ghost="true">Water - Enable Refraction</object>
<object name="waterRefractionCheckbox" size="100%-56 140 100%-30 165" type="checkbox" style="StoneCrossBox" checked="true">
<action on="Load">if (renderer.waterrefraction) this.checked = true; else this.checked = false;</action>
<action on="Press">renderer.waterrefraction = this.checked; </action>
</object>
<!-- Settings / Foam -->
<object size="0 160 100%-80 185" type="text" style="RightLabelText" ghost="true">Water - Enable Shore Foam</object>
<object name="waterFoamCheckbox" size="100%-56 165 100%-30 190" type="checkbox" style="StoneCrossBox" checked="true">
<action on="Load">if (renderer.waterfoam) this.checked = true; else this.checked = false;</action>
<action on="Press">renderer.waterfoam = this.checked; </action>
</object>
<!-- Settings / Waves -->
<object size="0 185 100%-80 210" type="text" style="RightLabelText" ghost="true">Water - Enable Shore Waves</object>
<object name="waterCoastalWavesCheckbox" size="100%-56 190 100%-30 215" type="checkbox" style="StoneCrossBox" checked="true">
<action on="Load">if (renderer.watercoastalwaves) this.checked = true; else this.checked = false;</action>
<action on="Press">renderer.watercoastalwaves = this.checked; </action>
</object>
<!-- Settings / Shadows -->
<object size="0 210 100%-80 235" type="text" style="RightLabelText" ghost="true">Water - Use Surface Shadows</object>
<object name="waterShadowsCheckbox" size="100%-56 215 100%-30 240" type="checkbox" style="StoneCrossBox" checked="true">
@@ -516,27 +516,27 @@
<action on="Load">if (renderer.particles) this.checked = true; else this.checked = false;</action>
<action on="Press">renderer.particles = this.checked;</action>
</object>
<!-- Settings / Unit Silhouettes -->
<object size="0 260 100%-80 285" type="text" style="RightLabelText" ghost="true">Enable Unit Silhouettes</object>
<object name="silhouettesCheckbox" size="100%-56 265 100%-30 290" type="checkbox" style="StoneCrossBox" checked="true">
<action on="Load">if (renderer.silhouettes) this.checked = true; else this.checked = false;</action>
<action on="Press">renderer.silhouettes = this.checked;</action>
</object>
<!-- Settings / Music-->
<object size="0 285 100%-80 310" type="text" style="RightLabelText" ghost="true">Enable Music</object>
<object name="musicCheckbox" size="100%-56 290 100%-30 315" type="checkbox" style="StoneCrossBox" checked="true">
<action on="Press">if (this.checked) global.music.start(); else global.music.stop();</action>
</object>
<!-- Settings / Dev Overlay -->
<object size="0 310 100%-80 335" type="text" style="RightLabelText" ghost="true">Developer Overlay</object>
<object name="developerOverlayCheckbox" size="100%-56 315 100%-30 340" type="checkbox" style="StoneCrossBox" checked="false">
<action on="Press">toggleDeveloperOverlay();</action>
</object>
</object>
<!-- Close button -->
<object type="button"
style="StoneButton"
@@ -640,7 +640,7 @@
</object>
<object size="100%-348 40 100%-198 65" name="gameSpeed" type="dropdown" buffer_zone="5" style="StoneDropDown" hidden="true" tooltip="Choose game speed" tooltip_style="sessionToolTip"/>
<!-- ================================ ================================ -->
<!-- Diplomacy Button -->
<!-- ================================ ================================ -->
@@ -790,12 +790,12 @@
name="unitHeroPanel"
size="0 36 50 86"
>
<object name="unitHeroButton" size="0 0 50 50" type="button" hidden="false" style="iconButton"
<object name="unitHeroButton" size="0 0 50 50" type="button" hidden="false" style="iconButton"
tooltip_style="sessionToolTip" tooltip="Attack and Armor">
<object name="unitHeroImage" size="5 5 100%-5 100%-5" type="image" ghost="true"/>
</object>
</object>
<!-- ================================ ================================ -->
<!-- Unit Selection Groups -->
<!-- ================================ ================================ -->
@@ -896,7 +896,7 @@
</object>
</object>
<object name="unitBarterPanel"
<object name="unitBarterPanel"
size="6 36 100% 100%"
hidden="true"
>
@@ -950,10 +950,10 @@
>
<!-- Unit details for Single Unit -->
<object size="50%-112 0 50%+112 100%" name="detailsAreaSingle">
<!-- Stats Bars -->
<object size= "2 0 100%-2 98" type="image" tooltip_style="sessionToolTip">
<object size="0 8 100% 60" type="image" sprite="edgedPanelShader">
<!-- Health bar -->
<object size="88 0 100% 24" name="healthSection">
@@ -991,25 +991,21 @@
</object>
</object>
</object>
<object size="0 60 100% 96" type="image" sprite="edgedPanelShader">
<!-- Attack and Armor -->
<object size="90 -2 126 34" name="attackAndArmorStats" type="image" sprite="stretched:session/icons/stances/defensive.png" tooltip="Attack and Armor" tooltip_style="sessionToolTip"/>
<!-- Resource carrying icon/counter -->
<!-- Used also for number of gatherers/builders -->
<object size="100%-78 -2 100%-84 34" type="text" name="resourceCarryingText" style="CarryingTextRight"/>
<object size="100%-36 -2 100%-56 34" type="image" name="resourceCarryingIcon" tooltip_style="sessionToolTip"/>
<!-- Throughput of this resource in resources/second -->
<object size="100%-10 -2 100%-28 34" type="text" name="resourceThroughputText" style="CarryingTextRight"/>
<object size="100%-5 -2 100% 34" type="text" name="resourceThroughputIcon" tooltip_style="sessionToolTip"/>
<object size="100%-98 -2 100%-28 34" type="text" name="resourceCarryingText" style="CarryingTextRight"/>
<object size="100%-36 -2 100% 34" type="image" name="resourceCarryingIcon" tooltip_style="sessionToolTip"/>
</object>
<!-- Big unit icon -->
<object size="-8 -8 88 88" type="image" name="iconBorder" sprite="iconBorder" tooltip_style="sessionToolTip">
<object size="1 1 100%-1 100%-1" type="image" name="icon" ghost="true"/>
<!-- Experience bar -->
<object size="2 2 6 100%-2" type="image" name="experience" tooltip="Experience" tooltip_style="sessionToolTip">
<object type="image" sprite="barBorder" ghost="true" size="-1 -1 100%+1 100%+1"/>
@@ -1017,18 +1013,18 @@
<object type="image" sprite="experienceForeground" ghost="true" name="experienceBar"/>
<object type="image" sprite="statsBarShaderVertical" ghost="true"/>
</object>
<object z="20" size="4 4 20 20" name="rankIcon" type="image" tooltip="Rank" tooltip_style="sessionToolTip"/>
</object>
</object>
<!-- Names (this must come before the attack and armor icon to avoid clipping issues) -->
<object size="2 96 100%-2 100%-36" name="statsArea" type="image" sprite="edgedPanelShader">
<!-- These images are used to clip off the top and bottom of the civ icon -->
<object z="30" size="0 -5 100% 40" ghost="true" type="image" sprite="remove"/>
<object z="30" size="0 100%-5 100% 100%+40" ghost="true" type="image" sprite="remove"/>
<object z="30" size="0 2 100% 45" ghost="true">
<!-- Specific Name -->
<object size="0 0 100% 20" name="specific" ghost="true" type="text" style="SpecificNameCentered"/>
@@ -1036,13 +1032,13 @@
<!-- Generic Name -->
<object size="0 15 100% 36" name="generic" ghost="true" type="text" style="GenericNameCentered"/>
</object>
<!-- Player Name and Civ -->
<object size="0 40 100% 100%">
<object size="50%-64 50%-64 50%+64 50%+64" name="playerCivIcon" type="image" ghost="true"/>
<object size="0 0 100% 100%" name="playerColorBackground" type="image" sprite="playerColorBackground" ghost="true"/>
<object size="0 0 100% 100%" type="image" sprite="bottomEdgedPanelShader" ghost="true"/>
<!-- Why is this being automatically ghosted? In the mean time, set ghost to false -->
<object ghost="false" size="0 0 100% 100%-5" name="player" type="text" style="largeCenteredOutlinedText" tooltip_style="sessionToolTip"/>
</object>
@@ -1216,7 +1212,7 @@
</repeat>
</object>
</object>
<object name="unitPackPanel"
size="10 12 100% 100%"
>
File diff suppressed because it is too large Load Diff
@@ -28,33 +28,10 @@ ResourceSupply.prototype.Schema =
"<value>treasure.stone</value>" +
"<value>treasure.metal</value>" +
"<value>treasure.food</value>" +
"</choice>" +
"</element>" +
"<optional>" +
"<element name='Regeneration' a:help='Controls whether this resource can regenerate its remaining amount.'>" +
"<interleave>" +
"<element name='Rate' a:help='Optional regeneration rate. Resources/second if the growth is linear or the rate of quadratic growth if the growth is quadratic.'>" +
"<ref name='nonNegativeDecimal'/>" +
"</element>" +
"<optional>" +
"<element name='Acceleration' a:help='Controls the curve the regeneration rate will follow for quadratic growth; does nothing for linear growth.'>" +
"<ref name='nonNegativeDecimal'/>" +
"</element>" +
"</optional>" +
"<element name='Delay' a:help='Seconds between when the number of gatherers hit 0 and the resource starts regenerating.'>" +
"<data type='nonNegativeInteger'/>" +
"</element>" +
"<element name='Growth' a:help='Growth formula for regeneration. Either linear or quadratic. Linear continues at a steady rate, while quadratic gets faster over time.'>" +
"<choice>" +
"<value>linear</value>" +
"<value>quadratic</value>" +
"</choice>" +
"</element>" +
"</interleave>" +
"</element>" +
"</optional>" +
"<element name='MaxGatherers' a:help='Amount of gatherers who can gather resources from this entity at the same time'>" +
"<data type='nonNegativeInteger'/>" +
"</choice>" +
"</element>" +
"<element name='MaxGatherers' a:help='Amount of gatherers who can gather resources from this entity at the same time'>" +
"<data type='nonNegativeInteger'/>" +
"</element>" +
"<optional>" +
"<element name='DiminishingReturns' a:help='The rate at which adding more gatherers decreases overall efficiency. Lower numbers = faster dropoff. Leave the element out for no diminishing returns.'>" +
@@ -66,18 +43,10 @@ ResourceSupply.prototype.Init = function()
{
// Current resource amount (non-negative)
this.amount = this.GetMaxAmount();
this.gatherers = []; // list of IDs
this.infinite = !isFinite(+this.template.Amount);
if (this.template.Regeneration) {
this.regenRate = +this.template.Regeneration.Rate;
if (this.template.Regeneration.Acceleration)
this.regenAccel = +this.template.Regeneration.Acceleration;
this.regenDelay = +this.template.Regeneration.Delay;
}
if (this.IsRegenerative())
this.RegenerateResources();
};
this.gatherers = []; // list of IDs
this.infinite = !isFinite(+this.template.Amount);
};
ResourceSupply.prototype.IsInfinite = function()
{
return this.infinite;
@@ -125,53 +94,16 @@ ResourceSupply.prototype.TakeResources = function(rate)
var old = this.amount;
this.amount = Math.max(0, old - rate);
var change = old - this.amount;
// Remove entities that have been exhausted
if (this.amount == 0 && !this.IsRegenerative())
Engine.DestroyEntity(this.entity);
Engine.PostMessage(this.entity, MT_ResourceSupplyChanged, { "from": old, "to": this.amount });
return { "amount": change, "exhausted": this.amount == 0 };
};
ResourceSupply.prototype.RegenerateResources = function(data, lateness)
{
var max = this.GetMaxAmount();
if (this.gatherers.length == 0 && !this.regenDelayTimer && this.amount < max)
{
var old = this.amount;
if (this.regenGrowth == "linear")
this.amount = Math.min(max, this.amount + data.rate);
else
this.amount = Math.min(max, this.amount + Math.max(1, data.rate * max * (data.acceleration * this.amount / max -Math.pow(this.amount / max, 2)) / 100));
Engine.PostMessage(this.entity, MT_ResourceSupplyChanged, { "from": old, "to": this.amount });
}
var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
var regenRate = this.GetRegenerationRate();
var absRegen = Math.abs(regenRate);
if (Math.floor(regenRate) == regenRate || this.regenGrowth == "quadratic")
cmpTimer.SetTimeout(this.entity, IID_ResourceSupply, "RegenerateResources", 1000, { "rate": regenRate, "acceleration": this.GetRegenerationAcceleration() });
else
cmpTimer.SetTimeout(this.entity, IID_ResourceSupply, "RegenerateResources", 1000 / absRegen,
{ "rate": absRegen == regenRate ? 1 : -1 });
};
ResourceSupply.prototype.StartRegenerationDelayTimer = function()
{
if (!this.regenDelayTimer) {
var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
this.regenDelayTimer = cmpTimer.SetTimeout(this.entity, IID_ResourceSupply, "CancelRegenerationDelayTimer", this.GetRegenerationDelay() * 1000, null);
}
};
ResourceSupply.prototype.CancelRegenerationDelayTimer = function()
{
var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
cmpTimer.CancelTimer(this.regenDelayTimer);
this.regenDelayTimer = null;
};
// Remove entities that have been exhausted
if (this.amount == 0)
Engine.DestroyEntity(this.entity);
Engine.PostMessage(this.entity, MT_ResourceSupplyChanged, { "from": old, "to": this.amount });
return { "amount": change, "exhausted": (this.amount == 0) };
};
ResourceSupply.prototype.GetType = function()
{
// All resources must have both type and subtype
@@ -185,54 +117,22 @@ ResourceSupply.prototype.IsAvailable = function(gathererID)
if (this.gatherers.length < this.GetMaxGatherers() || this.gatherers.indexOf(gathererID) !== -1)
return true;
return false;
};
ResourceSupply.prototype.IsRegenerative = function()
{
return this.GetRegenerationRate() != 0;
};
ResourceSupply.prototype.GetTerritoryOwner = function ()
{
var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
var cmpTerritoryManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TerritoryManager);
var cmpPosition = Engine.QueryInterface(this.entity, IID_Position);
if (!(cmpPosition && cmpPosition.IsInWorld()))
return 0; // Something's wrong, just say we're in neutral territory.
var pos = cmpPosition.GetPosition2D();
return cmpPlayerManager.GetPlayerByID(cmpTerritoryManager.GetOwner(pos.x, pos.y));
};
ResourceSupply.prototype.GetRegenerationRate = function()
{
return ApplyTechModificationsToPlayer("ResourceSupply/Regeneration/Rate", this.regenRate, this.GetTerritoryOwner());
};
ResourceSupply.prototype.GetRegenerationAcceleration = function()
{
return ApplyTechModificationsToPlayer("ResourceSupply/Regeneration/Acceleration", this.regenAccel, this.GetTerritoryOwner());
};
ResourceSupply.prototype.GetRegenerationDelay = function()
{
return ApplyTechModificationsToPlayer("ResourcesSupply/Regeneration/Delay", this.regenDelay, this.GetTerritoryOwner());
};
ResourceSupply.prototype.AddGatherer = function(gathererID)
{
if (!this.IsAvailable(gathererID))
return false;
if (this.gatherers.indexOf(gathererID) === -1)
{
this.gatherers.push(gathererID);
this.CancelRegenerationDelayTimer();
// broadcast message, mainly useful for the AIs.
Engine.PostMessage(this.entity, MT_ResourceSupplyGatherersChanged, { "to": this.gatherers });
}
return true;
};
};
ResourceSupply.prototype.AddGatherer = function(gathererID)
{
if (!this.IsAvailable(gathererID))
return false;
if (this.gatherers.indexOf(gathererID) === -1)
{
this.gatherers.push(gathererID);
// broadcast message, mainly useful for the AIs.
Engine.PostMessage(this.entity, MT_ResourceSupplyGatherersChanged, { "to": this.gatherers });
}
return true;
};
// should this return false if the gatherer didn't gather from said resource?
ResourceSupply.prototype.RemoveGatherer = function(gathererID)
@@ -241,10 +141,8 @@ ResourceSupply.prototype.RemoveGatherer = function(gathererID)
{
this.gatherers.splice(this.gatherers.indexOf(gathererID),1);
// broadcast message, mainly useful for the AIs.
Engine.PostMessage(this.entity, MT_ResourceSupplyGatherersChanged, { "to": this.gatherers });
}
if (this.gatherers.length == 0)
this.StartRegenerationDelayTimer();
};
Engine.PostMessage(this.entity, MT_ResourceSupplyGatherersChanged, { "to": this.gatherers });
}
};
Engine.RegisterComponentType(IID_ResourceSupply, "ResourceSupply", ResourceSupply);
@@ -98,10 +98,7 @@ StatisticsTracker.prototype.KilledEntity = function(targetEntity)
{
var cmpTargetEntityIdentity = Engine.QueryInterface(targetEntity, IID_Identity);
var cmpCost = Engine.QueryInterface(targetEntity, IID_Cost);
if (cmpCost)
var costs = cmpCost.GetResourceCosts();
else
var costs = { "food": 0, "wood": 0, "stone": 0, "metal": 0 };
var costs = cmpCost.GetResourceCosts();
if (cmpTargetEntityIdentity)
{
var cmpFoundation = Engine.QueryInterface(targetEntity, IID_Foundation);
@@ -113,7 +110,7 @@ StatisticsTracker.prototype.KilledEntity = function(targetEntity)
var targetIsCivCentre = cmpTargetEntityIdentity.HasClass("CivCentre");
var cmpTargetOwnership = Engine.QueryInterface(targetEntity, IID_Ownership);
// Don't increase counters if target player is gaia (player 0)
if (cmpTargetOwnership.GetOwner() != 0)
{
@@ -124,7 +121,7 @@ StatisticsTracker.prototype.KilledEntity = function(targetEntity)
{
this.enemyUnitsKilledValue += costs[r];
}
}
}
if (targetIsStructure)
{
this.enemyBuildingsDestroyed++;
@@ -143,10 +140,7 @@ StatisticsTracker.prototype.LostEntity = function(lostEntity)
{
var cmpLostEntityIdentity = Engine.QueryInterface(lostEntity, IID_Identity);
var cmpCost = Engine.QueryInterface(lostEntity, IID_Cost);
if (cmpCost)
var costs = cmpCost.GetResourceCosts();
else
var costs = { "food": 0, "wood": 0, "stone": 0, "metal": 0 };
var costs = cmpCost.GetResourceCosts();
if (cmpLostEntityIdentity)
{
var cmpFoundation = Engine.QueryInterface(lostEntity, IID_Foundation);
@@ -162,8 +156,8 @@ StatisticsTracker.prototype.LostEntity = function(lostEntity)
for (var r in costs)
{
this.unitsLostValue += costs[r];
}
}
}
}
if (lostEntityIsStructure)
{
this.buildingsLost++;
@@ -183,7 +177,7 @@ StatisticsTracker.prototype.LostEntity = function(lostEntity)
StatisticsTracker.prototype.IncreaseResourceGatheredCounter = function(type, amount, specificType)
{
this.resourcesGathered[type] += amount;
if (type == "food" && (specificType == "fruit" || specificType == "grain"))
this.resourcesGathered["vegetarianFood"] += amount;
};
@@ -10,13 +10,10 @@
<Icon>gaia/flora_bush_berry.png</Icon>
</Identity>
<Obstruction>
<Unit radius="0.9"/>
</Obstruction>
<Health>
<Max>150</Max>
</Health>
<ResourceSupply>
<Amount>400</Amount>
<Unit radius="0.9"/>
</Obstruction>
<ResourceSupply>
<Amount>400</Amount>
<Type>food.fruit</Type>
</ResourceSupply>
<VisualActor>
@@ -13,32 +13,15 @@
</Identity>
<Minimap>
<Type>food</Type>
<Colour r="205" g="115" b="16"/>
</Minimap>
<Health>
<Max>100</Max>
<RegenRate>0</RegenRate>
<DeathType>vanish</DeathType>
<Unhealable>true</Unhealable>
<Repairable>false</Repairable>
</Health>
<Armour>
<Hack>1.0</Hack>
<Pierce>1.0</Pierce>
<Crush>1.0</Crush>
</Armour>
<ResourceSupply>
<KillBeforeGather>false</KillBeforeGather>
<Amount>200</Amount>
<Type>food.fruit</Type>
<MaxGatherers>8</MaxGatherers>
<Regeneration>
<Rate>3</Rate>
<Delay>10</Delay>
<Growth>linear</Growth>
</Regeneration>
</ResourceSupply>
<Selectable>
<Colour r="205" g="115" b="16"/>
</Minimap>
<ResourceSupply>
<KillBeforeGather>false</KillBeforeGather>
<Amount>200</Amount>
<Type>food.fruit</Type>
<MaxGatherers>8</MaxGatherers>
</ResourceSupply>
<Selectable>
<EditorOnly disable=""/>
<Overlay>
<Texture>
@@ -20,17 +20,11 @@
</Position>
<ResourceSupply>
<KillBeforeGather>false</KillBeforeGather>
<Amount>1000</Amount>
<Type>food.fish</Type>
<MaxGatherers>4</MaxGatherers>
<Regeneration>
<Rate>1</Rate>
<Acceleration>1.03</Acceleration>
<Delay>5</Delay>
<Growth>quadratic</Growth>
</Regeneration>
</ResourceSupply>
<Selectable>
<Amount>1000</Amount>
<Type>food.fish</Type>
<MaxGatherers>4</MaxGatherers>
</ResourceSupply>
<Selectable>
<Overlay>
<Texture disable=""/>
<Outline>
-9
View File
@@ -1775,15 +1775,6 @@ void CGUI::Xeromyces_ReadScrollBarStyle(XMBElement Element, CXeromyces* pFile)
scrollbar.m_MinimumBarSize = f;
}
else
if (attr_name == "maximum_bar_size")
{
float f;
if (!GUI<float>::ParseString(attr_value.FromUTF8(), f))
LOGERROR(L"GUI: Error parsing '%hs' (\"%hs\")", attr_name.c_str(), attr_value.c_str());
else
scrollbar.m_MaximumBarSize = f;
}
else
if (attr_name == "sprite_button_top")
scrollbar.m_SpriteButtonTop = attr_value;
else
+41 -19
View File
@@ -22,6 +22,7 @@ IGUIScrollBar
#include "precompiled.h"
#include "GUI.h"
#include "CGUIScrollBarVertical.h"
#include "ps/CLogger.h"
@@ -38,22 +39,18 @@ void CGUIScrollBarVertical::SetPosFromMousePos(const CPos &mouse)
if (!GetStyle())
return;
/**
* Calculate the position for the top of the item being scrolled
*/
m_Pos = m_PosWhenPressed + GetMaxPos() * (mouse.y - m_BarPressedAtPos.y) / (m_Length - GetStyle()->m_Width * 2 - m_BarSize);
m_Pos = (m_PosWhenPressed + m_ScrollRange*(mouse.y-m_BarPressedAtPos.y)/(m_Length-GetStyle()->m_Width*2));
}
void CGUIScrollBarVertical::Draw()
{
if (!GetStyle())
{
LOGWARNING(L"Attempt to draw scrollbar without a style.");
// TODO Gee: Report in error log
return;
}
// Only draw the scrollbar if the GUI exists and there is something to scroll.
if (GetGUI() && GetMaxPos() != 1)
if (GetGUI())
{
CRect outline = GetOuterRect();
@@ -82,7 +79,7 @@ void CGUIScrollBarVertical::Draw()
}
else button_top = &GetStyle()->m_SpriteButtonTop;
// figure out what sprite to use for bottom button
// figure out what sprite to use for top button
if (m_ButtonPlusHovered)
{
if (m_ButtonPlusPressed)
@@ -114,10 +111,22 @@ void CGUIScrollBarVertical::Draw()
}
// Draw bar
GetGUI()->DrawSprite(GetStyle()->m_SpriteBarVertical,
0,
m_Z + 0.2f,
GetBarRect());
/*if (m_BarPressed)
GetGUI()->DrawSprite(GUI<>::FallBackSprite(GetStyle()->m_SpriteBarVerticalPressed, GetStyle()->m_SpriteBarVertical),
0,
m_Z+0.2f,
GetBarRect());
else
if (m_BarHovered)
GetGUI()->DrawSprite(GUI<>::FallBackSprite(GetStyle()->m_SpriteBarVerticalOver, GetStyle()->m_SpriteBarVertical),
0,
m_Z+0.2f,
GetBarRect());
else*/
GetGUI()->DrawSprite(GetStyle()->m_SpriteBarVertical,
0,
m_Z+0.2f,
GetBarRect());
}
}
@@ -132,19 +141,32 @@ CRect CGUIScrollBarVertical::GetBarRect() const
if (!GetStyle())
return ret;
// Get from where the scroll area begins to where it ends
float from = m_Y;
float to = m_Y + m_Length - m_BarSize;
float size;
float from, to;
// is edge buttons used?
if (m_UseEdgeButtons)
{
from += GetStyle()->m_Width;
to -= GetStyle()->m_Width;
size = (m_Length-GetStyle()->m_Width*2.f)*m_BarSize;
if (size < GetStyle()->m_MinimumBarSize)
size = GetStyle()->m_MinimumBarSize;
from = m_Y+GetStyle()->m_Width;
to = m_Y+m_Length-GetStyle()->m_Width-size;
}
else
{
size = m_Length*m_BarSize;
if (size < GetStyle()->m_MinimumBarSize)
size = GetStyle()->m_MinimumBarSize;
from = m_Y;
to = m_Y+m_Length-size;
}
// Setup rectangle
ret.top = from + (to - from) * (m_Pos / GetMaxPos());
ret.bottom = ret.top + m_BarSize;
ret.top = (from + (to-from)*(m_Pos/(std::max(1.f, m_ScrollRange - m_ScrollSpace))));
ret.bottom = ret.top+size;
ret.right = m_X + ((m_RightAligned)?(0.f):(GetStyle()->m_Width));
ret.left = ret.right - GetStyle()->m_Width;
+1 -1
View File
@@ -74,7 +74,7 @@ public:
virtual void HandleMessage(SGUIMessage &Message);
/**
* Set m_Pos with g_mouse_x/y input, i.e. when dragging.
* Set m_Pos with g_mouse_x/y input, i.e. when draggin.
*/
virtual void SetPosFromMousePos(const CPos &mouse);
+10 -27
View File
@@ -21,8 +21,7 @@ IGUIScrollBar
#include "precompiled.h"
#include "GUI.h"
#include "maths/MathUtil.h"
#include "ps/CLogger.h"
//-------------------------------------------------------------------
// IGUIScrollBar
@@ -31,7 +30,7 @@ IGUIScrollBar::IGUIScrollBar() : m_pStyle(NULL), m_pGUI(NULL),
m_X(300.f), m_Y(300.f),
m_ScrollRange(1.f), m_ScrollSpace(0.f), // MaxPos: not 0, due to division.
m_Length(200.f), m_Width(20.f),
m_BarSize(0.f), m_Pos(0.f),
m_BarSize(0.5f), m_Pos(0.f),
m_UseEdgeButtons(true),
m_ButtonPlusPressed(false),
m_ButtonMinusPressed(false),
@@ -48,25 +47,7 @@ IGUIScrollBar::~IGUIScrollBar()
void IGUIScrollBar::SetupBarSize()
{
float min = GetStyle()->m_MinimumBarSize;
float max = GetStyle()->m_MaximumBarSize;
float length = m_Length;
// Check for edge buttons
if (m_UseEdgeButtons)
length -= GetStyle()->m_Width * 2.f;
// Check min and max are valid
if (min > length)
{
LOGWARNING(L"Minimum scrollbar size of %g is larger than the total scrollbar size of %g", min, length);
min = 0.f;
}
if (max < min)
max = length;
// Clamp size to not exceed a minimum or maximum.
m_BarSize = clamp(length * std::min((float)m_ScrollSpace / (float)m_ScrollRange, 1.f), min, max);
m_BarSize = std::min((float)m_ScrollSpace/(float)m_ScrollRange, 1.f);
}
const SGUIScrollBarStyle *IGUIScrollBar::GetStyle() const
@@ -91,8 +72,8 @@ void IGUIScrollBar::UpdatePosBoundaries()
m_ScrollRange < m_ScrollSpace) // <= scrolling not applicable
m_Pos = 0.f;
else
if (m_Pos > GetMaxPos())
m_Pos = GetMaxPos();
if (m_Pos > m_ScrollRange - m_ScrollSpace)
m_Pos = m_ScrollRange - m_ScrollSpace;
}
void IGUIScrollBar::HandleMessage(SGUIMessage &Message)
@@ -112,10 +93,12 @@ void IGUIScrollBar::HandleMessage(SGUIMessage &Message)
UpdatePosBoundaries();
}
CRect bar_rect = GetBarRect();
// check if components are being hovered
m_BarHovered = GetBarRect().PointInside(mouse);
m_ButtonMinusHovered = HoveringButtonMinus(mouse);
m_ButtonPlusHovered = HoveringButtonPlus(mouse);
m_BarHovered = bar_rect.PointInside(mouse);
m_ButtonMinusHovered = HoveringButtonMinus(m_pHostObject->GetMousePos());
m_ButtonPlusHovered = HoveringButtonPlus(m_pHostObject->GetMousePos());
if (!m_ButtonMinusHovered)
m_ButtonMinusPressed = false;
+6 -13
View File
@@ -90,13 +90,6 @@ struct SGUIScrollBarStyle
*/
float m_MinimumBarSize;
/**
* Sometimes you would like your scroll bar to have a fixed maximum size
* so that the texture does not get too stretched, you can set a maximum
* in pixels.
*/
float m_MaximumBarSize;
//@}
//--------------------------------------------------------
/** @name Horizontal Sprites */
@@ -206,27 +199,27 @@ public:
virtual void SetPos(float f) { m_Pos = f; UpdatePosBoundaries(); }
/**
* Get the value of m_Pos that corresponds to the bottom of the scrollable region
* Get the value of Pos that corresponds to the bottom of the scrollable region
*/
float GetMaxPos() const { return std::max(1.f, m_ScrollRange - m_ScrollSpace); }
float GetMaxPos() const { return m_ScrollRange - m_ScrollSpace; }
/**
* Increase scroll one step
* Scroll towards 1.0 one step
*/
virtual void ScrollPlus() { m_Pos += 30.f; UpdatePosBoundaries(); }
/**
* Decrease scroll one step
* Scroll towards 0.0 one step
*/
virtual void ScrollMinus() { m_Pos -= 30.f; UpdatePosBoundaries(); }
/**
* Increase scroll three steps
* Scroll towards 1.0 one step
*/
virtual void ScrollPlusPlenty() { m_Pos += 90.f; UpdatePosBoundaries(); }
/**
* Decrease scroll three steps
* Scroll towards 0.0 one step
*/
virtual void ScrollMinusPlenty() { m_Pos -= 90.f; UpdatePosBoundaries(); }