Dawn/src/dawn/asset/assets/LanguageAsset.hpp

38 lines
949 B
C++

// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "../Asset.hpp"
#include "asset/AssetLoader.hpp"
namespace Dawn {
struct AssetLanguageValue {
size_t begin;
size_t length;
};
enum LangageAssetLoadState {
LANGUAGE_ASSET_LOAD_STATE_NOT_LOADING,
LANGUAGE_ASSET_LOAD_STATE_OPENING,
LANGUAGE_ASSET_LOAD_STATE_CREATING_BUFFER,
LANGUAGE_ASSET_LOAD_STATE_READY_TO_READ
};
class LanguageAsset : public Asset {
protected:
AssetLoader loader;
enum LangageAssetLoadState state = LANGUAGE_ASSET_LOAD_STATE_NOT_LOADING;
std::map<std::string, struct AssetLanguageValue> values;
uint8_t buffer[1024];
public:
LanguageAsset(AssetManager *man, std::string name);
void updateSync() override;
void updateAsync() override;
std::string getValue(std::string key);
};
}