1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Modular Screens 1.0

Allows modders to safely add launchbar buttons and partial hookups, etc

  1. astog

    astog Warlord

    Joined:
    May 29, 2015
    Messages:
    238
    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: Jul 23, 2017
    Atlas627 and Ewok-Bacon-Bits like this.
  2. Golan v

    Golan v Warlord

    Joined:
    Oct 31, 2016
    Messages:
    160
    Gender:
    Male
    Location:
    Israel
    Looks great .. is it finish i didnt get it?
     
  3. astog

    astog Warlord

    Joined:
    May 29, 2015
    Messages:
    238
    Location:
    Minneapolis
    Yes, this is ready. This is a modders resource, so it requires other mods to use this in future.
     
  4. Golan v

    Golan v Warlord

    Joined:
    Oct 31, 2016
    Messages:
    160
    Gender:
    Male
    Location:
    Israel
    I understand , so what did you fulfill inside one of the tabs or tables >?
    :)
     
  5. astog

    astog Warlord

    Joined:
    May 29, 2015
    Messages:
    238
    Location:
    Minneapolis
    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.
     
  6. thecraftybee

    thecraftybee Warlord

    Joined:
    Jan 10, 2015
    Messages:
    229
    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?
     
  7. astog

    astog Warlord

    Joined:
    May 29, 2015
    Messages:
    238
    Location:
    Minneapolis
    Yes, JFD would need to write the code for it though.
     
    Last edited: Aug 1, 2017
  8. pipi0404

    pipi0404 Chieftain

    Joined:
    Sep 22, 2016
    Messages:
    5

Share This Page