One of the real pains of modding CC2 comes when two mods conflict. You cant trivially use two mods that alter the same in-game files. Your only options are to manually merge them yourself, which often is a challenge, or to hope the owners of either mod will agree to do the same.
UI Enhancer is an absolute MUST HAVE mod for the game. While it is perfectly playable without, UI Enhancer is so good it feels like it IS the official game interface. However because it touches so many areas to tweak them, it alters many files that other mods want to change.
For instance, if you want to change what attachments can be used on an Albatross, you have to edit get_ui_vehicle_chassis_attachments() function in the library_ui.lua script to add the extra options, this means you conflict with UI Enhancer because it edits that too.
Allowing for fewer conflicts
I’ve written up a bit about how the game loads the lua files here https://github.com/cc2modteam/knowledgebase/wiki/Mod-Lua-Capabilities-and-Load-order
In essence, the four library files are joined together as one file, and then executed once as a whole before the game loop functions are called. This means that any change you make to library_ui.lua can override those made to any of the earlier library_*.lua files.
What does this mean?
If we moved all the UI enhancer changes from the earlier library files into library_ui.lua, we could allow other mods to alter those files. By itself this wouldn’t help much as library_ui.lua would override those changes, but it could allow us to create a few basic extension points that others could implement/extend by editing the earlier files. eg
# library_ui.lua
function get_ui_vehicle_chassis_attachments(vehicle)
local vehicle_definition_index = vehicle:get_definition_index()
local vehicle_attachment_count = vehicle:get_attachment_count()
local vehicle_attachment_rows = {}
...
return vehicle_attachment_rows
end
The above fragment shows the current interface for the loadout screen. vehicle_attachment_rows is returned containing some basic x,y,shape locations that the loadout screen uses to show where each attachment is and what kind it is.
We could provide an extension point here!
# library_ui.lua
function get_ui_vehicle_chassis_attachments(vehicle)
local vehicle_definition_index = vehicle:get_definition_index()
local vehicle_attachment_count = vehicle:get_attachment_count()
local vehicle_attachment_rows = {}
if g_extend_get_ui_vehicle_chassis_attachments ~= nil then
local ext = g_extend_get_ui_vehicle_chassis_attachments
if ext[vehicle_definition_index] ~= nil then
return ext[vehicle_definition_index]
fi
fi
...
return vehicle_attachment_rows
end
Then, if another mod wanted to change for example the Albatross’s attachment view, it could alter one of the other library scripts to contain:
g_extend_get_ui_vehicle_chassis_attachments = {
e_game_object_type.chassis_air_wing_light = {
{
{ i=1, x=0, y=-22 }
},
{
{ i=2, x=-26, y=0 },
{ i=4, x=-14, y=0 },
{ i=5, x=14, y=0 },
{ i=3, x=26, y=0 },
{ i=6, x=0, y=0 },
}
},
}
The above adds a 6th attachment in the middle of the ALB’s graphic.
When the get_ui_vehicle_chassis_attachments() is called, it sees this extra global and uses the new value.
This may not help the more complex changes but will maybe make it possible for the mods involved with moving or altering hardpoints to be less conflicty!

