develop #30
@ -1,9 +1,7 @@
|
|||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Main.gdns" type="Script" id=1]
|
[ext_resource path="res://Main.gdns" type="Script" id=1]
|
||||||
[ext_resource path="res://levels/Level2.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://levels/Level2.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://monitor/Monitor.tscn" type="PackedScene" id=3]
|
|
||||||
[ext_resource path="res://shaders/crt/crt.tscn" type="PackedScene" id=4]
|
|
||||||
|
|
||||||
[node name="Main" type="Node"]
|
[node name="Main" type="Node"]
|
||||||
pause_mode = 2
|
pause_mode = 2
|
||||||
@ -12,7 +10,3 @@ level = ExtResource( 2 )
|
|||||||
|
|
||||||
[node name="Level" type="Node" parent="."]
|
[node name="Level" type="Node" parent="."]
|
||||||
pause_mode = 1
|
pause_mode = 1
|
||||||
|
|
||||||
[node name="Monitor" parent="." instance=ExtResource( 3 )]
|
|
||||||
|
|
||||||
[node name="CRT" parent="." instance=ExtResource( 4 )]
|
|
||||||
|
@ -114,6 +114,10 @@ func show_error_message(message: String) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_PopupDialog_gui_input(event: InputEvent) -> void:
|
func _on_PopupDialog_gui_input(event: InputEvent) -> void:
|
||||||
if event.is_pressed():
|
|
||||||
var popup = get_node("%PopupDialog")
|
var popup = get_node("%PopupDialog")
|
||||||
popup.hide()
|
if popup.visible and event.is_pressed():
|
||||||
|
popup.call_deferred("hide")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_text_entered(_new_text: String) -> void:
|
||||||
|
call_deferred("_on_Button_pressed")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=17 format=2]
|
[gd_scene load_steps=18 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://assets/fonts/data/PixelOperator.tres" type="DynamicFontData" id=1]
|
[ext_resource path="res://assets/fonts/data/PixelOperator.tres" type="DynamicFontData" id=1]
|
||||||
[ext_resource path="res://assets/fonts/data/PixelOperator-Bold.tres" type="DynamicFontData" id=2]
|
[ext_resource path="res://assets/fonts/data/PixelOperator-Bold.tres" type="DynamicFontData" id=2]
|
||||||
@ -7,6 +7,7 @@
|
|||||||
[ext_resource path="res://monitor/EnterButton.gd" type="Script" id=5]
|
[ext_resource path="res://monitor/EnterButton.gd" type="Script" id=5]
|
||||||
[ext_resource path="res://assets/sounds/ui_popup.wav" type="AudioStream" id=6]
|
[ext_resource path="res://assets/sounds/ui_popup.wav" type="AudioStream" id=6]
|
||||||
[ext_resource path="res://assets/sounds/ui_select.wav" type="AudioStream" id=7]
|
[ext_resource path="res://assets/sounds/ui_select.wav" type="AudioStream" id=7]
|
||||||
|
[ext_resource path="res://monitor/MonitorGUI.gd" type="Script" id=8]
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=1]
|
[sub_resource type="DynamicFont" id=1]
|
||||||
font_data = ExtResource( 1 )
|
font_data = ExtResource( 1 )
|
||||||
@ -69,6 +70,7 @@ font_data = ExtResource( 2 )
|
|||||||
|
|
||||||
[node name="MonitorGUI" type="CanvasLayer"]
|
[node name="MonitorGUI" type="CanvasLayer"]
|
||||||
pause_mode = 2
|
pause_mode = 2
|
||||||
|
script = ExtResource( 8 )
|
||||||
|
|
||||||
[node name="ColorRect" type="ColorRect" parent="."]
|
[node name="ColorRect" type="ColorRect" parent="."]
|
||||||
margin_right = 40.0
|
margin_right = 40.0
|
||||||
@ -235,9 +237,12 @@ valign = 1
|
|||||||
autowrap = true
|
autowrap = true
|
||||||
|
|
||||||
[connection signal="focus_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Name" to="GUI/Sounds" method="_play_ui_select_sound"]
|
[connection signal="focus_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Name" to="GUI/Sounds" method="_play_ui_select_sound"]
|
||||||
|
[connection signal="text_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Name" to="GUI/VBoxContainer/CenterContainer3/Button" method="_on_text_entered"]
|
||||||
[connection signal="focus_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Rut" to="GUI/Sounds" method="_play_ui_select_sound"]
|
[connection signal="focus_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Rut" to="GUI/Sounds" method="_play_ui_select_sound"]
|
||||||
[connection signal="text_changed" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Rut" to="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Rut" method="_on_Rut_text_changed"]
|
[connection signal="text_changed" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Rut" to="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Rut" method="_on_Rut_text_changed"]
|
||||||
|
[connection signal="text_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Rut" to="GUI/VBoxContainer/CenterContainer3/Button" method="_on_text_entered"]
|
||||||
[connection signal="focus_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Email" to="GUI/Sounds" method="_play_ui_select_sound"]
|
[connection signal="focus_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Email" to="GUI/Sounds" method="_play_ui_select_sound"]
|
||||||
|
[connection signal="text_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Email" to="GUI/VBoxContainer/CenterContainer3/Button" method="_on_text_entered"]
|
||||||
[connection signal="focus_entered" from="GUI/VBoxContainer/CenterContainer3/Button" to="GUI/Sounds" method="_play_ui_select_sound"]
|
[connection signal="focus_entered" from="GUI/VBoxContainer/CenterContainer3/Button" to="GUI/Sounds" method="_play_ui_select_sound"]
|
||||||
[connection signal="pressed" from="GUI/VBoxContainer/CenterContainer3/Button" to="GUI/VBoxContainer/CenterContainer3/Button" method="_on_Button_pressed"]
|
[connection signal="pressed" from="GUI/VBoxContainer/CenterContainer3/Button" to="GUI/VBoxContainer/CenterContainer3/Button" method="_on_Button_pressed"]
|
||||||
[connection signal="focus_entered" from="PopupDialog" to="GUI/Sounds" method="_play_popup_sound"]
|
[connection signal="focus_entered" from="PopupDialog" to="GUI/Sounds" method="_play_popup_sound"]
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
signal monitor_loaded()
|
||||||
|
|
||||||
|
|
||||||
export var monitor_enabled: bool = false
|
export var monitor_enabled: bool = false
|
||||||
export var development_url: String = "http://localhost:4050/api/v1"
|
export var development_url: String = "http://localhost:4050/api/v1"
|
||||||
var url_real: String = "https://alai.cromer.cl/api/v1"
|
var url_real: String = "https://alai.cromer.cl/api/v1"
|
||||||
@ -101,6 +104,7 @@ func _physics_process(_delta: float) -> void:
|
|||||||
if monitor_enabled:
|
if monitor_enabled:
|
||||||
if has_node("MonitorGUI") and not $MonitorGUI.visible:
|
if has_node("MonitorGUI") and not $MonitorGUI.visible:
|
||||||
$MonitorGUI.visible = true
|
$MonitorGUI.visible = true
|
||||||
|
emit_signal("monitor_loaded")
|
||||||
|
|
||||||
if started and not get_tree().paused:
|
if started and not get_tree().paused:
|
||||||
var frame = empty_frame.duplicate(true)
|
var frame = empty_frame.duplicate(true)
|
||||||
@ -122,6 +126,7 @@ func _physics_process(_delta: float) -> void:
|
|||||||
start_monitor()
|
start_monitor()
|
||||||
else:
|
else:
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
|
emit_signal("monitor_loaded")
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
@ -129,21 +134,22 @@ func _on_input_validated(validated_player: Dictionary) -> void:
|
|||||||
$MonitorGUI.queue_free()
|
$MonitorGUI.queue_free()
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
player = validated_player.duplicate(true)
|
player = validated_player.duplicate(true)
|
||||||
|
game["player"] = player
|
||||||
|
|
||||||
|
|
||||||
func _object_created(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
func _object_created(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
||||||
if monitor_enabled and started:
|
if monitor_enabled:
|
||||||
add_object(name, state, position, velocity)
|
add_object(name, state, position, velocity)
|
||||||
|
|
||||||
|
|
||||||
func _object_updated(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
func _object_updated(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
||||||
if monitor_enabled and started:
|
if monitor_enabled:
|
||||||
remove_object(name)
|
remove_object(name)
|
||||||
add_object(name, state, position, velocity)
|
add_object(name, state, position, velocity)
|
||||||
|
|
||||||
|
|
||||||
func _object_removed(name: String) -> void:
|
func _object_removed(name: String) -> void:
|
||||||
if monitor_enabled and started:
|
if monitor_enabled:
|
||||||
remove_object(name)
|
remove_object(name)
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,10 +6,9 @@
|
|||||||
[node name="Monitor" type="Node"]
|
[node name="Monitor" type="Node"]
|
||||||
pause_mode = 2
|
pause_mode = 2
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
monitor_enabled = true
|
|
||||||
use_development_url = true
|
|
||||||
|
|
||||||
[node name="MonitorGUI" parent="." instance=ExtResource( 3 )]
|
[node name="MonitorGUI" parent="." instance=ExtResource( 3 )]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
[node name="HTTPRequest" type="HTTPRequest" parent="."]
|
[node name="HTTPRequest" type="HTTPRequest" parent="."]
|
||||||
|
pause_mode = 2
|
||||||
|
12
godot/monitor/MonitorGUI.gd
Normal file
12
godot/monitor/MonitorGUI.gd
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
extends CanvasLayer
|
||||||
|
|
||||||
|
|
||||||
|
export var default_name = ""
|
||||||
|
export var default_rut = ""
|
||||||
|
export var default_email = ""
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
get_node("%Name").text = default_name
|
||||||
|
get_node("%Rut").text = default_rut
|
||||||
|
get_node("%Email").text = default_email
|
69
src/Main.cpp
69
src/Main.cpp
@ -9,11 +9,13 @@ void Main::_register_methods()
|
|||||||
{
|
{
|
||||||
register_method("_ready", &Main::_ready);
|
register_method("_ready", &Main::_ready);
|
||||||
register_method("_physics_process", &Main::_physics_process);
|
register_method("_physics_process", &Main::_physics_process);
|
||||||
|
register_method("_on_monitor_loaded", &Main::_on_monitor_loaded);
|
||||||
register_property<Main, String>("game_version", &Main::set_game_version, &Main::get_game_version, String(main::game_version.c_str()));
|
register_property<Main, String>("game_version", &Main::set_game_version, &Main::get_game_version, String(main::game_version.c_str()));
|
||||||
register_property<Main, Ref<PackedScene>>("level", &Main::set_level, &Main::get_level, NULL, GODOT_METHOD_RPC_MODE_DISABLED, GODOT_PROPERTY_USAGE_DEFAULT, GODOT_PROPERTY_HINT_RESOURCE_TYPE, String("PackedScene"));
|
register_property<Main, Ref<PackedScene>>("level", &Main::set_level, &Main::get_level, NULL, GODOT_METHOD_RPC_MODE_DISABLED, GODOT_PROPERTY_USAGE_DEFAULT, GODOT_PROPERTY_HINT_RESOURCE_TYPE, String("PackedScene"));
|
||||||
register_property<Main, bool>("full_screen", &Main::set_full_screen, &Main::get_full_screen, main::full_screen);
|
register_property<Main, bool>("full_screen", &Main::set_full_screen, &Main::get_full_screen, main::full_screen);
|
||||||
register_property<Main, Vector2>("window_size", &Main::set_window_size, &Main::get_window_size, main::window_size);
|
register_property<Main, Vector2>("window_size", &Main::set_window_size, &Main::get_window_size, main::window_size);
|
||||||
register_property<Main, int8_t>("launch_screen", &Main::set_launch_screen, &Main::get_launch_screen, main::launch_screen);
|
register_property<Main, int8_t>("launch_screen", &Main::set_launch_screen, &Main::get_launch_screen, main::launch_screen);
|
||||||
|
register_signal<Main>("monitor_loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
Main::Main()
|
Main::Main()
|
||||||
@ -28,6 +30,8 @@ void Main::_init()
|
|||||||
{
|
{
|
||||||
_os = OS::get_singleton();
|
_os = OS::get_singleton();
|
||||||
_input = Input::get_singleton();
|
_input = Input::get_singleton();
|
||||||
|
_project_settings = ProjectSettings::get_singleton();
|
||||||
|
_resource_loader = ResourceLoader::get_singleton();
|
||||||
|
|
||||||
game_version = String(main::game_version.c_str());
|
game_version = String(main::game_version.c_str());
|
||||||
full_screen = main::full_screen;
|
full_screen = main::full_screen;
|
||||||
@ -37,7 +41,24 @@ void Main::_init()
|
|||||||
|
|
||||||
void Main::_ready()
|
void Main::_ready()
|
||||||
{
|
{
|
||||||
get_tree()->set_pause(true);
|
auto success = _project_settings->load_resource_pack("monitor.pck");
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
// Load monitor from pck
|
||||||
|
Godot::print("Monitor pck found, loading...");
|
||||||
|
load_monitor();
|
||||||
|
}
|
||||||
|
else if (_resource_loader->exists("res://monitor/Monitor.tscn"))
|
||||||
|
{
|
||||||
|
// Load monitor from alai's pck
|
||||||
|
load_monitor();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// There is no monitor included
|
||||||
|
_on_monitor_loaded();
|
||||||
|
}
|
||||||
|
|
||||||
if (get_full_screen())
|
if (get_full_screen())
|
||||||
{
|
{
|
||||||
_os->set_window_fullscreen(true);
|
_os->set_window_fullscreen(true);
|
||||||
@ -50,10 +71,52 @@ void Main::_ready()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level != NULL)
|
success = _project_settings->load_resource_pack("crt.pck");
|
||||||
|
if (success)
|
||||||
{
|
{
|
||||||
get_node("Level")->add_child(level->instance());
|
// Load crt from pck
|
||||||
|
Godot::print("CRT pck found, loading...");
|
||||||
|
Ref<PackedScene> crt_scene = _resource_loader->load("res://shaders/crt/crt.tscn");
|
||||||
|
add_child(crt_scene->instance());
|
||||||
}
|
}
|
||||||
|
else if (_resource_loader->exists("res://shaders/crt/crt.tscn"))
|
||||||
|
{
|
||||||
|
// Load crt from alai's pck
|
||||||
|
Ref<PackedScene> crt_scene = _resource_loader->load("res://shaders/crt/crt.tscn");
|
||||||
|
add_child(crt_scene->instance());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Main::_on_monitor_loaded()
|
||||||
|
{
|
||||||
|
if (level != nullptr)
|
||||||
|
{
|
||||||
|
auto level_node = load_level();
|
||||||
|
connect("monitor_loaded", level_node->get_child(0)->find_node("Player", true, false), "_on_monitor_loaded");
|
||||||
|
emit_signal("monitor_loaded");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Main::load_monitor()
|
||||||
|
{
|
||||||
|
Ref<PackedScene> monitor_scene = _resource_loader->load("res://monitor/Monitor.tscn");
|
||||||
|
add_child(monitor_scene->instance());
|
||||||
|
auto monitor = get_node("Monitor");
|
||||||
|
monitor->connect("monitor_loaded", this, "_on_monitor_loaded");
|
||||||
|
get_tree()->set_pause(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Node *Main::load_level()
|
||||||
|
{
|
||||||
|
if (level != nullptr)
|
||||||
|
{
|
||||||
|
auto path = level->get_path();
|
||||||
|
auto loaded_level = level->instance();
|
||||||
|
auto level_node = get_node("Level");
|
||||||
|
level_node->add_child(loaded_level);
|
||||||
|
return level_node;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Main::_physics_process(float delta)
|
void Main::_physics_process(float delta)
|
||||||
|
17
src/Main.h
17
src/Main.h
@ -8,6 +8,8 @@
|
|||||||
#include <Input.hpp>
|
#include <Input.hpp>
|
||||||
#include <PackedScene.hpp>
|
#include <PackedScene.hpp>
|
||||||
#include <Ref.hpp>
|
#include <Ref.hpp>
|
||||||
|
#include <ProjectSettings.hpp>
|
||||||
|
#include <ResourceLoader.hpp>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This is the godot namespace for all the code included in the library.
|
* @brief This is the godot namespace for all the code included in the library.
|
||||||
@ -64,6 +66,16 @@ namespace godot
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Input *_input;
|
Input *_input;
|
||||||
|
/**
|
||||||
|
* @brief ProjectSettings singleton.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
ProjectSettings *_project_settings;
|
||||||
|
/**
|
||||||
|
* @brief ResourceLoader singleton.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
ResourceLoader *_resource_loader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The first level to load
|
* @brief The first level to load
|
||||||
@ -204,6 +216,11 @@ namespace godot
|
|||||||
* @return int8_t The launch screen.
|
* @return int8_t The launch screen.
|
||||||
*/
|
*/
|
||||||
int8_t get_launch_screen();
|
int8_t get_launch_screen();
|
||||||
|
|
||||||
|
void _on_monitor_loaded();
|
||||||
|
|
||||||
|
void load_monitor();
|
||||||
|
Node *load_level();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ void Player::_register_methods()
|
|||||||
register_method("set_velocity", &Player::set_velocity);
|
register_method("set_velocity", &Player::set_velocity);
|
||||||
register_method("get_velocity", &Player::get_velocity);
|
register_method("get_velocity", &Player::get_velocity);
|
||||||
register_method("_on_player_touched", &Player::_on_player_touched);
|
register_method("_on_player_touched", &Player::_on_player_touched);
|
||||||
|
register_method("_on_monitor_loaded", &Player::_on_monitor_loaded);
|
||||||
//register_property<Player, Ref<SpriteFrames>>("sprite_frames", &Player::set_sprite_frames, &Player::get_sprite_frames, Ref<SpriteFrames>(), GODOT_METHOD_RPC_MODE_DISABLED, GODOT_PROPERTY_USAGE_DEFAULT, GODOT_PROPERTY_HINT_RESOURCE_TYPE, String("SpriteFrames"));
|
//register_property<Player, Ref<SpriteFrames>>("sprite_frames", &Player::set_sprite_frames, &Player::get_sprite_frames, Ref<SpriteFrames>(), GODOT_METHOD_RPC_MODE_DISABLED, GODOT_PROPERTY_USAGE_DEFAULT, GODOT_PROPERTY_HINT_RESOURCE_TYPE, String("SpriteFrames"));
|
||||||
register_property<Player, float>("speed", &Player::set_speed, &Player::get_speed, player::speed);
|
register_property<Player, float>("speed", &Player::set_speed, &Player::get_speed, player::speed);
|
||||||
register_property<Player, float>("jump_force", &Player::set_jump_force, &Player::get_jump_force, player::jump_force);
|
register_property<Player, float>("jump_force", &Player::set_jump_force, &Player::get_jump_force, player::jump_force);
|
||||||
@ -77,8 +78,10 @@ void Player::_ready()
|
|||||||
{
|
{
|
||||||
WARN_PRINT("Middleground not found!");
|
WARN_PRINT("Middleground not found!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto object_node = get_tree()->get_root()->get_node("Main")->find_node("Monitor", true);
|
void Player::_on_monitor_loaded() {
|
||||||
|
auto object_node = get_tree()->get_root()->find_node("Monitor", true, false);
|
||||||
if (object_node != nullptr)
|
if (object_node != nullptr)
|
||||||
{
|
{
|
||||||
auto state = get_node("StateMachine")->get_child(0);
|
auto state = get_node("StateMachine")->get_child(0);
|
||||||
@ -94,10 +97,12 @@ void Player::_ready()
|
|||||||
WARN_PRINT("State not found!");
|
WARN_PRINT("State not found!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifndef NDEBUG
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WARN_PRINT("Data not found!");
|
WARN_PRINT("Monitor not found!");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_physics_process(float delta)
|
void Player::_physics_process(float delta)
|
||||||
|
@ -280,6 +280,8 @@ namespace godot
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void _on_player_touched();
|
void _on_player_touched();
|
||||||
|
|
||||||
|
void _on_monitor_loaded();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user