Peoplemon  0.1.0
Peoplemon 3 game source documentation
main.cpp
Go to the documentation of this file.
1 #include <BLIB/Engine.hpp>
2 #include <BLIB/Logging.hpp>
3 #include <BLIB/Resources.hpp>
4 #include <BLIB/Util/Waiter.hpp>
5 
6 #include <Core/Files/ItemDB.hpp>
7 #include <Core/Files/MoveDB.hpp>
9 #include <Core/Items/Item.hpp>
10 #include <Core/Peoplemon/Move.hpp>
12 
13 #include <Core/Properties.hpp>
14 #include <Core/Resources.hpp>
15 #include <Core/Systems/Systems.hpp>
17 
18 #include <iostream>
19 
20 int main(int, char**) {
21  bl::logging::Config::rollLogs("logs", "editor", 3);
22  bl::logging::Config::configureOutput(std::cout, bl::logging::Config::Debug);
23  bl::logging::Config::addFileOutput("logs/editor.log", bl::logging::Config::Debug);
24 
25  BL_LOG_INFO << "Loading application properties";
26  if (!core::Properties::load(true)) {
27  BL_LOG_ERROR << "Failed to load application properties";
28  return 1;
29  }
30 
31  BL_LOG_INFO << "Initializing resource systems";
33 
34  BL_LOG_INFO << "Loading game metadata";
35  BL_LOG_INFO << "Loading items";
36  core::file::ItemDB itemdb;
37  if (!itemdb.load()) {
38  BL_LOG_ERROR << "Failed to load item database";
39  return 1;
40  }
42  BL_LOG_INFO << "Loading moves";
43  core::file::MoveDB movedb;
44  if (!movedb.load()) {
45  BL_LOG_ERROR << "Failed to load move database";
46  return 1;
47  }
49  BL_LOG_INFO << "Loading Peoplemon";
51  if (!ppldb.load()) {
52  BL_LOG_ERROR << "Failed to load peoplemon database";
53  return 1;
54  }
56  BL_LOG_INFO << "Game metadata loaded";
57 
59  BL_LOG_INFO << "Registered factories for custom GUI elements";
60 
61  {
62  BL_LOG_INFO << "Creating engine instance";
63  const bl::engine::Settings engineSettings =
64  bl::engine::Settings()
65  .withWindowParameters(
66  bl::engine::Settings::WindowParameters()
67  .withVideoMode(sf::VideoMode(core::Properties::WindowWidth() + 350.f,
69  32))
70  .withStyle(sf::Style::Close | sf::Style::Titlebar | sf::Style::Resize)
71  .withTitle("Peoplemon Editor")
72  .withIcon("EditorResources/icon.png")
73  .withLetterBoxOnResize(false)
74  .withSyncOverlaySizeToWindow(true))
75  .withAllowVariableTimestep(false);
76  bl::engine::Engine engine(engineSettings);
77  BL_LOG_INFO << "Created engine";
78 
79  BL_LOG_INFO << "Initializing game systems";
80  core::system::Systems systems(engine);
81  BL_LOG_INFO << "Core game systems initialized";
82 
83  BL_LOG_INFO << "Running engine main loop";
84  if (!engine.run(std::bind(&editor::state::MainEditor::create, std::ref(systems)))) {
85  BL_LOG_ERROR << "Engine exited with error";
86  bl::util::Waiter::unblockAll();
87  return 1;
88  }
89 
90  BL_LOG_INFO << "Unblocking waiting threads";
91  bl::util::Waiter::unblockAll();
92  }
93 
94  BL_LOG_INFO << "Freeing resources";
95  bl::resource::GarbageCollector::shutdownAndClear();
96 
97  BL_LOG_INFO << "Exiting normally";
98  return 0;
99 }
void installDevLoaders()
Sets up the BLIB resource managers in dev mode.
Definition: Resources.cpp:16
Loads and stores metadata surrounding items in the game.
Definition: ItemDB.hpp:24
bool load()
Loads the item metadata from the data file.
Definition: ItemDB.cpp:11
Stores the metadata of all peoplemon moves.
Definition: MoveDB.hpp:22
bool load()
Loads the moves from the data file.
Definition: MoveDB.cpp:12
Data structure that holds the underlaying data for all the peoplemon.
Definition: PeoplemonDB.hpp:26
bool load()
Loads the database data from the save file.
Definition: PeoplemonDB.cpp:12
static void setDataSource(file::ItemDB &source)
Set the data source for the item methods.
Definition: Item.cpp:41
static void setDataSource(file::MoveDB &source)
Set the data source for each method.
Definition: Move.cpp:46
static void setDataSource(file::PeoplemonDB &data)
Sets the data source for all peoplemon. Must remain in scope.
Definition: Peoplemon.cpp:94
static int WindowWidth()
Definition: Properties.cpp:250
static int WindowHeight()
Definition: Properties.cpp:256
static bool load(bool inEditor)
Loads from the config file and sets defaults. Must be called before using any properties.
Definition: Properties.cpp:119
Owns all primary systems and a reference to the engine.
Definition: Systems.hpp:47
static Ptr create(core::system::Systems &systems)
Construct a new Main Editor state.
Definition: MainEditor.cpp:15
static void registerCustomGuiComponents()
Registers renderer components for custom GUI elements.
Definition: MainEditor.cpp:98
int main()
Definition: main.cpp:8