Skip to content

Commit

Permalink
Rewiring of new GraphemeEditor capabilities with the visualizer's Nam…
Browse files Browse the repository at this point in the history
…eGenerator
  • Loading branch information
kesac committed Jun 16, 2024
1 parent abb0197 commit 5d21276
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
36 changes: 27 additions & 9 deletions Syllabore/Syllabore.Visualizer/MainVisualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,52 @@ public void InitializeEditorTextValues()
leadingConsonantPanel.LabelText = "Leading Consonants";
leadingConsonantPanel.Text = leadingConsonants;
leadingConsonantPanel.Probability = _syllableGenerator.Probability.ChanceLeadingConsonantExists.Value;
leadingConsonantPanel.Enabled = true;

var vowelPanel = this.GetNode<GraphemeEditor>("Editor/VowelsPanel");
vowelPanel.LabelText = "Vowels";
vowelPanel.Text = vowels;
vowelPanel.Probability = _syllableGenerator.Probability.ChanceVowelExists.Value;
vowelPanel.Enabled = true;

var trailingConsonantPanel = this.GetNode<GraphemeEditor>("Editor/TrailingConsonantsPanel");
trailingConsonantPanel.LabelText = "Trailing Consonants";
trailingConsonantPanel.Text = trailingConsonants;
trailingConsonantPanel.Probability = _syllableGenerator.Probability.ChanceTrailingConsonantExists.Value;
trailingConsonantPanel.Enabled = true;

}

public void RefreshSyllableGenerator()
{
var vowels = this.GetNode<GraphemeEditor>("Editor/VowelsPanel").Text;
var leadingConsonants = this.GetNode<GraphemeEditor>("Editor/LeadingConsonantsPanel").Text;
var trailingConsonants = this.GetNode<GraphemeEditor>("Editor/TrailingConsonantsPanel").Text;
var vowels = this.GetNode<GraphemeEditor>("Editor/VowelsPanel");
var leadingConsonants = this.GetNode<GraphemeEditor>("Editor/LeadingConsonantsPanel");
var trailingConsonants = this.GetNode<GraphemeEditor>("Editor/TrailingConsonantsPanel");

_syllableGenerator = new SyllableGenerator()
.WithVowels(vowels)
.WithLeadingConsonants(leadingConsonants)
.WithTrailingConsonants(trailingConsonants)
.AllowEmptyStrings(true);

_syllableGenerator.Probability.ChanceLeadingConsonantExists = this.GetNode<GraphemeEditor>("Editor/LeadingConsonantsPanel").Probability;
_syllableGenerator.Probability.ChanceVowelExists = this.GetNode<GraphemeEditor>("Editor/VowelsPanel").Probability;
_syllableGenerator.Probability.ChanceTrailingConsonantExists = this.GetNode<GraphemeEditor>("Editor/TrailingConsonantsPanel").Probability;
if (vowels.Enabled)
{
_syllableGenerator.WithVowels(vowels.Text);
_syllableGenerator.Probability.ChanceVowelExists = this.GetNode<GraphemeEditor>("Editor/VowelsPanel").Probability;
}
else
{
_syllableGenerator.WithVowels(string.Empty);
}

if (leadingConsonants.Enabled)
{
_syllableGenerator.WithLeadingConsonants(leadingConsonants.Text);
_syllableGenerator.Probability.ChanceLeadingConsonantExists = this.GetNode<GraphemeEditor>("Editor/LeadingConsonantsPanel").Probability;
}

if (trailingConsonants.Enabled)
{
_syllableGenerator.WithTrailingConsonants(trailingConsonants.Text);
_syllableGenerator.Probability.ChanceTrailingConsonantExists = this.GetNode<GraphemeEditor>("Editor/TrailingConsonantsPanel").Probability;
}

_nameGenerator = new NameGenerator(_syllableGenerator)
.UsingSyllableCount(2, 3);
Expand Down
10 changes: 8 additions & 2 deletions Syllabore/Syllabore.Visualizer/MainVisualizer.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[gd_scene load_steps=4 format=3 uid="uid://dvet30uohxhwh"]
[gd_scene load_steps=5 format=3 uid="uid://dvet30uohxhwh"]

[ext_resource type="Script" path="res://MainVisualizer.cs" id="1_42c8l"]
[ext_resource type="PackedScene" uid="uid://dfh0hshtdjms1" path="res://GraphemeEditor.tscn" id="2_kt3in"]
[ext_resource type="FontFile" uid="uid://dpthqbkpqte48" path="res://Fonts/Kenney Pixel.ttf" id="3_kgymp"]

[sub_resource type="LabelSettings" id="LabelSettings_sy3ib"]
font_size = 30
font = ExtResource("3_kgymp")
font_size = 40

[node name="MainVisualizer" type="Node2D"]
script = ExtResource("1_42c8l")
Expand Down Expand Up @@ -33,7 +35,9 @@ grow_vertical = 2
layout_mode = 1
anchors_preset = -1
anchor_left = -0.00371747
anchor_top = -0.0305445
anchor_right = 0.996283
anchor_bottom = 0.969456
offset_left = 9.0
offset_top = 243.0
offset_right = 9.0
Expand All @@ -44,7 +48,9 @@ metadata/_edit_use_anchors_ = true
layout_mode = 1
anchors_preset = -1
anchor_left = -0.00371747
anchor_top = -0.0146082
anchor_right = 0.996283
anchor_bottom = 0.985392
offset_left = 9.0
offset_top = 155.0
offset_right = 3.0
Expand Down

0 comments on commit 5d21276

Please sign in to comment.