Skip to content

Commit

Permalink
Added a control for changing the visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
kesac committed Jun 18, 2024
1 parent 50f732e commit 2684a9a
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 25 deletions.
19 changes: 18 additions & 1 deletion Syllabore/Syllabore.Visualizer/MainVisualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ public partial class MainVisualizer : Node2D, ITemporalController
private int _xLeftPadding = 300; // Make room for the menu stuff
private int _xRightPadding = 100; // Ensure names fit

private Node2D _fallingNamesVisualization;

public bool IsSlowed { get; set; }
public bool IsPaused { get; set; }

public override void _Ready()
{
_fallingNamesVisualization = this.GetNode<Node2D>("FallingNamesVisualization");

_syllableGenerator = new SyllableGenerator()
.WithVowels(DefaultVowels)
.WithLeadingConsonants(DefaultLeadingConsonants)
Expand Down Expand Up @@ -130,6 +134,18 @@ public void ResumeFloaters()
this.IsPaused = false;
}

public void OnVisualizationSelectionChanged(int index)
{
if (index == 0)
{
_fallingNamesVisualization.Visible = true;
}
else
{
_fallingNamesVisualization.Visible = false;
}
}

public void GenerateName()
{
if (!this.IsPaused && !this.IsSlowed && _syllableGenerator.Vowels.Count > 0)
Expand Down Expand Up @@ -160,7 +176,8 @@ public void GenerateName()
nameLabel.MouseEntered += this.SlowDownFloaters;
nameLabel.MouseExited += this.ResumeFloaters;

this.GetTree().CurrentScene.AddChild(instance);
// this.GetTree().CurrentScene.AddChild(instance);
_fallingNamesVisualization.AddChild(instance);
}
}

Expand Down
90 changes: 66 additions & 24 deletions Syllabore/Syllabore.Visualizer/MainVisualizer.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,78 @@ color = Color(0, 0, 0, 1)
wait_time = 0.5
autostart = true

[node name="FallingNamesVisualization" type="Node2D" parent="."]

[node name="VisualizationSelectionPanel" type="Panel" parent="."]
offset_left = 20.0
offset_top = 24.0
offset_right = 289.0
offset_bottom = 124.0

[node name="Label" type="Label" parent="VisualizationSelectionPanel"]
layout_mode = 1
anchors_preset = -1
anchor_left = -0.00743494
anchor_top = 0.0159011
anchor_right = -0.00743494
anchor_bottom = 0.0159011
offset_left = 10.0
offset_top = -5.0
offset_right = 242.0
offset_bottom = 43.0
text = "Visualization"
label_settings = SubResource("LabelSettings_sy3ib")
vertical_alignment = 1
metadata/_edit_use_anchors_ = true

[node name="OptionButton" type="OptionButton" parent="VisualizationSelectionPanel"]
layout_mode = 0
offset_left = 10.0
offset_top = 53.0
offset_right = 250.0
offset_bottom = 88.0
theme_override_fonts/font = ExtResource("3_kgymp")
theme_override_font_sizes/font_size = 30
item_count = 2
selected = 0
popup/item_0/text = "Infinite Names"
popup/item_0/id = 0
popup/item_1/text = "Grid of Names"
popup/item_1/id = 1

[node name="Editor" type="Panel" parent="."]
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 13.0
offset_top = 17.0
offset_right = 282.0
offset_bottom = 770.0
offset_left = 19.0
offset_top = 131.0
offset_right = 288.0
offset_bottom = 697.0
grow_vertical = 2

[node name="Label" type="Label" parent="Editor"]
layout_mode = 1
anchors_preset = -1
anchor_left = -0.00743494
anchor_top = 0.0159011
anchor_right = -0.00743494
anchor_bottom = 0.0159011
offset_left = 10.0
offset_top = -5.0
offset_right = 242.0
offset_bottom = 43.0
text = "Graphemes"
label_settings = SubResource("LabelSettings_sy3ib")
vertical_alignment = 1
metadata/_edit_use_anchors_ = true

[node name="TrailingConsonantsPanel" parent="Editor" instance=ExtResource("2_kt3in")]
layout_mode = 1
anchors_preset = -1
anchor_left = -0.00371747
anchor_top = -0.0305445
anchor_top = -0.0340778
anchor_right = 0.996283
anchor_bottom = 0.969456
anchor_bottom = 1.14967
offset_left = 9.0
offset_top = 243.0
offset_right = 9.0
Expand All @@ -48,9 +103,9 @@ metadata/_edit_use_anchors_ = true
layout_mode = 1
anchors_preset = -1
anchor_left = -0.00371747
anchor_top = -0.0146082
anchor_top = -0.023442
anchor_right = 0.996283
anchor_bottom = 0.985392
anchor_bottom = 1.1709
offset_left = 9.0
offset_top = 155.0
offset_right = 3.0
Expand All @@ -61,27 +116,14 @@ metadata/_edit_use_anchors_ = true
layout_mode = 1
anchors_preset = -1
anchor_left = -0.00371747
anchor_top = -0.00795053
anchor_right = 0.996283
anchor_bottom = 1.18463
offset_left = 9.0
offset_top = 67.0
offset_right = 9.0
offset_bottom = -608.0
metadata/_edit_use_anchors_ = true

[node name="GraphemeSectionLabel" type="Label" parent="Editor"]
layout_mode = 1
anchors_preset = -1
anchor_left = -0.0111524
anchor_top = 0.0172643
anchor_right = -0.0111524
anchor_bottom = 0.0172643
offset_left = 10.0
offset_top = -5.0
offset_right = 242.0
offset_bottom = 43.0
text = "Graphemes"
label_settings = SubResource("LabelSettings_sy3ib")
vertical_alignment = 1
metadata/_edit_use_anchors_ = true

[connection signal="timeout" from="GenerateNamesTimer" to="." method="GenerateName"]
[connection signal="item_selected" from="VisualizationSelectionPanel/OptionButton" to="." method="OnVisualizationSelectionChanged"]

0 comments on commit 2684a9a

Please sign in to comment.