comment out some config stuff to get sdl2 building again, will work through and remove config as chemical is the updated config
This commit is contained in:
parent
122eb1d351
commit
119d1b2c64
4 changed files with 336 additions and 336 deletions
|
|
@ -9,15 +9,15 @@ extern "C" {
|
||||||
#include "arc/std/string.h"
|
#include "arc/std/string.h"
|
||||||
|
|
||||||
typedef struct ARC_Config ARC_Config;
|
typedef struct ARC_Config ARC_Config;
|
||||||
void ARC_MathConfig_Init(ARC_Config *config);
|
//void ARC_MathConfig_Init(ARC_Config *config);
|
||||||
|
//
|
||||||
uint8_t ARC_Point_Read (ARC_Config *config, ARC_String *string, void **value);
|
//uint8_t ARC_Point_Read (ARC_Config *config, ARC_String *string, void **value);
|
||||||
uint8_t ARC_Rect_Read (ARC_Config *config, ARC_String *string, void **value);
|
//uint8_t ARC_Rect_Read (ARC_Config *config, ARC_String *string, void **value);
|
||||||
uint8_t ARC_RectArray_Read(ARC_Config *config, ARC_String *string, void **value);
|
//uint8_t ARC_RectArray_Read(ARC_Config *config, ARC_String *string, void **value);
|
||||||
|
//
|
||||||
void ARC_Point_Delete (ARC_Config *config, ARC_String *string, void *value);
|
//void ARC_Point_Delete (ARC_Config *config, ARC_String *string, void *value);
|
||||||
void ARC_Rect_Delete (ARC_Config *config, ARC_String *string, void *value);
|
//void ARC_Rect_Delete (ARC_Config *config, ARC_String *string, void *value);
|
||||||
void ARC_RectArray_Delete(ARC_Config *config, ARC_String *string, void *value);
|
//void ARC_RectArray_Delete(ARC_Config *config, ARC_String *string, void *value);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ void ARC_Config_AddKey(ARC_Config *config, ARC_String *type, ARC_ConfigKeyRead k
|
||||||
* @param keyRead function for reading/creating key from string
|
* @param keyRead function for reading/creating key from string
|
||||||
* @param keyDelete function for deleting stored key
|
* @param keyDelete function for deleting stored key
|
||||||
*/
|
*/
|
||||||
void ARC_Config_AddKeyCString(ARC_Config *config, const char *type, uint64_t length, ARC_ConfigKeyRead keyRead, ARC_ConfigKeyDelete keyDelete);
|
//void ARC_Config_AddKeyCString(ARC_Config *config, const char *type, uint64_t length, ARC_ConfigKeyRead keyRead, ARC_ConfigKeyDelete keyDelete);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief external callback to add keys to config
|
* @brief external callback to add keys to config
|
||||||
|
|
@ -99,7 +99,7 @@ void ARC_Config_SetGroup(ARC_Config *config, ARC_String *groupname);
|
||||||
* @param keyname name of key to get from config
|
* @param keyname name of key to get from config
|
||||||
* @param value data retrieved from config
|
* @param value data retrieved from config
|
||||||
*/
|
*/
|
||||||
void ARC_Config_Get(ARC_Config *config, ARC_String *keyname, void **value);
|
//void ARC_Config_Get(ARC_Config *config, ARC_String *keyname, void **value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief commands that can be used in ARC_Config_FileIO
|
* @brief commands that can be used in ARC_Config_FileIO
|
||||||
|
|
|
||||||
|
|
@ -8,36 +8,36 @@
|
||||||
|
|
||||||
// #define ARC_DEFAULT_CONFIG
|
// #define ARC_DEFAULT_CONFIG
|
||||||
#include "arc/std/defaults/config.h"
|
#include "arc/std/defaults/config.h"
|
||||||
|
//
|
||||||
void ARC_AudioConfig_Init(ARC_Config *config){
|
//void ARC_AudioConfig_Init(ARC_Config *config){
|
||||||
ARC_Config_AddKeyCString(config, (char *)"ARC_Audio", 9, ARC_Audio_Read, ARC_Audio_Delete);
|
// ARC_Config_AddKeyCString(config, (char *)"ARC_Audio", 9, ARC_Audio_Read, ARC_Audio_Delete);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
uint8_t ARC_Audio_Read(ARC_Config *config, ARC_String *string, void **value){
|
//uint8_t ARC_Audio_Read(ARC_Config *config, ARC_String *string, void **value){
|
||||||
ARC_Config_Get(config, string, value);
|
// ARC_Config_Get(config, string, value);
|
||||||
if(*value){
|
// if(*value){
|
||||||
return 1;
|
// return 1;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(string->data[0] != '"' || string->data[string->length - 1] != '"'){
|
// if(string->data[0] != '"' || string->data[string->length - 1] != '"'){
|
||||||
ARC_DEBUG_LOG_ERROR_WITH_VARIABLES("in ARC_Point_Read(config, string, value); no matching quotes: %s", string->data);
|
// ARC_DEBUG_LOG_ERROR_WITH_VARIABLES("in ARC_Point_Read(config, string, value); no matching quotes: %s", string->data);
|
||||||
arc_errno = ARC_ERRNO_DATA;
|
// arc_errno = ARC_ERRNO_DATA;
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ARC_Audio *audio = (ARC_Audio *)malloc(sizeof(ARC_Audio));
|
// ARC_Audio *audio = (ARC_Audio *)malloc(sizeof(ARC_Audio));
|
||||||
|
//
|
||||||
ARC_String *path;
|
// ARC_String *path;
|
||||||
ARC_String_CopySubstring(&path, string, 1, string->length - 2);
|
// ARC_String_CopySubstring(&path, string, 1, string->length - 2);
|
||||||
audio->chunk = Mix_LoadWAV(path->data);
|
// audio->chunk = Mix_LoadWAV(path->data);
|
||||||
|
//
|
||||||
//TODO: get error message if not loaded
|
// //TODO: get error message if not loaded
|
||||||
|
//
|
||||||
*value = (void *)audio;
|
// *value = (void *)audio;
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
void ARC_Audio_Delete(ARC_Config* config, ARC_String *string, void *value){
|
//void ARC_Audio_Delete(ARC_Config* config, ARC_String *string, void *value){
|
||||||
Mix_FreeChunk(((ARC_Audio *)value)->chunk);
|
// Mix_FreeChunk(((ARC_Audio *)value)->chunk);
|
||||||
free((ARC_Audio *)value);
|
// free((ARC_Audio *)value);
|
||||||
}
|
//}
|
||||||
|
|
@ -17,295 +17,295 @@
|
||||||
// #define ARC_DEFAULT_CONFIG
|
// #define ARC_DEFAULT_CONFIG
|
||||||
#include "arc/std/defaults/config.h"
|
#include "arc/std/defaults/config.h"
|
||||||
|
|
||||||
SDL_Renderer *global_renderer;
|
//SDL_Renderer *global_renderer;
|
||||||
|
//
|
||||||
uint8_t ARC_SDL_Texture_Read(ARC_Config *config, ARC_String *string, void **value);
|
//uint8_t ARC_SDL_Texture_Read(ARC_Config *config, ARC_String *string, void **value);
|
||||||
uint8_t ARC_Spritesheet_Read(ARC_Config *config, ARC_String *string, void **value);
|
//uint8_t ARC_Spritesheet_Read(ARC_Config *config, ARC_String *string, void **value);
|
||||||
uint8_t ARC_Sprite_Read (ARC_Config *config, ARC_String *string, void **value);
|
//uint8_t ARC_Sprite_Read (ARC_Config *config, ARC_String *string, void **value);
|
||||||
|
//
|
||||||
void ARC_SDL_Texture_Delete(ARC_Config *config, ARC_String *string, void *value);
|
//void ARC_SDL_Texture_Delete(ARC_Config *config, ARC_String *string, void *value);
|
||||||
void ARC_Spritesheet_Delete(ARC_Config *config, ARC_String *string, void *value);
|
//void ARC_Spritesheet_Delete(ARC_Config *config, ARC_String *string, void *value);
|
||||||
void ARC_Sprite_Delete (ARC_Config *config, ARC_String *string, void *value);
|
//void ARC_Sprite_Delete (ARC_Config *config, ARC_String *string, void *value);
|
||||||
|
//
|
||||||
void ARC_GraphicsConfig_Init(ARC_Config *config, ARC_Renderer *renderer){
|
//void ARC_GraphicsConfig_Init(ARC_Config *config, ARC_Renderer *renderer){
|
||||||
global_renderer = (SDL_Renderer *)renderer;
|
// global_renderer = (SDL_Renderer *)renderer;
|
||||||
ARC_Config_AddKeyCString(config, (char *)"SDL_Texture" , 11, ARC_SDL_Texture_Read, ARC_SDL_Texture_Delete);
|
// ARC_Config_AddKeyCString(config, (char *)"SDL_Texture" , 11, ARC_SDL_Texture_Read, ARC_SDL_Texture_Delete);
|
||||||
ARC_Config_AddKeyCString(config, (char *)"ARC_Spritesheet", 15, ARC_Spritesheet_Read, ARC_Spritesheet_Delete);
|
// ARC_Config_AddKeyCString(config, (char *)"ARC_Spritesheet", 15, ARC_Spritesheet_Read, ARC_Spritesheet_Delete);
|
||||||
ARC_Config_AddKeyCString(config, (char *)"ARC_Sprite" , 10, ARC_Sprite_Read , ARC_Sprite_Delete );
|
// ARC_Config_AddKeyCString(config, (char *)"ARC_Sprite" , 10, ARC_Sprite_Read , ARC_Sprite_Delete );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
uint64_t ARC_GraphicsConfig_GetIndexAndErrorCheck(ARC_String *string, char *search, uint64_t searchLength){
|
//uint64_t ARC_GraphicsConfig_GetIndexAndErrorCheck(ARC_String *string, char *search, uint64_t searchLength){
|
||||||
uint64_t separator = ARC_String_FindCString(string, ",", 1);
|
// uint64_t separator = ARC_String_FindCString(string, ",", 1);
|
||||||
|
//
|
||||||
if(separator == ~(uint64_t)0){
|
// if(separator == ~(uint64_t)0){
|
||||||
arc_errno = ARC_ERRNO_DATA;
|
// arc_errno = ARC_ERRNO_DATA;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return separator;
|
// return separator;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
int32_t ARC_SDL_Texture_Load(const char *path, SDL_Texture **texture){
|
//int32_t ARC_SDL_Texture_Load(const char *path, SDL_Texture **texture){
|
||||||
IMG_Init(IMG_INIT_PNG);
|
// IMG_Init(IMG_INIT_PNG);
|
||||||
SDL_Surface *surface = IMG_Load(path);
|
// SDL_Surface *surface = IMG_Load(path);
|
||||||
if(!surface){
|
// if(!surface){
|
||||||
printf("Error: reading png '%s'\nSDL_Image Error: %s", path, IMG_GetError());
|
// printf("Error: reading png '%s'\nSDL_Image Error: %s", path, IMG_GetError());
|
||||||
return 1; // GE_SDL_ERRNO_
|
// return 1; // GE_SDL_ERRNO_
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
SDL_BlendMode tempMode;
|
// SDL_BlendMode tempMode;
|
||||||
SDL_GetSurfaceBlendMode(surface, &tempMode);
|
// SDL_GetSurfaceBlendMode(surface, &tempMode);
|
||||||
*texture = SDL_CreateTextureFromSurface(global_renderer, surface);
|
// *texture = SDL_CreateTextureFromSurface(global_renderer, surface);
|
||||||
SDL_GetTextureBlendMode(*texture, &tempMode);
|
// SDL_GetTextureBlendMode(*texture, &tempMode);
|
||||||
|
//
|
||||||
SDL_FreeSurface(surface);
|
// SDL_FreeSurface(surface);
|
||||||
IMG_Quit();
|
// IMG_Quit();
|
||||||
|
//
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
uint8_t ARC_SDL_Texture_Read(ARC_Config* config, ARC_String *string, void **value){
|
//uint8_t ARC_SDL_Texture_Read(ARC_Config* config, ARC_String *string, void **value){
|
||||||
ARC_Config_Get(config, string, value);
|
// ARC_Config_Get(config, string, value);
|
||||||
if(*value){
|
// if(*value){
|
||||||
return 1;
|
// return 1;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ARC_String *tempStr, *textureStr;
|
// ARC_String *tempStr, *textureStr;
|
||||||
ARC_String_StripEndsWhitespace(&tempStr, string);
|
// ARC_String_StripEndsWhitespace(&tempStr, string);
|
||||||
|
//
|
||||||
ARC_String_CopySubstring(&textureStr, tempStr, 1, tempStr->length - 2);
|
// ARC_String_CopySubstring(&textureStr, tempStr, 1, tempStr->length - 2);
|
||||||
ARC_String_Destroy(tempStr);
|
// ARC_String_Destroy(tempStr);
|
||||||
|
//
|
||||||
ARC_SDL_Texture_Load(textureStr->data, (SDL_Texture **)value);
|
// ARC_SDL_Texture_Load(textureStr->data, (SDL_Texture **)value);
|
||||||
|
//
|
||||||
ARC_String_Destroy(textureStr);
|
// ARC_String_Destroy(textureStr);
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
void ARC_Spritesheet_ReadTexture(ARC_Config *config, ARC_String *string, uint32_t *size, void **value){
|
//void ARC_Spritesheet_ReadTexture(ARC_Config *config, ARC_String *string, uint32_t *size, void **value){
|
||||||
SDL_Texture *texture;
|
// SDL_Texture *texture;
|
||||||
|
//
|
||||||
ARC_String *tempStr, *textureStr;
|
// ARC_String *tempStr, *textureStr;
|
||||||
ARC_String_StripEndsWhitespace(&tempStr, string);
|
// ARC_String_StripEndsWhitespace(&tempStr, string);
|
||||||
|
//
|
||||||
//check for reference
|
// //check for reference
|
||||||
ARC_Config_Get(config, tempStr, (void **)&texture);
|
// ARC_Config_Get(config, tempStr, (void **)&texture);
|
||||||
if(!texture && (tempStr->data[0] != '"' || tempStr->data[string->length - 1] != '"')){
|
// if(!texture && (tempStr->data[0] != '"' || tempStr->data[string->length - 1] != '"')){
|
||||||
arc_errno = ARC_ERRNO_DATA;
|
// arc_errno = ARC_ERRNO_DATA;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ARC_String_CopySubstring(&textureStr, tempStr, 1, tempStr->length - 2);
|
// ARC_String_CopySubstring(&textureStr, tempStr, 1, tempStr->length - 2);
|
||||||
ARC_String_Destroy(tempStr);
|
// ARC_String_Destroy(tempStr);
|
||||||
|
//
|
||||||
//try reading in the texture
|
// //try reading in the texture
|
||||||
if(!texture){
|
// if(!texture){
|
||||||
ARC_SDL_Texture_Read(config, string, (void **)&texture);
|
// ARC_SDL_Texture_Read(config, string, (void **)&texture);
|
||||||
if(arc_errno){
|
// if(arc_errno){
|
||||||
*value = NULL;
|
// *value = NULL;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ARC_String_Destroy(textureStr);
|
// ARC_String_Destroy(textureStr);
|
||||||
|
//
|
||||||
*value = malloc(sizeof(ARC_Spritesheet));
|
// *value = malloc(sizeof(ARC_Spritesheet));
|
||||||
((ARC_Spritesheet *) *value)->texture = texture;
|
// ((ARC_Spritesheet *) *value)->texture = texture;
|
||||||
((ARC_Spritesheet *) *value)->size = size;
|
// ((ARC_Spritesheet *) *value)->size = size;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
uint8_t ARC_Spritesheet_Read(ARC_Config* config, ARC_String *string, void **value){
|
//uint8_t ARC_Spritesheet_Read(ARC_Config* config, ARC_String *string, void **value){
|
||||||
if(string->data[0] != '{' || string->data[string->length - 1] != '}'){
|
// if(string->data[0] != '{' || string->data[string->length - 1] != '}'){
|
||||||
ARC_Spritesheet_ReadTexture(config, string, NULL, value);
|
// ARC_Spritesheet_ReadTexture(config, string, NULL, value);
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
uint64_t split = ARC_GraphicsConfig_GetIndexAndErrorCheck(string, ",", 1);
|
// uint64_t split = ARC_GraphicsConfig_GetIndexAndErrorCheck(string, ",", 1);
|
||||||
if(arc_errno){
|
// if(arc_errno){
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ARC_String *temp, *textureStr, *sizeStr;
|
// ARC_String *temp, *textureStr, *sizeStr;
|
||||||
ARC_String_CopySubstring(&temp, string, 1, split - 2);
|
// ARC_String_CopySubstring(&temp, string, 1, split - 2);
|
||||||
ARC_String_StripEndsWhitespace(&textureStr, temp);
|
// ARC_String_StripEndsWhitespace(&textureStr, temp);
|
||||||
ARC_String_Destroy(temp);
|
// ARC_String_Destroy(temp);
|
||||||
|
//
|
||||||
ARC_String_CopySubstring(&temp, string, split + 1, string->length - (split + 2));
|
// ARC_String_CopySubstring(&temp, string, split + 1, string->length - (split + 2));
|
||||||
ARC_String_StripEndsWhitespace(&sizeStr, temp);
|
// ARC_String_StripEndsWhitespace(&sizeStr, temp);
|
||||||
ARC_String_Destroy(temp);
|
// ARC_String_Destroy(temp);
|
||||||
|
//
|
||||||
uint32_t *size;
|
// uint32_t *size;
|
||||||
ARC_Config_Get(config, string, (void **)&size);
|
// ARC_Config_Get(config, string, (void **)&size);
|
||||||
if(!size){
|
// if(!size){
|
||||||
ARC_ConfigKey_Read_Uint32_t(config, sizeStr, (void **)&size);
|
// ARC_ConfigKey_Read_Uint32_t(config, sizeStr, (void **)&size);
|
||||||
if(arc_errno){
|
// if(arc_errno){
|
||||||
ARC_String_Destroy(sizeStr);
|
// ARC_String_Destroy(sizeStr);
|
||||||
ARC_String_Destroy(textureStr);
|
// ARC_String_Destroy(textureStr);
|
||||||
return ARC_ERRNO_DATA;
|
// return ARC_ERRNO_DATA;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ARC_Spritesheet_ReadTexture(config, textureStr, size, value);
|
// ARC_Spritesheet_ReadTexture(config, textureStr, size, value);
|
||||||
|
//
|
||||||
ARC_String_Destroy(sizeStr);
|
// ARC_String_Destroy(sizeStr);
|
||||||
ARC_String_Destroy(textureStr);
|
// ARC_String_Destroy(textureStr);
|
||||||
|
//
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
uint8_t ARC_Sprite_Read(ARC_Config* config, ARC_String *string, void **value){
|
//uint8_t ARC_Sprite_Read(ARC_Config* config, ARC_String *string, void **value){
|
||||||
ARC_Config_Get(config, string, value);
|
// ARC_Config_Get(config, string, value);
|
||||||
if(*value){
|
// if(*value){
|
||||||
return 1;
|
// return 1;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(string->data[0] != '{' || string->data[string->length - 1] != '}'){
|
// if(string->data[0] != '{' || string->data[string->length - 1] != '}'){
|
||||||
ARC_Spritesheet_ReadTexture(config, string, NULL, value);
|
// ARC_Spritesheet_ReadTexture(config, string, NULL, value);
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
uint64_t split = ARC_GraphicsConfig_GetIndexAndErrorCheck(string, ",", 1);
|
// uint64_t split = ARC_GraphicsConfig_GetIndexAndErrorCheck(string, ",", 1);
|
||||||
if(arc_errno){
|
// if(arc_errno){
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ARC_String *temp, *spritesheetStr, *framesStr;
|
// ARC_String *temp, *spritesheetStr, *framesStr;
|
||||||
ARC_String_CopySubstring(&temp, string, 1, split - 2);
|
// ARC_String_CopySubstring(&temp, string, 1, split - 2);
|
||||||
ARC_String_StripEndsWhitespace(&spritesheetStr, temp);
|
// ARC_String_StripEndsWhitespace(&spritesheetStr, temp);
|
||||||
ARC_String_Destroy(temp);
|
// ARC_String_Destroy(temp);
|
||||||
|
//
|
||||||
ARC_String_CopySubstring(&temp, string, split + 1, string->length - (split + 2));
|
// ARC_String_CopySubstring(&temp, string, split + 1, string->length - (split + 2));
|
||||||
ARC_String_StripEndsWhitespace(&framesStr, temp);
|
// ARC_String_StripEndsWhitespace(&framesStr, temp);
|
||||||
ARC_String_Destroy(temp);
|
// ARC_String_Destroy(temp);
|
||||||
|
//
|
||||||
//spritesheet
|
// //spritesheet
|
||||||
ARC_Spritesheet *spritesheet;
|
// ARC_Spritesheet *spritesheet;
|
||||||
ARC_Config_Get(config, spritesheetStr, (void **)&spritesheet);
|
// ARC_Config_Get(config, spritesheetStr, (void **)&spritesheet);
|
||||||
|
//
|
||||||
if(!spritesheet){
|
// if(!spritesheet){
|
||||||
ARC_Spritesheet_Read(config, spritesheetStr, (void **)&spritesheet);
|
// ARC_Spritesheet_Read(config, spritesheetStr, (void **)&spritesheet);
|
||||||
if(arc_errno){
|
// if(arc_errno){
|
||||||
ARC_String_Destroy(spritesheetStr);
|
// ARC_String_Destroy(spritesheetStr);
|
||||||
ARC_String_Destroy(framesStr );
|
// ARC_String_Destroy(framesStr );
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
//bounds
|
// //bounds
|
||||||
ARC_Array *frames;
|
// ARC_Array *frames;
|
||||||
ARC_Config_Get(config, framesStr, (void **)&frames);
|
// ARC_Config_Get(config, framesStr, (void **)&frames);
|
||||||
|
//
|
||||||
if(!frames){
|
// if(!frames){
|
||||||
ARC_RectArray_Read(config, framesStr, (void **)&frames);
|
// ARC_RectArray_Read(config, framesStr, (void **)&frames);
|
||||||
if(arc_errno){
|
// if(arc_errno){
|
||||||
ARC_String_Destroy(spritesheetStr);
|
// ARC_String_Destroy(spritesheetStr);
|
||||||
ARC_String_Destroy(framesStr );
|
// ARC_String_Destroy(framesStr );
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ARC_String_Destroy(spritesheetStr);
|
// ARC_String_Destroy(spritesheetStr);
|
||||||
ARC_String_Destroy(framesStr );
|
// ARC_String_Destroy(framesStr );
|
||||||
|
//
|
||||||
// Scale frames to match spritesheet size
|
// // Scale frames to match spritesheet size
|
||||||
// TODO: possible bug for sheets that use same frames
|
// // TODO: possible bug for sheets that use same frames
|
||||||
if(spritesheet->size){
|
// if(spritesheet->size){
|
||||||
for(uint32_t i = 0; i < frames->size; i++){
|
// for(uint32_t i = 0; i < frames->size; i++){
|
||||||
((ARC_Rect *)frames->data)[i].x *= *spritesheet->size;
|
// ((ARC_Rect *)frames->data)[i].x *= *spritesheet->size;
|
||||||
((ARC_Rect *)frames->data)[i].y *= *spritesheet->size;
|
// ((ARC_Rect *)frames->data)[i].y *= *spritesheet->size;
|
||||||
((ARC_Rect *)frames->data)[i].w *= *spritesheet->size;
|
// ((ARC_Rect *)frames->data)[i].w *= *spritesheet->size;
|
||||||
((ARC_Rect *)frames->data)[i].h *= *spritesheet->size;
|
// ((ARC_Rect *)frames->data)[i].h *= *spritesheet->size;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
//sprite
|
// //sprite
|
||||||
ARC_Sprite_Create((ARC_Sprite **)value, spritesheet, frames);
|
// ARC_Sprite_Create((ARC_Sprite **)value, spritesheet, frames);
|
||||||
|
//
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
void ARC_SDL_Texture_Delete(ARC_Config* config, ARC_String *string, void *value){
|
//void ARC_SDL_Texture_Delete(ARC_Config* config, ARC_String *string, void *value){
|
||||||
SDL_DestroyTexture((SDL_Texture *) value);
|
// SDL_DestroyTexture((SDL_Texture *) value);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
void ARC_Spritesheet_Delete(ARC_Config* config, ARC_String *string, void *value){
|
//void ARC_Spritesheet_Delete(ARC_Config* config, ARC_String *string, void *value){
|
||||||
ARC_Spritesheet *sheetValue = (ARC_Spritesheet *)value;
|
// ARC_Spritesheet *sheetValue = (ARC_Spritesheet *)value;
|
||||||
|
//
|
||||||
//check if read in as a Textrue reference
|
// //check if read in as a Textrue reference
|
||||||
void *temp;
|
// void *temp;
|
||||||
ARC_Config_Get(config, string, &temp);
|
// ARC_Config_Get(config, string, &temp);
|
||||||
if(temp){
|
// if(temp){
|
||||||
//TODO: test to see if this breaks references
|
// //TODO: test to see if this breaks references
|
||||||
free(sheetValue);
|
// free(sheetValue);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
uint64_t split = ARC_GraphicsConfig_GetIndexAndErrorCheck(string, ",", 1);
|
// uint64_t split = ARC_GraphicsConfig_GetIndexAndErrorCheck(string, ",", 1);
|
||||||
if(arc_errno){
|
// if(arc_errno){
|
||||||
//TODO: test to make sure no edge cases
|
// //TODO: test to make sure no edge cases
|
||||||
// free(sheetValue);
|
// // free(sheetValue);
|
||||||
ARC_SDL_Texture_Delete(config, string, value);
|
// ARC_SDL_Texture_Delete(config, string, value);
|
||||||
arc_errno = 0;
|
// arc_errno = 0;
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(split == ~0){
|
// if(split == ~0){
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
//check if texture and size are references
|
// //check if texture and size are references
|
||||||
ARC_String *tempStr, *textureStr, *sizeStr;
|
// ARC_String *tempStr, *textureStr, *sizeStr;
|
||||||
ARC_String_CopySubstring(&tempStr, string, 1, split - 1);
|
// ARC_String_CopySubstring(&tempStr, string, 1, split - 1);
|
||||||
ARC_String_StripEndsWhitespace(&textureStr, tempStr);
|
// ARC_String_StripEndsWhitespace(&textureStr, tempStr);
|
||||||
ARC_String_Destroy(tempStr);
|
// ARC_String_Destroy(tempStr);
|
||||||
|
//
|
||||||
ARC_String_CopySubstring(&tempStr, string, split + 1, string->length - (split + 1));
|
// ARC_String_CopySubstring(&tempStr, string, split + 1, string->length - (split + 1));
|
||||||
ARC_String_StripEndsWhitespace(&sizeStr, tempStr);
|
// ARC_String_StripEndsWhitespace(&sizeStr, tempStr);
|
||||||
ARC_String_Destroy(tempStr);
|
// ARC_String_Destroy(tempStr);
|
||||||
|
//
|
||||||
ARC_Config_Get(config, sizeStr, (void **)&temp);
|
// ARC_Config_Get(config, sizeStr, (void **)&temp);
|
||||||
ARC_String_Destroy(sizeStr);
|
// ARC_String_Destroy(sizeStr);
|
||||||
if(temp){
|
// if(temp){
|
||||||
free(sheetValue->size);
|
// free(sheetValue->size);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ARC_Config_Get(config, textureStr, (void **)&temp);
|
// ARC_Config_Get(config, textureStr, (void **)&temp);
|
||||||
ARC_String_Destroy(textureStr);
|
// ARC_String_Destroy(textureStr);
|
||||||
if(temp){
|
// if(temp){
|
||||||
free(sheetValue->size);
|
// free(sheetValue->size);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
free(sheetValue);
|
// free(sheetValue);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
void ARC_Sprite_Delete(ARC_Config* config, ARC_String *string, void *value){
|
//void ARC_Sprite_Delete(ARC_Config* config, ARC_String *string, void *value){
|
||||||
ARC_Sprite *spriteValue = (ARC_Sprite *)value;
|
// ARC_Sprite *spriteValue = (ARC_Sprite *)value;
|
||||||
|
//
|
||||||
//check if read in as a Textrue reference
|
// //check if read in as a Textrue reference
|
||||||
void *temp;
|
// void *temp;
|
||||||
uint64_t split = ARC_GraphicsConfig_GetIndexAndErrorCheck(string, ",", 1);
|
// uint64_t split = ARC_GraphicsConfig_GetIndexAndErrorCheck(string, ",", 1);
|
||||||
if(arc_errno){
|
// if(arc_errno){
|
||||||
free(spriteValue);
|
// free(spriteValue);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
//check if texture and size are references
|
// //check if texture and size are references
|
||||||
ARC_String *tempStr, *spritesheetStr, *framesStr;
|
// ARC_String *tempStr, *spritesheetStr, *framesStr;
|
||||||
ARC_String_CopySubstring(&tempStr, string, 1, split - 1);
|
// ARC_String_CopySubstring(&tempStr, string, 1, split - 1);
|
||||||
ARC_String_StripEndsWhitespace(&spritesheetStr, tempStr);
|
// ARC_String_StripEndsWhitespace(&spritesheetStr, tempStr);
|
||||||
ARC_String_Destroy(tempStr);
|
// ARC_String_Destroy(tempStr);
|
||||||
|
//
|
||||||
ARC_String_CopySubstring(&tempStr, string, split + 1, string->length - (split + 1));
|
// ARC_String_CopySubstring(&tempStr, string, split + 1, string->length - (split + 1));
|
||||||
ARC_String_StripEndsWhitespace(&framesStr, tempStr);
|
// ARC_String_StripEndsWhitespace(&framesStr, tempStr);
|
||||||
ARC_String_Destroy(tempStr);
|
// ARC_String_Destroy(tempStr);
|
||||||
|
//
|
||||||
ARC_Config_Get(config, spritesheetStr, (void **)&temp);
|
// ARC_Config_Get(config, spritesheetStr, (void **)&temp);
|
||||||
ARC_String_Destroy(spritesheetStr);
|
// ARC_String_Destroy(spritesheetStr);
|
||||||
if(temp){
|
// if(temp){
|
||||||
free(spriteValue->spritesheet);
|
// free(spriteValue->spritesheet);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ARC_Config_Get(config, framesStr, (void **)&temp);
|
// ARC_Config_Get(config, framesStr, (void **)&temp);
|
||||||
ARC_String_Destroy(framesStr);
|
// ARC_String_Destroy(framesStr);
|
||||||
if(temp){
|
// if(temp){
|
||||||
free(spriteValue->frames);
|
// free(spriteValue->frames);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
free(spriteValue);
|
// free(spriteValue);
|
||||||
}
|
//}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue