1 #include <BLIB/Engine.hpp>
2 #include <BLIB/Logging.hpp>
3 #include <BLIB/Resources.hpp>
4 #include <BLIB/Util/Waiter.hpp>
22 #include <BLIB/ECS.hpp>
26 virtual void observe(
const bl::engine::event::WindowResized&)
override {
31 int main(
int argc,
char** argv) {
32 #ifdef PEOPLEMON_DEBUG
33 bl::logging::Config::rollLogs(
"logs",
"verbose", 3);
34 bl::logging::Config::configureOutput(std::cout, bl::logging::Config::Info);
35 bl::logging::Config::addFileOutput(
"logs/verbose.log", bl::logging::Config::Trace);
37 bl::logging::Config::rollLogs(
"logs",
"error", 3);
38 bl::logging::Config::configureOutput(std::cout, bl::logging::Config::Warn);
39 bl::logging::Config::addFileOutput(
"logs/error.log", bl::logging::Config::Warn);
44 BL_LOG_INFO <<
"Initializing resource systems";
45 #ifdef PEOPLEMON_DEBUG
51 BL_LOG_INFO <<
"Loading application properties";
53 BL_LOG_ERROR <<
"Failed to load application properties";
57 bl::event::Dispatcher::subscribe(&sizePersist);
58 bl::cam::OverlayCamera::setOverlayCoordinateSpace(
62 BL_LOG_INFO <<
"Loading game metadata";
63 BL_LOG_INFO <<
"Loading items";
66 BL_LOG_ERROR <<
"Failed to load item database";
70 BL_LOG_INFO <<
"Loading moves";
73 BL_LOG_ERROR <<
"Failed to load move database";
77 BL_LOG_INFO <<
"Loading Peoplemon";
80 BL_LOG_ERROR <<
"Failed to load peoplemon database";
84 BL_LOG_INFO <<
"Game metadata loaded";
87 BL_LOG_INFO <<
"Creating engine instance";
88 const bl::engine::Settings engineSettings =
89 bl::engine::Settings()
90 .withWindowParameters(
91 bl::engine::Settings::WindowParameters()
92 .withVideoMode(sf::VideoMode(
94 .withStyle(sf::Style::Close | sf::Style::Titlebar | sf::Style::Resize)
95 .withTitle(
"Peoplemon")
97 .withLetterBoxOnResize(
true)
101 bl::engine::Engine engine(engineSettings);
103 BL_LOG_INFO <<
"Created engine";
105 BL_LOG_INFO <<
"Initializing game systems";
106 #ifdef PEOPLEMON_DEBUG
107 engine.systems().registerSystem<core::debug::DebugBanner>(bl::engine::FrameStage::Update0,
108 bl::engine::StateMask::All);
111 BL_LOG_INFO <<
"Core game systems initialized";
113 BL_LOG_INFO <<
"Configuring menu sounds";
119 #ifdef PEOPLEMON_DEBUG
120 core::debug::DebugOverrides::subscribe();
123 const std::string path = argv[1];
124 BL_LOG_INFO <<
"Loading save: " << path;
126 BL_LOG_CRITICAL <<
"Failed to load save";
133 BL_LOG_INFO <<
"Running engine main loop";
134 if (!engine.run(state)) {
135 BL_LOG_ERROR <<
"Engine exited with error";
136 bl::util::Waiter::unblockAll();
140 BL_LOG_INFO <<
"Unblocking waiting threads";
141 bl::util::Waiter::unblockAll();
144 BL_LOG_INFO <<
"Freeing resources";
145 bl::resource::GarbageCollector::shutdownAndClear();
147 BL_LOG_INFO <<
"Exiting normally";
void installProdLoaders()
Sets up the BLIB resource managers in prod mode and mounts the resource bundles.
void installDevLoaders()
Sets up the BLIB resource managers in dev mode.
void configureInputSystem(bl::input::InputSystem &system)
Configures the input system for the set of peoplemon inputs.
static bool loadFromFile(const std::string &sourceFile)
Loads the game from the given save file.
Loads and stores metadata surrounding items in the game.
bool load()
Loads the item metadata from the data file.
Stores the metadata of all peoplemon moves.
bool load()
Loads the moves from the data file.
Data structure that holds the underlaying data for all the peoplemon.
bool load()
Loads the database data from the save file.
static void setDataSource(file::ItemDB &source)
Set the data source for the item methods.
static void setDataSource(file::MoveDB &source)
Set the data source for each method.
static void setDataSource(file::PeoplemonDB &data)
Sets the data source for all peoplemon. Must remain in scope.
static void save()
Saves the config to the data file.
static bl::audio::AudioSystem::Handle MenuMoveFailSound()
static bl::audio::AudioSystem::Handle MenuMoveSound()
static sf::Vector2f WindowSize()
static int WindowHeight()
static bool load(bool inEditor)
Loads from the config file and sets defaults. Must be called before using any properties.
static const std::string & WindowIconFile()
Owns all primary systems and a reference to the engine.
static bl::engine::State::Ptr create(core::system::Systems &systems)
Creates the main game state. The game state must be initialized before invoking the main game state.
static bl::engine::State::Ptr create(core::system::Systems &systems)
Creates a new MainMenu state.
virtual void observe(const bl::engine::event::WindowResized &) override