Fixed code formatting issues.

This commit is contained in:
Tim Sarbin 2019-02-25 00:14:20 -05:00
parent 517a52770d
commit 9c3a2a10c4
6 changed files with 70 additions and 71 deletions

View File

@ -5,8 +5,10 @@
namespace fs = std::experimental::filesystem;
OpenDiablo2::Game::D2DataManager::D2DataManager(const D2EngineConfig &engineConfig)
: fileEntries() {
OpenDiablo2::Game::D2DataManager::D2DataManager(
const D2EngineConfig &engineConfig)
: fileEntries()
{
spdlog::info("Loading data files");
auto mpqExt = std::string(".mpq");
for (auto &p : fs::recursive_directory_iterator(engineConfig.BasePath))

View File

@ -1,8 +1,8 @@
#include <OpenDiablo2.Game/D2Engine.h>
#include <OpenDiablo2.Game/Scenes/D2MainMenu.h>
OpenDiablo2::Game::D2Engine::D2Engine(const D2EngineConfig &config)
OpenDiablo2::Game::D2Engine::D2Engine(
const D2EngineConfig &config)
: config(config)
, gfx(std::make_unique<OpenDiablo2::System::D2Graphics>())
, input(std::make_unique<OpenDiablo2::System::D2Input>())
@ -10,7 +10,8 @@ OpenDiablo2::Game::D2Engine::D2Engine(const D2EngineConfig &config)
{ }
void
OpenDiablo2::Game::D2Engine::Run() {
OpenDiablo2::Game::D2Engine::Run()
{
gfx->InitializeWindow();
sceneStack.emplace(std::make_shared<Scenes::MainMenu>(shared_from_this()));

View File

@ -7,8 +7,9 @@
#include <StormLib.h>
int
main(int argc,
char** argv)
main(
int argc,
char** argv)
{
spdlog::set_level(spdlog::level::trace);
spdlog::set_pattern("[%^%l%$] %v");

View File

@ -6,49 +6,46 @@
#include "OpenDiablo2.System/D2Graphics.h"
namespace OpenDiablo2 {
namespace System {
D2Graphics::D2Graphics() {
atexit(SDL_Quit);
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
spdlog::error("Could not initialize sdl2: " + std::string(SDL_GetError()));
exit(1);
}
}
void
D2Graphics::Clear() {
SDL_RenderClear(renderer.get());
}
void
D2Graphics::InitializeWindow() {
spdlog::debug("Initializing SDL window");
window = std::unique_ptr<SDL_Window, SDLWindowDestroyer>(SDL_CreateWindow("OpenDiablo 2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
800, 600, SDL_WINDOW_SHOWN));
if (window == nullptr) {
spdlog::error("Could not create sdl2 window: " + std::string(SDL_GetError()));
SDL_Quit();
exit(1);
}
spdlog::debug("Initializing SDL renderer");
renderer = std::unique_ptr<SDL_Renderer, SDLRendererDestroyer>(SDL_CreateRenderer(window.get(), -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC));
if (renderer == nullptr){
spdlog::error("Could not create sdl2 window: " + std::string(SDL_GetError()));
SDL_Quit();
exit(1);
}
}
void
D2Graphics::Present() {
SDL_RenderPresent(renderer.get());
}
OpenDiablo2::System::D2Graphics::D2Graphics()
{
atexit(SDL_Quit);
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
spdlog::error("Could not initialize sdl2: " + std::string(SDL_GetError()));
exit(1);
}
}
void
OpenDiablo2::System::D2Graphics::Clear()
{
SDL_RenderClear(renderer.get());
}
void
OpenDiablo2::System::D2Graphics::InitializeWindow()
{
spdlog::debug("Initializing SDL window");
window = std::unique_ptr<SDL_Window, SDLWindowDestroyer>(SDL_CreateWindow("OpenDiablo 2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
800, 600, SDL_WINDOW_SHOWN));
if (window == nullptr) {
spdlog::error("Could not create sdl2 window: " + std::string(SDL_GetError()));
SDL_Quit();
exit(1);
}
spdlog::debug("Initializing SDL renderer");
renderer = std::unique_ptr<SDL_Renderer, SDLRendererDestroyer>(SDL_CreateRenderer(window.get(), -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC));
if (renderer == nullptr){
spdlog::error("Could not create sdl2 window: " + std::string(SDL_GetError()));
SDL_Quit();
exit(1);
}
}
void
OpenDiablo2::System::D2Graphics::Present()
{
SDL_RenderPresent(renderer.get());
}

View File

@ -2,26 +2,24 @@
#include <OpenDiablo2.System/D2Input.h>
#include <SDL2/SDL.h>
namespace OpenDiablo2 {
namespace System {
OpenDiablo2::System::D2Input::D2Input()
{
SDL_Init(SDL_INIT_EVENTS);
}
D2Input::D2Input() {
SDL_Init(SDL_INIT_EVENTS);
}
void
D2Input::ProcessEvents() {
SDL_Event event;
while (SDL_PollEvent(&event)) {
if( event.type == SDL_QUIT ) {
quitIsRequested = true;
}
}
}
bool
D2Input::QuitIsRequested() {
return quitIsRequested;
void
OpenDiablo2::System::D2Input::ProcessEvents()
{
SDL_Event event;
while (SDL_PollEvent(&event)) {
if( event.type == SDL_QUIT ) {
quitIsRequested = true;
}
}
}
bool
OpenDiablo2::System::D2Input::QuitIsRequested()
{
return quitIsRequested;
}

View File

@ -14,9 +14,9 @@ OpenDiablo2::System::D2Sprite::D2Sprite()
OpenDiablo2::System::D2Sprite *
OpenDiablo2::System::D2Sprite::Load(
std::string resourcePath,
std::string palette,
bool cacheFrames)
std::string resourcePath,
std::string palette,
bool cacheFrames)
{
return Load(resourcePath, palette, OpenDiablo2::Game::Common::D2Point {0, 0}, cacheFrames);
}