This patch adds a common function that allows spacing objects vertically, instead of horizontally, thus offering more possibilities for modders who'd want to redesign parts of the GUI.
Details
Diff Detail
- Repository
- rP 0 A.D. Public Repository
- Branch
- /ps/trunk
- Lint
Lint OK - Unit
No Unit Test Coverage - Build Status
Buildable 5666 Build 9529: Vulcan Build Jenkins Build 9528: arc lint + arc unit
Event Timeline
Here an example how I use this code to display five resources vertically in my 0abc mod (A22, mind):
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Default... Executing section Source... Executing section JS... binaries/data/mods/public/gui/common/functions_utility.js | 189| » }·catch·(e)·{ | | [NORMAL] ESLintBear (no-empty): | | Empty block statement. | | [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 | 413| 413| // Players see colors depending on diplomacy | 414| 414| g_DisplayedPlayerColors[i] = | 415| 415| g_ViewedPlayer == i ? g_DiplomacyColorPalette.Self : | 416| |- g_Players[g_ViewedPlayer].isAlly[i] ? g_DiplomacyColorPalette.Ally : | | 416|+ g_Players[g_ViewedPlayer].isAlly[i] ? g_DiplomacyColorPalette.Ally : | 417| 417| g_Players[g_ViewedPlayer].isNeutral[i] ? g_DiplomacyColorPalette.Neutral : | 418| 418| g_DiplomacyColorPalette.Enemy; | 419| 419| | | [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 | 414| 414| g_DisplayedPlayerColors[i] = | 415| 415| g_ViewedPlayer == i ? g_DiplomacyColorPalette.Self : | 416| 416| g_Players[g_ViewedPlayer].isAlly[i] ? g_DiplomacyColorPalette.Ally : | 417| |- g_Players[g_ViewedPlayer].isNeutral[i] ? g_DiplomacyColorPalette.Neutral : | | 417|+ g_Players[g_ViewedPlayer].isNeutral[i] ? g_DiplomacyColorPalette.Neutral : | 418| 418| g_DiplomacyColorPalette.Enemy; | 419| 419| | 420| 420| 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 | 415| 415| g_ViewedPlayer == i ? g_DiplomacyColorPalette.Self : | 416| 416| g_Players[g_ViewedPlayer].isAlly[i] ? g_DiplomacyColorPalette.Ally : | 417| 417| g_Players[g_ViewedPlayer].isNeutral[i] ? g_DiplomacyColorPalette.Neutral : | 418| |- g_DiplomacyColorPalette.Enemy; | | 418|+ g_DiplomacyColorPalette.Enemy; | 419| 419| | 420| 420| g_DisplayedPlayerColors[0] = g_Players[0].color; | 421| 421| } | | [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 |1190|1190| |1191|1191| let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" : |1192|1192| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1193| |- "hotkey": setStringTags("\\[Click]", g_HotkeyTags), | |1193|+ "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1194|1194| "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1195|1195| }); |1196|1196| | | [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 |1191|1191| let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" : |1192|1192| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1193|1193| "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1194| |- "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") | |1194|+ "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1195|1195| }); |1196|1196| |1197|1197| 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 |1192|1192| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1193|1193| "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1194|1194| "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1195| |- }); | |1195|+ }); |1196|1196| |1197|1197| let resCodes = g_ResourceData.GetCodes(); |1198|1198| 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 |1681|1681| for (let rct of resourcesCounterTypes) |1682|1682| for (let rt of resourcesTypes) |1683|1683| reportObject[rt + rct.substr(9)] = playerStatistics[rct][rt]; |1684| |- // eg. rt = food rct.substr = Gathered rct = resourcesGathered | |1684|+ // eg. rt = food rct.substr = Gathered rct = resourcesGathered |1685|1685| |1686|1686| reportObject.vegetarianFoodGathered = playerStatistics.resourcesGathered.vegetarianFood; |1687|1687| for (let type of unitsClasses) binaries/data/mods/public/gui/session/session.js |1018| » 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 |1093| » » 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 |1094| » » 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 |1095| » » button.onpressright·=·(function(i)·{·return·function()·{·performGroup("breakUp",·i);·};·})(i); | | [NORMAL] ESLintBear (no-shadow): | | 'i' is already declared in the upper scope.
Link to build: https://jenkins.wildfiregames.com/job/differential/77/display/redirect
shouldn't updateViewedPlayerDropdown be in the new file too? ( for getBuildString see D1348)
binaries/data/mods/public/gui/common/functions_utility.js | ||
---|---|---|
244 | period | |
245 | parentName jsDoc | |
246 | @param {number} margin - The ... | |
248 | please make a new revision with this change and use it for the tab_buttons, options in option menu, settings in gamesetup, and maybe some more | |
binaries/data/mods/public/gui/session/top_panel.js | ||
29–30 ↗ | (On Diff #5892) | seems like we just want to loop over the indices instead and use .length below |
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Default... Executing section Source... Executing section JS... binaries/data/mods/public/gui/session/top_panel.js | 66| The line belonging to the following result cannot be printed because it refers to a line that doesn't seem to exist in the given file. | | [MAJOR] ESLintBear: | | Parsing error: Unexpected token binaries/data/mods/public/gui/session/top_panel.js | 6| { | | [MAJOR] JSHintBear: | | Unmatched '{'. binaries/data/mods/public/gui/session/top_panel.js | 66| The line belonging to the following result cannot be printed because it refers to a line that doesn't seem to exist in the given file. | | [MAJOR] JSHintBear: | | Unrecoverable syntax error. (100% scanned). binaries/data/mods/public/gui/common/functions_utility.js | 189| » }·catch·(e)·{ | | [NORMAL] ESLintBear (no-empty): | | Empty block statement. | | [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 | 412| 412| // Players see colors depending on diplomacy | 413| 413| g_DisplayedPlayerColors[i] = | 414| 414| g_ViewedPlayer == i ? getDiplomacyColor("self") : | 415| |- g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | | 415|+ g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | 416| 416| g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | 417| 417| getDiplomacyColor("enemy"); | 418| 418| | | [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 | 413| 413| g_DisplayedPlayerColors[i] = | 414| 414| g_ViewedPlayer == i ? getDiplomacyColor("self") : | 415| 415| g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | 416| |- g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | | 416|+ g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | 417| 417| getDiplomacyColor("enemy"); | 418| 418| | 419| 419| 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 | 414| 414| g_ViewedPlayer == i ? getDiplomacyColor("self") : | 415| 415| g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | 416| 416| g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | 417| |- getDiplomacyColor("enemy"); | | 417|+ getDiplomacyColor("enemy"); | 418| 418| | 419| 419| g_DisplayedPlayerColors[0] = g_Players[0].color; | 420| 420| } | | [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 |1183|1183| |1184|1184| let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" : |1185|1185| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1186| |- "hotkey": setStringTags("\\[Click]", g_HotkeyTags), | |1186|+ "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1187|1187| "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1188|1188| }); |1189|1189| | | [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 |1184|1184| let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" : |1185|1185| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1186|1186| "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1187| |- "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") | |1187|+ "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1188|1188| }); |1189|1189| |1190|1190| 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 |1185|1185| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1186|1186| "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1187|1187| "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1188| |- }); | |1188|+ }); |1189|1189| |1190|1190| let resCodes = g_ResourceData.GetCodes(); |1191|1191| 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 |1683|1683| for (let rct of resourcesCounterTypes) |1684|1684| for (let rt of resourcesTypes) |1685|1685| reportObject[rt + rct.substr(9)] = playerStatistics[rct][rt]; |1686| |- // eg. rt = food rct.substr = Gathered rct = resourcesGathered | |1686|+ // eg. rt = food rct.substr = Gathered rct = resourcesGathered |1687|1687| |1688|1688| reportObject.vegetarianFoodGathered = playerStatistics.resourcesGathered.vegetarianFood; |1689|1689| for (let type of unitsClasses) binaries/data/mods/public/gui/session/session.js |1011| » 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 |1086| » » 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 |1087| » » 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 |1088| » » button.onpressright·=·(function(i)·{·return·function()·{·performGroup("breakUp",·i);·};·})(i); | | [NORMAL] ESLintBear (no-shadow): | | 'i' is already declared in the upper scope.
Link to build: https://jenkins.wildfiregames.com/job/differential/292/display/redirect
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Default... Executing section Source... Executing section JS... binaries/data/mods/public/gui/session/top_panel.js | 66| The line belonging to the following result cannot be printed because it refers to a line that doesn't seem to exist in the given file. | | [MAJOR] ESLintBear: | | Parsing error: Unexpected token binaries/data/mods/public/gui/session/top_panel.js | 6| { | | [MAJOR] JSHintBear: | | Unmatched '{'. binaries/data/mods/public/gui/session/top_panel.js | 66| The line belonging to the following result cannot be printed because it refers to a line that doesn't seem to exist in the given file. | | [MAJOR] JSHintBear: | | Unrecoverable syntax error. (100% scanned). binaries/data/mods/public/gui/common/functions_utility.js | 189| » }·catch·(e)·{ | | [NORMAL] ESLintBear (no-empty): | | Empty block statement. | | [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 | 412| 412| // Players see colors depending on diplomacy | 413| 413| g_DisplayedPlayerColors[i] = | 414| 414| g_ViewedPlayer == i ? getDiplomacyColor("self") : | 415| |- g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | | 415|+ g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | 416| 416| g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | 417| 417| getDiplomacyColor("enemy"); | 418| 418| | | [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 | 413| 413| g_DisplayedPlayerColors[i] = | 414| 414| g_ViewedPlayer == i ? getDiplomacyColor("self") : | 415| 415| g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | 416| |- g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | | 416|+ g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | 417| 417| getDiplomacyColor("enemy"); | 418| 418| | 419| 419| 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 | 414| 414| g_ViewedPlayer == i ? getDiplomacyColor("self") : | 415| 415| g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | 416| 416| g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | 417| |- getDiplomacyColor("enemy"); | | 417|+ getDiplomacyColor("enemy"); | 418| 418| | 419| 419| g_DisplayedPlayerColors[0] = g_Players[0].color; | 420| 420| } | | [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 |1183|1183| |1184|1184| let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" : |1185|1185| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1186| |- "hotkey": setStringTags("\\[Click]", g_HotkeyTags), | |1186|+ "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1187|1187| "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1188|1188| }); |1189|1189| | | [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 |1184|1184| let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" : |1185|1185| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1186|1186| "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1187| |- "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") | |1187|+ "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1188|1188| }); |1189|1189| |1190|1190| 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 |1185|1185| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1186|1186| "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1187|1187| "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1188| |- }); | |1188|+ }); |1189|1189| |1190|1190| let resCodes = g_ResourceData.GetCodes(); |1191|1191| 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 |1683|1683| for (let rct of resourcesCounterTypes) |1684|1684| for (let rt of resourcesTypes) |1685|1685| reportObject[rt + rct.substr(9)] = playerStatistics[rct][rt]; |1686| |- // eg. rt = food rct.substr = Gathered rct = resourcesGathered | |1686|+ // eg. rt = food rct.substr = Gathered rct = resourcesGathered |1687|1687| |1688|1688| reportObject.vegetarianFoodGathered = playerStatistics.resourcesGathered.vegetarianFood; |1689|1689| for (let type of unitsClasses) binaries/data/mods/public/gui/session/session.js |1011| » 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 |1086| » » 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 |1087| » » 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 |1088| » » button.onpressright·=·(function(i)·{·return·function()·{·performGroup("breakUp",·i);·};·})(i); | | [NORMAL] ESLintBear (no-shadow): | | 'i' is already declared in the upper scope.
Link to build: https://jenkins.wildfiregames.com/job/differential/293/display/redirect
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Default... Executing section Source... Executing section JS... binaries/data/mods/public/gui/session/top_panel.js | 66| The line belonging to the following result cannot be printed because it refers to a line that doesn't seem to exist in the given file. | | [MAJOR] ESLintBear: | | Parsing error: Unexpected token binaries/data/mods/public/gui/session/top_panel.js | 6| { | | [MAJOR] JSHintBear: | | Unmatched '{'. binaries/data/mods/public/gui/session/top_panel.js | 66| The line belonging to the following result cannot be printed because it refers to a line that doesn't seem to exist in the given file. | | [MAJOR] JSHintBear: | | Unrecoverable syntax error. (100% scanned). binaries/data/mods/public/gui/common/functions_utility.js | 189| » }·catch·(e)·{ | | [NORMAL] ESLintBear (no-empty): | | Empty block statement. | | [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 | 412| 412| // Players see colors depending on diplomacy | 413| 413| g_DisplayedPlayerColors[i] = | 414| 414| g_ViewedPlayer == i ? getDiplomacyColor("self") : | 415| |- g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | | 415|+ g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | 416| 416| g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | 417| 417| getDiplomacyColor("enemy"); | 418| 418| | | [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 | 413| 413| g_DisplayedPlayerColors[i] = | 414| 414| g_ViewedPlayer == i ? getDiplomacyColor("self") : | 415| 415| g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | 416| |- g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | | 416|+ g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | 417| 417| getDiplomacyColor("enemy"); | 418| 418| | 419| 419| 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 | 414| 414| g_ViewedPlayer == i ? getDiplomacyColor("self") : | 415| 415| g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | 416| 416| g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | 417| |- getDiplomacyColor("enemy"); | | 417|+ getDiplomacyColor("enemy"); | 418| 418| | 419| 419| g_DisplayedPlayerColors[0] = g_Players[0].color; | 420| 420| } | | [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 |1183|1183| |1184|1184| let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" : |1185|1185| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1186| |- "hotkey": setStringTags("\\[Click]", g_HotkeyTags), | |1186|+ "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1187|1187| "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1188|1188| }); |1189|1189| | | [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 |1184|1184| let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" : |1185|1185| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1186|1186| "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1187| |- "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") | |1187|+ "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1188|1188| }); |1189|1189| |1190|1190| 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 |1185|1185| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1186|1186| "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1187|1187| "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1188| |- }); | |1188|+ }); |1189|1189| |1190|1190| let resCodes = g_ResourceData.GetCodes(); |1191|1191| 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 |1683|1683| for (let rct of resourcesCounterTypes) |1684|1684| for (let rt of resourcesTypes) |1685|1685| reportObject[rt + rct.substr(9)] = playerStatistics[rct][rt]; |1686| |- // eg. rt = food rct.substr = Gathered rct = resourcesGathered | |1686|+ // eg. rt = food rct.substr = Gathered rct = resourcesGathered |1687|1687| |1688|1688| reportObject.vegetarianFoodGathered = playerStatistics.resourcesGathered.vegetarianFood; |1689|1689| for (let type of unitsClasses) binaries/data/mods/public/gui/session/session.js |1011| » 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 |1086| » » 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 |1087| » » 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 |1088| » » button.onpressright·=·(function(i)·{·return·function()·{·performGroup("breakUp",·i);·};·})(i); | | [NORMAL] ESLintBear (no-shadow): | | 'i' is already declared in the upper scope.
Link to build: https://jenkins.wildfiregames.com/job/differential/294/display/redirect
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Default... Executing section Source... Executing section JS... | | [NORMAL] ESLintBear (indent): | | Expected indentation of 4 tabs but found 3. |----| | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/top_panel.js | |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/gui/session/top_panel.js | 17| 17| "civ": setStringTags(g_CivData[g_Players[g_ViewedPlayer].civ].Name, { "font": "sans-bold-stroke-14" }), | 18| 18| "hotkey_civinfo": colorizeHotkey("%(hotkey)s", "civinfo"), | 19| 19| "hotkey_structree": colorizeHotkey("%(hotkey)s", "structree") | 20| |- }); | | 20|+ }); | 21| 21| } | 22| 22| | 23| 23| Engine.GetGUIObjectByName("optionFollowPlayer").hidden = !g_IsObserver || binaries/data/mods/public/gui/common/functions_utility.js | 189| » }·catch·(e)·{ | | [NORMAL] ESLintBear (no-empty): | | Empty block statement. | | [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 | 412| 412| // Players see colors depending on diplomacy | 413| 413| g_DisplayedPlayerColors[i] = | 414| 414| g_ViewedPlayer == i ? getDiplomacyColor("self") : | 415| |- g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | | 415|+ g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | 416| 416| g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | 417| 417| getDiplomacyColor("enemy"); | 418| 418| | | [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 | 413| 413| g_DisplayedPlayerColors[i] = | 414| 414| g_ViewedPlayer == i ? getDiplomacyColor("self") : | 415| 415| g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | 416| |- g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | | 416|+ g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | 417| 417| getDiplomacyColor("enemy"); | 418| 418| | 419| 419| 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 | 414| 414| g_ViewedPlayer == i ? getDiplomacyColor("self") : | 415| 415| g_Players[g_ViewedPlayer].isAlly[i] ? getDiplomacyColor("ally") : | 416| 416| g_Players[g_ViewedPlayer].isNeutral[i] ? getDiplomacyColor("neutral") : | 417| |- getDiplomacyColor("enemy"); | | 417|+ getDiplomacyColor("enemy"); | 418| 418| | 419| 419| g_DisplayedPlayerColors[0] = g_Players[0].color; | 420| 420| } | | [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 |1183|1183| |1184|1184| let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" : |1185|1185| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1186| |- "hotkey": setStringTags("\\[Click]", g_HotkeyTags), | |1186|+ "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1187|1187| "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1188|1188| }); |1189|1189| | | [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 |1184|1184| let orderHotkeyTooltip = Object.keys(viewablePlayerStates).length <= 1 ? "" : |1185|1185| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1186|1186| "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1187| |- "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") | |1187|+ "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1188|1188| }); |1189|1189| |1190|1190| 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 |1185|1185| "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), { |1186|1186| "hotkey": setStringTags("\\[Click]", g_HotkeyTags), |1187|1187| "order": tooltipSort == 0 ? translate("Unordered") : tooltipSort == 1 ? translate("Descending") : translate("Ascending") |1188| |- }); | |1188|+ }); |1189|1189| |1190|1190| let resCodes = g_ResourceData.GetCodes(); |1191|1191| 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 |1683|1683| for (let rct of resourcesCounterTypes) |1684|1684| for (let rt of resourcesTypes) |1685|1685| reportObject[rt + rct.substr(9)] = playerStatistics[rct][rt]; |1686| |- // eg. rt = food rct.substr = Gathered rct = resourcesGathered | |1686|+ // eg. rt = food rct.substr = Gathered rct = resourcesGathered |1687|1687| |1688|1688| reportObject.vegetarianFoodGathered = playerStatistics.resourcesGathered.vegetarianFood; |1689|1689| for (let type of unitsClasses) binaries/data/mods/public/gui/session/session.js |1011| » 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 |1086| » » 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 |1087| » » 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 |1088| » » button.onpressright·=·(function(i)·{·return·function()·{·performGroup("breakUp",·i);·};·})(i); | | [NORMAL] ESLintBear (no-shadow): | | 'i' is already declared in the upper scope.
Link to build: https://jenkins.wildfiregames.com/job/differential/295/display/redirect
The reason I'm proposing this patch is to improve mod support for myself and others who'd like to modify e.g. the resource bar like I did in my 0abc mod.
The "verticallySpaceObjects" function is basically a copy of the "horizontallySpaceObjects" function directly above, mutatis mutandis. I use it in my 0abc mod; including it in the main game would save me, and other modders who'd like to list objects vertically, the trouble of maintaining a full copy of the functions_utility.js file.
Also, I don't intend to change "updateTopPanel" the function; I can see it works, but I don't fully understand it in detail. This patch merely moves the function out of the hard-to-maintain session.js into a new file. This way modders don't have to keep a copy of session.js, they can simply tweak the small top_panel.js file instead.
I understand that, and agree such a function could be useful and actually already is (see last comments). So I am only saying that the two proposed changes (function move and new function) should both get an own revision and that the function should be used in a few places already.
Also, I don't intend to change "updateTopPanel" the function; I can see it works, but I don't fully understand it in detail. This patch merely moves the function out of the hard-to-maintain session.js into a new file. This way modders don't have to keep a copy of session.js, they can simply tweak the small top_panel.js file instead.
Didn't ask for real changes (as in executing the code would result in the same), but only a small style fix.
What about that updateViewedPlayerDropdown move?
Split patch in two: this one introduces the "vertically space objects" function; D1410 moves the "update top panel" into a separate file.
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Default... Executing section Source... Executing section JS... binaries/data/mods/public/gui/common/functions_utility.js | 189| » }·catch·(e)·{ | | [NORMAL] ESLintBear (no-empty): | | Empty block statement.
Link to build: https://jenkins.wildfiregames.com/job/differential/301/display/redirect
The function looks good and seems already useable in a couple of places in the public mod, (from the top of my mind: tab_buttons, options in options menu, settings in gamesetup). It would be great to let those places use the new function while adding the function to he codebase.
EDIT: gamesetup probably no the best example due to the column splitting, so leave that one out. (one could add two extra parameters start and stop indicating the first /last index of the button to be distributed, then gamesetup can become agnostic too)
binaries/data/mods/public/gui/common/functions_utility.js | ||
---|---|---|
246 | Also add @param {string} parentName - Name of the parent GUIObject. |
It would be great to let those places use the new function while adding the function to he codebase.
My programming skills are rather limited, but I'm willing to give it a look, see if I can find them, and possibly make use of the new vso function.
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Default... Executing section Source... Executing section JS... binaries/data/mods/public/gui/common/functions_utility.js | 189| » }·catch·(e)·{ | | [NORMAL] ESLintBear (no-empty): | | Empty block statement.
Link to build: https://jenkins.wildfiregames.com/job/differential/304/display/redirect
binaries/data/mods/public/gui/common/functions_utility.js | ||
---|---|---|
217 | I think, the hideRemaining doesn't sound like 'Hide all children after a certain index". Probably hideChildrenFrom or hideChildren? |
Does discussing the implementation imply that we all prefer this design over the existing one? Maybe it's just me being used to the existing UI, but IMO it could look nicer.
Actually we (s0600204 and me) ran into this problem when the resource-agnostic patch was done... it was at the barter panel at the market.
If there are 4 resources, the existing GUI composition was used, whereas with 5+ variants, it did something less beautiful but more usable to (GUI-lazy) mods.
Does discussing the implementation imply that we all prefer this design over the existing one? Maybe it's just me being used to the existing UI, but IMO it could look nicer.
I don't understand what you mean there?
As far as I understand it this patch doesn't change the UI, it just allows modders to change theirs using different methods.
I thought the goal of the diff was to support more than 4 resources in the top bar without mods having to change the GUI, i.e. that 0 AD should use the same theme as on the screenshot..
But if it's just introducing the counterpart to the other function, even if unused, then I guess that can be done, so that GUI modders don't have to invent that function that they likely will need (and every of them will likely need the same function).
(D1650 also adds new algining code, perhaps these three can be refactored/merged/united eventually.)
To clarify, this patch does not change the current GUI. All it does it add a function that could be useful for modders. The screenshot is an example how it *could* be used.
(forEach((object, i) => ) could save one line yay.
The hideRemaining function isn't changed and doesn't benefit from the move?