]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Modules/Save/event_save.gd
Squashed commit of the following:
[wolf-seeking-sheep.git] / addons / dialogic / Modules / Save / event_save.gd
1 @tool
2 class_name DialogicSaveEvent
3 extends DialogicEvent
4
5 ## Event that allows saving to a specific slot.
6
7
8 ### Settings
9
10 ## The name of the slot to save to. Learn more in the saving subsystem.
11 ## If empty, the event will attempt to save to the latest slot, and otherwise use the default.
12 var slot_name := ""
13
14
15 ################################################################################
16 ##                                              INITIALIZE
17 ################################################################################
18
19 func _execute() -> void:
20         if slot_name.is_empty():
21                 if dialogic.Save.get_latest_slot():
22                         dialogic.Save.save(dialogic.Save.get_latest_slot())
23                 else:
24                         dialogic.Save.save()
25         else:
26                 dialogic.Save.save(slot_name)
27         finish()
28
29
30 ################################################################################
31 ##                                              INITIALIZE
32 ################################################################################
33
34 func _init() -> void:
35         event_name = "Save"
36         set_default_color('Color6')
37         event_category = "Other"
38         event_sorting_index = 0
39
40
41 func _get_icon() -> Resource:
42         return load(self.get_script().get_path().get_base_dir().path_join('icon.svg'))
43
44
45 ################################################################################
46 ##                                              SAVING/LOADING
47 ################################################################################
48
49 func get_shortcode() -> String:
50         return "save"
51
52
53 func get_shortcode_parameters() -> Dictionary:
54         return {
55                 #param_name : property_info
56                 "slot"          : {"property": "slot_name", "default": "Default"},
57         }
58
59
60 ################################################################################
61 ##                                              EDITOR REPRESENTATION
62 ################################################################################
63
64 func build_event_editor() -> void:
65         add_header_edit('slot_name', ValueType.SINGLELINE_TEXT, {'left_text':'Save to slot'})