Commit ca47a26b authored by Oscar Campos's avatar Oscar Campos Committed by Oscar Campos
Browse files

chore: updated SimpleDemo example project

parent 8419ba6c
......@@ -2,7 +2,7 @@
all: generate build
generate:
/home/damnwidget/development/pimpam/engines/godot/gdnative-go/gdnativego generate --path="./src"
${GOPATH}/bin/gogdc generate --path="./src"
build:
go build -v -buildmode=c-shared -o ./bin/libsimple.so ./src/*.go
......
......@@ -3,9 +3,6 @@
[ext_resource path="res://bin/simple.gdnlib" type="GDNativeLibrary" id=1]
[resource]
resource_name = "SIMPLE"
class_name = "SIMPLE"
library = ExtResource( 1 )
_sections_unfolded = [ "Resource" ]
......@@ -2,7 +2,11 @@ extends Control
# load the SIMPLE library
const SIMPLE = preload("res://bin/simple.gdns")
onready var data = SIMPLE.new()
var data = SIMPLE.new()
func _on_Button_pressed():
# data comes directly from the Go context
$Label.text = "Data = " + data.get_data()
data.HP += 1
print("data.Blood is ", data.Blood)
data.Blood += 1
......@@ -2,65 +2,22 @@
[ext_resource path="res://main.gd" type="Script" id=1]
[node name="main" type="Control" index="0"]
anchor_left = 0.0
anchor_top = 0.0
[node name="main" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
script = ExtResource( 1 )
[node name="Button" type="Button" parent="." index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="Button" type="Button" parent="."]
margin_left = 384.0
margin_top = 233.0
margin_right = 630.0
margin_bottom = 289.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "Hello"
flat = false
align = 1
[node name="Label" type="Label" parent="." index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
[node name="Label" type="Label" parent="."]
margin_left = 392.0
margin_top = 311.0
margin_right = 629.0
margin_bottom = 368.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 0
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]
......@@ -4,16 +4,19 @@ import (
"gitlab.com/pimpam-games-studio/gdnative-go/gdnative"
)
// Ignored is ignored by the gdnativego compiler
type Ignored struct{}
// Ignored is ignored by gdnativego compiler
type Ignored struct{} //nolint:deadcode,unused
// SimpleClass is a structure that we can register with Godot.
//godot::register as SIMPLE
type SimpleClass struct {
Hit gdnative.Signal
HP gdnative.Int `hint:"range" hint_string:"The player's Hit Points" usage:"Default"`
Mana, Blood gdnative.Int `hint:"range" hint_string:"The player points to cast spells"`
IgnoreMe gdnative.Float `-` // this property will be ignored
HP gdnative.Int `hint:"range" hint_string:"The player's Hit Points" usage:"Default"`
Mana, Blood gdnative.Int `hint:"range" hint_string:"The player points to cast spells"`
Position gdnative.Vector2 `hint:"none" hint_string:"The player position"`
// IgnoreMe property will be ignored
IgnoreMe gdnative.Float `-` //nolint
}
// New creates a new SimpleClass value and returns a pointer to it
......@@ -21,7 +24,7 @@ type SimpleClass struct {
func New() *SimpleClass {
sc := SimpleClass{
// Signals must be defined as literals or they will be ignored by the gdnativego compiler
HP: 100,
Hit: gdnative.Signal{
Name: "hit",
NumArgs: gdnative.Int(1),
......@@ -50,7 +53,7 @@ func (sc *SimpleClass) GetData() gdnative.Variant {
gdnative.Log.Println("SIMPLE.get_data() called!")
data := gdnative.NewStringWithWideString("Hello World from gdnative-go instance!")
data := gdnative.NewStringWithWideString(fmt.Sprintf("Hello World from gdnative-go instance! HP value: %d", sc.HP))
return gdnative.NewVariantWithString(data)
}
......
......@@ -713,11 +713,6 @@ func parseKeyValueExpr(expr *ast.KeyValueExpr) (string, string) { //nolint:unuse
func parseSignalArgs(composite *ast.CompositeLit) string {
// buffer := bufio.NewBuffer(nil)
// fileSet := token.NewFileSet()
// printer.Fprint(buffer, fileSet, composite)
// return buffer.String()
buffer := []byte{}
buf := bytes.NewBuffer(buffer)
fileSet := token.NewFileSet()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment