-
Notifications
You must be signed in to change notification settings - Fork 16
Allow selecting patches #165
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
Changes from 2 commits
cccf21d
26c0290
5708fc7
21bba4d
63b9727
0f4b1ab
9024599
083973c
7b8e258
8591aac
1cab956
751cb68
99d77dc
382dea9
2ebebf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| using System; | ||
|
|
||
| namespace JSI | ||
| { | ||
| public class GenericVariable : IVariable | ||
| { | ||
| private Func<object> Generator; | ||
|
|
||
| internal GenericVariable(Func<object> generator) | ||
| { | ||
| Generator = generator; | ||
| } | ||
|
|
||
| object IVariable.GetValue() | ||
| { | ||
| return Generator(); | ||
| } | ||
|
|
||
| bool IVariable.Changed(object oldValue) | ||
| { | ||
| return true; | ||
andymac-2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| bool IVariable.IsConstant() | ||
| { | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace JSI | ||
| { | ||
| internal interface IPageElement | ||
|
||
| { | ||
| void HandlePageCreate(RasterPropMonitor propMonitor); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| namespace JSI | ||
| { | ||
| /// <summary> | ||
| /// This class exists to provide a base class that RasterPropMonitorComputer | ||
| /// manages for tracking various built-in plugin action handlers. | ||
| /// </summary> | ||
| internal interface IVariable | ||
| { | ||
| object GetValue(); | ||
| bool Changed(object oldValue); | ||
| bool IsConstant(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ | |
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Reflection; | ||
| using System.Text; | ||
| using UnityEngine; | ||
|
|
||
| namespace JSI | ||
|
|
@@ -80,7 +79,7 @@ public enum BackgroundType | |
| private readonly MonoBehaviour backgroundHandlerModule, pageHandlerModule; | ||
| private readonly List<string> techsRequired = new List<string>(); | ||
| private readonly string fallbackPageName = string.Empty; | ||
|
|
||
| private readonly PatchSelector patchSelector; | ||
|
||
|
|
||
| private struct HandlerSupportMethods | ||
| { | ||
|
|
@@ -136,7 +135,7 @@ public void UpdateText(RasterPropMonitorComputer rpmComp) | |
| allTextConstant = true; | ||
| for (int i = 0; i < linesArray.Length; ++i) | ||
| { | ||
| spf[i] = new StringProcessorFormatter(linesArray[i], rpmComp); | ||
| spf[i] = new StringProcessorFormatter(linesArray[i], rpmComp, ourMonitor); | ||
|
|
||
| outputLines[i] = spf[i].cachedResult; | ||
|
|
||
|
|
@@ -156,7 +155,7 @@ public void UpdateText(RasterPropMonitorComputer rpmComp) | |
| { | ||
| if (spf[i] != null) | ||
| { | ||
| outputLines[i] = StringProcessor.ProcessString(spf[i], rpmComp); | ||
| outputLines[i] = spf[i].GetFormattedString(); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -433,6 +432,13 @@ public MonitorPage(int idNum, ConfigNode node, RasterPropMonitor thatMonitor) | |
| } | ||
| } | ||
|
|
||
| if (node.HasNode("PATCHSELECTOR")) | ||
| { | ||
| foreach (ConfigNode patchSelectorNode in node.GetNodes("PATCHSELECTOR")) | ||
| { | ||
| patchSelector = new PatchSelector(ourMonitor, patchSelectorNode); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private static MethodInfo InstantiateHandler(ConfigNode node, RasterPropMonitor ourMonitor, out MonoBehaviour moduleInstance, out HandlerSupportMethods support) | ||
|
|
@@ -593,6 +599,11 @@ private static MethodInfo InstantiateHandler(ConfigNode node, RasterPropMonitor | |
| } | ||
| } | ||
|
|
||
| if (thatModule is IPageElement pageElement) | ||
| { | ||
| pageElement.HandlePageCreate(ourMonitor); | ||
| } | ||
|
|
||
| moduleInstance = thatModule; | ||
| foreach (MethodInfo m in thatModule.GetType().GetMethods()) | ||
| { | ||
|
|
@@ -626,17 +637,27 @@ public bool GlobalButtonClick(int buttonID) | |
| { | ||
| return false; | ||
| } | ||
|
|
||
| bool actionTaken = false; | ||
|
|
||
| if (pageHandlerS.buttonClick != null) | ||
| { | ||
| pageHandlerS.buttonClick(buttonID); | ||
| actionTaken = true; | ||
| } | ||
|
|
||
| if (backgroundHandlerS.buttonClick != null && pageHandlerS.buttonClick != backgroundHandlerS.buttonClick) | ||
| { | ||
| backgroundHandlerS.buttonClick(buttonID); | ||
| actionTaken = true; | ||
| } | ||
|
|
||
| if (patchSelector != null) | ||
| { | ||
| patchSelector.HandleButtonPress(buttonID); | ||
| actionTaken = true; | ||
| } | ||
|
|
||
| return actionTaken; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.