42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
#include "menu_ui.hpp"
|
|
#include "utils/game_root.hpp"
|
|
#include "utils/godot_macros.h"
|
|
#include <godot_cpp/classes/button.hpp>
|
|
#include <godot_cpp/classes/control.hpp>
|
|
#include <godot_cpp/classes/global_constants.hpp>
|
|
#include <godot_cpp/classes/packed_scene.hpp>
|
|
|
|
namespace godot {
|
|
void MenuUI::_bind_methods() {
|
|
#define CLASSNAME MenuUI
|
|
GDPROPERTY_HINTED(game_scene, Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, "PackedScene");
|
|
}
|
|
|
|
void MenuUI::_enter_tree() { GDGAMEONLY();
|
|
Button *start_button = this->get_node<Button>("StartButton");
|
|
start_button->connect("button_down", callable_mp(this, &MenuUI::start_game));
|
|
start_button->grab_focus();
|
|
Button *controls_button = this->get_node<Button>("ControlsButton");
|
|
controls_button->connect("button_down", callable_mp(this, &MenuUI::toggle_controls));
|
|
this->controls = this->get_node<Control>("ControlsScreen");
|
|
this->controls->set_visible(false);
|
|
}
|
|
|
|
void MenuUI::start_game() {
|
|
this->get_parent()->queue_free();
|
|
GameRoot3D::get_singleton()->load_level(this->game_scene);
|
|
}
|
|
|
|
void MenuUI::toggle_controls() {
|
|
this->controls->set_visible(true);
|
|
}
|
|
|
|
void MenuUI::set_game_scene(Ref<PackedScene> scene) {
|
|
this->game_scene = scene;
|
|
}
|
|
|
|
Ref<PackedScene> MenuUI::get_game_scene() const {
|
|
return this->game_scene;
|
|
}
|
|
}
|