mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-22 02:45:49 -04:00
GGCP
- remove datastore - remove binary parsing in mod.json - try to fix mac build again
This commit is contained in:
parent
02efe58724
commit
72af8b95e6
7 changed files with 23 additions and 160 deletions
9
.github/workflows/build.yml
vendored
9
.github/workflows/build.yml
vendored
|
@ -67,8 +67,13 @@ jobs:
|
|||
echo "${{ github.workspace }}/cli" >> $GITHUB_PATH
|
||||
|
||||
- name: Configure CMake
|
||||
run: |
|
||||
${{ matrix.config.prefixes }} cmake -B ${{ github.workspace }}/build ${{ matrix.config.extra_flags }} -DGEODE_DISABLE_CLI_CALLS=ON -DCLI_PATH="${{ github.workspace }}/cli"
|
||||
run: >
|
||||
${{ matrix.config.prefixes }} cmake -B
|
||||
${{ github.workspace }}/build
|
||||
${{ matrix.config.extra_flags }}
|
||||
-DGEODE_DISABLE_CLI_CALLS=ON
|
||||
-DCLI_PATH="${{ github.workspace }}/cli"
|
||||
--parallel
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
|
|
|
@ -144,10 +144,6 @@ namespace geode {
|
|||
* Mod spritesheet names
|
||||
*/
|
||||
std::vector<std::string> m_spritesheets;
|
||||
/**
|
||||
* Default data store values
|
||||
*/
|
||||
nlohmann::json m_defaultDataStore;
|
||||
/**
|
||||
* Mod settings
|
||||
*/
|
||||
|
@ -202,29 +198,6 @@ namespace geode {
|
|||
// For converting ModInfo back to JSON
|
||||
void GEODE_DLL to_json(nlohmann::json& json, ModInfo const& info);
|
||||
|
||||
/**
|
||||
* @class DataStore
|
||||
* Internal class for notifying Mod
|
||||
* when the datastore changes
|
||||
*/
|
||||
class GEODE_DLL DataStore {
|
||||
nlohmann::json m_store;
|
||||
Mod* m_mod;
|
||||
|
||||
DataStore(Mod* m, nlohmann::json& j) : m_mod(m), m_store(j) {}
|
||||
|
||||
friend class Mod;
|
||||
|
||||
public:
|
||||
~DataStore();
|
||||
|
||||
nlohmann::json& getJson() const;
|
||||
nlohmann::json& operator[](std::string const&);
|
||||
DataStore& operator=(nlohmann::json&);
|
||||
bool contains(std::string const&) const;
|
||||
operator nlohmann::json();
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct HandleToSaved : public T {
|
||||
Mod* m_mod;
|
||||
|
@ -322,10 +295,6 @@ namespace geode {
|
|||
*/
|
||||
std::string m_loadErrorInfo = "";
|
||||
|
||||
/**
|
||||
* Data Store object
|
||||
*/
|
||||
nlohmann::json m_dataStore;
|
||||
/**
|
||||
* Saved values
|
||||
*/
|
||||
|
@ -340,9 +309,6 @@ namespace geode {
|
|||
Result<> saveSettings();
|
||||
Result<> loadSettings();
|
||||
|
||||
[[deprecated("Datastore will be removed in v1.0.0")]]
|
||||
void postDSUpdate();
|
||||
|
||||
Result<> createTempDir();
|
||||
|
||||
static bool validateID(std::string const& id);
|
||||
|
@ -361,7 +327,6 @@ namespace geode {
|
|||
friend class Loader;
|
||||
friend class ::InternalLoader;
|
||||
friend struct ModInfo;
|
||||
friend class DataStore;
|
||||
|
||||
template <class = void>
|
||||
static inline GEODE_HIDDEN Mod* sharedMod = nullptr;
|
||||
|
@ -446,7 +411,7 @@ namespace geode {
|
|||
return m_saved.at(key);
|
||||
} catch(...) {}
|
||||
}
|
||||
m_saved.insert({ key, defaultValue });
|
||||
m_saved[key] = defaultValue;
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
@ -600,21 +565,6 @@ namespace geode {
|
|||
Result<> uninstall();
|
||||
bool isUninstalled() const;
|
||||
|
||||
/**
|
||||
* Return the data store object
|
||||
* @returns DataStore object
|
||||
* store
|
||||
*/
|
||||
[[deprecated("Datastore will be removed in v1.0.0")]]
|
||||
DataStore getDataStore();
|
||||
|
||||
/**
|
||||
* Reset the data store to the
|
||||
* default value
|
||||
*/
|
||||
[[deprecated("Datastore will be removed in v1.0.0")]]
|
||||
Result<> resetDataStore();
|
||||
|
||||
/**
|
||||
* Check whether or not this Mod
|
||||
* depends on another mod
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef GEODE_IS_WINDOWS
|
||||
|
||||
#if defined(GEODE_IS_MACOS)
|
||||
#include "../platform/mac/"
|
||||
#include "../platform/mac/Core.hpp"
|
||||
#elif defined(GEODE_IS_IOS)
|
||||
// #include "iOS.hpp"
|
||||
#endif
|
||||
|
|
|
@ -14,33 +14,6 @@
|
|||
|
||||
USE_GEODE_NAMESPACE();
|
||||
|
||||
nlohmann::json& DataStore::operator[](std::string const& key) {
|
||||
return m_mod->m_dataStore[key];
|
||||
}
|
||||
|
||||
DataStore& DataStore::operator=(nlohmann::json& jsn) {
|
||||
m_mod->m_dataStore = jsn;
|
||||
return *this;
|
||||
}
|
||||
|
||||
nlohmann::json& DataStore::getJson() const {
|
||||
return m_mod->m_dataStore;
|
||||
}
|
||||
|
||||
bool DataStore::contains(std::string const& key) const {
|
||||
return m_mod->m_dataStore.contains(key);
|
||||
}
|
||||
|
||||
DataStore::operator nlohmann::json() {
|
||||
return m_mod->m_dataStore;
|
||||
}
|
||||
|
||||
DataStore::~DataStore() {
|
||||
if (m_store != m_mod->m_dataStore) {
|
||||
m_mod->postDSUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
Mod::Mod(ModInfo const& info) {
|
||||
m_info = info;
|
||||
}
|
||||
|
@ -96,21 +69,6 @@ Result<> Mod::loadSettings() {
|
|||
}
|
||||
}
|
||||
|
||||
// datastore
|
||||
auto dsPath = m_saveDirPath / "ds.json";
|
||||
if (!ghc::filesystem::exists(dsPath)) {
|
||||
m_dataStore = m_info.m_defaultDataStore;
|
||||
}
|
||||
else {
|
||||
GEODE_UNWRAP_INTO(auto dsData, utils::file::readString(dsPath));
|
||||
try {
|
||||
m_dataStore = nlohmann::json::parse(dsData);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
return Err(std::string("Unable to parse datastore: ") + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
@ -137,13 +95,6 @@ Result<> Mod::saveSettings() {
|
|||
return sdw;
|
||||
}
|
||||
|
||||
// datastore
|
||||
auto dsPath = m_saveDirPath / "ds.json";
|
||||
auto dw = utils::file::writeString(dsPath, m_dataStore.dump(4));
|
||||
if (!dw) {
|
||||
return dw;
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
@ -169,18 +120,6 @@ Result<> Mod::saveData() {
|
|||
return this->saveSettings();
|
||||
}
|
||||
|
||||
DataStore Mod::getDataStore() {
|
||||
return DataStore(this, m_dataStore);
|
||||
}
|
||||
|
||||
void Mod::postDSUpdate() {
|
||||
/*EventCenter::get()->send(Event(
|
||||
"datastore-changed",
|
||||
this
|
||||
), this);*/
|
||||
// FIXME: Dispatch
|
||||
}
|
||||
|
||||
Result<> Mod::createTempDir() {
|
||||
ZipFile unzip(m_info.m_path.string());
|
||||
|
||||
|
|
|
@ -31,12 +31,6 @@ Result<ModInfo> ModInfo::createFromSchemaV010(ModJson const& rawJson) {
|
|||
root.needs("developer").into(info.m_developer);
|
||||
root.has("description").into(info.m_description);
|
||||
root.has("repository").into(info.m_repository);
|
||||
if (root.has("datastore").intoRaw(info.m_defaultDataStore)) {
|
||||
log::warn(
|
||||
"[mod.json].datastore is deprecated "
|
||||
"and will be removed in the future."
|
||||
);
|
||||
}
|
||||
root.has("toggleable").into(info.m_supportsDisabling);
|
||||
root.has("unloadable").into(info.m_supportsUnloading);
|
||||
|
||||
|
@ -74,37 +68,15 @@ Result<ModInfo> ModInfo::createFromSchemaV010(ModJson const& rawJson) {
|
|||
// with new cli, binary name is always mod id
|
||||
info.m_binaryName = info.m_id + GEODE_PLATFORM_EXTENSION;
|
||||
|
||||
if (root.has("binary")) {
|
||||
log::warn(
|
||||
"[mod.json].binary is deprecated "
|
||||
"and will be removed in the future."
|
||||
// removed keys
|
||||
if (root.has("datastore")) {
|
||||
log::error(
|
||||
"[mod.json].datastore has been deprecated "
|
||||
"and removed. Use Saved Values instead (see TODO: DOCS LINK)"
|
||||
);
|
||||
}
|
||||
|
||||
root.has("binary").asOneOf<value_t::string, value_t::object>();
|
||||
|
||||
bool autoEndBinaryName = true;
|
||||
|
||||
root.has("binary").is<value_t::string>().into(info.m_binaryName);
|
||||
|
||||
if (auto bin = root.has("binary").is<value_t::object>().obj()) {
|
||||
bin.has("*").into(info.m_binaryName);
|
||||
bin.has("auto").into(autoEndBinaryName);
|
||||
|
||||
#if defined(GEODE_IS_WINDOWS)
|
||||
bin.has("windows").into(info.m_binaryName);
|
||||
#elif defined(GEODE_IS_MACOS)
|
||||
bin.has("macos").into(info.m_binaryName);
|
||||
#elif defined(GEODE_IS_ANDROID)
|
||||
bin.has("android").into(info.m_binaryName);
|
||||
#elif defined(GEODE_IS_IOS)
|
||||
bin.has("ios").into(info.m_binaryName);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (root.has("binary") && autoEndBinaryName &&
|
||||
!utils::string::endsWith(info.m_binaryName, GEODE_PLATFORM_EXTENSION)) {
|
||||
info.m_binaryName += GEODE_PLATFORM_EXTENSION;
|
||||
if (root.has("binary")) {
|
||||
log::error("[mod.json].binary has been deprecated and removed.");
|
||||
}
|
||||
|
||||
if (checker.isError()) {
|
||||
|
|
|
@ -47,14 +47,14 @@ struct GJGarageLayerTest : Modify<GJGarageLayerTest, GJGarageLayer> {
|
|||
addChild(label);
|
||||
}
|
||||
|
||||
// Data Store
|
||||
auto ds = Mod::get()->getDataStore();
|
||||
int out = ds["times-opened"];
|
||||
ds["times-opened"] = out + 1;
|
||||
// Saved Values
|
||||
auto timesOpened = Mod::get()->getSavedValue<int64_t>("times-opened", 0);
|
||||
Mod::get()->setSavedValue("times-opened", timesOpened + 1);
|
||||
|
||||
std::string text = std::string("Times opened: ") + std::to_string(out);
|
||||
|
||||
auto label2 = CCLabelBMFont::create(text.c_str(), "bigFont.fnt");
|
||||
auto label2 = CCLabelBMFont::create(
|
||||
fmt::format("Times opened: {}", timesOpened).c_str(),
|
||||
"bigFont.fnt"
|
||||
);
|
||||
label2->setPosition(100, 90);
|
||||
label2->setScale(.4f);
|
||||
label2->setZOrder(99999);
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
"name": "Geode Test",
|
||||
"developer": "Geode Team",
|
||||
"description": "unit test for geode",
|
||||
"datastore": {
|
||||
"times-opened": 1
|
||||
},
|
||||
"dependencies": [
|
||||
{
|
||||
"id": "geode.testdep",
|
||||
|
|
Loading…
Reference in a new issue