Skip to content

Commit

Permalink
Context menu dialog improvements (OrderOfThePorcupine#238)
Browse files Browse the repository at this point in the history
* Gas connections will not function outside.

* Improves the look of context menu items

* Gas comment

* Context-appropriate style.
  • Loading branch information
kd7uiy authored Feb 24, 2019
1 parent bd4415e commit 6180597
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 59 deletions.
32 changes: 17 additions & 15 deletions Assets/Resources/UI/Components/ContextMenuItem.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
serializedVersion: 5
m_Component:
- 224: {fileID: 224000013742935920}
- 222: {fileID: 222000012553358708}
- 114: {fileID: 114000010682378114}
- 114: {fileID: 114000014070300310}
- 114: {fileID: 114000011943728566}
- 114: {fileID: 114000013092840952}
- component: {fileID: 224000013742935920}
- component: {fileID: 222000012553358708}
- component: {fileID: 114000010682378114}
- component: {fileID: 114000014070300310}
- component: {fileID: 114000011943728566}
- component: {fileID: 114000013092840952}
m_Layer: 5
m_Name: ContextMenuItem
m_TagString: Untagged
Expand All @@ -36,11 +36,11 @@ GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
serializedVersion: 5
m_Component:
- 224: {fileID: 224000011770679948}
- 222: {fileID: 222000011974463574}
- 114: {fileID: 114000011145545988}
- component: {fileID: 224000011770679948}
- component: {fileID: 222000011974463574}
- component: {fileID: 114000011145545988}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
Expand Down Expand Up @@ -96,10 +96,10 @@ MonoBehaviour:
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontSize: 20
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MinSize: 2
m_MaxSize: 40
m_Alignment: 3
m_AlignByGeometry: 0
Expand Down Expand Up @@ -141,6 +141,8 @@ MonoBehaviour:
m_Spacing: 0
m_ChildForceExpandWidth: 1
m_ChildForceExpandHeight: 1
m_ChildControlWidth: 1
m_ChildControlHeight: 1
--- !u!114 &114000014070300310
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -214,10 +216,10 @@ RectTransform:
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: 224000013742935920}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
Expand All @@ -232,11 +234,11 @@ RectTransform:
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:
- {fileID: 224000011770679948}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
Expand Down
40 changes: 21 additions & 19 deletions Assets/Resources/UI/ContextMenu.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
serializedVersion: 5
m_Component:
- 224: {fileID: 224000011377820364}
- 222: {fileID: 222000013824823538}
- 114: {fileID: 114000013225789384}
- 114: {fileID: 114000011413206680}
- 114: {fileID: 114000013108134710}
- 114: {fileID: 114000011622113432}
- 114: {fileID: 114000013495731334}
- component: {fileID: 224000011377820364}
- component: {fileID: 222000013824823538}
- component: {fileID: 114000013225789384}
- component: {fileID: 114000011413206680}
- component: {fileID: 114000013108134710}
- component: {fileID: 114000011622113432}
- component: {fileID: 114000013495731334}
m_Layer: 5
m_Name: ContextMenu
m_TagString: Untagged
Expand All @@ -38,7 +38,7 @@ MonoBehaviour:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010986077850}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 55b3394b4a8b4724f8d1baca789856db, type: 3}
m_Name:
Expand Down Expand Up @@ -82,7 +82,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1953a4b5e546b594f9bb9c527fcd9ce4, type: 3}
m_Name:
m_EditorClassIdentifier:
ContextualMenuItemPrefab: {fileID: 1000012466397640, guid: 2736cb62d5f066844b2d276b486bc33d,
ContextualMenuItemPrefab: {fileID: 114000011943728566, guid: 2736cb62d5f066844b2d276b486bc33d,
type: 2}
--- !u!114 &114000013225789384
MonoBehaviour:
Expand All @@ -96,14 +96,16 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_Left: 3
m_Right: 3
m_Top: 2
m_Bottom: 2
m_ChildAlignment: 0
m_Spacing: 0
m_ChildForceExpandWidth: 1
m_ChildForceExpandHeight: 1
m_Spacing: 2
m_ChildForceExpandWidth: 0
m_ChildForceExpandHeight: 0
m_ChildControlWidth: 1
m_ChildControlHeight: 1
--- !u!114 &114000013495731334
MonoBehaviour:
m_ObjectHideFlags: 1
Expand All @@ -116,7 +118,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 2
m_VerticalFit: 0
m_VerticalFit: 2
--- !u!222 &222000013824823538
CanvasRenderer:
m_ObjectHideFlags: 1
Expand All @@ -132,10 +134,10 @@ RectTransform:
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: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Models/Buildable/Components/GasConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public override bool CanFunction()
if (Requires != null && Requires.Count > 0 && ParentFurniture.Tile.Room != null)
{
Room room = ParentFurniture.Tile.Room;

// Gas connections do not function outside.
if (room.IsOutsideRoom())
{
return false;
Expand Down
7 changes: 2 additions & 5 deletions Assets/Scripts/UI/ContextMenu/ContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class ContextMenu : MonoBehaviour
{
public GameObject ContextualMenuItemPrefab;
public ContextMenuItem ContextualMenuItemPrefab;

public bool Opened
{
Expand Down Expand Up @@ -72,10 +72,7 @@ private void BuildInterface(List<ContextMenuAction> contextualActions)
if ((contextMenuAction.RequireCharacterSelected && characterSelected) ||
!contextMenuAction.RequireCharacterSelected)
{
GameObject go = (GameObject)Instantiate(ContextualMenuItemPrefab);
go.transform.SetParent(gameObject.transform);

ContextMenuItem contextMenuItem = go.GetComponent<ContextMenuItem>();
ContextMenuItem contextMenuItem = Instantiate(ContextualMenuItemPrefab, gameObject.transform, false);
contextMenuItem.ContextMenu = this;
contextMenuItem.Action = contextMenuAction;
contextMenuItem.BuildInterface();
Expand Down
Loading

0 comments on commit 6180597

Please sign in to comment.