@papercraftgames/estragon 0.1.0-beta.7 → 0.1.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,8 +5,10 @@ var create: Callable
5
5
  var root_context := false
6
6
  func _popup_menu(paths: PackedStringArray) -> void:
7
7
  root_context = paths.is_empty()
8
- add_context_menu_item("New Gogo Component…" if paths.is_empty() else "Gogo Component…",_selected)
9
- func _selected(paths: PackedStringArray) -> void:
8
+ var prefix := "New " if paths.is_empty() else ""
9
+ add_context_menu_item(prefix+"Gogo Component (2D)…",_selected.bind(false))
10
+ add_context_menu_item(prefix+"Gogo Component (3D)…",_selected.bind(true))
11
+ func _selected(paths: PackedStringArray, spatial: bool) -> void:
10
12
  # The engine supplies a current directory to callbacks even when popup
11
13
  # paths were empty. Empty-space creation deliberately starts at project root.
12
- if create.is_valid(): create.call(paths[0] if not root_context and not paths.is_empty() else "res://")
14
+ if create.is_valid(): create.call(paths[0] if not root_context and not paths.is_empty() else "res://",spatial)
@@ -4,9 +4,6 @@ extends RefCounted
4
4
  const Build = preload("build_service.gd")
5
5
  const Source = preload("../compiler/source.gd")
6
6
  const Element = preload("../runtime/composition/element.gd")
7
- const Entry2D = preload("../runtime/node/estragon_2d.gd")
8
- const Entry3D = preload("../runtime/node/estragon_3d.gd")
9
- const Text = preload("../runtime/node/text.gd")
10
7
  var dialog: Variant
11
8
  var dimension: OptionButton
12
9
  var error: AcceptDialog
@@ -31,30 +28,28 @@ func start(parent: Node) -> void:
31
28
  dialog.add_filter("*","Gogo Component (.gogo)")
32
29
  dimension = OptionButton.new()
33
30
  dimension.name = "GogoTemplate"
34
- dimension.add_item("Node2D — native layout and text")
35
- dimension.add_item("Node3D — native spatial layout")
31
+ dimension.add_item("Node2D — blank component")
32
+ dimension.add_item("Node3D — blank component")
36
33
  dialog.get_vbox().add_child(dimension)
37
34
  dialog.file_selected.connect(_selected)
38
35
  parent.add_child(dialog)
39
36
  error = AcceptDialog.new()
40
37
  error.title = "New Gogo Component"
41
38
  parent.add_child(error)
42
- func show_dialog(context_directory: String = "") -> void:
39
+ func show_dialog(context_directory: String = "", spatial: bool = false) -> void:
43
40
  if not active: return
44
41
  var directory := context_directory if not context_directory.is_empty() else interface.get_current_directory()
45
42
  if not directory.begins_with("res://") or not DirAccess.dir_exists_absolute(directory): directory = "res://"
46
43
  dialog.current_dir = directory
47
44
  dialog.current_file = "NewComponent.gogo"
45
+ dimension.select(1 if spatial else 0)
48
46
  dialog.popup_centered_ratio(0.65)
49
47
  static func template(path: String, spatial: bool) -> String:
48
+ var kind := "Node3D" if spatial else "Node2D"
50
49
  var directory := Build.output_for(path).get_base_dir()
51
50
  var element := JSON.stringify(Source.relative_path(directory,(Element as Script).resource_path))
52
- var entry := JSON.stringify(Source.relative_path(directory,((Entry3D if spatial else Entry2D) as Script).resource_path))
53
- var result := "extends "+("Node3D" if spatial else "Node2D")+"\nconst Element = preload("+element+")\nconst Entry = preload("+entry+")\n"
54
- if spatial:
55
- return result+"\nfunc build_view() -> Element:\n\treturn <Entry name=\"Layout\" width={4.0} height={2.0} depth={1.0} />\n"
56
- var text := JSON.stringify(Source.relative_path(directory,(Text as Script).resource_path))
57
- return result+"const Text = preload("+text+")\n\nfunc build_view() -> Element:\n\treturn <Entry name=\"UI\" viewport_width_scale={0.9}>\n\t\t<Text name=\"Greeting\" text=\"Hello Gogo\" />\n\t</Entry>\n"
51
+ # Ordinary native grouping node: no drawing, layout scope or configuration.
52
+ return "extends "+kind+"\nconst Element = preload("+element+")\n\nfunc build_view() -> Element:\n\treturn <"+kind+" />\n"
58
53
  func _selected(path: String) -> void:
59
54
  if not active: return
60
55
  if path.get_extension().is_empty(): path += ".gogo"
@@ -3,5 +3,5 @@
3
3
  name="Estragon"
4
4
  description="Native Gogo/GGX highlighting, compilation and validation before Play."
5
5
  author="Resist Design"
6
- version="0.1.0-beta.7"
6
+ version="0.1.0-beta.8"
7
7
  script="plugin.gd"
@@ -55,7 +55,8 @@ func _enter_tree() -> void:
55
55
  _highlighter_association.start(_interface)
56
56
  _new_script = NewScript.new(_interface,_navigation)
57
57
  _new_script.start(self)
58
- add_tool_menu_item("New Gogo Component…",_new_script.show_dialog)
58
+ add_tool_menu_item("New Gogo Component (2D)…",_new_script.show_dialog.bind("",false))
59
+ add_tool_menu_item("New Gogo Component (3D)…",_new_script.show_dialog.bind("",true))
59
60
  # Never parse a script extending a newer native class on Godot 4.0.
60
61
  if has_method("add_context_menu_plugin") and has_method("remove_context_menu_plugin") and ClassDB.class_exists("EditorContextMenuPlugin") and "CONTEXT_SLOT_FILESYSTEM_CREATE" in ClassDB.class_get_integer_constant_list("EditorContextMenuPlugin"):
61
62
  var adapter := GDScript.new()
@@ -244,7 +245,8 @@ func _show_report() -> void:
244
245
 
245
246
  func _exit_tree() -> void:
246
247
  _active = false
247
- remove_tool_menu_item("New Gogo Component…")
248
+ remove_tool_menu_item("New Gogo Component (2D)…")
249
+ remove_tool_menu_item("New Gogo Component (3D)…")
248
250
  if _creation_menu != null:
249
251
  call("remove_context_menu_plugin",_creation_menu)
250
252
  _creation_menu.create = Callable()
package/package.json CHANGED
@@ -29,5 +29,5 @@
29
29
  "tag": "beta",
30
30
  "registry": "https://registry.npmjs.org/"
31
31
  },
32
- "version": "0.1.0-beta.7"
32
+ "version": "0.1.0-beta.8"
33
33
  }