Skip to content

Commit acc330d

Browse files
authored
Merge pull request #7 from Kersoph/p2_develop
Merge features and fixes from the P2 develop
2 parents d48129a + e412a58 commit acc330d

File tree

90 files changed

+4593
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+4593
-87
lines changed

data/core/Startup.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Godot;
2+
using System;
3+
4+
namespace Osls
5+
{
6+
public class Startup : Node
7+
{
8+
#region ==================== Fields / Properties ====================
9+
[Export] private PackedScene _mainScene;
10+
private int _initialisationStep;
11+
#endregion
12+
13+
14+
#region ==================== Public Methods ====================
15+
/// <summary>
16+
/// Add initialisation steps to the loading scene util GetTree().ChangeSceneTo() is called.
17+
/// If it takes some time create a loading bar.
18+
/// </summary>
19+
public override void _Process(float delta)
20+
{
21+
switch (_initialisationStep)
22+
{
23+
case 0:
24+
OS.WindowMaximized = true;
25+
_initialisationStep++;
26+
break;
27+
case 1:
28+
GetTree().ChangeSceneTo(_mainScene);
29+
break;
30+
}
31+
}
32+
#endregion
33+
}
34+
}

data/core/Startup.tscn

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[gd_scene load_steps=3 format=2]
2+
3+
[ext_resource path="res://data/core/Startup.cs" type="Script" id=1]
4+
[ext_resource path="res://data/core/scene_manager/Main.tscn" type="PackedScene" id=2]
5+
6+
[node name="Startup" type="Node"]
7+
script = ExtResource( 1 )
8+
_mainScene = ExtResource( 2 )
9+
10+
[node name="ColorRect" type="ColorRect" parent="."]
11+
anchor_right = 1.0
12+
anchor_bottom = 1.0
13+
mouse_default_cursor_shape = 5
14+
color = Color( 0.12549, 0.145098, 0.192157, 1 )
15+
__meta__ = {
16+
"_edit_use_anchors_": false
17+
}

data/core/landing_page/LandingPage.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ margin_bottom = 1016.0
8282
show_behind_parent = true
8383
anchor_right = 1.0
8484
anchor_bottom = 1.0
85+
mouse_filter = 2
8586
__meta__ = {
8687
"_edit_use_anchors_": false
8788
}

data/core/landing_page/LightButton.tscn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ content_margin_left = 8.0
3737
content_margin_right = 8.0
3838
content_margin_top = 8.0
3939
content_margin_bottom = 8.0
40-
bg_color = Color( 1, 1, 1, 1 )
40+
bg_color = Color( 1, 0.866667, 0.866667, 1 )
4141
border_width_left = 1
4242
border_width_top = 1
4343
border_width_right = 1
4444
border_width_bottom = 1
45-
border_color = Color( 0.627451, 0.627451, 0.627451, 1 )
45+
border_color = Color( 0.470588, 0.470588, 0.470588, 1 )
4646
anti_aliasing = false
4747

4848
[sub_resource type="StyleBoxFlat" id=5]

data/core/landing_page/lesson_source_controller/LessonControllerNode.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public void SetLessonInfo(ILessonEntity info, LessonSelectionGridNode gridContro
3535
_gridController = gridController;
3636
SetTitle(info.Title);
3737
SetStars(info.Stars);
38+
if (string.IsNullOrEmpty(info.SimulationPath))
39+
{
40+
GetNode<Button>("LessonButton").Disabled = true;
41+
GetNode<Button>("LessonButton").MouseDefaultCursorShape = CursorShape.Forbidden;
42+
}
3843
}
3944
#endregion
4045

data/core/lesson/viewer/LessonView.tscn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ margin_left = 2.0
5656
margin_top = 2.0
5757
margin_right = -2.0
5858
margin_bottom = -2.0
59+
focus_mode = 2
60+
selection_enabled = true
5961

6062
[node name="ColorRect" type="ColorRect" parent="LessonInfo"]
6163
anchor_top = 1.0

data/diagram_models/sfc/editor/2d_editor/Sfc2dEditorControl.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ public class Sfc2dEditorControl
1212
{
1313
#region ==================== Fields Properties ====================
1414
private readonly Dictionary<int, SfcPatchControl> _controlMap = new Dictionary<int, SfcPatchControl>();
15+
private bool _isEditable;
16+
17+
/// <summary>
18+
/// Returns the patch control map
19+
/// </summary>
20+
public IReadOnlyDictionary<int, SfcPatchControl> ControlMap { get { return _controlMap; } }
1521

1622
/// <summary>
1723
/// Reference patch to hold the nodes
@@ -26,10 +32,11 @@ public class Sfc2dEditorControl
2632

2733

2834
#region ==================== Public ====================
29-
public Sfc2dEditorControl(ReferenceRect referenceRect, ProcessingData data)
35+
public Sfc2dEditorControl(ReferenceRect referenceRect, ProcessingData data, bool isEditable)
3036
{
3137
ReferenceRect = referenceRect;
3238
Data = data;
39+
_isEditable = isEditable;
3340
}
3441

3542
/// <summary>
@@ -111,7 +118,7 @@ private void InitialiseFromData()
111118
IReadOnlyCollection<PatchEntity> patches = Data.SfcEntity.Patches;
112119
foreach (PatchEntity entity in patches)
113120
{
114-
SfcPatchControl control = new SfcPatchControl(entity, this);
121+
SfcPatchControl control = new SfcPatchControl(entity, this, !_isEditable);
115122
_controlMap.Add(entity.Key, control);
116123
}
117124
UpdateGrid();
@@ -122,13 +129,16 @@ private void InitialiseFromData()
122129
/// </summary>
123130
private void UpdateLogicalModel()
124131
{
125-
// We want a copy because we will add empty forward patches to the dict
126-
PatchEntity[] patches = Data.SfcEntity.Patches.ToArray();
127-
foreach (PatchEntity patch in patches)
132+
if (_isEditable)
128133
{
129-
if (patch.ContainsRelevantData())
134+
// We want a copy because we will add empty forward patches to the dict
135+
PatchEntity[] patches = Data.SfcEntity.Patches.ToArray();
136+
foreach (PatchEntity patch in patches)
130137
{
131-
EnsureNeighbours(patch);
138+
if (patch.ContainsRelevantData())
139+
{
140+
EnsureNeighbours(patch);
141+
}
132142
}
133143
}
134144
Data.StepMaster.UpdateStepNames(Data.SfcEntity);
@@ -155,7 +165,7 @@ private void EnsurePatchAt(int x, int y)
155165
{
156166
Data.SfcEntity.CreatePatchAt((short)x, (short)y);
157167
patch = Data.SfcEntity.Lookup(x, y);
158-
SfcPatchControl control = new SfcPatchControl(patch, this);
168+
SfcPatchControl control = new SfcPatchControl(patch, this, !_isEditable);
159169
_controlMap.Add(patch.Key, control);
160170
}
161171
}

data/diagram_models/sfc/editor/2d_editor/Sfc2dEditorNode.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public class Sfc2dEditorNode : Control
2323
/// <summary>
2424
/// Creates a controller and initializes the patch fields.
2525
/// </summary>
26-
public void InitializeEditor(ProcessingData data)
26+
public void InitializeEditor(ProcessingData data, bool isEditable)
2727
{
2828
_renderViewportReferenceRect = GetNode<ReferenceRect>("RenderViewportReferenceRect");
29-
Sfc2dEditorControl = new Sfc2dEditorControl(_renderViewportReferenceRect, data);
29+
Sfc2dEditorControl = new Sfc2dEditorControl(_renderViewportReferenceRect, data, isEditable);
3030
}
3131

3232
public override void _Process(float delta)
@@ -106,14 +106,30 @@ public override void _GuiInput(InputEvent @event)
106106
{
107107
if (@event.IsActionPressed("ui_translate_idle"))
108108
{
109-
_lastDragPosition = GetViewport().GetMousePosition();
110-
_isDragging = true;
109+
StartDrag();
111110
}
112111
else if (@event.IsActionReleased("ui_translate_idle"))
113112
{
114-
_isDragging = false;
113+
StopDrag();
115114
}
116115
}
116+
117+
/// <summary>
118+
/// Called if the user wants to drag the editor
119+
/// </summary>
120+
public void StartDrag()
121+
{
122+
_lastDragPosition = GetViewport().GetMousePosition();
123+
_isDragging = true;
124+
}
125+
126+
/// <summary>
127+
/// Called if the user stops to drag the editor
128+
/// </summary>
129+
public void StopDrag()
130+
{
131+
_isDragging = false;
132+
}
117133
#endregion
118134

119135

data/diagram_models/sfc/editor/2d_editor/sfc_patch/SfcPatch.tscn

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,25 @@ margin_left = -10.0
7373
margin_top = 14.0
7474
margin_bottom = 16.0
7575
color = Color( 0.705882, 0.705882, 0.705882, 1 )
76+
77+
[node name="MouseFilterEdit" type="Control" parent="."]
78+
visible = false
79+
anchor_right = 1.0
80+
anchor_bottom = 1.0
81+
mouse_filter = 1
82+
mouse_default_cursor_shape = 8
83+
__meta__ = {
84+
"_edit_lock_": true,
85+
"_edit_use_anchors_": false
86+
}
87+
88+
[node name="LineFilter" type="Control" parent="MouseFilterEdit"]
89+
anchor_right = 1.0
90+
anchor_bottom = 1.0
91+
margin_top = 70.0
92+
margin_right = 75.0
93+
mouse_filter = 1
94+
mouse_default_cursor_shape = 8
95+
__meta__ = {
96+
"_edit_lock_": true
97+
}

data/diagram_models/sfc/editor/2d_editor/sfc_patch/SfcPatchControl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ public class SfcPatchControl
3737
/// <summary>
3838
/// Constructor. It will add the patch to the 2d editor.
3939
/// </summary>
40-
public SfcPatchControl(PatchEntity data, Sfc2dEditorControl control)
40+
public SfcPatchControl(PatchEntity data, Sfc2dEditorControl control, bool setMouseFilter)
4141
{
4242
Data = data;
4343
Master = control;
4444
SfcPatchMeta = new SfcPatchMeta();
4545
Node node = ((PackedScene)GD.Load(_patchReferencePath)).Instance();
4646
SfcPatchNode = (SfcPatchNode)node;
47-
SfcPatchNode.InitializeWith(this, data);
47+
SfcPatchNode.InitializeWith(this, data, setMouseFilter);
4848
control.ReferenceRect.AddChild(SfcPatchNode);
4949
}
5050

0 commit comments

Comments
 (0)