Skip to content

Commit

Permalink
updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesenibbles123 committed Dec 24, 2020
1 parent cafcdcc commit 69017eb
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion customEliteBadges/mainClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,36 @@ void Start()
harmony.PatchAll();
initMod();
}
void setMainmenu()
{
MainMenu mm = FindObjectOfType<MainMenu>();

try
{
int.TryParse(mm.mainMenuPres.ToString(), out int prestige);
log(prestige.ToString());
if (prestige >= 10)
{
int.TryParse(mm.mainMenuLevel.ToString(), out int level);
log(level.ToString());
int index = ~levels.BinarySearch(level);
if (customBadges.TryGetValue(levels[index - 1], out Texture2D newBadgeTexture))
{
if (newBadgeTexture.name != "NOTFOUND")
{
mm.menuBadge.texture = newBadgeTexture;
}
}
return;

}
}
catch (Exception e)
{
log("Failed to assign custom badge to a player in main menu");
log(e.Message);
}
}
void initMod()
{
if (File.Exists(Application.dataPath + "/Managed/Mods/customBadges.txt"))
Expand All @@ -65,6 +94,7 @@ void initMod()
{
createConfig();
}
setMainmenu();
}

void createConfig()
Expand All @@ -75,9 +105,10 @@ void createConfig()
}
if (!File.Exists(Application.dataPath + "/Managed/Mods/customBadges.txt"))
{
string[] lines = { "100=silver", "250=default", "500=diamond" };
string[] lines = { "100=silver", "250=eyes", "500=diamond" };
File.WriteAllLines(Application.dataPath + "/Managed/Mods/customBadges.txt", lines);
}
initMod();
}

static Texture2D loadTexture(string texName, int imgWidth, int imgHeight)
Expand Down

0 comments on commit 69017eb

Please sign in to comment.