Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu Variants is now compatible with Fortrise new version! #16

Merged
merged 4 commits into from
Jan 11, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Loading everything based on ModContent folder
  • Loading branch information
lynconEBB committed Jan 10, 2025
commit 183b2756859fca0a8bec190455c6f7b3518a6ba0
15 changes: 9 additions & 6 deletions MenuVariantsMod/BezelLoad.cs
Original file line number Diff line number Diff line change
@@ -9,16 +9,19 @@ public class BezelLoad
public static List<CustomBezel> BezelList = new();
public static List<string> BezelNames = new();

private static readonly string CUSTOM_BEZELS_DIR = Path.Combine("Mods", "MenuVariantsMod", "Content", "CustomBezels");
private static readonly string CUSTOM_BEZELS_DIR ="Content/CustomBezels";

public static void Load(FortContent content) {
string[] directories = Directory.GetDirectories(CUSTOM_BEZELS_DIR);
public static void Load(FortContent content)
{
BezelNames.Add("DEFAULT");
BezelList = new List<CustomBezel>();
foreach (string customBezelPath in directories)

foreach (RiseCore.Resource resource in content[CUSTOM_BEZELS_DIR].Childrens)
{
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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


RiseCore.Resource bezelDataResource = content[$"{resource.Path}/BezelData.xml"];
var BezelData = Calc.LoadXML(bezelDataResource.Stream);
var TrueBezelData = BezelData["BezelData"];
if (atlas == null)
{
17 changes: 10 additions & 7 deletions MenuVariantsMod/LogoLoad.cs
Original file line number Diff line number Diff line change
@@ -7,20 +7,23 @@ namespace MenuVariantsMod
public class LogoLoad
{
public static List<CustomLogo> LogoList;
private static readonly string CUSTOM_LOGOS_DIR = "Content/CustomLogos";

private static readonly string CUSTOM_LOGOS_DIR = Path.Combine("Mods", "MenuVariantsMod", "Content", "CustomLogos" );

public static void Load(FortContent content) {
public static void Load(FortContent content)
{
MenuVariantModModule.Vanilla = new List<bool>();
MenuVariantModModule.Vanilla.Add(true);
MenuVariantModModule.Vanilla.Add(true);

string[] directories = Directory.GetDirectories(CUSTOM_LOGOS_DIR);
LogoList = new List<CustomLogo>();
foreach (string customLogoPath in directories)
foreach (RiseCore.Resource resource in content[CUSTOM_LOGOS_DIR].Childrens)
{
Atlas atlas = AtlasExt.CreateAtlas(content, Path.Combine(customLogoPath,"atlas.xml" ), Path.Combine(customLogoPath,"atlas.png"));
var LogoData = Calc.LoadXML(Path.Combine(customLogoPath, "LogoData.xml") );
if (resource.Childrens == null)
continue;

Atlas atlas = AtlasExt.CreateAtlas(content, $"{resource.Path}/atlas.xml" , $"{resource.Path}/atlas.png", ContentAccess.ModContent);
RiseCore.Resource logoDataResource = content[$"{resource.Path}/LogoData.xml"];
var LogoData = Calc.LoadXML(logoDataResource.Stream);
var TrueLogoData = LogoData["LogoData"];

if (atlas == null)
7 changes: 3 additions & 4 deletions MenuVariantsMod/MenuVariantsModModule.cs
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ public class MenuVariantModModule : FortModule
public static MenuVariantModModule Instance;
public static List<bool> Vanilla;

public static List<string> MenuVariantNames = new List<string>();
public static List<string> MenuVariantNames = new();
public MenuVariantModModule()
{
Instance = this;
@@ -29,12 +29,11 @@ public override void Load()
On.TowerFall.Logo.ctor += MyLogo.ctor;
typeof(ModExports).ModInterop();
}

public override void LoadContent()
{
string customLogos = Path.Combine("Mods", "MenuVariantsMod", "Content", "CustomLogos");
string customLogos = Path.Combine("Mods", Content.MetadataPath.Replace("mod:", ""), "Content", "CustomLogos");
Directory.CreateDirectory(customLogos);
string customBezels = Path.Combine("Mods", "MenuVariantsMod", "Content", "CustomBezels");
string customBezels = Path.Combine("Mods", Content.MetadataPath.Replace("mod:", ""), "Content", "CustomBezels");
Directory.CreateDirectory(customBezels);

MenuVariantNames.Add("ASCENSION");
1 change: 0 additions & 1 deletion MenuVariantsMod/MenuVariantsModSettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Monocle;
using FortRise;
using TowerFall;

namespace MenuVariantsMod;

3 changes: 3 additions & 0 deletions MenuVariantsMod/MyBezel.cs
Original file line number Diff line number Diff line change
@@ -5,6 +5,9 @@ public class MyBezel
{
public static void MyLoad()
{
if (MenuVariantModModule.Settings.BezelVariant > 0 && !BezelLoad.BezelList.Any())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

MenuVariantModModule.Settings.BezelVariant = 0;

if (MenuVariantModModule.Settings.BezelVariant > 0)
{
var LoadedBezel = BezelLoad.BezelList[MenuVariantModModule.Settings.BezelVariant - 1];
6 changes: 5 additions & 1 deletion MenuVariantsMod/MyLogo.cs
Original file line number Diff line number Diff line change
@@ -37,6 +37,10 @@ public static void ctor(On.TowerFall.Logo.orig_ctor orig, Logo self)
self.RemoveAll();
var towerTarget = LogoData.Get<Vector2>("towerTarget");
var coreTarget = LogoData.Get<Vector2>("towerTarget");

if (MenuVariantModModule.Settings.MenuVariant >= MenuVariantModModule.Vanilla.Count)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing for logos

MenuVariantModModule.Settings.MenuVariant = 0;

if (MenuVariantsMod.MenuVariantModModule.Vanilla[MenuVariantModModule.Settings.MenuVariant])
{
if (MenuVariantModModule.Settings.MenuVariant == 0)
@@ -135,7 +139,7 @@ public static void ctor(On.TowerFall.Logo.orig_ctor orig, Logo self)
}
else
{
var LoadedLogo = LogoLoad.LogoList[MenuVariantModModule.Settings.MenuVariant-2];
var LoadedLogo = LogoLoad.LogoList[MenuVariantModModule.Settings.MenuVariant - 2];
var atlas = LoadedLogo.Atlas;
if (LoadedLogo.VanillaTitle)
{