Actions Grid Panel

An upcoming extendable UI mod providing actions grid panel. Panel is used to provide actions that can be performed with current selection.

Sample exenstions are:

  • Enhancements extension:
    6ad9d023-9a05-4ede-8d55-c9f2d1ba9ae9-image.png
  • Factory templates extension:
    43d93e8b-c84d-4df7-b1af-55c6d19f6cec-image.png

Panel supports various settings and can be adjusted if needed:
9efc8392-3ffe-4ab5-83c6-1665bffb80d4-image.png
Extensions can be enabled/disabled via dedicated selector:
707952ef-705c-438b-b974-35e5d38d387a-image.png

Stay tuned!

“Be a yardstick of quality. Some people aren’t used to an environment where excellence is expected.”
— Steve Jobs.
My UI Mods
Support me

How to make your own extension
Extension starts with specifying in mod_info.lua that mod has anything for actions grid panel to work with.

AGP = "ExampleHandler"

In mod’s folder there must be a file with the same name containing a class with the same name.

ExampleHandler.lua:

--Generic imports for interfaces
local ISelectionHandler = import("/mods/AGP/modules/ISelectionHandler.lua").ISelectionHandler

local IItemComponent = import("/mods/AGP/modules/IItemComponent.lua").IItemComponent


---Handler class must implement ISelectionHandler interface to function. 
---It also must have a dedicated component class implementing IItemComponent.
---@class ExampleHandler : ISelectionHandler
ExampleHandler = Class(ISelectionHandler)
{
	--Name of the extension displayed in extensions selector 
    Name = "Example extension",

	--Description of the extension displayed in extensions selector
    Description = "Extension for testing purposes",

	--Decides whether extension is enabled by default of not
    Enabled = false,

	--called when player’s selection is changed. Here is a logic for providing grid with actions of this extension in particular. These actions then are processed by component below.
    ---@param self ExampleHandler
    ---@param selection UserUnit[]
    ---@return any[]?
    OnSelectionChanged = function(self, selection)    
    end,

  	--component class that receives action provided by handler. Since each item in grid has multiple components at once it is important to ensure that active one is not interrupted by disabled ones. Here is interface for it.
    ---@class ExampleComponent : IItemComponent
    ComponentClass = Class(IItemComponent)
    {
        ---Called when component is bond to an item. Initialize your controls and logic here.
        ---@param self ExampleComponent
        ---@param item Item
        Create = function(self, item)
        end,
        
        ---Called when grid item receives an event
        ---@param self ExampleComponent
        ---@param item Item
        ---@param event KeyEvent
        HandleEvent = function(self, item, event)
        end,

        ---Called when item is activated with this component. Here you show and enable components controls and logic
        ---@param self ExampleComponent
        ---@param item Item
        Enable = function(self, item)
        end,

		--called when component receives action it is bond to
        ---@param self ExampleComponent
        ---@param action string
		SetAction = function(self, action)
        end,  

        ---Called when item is changing an event handler. Here you hide and disable controls of the component 
        ---@param self ExampleComponent
        ---@param item Item
        Disable = function(self, item)
        end,

        ---Called when component is being destroyed. Clear all fields you had and destroy controls.
        ---@param self ExampleComponent
        Destroy = function(self)
        end,
    },
}

“Be a yardstick of quality. Some people aren’t used to an environment where excellence is expected.”
— Steve Jobs.
My UI Mods
Support me

Mod is uploaded with Factory Templates extension.

“Be a yardstick of quality. Some people aren’t used to an environment where excellence is expected.”
— Steve Jobs.
My UI Mods
Support me

Looks useful, good stuff.

"Design is an iterative process. The required number of iterations is one more than the number you have currently done. This is true at any point in time."

See all my projects:

Updated how to create your own extension. this looks ugly but I was doing that one not on pc 😛
It also lacks proper syntax highlighting 😞 @Brutus5000 is there a possibility that it will be fixed?

“Be a yardstick of quality. Some people aren’t used to an environment where excellence is expected.”
— Steve Jobs.
My UI Mods
Support me

Since there is no proper syntax highlighting I've added it to Mods README.

“Be a yardstick of quality. Some people aren’t used to an environment where excellence is expected.”
— Steve Jobs.
My UI Mods
Support me