Resource icon

Modular Screens 1.0

astog

Warlord
Joined
May 29, 2015
Messages
244
Location
Minneapolis
What is this?
In short, this is a mod that allows other modders to add buttons to launchbar (top left), screen hooks (top right), without needing to overwrite the base game UI files. It also adds a pull down to add extra buttons if the modder wants.

Why use this?
Since this allows modders to not overwrite the same base UI files, more mods will be compatible with each other, and allow them add screens to the game in a more sane way.

How to use this?
For a mod user, this requires the same installation as other mods. If you are a modder, and want to add buttons read the info below for the three main places where you can add buttons.

Launch Bar Extras List
I added list for menus that don't require an icon. I replaced the show/hide for the world builder with the list toggle. This is probably the easiest place to add a button. Below is one example:
Code:
LuaEvents.LaunchBar_AddExtra("Button1", extraButton);
The first parameter is key (to prevent duplicate buttons), second parameter is a table:
Code:
local extraButton:table = {
  Text = "Test1";    -- The text to display in the button
  Callback = Open;   -- The function to call when the button is clicked
  Tooltip = "test1"; -- If nil, tooltip disabled
}



Launch Bar
These are the icons above the world planner with Tech, Civic tree buttons, etc. To add icons call:
Code:
LuaEvents.LaunchBar_AddIcon(buttonInfo);
An example of buttonInfo that adds the samurai button below:
Code:
textureOffsetX, textureOffsetY, textureSheet = IconManager:FindIconAtlas("ICON_UNIT_JAPANESE_SAMURAI", 38);
  local button2Info = {
    -- ICON TEXTURE
    IconTexture = {
      OffsetX = textureOffsetX;
      OffsetY = textureOffsetY+3;
      Sheet = textureSheet;
      Color = UI.GetColorValue("COLOR_PLAYER_BARBARIAN_PRIMARY");
    };

    -- BASE TEXTURE (Treat it as Button Texture)
    BaseTexture = {
      OffsetX = 0;
      OffsetY = 147;
      Sheet = "LaunchBar_Hook_GreatPeopleButton";
      -- Color = UI.GetColorValue("COLOR_BLUE");
      HoverOffsetX = 0;
      HoverOffsetY = 0;
    };

    -- BUTTON INFO
    Callback = function() print("ATTACK!") end;
    -- Tooltip = "barbs...";
  }




Partial Screen Hooks
These are the top right of the screen with trade overview, world score, etc hooks. The way to add to these is similar to Launch Bar buttons.

Code:
LuaEvents.PartialScreenHooks_AddHook(hookInfo1);

The table structure is identical to the one used in Launch bar.

Code:
local hookInfo1:table = {
    -- ICON TEXTURE
    IconTexture = {
      OffsetX = 0;
      OffsetY = 0;
      Sheet = "MapPins24.dds";
      Color = UI.GetColorValue("COLOR_PLAYER_GOLDENROD")
    };

    -- BUTTON TEXTURE
    BaseTexture = {
      OffsetX = 0;
      OffsetY = 0;
      Sheet = "LaunchBar_Hook_ButtonSmall";

      -- Offset to have when hovering
      HoverOffsetX = 0;
      HoverOffsetY = 40;
    };

    Callback = function() print("Damascus steel!") end;
    Tooltip = "ATTACK!";
  };




Usage Notes
All of the LuaEvents should not be called in Initialize() since that would make it load order dependent. Rather call it in this event:
Code:
Events.LoadScreenClose

Other usage example can be seen at the bottom of launchbar.lua and partialscreenhooks.lua.
 
Last edited:

astog

Warlord
Joined
May 29, 2015
Messages
244
Location
Minneapolis
Looks great .. is it finish i didnt get it?
Yes, this is ready. This is a modders resource, so it requires other mods to use this in future.
 

astog

Warlord
Joined
May 29, 2015
Messages
244
Location
Minneapolis
I understand , so what did you fulfill inside one of the tabs or tables >?
:)
The code posted here is an example code to make buttons. Since they are demo buttons, they do nothing more than print console commands, but you can easily change code around to make it show/hide your own screens. I used this code also to create Reports Screen button for CQUI.
 

thecraftybee

Warlord
Joined
Jan 10, 2015
Messages
235
Could this be used to make Rule With Faith compatible with CQUI? RWF adds a new Great Person to the GP screen, but it doesnt display properly on CQUI. Could this be used to open a second GP screen with the new Great Theologian?
 

astog

Warlord
Joined
May 29, 2015
Messages
244
Location
Minneapolis
Could this be used to make Rule With Faith compatible with CQUI? RWF adds a new Great Person to the GP screen, but it doesnt display properly on CQUI. Could this be used to open a second GP screen with the new Great Theologian?
Yes, JFD would need to write the code for it though.
 
Last edited:
Top Bottom