Browse Source

Mathf Command more consistent implementation of HasReference and more Detailed Summaries

master
desktop-maesty/steve 6 years ago
parent
commit
5329caa624
  1. 5
      Assets/Fungus/Scripts/Commands/Math/Abs.cs
  2. 10
      Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs
  3. 11
      Assets/Fungus/Scripts/Commands/Math/Clamp.cs
  4. 5
      Assets/Fungus/Scripts/Commands/Math/Curve.cs
  5. 5
      Assets/Fungus/Scripts/Commands/Math/Exp.cs
  6. 5
      Assets/Fungus/Scripts/Commands/Math/Inv.cs
  7. 11
      Assets/Fungus/Scripts/Commands/Math/InvLerp.cs
  8. 6
      Assets/Fungus/Scripts/Commands/Math/Lerp.cs
  9. 12
      Assets/Fungus/Scripts/Commands/Math/Log.cs
  10. 7
      Assets/Fungus/Scripts/Commands/Math/Map.cs
  11. 11
      Assets/Fungus/Scripts/Commands/Math/MinMax.cs
  12. 5
      Assets/Fungus/Scripts/Commands/Math/Neg.cs
  13. 10
      Assets/Fungus/Scripts/Commands/Math/Pow.cs
  14. 2
      Assets/Fungus/Scripts/Commands/Math/Round.cs
  15. 5
      Assets/Fungus/Scripts/Commands/Math/Sign.cs
  16. 5
      Assets/Fungus/Scripts/Commands/Math/Sqrt.cs
  17. 30
      Assets/Fungus/Scripts/Commands/Math/ToInt.cs
  18. 9
      Assets/Fungus/Scripts/Commands/Math/Trig.cs

5
Assets/Fungus/Scripts/Commands/Math/Abs.cs

@ -17,10 +17,5 @@ namespace Fungus
Continue();
}
public override string GetSummary()
{
return "Abs";
}
}
}

10
Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs

@ -21,5 +21,15 @@ namespace Fungus
return new Color32(235, 191, 217, 255);
}
public override string GetSummary()
{
return "in: " + (inValue.floatRef != null ? inValue.floatRef.Key : inValue.Value.ToString()) +
", out: " + (outValue.floatRef != null ? outValue.floatRef.Key : outValue.Value.ToString());
}
public override bool HasReference(Variable variable)
{
return variable == inValue.floatRef || variable == outValue.floatRef;
}
}
}

11
Assets/Fungus/Scripts/Commands/Math/Clamp.cs

@ -55,7 +55,16 @@ namespace Fungus
public override string GetSummary()
{
return Mode.Clamp.ToString() + (mode != Mode.Clamp ? " & " + mode.ToString() : "");
if (outValue.floatRef == null)
return "Error: no output value selected";
return outValue.floatRef.Key + " = " + Mode.Clamp.ToString() + (mode != Mode.Clamp ? " & " + mode.ToString() : "");
}
public override bool HasReference(Variable variable)
{
return lower.floatRef == variable || upper.floatRef == variable || value.floatRef == variable ||
outValue.floatRef == variable;
}
public override Color GetButtonColor()

5
Assets/Fungus/Scripts/Commands/Math/Curve.cs

@ -20,10 +20,5 @@ namespace Fungus
Continue();
}
public override string GetSummary()
{
return "Curve";
}
}
}

5
Assets/Fungus/Scripts/Commands/Math/Exp.cs

@ -17,10 +17,5 @@ namespace Fungus
Continue();
}
public override string GetSummary()
{
return "Exp";
}
}
}

5
Assets/Fungus/Scripts/Commands/Math/Inv.cs

@ -19,10 +19,5 @@ namespace Fungus
Continue();
}
public override string GetSummary()
{
return "Inverse 1/f";
}
}
}

11
Assets/Fungus/Scripts/Commands/Math/InvLerp.cs

@ -35,7 +35,16 @@ namespace Fungus
public override string GetSummary()
{
return "InvLerp [" + a.Value.ToString() + "-" + b.Value.ToString() + "]";
if (outValue.floatRef == null)
return "Error: no out value selected";
return outValue.floatRef.Key + " = [" + a.Value.ToString() + "-" + b.Value.ToString() + "]";
}
public override bool HasReference(Variable variable)
{
return a.floatRef == variable || b.floatRef == variable || value.floatRef == variable ||
outValue.floatRef == variable;
}
public override Color GetButtonColor()

6
Assets/Fungus/Scripts/Commands/Math/Lerp.cs

@ -54,6 +54,12 @@ namespace Fungus
return mode.ToString() + " [" + a.Value.ToString() + "-" + b.Value.ToString() + "]";
}
public override bool HasReference(Variable variable)
{
return a.floatRef == variable || b.floatRef == variable || percentage.floatRef == variable ||
outValue.floatRef == variable;
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);

12
Assets/Fungus/Scripts/Commands/Math/Log.cs

@ -40,17 +40,7 @@ namespace Fungus
public override string GetSummary()
{
switch (mode)
{
case Mode.Base10:
return "Log Base 10";
case Mode.Natural:
return "Natural Log";
default:
break;
}
return "Log";
return mode.ToString() + " " + base.GetSummary();
}
}
}

7
Assets/Fungus/Scripts/Commands/Math/Map.cs

@ -40,6 +40,13 @@ namespace Fungus
newRangeLower.Value.ToString() + "-" + newRangeUpper.Value.ToString() + "]";
}
public override bool HasReference(Variable variable)
{
return initialRangeLower.floatRef == variable || initialRangeUpper.floatRef == variable || value.floatRef == variable ||
newRangeLower.floatRef == variable || newRangeUpper.floatRef == variable ||
outValue.floatRef == variable;
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);

11
Assets/Fungus/Scripts/Commands/Math/MinMax.cs

@ -43,19 +43,24 @@ namespace Fungus
break;
}
Continue();
}
public override string GetSummary()
{
return function.ToString();
return function.ToString() + " " +
"out: " + (outValue.floatRef != null ? outValue.floatRef.Key : outValue.Value.ToString()) +
" [" + inLHSValue.Value.ToString() + " - " + inRHSValue.Value.ToString() + "]";
}
public override bool HasReference(Variable variable)
{
return inLHSValue.floatRef == variable || inRHSValue.floatRef == variable || outValue.floatRef == variable;
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}

5
Assets/Fungus/Scripts/Commands/Math/Neg.cs

@ -17,10 +17,5 @@ namespace Fungus
Continue();
}
public override string GetSummary()
{
return "Negate";
}
}
}

10
Assets/Fungus/Scripts/Commands/Math/Pow.cs

@ -27,7 +27,10 @@ namespace Fungus
public override string GetSummary()
{
return "Pow";
if (outValue.floatRef == null)
return "Error: No out value selected";
return outValue.floatRef.Key + " = " + baseValue.Value.ToString() + "^" + exponentValue.Value.ToString();
}
public override Color GetButtonColor()
@ -35,5 +38,10 @@ namespace Fungus
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
return baseValue.floatRef == variable || exponentValue.floatRef == variable ||
outValue.floatRef == variable;
}
}
}

2
Assets/Fungus/Scripts/Commands/Math/Round.cs

@ -44,7 +44,7 @@ namespace Fungus
public override string GetSummary()
{
return function.ToString();
return function.ToString() + " " + base.GetSummary();
}
}
}

5
Assets/Fungus/Scripts/Commands/Math/Sign.cs

@ -17,10 +17,5 @@ namespace Fungus
Continue();
}
public override string GetSummary()
{
return "Sign";
}
}
}

5
Assets/Fungus/Scripts/Commands/Math/Sqrt.cs

@ -17,10 +17,5 @@ namespace Fungus
Continue();
}
public override string GetSummary()
{
return "Sqrt";
}
}
}

30
Assets/Fungus/Scripts/Commands/Math/ToInt.cs

@ -35,17 +35,17 @@ namespace Fungus
{
switch (function)
{
case Mode.RoundToInt:
outValue.Value = Mathf.RoundToInt(inValue.Value);
break;
case Mode.FloorToInt:
outValue.Value = Mathf.FloorToInt(inValue.Value);
break;
case Mode.CeilToInt:
outValue.Value = Mathf.CeilToInt(inValue.Value);
break;
default:
break;
case Mode.RoundToInt:
outValue.Value = Mathf.RoundToInt(inValue.Value);
break;
case Mode.FloorToInt:
outValue.Value = Mathf.FloorToInt(inValue.Value);
break;
case Mode.CeilToInt:
outValue.Value = Mathf.CeilToInt(inValue.Value);
break;
default:
break;
}
Continue();
@ -53,7 +53,9 @@ namespace Fungus
public override string GetSummary()
{
return function.ToString();
return function.ToString() +
" in: " + (inValue.floatRef != null ? inValue.floatRef.Key : inValue.Value.ToString()) +
", out: " + (outValue.integerRef != null ? outValue.integerRef.Key : outValue.Value.ToString()); ;
}
public override Color GetButtonColor()
@ -61,5 +63,9 @@ namespace Fungus
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
return variable == inValue.floatRef || variable == outValue.integerRef;
}
}
}

9
Assets/Fungus/Scripts/Commands/Math/Trig.cs

@ -23,7 +23,6 @@ namespace Fungus
Tan
}
[Tooltip("Trigonometric function to run.")]
[SerializeField]
protected Function function = Function.Sin;
@ -65,13 +64,7 @@ namespace Fungus
public override string GetSummary()
{
return function.ToString();
return function.ToString() + " " + base.GetSummary();
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}
Loading…
Cancel
Save