gurrenm3 / BTD-Mod-Helper

A powerful and easy to use API for modding BTD6, BATTD, and other Ninja Kiwi games.
https://gurrenm3.github.io/BTD-Mod-Helper/
GNU General Public License v3.0
175 stars 119 forks source link

Add GetBtd6Localization to StringExt.cs #253

Closed DarkTerraYT closed 2 months ago

DarkTerraYT commented 2 months ago

Example usage:

                ModHelperPanel mainPanel = InGame.instance.uiRect.gameObject.AddModHelperPanel(new("MainPanel", 1200, 750), VanillaSprites.MainBGPanelBlue);

                mainPanel.AddText(new("Title", 0, 225, 1200, 200), "Towers");

                List<string> towerDisplayNames = [];
                List<string> towerBaseIds = [];

                foreach (var towerModel in Game.instance.model.towers.ToList().FindAll(t => t.baseId == t.name))
                {
                    towerDisplayNames.Add(towerModel.baseId.GetBtd6Localization());
                    towerBaseIds.Add(towerModel.baseId);
                }

                mainPanel.AddDropdown(new("Dropdown", 0, -75, 850, 400), towerBaseIds.ToIl2CppList(), 1200, new Action<int>(index =>
                {
                    ModHelper.Log<BloonsTD6Mod>($"{towerBaseIds[index]}: {towerDisplayNames[index]}"); //Log the base id compared to the display name
                }));

This can also help with getting the display names of named mod content when not having access to the mod content