This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Max Oberaigner
committed
May 21, 2024
1 parent
a2f1324
commit 481e69d
Showing
7 changed files
with
133 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
extends AutoRefresh | ||
|
||
const Sprite: Resource = preload("res://src/sprite_selector/sprite.tscn") | ||
|
||
|
||
func _refresh_contents(): | ||
var sprites = Api.sprite_get_all() | ||
render_sprites(sprites) | ||
|
||
|
||
func render_sprites(sprites): | ||
var code_container := $VBoxIntems | ||
for old in code_container.get_children(): | ||
code_container.remove_child(old) | ||
|
||
for path in sprites: | ||
var sprite = Sprite.instantiate() | ||
sprite.setup(path) | ||
code_container.add_child(sprite) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
extends Button | ||
|
||
|
||
func _on_pressed(): | ||
$FileDialog.popup_centered() | ||
|
||
|
||
func _on_file_dialog_file_selected(path): | ||
print_debug("HFefe") | ||
API.sprite_add(path) | ||
print_debug("djuashduis") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extends FileDialog | ||
|
||
|
||
func _on_file_selected(path): | ||
print("HELL") | ||
API.sprite_add(path) | ||
print("GOO") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use godot::prelude::*; | ||
|
||
use crate::GodotASTNode; | ||
|
||
pub fn to_godot_ast(a: &compiler::ast::Statement) -> Gd<GodotASTNode> { | ||
use compiler::ast::Statement; | ||
let node = match a { | ||
Statement::MoveRandomly() => GodotASTNode { | ||
node_type: 1, | ||
identifier: -1, // TODO | ||
member_data: array![], | ||
}, | ||
Statement::MoveRelative(x, y) => GodotASTNode { | ||
node_type: 2, | ||
identifier: -1, // TODO | ||
member_data: varray![x, y], | ||
}, | ||
Statement::MoveTo(x, y) => GodotASTNode { | ||
node_type: 2, | ||
identifier: -1, // TODO | ||
member_data: varray![x, y], | ||
}, | ||
Statement::Calc(x) => GodotASTNode { | ||
node_type: 3, | ||
identifier: -1, | ||
member_data: varray![expression_to_godot_ast(x)], | ||
}, | ||
}; | ||
|
||
Gd::from_object(node) | ||
} | ||
|
||
pub fn expression_to_godot_ast(expr: &compiler::ast::Expression) -> Gd<GodotASTNode> { | ||
use compiler::ast::Expression; | ||
|
||
let node = match expr { | ||
Expression::IntLiteral(a) => GodotASTNode { | ||
node_type: 1000, | ||
identifier: -1, | ||
member_data: varray![a], // Literal Int | ||
}, | ||
|
||
Expression::Addition(a, b) => GodotASTNode { | ||
node_type: 2000, | ||
identifier: -1, | ||
member_data: varray![expression_to_godot_ast(a), expression_to_godot_ast(b)], | ||
}, | ||
|
||
Expression::Subtraction(a, b) => GodotASTNode { | ||
node_type: 2001, | ||
identifier: -1, | ||
member_data: varray![expression_to_godot_ast(a), expression_to_godot_ast(b)], | ||
}, | ||
|
||
Expression::Multiplication(a, b) => GodotASTNode { | ||
node_type: 2002, | ||
identifier: -1, | ||
member_data: varray![expression_to_godot_ast(a), expression_to_godot_ast(b)], | ||
}, | ||
|
||
Expression::Division(a, b) => GodotASTNode { | ||
node_type: 2003, | ||
identifier: -1, | ||
member_data: varray![expression_to_godot_ast(a), expression_to_godot_ast(b)], | ||
}, | ||
}; | ||
|
||
Gd::from_object(node) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters