Cutscenes are now integrated into the game. LONG LIVE THE RAT KING!
This commit is contained in:
parent
fa4573be7b
commit
8fdaadaf12
5 changed files with 30 additions and 17 deletions
36
gui/fsm.cpp
36
gui/fsm.cpp
|
|
@ -213,6 +213,9 @@ namespace gui {
|
||||||
|
|
||||||
void FSM::BOSS_FIGHT(Event ev, std::any data) {
|
void FSM::BOSS_FIGHT(Event ev, std::any data) {
|
||||||
dbc::check($boss_fight != nullptr, "$boss_fight not initialized");
|
dbc::check($boss_fight != nullptr, "$boss_fight not initialized");
|
||||||
|
|
||||||
|
if($boss_scene->playing()) return;
|
||||||
|
|
||||||
$boss_fight->mouse_pos = mouse_position();
|
$boss_fight->mouse_pos = mouse_position();
|
||||||
|
|
||||||
if(ev == gui::Event::QUIT) {
|
if(ev == gui::Event::QUIT) {
|
||||||
|
|
@ -380,31 +383,31 @@ namespace gui {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSM::draw_gui() {
|
void FSM::draw_gui() {
|
||||||
if(in_state(State::BOSS_FIGHT)) {
|
if($debug_ui.active) {
|
||||||
$boss_fight->render($window);
|
debug_render();
|
||||||
} else {
|
} else {
|
||||||
if($debug_ui.active) {
|
$main_ui.render();
|
||||||
debug_render();
|
}
|
||||||
} else {
|
|
||||||
$main_ui.render();
|
|
||||||
}
|
|
||||||
|
|
||||||
$status_ui.render($window);
|
$status_ui.render($window);
|
||||||
$combat_ui.render($window);
|
$combat_ui.render($window);
|
||||||
if($loot_ui.active) $loot_ui.render($window);
|
if($loot_ui.active) $loot_ui.render($window);
|
||||||
|
|
||||||
if(in_state(State::LOOTING)) $dnd_loot.render();
|
if(in_state(State::LOOTING)) $dnd_loot.render();
|
||||||
|
|
||||||
if($map_open) {
|
if($map_open) {
|
||||||
$map_ui.render($window, $main_ui.$compass_dir);
|
$map_ui.render($window, $main_ui.$compass_dir);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSM::render() {
|
void FSM::render() {
|
||||||
if(in_state(State::BOSS_FIGHT)) {
|
if(in_state(State::BOSS_FIGHT)) {
|
||||||
$window.clear();
|
$window.clear();
|
||||||
$boss_fight->render($window);
|
if($boss_scene->playing()) {
|
||||||
|
$boss_scene->render($window);
|
||||||
|
} else {
|
||||||
|
$boss_fight->render($window);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
draw_gui();
|
draw_gui();
|
||||||
}
|
}
|
||||||
|
|
@ -538,7 +541,10 @@ namespace gui {
|
||||||
|
|
||||||
void FSM::next_level(bool bossfight) {
|
void FSM::next_level(bool bossfight) {
|
||||||
if(bossfight) {
|
if(bossfight) {
|
||||||
|
$boss_scene = std::make_shared<storyboard::UI>("rat_king");
|
||||||
$boss_fight = boss::System::create_bossfight();
|
$boss_fight = boss::System::create_bossfight();
|
||||||
|
$boss_scene->init();
|
||||||
|
dbc::check($boss_scene->playing(), "boss scene doesn't play");
|
||||||
} else {
|
} else {
|
||||||
GameDB::create_level();
|
GameDB::create_level();
|
||||||
$status_ui.update_level();
|
$status_ui.update_level();
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include "events.hpp"
|
#include "events.hpp"
|
||||||
#include "gui/event_router.hpp"
|
#include "gui/event_router.hpp"
|
||||||
#include "gui/dnd_loot.hpp"
|
#include "gui/dnd_loot.hpp"
|
||||||
|
#include "storyboard/ui.hpp"
|
||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
enum class State {
|
enum class State {
|
||||||
|
|
@ -36,6 +37,7 @@ namespace gui {
|
||||||
DebugUI $debug_ui;
|
DebugUI $debug_ui;
|
||||||
MainUI $main_ui;
|
MainUI $main_ui;
|
||||||
std::shared_ptr<boss::Fight> $boss_fight = nullptr;
|
std::shared_ptr<boss::Fight> $boss_fight = nullptr;
|
||||||
|
std::shared_ptr<storyboard::UI> $boss_scene = nullptr;
|
||||||
CombatUI $combat_ui;
|
CombatUI $combat_ui;
|
||||||
StatusUI $status_ui;
|
StatusUI $status_ui;
|
||||||
MapViewUI $map_ui;
|
MapViewUI $map_ui;
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,10 @@ namespace storyboard {
|
||||||
window.draw($view_sprite);
|
window.draw($view_sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UI::playing() {
|
||||||
|
return $audio->getStatus() == sf::SoundSource::Status::Playing;
|
||||||
|
}
|
||||||
|
|
||||||
sf::Time parse_time_code(const std::string& time) {
|
sf::Time parse_time_code(const std::string& time) {
|
||||||
std::chrono::seconds out{};
|
std::chrono::seconds out{};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ namespace storyboard {
|
||||||
void zoom(const std::string &cell_name);
|
void zoom(const std::string &cell_name);
|
||||||
void reset();
|
void reset();
|
||||||
void track_audio();
|
void track_audio();
|
||||||
|
bool playing();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,7 @@ int main(int, char*[]) {
|
||||||
storyboard::UI main("rat_king");
|
storyboard::UI main("rat_king");
|
||||||
main.init();
|
main.init();
|
||||||
|
|
||||||
while(true) {
|
while(main.playing()) {
|
||||||
|
|
||||||
while(const auto ev = window.pollEvent()) {
|
while(const auto ev = window.pollEvent()) {
|
||||||
auto gui_ev = router.process_event(ev);
|
auto gui_ev = router.process_event(ev);
|
||||||
auto mouse_pos = window.mapPixelToCoords(router.position);
|
auto mouse_pos = window.mapPixelToCoords(router.position);
|
||||||
|
|
@ -41,6 +40,7 @@ int main(int, char*[]) {
|
||||||
main.mouse(mouse_pos.x, mouse_pos.y, guecs::NO_MODS);
|
main.mouse(mouse_pos.x, mouse_pos.y, guecs::NO_MODS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main.render(window);
|
main.render(window);
|
||||||
window.display();
|
window.display();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue