diff --git a/mods/ReUI.GW/Main.lua b/mods/ReUI.GW/Main.lua new file mode 100644 index 000000000..4aa9573c3 --- /dev/null +++ b/mods/ReUI.GW/Main.lua @@ -0,0 +1,47 @@ +ReUI.Require +{ + "ReUI.Core >= 1.5.0", + "ReUI.Options >= 1.0.0" +} + +function Main(isReplay) + + local function IsGalacticWar() + if not exists('/lua/ui/gw/ranks.lua') then + return false + end + local ok, module = pcall(import, '/lua/ui/gw/ranks.lua') + if not ok then + return false + end + + return true + end + + if not IsGalacticWar() then + return + end + + local options = ReUI.Options.Mods["ReUI.GW"] + + local Score = ReUI.Exists "ReUI.Score < 1.3.0" --[[@as ReUI.Score?]] + if Score then + local Ranks = import("/lua/ui/gw/ranks.lua") + local data = import("/mods/ReUI.Score/Modules/Utils.lua").GetArmiesFormattedTable() + local sessionInfo = SessionGetScenarioInfo() + local ranks = sessionInfo.Options.Ranks + + + for _, army in ipairs(data) do + local nickname = army.nickname + local rank = ranks[nickname] or 1 + army.rating = rank + local rankName = Ranks.GetRankName(army.faction, rank) + if rankName and options.displayRankNames() then + army.name = ("[%s] %s"):format(rankName, nickname) + end + end + + end + +end diff --git a/mods/ReUI.GW/ModuleMeta.lua b/mods/ReUI.GW/ModuleMeta.lua new file mode 100644 index 000000000..52908eec0 --- /dev/null +++ b/mods/ReUI.GW/ModuleMeta.lua @@ -0,0 +1,6 @@ +---@meta + + +---@class ReUI.GW : ReUI.Module +ReUI.GW = {} + diff --git a/mods/ReUI.GW/Options.lua b/mods/ReUI.GW/Options.lua new file mode 100644 index 000000000..9a458d10e --- /dev/null +++ b/mods/ReUI.GW/Options.lua @@ -0,0 +1,14 @@ +local Opt = ReUI.Options.Opt +ReUI.Options.Mods["ReUI.GW"] = { + displayRankNames = Opt(true), +} + +function Main(isReplay) + local Options = ReUI.Options.Builder + local options = ReUI.Options.Mods["ReUI.GW"] + + Options.AddOptions("ReUI.GW", "ReUI.GW", { + Options.Filter("Display rank names", options.displayRankNames, 4), + }) + +end diff --git a/mods/ReUI.GW/mod_info.lua b/mods/ReUI.GW/mod_info.lua new file mode 100644 index 000000000..0c747c2a9 --- /dev/null +++ b/mods/ReUI.GW/mod_info.lua @@ -0,0 +1,22 @@ +name = "ReUI.GW" +uid = "reui-gw-1.0.0" +version = 1 +copyright = "" +description = [[Check on Github and official Discord server for mode details. +https://github.com/4z0t/FAF-UI-Mods +https://discord.gg/UZeAEXHV +]] +author = "4z0t" +icon = "/mods/ReUI.GW/icon.png" +url = "https://github.com/4z0t/FAF-UI-Mods" +selectable = true +enabled = true +exclusive = false +ui_only = true +requires = {} +requiresNames = {} +conflicts = {} +before = {} +after = {} + +ReUI = 'ReUI.GW=1.0.0'