Skip to content

Commit

Permalink
dialog_box_modify
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy260700 committed Jan 4, 2021
1 parent ea5e3eb commit 29302d9
Show file tree
Hide file tree
Showing 12 changed files with 235 additions and 16 deletions.
Binary file added assets/dialogue_system/next.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions assets/dialogue_system/next.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/next.png-688a916dc919a8216008c3afdd09f990.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/dialogue_system/next.png"
dest_files=[ "res://.import/next.png-688a916dc919a8216008c3afdd09f990.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Binary file not shown.
4 changes: 4 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ config/name="Productathon"
run/main_scene="res://Player_s.tscn"
config/icon="res://icon.png"

[autoload]

ProgressManager="*res://scenes/ProgressManager.tscn"

[rendering]

quality/driver/driver_name="GLES2"
Expand Down
15 changes: 15 additions & 0 deletions resources/dialogue/story.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,20 @@
"text": "‘I want the design at any cost ! Any cost...This has to be done in utmost silence and I don’t want too many people spoiling the mission…this man knows all about their language, and almost all that has to be done, take good care of him and you have to do everything else by yourself ! Now leave…'",
"type":"assertive",
"character": "Boss"
},
"4" : {
"text": "‘Listen boy…they speak the beautiful language of Sanskrit…and to succeed in what’s laying ahead, you have to learn it….you need to learn Sanskrit’",
"type":"assertive",
"character":"the old man"
},
"5" : {
"text": "but how ?",
"type":"assertive",
"character": "you"
},
"6" : {
"text": "‘The best way to learn a language is to be where it is spoken….to listen what’s spoken…but there’s some basics I’ll tell you first’",
"type": "assertive",
"character":"the old man"
}
}
1 change: 1 addition & 0 deletions resources/script/DialogueLoader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ func get_dialogue() -> Dictionary:
return dialogue

func set_dialogue_file_path(path: String) -> void:
print(path)
assert(path.ends_with(".json"))
dialogue_file_path = path
16 changes: 16 additions & 0 deletions resources/script/objective.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extends Node


# Declare member variables here. Examples:
var objective_count = 0
# var b = "text"


# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
9 changes: 3 additions & 6 deletions scenes/dialog.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=5 format=2]

[ext_resource path="res://assets/dialogue_system/next-indicator.png" type="Texture" id=1]
[ext_resource path="res://resources/script/dialog.gd" type="Script" id=2]
[ext_resource path="res://assets/dialogue_system/next.png" type="Texture" id=1]
[ext_resource path="res://scenes/DialogueLoader.tscn" type="PackedScene" id=3]
[ext_resource path="res://assets/dialogue_Ui/paper_hor.png" type="Texture" id=4]
[ext_resource path="res://scenes/dialogue_controller.gd" type="Script" id=5]
Expand All @@ -18,11 +17,9 @@ margin_left = -512.0
margin_top = -600.0
margin_right = 512.0
margin_bottom = 0.000427246
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
dialogue_file_path = "res://resources/dialogue/first.json"

[node name="DialogBox" type="Control" parent="DialogueSystem"]
anchor_left = 0.5
Expand Down Expand Up @@ -101,4 +98,4 @@ __meta__ = {
[node name="Tween" type="Tween" parent="DialogueSystem"]

[node name="DialogueLoader" parent="DialogueSystem" instance=ExtResource( 3 )]
[connection signal="button_down" from="DialogueSystem/DialogBox/box/Button" to="DialogueSystem" method="_on_Button_button_down"]
[connection signal="button_down" from="DialogueSystem/DialogBox/box/Button" to="." method="_on_Button_button_down"]
103 changes: 103 additions & 0 deletions scenes/dialog_starting.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
[gd_scene load_steps=5 format=2]

[ext_resource path="res://assets/dialogue_system/next.png" type="Texture" id=1]
[ext_resource path="res://scenes/DialogueLoader.tscn" type="PackedScene" id=3]
[ext_resource path="res://assets/dialogue_Ui/paper_hor.png" type="Texture" id=4]
[ext_resource path="res://scenes/dialogue_controller.gd" type="Script" id=5]

[node name="CanvasLayer" type="CanvasLayer"]
script = ExtResource( 5 )
dialogue_file_path = "res://resources/dialogue/story.json"

[node name="DialogueSystem" type="Control" parent="."]
anchor_left = 0.499001
anchor_top = 1.0
anchor_right = 0.499001
anchor_bottom = 1.0
margin_left = -512.0
margin_top = -600.653
margin_right = 512.0
margin_bottom = -0.652954
__meta__ = {
"_edit_use_anchors_": false
}

[node name="DialogBox" type="Control" parent="DialogueSystem"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -20.0
margin_top = -20.0001
margin_right = 20.0
margin_bottom = 20.0001
__meta__ = {
"_edit_use_anchors_": false
}

[node name="box" type="TextureRect" parent="DialogueSystem/DialogBox"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -305.5
margin_top = -176.5
margin_right = 305.5
margin_bottom = 176.5
texture = ExtResource( 4 )
expand = true
stretch_mode = 1
__meta__ = {
"_edit_use_anchors_": false
}

[node name="dialogue" type="Label" parent="DialogueSystem/DialogBox/box"]
anchor_left = -0.763288
anchor_top = -1.09389
anchor_right = -0.102274
anchor_bottom = -0.46889
margin_left = 600.0
margin_top = 446.4
margin_right = 640.0
margin_bottom = 460.4
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "Dialogue"
valign = 1
autowrap = true
__meta__ = {
"_edit_use_anchors_": true
}

[node name="speaker" type="Label" parent="DialogueSystem/DialogBox/box"]
anchor_left = -0.944145
anchor_top = -1.00031
anchor_right = -0.874235
anchor_bottom = -0.937808
margin_left = 600.0
margin_top = 446.4
margin_right = 640.0
margin_bottom = 460.4
custom_colors/font_color = Color( 0, 0, 0, 1 )
text = "Speaker"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": true
}

[node name="Button" type="Button" parent="DialogueSystem/DialogBox/box"]
margin_left = 479.425
margin_top = 282.982
margin_right = 521.425
margin_bottom = 318.982
icon = ExtResource( 1 )
flat = true
expand_icon = true
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Tween" type="Tween" parent="DialogueSystem"]

[node name="DialogueLoader" parent="DialogueSystem" instance=ExtResource( 3 )]
[connection signal="button_down" from="DialogueSystem/DialogBox/box/Button" to="." method="_on_Button_button_down"]
50 changes: 45 additions & 5 deletions scenes/dialogue_controller.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,55 @@ extends CanvasLayer
# var a: int = 2
# var b: String = "text"
onready var system = $DialogueSystem
export (String, FILE, "*.json") var dialogue_file_path: String
export (String, FILE, "*.json") var dialogue_file_path: String = "" setget set_dialogue_file_path
signal completed

# Called when the node enters the scene tree for the first time.
onready var dialogue = $DialogueSystem/DialogBox/box/dialogue
onready var speaker = $DialogueSystem/DialogBox/box/speaker
onready var box = $DialogueSystem/DialogBox/box


var index = 0
var loadedDialogue: Dictionary

onready var dialogLoader: DialogueLoader = $DialogueSystem/DialogueLoader
onready var tween: Tween = $DialogueSystem/Tween

var state: Dictionary = {} setget set_state

func set_state(new_state: Dictionary) -> void:
state = new_state

func process_state(new_state: Dictionary) -> void:
speaker.text = new_state["character"]+ ":"
dialogue.text = new_state["text"]
tween.interpolate_property(dialogue, "visible_characters", 0, dialogue.text.length(), 0.08 * dialogue.text.length())
tween.start()

func _ready() -> void:
system.dialogue_file_path = dialogue_file_path
if dialogue_file_path != "":
loadedDialogue = dialogLoader.load_dialogue()

func _on_Button_button_down() -> void:
tween.stop(dialogue)
dialogue.visible_characters = dialogue.text.length()
index += 1
if index < loadedDialogue.size():
set_state(loadedDialogue[String(index)])
process_state(state)
else:
system.set_visible(false)
emit_signal("completed")

func start() -> void:
system.start()
loadedDialogue = dialogLoader.load_dialogue()
system.set_visible(true)
set_state(loadedDialogue[String(index)])
process_state(state)

func set_dialogue_file_path(path: String) -> void:
dialogue_file_path = path
yield($DialogueSystem/DialogueLoader, "ready")
$DialogueSystem/DialogueLoader.set_dialogue_file_path(dialogue_file_path)

func _on_DialogueSystem_completed() -> void:
emit_signal("completed")
9 changes: 7 additions & 2 deletions scenes/main.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends Node2D

onready var system = $DialogueSystem

onready var system = $"initial story"
onready var system_main = $"main_dialogue"
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
Expand All @@ -16,3 +16,8 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass


func _on_initial_story_completed():
system_main.dialogue_file_path = "res://resources/dialogue/lesson1.json"
system_main.start()
10 changes: 7 additions & 3 deletions scenes/main.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=42 format=2]
[gd_scene load_steps=43 format=2]

[ext_resource path="res://resources/tilesets/stone_walls_and_floors.tres" type="TileSet" id=1]
[ext_resource path="res://resources/characters/Player.tscn" type="PackedScene" id=2]
Expand Down Expand Up @@ -38,17 +38,20 @@
[ext_resource path="res://resources/school/platform.tscn" type="PackedScene" id=36]
[ext_resource path="res://resources/speaking_characters/group 1.tscn" type="PackedScene" id=37]
[ext_resource path="res://resources/speaking_characters/group 2.tscn" type="PackedScene" id=38]
[ext_resource path="res://scenes/dialog.tscn" type="PackedScene" id=39]
[ext_resource path="res://scenes/dialog_starting.tscn" type="PackedScene" id=39]
[ext_resource path="res://scenes/main.gd" type="Script" id=40]
[ext_resource path="res://resources/transition/transition_F_T.tscn" type="PackedScene" id=41]
[ext_resource path="res://scenes/dialog.tscn" type="PackedScene" id=42]

[node name="Node2D" type="Node2D"]
script = ExtResource( 40 )
__meta__ = {
"_edit_horizontal_guides_": [ ]
}

[node name="DialogueSystem" parent="." instance=ExtResource( 39 )]
[node name="initial story" parent="." instance=ExtResource( 39 )]

[node name="main_dialogue" parent="." instance=ExtResource( 42 )]

[node name="dirt" type="TileMap" parent="."]
mode = 1
Expand Down Expand Up @@ -897,4 +900,5 @@ position = Vector2( 3388.58, -6526.62 )
[node name="Area2D" parent="." instance=ExtResource( 41 )]
position = Vector2( 6916.3, 5517.02 )
rotation = 1.0472
[connection signal="completed" from="initial story" to="." method="_on_initial_story_completed"]
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

0 comments on commit 29302d9

Please sign in to comment.