Simplified DawnGAme a lot

This commit is contained in:
2023-03-15 15:50:29 -07:00
parent cc7091717c
commit 646f8b057a
31 changed files with 564 additions and 714 deletions

View File

@ -14,7 +14,4 @@ target_include_directories(${DAWN_TARGET_NAME}
# Subdirs
add_subdirectory(game)
add_subdirectory(save)
# Assets
tool_bitmapfont(testbitmap bmfont.png 16 16)
add_subdirectory(save)

View File

@ -6,5 +6,5 @@
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
DawnGame.cpp
HelloGame.cpp
)

View File

@ -1,43 +0,0 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "DawnGame.hpp"
#include "scenes/HelloWorldScene.hpp"
using namespace Dawn;
DawnGame::DawnGame(DawnHost *host) :
host(host),
renderManager(this),
inputManager(this),
saveManager(this)
{
}
int32_t DawnGame::init() {
this->assetManager.init();
this->renderManager.init();
this->scene = new HelloWorldScene(this);
return DAWN_GAME_INIT_RESULT_SUCCESS;
}
int32_t DawnGame::update(float_t delta) {
this->assetManager.update();
this->inputManager.update();
this->timeManager.update(delta);
if(this->scene != nullptr) this->scene->update();
this->renderManager.update();
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
}
void DawnGame::sceneCutover(Scene *scene) {
if(scene == nullptr) scene = this->scene;
this->sceneToCutTo = scene;
}

View File

@ -1,28 +0,0 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "game/_DawnGame.hpp"
#include "save/DawnGameSaveManager.hpp"
namespace Dawn {
class DawnGame : public IDawnGame {
private:
Scene *sceneToCutTo = nullptr;
public:
DawnHost *host;
RenderManager renderManager;
AssetManager assetManager;
InputManager inputManager;
TimeManager timeManager;
DawnGameSaveManager saveManager;
DawnGame(DawnHost *host);
int32_t init() override;
int32_t update(float_t delta) override;
void sceneCutover(Scene *scene) override;
};
}

View File

@ -0,0 +1,13 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "game/DawnGame.hpp"
#include "scenes/HelloWorldScene.hpp"
using namespace Dawn;
Scene * Dawn::dawnGameGetInitialScene(DawnGame *game) {
return new HelloWorldScene(game);
}

View File

@ -6,5 +6,5 @@
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
DawnGameSaveManager.cpp
HelloSave.cpp
)

View File

@ -1,28 +0,0 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "DawnGameSaveManager.hpp"
using namespace Dawn;
DawnGameSaveManager::DawnGameSaveManager(DawnGame *game) : SaveManager(game) {
}
bool_t DawnGameSaveManager::validateSave(struct SaveFile raw) {
if(!raw.has(POKER_SAVE_KEY_EXAMPLE)) return true;
this->currentSave.copy(raw, POKER_SAVE_KEY_EXAMPLE);
return false;
}
void DawnGameSaveManager::setExample(int32_t val) {
savedata_t value;
value.i32 = val;
this->currentSave.set(POKER_SAVE_KEY_EXAMPLE, value);
}
int32_t DawnGameSaveManager::getExample() {
return this->currentSave.get(POKER_SAVE_KEY_EXAMPLE).i32;
}

View File

@ -1,22 +0,0 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "save/SaveManager.hpp"
#define POKER_SAVE_KEY_EXAMPLE "poker.example"
namespace Dawn {
class DawnGameSaveManager : public SaveManager {
protected:
virtual bool_t validateSave(struct SaveFile raw) override;
public:
DawnGameSaveManager(DawnGame *game);
void setExample(int32_t value);
int32_t getExample();
};
}

View File

@ -0,0 +1,12 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "save/SaveManager.hpp"
using namespace Dawn;
bool_t Dawn::saveValidateFile(struct SaveFile raw) {
return false;
}