Browse Source

Merge pull request #553 from zvinless/master

Issue #477: Color property for blocks
master
Chris Gregan 8 years ago committed by GitHub
parent
commit
65c02e13f3
  1. 9
      Assets/Fungus/Resources/Textures.meta
  2. BIN
      Assets/Fungus/Resources/Textures/choice_node_off.png
  3. 59
      Assets/Fungus/Resources/Textures/choice_node_off.png.meta
  4. BIN
      Assets/Fungus/Resources/Textures/choice_node_on.png
  5. 59
      Assets/Fungus/Resources/Textures/choice_node_on.png.meta
  6. BIN
      Assets/Fungus/Resources/Textures/command_background.png
  7. 59
      Assets/Fungus/Resources/Textures/command_background.png.meta
  8. BIN
      Assets/Fungus/Resources/Textures/event_node_off.png
  9. 59
      Assets/Fungus/Resources/Textures/event_node_off.png.meta
  10. BIN
      Assets/Fungus/Resources/Textures/event_node_on.png
  11. 59
      Assets/Fungus/Resources/Textures/event_node_on.png.meta
  12. BIN
      Assets/Fungus/Resources/Textures/play_big.png
  13. 59
      Assets/Fungus/Resources/Textures/play_big.png.meta
  14. BIN
      Assets/Fungus/Resources/Textures/play_small.png
  15. 59
      Assets/Fungus/Resources/Textures/play_small.png.meta
  16. BIN
      Assets/Fungus/Resources/Textures/process_node_off.png
  17. 59
      Assets/Fungus/Resources/Textures/process_node_off.png.meta
  18. BIN
      Assets/Fungus/Resources/Textures/process_node_on.png
  19. 59
      Assets/Fungus/Resources/Textures/process_node_on.png.meta
  20. 4
      Assets/Fungus/Scripts/Components/Node.cs
  21. 14
      Assets/Fungus/Scripts/Editor/BlockEditor.cs
  22. 37
      Assets/Fungus/Scripts/Editor/FlowchartWindow.cs
  23. 82
      Assets/Fungus/Scripts/Editor/FungusEditorResources.cs
  24. 6
      Assets/Fungus/Scripts/Utils/FungusConstants.cs

9
Assets/Fungus/Resources/Textures.meta

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: ad80fa4e16e424c1baf05fbd3125b7fa
folderAsset: yes
timeCreated: 1477810347
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Fungus/Resources/Textures/choice_node_off.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

59
Assets/Fungus/Resources/Textures/choice_node_off.png.meta

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 7b6fc04aac74540e39e9502da5312ce7
timeCreated: 1477811818
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: 0
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Fungus/Resources/Textures/choice_node_on.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

59
Assets/Fungus/Resources/Textures/choice_node_on.png.meta

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: cfc05494b71a0446182868aab5f7febf
timeCreated: 1477811867
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: 0
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Fungus/Resources/Textures/command_background.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

59
Assets/Fungus/Resources/Textures/command_background.png.meta

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: a5c9a4271b3de4e4f86eff7f8a1bd768
timeCreated: 1477809339
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: 0
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Fungus/Resources/Textures/event_node_off.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

59
Assets/Fungus/Resources/Textures/event_node_off.png.meta

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 0e16a209826864df7b05f6d3901aae7a
timeCreated: 1477810004
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: 0
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Fungus/Resources/Textures/event_node_on.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

59
Assets/Fungus/Resources/Textures/event_node_on.png.meta

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 9434488a4efb54da5986eba5d5619baf
timeCreated: 1477809339
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: 0
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Fungus/Resources/Textures/play_big.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

59
Assets/Fungus/Resources/Textures/play_big.png.meta

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: bff2ba39f5f4448589e80522ebfcd0a0
timeCreated: 1477809339
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: 0
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Fungus/Resources/Textures/play_small.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

59
Assets/Fungus/Resources/Textures/play_small.png.meta

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: a48a2b9b06deb469d9da1777b094521b
timeCreated: 1477809339
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: 0
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Fungus/Resources/Textures/process_node_off.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

59
Assets/Fungus/Resources/Textures/process_node_off.png.meta

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: ea3a4228e6c214149bfe5c741b56ae0c
timeCreated: 1477809339
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: 0
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Fungus/Resources/Textures/process_node_on.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

59
Assets/Fungus/Resources/Textures/process_node_on.png.meta

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: c2dceb780784240ccbe8d3cde89f7671
timeCreated: 1477809339
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 2048
textureSettings:
filterMode: 0
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

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

@ -12,10 +12,14 @@ namespace Fungus
public class Node : MonoBehaviour
{
[SerializeField] protected Rect nodeRect = new Rect(0, 0, 120, 30);
[SerializeField] protected Color tint = Color.white;
[SerializeField] protected bool useCustomTint = false;
#region Public members
public virtual Rect _NodeRect { get { return nodeRect; } set { nodeRect = value; } }
public virtual Color Tint { get { return tint; } set { tint = value; } }
public virtual bool UseCustomTint { get { return useCustomTint; } set { useCustomTint = value; } }
#endregion
}

14
Assets/Fungus/Scripts/Editor/BlockEditor.cs

@ -95,6 +95,20 @@ namespace Fungus.EditorUtils
if (block == flowchart.SelectedBlock)
{
// Custom tinting
SerializedProperty useCustomTintProp = serializedObject.FindProperty("useCustomTint");
SerializedProperty tintProp = serializedObject.FindProperty("tint");
EditorGUILayout.BeginHorizontal();
useCustomTintProp.boolValue = GUILayout.Toggle(useCustomTintProp.boolValue, " Custom Tint");
if (useCustomTintProp.boolValue)
{
EditorGUILayout.PropertyField(tintProp, GUIContent.none);
}
EditorGUILayout.EndHorizontal();
SerializedProperty descriptionProp = serializedObject.FindProperty("description");
EditorGUILayout.PropertyField(descriptionProp);

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

@ -607,10 +607,15 @@ namespace Fungus.EditorUtils
}
GUIStyle nodeStyleCopy = new GUIStyle(nodeStyle);
Texture2D offTex;
Texture2D onTex;
Color defaultColor;
if (block._EventHandler != null)
{
nodeStyleCopy.normal.background = selected ? FungusEditorResources.texEventNodeOn : FungusEditorResources.texEventNodeOff;
offTex = FungusEditorResources.texEventNodeOff;
onTex = FungusEditorResources.texEventNodeOn;
defaultColor = FungusConstants.DefaultEventBlockTint;
}
else
{
@ -629,16 +634,18 @@ namespace Fungus.EditorUtils
if (uniqueList.Count > 1)
{
nodeStyleCopy.normal.background = selected ? FungusEditorResources.texChoiceNodeOn : FungusEditorResources.texChoiceNodeOff;
offTex = FungusEditorResources.texChoiceNodeOff;
onTex = FungusEditorResources.texChoiceNodeOn;
defaultColor = FungusConstants.DefaultChoiceBlockTint;
}
else
{
nodeStyleCopy.normal.background = selected ? FungusEditorResources.texProcessNodeOn : FungusEditorResources.texProcessNodeOff;
offTex = FungusEditorResources.texProcessNodeOff;
onTex = FungusEditorResources.texProcessNodeOn;
defaultColor = FungusConstants.DefaultProcessBlockTint;
}
}
nodeStyleCopy.normal.textColor = Color.black;
// Make sure node is wide enough to fit the node name text
var n = block as Node;
float width = nodeStyleCopy.CalcSize(new GUIContent(block.BlockName)).x;
@ -646,8 +653,26 @@ namespace Fungus.EditorUtils
tempRect.width = Mathf.Max (n._NodeRect.width, width);
n._NodeRect = tempRect;
Rect boxRect = GUILayoutUtility.GetRect(n._NodeRect.width, n._NodeRect.height);
var tintColor = n.UseCustomTint ? n.Tint : defaultColor;
// Draw untinted highlight
if (selected)
{
GUI.backgroundColor = Color.white;
nodeStyleCopy.normal.background = onTex;
GUI.Box(boxRect, "", nodeStyleCopy);
}
// Draw tinted block; ensure text is readable
var brightness = tintColor.r * 0.3 + tintColor.g * 0.59 + tintColor.b * 0.11;
nodeStyleCopy.normal.textColor = brightness >= 0.5 ? Color.black : Color.white;
nodeStyleCopy.normal.background = offTex;
GUI.backgroundColor = tintColor;
GUI.Box(GUILayoutUtility.GetLastRect(), block.BlockName, nodeStyleCopy);
GUI.backgroundColor = Color.white;
GUILayout.Box(block.BlockName, nodeStyleCopy, GUILayout.Width(n._NodeRect.width), GUILayout.Height(n._NodeRect.height));
if (block.Description.Length > 0)
{

82
Assets/Fungus/Scripts/Editor/FungusEditorResources.cs

File diff suppressed because one or more lines are too long

6
Assets/Fungus/Scripts/Utils/FungusConstants.cs

@ -1,6 +1,8 @@
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
@ -25,6 +27,10 @@ namespace Fungus
/// </summary>
public const string DefaultBlockName = "New Block";
public static Color DefaultChoiceBlockTint = new Color(1.0f, 0.627f, 0.313f, 1.0f);
public static Color DefaultEventBlockTint = new Color(0.784f, 0.882f, 1.0f, 1.0f);
public static Color DefaultProcessBlockTint = new Color(1.0f, 0.882f, 0.0f, 1.0f);
#endregion
}
}
Loading…
Cancel
Save