Modular Screens 屏幕模塊化

作者 astog·版本 v1.0·更新於 2018-10-01

Modular Screens 屏幕模塊化

模組介紹 作者原文

Modular Screens 屏幕模塊化

允許修改者安全地添加啓動欄按鈕和部分連接等

概觀

版本歷史

討論

這是什麼?

簡而言之,這是一個mod,允許其他模塊添加按鈕到啓動欄(左上角),屏幕掛鉤(右上角),而無需覆蓋基本遊戲UI文件。如果modder需要,它還會添加一個下拉以添加額外的按鈕。

爲什麼用這個?

由於這允許modders不會覆蓋相同的基本UI文件,因此更多的mod將彼此兼容,並允許他們以更加理智的方式向遊戲添加屏幕。

怎麼用?

對於mod用戶,這需要與其他mod相同的安裝。如果您是一個modder,並且想要添加按鈕,請閱讀下面的信息,以獲取可以添加按鈕的三個主要位置。

啓動Bar Extras List

我爲不需要圖標的菜單添加了列表。我用列表切換替換了世界構建器的show / hide。這可能是添加按鈕最簡單的地方。以下是一個例子:

碼:

LuaEvents.LaunchBar_AddExtra(“Button1”,extraButton);

第一個參數是鍵(防止重複按鈕),第二個參數是表:

碼:

local extraButton:table = {

Text =“Test1”;  - 要在按鈕中顯示的文本

回調=開放;  - 單擊按鈕時調用的功能

Tooltip =“test1”;  - 如果爲nil,則禁用工具提示}

啓動欄

這些是世界規劃師上方的圖標,包括Tech,Civic tree按鈕等。要添加圖標,請致電:

碼:

LuaEvents.LaunchBar_AddIcon(buttonInfo);

buttonInfo的一個示例,它添加了下面的武士按鈕:

碼:

textureOffsetX,textureOffsetY,textureSheet = IconManager:FindIconAtlas(“ICON_UNIT_JAPANESE_SAMURAI”,38);

local button2Info = {

  • 圖標紋理

IconTexture = {

OffsetX = textureOffsetX;

OffsetY = textureOffsetY + 3;

Sheet = textureSheet;

Color = UI.GetColorValue(“COLOR_PLAYER_BARBARIAN_PRIMARY”);

};

  • 基礎紋理(將其視爲按鈕紋理)

BaseTexture = {

OffsetX = 0;

偏移Y = 147;

Sheet =“LaunchBar_Hook_GreatPeopleButton”;

  • Color = UI.GetColorValue(“COLOR_BLUE”);

HoverOffsetX = 0;

HoverOffsetY = 0;

};

  • 按鈕信息

Callback = function()print(“ATTACK!”)結束;

  • 工具提示=“倒鉤......”;

}

部分屏幕掛鉤這些是屏幕

的右上角,包括交易概覽,世界得分等等。添加到這些的方法類似於Launch Bar按鈕。

碼:

LuaEvents.PartialScreenHooks_AddHook(hookInfo1);

表結構與啓動欄中使用的表結構相同。

碼:

本地hookInfo1:table = {

  • 圖標紋理

IconTexture = {

OffsetX = 0;

偏移Y = 0;

Sheet =“MapPins24.dds”;

Color = UI.GetColorValue(“COLOR_PLAYER_GOLDENROD”)

};

  • 按鈕紋理

BaseTexture = {

OffsetX = 0;

偏移Y = 0;

Sheet =“LaunchBar_Hook_ButtonSmall”;

  • 懸停時的偏移量

HoverOffsetX = 0;

HoverOffsetY = 40;

};

Callback = function()print(“Damascus steel!”)結束;

Tooltip =“ATTACK!”;

};

使用說明

所有LuaEvents應該不會在初始化被稱爲(),因爲這將使它的加載順序依賴。而是在這個事件中調用它:

碼:

Events.LoadScreenClose

其他用法示例可以在launchbar.lua和partialscreenhooks.lua的底部看到。

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 = "LaunchB …

安裝與使用 安裝:按包內說明操作

  1. 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
  2. 這類遊戲沒有通用的模組管理器:有的模組直接替換遊戲檔案、有的放進遊戲專屬的 Mods 資料夾、有的要先裝遊戲對應的社群載入器或工具,以包內說明為準。
  3. 嚴格按說明放置檔案;標註「前置依賴」的模組需要把依賴一併裝好。
  4. 啟動遊戲確認載入成功;部分遊戲需要在設定或模組選單裡手動啟用。

不同遊戲、不同模組的安裝位置差異很大,包內說明是最可靠的依據。

檔案與校驗

檔案名稱
Modular Screens 屏幕模块化
檔案大小
20.6 KiB