Skip to content

Commit

Permalink
This was all intended to be part of the last commit
Browse files Browse the repository at this point in the history
My bad :(
  • Loading branch information
Jowan-Spooner committed Jun 20, 2024
1 parent 34682a0 commit 1548f67
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 41 deletions.
15 changes: 7 additions & 8 deletions addons/dialogic/Modules/Character/node_portrait_container.gd
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,14 @@ func is_container(id:Variant) -> bool:

#region DEBUG METHODS
################################################################################
# USE THIS TO DEBUG THE POSITIONS
#func _draw():
#draw_rect(Rect2(Vector2(), size), Color(1, 0.3098039329052, 1), false, 2)
#draw_string(get_theme_default_font(),get_theme_default_font().get_string_size(container_ids[0], HORIZONTAL_ALIGNMENT_LEFT, 1, get_theme_default_font_size()) , container_ids[0], HORIZONTAL_ALIGNMENT_CENTER)
#
#func _process(delta:float) -> void:
#queue_redraw()

func _draw():
draw_rect(Rect2(Vector2(), size), Color(1, 0.3098039329052, 1), false, 2)

draw_string(get_theme_default_font(),get_theme_default_font().get_string_size(container_ids[0], HORIZONTAL_ALIGNMENT_LEFT, 1, get_theme_default_font_size()) , container_ids[0], HORIZONTAL_ALIGNMENT_CENTER)


func _process(delta:float) -> void:
queue_redraw()

## Loads the debug_character with the debug_character_portrait
## Creates a holder node and applies mirror
Expand Down
19 changes: 1 addition & 18 deletions addons/dialogic/Modules/Character/subsystem_containers.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,6 @@ var transform_regex := r"(?<part>position|pos|size|siz|rotation|rot)\W*=(?<value
#region STATE
####################################################################################################

func clear_game_state(clear_flag := DialogicGameHandler.ClearFlags.FULL_CLEAR) -> void:
pass


func load_game_state(load_flag := LoadFlags.FULL_LOAD) -> void:
pass


func pause() -> void:
pass


func resume() -> void:
pass


func _ready() -> void:
pass

#endregion

Expand Down Expand Up @@ -67,6 +49,7 @@ func add_container(position_id: String, position := "", size := "") -> DialogicN
copy_container_setup(example_position, new_position)
new_position.container_ids = [position_id]
new_position.position = str_to_vector(position)-new_position._get_origin_position()
new_position.name = "Portrait_"+position_id.validate_node_name()
position_changed.emit({&'change':'added', &'container_node':new_position, &'position_id':position_id})
return new_position
return null
Expand Down
10 changes: 5 additions & 5 deletions addons/dialogic/Modules/Character/subsystem_portraits.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func load_game_state(_load_flag:=LoadFlags.FULL_LOAD) -> void:
for character_path in portraits_info:
var character_info: Dictionary = portraits_info[character_path]
var character: DialogicCharacter = load(character_path)
dialogic.PortraitContainers.load_position_container(character.get_character_name())
add_character(character, character_info.portrait, character_info.position_id)
var container := dialogic.PortraitContainers.load_position_container(character.get_character_name())
add_character(character, container, character_info.portrait, character_info.position_id)
change_character_mirror(character, character_info.get('custom_mirror', false))
change_character_z_index(character, character_info.get('z_index', 0))
change_character_extradata(character, character_info.get('extra_data', ""))
Expand Down Expand Up @@ -375,7 +375,8 @@ func join_character(character:DialogicCharacter, portrait:String, position_id:S
change_character_mirror(character, mirrored)
return

var character_node := add_character(character, portrait, position_id)
var container := dialogic.PortraitContainers.add_container(character.get_character_name())
var character_node := add_character(character, container, portrait, position_id)
if character_node == null:
return null

Expand Down Expand Up @@ -406,7 +407,7 @@ func join_character(character:DialogicCharacter, portrait:String, position_id:S
return character_node


func add_character(character:DialogicCharacter, portrait:String, position_id:String) -> Node:
func add_character(character:DialogicCharacter, container: DialogicNode_PortraitContainer, portrait:String, position_id:String) -> Node:
if is_character_joined(character):
printerr('[DialogicError] Cannot add a already joined character. If this is intended call _create_character_node manually.')
return null
Expand All @@ -420,7 +421,6 @@ func add_character(character:DialogicCharacter, portrait:String, position_id:St
printerr('[DialogicError] Cannot call add_portrait() with null character.')
return null

var container := dialogic.PortraitContainers.add_container(character.get_character_name())
var character_node := _create_character_node(character, container)

if character_node == null:
Expand Down
4 changes: 2 additions & 2 deletions addons/dialogic/Modules/Clear/event_clear.gd
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ func _execute() -> void:
if step_by_step: await dialogic.get_tree().create_timer(final_time).timeout

if clear_style and dialogic.has_subsystem('Styles'):
dialogic.Styles.load_style()
dialogic.Styles.change_style()

if clear_portrait_positions and dialogic.has_subsystem('Portraits'):
dialogic.Portraits.reset_all_portrait_positions()
dialogic.PortraitContainers.reset_all_containers()

finish()

Expand Down
2 changes: 1 addition & 1 deletion addons/dialogic/Modules/Style/event_style.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var style_name: String = ""
################################################################################

func _execute() -> void:
dialogic.Styles.load_style(style_name)
dialogic.Styles.change_style(style_name)
# we need to wait till the new layout is ready before continuing
await dialogic.get_tree().process_frame
finish()
Expand Down
22 changes: 15 additions & 7 deletions addons/dialogic/Modules/Style/subsystem_styles.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ signal style_changed(info:Dictionary)
#region STATE
####################################################################################################

func clear_game_state(_clear_flag:=DialogicGameHandler.ClearFlags.FULL_CLEAR) -> void:
func clear_game_state(_clear_flag := DialogicGameHandler.ClearFlags.FULL_CLEAR) -> void:
pass


func load_game_state(load_flag:=LoadFlags.FULL_LOAD) -> void:
func load_game_state(load_flag := LoadFlags.FULL_LOAD) -> void:
if load_flag == LoadFlags.ONLY_DNODES:
return
load_style(dialogic.current_state_info.get('style', ''))
Expand All @@ -23,7 +23,15 @@ func load_game_state(load_flag:=LoadFlags.FULL_LOAD) -> void:
#region MAIN METHODS
####################################################################################################

func load_style(style_name:="", parent:Node = null, is_base_style:=true) -> Node:
## This helper method calls load_style, but with the [parameter state_reload] as true,
## which is commonly wanted if you expect a game to already be in progress.
func change_style(style_name := "", is_base_style := true) -> Node:
return load_style(style_name, null, is_base_style, true)

## Loads a style. Consider using the simpler [method change_style] if you want to change the style while another style is already in use.
## [br] If [param state_reload] is true, the current state will be loaded into a new layout scenes nodes.
## That should not be done before calling start() or load() as it would be unnecessary or cause double-loading.
func load_style(style_name := "", parent: Node = null, is_base_style := true, state_reload := false) -> Node:
var style := DialogicUtil.get_style_by_name(style_name)

var signal_info := {'style':style_name}
Expand Down Expand Up @@ -59,10 +67,10 @@ func load_style(style_name:="", parent:Node = null, is_base_style:=true) -> Node
previous_layout.get_parent().remove_child(previous_layout)
previous_layout.queue_free()


# if this is another style:
var new_layout := create_layout(style, parent)
new_layout.ready.connect(reload_current_info_into_new_style)
if state_reload:
new_layout.ready.connect(reload_current_info_into_new_style)

style_changed.emit(signal_info)

Expand All @@ -71,7 +79,7 @@ func load_style(style_name:="", parent:Node = null, is_base_style:=true) -> Node

## Method that adds a layout scene with all the necessary layers.
## The layout scene will be added to the tree root and returned.
func create_layout(style:DialogicStyle, parent:Node = null) -> DialogicLayoutBase:
func create_layout(style: DialogicStyle, parent: Node = null) -> DialogicLayoutBase:

# Load base scene
var base_scene: DialogicLayoutBase
Expand Down Expand Up @@ -146,7 +154,7 @@ func get_layout_node() -> Node:


## Similar to get_tree().get_first_node_in_group('group_name') but filtered to the active layout node subtree
func get_first_node_in_layout(group_name : String) -> Node:
func get_first_node_in_layout(group_name: String) -> Node:
var layout_node := get_layout_node()
if null == layout_node:
return null
Expand Down

0 comments on commit 1548f67

Please sign in to comment.