Ticket #4099: roundup_wipv1.diff
File roundup_wipv1.diff, 8.4 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/common/tooltips.js
function getBuildRateTooltip(template) 298 298 */ 299 299 function multiplyEntityCosts(template, trainNum) 300 300 { 301 301 let totalCosts = {}; 302 302 for (let r in template.cost) 303 totalCosts[r] = Math. floor(template.cost[r] * trainNum);303 totalCosts[r] = Math.round(template.cost[r] * trainNum); 304 304 305 305 return totalCosts; 306 306 } 307 307 308 308 /** … … function getEntityCostComponentsTooltipS 313 313 if (!trainNum) 314 314 trainNum = 1; 315 315 316 316 let totalCosts = multiplyEntityCosts(template, trainNum); 317 317 if (template.cost.time) 318 totalCosts.time = Math. ceil(template.cost.time * (entity ? Engine.GuiInterfaceCall("GetBatchTime", { "entity": entity, "batchSize": trainNum }) : 1));318 totalCosts.time = Math.round(template.cost.time * (entity ? Engine.GuiInterfaceCall("GetBatchTime", { "entity": entity, "batchSize": trainNum }) : 1)); 319 319 320 320 let costs = []; 321 321 for (let type in template.cost) 322 322 // Population bonus is shown in the tooltip 323 323 if (type != "populationBonus" && totalCosts[type]) … … function getWallPieceTooltip(wallTypes) 386 386 for (let resource in resourceCount) 387 387 // Translation: This string is part of the resources cost string on 388 388 // the tooltip for wall structures. 389 389 out.push(sprintf(translate("%(resourceIcon)s %(minimum)s to %(resourceIcon)s %(maximum)s"), { 390 390 "resourceIcon": costIcon(resource), 391 "minimum": Math. min.apply(Math, resourceCount[resource]),392 "maximum": Math. max.apply(Math, resourceCount[resource])391 "minimum": Math.round(Math.min(...resourceCount[resource])), 392 "maximum": Math.round(Math.max(...resourceCount[resource])) 393 393 })); 394 394 else 395 395 for (let i = 0; i < wallTypes.length; ++i) 396 396 out.push(getEntityCostComponentsTooltipString(wallTypes[i]).join(", ")); 397 397 -
binaries/data/mods/public/gui/session/selection_details.js
function updateGarrisionHealthBar(entSta 49 49 let healthSize = healthBarGarrison.size; 50 50 healthSize.rtop = 100-100*Math.max(0, Math.min(1, totalGarrisionHealth / maxGarrisionHealth)); 51 51 healthBarGarrison.size = healthSize; 52 52 healthGarrison.tooltip = sprintf(translate("%(label)s %(current)s / %(max)s"), { 53 53 "label": "[font=\"sans-bold-13\"]" + translate("Hitpoints:") + "[/font]", 54 "current": Math. ceil(totalGarrisionHealth),55 "max": Math. ceil(maxGarrisionHealth)54 "current": Math.round(totalGarrisionHealth) || 1, 55 "max": Math.round(maxGarrisionHealth) || 1 56 56 }); 57 57 } 58 58 } 59 59 60 60 // Fills out information that most entities have … … function displaySingle(entState) 106 106 if (entState.foundation && entState.visibility == "visible" && entState.foundation.numBuilders !== 0) 107 107 { 108 108 // logic comes from Foundation component. 109 109 let speed = Math.pow(entState.foundation.numBuilders, 0.7); 110 110 let timeLeft = (1.0 - entState.foundation.progress / 100.0) * template.cost.time; 111 let timeToCompletion = Math. ceil(timeLeft/speed);111 let timeToCompletion = Math.round(timeLeft/speed) || 1; 112 112 Engine.GetGUIObjectByName("health").tooltip = sprintf(translatePlural("This foundation will be completed in %(seconds)s second.", "This foundation will be completed in %(seconds)s seconds.", timeToCompletion), { "seconds": timeToCompletion }); 113 113 } 114 114 else 115 115 Engine.GetGUIObjectByName("health").tooltip = ""; 116 116 117 117 Engine.GetGUIObjectByName("healthStats").caption = sprintf(translate("%(hitpoints)s / %(maxHitpoints)s"), { 118 "hitpoints": Math. ceil(entState.hitpoints),119 "maxHitpoints": Math. ceil(entState.maxHitpoints)118 "hitpoints": Math.round(entState.hitpoints) || 1, 119 "maxHitpoints": Math.round(entState.maxHitpoints) || 1 120 120 }); 121 121 } 122 122 123 123 // CapturePoints 124 124 Engine.GetGUIObjectByName("captureSection").hidden = !entState.capturePoints; … … function displaySingle(entState) 143 143 for (let i in entState.capturePoints) 144 144 if (i != entState.player) 145 145 size = setCaptureBarPart(i, size); 146 146 147 147 Engine.GetGUIObjectByName("captureStats").caption = sprintf(translate("%(capturePoints)s / %(maxCapturePoints)s"), { 148 "capturePoints": Math. ceil(entState.capturePoints[entState.player]),149 "maxCapturePoints": Math. ceil(entState.maxCapturePoints)148 "capturePoints": Math.round(entState.capturePoints[entState.player]) || 1, 149 "maxCapturePoints": Math.round(entState.maxCapturePoints) || 1 150 150 }); 151 151 } 152 152 153 153 // Experience 154 154 Engine.GetGUIObjectByName("experience").hidden = !entState.promotion; … … function displaySingle(entState) 176 176 Engine.GetGUIObjectByName("resourceSection").hidden = !entState.resourceSupply; 177 177 if (entState.resourceSupply) 178 178 { 179 179 let resources = entState.resourceSupply.isInfinite ? translate("∞") : // Infinity symbol 180 180 sprintf(translate("%(amount)s / %(max)s"), { 181 "amount": Math. ceil(+entState.resourceSupply.amount),181 "amount": Math.round(+entState.resourceSupply.amount) || 1, 182 182 "max": entState.resourceSupply.max 183 183 }); 184 184 185 185 let resourceType = getResourceTypeDisplayName(entState.resourceSupply.type); 186 186 … … function displaySingle(entState) 234 234 Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.foundation.numBuilders + " "; 235 235 if (entState.foundation.numBuilders !== 0) 236 236 { 237 237 let speedup = Math.pow((entState.foundation.numBuilders+1)/entState.foundation.numBuilders, 0.7); 238 238 let timeLeft = (1.0 - entState.foundation.progress / 100.0) * template.cost.time; 239 let timeSpeedup = Math. ceil(timeLeft - timeLeft/speedup);239 let timeSpeedup = Math.round(timeLeft - timeLeft/speedup) || 1; 240 240 Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = sprintf(translatePlural("Number of builders.\nTasking another to this foundation would speed construction up by %(speedup)s second.", "Number of builders.\nTasking another to this foundation would speed construction up by %(speedup)s seconds.", timeSpeedup), { "speedup": timeSpeedup }); 241 241 } 242 242 else 243 243 Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = translate("Number of builders."); 244 244 } … … function displayMultiple(selection) 353 353 healthSize.rtop = 100-100*Math.max(0, Math.min(1, averageHealth / maxHealth)); 354 354 unitHealthBar.size = healthSize; 355 355 356 356 Engine.GetGUIObjectByName("healthMultiple").tooltip = sprintf(translate("%(label)s %(current)s / %(max)s"), { 357 357 "label": "[font=\"sans-bold-13\"]" + translate("Hitpoints:") + "[/font]", 358 "current": Math. ceil(averageHealth),359 "max": Math. ceil(maxHealth)358 "current": Math.round(averageHealth) || 1, 359 "max": Math.round(maxHealth) || 1 360 360 }); 361 361 } 362 362 363 363 Engine.GetGUIObjectByName("captureMultiple").hidden = maxCapturePoints <= 0; 364 364 if (maxCapturePoints > 0) … … function displayMultiple(selection) 385 385 // last handle the owner's points, to keep those points on the bottom for clarity 386 386 setCaptureBarPart(playerID, size); 387 387 388 388 Engine.GetGUIObjectByName("captureMultiple").tooltip = sprintf(translate("%(label)s %(current)s / %(max)s"), { 389 389 "label": "[font=\"sans-bold-13\"]" + translate("Capture points:") + "[/font]", 390 "current": Math. ceil(capturePoints[playerID]),391 "max": Math. ceil(maxCapturePoints)390 "current": Math.round(capturePoints[playerID]) || 1, 391 "max": Math.round(maxCapturePoints) || 1 392 392 }); 393 393 } 394 394 395 395 let numberOfUnits = Engine.GetGUIObjectByName("numberOfUnits"); 396 396 numberOfUnits.caption = selection.length; -
binaries/data/mods/public/gui/session/session.js
function createHeroTooltip(heroState, te 829 829 { 830 830 return [ 831 831 "[font=\"sans-bold-16\"]" + template.name.specific + "[/font]" + "\n" + 832 832 sprintf(translate("%(label)s %(current)s / %(max)s"), { 833 833 "label": "[font=\"sans-bold-13\"]" + translate("Health:") + "[/font]", 834 "current": Math. ceil(heroState.hitpoints),835 "max": Math. ceil(heroState.maxHitpoints)834 "current": Math.round(heroState.hitpoints) || 1, 835 "max": Math.round(heroState.maxHitpoints) || 1 836 836 }), 837 837 getAttackTooltip(heroState), 838 838 getArmorTooltip(heroState), 839 839 getEntityTooltip(heroState) 840 840 ].filter(tip => tip).join("\n");