Skip to content

Commit

Permalink
improve styling of rounded sample views
Browse files Browse the repository at this point in the history
  • Loading branch information
dogboydog committed Nov 25, 2023
1 parent 6e15e03 commit 85a77f3
Show file tree
Hide file tree
Showing 18 changed files with 408 additions and 307 deletions.
2 changes: 1 addition & 1 deletion Samples/MarkupPalette/PaletteSample.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://uxc1jm6ayoar"]

[ext_resource type="PackedScene" uid="uid://bv42g323prh5f" path="res://addons/YarnSpinner-Godot/Scenes/DefaultDialogueSystem.tscn" id="1_luv5t"]
[ext_resource type="Resource" uid="uid://7y2xm4f22ep5" path="res://Samples/MarkupPalette/Palette.yarnproject" id="2_yfv6n"]
[ext_resource type="Resource" uid="uid://374uxyocig3s" path="res://Samples/MarkupPalette/Palette.yarnproject" id="2_yfv6n"]
[ext_resource type="Resource" uid="uid://c631us202ijmk" path="res://Samples/MarkupPalette/example_markup_palette.tres" id="3_1wwmk"]
[ext_resource type="Script" path="res://Samples/ReturnOnComplete.cs" id="4_q6j15"]

Expand Down
2 changes: 1 addition & 1 deletion Samples/RoundedViews/RoundedDialogue.yarn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Alice: This is a quick sample showing off the alternative prefabs.
Bob: Alternative prefabs?
Alice: Yes, notice how everything is more rounded?
Bob: ah so how is this done?
Alice: we use a 9-sliced image for the various pieces.
Alice: we use a StyleBox with texture margins for the various pieces. Then if the text gets way longer, that image expands too. The text can be really really really really really really really long and it will expand.
Bob: is there any code changes?
Alice: nope
Alice: any other questions?
Expand Down
6 changes: 4 additions & 2 deletions Samples/RoundedViews/RoundedSample.tscn
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
[gd_scene load_steps=3 format=3 uid="uid://d1q6uujk0isnq"]

[ext_resource type="PackedScene" uid="uid://dqe5yshlcmnpg" path="res://addons/YarnSpinner-Godot/Scenes/RoundedDialogueSystem.tscn" id="1_e1fcx"]
[ext_resource type="Resource" uid="uid://l42klvikwhmy" path="res://Samples/RoundedViews/Rounded.yarnproject" id="2_s6ssf"]
[ext_resource type="Resource" uid="uid://crbfo1tue0g06" path="res://Samples/RoundedViews/Rounded.yarnproject" id="2_s6ssf"]

[node name="RoundedSample" type="Node2D"]

[node name="RoundedYarnSpinnerCanvasLayer" parent="." instance=ExtResource("1_e1fcx")]

[node name="DialogueRunner" parent="RoundedYarnSpinnerCanvasLayer" index="0"]
yarnProject = ExtResource("2_s6ssf")
startNode = "Start"
startAutomatically = true

[node name="LineView" parent="RoundedYarnSpinnerCanvasLayer" index="2" node_paths=PackedStringArray("continueButton")]
continueButton = NodePath("ViewControl/LineText/LineBubble/ContinueButton")

[editable path="RoundedYarnSpinnerCanvasLayer"]
7 changes: 6 additions & 1 deletion Samples/SampleEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public partial class SampleEntryPoint : CanvasLayer
[Export] private Button _visualNovelButton;
[Export] private Button _markupPaletteButton;
[Export] private Button _pausingTypewriterButton;

[Export] private Button _roundedViewsButton;

/// <summary>
/// Resource path to the packed scene of entry point scene
/// </summary>
Expand All @@ -31,7 +32,11 @@ public override void _Ready()
);
_pausingTypewriterButton.Pressed += () => LoadSample(
"res://Samples/PausingTypewriter/PauseSample.tscn"
);
_roundedViewsButton.Pressed += () => LoadSample(
"res://Samples/RoundedViews/RoundedSample.tscn"
);

_spaceButton.GrabFocus();
}

Expand Down
24 changes: 23 additions & 1 deletion Samples/SampleEntryPoint.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
[ext_resource type="Theme" uid="uid://b2mp0b1wvnu8s" path="res://Samples/sample_default_theme.tres" id="2"]
[ext_resource type="Texture2D" uid="uid://pbrr5yyepbx8" path="res://addons/YarnSpinner-Godot/Editor/Icons/YarnSpinnerLogo.png" id="3_bcudv"]

[node name="SampleEntryPoint" type="CanvasLayer" node_paths=PackedStringArray("_spaceButton", "_visualNovelButton", "_markupPaletteButton", "_pausingTypewriterButton")]
[node name="SampleEntryPoint" type="CanvasLayer" node_paths=PackedStringArray("_spaceButton", "_visualNovelButton", "_markupPaletteButton", "_pausingTypewriterButton", "_roundedViewsButton")]
script = ExtResource("1")
_spaceButton = NodePath("HBoxContainer/VBoxContainer/Space")
_visualNovelButton = NodePath("HBoxContainer/VBoxContainer2/Visual Novel")
_markupPaletteButton = NodePath("HBoxContainer/VBoxContainer3/MarkupPalette")
_pausingTypewriterButton = NodePath("HBoxContainer/VBoxContainer4/PausingTypewriter")
_roundedViewsButton = NodePath("HBoxContainer/VBoxContainer5/RoundedViews")

[node name="ColorRect" type="ColorRect" parent="."]
anchors_preset = 15
Expand Down Expand Up @@ -143,3 +144,24 @@ theme_override_font_sizes/normal_font_size = 28
bbcode_enabled = true
text = "Pausing at specific points while revealing your dialogue text"
scroll_active = false

[node name="VBoxContainer5" type="VBoxContainer" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3

[node name="RoundedViews" type="Button" parent="HBoxContainer/VBoxContainer5"]
custom_minimum_size = Vector2(180, 100)
layout_mode = 2
theme = ExtResource("2")
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 5
theme_override_font_sizes/font_size = 27
text = "Rounded Views"

[node name="features" type="RichTextLabel" parent="HBoxContainer/VBoxContainer5"]
layout_mode = 2
size_flags_vertical = 3
theme_override_font_sizes/normal_font_size = 28
bbcode_enabled = true
text = "Alternate dialogue UI style"
scroll_active = false
1 change: 0 additions & 1 deletion addons/YarnSpinner-Godot/Editor/YarnEditorUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public static void CreateYarnProject(string projectPath)
public static void CreateMarkupPalette(string palettePath)
{
var newPalette = new MarkupPalette();

var absPath = ProjectSettings.GlobalizePath(palettePath);
newPalette.ResourceName = Path.GetFileNameWithoutExtension(absPath);
newPalette.ResourcePath = palettePath;
Expand Down
7 changes: 5 additions & 2 deletions addons/YarnSpinner-Godot/Editor/YarnImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ public override string _GetVisibleName()
return "Yarn Script";
}


public override string _GetSaveExtension() => "tres";

public override string _GetResourceType()
{
var a = new Array();

return "Resource";
}

Expand Down Expand Up @@ -144,8 +147,8 @@ private void ImportYarn(string assetPath)
else
{
// trigger update of the yarn project
// var godotProject = ResourceLoader.Load<YarnProject>(projectPath);
// YarnProjectEditorUtility.UpdateYarnProject(godotProject);
var godotProject = ResourceLoader.Load<YarnProject>(projectPath);
YarnProjectEditorUtility.UpdateYarnProject(godotProject);
}
}
}
Expand Down
87 changes: 54 additions & 33 deletions addons/YarnSpinner-Godot/Editor/YarnProjectInspectorPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ namespace YarnSpinnerGodot.Editor
public partial class YarnProjectInspectorPlugin : EditorInspectorPlugin
{
public EditorInterface editorInterface;
private Button _recompileButton;
private Button _addTagsButton;
private Button _updateLocalizationsButton;

private YarnCompileErrorsPropertyEditor _compileErrorsPropertyEditor;
private ScrollContainer _parseErrorControl;
private YarnProject _project;
Expand Down Expand Up @@ -58,6 +56,8 @@ public override bool _ParseProperty(GodotObject @object, Variant.Type type, stri
nameof(YarnProject.IsSuccessfullyParsed),
nameof(YarnProject.CompiledYarnProgramBase64),
nameof(YarnProject.baseLocalization),
nameof(YarnProject.ImportPath),
nameof(YarnProject.JSONProjectPath),
// can't use nameof for private fields here
"_baseLocalizationJSON",
"_lineMetadataJSON",
Expand Down Expand Up @@ -171,40 +171,29 @@ public override void _ParseBegin(GodotObject @object)
try
{
_project = (YarnProject) @object;
_project.JSONProject = Yarn.Compiler.Project.LoadFromFile(ProjectSettings.GlobalizePath(_project.JSONProjectPath));

if (IsInstanceValid(_recompileButton))
{
_recompileButton.QueueFree();
}

_recompileButton = new Button();
_recompileButton.Text = "Re-compile Scripts in Project";
_recompileButton.Connect("pressed", Callable.From(() => OnRecompileClicked(_project)));
AddCustomControl(_recompileButton);

if (IsInstanceValid(_addTagsButton))
using (var recompileButton = new Button())
{
_addTagsButton.QueueFree();
recompileButton.Text = "Re-compile Scripts in Project";
recompileButton.Connect("pressed", Callable.From(() => OnRecompileClicked(_project)));
AddCustomControl(recompileButton);
}

_addTagsButton = new Button();
var addTagsButton = new Button();
addTagsButton.Text = "Add Line Tags to Scripts";
addTagsButton.Connect("pressed", Callable.From(() => OnAddTagsClicked(_project)));
AddCustomControl(addTagsButton);


_addTagsButton.Text = "Add Line Tags to Scripts";
_addTagsButton.Connect("pressed", Callable.From(() => OnAddTagsClicked(_project)));
AddCustomControl(_addTagsButton);

if (IsInstanceValid(_updateLocalizationsButton))
{
_updateLocalizationsButton.QueueFree();
}

_updateLocalizationsButton = new Button();
var updateLocalizationsButton = new Button();

var sourceScripts = _project.JSONProject.SourceFiles.ToList();
_updateLocalizationsButton.Text = "Update Localizations";
_updateLocalizationsButton.TooltipText = "Update Localization CSV and Godot .translation Files";
_updateLocalizationsButton.Connect("pressed", new Callable(this, nameof(OnUpdateLocalizationsClicked)));
AddCustomControl(_updateLocalizationsButton);
updateLocalizationsButton.Text = "Update Localizations";
updateLocalizationsButton.TooltipText = "Update Localization CSV and Godot .translation Files";
updateLocalizationsButton.Connect("pressed", new Callable(this, nameof(OnUpdateLocalizationsClicked)));
AddCustomControl(updateLocalizationsButton);

var scriptPatternsGrid = new GridContainer
{
Expand Down Expand Up @@ -301,21 +290,22 @@ public override void _ParseBegin(GodotObject @object)
_sourceScriptsListLabel = new RichTextLabel
{
SizeFlagsHorizontal = Control.SizeFlags.ExpandFill,
SizeFlagsVertical = Control.SizeFlags.ExpandFill
SizeFlagsVertical = Control.SizeFlags.ExpandFill,
};
_sourceScriptsListLabel.CustomMinimumSize = new Vector2(0, scriptAreaHeight);
RenderSourceScriptsList(_project);
AddCustomControl(_sourceScriptsListLabel);

var localeGrid = new GridContainer{SizeFlagsHorizontal = Control.SizeFlags.ExpandFill};
var localeGrid = new GridContainer {SizeFlagsHorizontal = Control.SizeFlags.ExpandFill};
localeGrid.Columns = 3;

var label = new Label {Text = "Localization CSVs"};
localeGrid.AddChild(label);

var textEntry = new LineEdit
{
PlaceholderText = "locale code"
PlaceholderText = "locale code",
SizeFlagsHorizontal = Control.SizeFlags.ExpandFill,
};
var addButton = new Button {Text = "Add"};
SaveNewLocaleCode("", addButton);
Expand All @@ -337,7 +327,7 @@ public override void _ParseBegin(GodotObject @object)
picker.SizeFlagsVertical = Control.SizeFlags.ExpandFill;
var pathLabel = new Label
{
Text = locale.Value.Strings,
Text = locale.Value.Strings,
SizeFlagsVertical = Control.SizeFlags.ExpandFill,
AutowrapMode = TextServer.AutowrapMode.Arbitrary
};
Expand All @@ -360,6 +350,37 @@ public override void _ParseBegin(GodotObject @object)
}

AddCustomControl(localeGrid);

var baseLocaleRow = new HBoxContainer
{
SizeFlagsHorizontal = Control.SizeFlags.ExpandFill,
};
baseLocaleRow.AddChild(new Label {Text = "Base language"});

var baseLocaleInput = new LineEdit
{
Text = _project.JSONProject.BaseLanguage,
SizeFlagsHorizontal = Control.SizeFlags.ExpandFill
};
baseLocaleRow.AddChild(baseLocaleInput);
var changeBaseLocaleButton = new Button {Text = "Change"};
baseLocaleInput.TextChanged += (newText) =>
{
changeBaseLocaleButton.Disabled = string.IsNullOrWhiteSpace(newText);
};
changeBaseLocaleButton.Pressed += () =>
{
if (!IsInstanceValid(_project))
{
return;
}

_project.JSONProject.BaseLanguage = baseLocaleInput.Text.Trim();
_project.JSONProject.SaveToFile(_project.JSONProject.Path);
editorInterface.GetResourceFilesystem().ScanSources();
};
baseLocaleRow.AddChild(changeBaseLocaleButton);
AddCustomControl(baseLocaleRow);
}
catch (Exception e)
{
Expand Down
Loading

0 comments on commit 85a77f3

Please sign in to comment.