no message
This commit is contained in:
parent
376763c56a
commit
a6bfc6011e
|
@ -540,7 +540,7 @@ static void copyToClipboard(Code* code)
|
||||||
{
|
{
|
||||||
memcpy(clipboard, start, size);
|
memcpy(clipboard, start, size);
|
||||||
clipboard[size] = '\0';
|
clipboard[size] = '\0';
|
||||||
setClipboardText(clipboard);
|
getSystem()->setClipboardText(clipboard);
|
||||||
free(clipboard);
|
free(clipboard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -554,9 +554,9 @@ static void cutToClipboard(Code* code)
|
||||||
|
|
||||||
static void copyFromClipboard(Code* code)
|
static void copyFromClipboard(Code* code)
|
||||||
{
|
{
|
||||||
if(hasClipboardText())
|
if(getSystem()->hasClipboardText())
|
||||||
{
|
{
|
||||||
char* clipboard = getClipboardText();
|
char* clipboard = getSystem()->getClipboardText();
|
||||||
|
|
||||||
if(clipboard)
|
if(clipboard)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2573,7 +2573,7 @@ static NetVersion netVersionRequest()
|
||||||
};
|
};
|
||||||
|
|
||||||
s32 size = 0;
|
s32 size = 0;
|
||||||
void* buffer = getUrlRequest("/api?fn=version", &size);
|
void* buffer = getSystem()->getUrlRequest("/api?fn=version", &size);
|
||||||
|
|
||||||
if(buffer && size)
|
if(buffer && size)
|
||||||
{
|
{
|
||||||
|
@ -3055,7 +3055,7 @@ void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Config* config,
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
sprintf(buf, "parameter or file not processed: %s\n", argv[i]);
|
sprintf(buf, "parameter or file not processed: %s\n", argv[i]);
|
||||||
showMessageBox("Warning", buf);
|
getSystem()->showMessageBox("Warning", buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
src/fs.c
14
src/fs.c
|
@ -280,7 +280,7 @@ static void netDirRequest(const char* path, ListCallback callback, void* data)
|
||||||
sprintf(request, "/api?fn=dir&path=%s", path);
|
sprintf(request, "/api?fn=dir&path=%s", path);
|
||||||
|
|
||||||
s32 size = 0;
|
s32 size = 0;
|
||||||
void* buffer = getUrlRequest(request, &size);
|
void* buffer = getSystem()->getUrlRequest(request, &size);
|
||||||
|
|
||||||
NetDirData netDirData = {callback, data};
|
NetDirData netDirData = {callback, data};
|
||||||
onDirResponse(buffer, size, &netDirData);
|
onDirResponse(buffer, size, &netDirData);
|
||||||
|
@ -420,7 +420,7 @@ void fsAddFile(FileSystem* fs, AddCallback callback, void* data)
|
||||||
|
|
||||||
*addFileData = (AddFileData) { fs, callback, data };
|
*addFileData = (AddFileData) { fs, callback, data };
|
||||||
|
|
||||||
_file_dialog_load(&onAddFile, addFileData);
|
getSystem()->file_dialog_load(&onAddFile, addFileData);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -552,7 +552,7 @@ void fsGetFileData(GetCallback callback, const char* name, void* buffer, size_t
|
||||||
GetFileData* command = (GetFileData*)malloc(sizeof(GetFileData));
|
GetFileData* command = (GetFileData*)malloc(sizeof(GetFileData));
|
||||||
*command = (GetFileData) {callback, data, buffer};
|
*command = (GetFileData) {callback, data, buffer};
|
||||||
|
|
||||||
_file_dialog_save(onGetFile, name, buffer, size, command, mode);
|
getSystem()->file_dialog_save(onGetFile, name, buffer, size, command, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -576,7 +576,7 @@ void fsOpenFileData(OpenCallback callback, void* data)
|
||||||
|
|
||||||
*command = (OpenFileData){callback, data};
|
*command = (OpenFileData){callback, data};
|
||||||
|
|
||||||
_file_dialog_load(onOpenFileData, command);
|
getSystem()->file_dialog_load(onOpenFileData, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fsGetFile(FileSystem* fs, GetCallback callback, const char* name, void* data)
|
void fsGetFile(FileSystem* fs, GetCallback callback, const char* name, void* data)
|
||||||
|
@ -590,7 +590,7 @@ void fsGetFile(FileSystem* fs, GetCallback callback, const char* name, void* dat
|
||||||
*command = (GetFileData) {callback, data, buffer};
|
*command = (GetFileData) {callback, data, buffer};
|
||||||
|
|
||||||
s32 mode = fsGetMode(fs, name);
|
s32 mode = fsGetMode(fs, name);
|
||||||
_file_dialog_save(onGetFile, name, buffer, size, command, mode);
|
getSystem()->file_dialog_save(onGetFile, name, buffer, size, command, mode);
|
||||||
}
|
}
|
||||||
else callback(FS_FILE_NOT_DOWNLOADED, data);
|
else callback(FS_FILE_NOT_DOWNLOADED, data);
|
||||||
}
|
}
|
||||||
|
@ -843,7 +843,7 @@ void* fsLoadFile(FileSystem* fs, const char* name, s32* size)
|
||||||
|
|
||||||
char path[FILENAME_MAX] = {0};
|
char path[FILENAME_MAX] = {0};
|
||||||
sprintf(path, "/cart/%s/cart.tic", loadPublicCartData.hash);
|
sprintf(path, "/cart/%s/cart.tic", loadPublicCartData.hash);
|
||||||
void* data = getUrlRequest(path, size);
|
void* data = getSystem()->getUrlRequest(path, size);
|
||||||
|
|
||||||
if(data)
|
if(data)
|
||||||
fsSaveRootFile(fs, cachePath, data, *size, false);
|
fsSaveRootFile(fs, cachePath, data, *size, false);
|
||||||
|
@ -900,7 +900,7 @@ void fsOpenWorkingFolder(FileSystem* fs)
|
||||||
if(isPublic(fs))
|
if(isPublic(fs))
|
||||||
path = fs->dir;
|
path = fs->dir;
|
||||||
|
|
||||||
openSystemPath(path);
|
getSystem()->openSystemPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSystem* createFileSystem(const char* path)
|
FileSystem* createFileSystem(const char* path)
|
||||||
|
|
28
src/main.h
28
src/main.h
|
@ -1 +1,27 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "tic.h"
|
||||||
|
#include "ext/file_dialog.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
void (*setClipboardText)(const char* text);
|
||||||
|
bool (*hasClipboardText)();
|
||||||
|
char* (*getClipboardText)();
|
||||||
|
u64 (*getPerformanceCounter)();
|
||||||
|
u64 (*getPerformanceFrequency)();
|
||||||
|
|
||||||
|
void* (*getUrlRequest)(const char* url, s32* size);
|
||||||
|
|
||||||
|
void (*file_dialog_load)(file_dialog_load_callback callback, void* data);
|
||||||
|
void (*file_dialog_save)(file_dialog_save_callback callback, const char* name, const u8* buffer, size_t size, void* data, u32 mode);
|
||||||
|
|
||||||
|
void (*goFullscreen)();
|
||||||
|
void (*showMessageBox)(const char* title, const char* message);
|
||||||
|
void (*setWindowTitle)(const char* title);
|
||||||
|
|
||||||
|
void (*openSystemPath)(const char* path);
|
||||||
|
|
||||||
|
} System;
|
||||||
|
|
||||||
|
System* getSystem();
|
||||||
|
|
|
@ -976,9 +976,9 @@ static void cutToClipboard(Map* map)
|
||||||
|
|
||||||
static void copyFromClipboard(Map* map)
|
static void copyFromClipboard(Map* map)
|
||||||
{
|
{
|
||||||
if(hasClipboardText())
|
if(getSystem()->hasClipboardText())
|
||||||
{
|
{
|
||||||
char* clipboard = getClipboardText();
|
char* clipboard = getSystem()->getClipboardText();
|
||||||
|
|
||||||
if(clipboard)
|
if(clipboard)
|
||||||
{
|
{
|
||||||
|
|
|
@ -619,9 +619,9 @@ static void copyFromClipboard(Music* music)
|
||||||
{
|
{
|
||||||
tic_track_pattern* pattern = getChannelPattern(music);
|
tic_track_pattern* pattern = getChannelPattern(music);
|
||||||
|
|
||||||
if(pattern && hasClipboardText())
|
if(pattern && getSystem()->hasClipboardText())
|
||||||
{
|
{
|
||||||
char* clipboard = getClipboardText();
|
char* clipboard = getSystem()->getClipboardText();
|
||||||
|
|
||||||
if(clipboard)
|
if(clipboard)
|
||||||
{
|
{
|
||||||
|
|
|
@ -183,8 +183,8 @@ void initRun(Run* run, Console* console, tic_mem* tic)
|
||||||
{
|
{
|
||||||
.error = onError,
|
.error = onError,
|
||||||
.trace = onTrace,
|
.trace = onTrace,
|
||||||
.counter = getPerformanceCounter,
|
.counter = getSystem()->getPerformanceCounter,
|
||||||
.freq = getPerformanceFrequency,
|
.freq = getSystem()->getPerformanceFrequency,
|
||||||
.start = 0,
|
.start = 0,
|
||||||
.data = run,
|
.data = run,
|
||||||
.exit = onExit,
|
.exit = onExit,
|
||||||
|
|
116
src/studio.c
116
src/studio.c
|
@ -49,12 +49,7 @@
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
|
|
||||||
|
|
||||||
// #define TEXTURE_SIZE (TIC80_FULLWIDTH)
|
|
||||||
// #define STUDIO_PIXEL_FORMAT SDL_PIXELFORMAT_ARGB8888
|
|
||||||
#define FRAME_SIZE (TIC80_FULLWIDTH * TIC80_FULLHEIGHT * sizeof(u32))
|
#define FRAME_SIZE (TIC80_FULLWIDTH * TIC80_FULLHEIGHT * sizeof(u32))
|
||||||
// #define OFFSET_LEFT ((TIC80_FULLWIDTH-TIC80_WIDTH)/2)
|
|
||||||
// #define OFFSET_TOP ((TIC80_FULLHEIGHT-TIC80_HEIGHT)/2)
|
|
||||||
#define POPUP_DUR (TIC_FRAMERATE*2)
|
#define POPUP_DUR (TIC_FRAMERATE*2)
|
||||||
|
|
||||||
#define KEYBOARD_HOLD 20
|
#define KEYBOARD_HOLD 20
|
||||||
|
@ -372,7 +367,7 @@ void toClipboard(const void* data, s32 size, bool flip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setClipboardText(clipboard);
|
getSystem()->setClipboardText(clipboard);
|
||||||
free(clipboard);
|
free(clipboard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,9 +411,9 @@ bool fromClipboard(void* data, s32 size, bool flip, bool remove_white_spaces)
|
||||||
{
|
{
|
||||||
if(data)
|
if(data)
|
||||||
{
|
{
|
||||||
if(hasClipboardText())
|
if(getSystem()->hasClipboardText())
|
||||||
{
|
{
|
||||||
char* clipboard = getClipboardText();
|
char* clipboard = getSystem()->getClipboardText();
|
||||||
|
|
||||||
if(clipboard)
|
if(clipboard)
|
||||||
{
|
{
|
||||||
|
@ -1649,8 +1644,6 @@ static void renderStudio()
|
||||||
|
|
||||||
if(studioImpl.mode != TIC_RUN_MODE)
|
if(studioImpl.mode != TIC_RUN_MODE)
|
||||||
useSystemPalette();
|
useSystemPalette();
|
||||||
|
|
||||||
// renderCursor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateSystemFont()
|
static void updateSystemFont()
|
||||||
|
@ -1716,60 +1709,6 @@ static void initKeymap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #if defined(__EMSCRIPTEN__)
|
|
||||||
|
|
||||||
// #define DEFAULT_CART "cart.tic"
|
|
||||||
|
|
||||||
// static void onEmscriptenWget(const char* file)
|
|
||||||
// {
|
|
||||||
// studioImpl.argv[1] = DEFAULT_CART;
|
|
||||||
// createFileSystem(NULL, onFSInitialized);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static void onEmscriptenWgetError(const char* error) {}
|
|
||||||
|
|
||||||
// static void emstick()
|
|
||||||
// {
|
|
||||||
// static double nextTick = -1.0;
|
|
||||||
|
|
||||||
// studioImpl.missedFrame = false;
|
|
||||||
|
|
||||||
// if(nextTick < 0.0)
|
|
||||||
// nextTick = emscripten_get_now();
|
|
||||||
|
|
||||||
// nextTick += 1000.0/TIC_FRAMERATE;
|
|
||||||
// tick();
|
|
||||||
// double delay = nextTick - emscripten_get_now();
|
|
||||||
|
|
||||||
// if(delay < 0.0)
|
|
||||||
// {
|
|
||||||
// nextTick -= delay;
|
|
||||||
// studioImpl.missedFrame = true;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// emscripten_set_main_loop_timing(EM_TIMING_SETTIMEOUT, delay);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
// #if defined(__EMSCRIPTEN__)
|
|
||||||
|
|
||||||
// if(studioImpl.argc == 2)
|
|
||||||
// {
|
|
||||||
// emscripten_async_wget(studioImpl.argv[1], DEFAULT_CART, onEmscriptenWget, onEmscriptenWgetError);
|
|
||||||
// }
|
|
||||||
// else createFileSystem(NULL, onFSInitialized);
|
|
||||||
|
|
||||||
// // emscripten_set_main_loop(emstick, TIC_FRAMERATE, 1);
|
|
||||||
|
|
||||||
// #else
|
|
||||||
|
|
||||||
// FileSystem* fs = createFileSystem(argc > 1 && fsExists(argv[1]) ? fsBasename(argv[1]) : folder);
|
|
||||||
// onFSInitialized(fs);
|
|
||||||
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
|
|
||||||
Studio* studioInit(s32 argc, char **argv, s32 samplerate, const char* folder, System* system)
|
Studio* studioInit(s32 argc, char **argv, s32 samplerate, const char* folder, System* system)
|
||||||
{
|
{
|
||||||
setbuf(stdout, NULL);
|
setbuf(stdout, NULL);
|
||||||
|
@ -1935,52 +1874,7 @@ void studioClose()
|
||||||
tic80_delete((tic80*)studioImpl.tic80local);
|
tic80_delete((tic80*)studioImpl.tic80local);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setClipboardText(const char* text)
|
System* getSystem()
|
||||||
{
|
{
|
||||||
studioImpl.system->setClipboardText(text);
|
return studioImpl.system;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasClipboardText()
|
|
||||||
{
|
|
||||||
return studioImpl.system->hasClipboardText();
|
|
||||||
}
|
|
||||||
|
|
||||||
char* getClipboardText()
|
|
||||||
{
|
|
||||||
return studioImpl.system->getClipboardText();
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 getPerformanceCounter()
|
|
||||||
{
|
|
||||||
return studioImpl.system->getPerformanceCounter();
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 getPerformanceFrequency()
|
|
||||||
{
|
|
||||||
return studioImpl.system->getPerformanceFrequency();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _file_dialog_load(file_dialog_load_callback callback, void* data)
|
|
||||||
{
|
|
||||||
studioImpl.system->file_dialog_load(callback, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _file_dialog_save(file_dialog_save_callback callback, const char* name, const u8* buffer, size_t size, void* data, u32 mode)
|
|
||||||
{
|
|
||||||
studioImpl.system->file_dialog_save(callback, name, buffer, size, data, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void showMessageBox(const char* title, const char* message)
|
|
||||||
{
|
|
||||||
studioImpl.system->showMessageBox(title, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void openSystemPath(const char* path)
|
|
||||||
{
|
|
||||||
studioImpl.system->openSystemPath(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* getUrlRequest(const char* url, s32* size)
|
|
||||||
{
|
|
||||||
return studioImpl.system->getUrlRequest(url, size);
|
|
||||||
}
|
|
58
src/studio.h
58
src/studio.h
|
@ -27,8 +27,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
// #include <SDL.h>
|
|
||||||
|
|
||||||
#if defined(__EMSCRIPTEN__)
|
#if defined(__EMSCRIPTEN__)
|
||||||
#include <emscripten.h>
|
#include <emscripten.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,12 +36,11 @@
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "ext/file_dialog.h"
|
#include "ext/file_dialog.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
#define TIC_LOCAL ".local/"
|
#define TIC_LOCAL ".local/"
|
||||||
#define TIC_CACHE TIC_LOCAL "cache/"
|
#define TIC_CACHE TIC_LOCAL "cache/"
|
||||||
|
|
||||||
// #define TIC_MOD_CTRL (KMOD_GUI|KMOD_CTRL)
|
|
||||||
|
|
||||||
#define TOOLBAR_SIZE 7
|
#define TOOLBAR_SIZE 7
|
||||||
#define STUDIO_TEXT_WIDTH (TIC_FONT_WIDTH)
|
#define STUDIO_TEXT_WIDTH (TIC_FONT_WIDTH)
|
||||||
#define STUDIO_TEXT_HEIGHT (TIC_FONT_HEIGHT+1)
|
#define STUDIO_TEXT_HEIGHT (TIC_FONT_HEIGHT+1)
|
||||||
|
@ -211,54 +208,17 @@ void runProject();
|
||||||
tic_tiles* getBankTiles();
|
tic_tiles* getBankTiles();
|
||||||
tic_map* getBankMap();
|
tic_map* getBankMap();
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
tic_mem* tic;
|
|
||||||
bool quit;
|
|
||||||
|
|
||||||
} Studio;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
void (*setClipboardText)(const char* text);
|
|
||||||
bool (*hasClipboardText)();
|
|
||||||
char* (*getClipboardText)();
|
|
||||||
u64 (*getPerformanceCounter)();
|
|
||||||
u64 (*getPerformanceFrequency)();
|
|
||||||
|
|
||||||
void* (*getUrlRequest)(const char* url, s32* size);
|
|
||||||
|
|
||||||
void (*file_dialog_load)(file_dialog_load_callback callback, void* data);
|
|
||||||
void (*file_dialog_save)(file_dialog_save_callback callback, const char* name, const u8* buffer, size_t size, void* data, u32 mode);
|
|
||||||
|
|
||||||
void (*goFullscreen)();
|
|
||||||
void (*showMessageBox)(const char* title, const char* message);
|
|
||||||
void (*setWindowTitle)(const char* title);
|
|
||||||
|
|
||||||
void (*openSystemPath)(const char* path);
|
|
||||||
|
|
||||||
} System;
|
|
||||||
|
|
||||||
TIC80_API Studio* studioInit(s32 argc, char **argv, s32 samplerate, const char* appFolder, System* system);
|
|
||||||
TIC80_API void studioTick(void* pixels);
|
|
||||||
TIC80_API void studioClose();
|
|
||||||
|
|
||||||
char getKeyboardText();
|
char getKeyboardText();
|
||||||
bool keyWasPressed(tic_key key);
|
bool keyWasPressed(tic_key key);
|
||||||
bool anyKeyWasPressed();
|
bool anyKeyWasPressed();
|
||||||
|
|
||||||
void setClipboardText(const char* text);
|
typedef struct
|
||||||
bool hasClipboardText();
|
{
|
||||||
char* getClipboardText();
|
tic_mem* tic;
|
||||||
|
bool quit;
|
||||||
|
} Studio;
|
||||||
|
|
||||||
u64 getPerformanceCounter();
|
TIC80_API Studio* studioInit(s32 argc, char **argv, s32 samplerate, const char* appFolder, System* system);
|
||||||
u64 getPerformanceFrequency();
|
TIC80_API void studioTick(void* pixels);
|
||||||
|
TIC80_API void studioClose();
|
||||||
void _file_dialog_load(file_dialog_load_callback callback, void* data);
|
|
||||||
void _file_dialog_save(file_dialog_save_callback callback, const char* name, const u8* buffer, size_t size, void* data, u32 mode);
|
|
||||||
|
|
||||||
void showMessageBox(const char* title, const char* message);
|
|
||||||
TIC80_API void updateStudioProject();
|
TIC80_API void updateStudioProject();
|
||||||
|
|
||||||
void openSystemPath(const char* path);
|
|
||||||
void* getUrlRequest(const char* url, s32* size);
|
|
||||||
|
|
|
@ -477,7 +477,7 @@ static void* requestCover(Surf* surf, const char* hash, s32* size)
|
||||||
|
|
||||||
char path[FILENAME_MAX] = {0};
|
char path[FILENAME_MAX] = {0};
|
||||||
sprintf(path, "/cart/%s/cover.gif", hash);
|
sprintf(path, "/cart/%s/cover.gif", hash);
|
||||||
void* data = getUrlRequest(path, size);
|
void* data = getSystem()->getUrlRequest(path, size);
|
||||||
|
|
||||||
if(data)
|
if(data)
|
||||||
{
|
{
|
||||||
|
@ -780,7 +780,7 @@ static void processGamepad(Surf* surf)
|
||||||
{
|
{
|
||||||
char url[FILENAME_MAX];
|
char url[FILENAME_MAX];
|
||||||
sprintf(url, "https://" TIC_HOST "/play?cart=%i", item->id);
|
sprintf(url, "https://" TIC_HOST "/play?cart=%i", item->id);
|
||||||
openSystemPath(url);
|
getSystem()->openSystemPath(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue