Resource icon

Modular Screens 1.0

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.
Author
astog
Downloads
324
Views
331
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from astog

Top Bottom