Page MenuHomeWildfire Games

Show capture bar of panel entities.
AbandonedPublic

Authored by Freagarach on Jul 6 2019, 8:44 AM.

Details

Reviewers
Nescio
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Summary

@Nescio requested a method to show the capture bar of panel entities.
Whilst at it I ensured that only entities with health show their health bar.

Test Plan
  1. Start a capture the relic game.
  2. Capture a relic.
    1. Check that its capture points are correctly shown.
  3. Let another player capture part of the relic.
    1. Check that its capture points are still correctly shown.
  4. Build a hero.
    1. Check that its health is properly shown.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
/ps/trunk
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 8229
Build 13415: Vulcan BuildJenkins
Build 13414: arc lint + arc unit

Event Timeline

Freagarach created this revision.Jul 6 2019, 8:44 AM
Freagarach created this object with visibility "Subscribers".
Owners added a subscriber: Restricted Owners Package.Jul 6 2019, 8:44 AM
Freagarach removed a subscriber: Restricted Owners Package.Jul 6 2019, 8:45 AM
Freagarach edited the test plan for this revision. (Show Details)Jul 6 2019, 8:54 AM

@Nescio, feel free to upload changes if you want to!

Nescio added inline comments.Jul 6 2019, 2:01 PM
binaries/data/mods/public/gui/session/session_objects/panel_entities.xml
21

It seems you're placing the capture bar on exactly the same location (i.e. on top of) the health bar. The desirable location can be discussed, but if one wants to have it directly below the health bar, replace size with "3 100% 100%-3 100%+5".

Nescio added a comment.Jul 6 2019, 2:12 PM

should take all player' capture points into account.

You might want to have a look at gui/session/selection_panels_middle/single_details_area.xml lines 29 to 42.

Nescio added a reviewer: Restricted Owners Package.Jul 6 2019, 2:42 PM

This patch seems to work fine with catafalques, but when I have a hero, I get the following errors:

WARNING: JavaScript warning: gui/session/session.js line 1050 reference to undefined property panelEntState.capturePoints

ERROR: JavaScript error: gui/session/session.js line 1050 TypeError: panelEntState.capturePoints is undefined updatePanelEntities@gui/session/session.js:1050:9 updateGUIObjects@gui/session/session.js:938:3 updateDisplayedPlayerColors@gui/session/session.js:416:3 selectViewPlayer@gui/session/session.js:557:3 __eventhandler226 (selectionchange)@viewPlayer selectionchange:0:1 initViewedPlayerDropdown@gui/session/session.js:511:97 initGUIObjects@gui/session/session.js:300:3 init@gui/session/session.js:282:3 reallyStartGame@gui/loading/loading.js:97:2

ERROR: GUI page 'page_session.xml': Failed to call init() function

ERROR: JavaScript error: gui/session/session.js line 1050 TypeError: panelEntState.capturePoints is undefined updatePanelEntities@gui/session/session.js:1050:9 updateGUIObjects@gui/session/session.js:938:3 onSimulationUpdate@gui/session/session.js:875:3 __eventhandler108 (simulationupdate)@session simulationupdate:0:1

Presumably because catalfalques have capture points but heroes don't.

Freagarach updated this revision to Diff 8759.Jul 7 2019, 9:03 AM
Freagarach edited the summary of this revision. (Show Details)
  • No overwriting of health bar.
  • Undependant of whether capture or health are present.
Owners added a subscriber: Restricted Owners Package.Jul 7 2019, 9:03 AM

Owner player colours in capture bar?

  • No overwriting of health bar.
  • Undependant of whether capture or health are present.

Thanks, tried it out, and indeed it seems to work as it ought to:

By the way, why did you restrict the visibility of this patch?

binaries/data/mods/public/simulation/components/Player.js
42 ↗(On Diff #8759)

Shouldn't be changed, should it?

In D2047#85338, @Nescio wrote:

Owner player colours in capture bar?

Working on that ;)

In D2047#85338, @Nescio wrote:

By the way, why did you restrict the visibility of this patch?

To not bother everyone with another incompleat patch from me. Once I either get the capture bar working or get stuck I usually unrestrict.

binaries/data/mods/public/simulation/components/Player.js
42 ↗(On Diff #8759)

Nay, sorry. I had to rush to go to church ;)

Freagarach updated this revision to Diff 8762.Jul 7 2019, 12:33 PM
Freagarach retitled this revision from [Request:] Show capture bar of panel entities. to Show capture bar of panel entities..
Freagarach edited the summary of this revision. (Show Details)
Freagarach edited the test plan for this revision. (Show Details)
Freagarach changed the visibility from "Subscribers" to "Public (No Login Required)".

Take all players CP in account.

Freagarach marked an inline comment as done.Jul 7 2019, 12:34 PM
Nescio accepted this revision.Jul 7 2019, 12:50 PM
  • It is a nice addition to the game, both informative and clear
  • Fixes a potential error currently present (in case someone disables health for e.g. catafalques)
  • The changes look good
  • In game it works as it should, without errors, including proper player colours:


Therefore I think this patch ought to be accepted. Thank you.

This revision is now accepted and ready to land.Jul 7 2019, 12:50 PM
Vulcan added a comment.Jul 7 2019, 1:02 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/common/tooltips.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/common/tooltips.js
| 404| 404| function getRepairTimeTooltip(entState)
| 405| 405| {
| 406| 406| 	return sprintf(translate("%(label)s %(details)s"), {
| 407|    |-			"label": headerFont(translate("Number of repairers:")),
|    | 407|+		"label": headerFont(translate("Number of repairers:")),
| 408| 408| 			"details": entState.repairable.numBuilders
| 409| 409| 		}) + "\n" + (entState.repairable.numBuilders ?
| 410| 410| 		sprintf(translatePlural(
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/common/tooltips.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/common/tooltips.js
| 405| 405| {
| 406| 406| 	return sprintf(translate("%(label)s %(details)s"), {
| 407| 407| 			"label": headerFont(translate("Number of repairers:")),
| 408|    |-			"details": entState.repairable.numBuilders
|    | 408|+		"details": entState.repairable.numBuilders
| 409| 409| 		}) + "\n" + (entState.repairable.numBuilders ?
| 410| 410| 		sprintf(translatePlural(
| 411| 411| 			"Add another worker to speed up the repairs by %(second)s second.",
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 2.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/common/tooltips.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/common/tooltips.js
| 406| 406| 	return sprintf(translate("%(label)s %(details)s"), {
| 407| 407| 			"label": headerFont(translate("Number of repairers:")),
| 408| 408| 			"details": entState.repairable.numBuilders
| 409|    |-		}) + "\n" + (entState.repairable.numBuilders ?
|    | 409|+	}) + "\n" + (entState.repairable.numBuilders ?
| 410| 410| 		sprintf(translatePlural(
| 411| 411| 			"Add another worker to speed up the repairs by %(second)s second.",
| 412| 412| 			"Add another worker to speed up the repairs by %(second)s seconds.",
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/common/tooltips.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/common/tooltips.js
| 426| 426| function getBuildTimeTooltip(entState)
| 427| 427| {
| 428| 428| 	return sprintf(translate("%(label)s %(details)s"), {
| 429|    |-			"label": headerFont(translate("Number of builders:")),
|    | 429|+		"label": headerFont(translate("Number of builders:")),
| 430| 430| 			"details": entState.foundation.numBuilders
| 431| 431| 		}) + "\n" + (entState.foundation.numBuilders ?
| 432| 432| 		sprintf(translatePlural(
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/common/tooltips.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/common/tooltips.js
| 427| 427| {
| 428| 428| 	return sprintf(translate("%(label)s %(details)s"), {
| 429| 429| 			"label": headerFont(translate("Number of builders:")),
| 430|    |-			"details": entState.foundation.numBuilders
|    | 430|+		"details": entState.foundation.numBuilders
| 431| 431| 		}) + "\n" + (entState.foundation.numBuilders ?
| 432| 432| 		sprintf(translatePlural(
| 433| 433| 			"Add another worker to speed up the construction by %(second)s second.",
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 2.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/common/tooltips.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/common/tooltips.js
| 428| 428| 	return sprintf(translate("%(label)s %(details)s"), {
| 429| 429| 			"label": headerFont(translate("Number of builders:")),
| 430| 430| 			"details": entState.foundation.numBuilders
| 431|    |-		}) + "\n" + (entState.foundation.numBuilders ?
|    | 431|+	}) + "\n" + (entState.foundation.numBuilders ?
| 432| 432| 		sprintf(translatePlural(
| 433| 433| 			"Add another worker to speed up the construction by %(second)s second.",
| 434| 434| 			"Add another worker to speed up the construction by %(second)s seconds.",
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 6 tabs but found 5.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
| 392| 392| 				// Players see colors depending on diplomacy
| 393| 393| 				g_DisplayedPlayerColors[i] =
| 394| 394| 					g_ViewedPlayer == i ? getDiplomacyColor("self") :
| 395|    |-					g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") :
|    | 395|+						g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") :
| 396| 396| 					g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") :
| 397| 397| 					getDiplomacyColor("enemy");
| 398| 398| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 7 tabs but found 5.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
| 393| 393| 				g_DisplayedPlayerColors[i] =
| 394| 394| 					g_ViewedPlayer == i ? getDiplomacyColor("self") :
| 395| 395| 					g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") :
| 396|    |-					g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") :
|    | 396|+							g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") :
| 397| 397| 					getDiplomacyColor("enemy");
| 398| 398| 
| 399| 399| 		g_DisplayedPlayerColors[0] = g_Players[0].color;
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 8 tabs but found 5.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
| 394| 394| 					g_ViewedPlayer == i ? getDiplomacyColor("self") :
| 395| 395| 					g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") :
| 396| 396| 					g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") :
| 397|    |-					getDiplomacyColor("enemy");
|    | 397|+								getDiplomacyColor("enemy");
| 398| 398| 
| 399| 399| 		g_DisplayedPlayerColors[0] = g_Players[0].color;
| 400| 400| 	}
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 4 tabs but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
| 644| 644| 					"civ": setStringTags(g_CivData[g_Players[g_ViewedPlayer].civ].Name, { "font": "sans-bold-stroke-14" }),
| 645| 645| 					"hotkey_civinfo": colorizeHotkey("%(hotkey)s", "civinfo"),
| 646| 646| 					"hotkey_structree": colorizeHotkey("%(hotkey)s", "structree")
| 647|    |-			});
|    | 647|+				});
| 648| 648| 	}
| 649| 649| 
| 650| 650| 	// Following gaia can be interesting on scripted maps
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 2.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|1249|1249| 
|1250|1250| 	let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" :
|1251|1251| 		"\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), {
|1252|    |-		"hotkey": setStringTags("\\[Click]", g_HotkeyTags),
|    |1252|+			"hotkey": setStringTags("\\[Click]", g_HotkeyTags),
|1253|1253| 		"order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending")
|1254|1254| 	});
|1255|1255| 
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 3 tabs but found 2.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|1250|1250| 	let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" :
|1251|1251| 		"\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), {
|1252|1252| 		"hotkey": setStringTags("\\[Click]", g_HotkeyTags),
|1253|    |-		"order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending")
|    |1253|+			"order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending")
|1254|1254| 	});
|1255|1255| 
|1256|1256| 	let resCodes = g_ResourceData.GetCodes();
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 2 tabs but found 1.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|1251|1251| 		"\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), {
|1252|1252| 		"hotkey": setStringTags("\\[Click]", g_HotkeyTags),
|1253|1253| 		"order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending")
|1254|    |-	});
|    |1254|+		});
|1255|1255| 
|1256|1256| 	let resCodes = g_ResourceData.GetCodes();
|1257|1257| 	for (let r = 0; r < resCodes.length; ++r)
|    | [NORMAL] ESLintBear (indent):
|    | Expected indentation of 1 tab but found 3.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/session.js
|1734|1734| 	for (let rct of resourcesCounterTypes)
|1735|1735| 		for (let rt of resourcesTypes)
|1736|1736| 			reportObject[rt + rct.substr(9)] = playerStatistics[rct][rt];
|1737|    |-			// eg. rt = food rct.substr = Gathered rct = resourcesGathered
|    |1737|+	// eg. rt = food rct.substr = Gathered rct = resourcesGathered
|1738|1738| 
|1739|1739| 	reportObject.vegetarianFoodGathered = playerStatistics.resourcesGathered.vegetarianFood;
|1740|1740| 	for (let type of unitsClasses)

binaries/data/mods/public/gui/session/session.js
|1074| »   let·getPanelEntNameTooltip·=·panelEntState·=>·"[font=\"sans-bold-16\"]"·+·template.name.specific·+·"[/font]";
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'panelEntState' is already declared in the upper scope.

binaries/data/mods/public/gui/session/session.js
|1185| »   »   button.onpress·=·(function(i)·{·return·function()·{·performGroup((Engine.HotkeyIsPressed("selection.add")·?·"add"·:·"select"),·i);·};·})(i);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'i' is already declared in the upper scope.

binaries/data/mods/public/gui/session/session.js
|1186| »   »   button.ondoublepress·=·(function(i)·{·return·function()·{·performGroup("snap",·i);·};·})(i);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'i' is already declared in the upper scope.

binaries/data/mods/public/gui/session/session.js
|1187| »   »   button.onpressright·=·(function(i)·{·return·function()·{·performGroup("breakUp",·i);·};·})(i);
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'i' is already declared in the upper scope.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/differential/1932/display/redirect

Freagarach abandoned this revision.Jul 9 2019, 10:19 AM

Duplicated in D1268. Sorry people.