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

Add config option for debug logging #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
14 changes: 11 additions & 3 deletions BuildExpansion/BuildExpansionMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class BuildExpansionMod : BaseUnityPlugin
public static ConfigEntry<int> newGridWidth;
public static ConfigEntry<bool> disableScrollCategories;
public static ConfigEntry<bool> isEnabled;
public static ConfigEntry<bool> debugLogging;

public Harmony harmony;

Expand All @@ -31,6 +32,7 @@ public void Awake()
newGridWidth = Config.Bind("General", "GridWidth", 10, "Width in number of columns of the build grid, maximum value of 10.");
disableScrollCategories = Config.Bind("General.Toggles", "DisableScrollCategories", true, "Should the mousewheel stop scrolling categories, RECOMMEND TRUE.");
isEnabled = Config.Bind("General.Toggles", "EnableExpansion", true, "Whether or not to expand the build grid.");
debugLogging = Config.Bind("General.Toggles", "DebugLogging", false, "Whether or not to print the debug logging.");
if (newGridWidth.Value > 10)
newGridWidth.Value = 10;
harmony = new Harmony(ID);
Expand Down Expand Up @@ -147,8 +149,11 @@ public static bool Prefix(ref Hud __instance, ref Player player, ref Vector2Int
category = (Piece.PieceCategory)5;
if (needRefresh || __instance.m_pieceIcons.Count(x => x.m_go.activeSelf) != buildPieces.Count)
{
BuildExpansionMod.buildFilterLogger.LogDebug($"\npieceIcons: {__instance.m_pieceIcons.Count(x => x.m_go.activeSelf)}\nBuild pieces: {buildPieces.Count}");
BuildExpansionMod.buildFilterLogger.LogDebug($"\nRows: {calculatedRows}\nColumns: {columns}");
if (BuildExpansionMod.debugLogging.Value)
{
BuildExpansionMod.buildFilterLogger.LogDebug($"\npieceIcons: {__instance.m_pieceIcons.Count(x => x.m_go.activeSelf)}\nBuild pieces: {buildPieces.Count}");
BuildExpansionMod.buildFilterLogger.LogDebug($"\nRows: {calculatedRows}\nColumns: {columns}");
}
__instance.m_pieceListRoot.sizeDelta = new Vector2((int)(__instance.m_pieceIconSpacing * BuildExpansionMod.newGridWidth.Value), (int)(__instance.m_pieceIconSpacing * calculatedRows) + 16);
foreach (Hud.PieceIconData pieceIconData in __instance.m_pieceIcons)
{
Expand Down Expand Up @@ -199,11 +204,14 @@ public static bool Prefix(ref Hud __instance, ref Player player, ref Vector2Int
templatePieceData.m_upgrade.SetActive(false);
templatePieceData.m_go.SetActive(false);
}
BuildExpansionMod.buildFilterLogger.LogDebug($"\nPiece name: {templatePieceData.m_tooltip.m_text}" +
if (BuildExpansionMod.debugLogging.Value)
{
BuildExpansionMod.buildFilterLogger.LogDebug($"\nPiece name: {templatePieceData.m_tooltip.m_text}" +
$"\nPiece icon: {templatePieceData.m_icon.enabled}" +
$"\nPiece index: {index}" +
$"\nPiece x: {xaxis}" +
$"\nPiece y: {yaxis}");
}
__instance.m_pieceIcons.Add(templatePieceData);
}
}
Expand Down