feature/cleanup #33

Merged
cromer merged 9 commits from feature/cleanup into develop 2022-08-28 01:09:30 -04:00
3 changed files with 215 additions and 222 deletions
Showing only changes of commit 3478127e86 - Show all commits

View File

@ -2,41 +2,41 @@
#include <SceneTree.hpp>
void alai::main::Main::_register_methods()
void alai::Main::_register_methods()
{
godot::register_method("_ready", &Main::_ready);
godot::register_method("_physics_process", &Main::_physics_process);
godot::register_method("_on_monitor_loaded", &Main::_on_monitor_loaded);
godot::register_property<Main, godot::String>("game_version", &Main::set_game_version, &Main::get_game_version, godot::String(main::game_version.c_str()));
godot::register_property<Main, godot::String>("game_version", &Main::set_game_version, &Main::get_game_version, godot::String(alai::game_version.c_str()));
godot::register_property<Main, godot::Ref<godot::PackedScene>>("level", &Main::set_level, &Main::get_level, NULL, GODOT_METHOD_RPC_MODE_DISABLED, GODOT_PROPERTY_USAGE_DEFAULT, GODOT_PROPERTY_HINT_RESOURCE_TYPE, godot::String("PackedScene"));
godot::register_property<Main, bool>("full_screen", &Main::set_full_screen, &Main::get_full_screen, main::full_screen);
godot::register_property<Main, godot::Vector2>("window_size", &Main::set_window_size, &Main::get_window_size, main::window_size);
godot::register_property<Main, int8_t>("launch_screen", &Main::set_launch_screen, &Main::get_launch_screen, main::launch_screen);
godot::register_property<Main, bool>("full_screen", &Main::set_full_screen, &Main::get_full_screen, alai::full_screen);
godot::register_property<Main, godot::Vector2>("window_size", &Main::set_window_size, &Main::get_window_size, alai::window_size);
godot::register_property<Main, int8_t>("launch_screen", &Main::set_launch_screen, &Main::get_launch_screen, alai::launch_screen);
godot::register_signal<Main>("monitor_loaded");
}
alai::main::Main::Main()
alai::Main::Main()
{
}
alai::main::Main::~Main()
alai::Main::~Main()
{
}
void alai::main::Main::_init()
void alai::Main::_init()
{
_os = godot::OS::get_singleton();
_input = godot::Input::get_singleton();
_project_settings = godot::ProjectSettings::get_singleton();
_resource_loader = godot::ResourceLoader::get_singleton();
game_version = godot::String(main::game_version.c_str());
full_screen = main::full_screen;
window_size = main::window_size;
launch_screen = main::launch_screen;
game_version = godot::String(alai::game_version.c_str());
full_screen = alai::full_screen;
window_size = alai::window_size;
launch_screen = alai::launch_screen;
}
void alai::main::Main::_ready()
void alai::Main::_ready()
{
auto success = _project_settings->load_resource_pack("monitor.pck");
if (success)
@ -84,7 +84,7 @@ void alai::main::Main::_ready()
}
}
void alai::main::Main::_on_monitor_loaded()
void alai::Main::_on_monitor_loaded()
{
if (level != nullptr)
{
@ -94,7 +94,7 @@ void alai::main::Main::_on_monitor_loaded()
}
}
void alai::main::Main::load_monitor()
void alai::Main::load_monitor()
{
godot::Ref<godot::PackedScene> monitor_scene = _resource_loader->load("res://monitor/Monitor.tscn");
add_child(monitor_scene->instance());
@ -103,7 +103,7 @@ void alai::main::Main::load_monitor()
get_tree()->set_pause(true);
}
godot::Node *alai::main::Main::load_level()
godot::Node *alai::Main::load_level()
{
if (level != nullptr)
{
@ -116,7 +116,7 @@ godot::Node *alai::main::Main::load_level()
return nullptr;
}
void alai::main::Main::_physics_process(float delta)
void alai::Main::_physics_process(float delta)
{
if (_input->is_action_just_pressed("ui_cancel"))
{
@ -124,52 +124,52 @@ void alai::main::Main::_physics_process(float delta)
}
}
void alai::main::Main::set_level(godot::Ref<godot::PackedScene> level)
void alai::Main::set_level(godot::Ref<godot::PackedScene> level)
{
this->level = level;
}
godot::Ref<godot::PackedScene> alai::main::Main::get_level()
godot::Ref<godot::PackedScene> alai::Main::get_level()
{
return this->level;
}
void alai::main::Main::set_game_version(godot::String game_version)
void alai::Main::set_game_version(godot::String game_version)
{
this->game_version = game_version;
}
godot::String alai::main::Main::get_game_version()
godot::String alai::Main::get_game_version()
{
return this->game_version;
}
void alai::main::Main::set_full_screen(bool full_screen)
void alai::Main::set_full_screen(bool full_screen)
{
this->full_screen = full_screen;
}
bool alai::main::Main::get_full_screen()
bool alai::Main::get_full_screen()
{
return this->full_screen;
}
void alai::main::Main::set_window_size(godot::Vector2 window_size)
void alai::Main::set_window_size(godot::Vector2 window_size)
{
this-> window_size = window_size;
}
godot::Vector2 alai::main::Main::get_window_size()
godot::Vector2 alai::Main::get_window_size()
{
return this->window_size;
}
void alai::main::Main::set_launch_screen(int8_t launch_screen)
void alai::Main::set_launch_screen(int8_t launch_screen)
{
this->launch_screen = launch_screen;
}
int8_t alai::main::Main::get_launch_screen()
int8_t alai::Main::get_launch_screen()
{
if (this->launch_screen == -1)
{

View File

@ -19,224 +19,217 @@
namespace alai
{
/**
* @brief This namespace houses some global variables and the main class.
* @brief The default value for the game version.
*
*/
namespace main
const std::string game_version = "0.1.0";
/**
* @brief The default value for if the game should start in full screen.
*
*/
const bool full_screen = false;
/**
* @brief The default resolution for the game window.
*
*/
const godot::Vector2 window_size = godot::Vector2(1280, 720);
/**
* @brief The default screen the the game should open on.
*
* @details -1 opens it on the currently active screen. And 0 and above are the screens to use.
*/
const int8_t launch_screen = -1;
/**
* @brief This class controls the Main node.
*
* @details The main node is responsible for controlling the window and the game itself is a child of it.
*/
class Main : public godot::Node
{
/**
* @brief The default value for the game version.
*
*/
const std::string game_version = "0.1.0";
/**
* @brief The default value for if the game should start in full screen.
*
*/
const bool full_screen = false;
/**
* @brief The default resolution for the game window.
*
*/
const godot::Vector2 window_size = godot::Vector2(1280, 720);
/**
* @brief The default screen the the game should open on.
*
* @details -1 opens it on the currently active screen. And 0 and above are the screens to use.
*/
const int8_t launch_screen = -1;
GODOT_CLASS(Main, godot::Node)
/**
* @brief This class controls the Main node.
*
* @details The main node is responsible for controlling the window and the game itself is a child of it.
*/
class Main : public godot::Node
{
GODOT_CLASS(Main, godot::Node)
private:
/**
* @brief OS singleton.
*
*/
godot::OS *_os;
/**
* @brief Input singleton.
*
*/
godot::Input *_input;
/**
* @brief ProjectSettings singleton.
*
*/
godot::ProjectSettings *_project_settings;
/**
* @brief ResourceLoader singleton.
*
*/
godot::ResourceLoader *_resource_loader;
private:
/**
* @brief OS singleton.
*
*/
godot::OS *_os;
/**
* @brief Input singleton.
*
*/
godot::Input *_input;
/**
* @brief ProjectSettings singleton.
*
*/
godot::ProjectSettings *_project_settings;
/**
* @brief ResourceLoader singleton.
*
*/
godot::ResourceLoader *_resource_loader;
/**
* @brief The first level to load
*
*/
godot::Ref<godot::PackedScene> level;
/**
* @brief The current version of the game.
*
*/
godot::String game_version;
/**
* @brief If the window is full screen or not.
*
*/
bool full_screen;
/**
* @brief The size of the window.
*
*/
godot::Vector2 window_size;
/**
* @brief The screen to launch the game on.
*
*/
int8_t launch_screen;
/**
* @brief The first level to load
*
*/
godot::Ref<godot::PackedScene> level;
/**
* @brief The current version of the game.
*
*/
godot::String game_version;
/**
* @brief If the window is full screen or not.
*
*/
bool full_screen;
/**
* @brief The size of the window.
*
*/
godot::Vector2 window_size;
/**
* @brief The screen to launch the game on.
*
*/
int8_t launch_screen;
public:
/**
* @brief This method registers classes with Godot.
*
* @details This method registers methods, properties, and signals with the Godot engine.
*/
static void _register_methods();
public:
/**
* @brief This method registers classes with Godot.
*
* @details This method registers methods, properties, and signals with the Godot engine.
*/
static void _register_methods();
/**
* @brief Construct a new Main object.
*
*/
Main();
/**
* @brief Construct a new Main object.
*
*/
Main();
/**
* @brief Destroy the Main object.
*
*/
~Main();
/**
* @brief Destroy the Main object.
*
*/
~Main();
/**
* @brief Initialize the class from Godot.
*
* @details This method is called just once when the Godot engine connects to the instance of the class.
*/
void _init();
/**
* @brief Initialize the class from Godot.
*
* @details This method is called just once when the Godot engine connects to the instance of the class.
*/
void _init();
/**
* @brief Code to be run when ready.
*
* @details This method is run when all the children of this node are ready.
*/
void _ready();
/**
* @brief Code to be run when ready.
*
* @details This method is run when all the children of this node are ready.
*/
void _ready();
/**
* @brief This class handles the physics processing.
*
* @details Every delta time, this function is called to check for input and update positioning.
*
* @param[in] delta The difference in time that passed since the last call to this method.
*/
void _physics_process(float delta);
/**
* @brief This class handles the physics processing.
*
* @details Every delta time, this function is called to check for input and update positioning.
*
* @param[in] delta The difference in time that passed since the last call to this method.
*/
void _physics_process(float delta);
/**
* @brief Set the level object.
*
* @param[in] level The new level to load when starting.
*/
void set_level(godot::Ref<godot::PackedScene> level);
/**
* @brief Set the level object.
*
* @param[in] level The new level to load when starting.
*/
void set_level(godot::Ref<godot::PackedScene> level);
/**
* @brief Get the level object.
*
* @return Ref<PackedScene> The level scene to load.
*/
godot::Ref<godot::PackedScene> get_level();
/**
* @brief Get the level object.
*
* @return Ref<PackedScene> The level scene to load.
*/
godot::Ref<godot::PackedScene> get_level();
/**
* @brief Set the game version object.
*
* @param[in] game_version The new version fo the game.
*/
void set_game_version(godot::String game_version);
/**
* @brief Set the game version object.
*
* @param[in] game_version The new version fo the game.
*/
void set_game_version(godot::String game_version);
/**
* @brief Get the game version object.
*
* @return String The current version of the game.
*/
godot::String get_game_version();
/**
* @brief Get the game version object.
*
* @return String The current version of the game.
*/
godot::String get_game_version();
/**
* @brief Set the full screen object.
*
* @param[in] full_screen The new full screen state.
*/
void set_full_screen(bool full_screen);
/**
* @brief Set the full screen object.
*
* @param[in] full_screen The new full screen state.
*/
void set_full_screen(bool full_screen);
/**
* @brief Get the full screen object.
*
* @return true If full screen.
* @return false If not full screen.
*/
bool get_full_screen();
/**
* @brief Get the full screen object.
*
* @return true If full screen.
* @return false If not full screen.
*/
bool get_full_screen();
/**
* @brief Set the window size object.
*
* @param[in] window_size The new window size.
*/
void set_window_size(godot::Vector2 window_size);
/**
* @brief Set the window size object.
*
* @param[in] window_size The new window size.
*/
void set_window_size(godot::Vector2 window_size);
/**
* @brief Get the window size object.
*
* @return Vector2 The window size.
*/
godot::Vector2 get_window_size();
/**
* @brief Get the window size object.
*
* @return Vector2 The window size.
*/
godot::Vector2 get_window_size();
/**
* @brief Set the launch screen object.
*
* @param[in] launch_screen The launch screen to use.
*/
void set_launch_screen(int8_t launch_screen);
/**
* @brief Set the launch screen object.
*
* @param[in] launch_screen The launch screen to use.
*/
void set_launch_screen(int8_t launch_screen);
/**
* @brief Get the launch screen object.
*
* @return int8_t The launch screen.
*/
int8_t get_launch_screen();
/**
* @brief Get the launch screen object.
*
* @return int8_t The launch screen.
*/
int8_t get_launch_screen();
/**
* @brief Called when the monitor finishes loading.
*
*/
void _on_monitor_loaded();
/**
* @brief Called when the monitor finishes loading.
*
*/
void _on_monitor_loaded();
/**
* @brief Loads the monitor and adds it to the scene.
*
*/
void load_monitor();
/**
* @brief Loads the monitor and adds it to the scene.
*
*/
void load_monitor();
/**
* @brief Loads the selected level.
*
* @return Node* The level node which we will later add the monitor to.
*/
Node *load_level();
};
}
/**
* @brief Loads the selected level.
*
* @return Node* The level node which we will later add the monitor to.
*/
Node *load_level();
};
}
#endif

View File

@ -41,7 +41,7 @@ extern "C" void GDN_EXPORT godot_nativescript_init(void *handle)
godot::register_class<alai::StateMachine>();
godot::register_class<alai::State>();
godot::register_class<alai::main::Main>();
godot::register_class<alai::Main>();
godot::register_class<alai::CameraLimit>();
godot::register_class<alai::player::Player>();
godot::register_class<alai::player::PlayerIdle>();