adds support for Fennel text carts

This commit is contained in:
Mike Miller 2018-10-20 22:01:25 -04:00
parent adacd39d79
commit 0a1bf64d0d
3 changed files with 22 additions and 4 deletions

View File

@ -480,7 +480,7 @@ static void* getDemoCart(Console* console, ScriptLang script, s32* size)
case MoonScript: strcpy(path, DefaultMoonTicPath); break;
# endif
# if defined(TIC_BUILD_WITH_MOON)
# if defined(TIC_BUILD_WITH_FENNEL)
case Fennel: strcpy(path, DefaultFennelTicPath); break;
# endif
@ -690,12 +690,25 @@ static bool hasExt(const char* name, const char* ext)
static bool hasProjectExt(const char* name)
{
return hasExt(name, PROJECT_LUA_EXT) || hasExt(name, PROJECT_MOON_EXT) || hasExt(name, PROJECT_JS_EXT) || hasExt(name, PROJECT_WREN_EXT);
return hasExt(name, PROJECT_LUA_EXT) ||
hasExt(name, PROJECT_MOON_EXT) ||
hasExt(name, PROJECT_JS_EXT) ||
hasExt(name, PROJECT_WREN_EXT) ||
hasExt(name, PROJECT_FENNEL_EXT);
}
static const char* projectComment(const char* name)
{
return hasExt(name, PROJECT_JS_EXT) || hasExt(name, PROJECT_WREN_EXT) ? "//" : "--";
char* comment;
if(hasExt(name, PROJECT_JS_EXT) || hasExt(name, PROJECT_WREN_EXT))
comment = "//";
else if(hasExt(name, PROJECT_FENNEL_EXT))
comment = ";;";
else
comment = "--";
return comment;
}
static void buf2str(const void* data, s32 size, char* ptr, bool flip)
@ -1069,6 +1082,9 @@ static void onConsoleLoadCommandConfirmed(Console* console, const char* param)
if(!fsExistsFile(console->fs, name))
name = getName(param, PROJECT_WREN_EXT);
if(!fsExistsFile(console->fs, name))
name = getName(param, PROJECT_FENNEL_EXT);
void* data = fsLoadFile(console->fs, name, &size);
if(data)

View File

@ -60,6 +60,7 @@
#define PROJECT_JS_EXT ".js"
#define PROJECT_WREN_EXT ".wren"
#define PROJECT_SQUIRREL_EXT ".nut"
#define PROJECT_FENNEL_EXT ".fnl"
typedef enum
{

View File

@ -396,6 +396,7 @@ static bool addMenuItem(const char* name, const char* info, s32 id, void* ptr, b
|| hasExt(name, PROJECT_MOON_EXT)
|| hasExt(name, PROJECT_JS_EXT)
|| hasExt(name, PROJECT_WREN_EXT)
|| hasExt(name, PROJECT_FENNEL_EXT)
#endif
)
{
@ -533,7 +534,7 @@ static void loadCover(Surf* surf)
if(cart)
{
if(hasExt(item->name, PROJECT_LUA_EXT))
if(hasExt(item->name, PROJECT_LUA_EXT) || hasExt(item->name, PROJECT_FENNEL_EXT))
surf->console->loadProject(surf->console, item->name, data, size, cart);
else
tic->api.load(cart, data, size, true);