Menu Variants is now compatible with Fortrise new version! - #16
Conversation
Terria-K
left a comment
There was a problem hiding this comment.
I request a small changes on changing the obsolete signature that will be removed next major version. The path concatenation with _separator could be replaced with Path.Combine instead.
| Console.WriteLine(text); | ||
| var text2 = text.Replace("Content" + _separator, ""); | ||
| Atlas atlas = new Atlas(text2 + _separator + "atlas.xml", text2 + _separator + "atlas.png", true); | ||
| Atlas atlas = AtlasExt.CreateAtlas(content, text2 + _separator + "atlas.xml", text2 + _separator + "atlas.png", true, ContentAccess.Content); |
There was a problem hiding this comment.
you should remove the 4th argument since this signature is obsolete and will be removed in 5.0
| Atlas atlas = new Atlas(text2 + _separator + "atlas.xml", text2 + _separator + "atlas.png", true); | ||
| var LogoData = Calc.LoadXML(text + _separator + "LogoData.xml"); | ||
| Console.WriteLine(customLogoPath); | ||
| Atlas atlas = AtlasExt.CreateAtlas(content, customLogoPath + _separator + "atlas.xml", customLogoPath + _separator + "atlas.png", true, ContentAccess.Root); |
There was a problem hiding this comment.
This one as well is using the obsolete signature
|
Hi @Terria-K, Thank you for the feedback! I've followed your instructions and updated the code to use Path.Combine for creating the custom assets path. Additionally, I have changed the CreateAtlas method to use the non-obsolete signature as recommended. I also made several corrections to some mistakes I had made and renamed the main module class to something more appropriate, rather than leaving it as ExampleModModule. One concern I had was the hardcoding of the mod's folder name. I wanted to avoid assuming that players will always use the same folder name. Is there a way to dynamically retrieve the mod folder name, perhaps via ContentAccess.ModContent or another method? Any guidance here would be greatly appreciated!
|
|
There's a way to do this if you want to look inside of the mod content itself which uses
Basic usage would be like: private static readonly string CUSTOM_LOGOS_DIR = Path.Combine("Content", "CustomLogos" );
/* inside of LoadContent */
string anotherPath = Path.Combine(CUSTOM_LOGOS_DIR, "path/to/file").Replace('\\'. '/');
using Stream stream = Content[anotherPath].Stream;
// Do someting with the streamThe
If you need to iterate all files from a directory, you need to lookup a directory from a |
lynconEBB
left a comment
There was a problem hiding this comment.
I believe I have completed all the changes I intended, and the code is now stable and ready for a new release. If you encounter any issues, please let me know, and I will address them.
| { | ||
| Atlas atlas = AtlasExt.CreateAtlas(content, Path.Combine(customBezelPath, "atlas.xml"), Path.Combine(customBezelPath,"atlas.png")); | ||
| var BezelData = Calc.LoadXML(Path.Combine(customBezelPath, "BezelData.xml")); | ||
| Atlas atlas = AtlasExt.CreateAtlas(content, $"{resource.Path}/atlas.xml", $"{resource.Path}/atlas.png", ContentAccess.ModContent); |
There was a problem hiding this comment.
Loading based on Mod Content Folder concatenating string with $, i also needed to get the logo xml resource and then then load the XML, i think its better then using a path from root
| { | ||
| public static void MyLoad() | ||
| { | ||
| if (MenuVariantModModule.Settings.BezelVariant > 0 && !BezelLoad.BezelList.Any()) |
There was a problem hiding this comment.
Put this check so that when the configuration is set to use a custom logo, if on the next start this custom bezel is not present it will use the default one (user can delete the custom bezel folder and it dont crash)
| var towerTarget = LogoData.Get<Vector2>("towerTarget"); | ||
| var coreTarget = LogoData.Get<Vector2>("towerTarget"); | ||
|
|
||
| if (MenuVariantModModule.Settings.MenuVariant >= MenuVariantModModule.Vanilla.Count) |
There was a problem hiding this comment.
Same thing for logos
| <NoWarn>1701;1702;0104;1061;0246;0118;0123</NoWarn> | ||
| <WarningLevel>0</WarningLevel> | ||
| <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
| <OutputPath>..\Towerfall - Ascension\Mods\MenuVariantsMod\</OutputPath> |
There was a problem hiding this comment.
For simplicity, output in the mod base folder; Fortrise ONLY loads from the Towerfall\Mods folder.
Add credits
|
Merged! A later update will be added for more QOL features and customization options. |
This pull request fixes issue #6
Updated Atlas Creation:
I Replaced the deprecated new Atlas() with the recommended AtlasExt.CreateAtlas() method to ensure compatibility with the latest system architecture.
Improved Logo and Bezel Loading:
Modified the logo and bezel loading process so that assets no longer need to be placed in the root Content folder. Instead, logos and bezels can now be stored directly within the Mod's Content folder for better organization and modularity.
Enhanced Mod Settings Menu:
Updated the Mod Settings menu to utilize the new CreateModSettings(TextContainer textContainer) hook, allowing players to change logos and bezels in real-time without the need to restart the game.
Let me know if you need any clarification or further adjustments. I’m happy to assist with any questions or issues that may arise.