rP18487 Introduced that the "deletable"-button is not enabled when there is no entity to delete by checking for the "delete" command and whether the entity state is undeletable. rP18773 Fixed multiple entities selected by introducing the same check as performed in unit_actions.js.
rP18347 Introduced the "g_Observer" check.
This patch introduces optional enabledPlayer- and enabledObserver-elements in the object returned to selection_panels.js, both removing hardcoding of "delete" and "focus-rally" and allowing other commands to specify whether the button ought to be enabled or disabled (e.g. unloading not allowed when the garrison holder is moving).
Details
- Reviewers
- None
- Group Reviewers
Restricted Owners Package (Owns No Changed Paths)
Verify that previous behaviour is maintained by:
- Selecting an undeletable entity and checking that the button is disabled.
- Selecting a deletable entity and checking that the button is enabled.
Diff Detail
- Repository
- rP 0 A.D. Public Repository
- Branch
- /ps/trunk
- Lint
Lint OK - Unit
No Unit Test Coverage - Build Status
Buildable 9972 Build 16835: Vulcan Build Jenkins Build 16834: Vulcan Build (Windows) Jenkins Build 16833: arc lint + arc unit
Event Timeline
Successful build - Chance fights ever on the side of the prudent.
Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/495/display/redirect
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Source... Executing section JS... | | [NORMAL] ESLintBear (space-before-function-paren): | | Unexpected space before function parentheses. |----| | /zpool0/trunk/binaries/data/mods/public/gui/session/selection_panels.js | |++++| /zpool0/trunk/binaries/data/mods/public/gui/session/selection_panels.js | 761| 761| addResearchToQueue(data.item.researchFacilityId, t); | 762| 762| })(tech); | 763| 763| | 764| |- button.onPressRight = (t => function () { | | 764|+ button.onPressRight = (t => function() { | 765| 765| showTemplateDetails( | 766| 766| t, | 767| 767| GetTemplateData(data.unitEntStates.find(state => state.id == data.item.researchFacilityId).template).nativeCiv); binaries/data/mods/public/gui/session/selection_panels.js | 50| » » » switch·(data.item) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. binaries/data/mods/public/gui/session/selection_panels.js | 61| » » switch·(data.item) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. binaries/data/mods/public/gui/session/selection_panels.js | 729| » » » » » » switch·(entity.check) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. | | [NORMAL] ESLintBear (no-extra-semi): | | Unnecessary semicolon. |----| | /zpool0/trunk/binaries/data/mods/public/gui/session/unit_actions.js | |++++| /zpool0/trunk/binaries/data/mods/public/gui/session/unit_actions.js |1099|1099| resumeGame(); |1100|1100| } |1101|1101| ]); |1102| |- }; | |1102|+ } |1103|1103| }, |1104|1104| }, |1105|1105| binaries/data/mods/public/gui/session/unit_actions.js | 557| » » » switch·(tradingDetails.type) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. binaries/data/mods/public/gui/session/unit_actions.js |1102| » » » }; | | [NORMAL] JSHintBear: | | Unnecessary semicolon. Executing section cli...
Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1010/display/redirect
I guess you mean true and false, not "true" and "false". You can check for === undefined if you want default = true.
Active may be renamed to enabled, because it will be assigned to the enabled property of the GUIObject (i.e. less indirection, less vocabulary used to describe the same behavior).
The patch appears correct, without having it tested.
Also it appears like it's doing one less loop through all selected entities, i.e. a performance improvement. Can measure rudimentarily with let foo = Engine.GetMicroseconds(); ...; warn(Engine.GetMicroseconds() - foo);, or with those profiler commands I never tried Engine.ProfileStart("Trade Manager");, Engine.ProfileStop();.
Also its good to have this delete hardcoding removed. Consequentially the next question is what to do with data.item.name == "focus-rally"; in particular whether one can removed that as well without adding lots of function calls.
Successful build - Chance fights ever on the side of the prudent.
Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/498/display/redirect
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Source... Executing section JS... | | [NORMAL] ESLintBear (no-extra-semi): | | Unnecessary semicolon. |----| | /zpool0/trunk/binaries/data/mods/public/gui/session/unit_actions.js | |++++| /zpool0/trunk/binaries/data/mods/public/gui/session/unit_actions.js |1099|1099| resumeGame(); |1100|1100| } |1101|1101| ]); |1102| |- }; | |1102|+ } |1103|1103| }, |1104|1104| }, |1105|1105| binaries/data/mods/public/gui/session/unit_actions.js | 557| » » » switch·(tradingDetails.type) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. binaries/data/mods/public/gui/session/unit_actions.js |1102| » » » }; | | [NORMAL] JSHintBear: | | Unnecessary semicolon. | | [NORMAL] ESLintBear (space-before-function-paren): | | Unexpected space before function parentheses. |----| | /zpool0/trunk/binaries/data/mods/public/gui/session/selection_panels.js | |++++| /zpool0/trunk/binaries/data/mods/public/gui/session/selection_panels.js | 761| 761| addResearchToQueue(data.item.researchFacilityId, t); | 762| 762| })(tech); | 763| 763| | 764| |- button.onPressRight = (t => function () { | | 764|+ button.onPressRight = (t => function() { | 765| 765| showTemplateDetails( | 766| 766| t, | 767| 767| GetTemplateData(data.unitEntStates.find(state => state.id == data.item.researchFacilityId).template).nativeCiv); binaries/data/mods/public/gui/session/selection_panels.js | 50| » » » switch·(data.item) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. binaries/data/mods/public/gui/session/selection_panels.js | 61| » » switch·(data.item) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. binaries/data/mods/public/gui/session/selection_panels.js | 729| » » » » » » switch·(entity.check) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. Executing section cli...
Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1013/display/redirect
or !!data.item.enabled
it would be good to move the focus-rally too without adding too many function calls
binaries/data/mods/public/gui/session/selection_panels.js | ||
---|---|---|
138 | This check sounds somehow redundant. Any way to make it true/false instead of tristate ? |
binaries/data/mods/public/gui/session/selection_panels.js | ||
---|---|---|
138 | if enabled == true is wanted default behaviour, one can invert and do disabled property instead or write this one like |
Successful build - Chance fights ever on the side of the prudent.
Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/545/display/redirect
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Source... Executing section JS... | | [NORMAL] ESLintBear (space-before-function-paren): | | Unexpected space before function parentheses. |----| | /zpool0/trunk/binaries/data/mods/public/gui/session/selection_panels.js | |++++| /zpool0/trunk/binaries/data/mods/public/gui/session/selection_panels.js | 762| 762| addResearchToQueue(data.item.researchFacilityId, t); | 763| 763| })(tech); | 764| 764| | 765| |- button.onPressRight = (t => function () { | | 765|+ button.onPressRight = (t => function() { | 766| 766| showTemplateDetails( | 767| 767| t, | 768| 768| GetTemplateData(data.unitEntStates.find(state => state.id == data.item.researchFacilityId).template).nativeCiv); binaries/data/mods/public/gui/session/selection_panels.js | 50| » » » switch·(data.item) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. binaries/data/mods/public/gui/session/selection_panels.js | 61| » » switch·(data.item) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. binaries/data/mods/public/gui/session/selection_panels.js | 730| » » » » » » switch·(entity.check) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. binaries/data/mods/public/gui/session/unit_actions.js | 557| » » » switch·(tradingDetails.type) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. Executing section cli...
Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1059/display/redirect
- Less redundant checking.
- Ternary for observer check.
- Back to checking for undefined explicitly.
Successful build - Chance fights ever on the side of the prudent.
Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/548/display/redirect
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Source... Executing section JS... | | [NORMAL] ESLintBear (space-before-function-paren): | | Unexpected space before function parentheses. |----| | /zpool0/trunk/binaries/data/mods/public/gui/session/selection_panels.js | |++++| /zpool0/trunk/binaries/data/mods/public/gui/session/selection_panels.js | 760| 760| addResearchToQueue(data.item.researchFacilityId, t); | 761| 761| })(tech); | 762| 762| | 763| |- button.onPressRight = (t => function () { | | 763|+ button.onPressRight = (t => function() { | 764| 764| showTemplateDetails( | 765| 765| t, | 766| 766| GetTemplateData(data.unitEntStates.find(state => state.id == data.item.researchFacilityId).template).nativeCiv); binaries/data/mods/public/gui/session/selection_panels.js | 50| » » » switch·(data.item) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. binaries/data/mods/public/gui/session/selection_panels.js | 61| » » switch·(data.item) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. binaries/data/mods/public/gui/session/selection_panels.js | 728| » » » » » » switch·(entity.check) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. binaries/data/mods/public/gui/session/unit_actions.js | 557| » » » switch·(tradingDetails.type) | | [NORMAL] ESLintBear (default-case): | | Expected a default case. Executing section cli...
Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1062/display/redirect
binaries/data/mods/public/gui/session/selection_panels.js | ||
---|---|---|
139 | Some repetition: 2019-10-29-QuakeNet-#0ad-dev.log:18:07 < elexis> (an observerEnabled playerEnabled might be one way to do it, but only one enabled property sounds nicer) 2019-11-07-QuakeNet-#0ad-dev.log:18:53 < elexis> I thought of enabledPlayer and enabledObserver for the review: 2019-11-07-QuakeNet-#0ad-dev.log:20:55 < elexis> what's the difference between data.item.enabledObserver and data.item.enabledObserver == true? I think the answer to the last one is that enabled assignment will show a warning if it receives a value that is not of type boolean? In that case its more common to use !! (although Im not so sure if Boolean() wouldn't appear cleaner some time in the future)
i.e. less or none? |