Index: binaries/data/mods/public/gui/session/selection_panels.js =================================================================== --- binaries/data/mods/public/gui/session/selection_panels.js +++ binaries/data/mods/public/gui/session/selection_panels.js @@ -1018,6 +1018,59 @@ } }; +g_SelectionPanels.Turrets = { + "getMaxNumberOfItems": function() + { + return 24 - getNumberOfRightPanelButtons(); + }, + "getItems": function(unitEntStates) + { + if (unitEntStates.every(state => !state.garrisonHolder || !state.garrisonHolder.visibleGarrisonPoints.length)) + return []; + + let visibleGarrisonPoints = []; + + for (let state of unitEntStates) + if (state.garrisonHolder && state.garrisonHolder.visibleGarrisonPoints.length) + for (let point of state.garrisonHolder.visibleGarrisonPoints) + visibleGarrisonPoints.push(point); + + return visibleGarrisonPoints; + }, + "setupButton": function(data) + { + let entState; + let template; + if (data.item.entity) + { + entState = GetEntityState(data.item.entity); + template = GetTemplateData(entState.template); + } + + data.button.onPress = function() { + warn("Called!");; + }; + + data.button.enabled = !!entState && controlsPlayer(g_ViewedPlayer); + + data.button.tooltip = "Some (still bogus) tooltup."; + + data.guiSelection.sprite = "color:" + g_DiplomacyColors.getPlayerColor(!entState ? data.player : entState.player, 160); + data.button.sprite_disabled = data.button.sprite; + + // Selection panel buttons only appear disabled if they + // also appear disabled to the owner of the building. + data.icon.sprite = + (!g_IsObserver ? "" : "grayscale:") + + (!!template ? "stretched:session/portraits/" + template.icon : + "stretched:session/icons/groups.png"); + + setPanelObjectPosition(data.button, data.i + getNumberOfRightPanelButtons(), data.rowLength); + + return true; + } +}; + g_SelectionPanels.Upgrade = { "getMaxNumberOfItems": function() { @@ -1176,6 +1229,7 @@ "Gate", // Must always be shown on gates "Pack", // Must always be shown on packable entities "Upgrade", // Must always be shown on upgradable entities + "Turrets", "Training", "Construction", "Research", // Normal together with training Index: binaries/data/mods/public/gui/session/selection_panels_right/turrets_panel.xml =================================================================== --- /dev/null +++ binaries/data/mods/public/gui/session/selection_panels_right/turrets_panel.xml @@ -0,0 +1,13 @@ + + + + + Index: binaries/data/mods/public/simulation/components/GarrisonHolder.js =================================================================== --- binaries/data/mods/public/simulation/components/GarrisonHolder.js +++ binaries/data/mods/public/simulation/components/GarrisonHolder.js @@ -106,6 +106,16 @@ }; /** + * Get the visible garrison points of this entity. + * + * @return {Object[]} - An array containing visibly garrison points. + */ +GarrisonHolder.prototype.GetVisibleGarrisonPoints = function() +{ + return this.visibleGarrisonPoints; +}; + +/** * @return {Array} unit classes which can be garrisoned inside this * particular entity. Obtained from the entity's template. */ Index: binaries/data/mods/public/simulation/components/GuiInterface.js =================================================================== --- binaries/data/mods/public/simulation/components/GuiInterface.js +++ binaries/data/mods/public/simulation/components/GuiInterface.js @@ -360,7 +360,8 @@ "buffHeal": cmpGarrisonHolder.GetHealRate(), "allowedClasses": cmpGarrisonHolder.GetAllowedClasses(), "capacity": cmpGarrisonHolder.GetCapacity(), - "garrisonedEntitiesCount": cmpGarrisonHolder.GetGarrisonedEntitiesCount() + "garrisonedEntitiesCount": cmpGarrisonHolder.GetGarrisonedEntitiesCount(), + "visibleGarrisonPoints": cmpGarrisonHolder.GetVisibleGarrisonPoints() }; ret.canGarrison = !!Engine.QueryInterface(ent, IID_Garrisonable);