Browse Source

Merge branch 'snozbot/master' into icons

master
Zach Vinless 9 years ago
parent
commit
65a971ba2d
  1. 4
      Assets/Fungus/Scripts/Components/MusicManager.cs
  2. 7
      Assets/Fungus/Scripts/Editor/EditorZoomArea.cs
  3. 83
      Assets/Fungus/Scripts/Editor/FlowchartWindow.cs
  4. 2
      Assets/Fungus/Scripts/VariableTypes/StringVariable.cs
  5. 29
      Assets/Fungus/Thirdparty/CSVParser/CsvParser.cs
  6. 60
      Assets/FungusExamples/DragAndDrop/DragAndDrop(EventSystem).unity
  7. 60
      Assets/FungusExamples/DragAndDrop/DragAndDrop.unity
  8. 9
      Assets/FungusExamples/FungusLua/Narrative/StageAndPortraits.unity

4
Assets/Fungus/Scripts/Components/MusicManager.cs

@ -113,6 +113,10 @@ namespace Fungus
if (Mathf.Approximately(duration, 0f))
{
if (onComplete != null)
{
onComplete();
}
audio.volume = volume;
return;
}

7
Assets/Fungus/Scripts/Editor/EditorZoomArea.cs

@ -56,15 +56,16 @@ namespace Fungus.EditorUtils
public class EditorZoomArea
{
private const float kEditorWindowTabHeight = 21.0f;
private static Matrix4x4 _prevGuiMatrix;
private static Vector2 offset = new Vector2(2.0f, 19.0f);
public static Vector2 Offset { get { return offset; } set { offset = value; } }
public static Rect Begin(float zoomScale, Rect screenCoordsArea)
{
GUI.EndGroup(); // End the group Unity begins automatically for an EditorWindow to clip out the window tab. This allows us to draw outside of the size of the EditorWindow.
Rect clippedArea = screenCoordsArea.ScaleSizeBy(1.0f / zoomScale, screenCoordsArea.TopLeft());
clippedArea.y += kEditorWindowTabHeight;
clippedArea.position += offset;
GUI.BeginGroup(clippedArea);
_prevGuiMatrix = GUI.matrix;
@ -81,7 +82,7 @@ namespace Fungus.EditorUtils
{
GUI.matrix = _prevGuiMatrix;
GUI.EndGroup();
GUI.BeginGroup(new Rect(0.0f, kEditorWindowTabHeight, Screen.width, Screen.height));
GUI.BeginGroup(new Rect(offset.x, offset.y, Screen.width, Screen.height));
}
}
}

83
Assets/Fungus/Scripts/Editor/FlowchartWindow.cs

@ -7,6 +7,7 @@ using UnityEditorInternal;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
namespace Fungus.EditorUtils
{
@ -88,6 +89,24 @@ namespace Fungus.EditorUtils
Repaint();
}
protected virtual void OnBecameVisible()
{
// Ensure that toolbar looks correct in both docked and undocked windows
// The docked value doesn't always report correctly without the delayCall
EditorApplication.delayCall += () => {
var flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
var isDockedMethod = typeof(EditorWindow).GetProperty("docked", flags).GetGetMethod(true);
if ((bool) isDockedMethod.Invoke(this, null))
{
EditorZoomArea.Offset = new Vector2(2.0f, 19.0f);
}
else
{
EditorZoomArea.Offset = new Vector2(0.0f, 22.0f);
}
};
}
public static Flowchart GetFlowchart()
{
// Using a temp hidden object to track the active Flowchart across
@ -158,28 +177,46 @@ namespace Fungus.EditorUtils
protected virtual void DrawOverlay(Flowchart flowchart)
{
GUILayout.Space(8);
GUILayout.BeginHorizontal();
GUILayout.BeginHorizontal(EditorStyles.toolbar);
GUILayout.Space(8);
GUILayout.Space(2);
if (GUILayout.Button(new GUIContent(addTexture, "Add a new block")))
if (GUILayout.Button(new GUIContent(addTexture, "Add a new block"), EditorStyles.toolbarButton))
{
Vector2 newNodePosition = new Vector2(50 - flowchart.ScrollPos.x,
50 - flowchart.ScrollPos.y);
Vector2 newNodePosition = new Vector2(50 / flowchart.Zoom - flowchart.ScrollPos.x,
50 / flowchart.Zoom - flowchart.ScrollPos.y);
CreateBlock(flowchart, newNodePosition);
}
// Separator
GUILayout.Label("", EditorStyles.toolbarButton, GUILayout.Width(8));
GUILayout.Space(8);
GUILayout.Label("Scale", EditorStyles.miniLabel);
var newZoom = GUILayout.HorizontalSlider(
flowchart.Zoom, minZoomValue, maxZoomValue, GUILayout.MinWidth(40), GUILayout.MaxWidth(100)
);
GUILayout.Label(flowchart.Zoom.ToString("0.0#x"), EditorStyles.miniLabel, GUILayout.Width(30));
var newZoom = GUILayout.HorizontalSlider(flowchart.Zoom, minZoomValue, maxZoomValue, GUILayout.Width(100));
DoZoom(flowchart, newZoom - flowchart.Zoom, Vector2.one * 0.5f);
if (GUILayout.Button("Center", EditorStyles.toolbarButton))
{
flowchart.ScrollPos = flowchart.CenterPosition;
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.BeginVertical();
GUILayout.Label(flowchart.name, EditorStyles.whiteBoldLabel);
GUILayout.Space(2);
if (flowchart.Description.Length > 0)
{
GUILayout.Label(flowchart.Description, EditorStyles.helpBox);
@ -188,14 +225,14 @@ namespace Fungus.EditorUtils
GUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUILayout.BeginVertical(GUILayout.Width(440));
GUILayout.FlexibleSpace();
var rawMousePosition = Event.current.mousePosition; // mouse position outside of scrollview to test against toolbar rect
flowchart.VariablesScrollPos = GUILayout.BeginScrollView(flowchart.VariablesScrollPos, GUILayout.MaxHeight(position.height * 0.75f));
GUILayout.FlexibleSpace();
@ -215,7 +252,8 @@ namespace Fungus.EditorUtils
}
if (Event.current.type == EventType.Repaint)
{
mouseOverVariables = variableWindowRect.Contains(Event.current.mousePosition);
Rect toolbarRect = new Rect(0, 0, position.width, 18);
mouseOverVariables = variableWindowRect.Contains(Event.current.mousePosition) || toolbarRect.Contains(rawMousePosition);
}
GUILayout.EndScrollView();
@ -430,10 +468,10 @@ namespace Fungus.EditorUtils
// Draw selection box
if (startSelectionBoxPosition.x >= 0 && startSelectionBoxPosition.y >= 0)
{
GUI.Box(selectionBox, "", (GUIStyle) "SelectionRect");
{
GUI.Box(selectionBox, "", (GUIStyle) "SelectionRect");
forceRepaintCount = 6;
}
}
}
public virtual void CalcFlowchartCenter(Flowchart flowchart, Block[] blocks)
@ -457,8 +495,8 @@ namespace Fungus.EditorUtils
Vector2 center = (min + max) * -0.5f;
center.x += position.width * 0.5f;
center.y += position.height * 0.5f;
center.x += position.width * 0.5f / flowchart.Zoom;
center.y += position.height * 0.5f / flowchart.Zoom;
flowchart.CenterPosition = center;
}
@ -471,16 +509,19 @@ namespace Fungus.EditorUtils
switch (Event.current.type)
{
case EventType.MouseDown:
startSelectionBoxPosition = Event.current.mousePosition;
mouseDownSelectionState = new List<Block>(flowchart.SelectedBlocks);
Event.current.Use();
if (!mouseOverVariables)
{
startSelectionBoxPosition = Event.current.mousePosition;
mouseDownSelectionState = new List<Block>(flowchart.SelectedBlocks);
Event.current.Use();
}
break;
case EventType.MouseDrag:
if (startSelectionBoxPosition.x >= 0 && startSelectionBoxPosition.y >= 0)
{
var topLeft = Vector2.Min(startSelectionBoxPosition, Event.current.mousePosition);
var bottomRight = Vector2.Max(startSelectionBoxPosition, Event.current.mousePosition);
var bottomRight = Vector2.Max(startSelectionBoxPosition, Event.current.mousePosition);
selectionBox = Rect.MinMaxRect(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
Rect zoomSelectionBox = selectionBox;

2
Assets/Fungus/Scripts/VariableTypes/StringVariable.cs

@ -96,7 +96,7 @@ namespace Fungus
[VariableProperty("<Value>", typeof(StringVariable))]
public StringVariable stringRef;
[TextArea(1,10)]
[TextArea(1,15)]
[SerializeField]
public string stringVal;

29
Assets/Fungus/Thirdparty/CSVParser/CsvParser.cs vendored

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
namespace Ideafixxxer.CsvParser
{
@ -190,28 +191,36 @@ namespace Ideafixxxer.CsvParser
var context = new ParserContext();
// Handle both Windows and Mac line endings
string[] lines = csvData.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);
var lines = Regex.Split(csvData, "\n|\r\n");
ParserState currentState = ParserState.LineStartState;
foreach (string next in lines)
{
foreach (char ch in next)
for (int i = 0; i < lines.Length; i++) {
var next = lines [i];
// Skip empty entries
if (next.Length == 0)
{
switch (ch)
{
continue;
}
for (int j = 0; j < next.Length; j++) {
var ch = next [j];
switch (ch) {
case CommaCharacter:
currentState = currentState.Comma(context);
currentState = currentState.Comma (context);
break;
case QuoteCharacter:
currentState = currentState.Quote(context);
currentState = currentState.Quote (context);
break;
default:
currentState = currentState.AnyChar(ch, context);
currentState = currentState.AnyChar (ch, context);
break;
}
}
currentState = currentState.EndOfLine(context);
currentState = currentState.EndOfLine (context);
}
List<string[]> allLines = context.GetAllLines();
return allLines.ToArray();
}

60
Assets/FungusExamples/DragAndDrop/DragAndDrop(EventSystem).unity

@ -627,47 +627,6 @@ CircleCollider2D:
m_PrefabParentObject: {fileID: 5800000, guid: 4442b79fcbcbb4aac97f42d6dc3d4e0b,
type: 2}
m_PrefabInternal: {fileID: 442175927}
--- !u!1 &807929237
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 807929239}
- 114: {fileID: 807929238}
m_Layer: 0
m_Name: TestRunner
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &807929238
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 807929237}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5c3afc1c624179749bcdecf7b0224902, type: 3}
m_Name:
m_EditorClassIdentifier:
currentTest: {fileID: 0}
--- !u!4 &807929239
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 807929237}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
--- !u!1 &1081858233 stripped
GameObject:
m_PrefabParentObject: {fileID: 100000, guid: 4d55f86cf3b124c8fb1158da26ffa96d, type: 2}
@ -997,7 +956,7 @@ MonoBehaviour:
y: -452
width: 1887
height: 1080
selectedBlock: {fileID: 2019116698}
selectedBlocks: []
selectedCommands:
- {fileID: 2019116697}
variables: []
@ -1030,6 +989,8 @@ MonoBehaviour:
y: 29
width: 197
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 17
blockName: Drag Completed
description:
@ -1240,6 +1201,8 @@ MonoBehaviour:
y: 132
width: 197
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 16
blockName: Drag Exited
description:
@ -1294,6 +1257,8 @@ MonoBehaviour:
y: 133
width: 197
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 15
blockName: Drag Entered
description:
@ -1332,6 +1297,8 @@ MonoBehaviour:
y: 30
width: 136
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 14
blockName: Drag Cancelled
description:
@ -1370,6 +1337,8 @@ MonoBehaviour:
y: 27
width: 136
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 13
blockName: Drag Start
description:
@ -1523,6 +1492,8 @@ MonoBehaviour:
y: 29
width: 137
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 18
blockName: Object Clicked 1
description:
@ -1546,6 +1517,8 @@ MonoBehaviour:
y: 31
width: 137
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 19
blockName: Object Clicked 2
description:
@ -1630,6 +1603,8 @@ MonoBehaviour:
y: -50
width: 120
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 20
blockName: Start
description:
@ -1648,6 +1623,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
parentBlock: {fileID: 2019116698}
waitForFrames: 1
--- !u!1 &2096462794
GameObject:
m_ObjectHideFlags: 0

60
Assets/FungusExamples/DragAndDrop/DragAndDrop.unity

@ -608,47 +608,6 @@ CircleCollider2D:
m_PrefabParentObject: {fileID: 5800000, guid: 4442b79fcbcbb4aac97f42d6dc3d4e0b,
type: 2}
m_PrefabInternal: {fileID: 442175927}
--- !u!1 &807929237
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 807929239}
- 114: {fileID: 807929238}
m_Layer: 0
m_Name: TestRunner
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &807929238
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 807929237}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5c3afc1c624179749bcdecf7b0224902, type: 3}
m_Name:
m_EditorClassIdentifier:
currentTest: {fileID: 0}
--- !u!4 &807929239
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 807929237}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
--- !u!1 &1081858233 stripped
GameObject:
m_PrefabParentObject: {fileID: 100000, guid: 4d55f86cf3b124c8fb1158da26ffa96d, type: 2}
@ -979,7 +938,7 @@ MonoBehaviour:
y: -452
width: 1887
height: 1080
selectedBlock: {fileID: 2019116698}
selectedBlocks: []
selectedCommands: []
variables: []
description: 'This scene shows how to set up a drag-and-drop
@ -1011,6 +970,8 @@ MonoBehaviour:
y: 29
width: 197
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 17
blockName: Drag Completed
description:
@ -1221,6 +1182,8 @@ MonoBehaviour:
y: 132
width: 197
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 16
blockName: Drag Exited
description:
@ -1275,6 +1238,8 @@ MonoBehaviour:
y: 133
width: 197
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 15
blockName: Drag Entered
description:
@ -1313,6 +1278,8 @@ MonoBehaviour:
y: 30
width: 136
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 14
blockName: Drag Cancelled
description:
@ -1351,6 +1318,8 @@ MonoBehaviour:
y: 27
width: 136
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 13
blockName: Drag Start
description:
@ -1504,6 +1473,8 @@ MonoBehaviour:
y: 29
width: 137
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 18
blockName: Object Clicked 1
description:
@ -1527,6 +1498,8 @@ MonoBehaviour:
y: 31
width: 137
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 19
blockName: Object Clicked 2
description:
@ -1611,6 +1584,8 @@ MonoBehaviour:
y: -50
width: 120
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 20
blockName: Start
description:
@ -1629,6 +1604,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
parentBlock: {fileID: 2019116698}
waitForFrames: 1
--- !u!1 &2096462794
GameObject:
m_ObjectHideFlags: 0

9
Assets/FungusExamples/FungusLua/Narrative/StageAndPortraits.unity

@ -331,6 +331,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
parentBlock: {fileID: 574033268}
waitForFrames: 1
--- !u!114 &574033268
MonoBehaviour:
m_ObjectHideFlags: 2
@ -349,6 +350,8 @@ MonoBehaviour:
y: 68.96694
width: 120
height: 40
tint: {r: 1, g: 1, b: 1, a: 1}
useCustomTint: 0
itemId: 0
blockName: Start
description:
@ -381,7 +384,7 @@ MonoBehaviour:
y: -340
width: 1114
height: 859
selectedBlock: {fileID: 574033268}
selectedBlocks: []
selectedCommands:
- {fileID: 574033272}
variables: []
@ -903,7 +906,7 @@ MonoBehaviour:
nameColor: {r: 1, g: 1, b: 1, a: 1}
soundEffect: {fileID: 0}
portraits:
- {fileID: 21300000, guid: a92b08a118b7d46f59dd091acb2e4102, type: 3}
- {fileID: 21300000, guid: e8a9122c4dc10b14da3b625e1f2634c9, type: 3}
- {fileID: 21300000, guid: 03bc547cc0049594bae51f00903eedef, type: 3}
portraitsFace: 0
setSayDialog: {fileID: 1231398849}
@ -954,7 +957,7 @@ MonoBehaviour:
soundEffect: {fileID: 0}
portraits:
- {fileID: 21300000, guid: 8f5b5b110e73a414eb229eeead86200f, type: 3}
- {fileID: 21300000, guid: c779e34c6eb8e45da98c70cf2802a54c, type: 3}
- {fileID: 21300000, guid: 84cdbfde1b7d4c24ab7071894480d5db, type: 3}
portraitsFace: 0
setSayDialog: {fileID: 1958712152}
description:

Loading…
Cancel
Save