I hate my life

This commit is contained in:
2021-11-05 10:55:10 -07:00
parent f6ea081b2d
commit 715ecd3a73
16 changed files with 522 additions and 86 deletions

View File

@ -29,9 +29,11 @@ add_executable(${PROJECT_NAME})
# Variables
set(ROOT_DIR "${CMAKE_SOURCE_DIR}")
set(BUILD_DIR "${CMAKE_BINARY_DIR}")
set(TOOLS_DIR "${ROOT_DIR}/tools")
set(ASSETS_DIR "assets")
set(TEMP_DIR "temp")
set(ASSETS_SOURCE_DIR "${ROOT_DIR}/assets")
set(ASSETS_BUILD_DIR "${BUILD_DIR}/assets")
set(TEMP_DIR "${BUILD_DIR}/temp")
# Include tools
add_subdirectory(tools)
@ -44,24 +46,24 @@ elseif(TARGET_TYPE STREQUAL game)
# Shaders
tool_copy(shader_textured
shared/shaders/textured.vert shaders/textured.vert
shared/shaders/textured.frag shaders/textured.frag
${ASSETS_SOURCE_DIR}/shared/shaders/textured.vert shaders/textured.vert
${ASSETS_SOURCE_DIR}/shared/shaders/textured.frag shaders/textured.frag
)
# Fonts
tool_copy(font_opensans
shared/fonts/opensans/OpenSans-Regular.ttf fonts/opensans/OpenSans-Regular.ttf
shared/fonts/opensans/OpenSans-Bold.ttf fonts/opensans/OpenSans-Bold.ttf
${ASSETS_SOURCE_DIR}/shared/fonts/opensans/OpenSans-Regular.ttf fonts/opensans/OpenSans-Regular.ttf
${ASSETS_SOURCE_DIR}/shared/fonts/opensans/OpenSans-Bold.ttf fonts/opensans/OpenSans-Bold.ttf
)
# Textures
tool_copy(texture_test
shared/textures/test_texture.png textures/test_texture.png
${ASSETS_SOURCE_DIR}/shared/textures/test_texture.png textures/test_texture.png
)
# Locales
tool_copy(locale_en
locale/language/en-US.csv locale/language/en-US.csv
${ASSETS_SOURCE_DIR}/locale/language/en-US.csv locale/language/en-US.csv
)
# Poker Game
@ -78,7 +80,7 @@ elseif(TARGET_TYPE STREQUAL game)
# Characters
set(DIR_CHARS poker/characters)
set(DIR_CHARS "${ASSETS_SOURCE_DIR}/poker/characters")
tool_vn_character(vn_penny
${DIR_CHARS}/penny/character.xml ${DIR_CHARS}/penny.png
)
@ -118,7 +120,6 @@ elseif(TARGET_TYPE STREQUAL game)
locale_en
)
add_dependencies()
elseif(TARGET_GAME STREQUAL sandbox)
add_compile_definitions(
GAME_NAME="Sandbox"
@ -129,11 +130,17 @@ elseif(TARGET_TYPE STREQUAL game)
GAME_DISPOSE=sandboxGameDispose
GAME_VERSION=1.0
)
tool_texture(test_texture
poker/characters/penny/sprites/sheet.png out/penny
)
# set(DIR_CHARS "${ASSETS_SOURCE_DIR}/poker/characters")
# tool_vn_character(vn_penny
# ${DIR_CHARS}/penny/character.xml poker/characters/penny/sprite
# )
# tool_vn_character(vn_sammy
# ${DIR_CHARS}/sammy/character.xml poker/characters/sammy/sprite
# )
tool_assets(
test_texture
# vn_penny
# vn_sammy
shader_textured
font_opensans

140
src/file/xml2.c Normal file
View File

@ -0,0 +1,140 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "xml2.h"
void xmlParseElement(xmlnode_t *node, char *string) {
char c;
int32_t i, j;
uint8_t state;
node->attributeCount = 0;
i = 0;
state = XML_STATE_NOTHING;
while(c = string[i++]) {
switch(state) {
case XML_STATE_NOTHING:
if(c != '<') continue;
node->start = string + (i - 1);
state = XML_STATE_PARSING_NAME;
break;
case XML_STATE_PARSING_NAME:
if(c == ' ' || c == '\n' || c == '\r') continue;
j = i - 1;
while(c = string[j++]) {
if(c == ' ' || c == '\n' || c == '\r' || c == '>') break;
node->name[j - i] = c;
}
node->name[j-i] = '\0';
i = j - 1;
state = XML_STATE_PARSING_ATTRIBUTES;
break;
case XML_STATE_PARSING_ATTRIBUTES:
if(c == ' ' || c == '\n' || c == '\r') continue;
if(c == '>') {
node->internalStart = string + i;
state = XML_STATE_DONE;
break;
}
// Parse Name
node->attributeNames[node->attributeCount] = string + (i - 1);
node->attributeNameLengths[node->attributeCount] = 0;
while(c != ' ' && c != '\n' && c != '\r' && c != '>' && c != '=' && c != '\0') {
c = string[i++];
node->attributeNameLengths[node->attributeCount]++;
}
if(c == '>') {
i--;
node->attributeValues[node->attributeCount] = NULL;
node->attributeValueLengths[node->attributeCount] = 0;
node->attributeCount++;
continue;
}
// Wait for = sign
while(c == ' ' || c == '\n' || c == '\r') c = string[i++];
// Handle booleans
if(c != '=') {
node->attributeValues[node->attributeCount] = NULL;
node->attributeValueLengths[node->attributeCount] = 0;
node->attributeCount++;
continue;
}
// Skip the "
i++;
node->attributeValues[node->attributeCount] = string + i;
node->attributeValueLengths[node->attributeCount] = 0;
do {
c = string[i++];
if(c == '\0' || c == '"') break;
if(c == '\\') {
i++;
node->attributeValueLengths[node->attributeCount]++;
}
node->attributeValueLengths[node->attributeCount]++;
} while(c);
node->attributeCount++;
break;
default:
break;
}
}
}
void xmlGetAttributeName(xmlnode_t *xml, uint8_t attribute, char *buffer) {
int32_t i;
buffer[0] = '\0';
for(i = 0; i < xml->attributeNameLengths[attribute]; i++) {
buffer[i] = xml->attributeNames[attribute][i];
}
buffer[xml->attributeNameLengths[attribute]] = '\0';
}
void xmlGetAttributeValue(xmlnode_t *xml, uint8_t attribute, char *buffer) {
int32_t i;
buffer[0] = '\0';
for(i = 0; i < xml->attributeValueLengths[attribute]; i++) {
buffer[i] = xml->attributeValues[attribute][i];
}
buffer[xml->attributeValueLengths[attribute]] = '\0';
}
uint8_t xmlGetAttributeByName(xmlnode_t *xml, char *name) {
uint8_t i;
int32_t len = strlen(name);
for(i = 0; i < xml->attributeCount; i++) {
if(xml->attributeNameLengths[i] != len) continue;
if(memcmp(name, xml->attributeNames[i], len) == 0) return i;
}
return 0xFF;
}
void xmlFindChildNode(xmlnode_t *node, char** start, char** end) {
char c;
int32_t i;
i = 0;
while(c = node->internalStart[i++]) {
if(c == '<') break;
}
*start = node->internalStart + i - 1;
// Now the part I am dreading.
}

42
src/file/xml2.h Normal file
View File

@ -0,0 +1,42 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../libs.h"
#define XML_NODE_CHILD_MAX 32
#define XML_NODE_NAME_MAX 32
#define XML_NODE_ATTRIBUTES_MAX 32
#define XML_STATE_NOTHING 0x00
#define XML_STATE_PARSING_NAME 0x01
#define XML_STATE_PARSING_ATTRIBUTES 0x02
#define XML_STATE_DONE 0x03
typedef struct {
char *start;
char *internalStart;
char name[XML_NODE_NAME_MAX];
char *attributeNames[XML_NODE_ATTRIBUTES_MAX];
uint8_t attributeNameLengths[XML_NODE_ATTRIBUTES_MAX];
char *attributeValues[XML_NODE_ATTRIBUTES_MAX];
uint8_t attributeValueLengths[XML_NODE_ATTRIBUTES_MAX];
uint8_t attributeCount;
} xmlnode_t;
void xmlParseElement(xmlnode_t *node, char *string);
void xmlGetAttributeName(xmlnode_t *xml, uint8_t attribute, char *buffer);
void xmlGetAttributeValue(xmlnode_t *xml, uint8_t attribute, char *buffer);
uint8_t xmlGetAttributeByName(xmlnode_t *xml, char *name);
void xmlFindChildNode(xmlnode_t *node, char** start, char** end);

View File

@ -7,7 +7,19 @@
#include "game.h"
bool sandboxGameInit(sandboxgame_t *game) {
xmlnode_t node;
char *string = "<xml attribute=\"value\" something=\"else\"><child>Hello World</child></xml>";
char bufferTest[64];
xmlParseElement(&node, string;
xmlGetAttributeValue(&node, xmlGetAttributeByName(&node, "something"), bufferTest);
char *start = xmlFindChildNode(&node);
quadInit(&game->quad, 0, 0,0,0,0, 500,500,1,1);
assetManagerInit(&game->manager);

View File

@ -17,6 +17,8 @@
#include "../../ui/breakpoint.h"
#include "../../file/assetmanager.h"
#include "../../file/xml2.h"
typedef struct {
engine_t engine;
shader_t shader;

View File

@ -7,13 +7,10 @@ cmake_minimum_required(VERSION 3.13)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
SET(TOOL_NAME texture_generation)
set(TOOL_TEXTURE_GENERATION_SOURCE_DIR)
# Build Tool
project(${TOOL_NAME} VERSION 1.0)
add_executable(${TOOL_NAME})
target_sources(${TOOL_NAME}
project(texture_generation VERSION 1.0)
add_executable(texture_generation)
target_sources(texture_generation
PRIVATE
texture_generation.c
../utils/file.c
@ -22,7 +19,7 @@ target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/../
)
target_link_libraries(${TOOL_NAME}
target_link_libraries(texture_generation
PUBLIC
stb
)
@ -30,8 +27,8 @@ target_link_libraries(${TOOL_NAME}
# Function for creating the target
function(tool_texture target in out)
add_custom_target(${target}
COMMAND texture_generation "${ROOT_DIR}/${ASSETS_DIR}/${in}" "${ASSETS_DIR}/${out}"
COMMAND texture_generation "${in}" "${ASSETS_BUILD_DIR}/${out}"
COMMENT "Generating texture ${target} from ${in}"
SOURCES ${TOOL_NAME}
DEPENDS texture_generation ${ARGN}
)
endfunction()

View File

@ -5,8 +5,10 @@
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../utils/common.h"
#include "../utils/file.h"
#include "../utils/image.h"
#ifndef STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
@ -22,6 +24,7 @@ int RESIZE_SCALES[RESIZE_VARIANT_COUNT] = { 1, 2, 3, 4 };
int main(int argc, char *argv[]) {
FILE *file;
char path[FILENAME_MAX + 1];
char xml[2048];
char *in;
char *out;
char pathSep;
@ -38,7 +41,7 @@ int main(int argc, char *argv[]) {
pathSep = FILE_PATH_SEP;
in = argv[1];
out = argv[2];
// Normalize slashes
fileNormalizeSlashes(in);
fileNormalizeSlashes(out);
@ -57,6 +60,13 @@ int main(int argc, char *argv[]) {
}
fclose(file);
// Begin XML buffering
xml[0] = '\0';
sprintf(xml,
"<texture channels=\"%i\" width=\"%i\" height=\"%i\">",
channels, w, h
);
// For each scale.
for(i = 0; i < RESIZE_VARIANT_COUNT; i++) {
// Resize image
@ -68,22 +78,15 @@ int main(int argc, char *argv[]) {
// Determine output path
path[0] = '\0';
if(getcwd(path,sizeof(path)) == NULL) {
printf("Failed to get current dir!\n");
stbi_image_free(dataOriginal);
return 1;
}
// Determine Output path
sprintf(path, "%s%c%s_%i.texture", path, FILE_PATH_SEP, out, scale);
printf("Writing %s\n", path);
sprintf(path, "%s_%i.texture", out, scale);
// Open output file
fileMkdirp(path);
printf("OPOut %s\n", path);
file = fopen(path, "wb");
if(file == NULL) {
printf("Invalid file out!\n");
printf("Invalid texture file out!\n");
return 1;
}
@ -93,10 +96,33 @@ int main(int argc, char *argv[]) {
// Cleanup
fclose(file);
free(dataResized);
// Buffer XML info.
sprintf(xml,
"%s\n <texture-scale scale=\"%i\" width=\"%i\" height=\"%i\" asset=\"%s_%i.texture\" />",
xml, scale, rw, rh, out, scale
);
}
// Cleanup
stbi_image_free(dataOriginal);
// Finalize XML
sprintf(xml, "%s\n</texture>", xml);
// Determine XML path
path[0] = '\0';
sprintf(path, "%s.xml", out);
// Write XML
fileMkdirp(path);
file = fopen(path, "w");
if(file == NULL) {
printf("Invalid XML File Out!\n");
return 1;
}
fwrite(xml, sizeof(char), strlen(xml), file);
fclose(file);
return 0;
}

View File

@ -5,7 +5,7 @@
function(tool_assets args)
add_custom_target(assets
COMMAND tar -C ./assets -czvf assets.tar.gz *
COMMAND tar -C ${ASSETS_BUILD_DIR} -czvf assets.tar.gz *
DEPENDS ${ARGV}
COMMENT "Compressing Assets"
)
@ -23,7 +23,7 @@ function(tool_copy target)
LIST(GET ARGV ${indexnext} to)
LIST(APPEND LOOP_DEPENDENCIES ${LOOP_TARGET})
add_custom_command(OUTPUT ${LOOP_TARGET}
COMMAND ${CMAKE_COMMAND} -E copy "${ROOT_DIR}/${ASSETS_DIR}/${from}" "${ASSETS_DIR}/${to}"
COMMAND ${CMAKE_COMMAND} -E copy "${from}" "${ASSETS_BUILD_DIR}/${to}"
COMMENT "Copying ${from} => ${to}"
)
endforeach()

View File

@ -47,4 +47,12 @@ void fileMkdirp(char *path) {
buffer[i] = '\0';
_mkdir(buffer);
}
}
void assetReadString(FILE *file, char *buffer) {
size_t length;
fseek(file, 0, SEEK_END);// Seek to the end
length = ftell(file);// Get our current position (the end)
fseek(file, 0, SEEK_SET);// Reset the seek
fread(buffer, 1, length, file);// Read all the bytes
}

View File

@ -19,4 +19,6 @@
void fileNormalizeSlashes(char *string);
void fileMkdirp(char *path);
void fileMkdirp(char *path);
void assetReadString(FILE *file, char *buffer);

8
tools/utils/image.h Normal file
View File

@ -0,0 +1,8 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once

94
tools/utils/xml.c Normal file
View File

@ -0,0 +1,94 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "xml.h"
void xmlParseElement(xmlnode_t *node, char *string) {
char c;
int32_t i, j;
uint8_t state;
node->attributeCount = 0;
i = 0;
state = XML_STATE_NOTHING;
while(c = string[i++]) {
switch(state) {
case XML_STATE_NOTHING:
if(c != '<') continue;
node->start = string + (i - 1);
state = XML_STATE_PARSING_NAME;
break;
case XML_STATE_PARSING_NAME:
if(c == ' ' || c == '\n' || c == '\r') continue;
j = i - 1;
while(c = string[j++]) {
if(c == ' ') break;
node->name[j] = c;
}
i = j;
state = XML_STATE_PARSING_ATTRIBUTES;
break;
case XML_STATE_PARSING_ATTRIBUTES:
if(c == ' ' || c == '\n' || c == '\r') continue;
if(c == '>') {
node->internal = string + i;
break;
continue;
}
// Parse Name
node->attributeNames[node->attributeCount] = string + (i - 1);
node->attributeNameLengths[node->attributeCount] = 0;
while(c == ' ' && c == '\n' && c == '\r' && c != '>' && c != '=' && c != '\0') {
c = string[i++];
node->attributeNameLengths[node->attributeCount]++;
}
if(c == '>') {
i--;
node->attributeValues[node->attributeCount] = NULL;
node->attributeValueLengths[node->attributeCount] = 0;
node->attributeCount++;
continue;
}
// Wait for = sign
while(c == ' ' || c == '\n' || c == '\r') c = string[i++];
// Handle booleans
if(c != '=') {
node->attributeValues[node->attributeCount] = NULL;
node->attributeValueLengths[node->attributeCount] = 0;
node->attributeCount++;
i--;
continue;
}
node->attributeValues[node->attributeCount] = string + i;
node->attributeValueLengths[node->attributeCount] = 0;
do {
c = string[i++];
node->attributeNameLengths[node->attributeCount]++;
if(c == '\0' || c == '"') break;
if(c == '\\') {
i++;
node->attributeNameLengths[node->attributeCount]++;
}
} while(c);
node->attributeCount++;
break;
default:
break;
}
}
}

34
tools/utils/xml.h Normal file
View File

@ -0,0 +1,34 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "common.h"
#include "file.h"
#define XML_NODE_CHILD_MAX 32
#define XML_NODE_NAME_MAX 32
#define XML_NODE_ATTRIBUTES_MAX 32
#define XML_STATE_NOTHING 0x00
#define XML_STATE_PARSING_NAME 0x01
#define XML_STATE_PARSING_ATTRIBUTES 0x02
typedef struct {
char *start;
char *internal;
char name[XML_NODE_NAME_MAX];
char *attributeNames[XML_NODE_ATTRIBUTES_MAX];
uint8_t attributeNameLengths[XML_NODE_ATTRIBUTES_MAX];
char *attributeValues[XML_NODE_ATTRIBUTES_MAX];
uint8_t attributeValueLengths[XML_NODE_ATTRIBUTES_MAX];
uint8_t attributeCount;
} xmlnode_t;
void xmlParseElement(xmlnode_t *node, char *string);

View File

@ -3,20 +3,38 @@
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
function(tool_vn_character DEP_NAME IN OUT)
add_custom_command(
OUTPUT ${TEMP_DIR}/vn/${DEP_NAME}.c ${TEMP_DIR}/vn/${DEP_NAME}.h
COMMAND node ${TOOLS_DIR}/vn/character-sheet-generator.js --assets="${ASSETS_DIR}" --root="${ROOT_DIR}" --temp="${TEMP_DIR}" --in="${IN}" --out="${OUT}" --dep="${DEP_NAME}"
COMMENT "Generating VN Character ${DEP_NAME}"
cmake_minimum_required(VERSION 3.13)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
# Build Tool
project(character_generator VERSION 1.0)
add_executable(character_generator)
target_sources(character_generator
PRIVATE
character_generator.c
../utils/file.c
../utils/xml.c
)
target_include_directories(character_generator
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/../
)
target_link_libraries(character_generator
PUBLIC
stb
)
# Function Target
function(tool_vn_character target in out)
add_custom_target(vn_character_${target}
COMMAND character_generator "${in}" "${TEMP_DIR}/${out}"
COMMENT "Generating character ${target} from ${in}"
DEPENDS character_generator ${ARGN}
)
tool_texture(${target}
${TEMP_DIR}/${out}.png ${out}
vn_character_${target}
)
# target_sources(${PROJECT_NAME}
# PRIVATE
# ${CMAKE_CURRENT_BINARY_DIR}/${TEMP_DIR}/vn/${DEP_NAME}.c
# ${CMAKE_CURRENT_BINARY_DIR}/${TEMP_DIR}/vn/${DEP_NAME}.h
# )
# target_include_directories(${PROJECT_NAME}
# PUBLIC
# ${CMAKE_CURRENT_BINARY_DIR}/${TEMP_DIR}/vn/
# )
endfunction()

View File

@ -6,9 +6,7 @@ const { args } = require('./../utils/args');
const { mkdirp } = require('../utils/file');
// Parse Args
if(!args.root) throw new Error(`Missing root argument`);
if(!args.assets) throw new Error(`Missing assets argument`);
if(!args.temp) throw new Error(`Missing temp argument`);
// if(!args.temp) throw new Error(`Missing temp argument`);
if(!args.in) throw new Error(`Missing in argument`);
if(!args.out) throw new Error(`Missing out argument`);
if(!args.dep) throw new Error(`Missing dep argument`);
@ -16,14 +14,16 @@ if(!args.in.endsWith('xml')) throw new Error(`Invalid in XML`);
if(!args.out.endsWith('png')) throw new Error(`Invalid out PNG`);
// Determine in and out.
const root = path.resolve(args.root);
const file = path.resolve(args.root, args.assets, args.in);
const outFile = path.resolve(args.assets, args.out);
const file = path.resolve(args.in);
const outFile = path.resolve(args.out);
const cOut = path.resolve(args.temp, 'vn', `${args.dep}.c`);
const hOut = path.resolve(args.temp, 'vn', `${args.dep}.h`);
console.log(outFile);
// const cOut = path.resolve(args.temp, 'vn', `${args.dep}.c`);
// const hOut = path.resolve(args.temp, 'vn', `${args.dep}.h`);
if(!fs.existsSync(file)) throw new Error(`Could not find ${file}`);
if(fs.existsSync(outFile) && fs.existsSync(cOut) && fs.existsSync(hOut)) return;
// if(fs.existsSync(outFile) && fs.existsSync(cOut) && fs.existsSync(hOut)) return;
if(fs.existsSync(outFile)) return;
// Load XML
const data = xml.xml2js(fs.readFileSync(file, 'utf-8'));
@ -31,7 +31,7 @@ const [ character ] = data.elements;
// Validate file.
if(!character.attributes.context) throw new Error(`Missing context`)
const dir = path.resolve(root, args.assets, character.attributes.context);
const dir = path.resolve(path.dirname(file), character.attributes.context);
// Parse base and layers
const base = character.elements.find(e => e.name == 'base').attributes;
@ -107,33 +107,33 @@ const layers = character.elements
mkdirp(outFile);
await imageWrite(out, outFile);
mkdirp(cOut);
let name = character.attributes.name || args.name || args.dep;
// mkdirp(cOut);
// fs.writeFileSync(cOut, `
// #include "${args.dep}.h"
fs.writeFileSync(cOut, `
#include "${args.dep}.h"
// void vnCharacter${name}Init(vncharacter_t *vnc, texture_t *texture) {
// assetTextureLoad(texture, VN_CHARACTER_${name.toUpperCase()}_TEXTURE);
// vnCharacterInit(vnc, texture);
void vnCharacter${name}Init(vncharacter_t *vnc, texture_t *texture) {
assetTextureLoad(texture, VN_CHARACTER_${name.toUpperCase()}_TEXTURE);
vnCharacterInit(vnc, texture);
// // Base Layer
// vnCharacterLayerAdd(vnc, 1, 0, 0, 0, 0, ${baseImage.width}, ${baseImage.height});
// Base Layer
vnCharacterLayerAdd(vnc, 1, 0, 0, 0, 0, ${baseImage.width}, ${baseImage.height});
// // Layers
// ${strLayers}
// }
// `);
// Layers
${strLayers}
}
`);
// fs.writeFileSync(hOut, `
// #pragma once
// #include <libs.h>
// #include <vn/vncharacter.h>
// #include <display/texture.h>
// #include <file/asset.h>
fs.writeFileSync(hOut, `
#pragma once
#include <libs.h>
#include <vn/vncharacter.h>
#include <display/texture.h>
#include <file/asset.h>
#define VN_CHARACTER_${name.toUpperCase()}_TEXTURE "${args.out}"
// #define VN_CHARACTER_${name.toUpperCase()}_TEXTURE "${args.out}"
void vnCharacter${name}Init(vncharacter_t *vnc, texture_t *texture);
`);
// void vnCharacter${name}Init(vncharacter_t *vnc, texture_t *texture);
// `);
})().catch(console.error);

View File

@ -0,0 +1,46 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "../utils/common.h"
#include "../utils/file.h"
#include "../utils/image.h"
#include "../utils/xml.h"
int main(int argc, char *argv[]) {
FILE *file;
char *in;
char *out;
char xmlBuffer[2048];
if(argc != 3) {
printf("Invalid number of arguments\n");
return 1;
}
// Set up strings
in = argv[1];
out = argv[2];
// Normalize slashes
fileNormalizeSlashes(in);
fileNormalizeSlashes(out);
// Read in XML file
file = fopen(in, "rb");
if(file == NULL) {
printf("Failed to open file!\n");
return 1;
}
assetReadString(file, xmlBuffer);
xmlnode_t node;
xmlParseElement(&node, xmlBuffer);
return 0;
}