Skip to content

Commit

Permalink
Merge pull request #45 from zambony/preview
Browse files Browse the repository at this point in the history
Patch for latest game changes
  • Loading branch information
zambony authored Mar 15, 2023
2 parents aea8ae9 + db71762 commit 64f6f63
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/CommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2055,6 +2055,10 @@ public static void Reset(Vector3 position, float radius)

compiler.InvokePrivate<object>("Save");
heightmap.Poke(true);

// Push new terrain data to all clients.
var zdo = compiler.GetComponent<ZNetView>().GetZDO();
ZDOMan.instance.ForceSendZDO(zdo.m_uid);
}

if (ClutterSystem.instance != null && resetGrass)
Expand Down
41 changes: 38 additions & 3 deletions src/CustomConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

Expand Down Expand Up @@ -136,7 +137,8 @@ private void CreateStyle()
background.color = s_backgroundColor;
}

Console.instance.m_output.font = font;
var textMeshProFont = TMP_FontAsset.CreateFontAsset(font);
Console.instance.m_output.font = textMeshProFont;
Console.instance.m_output.fontSize = font.fontSize;
Console.instance.m_output.color = Color.white;
Console.instance.m_input.textComponent.font = font;
Expand Down Expand Up @@ -334,9 +336,16 @@ private void OnGUI()
float height = m_consoleStyle.CalcHeight(content, contentSize.x);
const float margin = 10f;

GUITools.DrawRect(new Rect(m_windowRect.x - margin, m_background.rectTransform.rect.height + 30f, contentSize.x + (margin * 2), height + (margin * 2)), s_backgroundColor);
// Retrieve the absolute bounds of the image component since Unity SUCKS.
var corners = new Vector3[4];
m_background.rectTransform.GetWorldCorners(corners);
var bgRect = new Rect(corners[1].x, Screen.height - corners[1].y, corners[2].x - corners[1].x, corners[1].y - corners[0].y);

float tooltipY = bgRect.yMax + 30f;

GUITools.DrawRect(new Rect(m_windowRect.x - margin, tooltipY, contentSize.x + (margin * 2), height + (margin * 2)), s_backgroundColor);
GUI.Label(
new Rect(m_windowRect.x, m_background.rectTransform.rect.height + 30f + margin, m_windowRect.width, LineHeight * 2f),
new Rect(m_windowRect.x, tooltipY + margin, m_windowRect.width, LineHeight * 2f),
content,
m_consoleStyle
);
Expand Down Expand Up @@ -388,6 +397,32 @@ public static void DrawRect(Rect position, Color color, GUIContent content = nul
GUI.backgroundColor = backgroundColor;
}

public static void DrawCorners(Rect rect, float size, Color color, GUIContent content = null)
{
var backgroundColor = GUI.backgroundColor;
GUI.backgroundColor = color;

GUI.Box(new Rect(rect.xMin, rect.yMin, size, size), content ?? GUIContent.none, textureStyle);
GUI.Box(new Rect(rect.xMax - size, rect.yMin, size, size), content ?? GUIContent.none, textureStyle);
GUI.Box(new Rect(rect.xMin, rect.yMax - size, size, size), content ?? GUIContent.none, textureStyle);
GUI.Box(new Rect(rect.xMax - size, rect.yMax - size, size, size), content ?? GUIContent.none, textureStyle);

GUI.backgroundColor = backgroundColor;
}

public static void DrawCornersID(Rect rect, float size, Color color)
{
var backgroundColor = GUI.backgroundColor;
GUI.backgroundColor = color;

GUI.Box(new Rect(rect.xMin, rect.yMin, size, size), "1", textureStyle);
GUI.Box(new Rect(rect.xMax - size, rect.yMin, size, size), "2", textureStyle);
GUI.Box(new Rect(rect.xMin, rect.yMax - size, size, size), "3", textureStyle);
GUI.Box(new Rect(rect.xMax - size, rect.yMax - size, size, size), "4", textureStyle);

GUI.backgroundColor = backgroundColor;
}

public static void LayoutBox(Color color, GUIContent content = null)
{
var backgroundColor = GUI.backgroundColor;
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.0";
public const string ModVersion = "1.7.1";

private readonly Harmony m_harmony = new Harmony(ModGUID);
private CommandHandler m_handler = new CommandHandler();
Expand Down
4 changes: 2 additions & 2 deletions src/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static Player GetPlayerByName(string name, bool noThrow = false)
{
var query =
from player in Player.GetAllPlayers()
where player.GetPlayerName().Simplified().StartsWith(name.ToLower(), StringComparison.OrdinalIgnoreCase)
where player.GetPlayerName().Simplified().StartsWith(name, StringComparison.OrdinalIgnoreCase)
select player;

if (query.Count() > 1)
Expand All @@ -162,7 +162,7 @@ where player.GetPlayerName().Simplified().StartsWith(name.ToLower(), StringCompa
// to find the exact match. If there's no exact match, the intent is unclear and we shouldn't process it.
foreach (Player player in query)
{
if (player.GetPlayerName().Simplified().Equals(name.ToLower(), StringComparison.OrdinalIgnoreCase))
if (player.GetPlayerName().Simplified().Equals(name, StringComparison.OrdinalIgnoreCase))
return player;
}

Expand Down

0 comments on commit 64f6f63

Please sign in to comment.