NAT godot playground UI implementation skeleton

This commit is contained in:
2023-02-11 16:01:59 -07:00
parent 7e023d6167
commit 1fc1c98468
12 changed files with 137 additions and 11 deletions

View File

@@ -0,0 +1,28 @@
extends PanelContainer
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var z = 0
# 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
func _on_EntryContainer_mouse_entered():
var current_focus_z = get_parent().current_focus_z
if is_nan(current_focus_z) or current_focus_z <= self.z:
get_parent().current_focus = self
get_parent().current_focus_z = self.z
func _on_EntryContainer_mouse_exited():
if get_parent().current_focus == self:
get_parent().current_focus = null
get_parent().current_focus_z = NAN

View File

@@ -0,0 +1,7 @@
package;
import kiss.Prelude;
import kiss_tools.KeyShortcutHandler;
@:build(kiss.Kiss.build())
class GodotUI implements ArchiveUI {}

View File

@@ -0,0 +1,18 @@
(prop &mut :ArchiveController controller (property default default))
(prop &mut :Null<KeyShortcutHandler<Entry>> shortcutHandler (property default null))
(method :Void showPrefixMap [:Map<String,String> map] (throw "TODO Not implemented!"))
(method :Void hidePrefixMap [] (throw "TODO Not implemented!"))
(method :Null<PlaygroundSystem> playgroundSystem [] (throw "TODO Not implemented!"))
(method :Void enterText [:String prompt :String->Void resolve :Float maxLength] (throw "TODO Not implemented!"))
(method :Void enterNumber [:String prompt :Float->Void resolve :Float min :Float max &opt :Null<Float> inStepsOf &opt :Null<Bool> allowNaN] (throw "TODO Not implemented!"))
(method :Void chooseEntry [:String prompt :Archive archive :Entry->Void resolve] (throw "TODO Not implemented!"))
(method :Void chooseEntries [:String prompt :Archive archive :Array<Entry>->Void resolve :Int min :Float max] (throw "TODO Not implemented!"))
(method :Void handleChanges [:Archive archive :ChangeSet changeSet] (throw "TODO Not implemented!"))
(method :Void displayMessage [:String message] (throw "TODO Not implemented!"))
(method :Void reportError [:String error] (throw "TODO Not implemented!"))
(method :Void onSelectionChanged [:Array<Entry> selectedEntries :Array<Entry> lastSelectedEntries] (throw "TODO Not implemented!"))
(method :Void choosePosition [:String prompt :Position->Void resolve] (throw "TODO Not implemented!"))
(method :Option<Position> cursorPosition [] (throw "TODO Not implemented!"))(method :Void chooseBetweenStrings [:String prompt :Array<String> choices :String->Void resolve] (throw "TODO Not implemented!"))
(defNew [&prop :Archive archive
&prop :Node rootNode])

View File

@@ -0,0 +1,27 @@
extends Control
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
var current_focus = null
var current_focus_z = NAN
func get_drag_data(position):
return current_focus
func can_drop_data(position, data):
return data != null
func drop_data(position, data):
data.rect_position = position
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@@ -0,0 +1,6 @@
package;
import kiss.Prelude;
@:build(kiss.Kiss.build())
class RootNode extends Control {}

View File

@@ -0,0 +1,9 @@
(method &override &public :Void _Ready []
// TODO find a better way to pass the archiveDir to a Godot game
(let [archiveDir
(or (Sys.getEnv "NAT_DIR") (throw "NAT_DIR environment variable must be set"))
archive
(new Archive archiveDir)
ui (new GodotUI archive this)
controller (new ArchiveController archive ui)]
(set ui.controller controller)))

View File

@@ -0,0 +1,15 @@
import godot.*;
import godot.GD.*;
// using godot.Utils;
import nat.Archive;
import nat.ArchiveUI;
import nat.ArchiveController;
import nat.Lib;
import nat.Entry;
import nat.System;
import nat.systems.*;
import nat.components.*;
import haxe.ds.Option;