ESC compiler rewrite

Splits the former ESC_Runner and ESC_Level_Runner into multiple dedicated managers. 
Authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
Dennis Ploeger
2021-06-04 16:12:42 +02:00
committed by GitHub
parent f069ab2ffd
commit 746a724f5a
115 changed files with 4740 additions and 2584 deletions

View File

@@ -19,7 +19,7 @@ font = ExtResource( 2 )
margin_left = 20.0
margin_top = 20.0
margin_right = 1280.0
margin_bottom = 800.0
margin_bottom = 900.0
scroll_horizontal_enabled = false
__meta__ = {
"_edit_use_anchors_": false

View File

@@ -2,8 +2,23 @@ extends Control
func _ready():
escoria.esc_level_runner.set_sound_state(["bg_music",
"res://game/sfx/Game-Menu_Looping.mp3", true])
var event = ESCEvent.new(":music")
event.statements.append(
ESCCommand.new(
"set_sound_state bg_music res://game/sfx/Game-Menu_Looping.mp3 true"
)
)
escoria.event_manager.queue_event(event)
var rc = yield(event, "finished")
if rc != ESCExecution.RC_OK:
escoria.logger.report_errors(
"main_menu: Can't start menu music",
[
"set_sound_state returned %d" % rc
]
)
return false
func _on_continue_pressed():

View File

@@ -15,21 +15,21 @@ func _on_language_input(event : InputEvent, language : String):
if event.is_pressed():
TranslationServer.set_locale(language)
escoria.settings["text_lang"] = language
escoria.esc_runner.save_data.save_settings(escoria.settings, null)
escoria.save_data.save_settings(escoria.settings, null)
func _on_sound_volume_changed(value):
escoria.settings["sfx_volume"] = value
escoria.esc_runner.save_data.save_settings(escoria.settings, null)
escoria.save_data.save_settings(escoria.settings, null)
escoria._on_settings_loaded(escoria.settings)
func _on_music_volume_changed(value):
escoria.settings["music_volume"] = value
escoria.esc_runner.save_data.save_settings(escoria.settings, null)
escoria.save_data.save_settings(escoria.settings, null)
escoria._on_settings_loaded(escoria.settings)
func _on_general_volume_changed(value):
escoria.settings["master_volume"] = value
escoria.esc_runner.save_data.save_settings(escoria.settings, null)
escoria.save_data.save_settings(escoria.settings, null)
escoria._on_settings_loaded(escoria.settings)

View File

@@ -23,14 +23,13 @@ func _ready():
func _on_button_pressed():
var actual_command = ":debug\nchange_scene " + options_paths[selected_id] + "\n"
var errors = []
var events = escoria.esc_compiler.compile_str(actual_command, errors)
var script = escoria.esc_compiler.compile([
":debug",
"change_scene %s" % options_paths[selected_id]
])
if errors.empty():
#past_actions.text += str(events)
var _ret = escoria.esc_runner.run_event(events["debug"])
escoria.event_manager.queue_event(script.events['debug'])
func _on_option_item_selected(index):
selected_id = index

View File

@@ -49,27 +49,28 @@ func _input(event):
func left_click_on_bg(position : Vector2) -> void:
escoria.do("walk", ["player", position])
escoria.esc_runner.clear_current_action()
escoria.action_manager.clear_current_action()
verbs_menu.unselect_actions()
func right_click_on_bg(position : Vector2) -> void:
escoria.do("walk", ["player", position])
escoria.esc_runner.clear_current_action()
escoria.action_manager.clear_current_action()
verbs_menu.unselect_actions()
func left_double_click_on_bg(position : Vector2) -> void:
escoria.do("walk", ["player", position, true])
escoria.esc_runner.clear_current_action()
escoria.action_manager.clear_current_action()
verbs_menu.unselect_actions()
## ITEM FOCUS ##
func element_focused(element_id : String) -> void:
var target_obj = escoria.esc_runner.get_object(element_id)
var target_obj = escoria.object_manager.get_object(element_id).node
tooltip.set_target(target_obj.tooltip_name)
if escoria.esc_runner.current_action != "use" && escoria.esc_runner.current_tool == null:
if escoria.action_manager.current_action != "use" \
and escoria.action_manager.current_tool == null:
if target_obj is ESCItem:
verbs_menu.set_by_name(target_obj.default_action)
@@ -83,7 +84,7 @@ func left_click_on_item(item_global_id : String, event : InputEvent) -> void:
escoria.do("item_left_click", [item_global_id, event])
func right_click_on_item(item_global_id : String, event : InputEvent) -> void:
escoria.esc_runner.set_current_action(verbs_menu.selected_action)
escoria.action_manager.set_current_action(verbs_menu.selected_action)
escoria.do("item_right_click", [item_global_id, event])
func left_double_click_on_item(item_global_id : String, event : InputEvent) -> void:
@@ -93,26 +94,23 @@ func left_double_click_on_item(item_global_id : String, event : InputEvent) -> v
## INVENTORY ##
func left_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void:
escoria.do("item_left_click", [inventory_item_global_id, event])
# if escoria.esc_runner.current_action == "use":
# var item = escoria.esc_runner.get_object(inventory_item_global_id)
# if item.texture:
# verbs_menu.set_tool_texture(item.texture)
# elif item.inventory_item_scene_file.instance().texture_normal:
# verbs_menu.set_tool_texture(item.inventory_item_scene_file.instance().texture_normal)
func right_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void:
escoria.esc_runner.set_current_action(verbs_menu.selected_action)
escoria.action_manager.set_current_action(verbs_menu.selected_action)
escoria.do("item_right_click", [inventory_item_global_id, event])
func left_double_click_on_inventory_item(_inventory_item_global_id : String, _event : InputEvent) -> void:
pass
func inventory_item_focused(inventory_item_global_id : String) -> void:
var target_obj = escoria.esc_runner.get_object(inventory_item_global_id)
var target_obj = escoria.object_manager.get_object(
inventory_item_global_id
).node
tooltip.set_target(target_obj.tooltip_name)
if escoria.esc_runner.current_action != "use" && escoria.esc_runner.current_tool == null:
if escoria.action_manager.current_action != "use" \
and escoria.action_manager.current_tool == null:
if target_obj is ESCItem:
verbs_menu.set_by_name(target_obj.default_action_inventory)
@@ -148,7 +146,7 @@ func show_ui():
tooltip.show()
func _on_event_done(_event_name: String):
escoria.esc_runner.clear_current_action()
escoria.action_manager.clear_current_action()
verbs_menu.unselect_actions()

View File

@@ -14,7 +14,7 @@ func _ready():
but.toggle_mode = true
func _on_action_selected(action : String):
escoria.esc_runner.set_current_action(action)
escoria.action_manager.set_current_action(action)
for but in get_children():
but.set_pressed(but.get_name() == action)

View File

@@ -55,10 +55,11 @@ func left_double_click_on_bg(position : Vector2) -> void:
## ITEM/HOTSPOT FOCUS ##
func element_focused(element_id : String) -> void:
var target_obj = escoria.esc_runner.get_object(element_id)
var target_obj = escoria.object_manager.get_object(element_id).node
$ui/tooltip_layer/tooltip.set_target(target_obj.tooltip_name)
if escoria.esc_runner.current_action != "use" && escoria.esc_runner.current_tool == null:
if escoria.action_manager.current_action != "use" \
and escoria.action_manager.current_tool == null:
if target_obj is ESCItem:
$ui/verbs_layer/verbs_menu.set_by_name(target_obj.default_action)
@@ -81,8 +82,10 @@ func left_double_click_on_item(item_global_id : String, event : InputEvent) -> v
## INVENTORY ##
func left_click_on_inventory_item(inventory_item_global_id : String, event : InputEvent) -> void:
escoria.do("item_left_click", [inventory_item_global_id, event])
if escoria.esc_runner.current_action == "use":
var item = escoria.esc_runner.get_object(inventory_item_global_id)
if escoria.action_manager.current_action == "use":
var item = escoria.object_manager.get_object(
inventory_item_global_id
).node
if item.get_node("sprite").texture:
$ui/verbs_layer/verbs_menu.set_tool_texture(item.get_node("sprite").texture)
elif item.inventory_item_scene_file.instance().texture_normal:
@@ -96,7 +99,11 @@ func left_double_click_on_inventory_item(inventory_item_global_id : String, even
pass
func inventory_item_focused(inventory_item_global_id : String) -> void:
$ui/tooltip_layer/tooltip.set_target(escoria.esc_runner.get_object(inventory_item_global_id).tooltip_name)
$ui/tooltip_layer/tooltip.set_target(
escoria.object_manager.get_object(
inventory_item_global_id
).node.tooltip_name
)
func inventory_item_unfocused() -> void:
$ui/tooltip_layer/tooltip.set_target("")
@@ -119,5 +126,5 @@ func show_ui():
$ui/inventory_layer/inventory_ui.show()
func _on_event_done(event_name: String):
escoria.esc_runner.clear_current_action()
escoria.action_manager.clear_current_action()
$ui/verbs_layer/verbs_menu.clear_tool_texture()

View File

@@ -32,7 +32,7 @@ func iterate_actions_cursor(direction : int):
current_cursor_id = cursors.size() - 1
Input.set_custom_mouse_cursor(cursors[current_cursor_id].texture)
escoria.esc_runner.set_current_action(cursors[current_cursor_id].name)
escoria.action_manager.set_current_action(cursors[current_cursor_id].name)
if $mouse_position/tool.texture != null:
clear_tool_texture()
@@ -43,7 +43,7 @@ func set_by_name(name : String) -> void:
break
Input.set_custom_mouse_cursor(cursors[current_cursor_id].texture)
escoria.esc_runner.set_current_action(cursors[current_cursor_id].name)
escoria.action_manager.set_current_action(cursors[current_cursor_id].name)
func set_tool_texture(texture : Texture):
set_process(true)