Skip to content

Commit

Permalink
Beta 9
Browse files Browse the repository at this point in the history
Fixed gear forge shift-clicking, adds better droid hover box, and allows runtime GadgetCore config changes.
  • Loading branch information
SuperKael committed Sep 6, 2020
1 parent 469e16c commit 7653676
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 35 deletions.
6 changes: 5 additions & 1 deletion API/ConfigMenu/INIGadgetConfigMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,11 @@ public override void Update()
{
base.Update();
IniParser.WriteFile(ConfigFilePath, Ini);
GadgetCore.CoreLogger.LogConsole("Reloading Config: " + ConfigFileSection);
if (ConfigFileSection == "GadgetCore")
{
GadgetCoreConfig.Load();
GadgetCore.CoreLogger.Log("Finished reloading config.");
}
if (autoReload != null)
{
if (autoReload.Name == ConfigFileSection)
Expand Down
2 changes: 1 addition & 1 deletion API/GadgetCoreAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static class GadgetCoreAPI
/// <summary>
/// A slightly more informative version. You generally shouldn't access this directly, instead use <see cref="GetFullVersion()"/>
/// </summary>
public const string FULL_VERSION = "2.0.0.0-BETA8";
public const string FULL_VERSION = "2.0.0.0-BETA9";
/// <summary>
/// Indicates whether this version of GadgetCore is a beta version. You generally shouldn't access this directly, instead use <see cref="GetIsBeta()"/>
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions GadgetCoreConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public static class GadgetCoreConfig
internal static Dictionary<string, bool> enabledMods = new Dictionary<string, bool>();
internal static Dictionary<string, bool> enabledGadgets = new Dictionary<string, bool>();

/// <summary>
/// Whether to use the standard hover box for droids, rather than the text-based description.
/// </summary>
public static bool BetterDroidHover { get; private set; } = true;
/// <summary>
/// The maximum connections allowed when hosting a game. This value is irrelevant if we are the client, not the host.
/// </summary>
Expand Down Expand Up @@ -58,6 +62,7 @@ internal static void Load()
cfg.WriteString("ConfigVersion", configVersion, comments: "The Config Version (not to be confused with mod version)");
}

BetterDroidHover = cfg.ReadBool("BetterDroidHover", true, false, false, "Whether to use the standard hover box for droids, rather than the text-based description.");
MaxConnections = cfg.ReadInt("MaxConnections", 4, 4, false, 1, int.MaxValue, "The maximum number of connections allowed when using host-and-play. This setting only matters on the host.");
UseUPnP = cfg.ReadBool("UseUPnP", false, false, false, "If True, will attempt to use UPnP to bypass the need to port-forward to host-and-play over the internet. Not all routers support this. Disabled by default due to severe unresolved bugs that prevent the game from working at all sometimes.");
GadgetNetwork.MatrixTimeout = cfg.ReadFloat("NetworkTimeout", 2.5f, comments: "How long to wait for the host's game to respond to Gadget Core's ID synchronization. If the host's game does not respond in time, it will be assumed that the host does not have Gadget Core installed.");
Expand Down
1 change: 1 addition & 0 deletions ModMenuController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ public void UpdateInfo(Toggle toggle, int modIndex, int gadgetIndex = -1)
{
["Name"] = mod.Attribute.Name,
["Version"] = mod.Mod.Version.ToString(),
["Required On Clients"] = mod.Attribute.RequiredOnClients ? "Yes" : "No",
["Dependencies"] = mod.Attribute.Dependencies.Length > 0 ? mod.Attribute.Dependencies.Aggregate(new StringBuilder(), (a, b) => { if (a.Length == 0) a.Append(", "); a.Append(b); return a; }).ToString() : "None"
};
foreach (KeyValuePair<string, string> info in gadgetInfo)
Expand Down
106 changes: 77 additions & 29 deletions PatchMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,27 @@ public static void HoverItem(Item item)
ItemType type = ItemRegistry.GetTypeByID(id);
if ((type & ItemType.EQUIPABLE) == ItemType.EQUIPABLE)
{
if ((type & ItemType.MODABLE) == ItemType.MODABLE)
if ((type & ItemType.LEVELING) == ItemType.LEVELING)
{
InstanceTracker.GameScript.itemexpbar.SetActive(true);
float[] itemLevel = GetItemLevel2.Invoke(InstanceTracker.GameScript, new object[] { item.exp }) as float[];
int num = (int)itemLevel[0];
InstanceTracker.GameScript.itemexpbar.transform.localScale = new Vector3(itemLevel[1], 0.015f, 1f);
if (num < 10)
{
InstanceTracker.GameScript.itemLevel.text = "Lv." + num;
}
else
{
InstanceTracker.GameScript.itemLevel.text = "MAX";
}
}
else
{
InstanceTracker.GameScript.itemexpbar.SetActive(false);
}
if ((type & ItemType.MODABLE) == ItemType.MODABLE)
{
if (item.tier == 0)
{
InstanceTracker.GameScript.itemName.color = Color.white;
Expand All @@ -58,17 +76,6 @@ public static void HoverItem(Item item)
}
InstanceTracker.GameScript.hoverItem.GetComponent<Renderer>().material = InstanceTracker.GameScript.hoverItemMat2;
InstanceTracker.GameScript.itemDesc.text = string.Empty;
float[] itemLevel2 = GetItemLevel2.Invoke(InstanceTracker.GameScript, new object[] { item.exp }) as float[];
int num2 = (int)itemLevel2[0];
InstanceTracker.GameScript.itemexpbar.transform.localScale = new Vector3(itemLevel2[1], 0.015f, 1f);
if (num2 < 10)
{
InstanceTracker.GameScript.itemLevel.text = "Lv." + num2;
}
else
{
InstanceTracker.GameScript.itemLevel.text = "MAX";
}
for (int i = 0; i < 3; i++)
{
if (item.aspectLvl[i] > 0)
Expand Down Expand Up @@ -106,28 +113,69 @@ public static void HoverItem(Item item)
}
else
{
InstanceTracker.GameScript.itemexpbar.SetActive(true);
InstanceTracker.GameScript.itemName.color = Color.white;
InstanceTracker.GameScript.hoverItem.GetComponent<Renderer>().material = InstanceTracker.GameScript.hoverItemMat1;
float[] itemLevel = GetItemLevel2.Invoke(InstanceTracker.GameScript, new object[] { item.exp }) as float[];
int num = (int)itemLevel[0];
InstanceTracker.GameScript.itemexpbar.transform.localScale = new Vector3(itemLevel[1], 0.015f, 1f);
if (num < 10)
if (GadgetCoreConfig.BetterDroidHover)
{
InstanceTracker.GameScript.itemLevel.text = "Lv." + num;
if (item.tier == 0)
{
InstanceTracker.GameScript.itemName.color = Color.white;
}
else if (item.tier == 1)
{
InstanceTracker.GameScript.itemName.color = Color.cyan;
}
else if (item.tier == 2)
{
InstanceTracker.GameScript.itemName.color = Color.magenta;
}
else if (item.tier == 3)
{
InstanceTracker.GameScript.itemName.color = Color.yellow;
}
InstanceTracker.GameScript.hoverItem.GetComponent<Renderer>().material = InstanceTracker.GameScript.hoverItemMat2;
InstanceTracker.GameScript.itemDesc.text = string.Empty;
for (int i = 0; i < 3; i++)
{
InstanceTracker.GameScript.aspectObj[i].SetActive(false);
}
InstanceTracker.GameScript.itemAspect[0].text = "";
InstanceTracker.GameScript.itemAspect[1].text = "NOT MODABLE";
InstanceTracker.GameScript.itemAspect[2].text = "";
int[] gearStats = GadgetCoreAPI.GetGearStats(item).GetStatArray();
for (int i = 0; i < 6; i++)
{
if (gearStats[i] > 0)
{
InstanceTracker.GameScript.itemStat[i].text = "+" + gearStats[i];
if (InstanceTracker.GameScript.itemStat[i].text.Length > 4)
{
InstanceTracker.GameScript.itemStat[i].characterSize = 4f / InstanceTracker.GameScript.itemStat[i].text.Length;
}
else
{
InstanceTracker.GameScript.itemStat[i].characterSize = 1;
}
}
else
{
InstanceTracker.GameScript.itemStat[i].text = string.Empty;
InstanceTracker.GameScript.itemStat[i].characterSize = 1;
}
}
InstanceTracker.GameScript.txtStats.SetActive(true);
}
else
{
InstanceTracker.GameScript.itemLevel.text = "MAX";
InstanceTracker.GameScript.itemName.color = Color.white;
InstanceTracker.GameScript.hoverItem.GetComponent<Renderer>().material = InstanceTracker.GameScript.hoverItemMat1;
InstanceTracker.GameScript.itemAspect[0].text = string.Empty;
InstanceTracker.GameScript.itemAspect[1].text = string.Empty;
InstanceTracker.GameScript.itemAspect[2].text = string.Empty;
InstanceTracker.GameScript.txtStats.SetActive(false);
InstanceTracker.GameScript.aspectObj[0].SetActive(false);
InstanceTracker.GameScript.aspectObj[1].SetActive(false);
InstanceTracker.GameScript.aspectObj[2].SetActive(false);
InstanceTracker.GameScript.itemDesc.text = GadgetCoreAPI.GetItemDesc(id);
}
InstanceTracker.GameScript.itemAspect[0].text = string.Empty;
InstanceTracker.GameScript.itemAspect[1].text = string.Empty;
InstanceTracker.GameScript.itemAspect[2].text = string.Empty;
InstanceTracker.GameScript.txtStats.SetActive(false);
InstanceTracker.GameScript.aspectObj[0].SetActive(false);
InstanceTracker.GameScript.aspectObj[1].SetActive(false);
InstanceTracker.GameScript.aspectObj[2].SetActive(false);
InstanceTracker.GameScript.itemDesc.text = GadgetCoreAPI.GetItemDesc(id);
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion Patches/Patch_GameScript_GetItemWorth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static bool Prefix(GameScript __instance, int id, ref int __result)
{
if (ItemRegistry.GetSingleton().HasEntry(id))
{
__result = ItemRegistry.GetSingleton().GetEntry(id).Value;
__result = ItemRegistry.GetSingleton().GetEntry(id).GetValue();
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion Patches/Patch_GameScript_ShiftClick2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static bool Prefix(GameScript __instance, ref bool ___shiftclicking, Item
int num = 0;
if (___craftType == 0)
{
if (slotItemType == ItemType.EMBLEM)
if ((slotItemType & ItemType.BASIC_MASK) == ItemType.EMBLEM)
{
for (int i = 0; i < 3; i++)
{
Expand Down
Binary file modified Release/GadgetCore.dll
Binary file not shown.
5 changes: 5 additions & 0 deletions Release/GadgetCore.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Release/GadgetCore.zip
Binary file not shown.
3 changes: 1 addition & 2 deletions TemplateGadgetMod/TemplateGadgetMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@
</GetFileVersion>
<ItemGroup>
<OldZip Include="$(TargetDir)$(AssemblyName)_v*.zip" />
<OldDest Include="$(GamePath)GadgetCore\Mods\$(AssemblyName)_v*.zip" />
<OldZip Include="$(GamePath)GadgetCore\Mods\$(AssemblyName)_v*.zip" />
</ItemGroup>
<Delete Files="@(OldZip)" />
<Delete Files="@(OldDest)" />
<MakeDir Directories="$(TargetDir)..\BuildCache\" />
<ZipDirectory SourceDirectory="$(TargetDir)" DestinationFile="$(TargetDir)..\BuildCache\$(AssemblyName)_v$(AssemblyFileVersion).zip" />
<Copy SourceFiles="$(TargetDir)..\BuildCache\$(AssemblyName)_v$(AssemblyFileVersion).zip" DestinationFiles="$(TargetDir)$(AssemblyName)_v$(AssemblyFileVersion).zip" />
Expand Down

0 comments on commit 7653676

Please sign in to comment.