Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Added toggle for Ingame Log.
Browse files Browse the repository at this point in the history
  • Loading branch information
RequiDev committed Aug 17, 2021
1 parent 9271a15 commit 0334b77
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ReModCE/Components/IngameLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ internal class IngameLog : ModComponent
private ReScrollView _log;
private string _preUiLog;

private ConfigValue<bool> IngameLogEnabled;
private ReQuickToggle _logToggle;
public IngameLog()
{
IngameLogEnabled = new ConfigValue<bool>(nameof(IngameLogEnabled), true);
IngameLogEnabled.OnValueChanged += () => _logToggle.Toggle(IngameLogEnabled);
MelonLogger.MsgCallbackHandler += (color, consoleColor, nameSection, msg) =>
{
if (nameSection != nameof(ReModCE) && !msg.Contains("[ReMod]"))
Expand All @@ -36,6 +40,9 @@ public IngameLog()

public override void OnUiManagerInit(UiManager uiManager)
{
var logMenu = uiManager.MainMenu.AddSubMenu("Ingame Log", "Access ingame log related settings.");
_logToggle = logMenu.AddToggle("Enabled", "Enable/Disable the ingame log UI", ToggleIngameLog, IngameLogEnabled);

var logPos = new Vector2(-1695, 1470f);
if (uiManager.IsRubyLoaded)
{
Expand All @@ -44,8 +51,13 @@ public override void OnUiManagerInit(UiManager uiManager)

_log = new ReScrollView("ReModCELog", logPos, ExtendedQuickMenu.ShortcutMenu);
_log.AddText(_preUiLog);
}

private void ToggleIngameLog(bool toggled)
{
_log.Active = toggled;
}

private static string ConsoleColorToHexCode(ConsoleColor c)
{
string[] cColors = {
Expand Down
6 changes: 6 additions & 0 deletions ReModCE/UI/UIElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public Vector3 Position
set => RectTransform.localPosition = value;
}

public bool Active
{
get => GameObject.activeSelf;
set => GameObject.SetActive(value);
}

public UIElement(GameObject original, Transform parent, Vector3 pos, string name, bool defaultState = true) : this(original, parent, name, defaultState)
{
GameObject.transform.localPosition = pos;
Expand Down

0 comments on commit 0334b77

Please sign in to comment.