Skip to content

Commit

Permalink
Updates for Hildir's Request
Browse files Browse the repository at this point in the history
Fix ambiguous function patches, /listportals, font creation and drawing, etc.
  • Loading branch information
zambony committed Aug 31, 2023
1 parent d2915c1 commit ecb04b9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 22 deletions.
25 changes: 13 additions & 12 deletions src/CommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -627,20 +627,21 @@ public void ListPortals()

HashSet<string> tagSet = new HashSet<string>();

int portalHash = Game.instance.m_portalPrefab.name.GetStableHashCode();

var query =
from pair in ZDOMan.instance.GetPrivateField<Dictionary<ZDOID, ZDO>>("m_objectsByID")
let tag = pair.Value.GetString("tag", null)
where pair.Value.GetPrefab() == portalHash && !string.IsNullOrEmpty(tag) && tag != " "
select pair.Value;

foreach (ZDO zdo in query)
foreach (int portalHash in Game.instance.PortalPrefabHash)
{
string tag = zdo.GetString("tag", null);
var query =
from pair in ZDOMan.instance.GetPrivateField<Dictionary<ZDOID, ZDO>>("m_objectsByID")
let tag = pair.Value.GetString("tag", null)
where pair.Value.GetPrefab() == portalHash && !string.IsNullOrEmpty(tag) && tag != " "
select pair.Value;

if (!tagSet.Contains(tag))
tagSet.Add(tag);
foreach (ZDO zdo in query)
{
string tag = zdo.GetString("tag", null);

if (!tagSet.Contains(tag))
tagSet.Add(tag);
}
}

Logger.Log($"Found {tagSet.Count.ToString().WithColor(Logger.GoodColor)} tag(s)...", true);
Expand Down
30 changes: 23 additions & 7 deletions src/CustomConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal class CustomConsole : MonoBehaviour
private const int s_historyEntryMargin = 10;
private static Color s_backgroundColor = new Color32(42, 47, 58, 165);
private GUIStyle m_consoleStyle = new GUIStyle();
private Font m_font = Font.CreateDynamicFontFromOSFont("Consolas", s_fontSize);

// History-related values.
private List<string> m_history = new List<string>();
Expand Down Expand Up @@ -107,10 +108,22 @@ private void Start()
/// </summary>
private void CreateStyle()
{
Font font = Font.CreateDynamicFontFromOSFont("Consolas", s_fontSize);
string[] fontPaths = Font.GetPathsToOSFonts();
string consolaPath = "Consolas";

// Locate the Consolas font, because TextMeshPro needs a path.
foreach (var path in fontPaths)
{
if (path.IndexOf("consola.ttf", StringComparison.OrdinalIgnoreCase) != -1)
{
consolaPath = path;
break;
}
}

m_consoleStyle.wordWrap = true;
m_consoleStyle.fontSize = font.fontSize;
m_consoleStyle.font = font;
m_consoleStyle.fontSize = s_fontSize;
m_consoleStyle.font = m_font;
m_consoleStyle.normal.textColor = Color.white;
m_consoleStyle.richText = true;
m_consoleStyle.alignment = TextAnchor.UpperLeft;
Expand All @@ -137,12 +150,15 @@ private void CreateStyle()
background.color = s_backgroundColor;
}

var textMeshProFont = TMP_FontAsset.CreateFontAsset(font);
Font osFont = new Font(consolaPath);
var textMeshProFont = TMP_FontAsset.CreateFontAsset(osFont);
Console.instance.m_output.font = textMeshProFont;
Console.instance.m_output.fontSize = font.fontSize;
Console.instance.m_input.textComponent.font = textMeshProFont;

Console.instance.m_output.fontSize = m_font.fontSize;
Console.instance.m_output.color = Color.white;
Console.instance.m_input.textComponent.font = font;
Console.instance.m_input.textComponent.fontSize = font.fontSize;

Console.instance.m_input.textComponent.fontSize = m_font.fontSize;
Console.instance.m_input.caretColor = Color.white;
Console.instance.m_input.customCaretColor = true;

Expand Down
2 changes: 1 addition & 1 deletion src/Gungnir.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Gungnir : BaseUnityPlugin
public const string ModName = "Gungnir";
public const string ModOrg = "zamboni";
public const string ModGUID = ModOrg + "." + ModName;
public const string ModVersion = "1.7.2";
public const string ModVersion = "1.7.3";

private readonly Harmony m_harmony = new Harmony(ModGUID);
private CommandHandler m_handler = new CommandHandler();
Expand Down
4 changes: 2 additions & 2 deletions src/PatchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ private static bool Prefix(ref float __result, ref ZNetView ___m_nview)
return true;
}
}
[HarmonyPatch(typeof(Player), "UpdateStats")]

[HarmonyPatch(typeof(Player), "UpdateStats", new System.Type[] { typeof(float) })]
public static class UpdateStatsEitrPatch
{
private static void Postfix(ref ZNetView ___m_nview, ref float ___m_eitr)
Expand Down

0 comments on commit ecb04b9

Please sign in to comment.