Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Visual Novel Example to Example branch #72

Draft
wants to merge 15 commits into
base: examples
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,11 @@ addons/*
!/docs/
!/docs/*
# No forget the gitbook configuration file
!.gitbook.yaml
!.gitbook.yaml

##########
# Examples
##########
# Do not forget the examples folder
!/examples/
!/examples/*
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_resource type="Resource" load_steps=12 format=2]
[gd_resource type="Resource" load_steps=17 format=2]

[ext_resource path="res://addons/event_system_plugin/resources/registered_events/_.gd" type="Script" id=1]
[ext_resource path="res://addons/event_system_plugin/events/comment.gd" type="Script" id=2]
Expand All @@ -10,8 +10,13 @@
[ext_resource path="res://addons/event_system_plugin/events/condition.gd" type="Script" id=8]
[ext_resource path="res://addons/event_system_plugin/events/show.gd" type="Script" id=9]
[ext_resource path="res://addons/event_system_plugin/events/hide.gd" type="Script" id=10]
[ext_resource path="res://addons/textalog/events/dialog/text.gd" type="Script" id=11]
[ext_resource path="res://addons/event_system_plugin/events/call_from.gd" type="Script" id=12]
[ext_resource path="res://addons/textalog/events/dialog/choice.gd" type="Script" id=13]
[ext_resource path="res://addons/textalog/events/character/change_expression.gd" type="Script" id=14]
[ext_resource path="res://addons/textalog/events/character/join.gd" type="Script" id=15]
[ext_resource path="res://addons/textalog/events/character/leave.gd" type="Script" id=16]

[resource]
script = ExtResource( 1 )
events = [ ExtResource( 3 ), ExtResource( 5 ), ExtResource( 4 ), ExtResource( 2 ), ExtResource( 6 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 10 ), ExtResource( 9 ), ExtResource( 12 ) ]
events = [ ExtResource( 3 ), ExtResource( 5 ), ExtResource( 4 ), ExtResource( 2 ), ExtResource( 6 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 10 ), ExtResource( 9 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 13 ), ExtResource( 14 ), ExtResource( 15 ), ExtResource( 16 ) ]
4 changes: 2 additions & 2 deletions addons/textalog/assets/themes/default_theme/plain_black.tres
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[ext_resource path="res://addons/textalog/assets/fonts/Poppins/godot_fonts/Poppins-Normal.tres" type="DynamicFont" id=2]

[sub_resource type="StyleBoxFlat" id=2]
[sub_resource type="StyleBoxFlat" id=7]
resource_name = "NameStyle"
content_margin_left = 16.0
content_margin_right = 16.0
Expand Down Expand Up @@ -39,5 +39,5 @@ corner_radius_bottom_left = 12
[resource]
default_font = ExtResource( 2 )
DialogNode/styles/bubble = null
DialogNode/styles/name = SubResource( 2 )
DialogNode/styles/name = SubResource( 7 )
DialogNode/styles/text = SubResource( 1 )
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions examples/VisualNovel/Backgrounds/backgroundColorForest.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/backgroundColorForest.png-381303fc1ed84ef726ff9947fb369f53.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://examples/VisualNovel/Backgrounds/backgroundColorForest.png"
dest_files=[ "res://.import/backgroundColorForest.png-381303fc1ed84ef726ff9947fb369f53.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions examples/VisualNovel/Backgrounds/backgroundColorGrass.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/backgroundColorGrass.png-593b0d7eb6130ce55ca13af8b367d76d.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://examples/VisualNovel/Backgrounds/backgroundColorGrass.png"
dest_files=[ "res://.import/backgroundColorGrass.png-593b0d7eb6130ce55ca13af8b367d76d.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
43 changes: 43 additions & 0 deletions examples/VisualNovel/Character.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
extends Control


export var main_node: NodePath
export var expression_player: NodePath
export var talk_player: NodePath

var texture

func _ready():
set_size(get_node(main_node).get_rect().size)
if is_connected("resized", self, "_on_resized"):
return
connect("resized", self, "_on_resized")


func _on_resized():
if not main_node:
push_warning("Main Node not defined on %" % self)
return
var node = get_node(main_node)
var size = node.get_rect().size
node.set_scale(Vector2(rect_size.y/size.y, rect_size.y/size.y))
node.position.x = (rect_size.x - size.x*node.scale.x)/2


func change_expression(expression: String):
if not expression_player:
push_warning("Expression Player not defined on %" % self)
return
var anim_player = get_node(expression_player)
anim_player.play(expression)


func set_talk(toggle: bool):
if not talk_player:
push_warning("Talk Player not defined on %" % self)
return
var anim_player = get_node(talk_player)
if toggle:
anim_player.play("talk")
else:
anim_player.play("RESET")
41 changes: 41 additions & 0 deletions examples/VisualNovel/DialogPiece.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[gd_scene format=2]

[node name="DialogPiece" type="PanelContainer"]
margin_right = 1024.0
margin_bottom = 78.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="HBoxContainer" type="HBoxContainer" parent="."]
margin_left = 7.0
margin_top = 7.0
margin_right = 1017.0
margin_bottom = 71.0

[node name="Avatar" type="TextureRect" parent="HBoxContainer"]
margin_right = 64.0
margin_bottom = 64.0
rect_min_size = Vector2( 64, 64 )
expand = true

[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"]
margin_left = 68.0
margin_right = 1010.0
margin_bottom = 64.0
size_flags_horizontal = 3

[node name="Name" type="Label" parent="HBoxContainer/VBoxContainer"]
margin_right = 942.0
margin_bottom = 14.0
text = "Character Name"

[node name="Dialog" type="RichTextLabel" parent="HBoxContainer/VBoxContainer"]
margin_top = 18.0
margin_right = 942.0
margin_bottom = 64.0
size_flags_horizontal = 3
size_flags_vertical = 3
bbcode_enabled = true
bbcode_text = "Text"
text = "Text"
44 changes: 44 additions & 0 deletions examples/VisualNovel/ICLogs.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
extends Control


var piece_res = preload("res://examples/VisualNovel/DialogPiece.tscn")

onready var scroll_container = $LogLayout/ScrollContainer
onready var piece_container = $LogLayout/ScrollContainer/PieceContainer
onready var log_layout = $LogLayout

func clear():
for piece in piece_container.get_children():
piece.queue_free()


func add_piece(icon: Texture, showname: String, text: String):
var piece: Control = piece_res.instance()
piece.get_node("HBoxContainer/Avatar").texture = icon
piece.get_node("HBoxContainer/VBoxContainer/Name").text = showname
piece.get_node("HBoxContainer/VBoxContainer/Dialog").bbcode_text = text
piece_container.add_child(piece)
yield(get_tree(), "idle_frame")
scroll_container.ensure_control_visible(piece)


func filter_pieces(search: String):
for piece in piece_container.get_children():
var piece_name = piece.get_node("HBoxContainer/VBoxContainer/Name").text
var piece_dialog = piece.get_node("HBoxContainer/VBoxContainer/Dialog").text

piece.set_visible(false)
if search == "" or piece_name.to_lower().find(search.to_lower()) != -1 \
or piece_dialog.to_lower().find(search.to_lower()) != -1:
piece.set_visible(true)


func _on_SearchString_text_changed(new_text: String):
filter_pieces(new_text)


func _on_Button_pressed():
log_layout.set_visible(not log_layout.visible)
if log_layout.visible:
yield(get_tree(), "idle_frame")
scroll_container.scroll_vertical = scroll_container.get_v_scrollbar().max_value
79 changes: 79 additions & 0 deletions examples/VisualNovel/ICLogs.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://examples/VisualNovel/ICLogs.gd" type="Script" id=2]

[node name="ICLogs" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
script = ExtResource( 2 )
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}

[node name="LogLayout" type="Control" parent="."]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Fade" type="ColorRect" parent="LogLayout"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
color = Color( 0, 0, 0, 0.294118 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="ScrollContainer" type="ScrollContainer" parent="LogLayout"]
anchor_left = 0.207031
anchor_top = 0.0716667
anchor_right = 0.792969
anchor_bottom = 1.0
follow_focus = true
scroll_horizontal_enabled = false
__meta__ = {
"_edit_use_anchors_": true
}

[node name="PieceContainer" type="VBoxContainer" parent="LogLayout/ScrollContainer"]
margin_right = 600.0
margin_bottom = 557.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": true
}

[node name="SearchString" type="LineEdit" parent="LogLayout"]
anchor_left = 0.207
anchor_right = 0.793
margin_left = 0.0319824
margin_right = -0.0320435
margin_bottom = 27.0
focus_mode = 1
size_flags_horizontal = 3
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Button" type="Button" parent="."]
anchor_left = 1.0
anchor_right = 1.0
margin_left = -95.0
margin_top = 10.0
margin_right = -14.0
margin_bottom = 43.0
focus_mode = 0
text = "Logs"
__meta__ = {
"_edit_use_anchors_": false
}

[connection signal="text_changed" from="LogLayout/SearchString" to="." method="_on_SearchString_text_changed"]
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]
Loading