I hate cmake
This commit is contained in:
8
.gitmodules
vendored
8
.gitmodules
vendored
@ -9,4 +9,10 @@
|
||||
url = https://github.com/recp/cglm
|
||||
[submodule "lib/glfw"]
|
||||
path = lib/glfw
|
||||
url = https://github.com/glfw/glfw
|
||||
url = https://github.com/glfw/glfw
|
||||
[submodule "lib/libzip"]
|
||||
path = lib/libzip
|
||||
url = https://github.com/nih-at/libzip
|
||||
[submodule "lib/zlib"]
|
||||
path = lib/zlib
|
||||
url = https://github.com/madler/zlib
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include "game.h"
|
||||
|
||||
#define CHUNK 16384
|
||||
|
||||
bool sandboxGameInit(sandboxgame_t *game) {
|
||||
quadInit(&game->quad, 0, 0,0,0,0, 500,500,1,1);
|
||||
|
||||
@ -25,6 +27,8 @@ bool sandboxGameInit(sandboxgame_t *game) {
|
||||
|
||||
assetManagerStart(&game->manager);
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
72
src/save/save.c
Normal file
72
src/save/save.c
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "save.h"
|
||||
|
||||
void saveManagerInit(savemanager_t *man) {
|
||||
man->count = 0;
|
||||
}
|
||||
|
||||
savevalue_t * saveManagerAddOrGet(savemanager_t *man, char *key) {
|
||||
uint8_t i, j;
|
||||
|
||||
j = saveManagerGetKey(man, key);
|
||||
|
||||
if(j != 0xFF) return man->values + j;
|
||||
|
||||
// Find empty key
|
||||
for(i = 0; i < man->count; i++) {
|
||||
if(man->keys[i] != NULL) continue;
|
||||
|
||||
man->keys[i] = key;
|
||||
return man->values + i;
|
||||
}
|
||||
|
||||
// No empty key
|
||||
man->keys[man->count] = key;
|
||||
return man->values + man->count++;
|
||||
}
|
||||
|
||||
uint8_t saveManagerGetKey(savemanager_t *man, char *key) {
|
||||
uint8_t i;
|
||||
for(i = 0; i < man->count; i++) {
|
||||
if(strcmp(man->keys + i, key) == 0) return i;
|
||||
}
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
void saveManagerRemove(savemanager_t *man, char *key) {
|
||||
uint8_t i;
|
||||
|
||||
i = saveManagerGetKey(man, key);
|
||||
if(i == 0xFF) return;
|
||||
|
||||
man->keys[i] = NULL;
|
||||
}
|
||||
|
||||
|
||||
// Setters
|
||||
savevalue_t * saveManagerSetBool(savemanager_t *man, char *key, bool val) {
|
||||
savevalue_t * v = saveManagerAddOrGet(man, key);
|
||||
v->b = val;
|
||||
return v;
|
||||
}
|
||||
|
||||
savevalue_t * saveManagerSetUint8(savemanager_t *man, char *key, uint8_t val) {
|
||||
savevalue_t * v = saveManagerAddOrGet(man, key);
|
||||
v->u8 = val;
|
||||
return v;
|
||||
}
|
||||
|
||||
// Getters
|
||||
bool saveManagerGetBool(savemanager_t *man, char *key) {
|
||||
return saveManagerAddOrGet(man, key)->b;
|
||||
}
|
||||
|
||||
uint8_t saveManagerGetUint8(savemanager_t *man, char *key) {
|
||||
return saveManagerAddOrGet(man, key)->u8;
|
||||
}
|
41
src/save/save.h
Normal file
41
src/save/save.h
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
#include "../util/array.h"
|
||||
|
||||
#define SAVE_VALUES_MAX 200
|
||||
|
||||
typedef union {
|
||||
// char *s;
|
||||
bool b;
|
||||
uint8_t u8;
|
||||
int8_t i8;
|
||||
int16_t i16;
|
||||
int32_t i32;
|
||||
} savevalue_t;
|
||||
|
||||
typedef struct {
|
||||
char *keys[SAVE_VALUES_MAX];
|
||||
savevalue_t values[SAVE_VALUES_MAX];
|
||||
uint8_t count;
|
||||
} savemanager_t;
|
||||
|
||||
void saveManagerInit(savemanager_t *man);
|
||||
|
||||
savevalue_t * saveManagerAddOrGet(savemanager_t *man, char *key);
|
||||
|
||||
uint8_t saveManagerGetKey(savemanager_t *man, char *key);
|
||||
|
||||
void saveManagerRemove(savemanager_t *man, char *key);
|
||||
|
||||
savevalue_t * saveManagerSetBool(savemanager_t *man, char *key, bool val);
|
||||
savevalue_t * saveManagerSetUint8(savemanager_t *man, char *key, uint8_t val);
|
||||
|
||||
bool saveManagerGetBool(savemanager_t *man, char *key);
|
||||
uint8_t saveManagerGetUint8(savemanager_t *man, char *key);
|
Reference in New Issue
Block a user