Save Manager

This commit is contained in:
2022-12-17 23:18:06 -08:00
parent 4090e61406
commit 1dbfd9f42e
23 changed files with 574 additions and 15 deletions

View File

@ -20,6 +20,7 @@ add_subdirectory(game)
add_subdirectory(prefabs)
add_subdirectory(ui)
add_subdirectory(visualnovel)
add_subdirectory(save)
add_subdirectory(scenes)
# Assets

View File

@ -15,7 +15,8 @@ DawnGame::DawnGame(DawnHost *host) :
host(host),
renderManager(this),
inputManager(this),
localeManager(this)
localeManager(this),
saveManager(this)
{
}

View File

@ -6,6 +6,7 @@
#pragma once
#include "game/_DawnGame.hpp"
#include "scene/components/Components.hpp"
#include "save/PokerSaveManager.hpp"
namespace Dawn {
class DawnGame : public IDawnGame {
@ -16,6 +17,7 @@ namespace Dawn {
InputManager inputManager;
TimeManager timeManager;
LocaleManager localeManager;
PokerSaveManager saveManager;
DawnGame(DawnHost *host);
int32_t init() override;

View File

@ -0,0 +1,10 @@
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
PokerSaveManager.cpp
)

View File

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

View File

@ -0,0 +1,22 @@
// Copyright (c) 2022 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 PokerSaveManager : public SaveManager {
protected:
virtual bool_t validateSave(struct SaveFile raw) override;
public:
PokerSaveManager(DawnGame *game);
void setExample(int32_t value);
int32_t getExample();
};
}

View File

@ -39,10 +39,6 @@ namespace Dawn {
auto start = new VisualNovelChangeSimpleBackgroundEvent(
vnManager, &texture->texture
);
struct Locale loc;
loc.language = "fr";
this->game->localeManager.setLocale(loc);
start
->then(new VisualNovelTextboxEvent(vnManager, "test"))