Part 4: UI Controls
Note: all of the following require a call to Tools.Init before they will work (generally following scenario start or load). This in turn requires the following declaration at the top of your .cs file:
private Toolset Tools;
FlashUIControl(int inProgrammerCode, int inFormID, int inFlashPeriod)
Flashes the specified build button, unsually when it has just been unlocked. The flash period appears to be measured in milliseconds: the smaller the value, the quicker the flash. See LockUIControl below for more details on its use.
LockUIControl(int inProgrammerCode, int inFormID)
This locks the specified build button, preventing the player from building that particular structure. This would be used normally to disable a building until particular requirements are met.
The control has to be identified by its ID; for some buildings, this can be obtained from IDMaker. (For others I had to find the absolute ID value by a 'brute force' custom script.) All known values are posted in the annex. Note that there are a small number for which we have not been able to find an ID. Examples (locking the furniture and utensils factory buttons:
int mUIIDFurniture = IDMaker.FromString("FACTORY_FURNITURE");
int mUIIDUtensils = 246675851;
game.LockUIControl(mUIIDFurniture, Toolset.MainGameFormID);
game.LockUIControl(mUIIDUtensils, Toolset.MainGameFormID);
See Part 11 for a complete list of UI control IDs.
Notes:
- If you are writing a script that uses this technique, you will need to keep track of which ones have been locked/unlocked by means of Boolean flags that are persistent across loads, i.e. their values are retained when the scenario is loaded from a saved game. The function ResetBaseUI is generally used on scenario start and load to reset the controls based on the values of these flags.
- For the major buttons e.g. Government, there is a method in Tools.cs that can be used to lock/unlock these buttons. For example:
Tools.LockUI((int)Toolset.UIID._Govt);
UnlockUIControl(int inProgrammerCode, int inFormID)
This unlocks the specified control, which will have been locked using LockUIControl as described above.
GetUIControlLocked(int inProgrammerCode, int inFormID, out bool outLocked)
Not tested, but presumably works in much the same way as LockUIControl etc. It has no obvious purpose (except perhaps for debugging), since if controls are being locked/unlocked then the script will need to keep track of these using its own boolean flags.
GetUIControlUsed(int inProgrammerCode, int inFormID, out bool outUsed)
Not tested, but presumably works in much the same way as LockUIControl etc. Its purpose is unknown.
< Previous: Buildings and resources | Editor Guide | Next: Triggered events >