add window_debug()
parent
06989e23eb
commit
50d622da52
|
@ -2019,6 +2019,7 @@ enum WINDOW_FLAGS {
|
|||
vec2 window_canvas();
|
||||
void* window_handle();
|
||||
char* window_stats();
|
||||
void window_debug(bool visible);
|
||||
uint64_t window_frame();
|
||||
int window_width();
|
||||
int window_height();
|
||||
|
|
|
@ -18672,6 +18672,7 @@ API void window_color(unsigned color);
|
|||
API vec2 window_canvas();
|
||||
API void* window_handle();
|
||||
API char* window_stats();
|
||||
API void window_debug(bool visible);
|
||||
|
||||
API uint64_t window_frame();
|
||||
API int window_width();
|
||||
|
@ -355092,6 +355093,8 @@ void ui_hue_cycle( unsigned num_cycles ) {
|
|||
}
|
||||
}
|
||||
|
||||
extern bool debug_visible;
|
||||
|
||||
static
|
||||
void ui_render() {
|
||||
|
||||
|
@ -355106,11 +355109,15 @@ void ui_render() {
|
|||
* rendering the UI. */
|
||||
//nk_sdl_render(NK_ANTI_ALIASING_ON, MAX_VERTEX_MEMORY, MAX_ELEMENT_MEMORY);
|
||||
|
||||
GLfloat bkColor[4]; glGetFloatv(GL_COLOR_CLEAR_VALUE, bkColor); // @transparent
|
||||
glClearColor(0,0,0,1); // @transparent
|
||||
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,!bkColor[3] ? GL_TRUE : GL_FALSE); // @transparent
|
||||
nk_glfw3_render(&nk_glfw, NK_ANTI_ALIASING_ON, MAX_VERTEX_MEMORY, MAX_ELEMENT_MEMORY);
|
||||
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); // @transparent
|
||||
if (debug_visible) {
|
||||
GLfloat bkColor[4]; glGetFloatv(GL_COLOR_CLEAR_VALUE, bkColor); // @transparent
|
||||
glClearColor(0,0,0,1); // @transparent
|
||||
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,!bkColor[3] ? GL_TRUE : GL_FALSE); // @transparent
|
||||
nk_glfw3_render(&nk_glfw, NK_ANTI_ALIASING_ON, MAX_VERTEX_MEMORY, MAX_ELEMENT_MEMORY);
|
||||
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); // @transparent
|
||||
} else {
|
||||
nk_clear(&nk_glfw.ctx);
|
||||
}
|
||||
|
||||
#if is(ems)
|
||||
glFinish();
|
||||
|
@ -379035,6 +379042,7 @@ static char title[128] = {0};
|
|||
static char screenshot_file[DIR_MAX];
|
||||
static int locked_aspect_ratio = 0;
|
||||
static vec4 winbgcolor = {0,0,0,1};
|
||||
static bool debug_visible = true;
|
||||
|
||||
vec4 window_getcolor_() { return winbgcolor; } // internal
|
||||
|
||||
|
@ -379463,6 +379471,9 @@ int window_frame_begin() {
|
|||
}
|
||||
}
|
||||
|
||||
if (!debug_visible)
|
||||
may_render_debug_panel = 0;
|
||||
|
||||
// generate Debug panel contents
|
||||
if( may_render_debug_panel ) {
|
||||
if( has_menu ? ui_window("Debug " ICON_MD_SETTINGS, 0) : ui_panel("Debug " ICON_MD_SETTINGS, 0) ) {
|
||||
|
@ -379672,6 +379683,10 @@ double window_delta() {
|
|||
return dt;
|
||||
}
|
||||
|
||||
void window_debug(bool visible) {
|
||||
debug_visible = visible;
|
||||
}
|
||||
|
||||
double window_fps() {
|
||||
return fps;
|
||||
}
|
||||
|
|
|
@ -1031,6 +1031,8 @@ void ui_hue_cycle( unsigned num_cycles ) {
|
|||
}
|
||||
}
|
||||
|
||||
extern bool debug_visible;
|
||||
|
||||
static
|
||||
void ui_render() {
|
||||
|
||||
|
@ -1045,11 +1047,15 @@ void ui_render() {
|
|||
* rendering the UI. */
|
||||
//nk_sdl_render(NK_ANTI_ALIASING_ON, MAX_VERTEX_MEMORY, MAX_ELEMENT_MEMORY);
|
||||
|
||||
GLfloat bkColor[4]; glGetFloatv(GL_COLOR_CLEAR_VALUE, bkColor); // @transparent
|
||||
glClearColor(0,0,0,1); // @transparent
|
||||
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,!bkColor[3] ? GL_TRUE : GL_FALSE); // @transparent
|
||||
nk_glfw3_render(&nk_glfw, NK_ANTI_ALIASING_ON, MAX_VERTEX_MEMORY, MAX_ELEMENT_MEMORY);
|
||||
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); // @transparent
|
||||
if (debug_visible) {
|
||||
GLfloat bkColor[4]; glGetFloatv(GL_COLOR_CLEAR_VALUE, bkColor); // @transparent
|
||||
glClearColor(0,0,0,1); // @transparent
|
||||
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,!bkColor[3] ? GL_TRUE : GL_FALSE); // @transparent
|
||||
nk_glfw3_render(&nk_glfw, NK_ANTI_ALIASING_ON, MAX_VERTEX_MEMORY, MAX_ELEMENT_MEMORY);
|
||||
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); // @transparent
|
||||
} else {
|
||||
nk_clear(&nk_glfw.ctx);
|
||||
}
|
||||
|
||||
#if is(ems)
|
||||
glFinish();
|
||||
|
|
|
@ -108,6 +108,7 @@ static char title[128] = {0};
|
|||
static char screenshot_file[DIR_MAX];
|
||||
static int locked_aspect_ratio = 0;
|
||||
static vec4 winbgcolor = {0,0,0,1};
|
||||
static bool debug_visible = true;
|
||||
|
||||
vec4 window_getcolor_() { return winbgcolor; } // internal
|
||||
|
||||
|
@ -536,6 +537,9 @@ int window_frame_begin() {
|
|||
}
|
||||
}
|
||||
|
||||
if (!debug_visible)
|
||||
may_render_debug_panel = 0;
|
||||
|
||||
// generate Debug panel contents
|
||||
if( may_render_debug_panel ) {
|
||||
if( has_menu ? ui_window("Debug " ICON_MD_SETTINGS, 0) : ui_panel("Debug " ICON_MD_SETTINGS, 0) ) {
|
||||
|
@ -745,6 +749,10 @@ double window_delta() {
|
|||
return dt;
|
||||
}
|
||||
|
||||
void window_debug(bool visible) {
|
||||
debug_visible = visible;
|
||||
}
|
||||
|
||||
double window_fps() {
|
||||
return fps;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ API void window_color(unsigned color);
|
|||
API vec2 window_canvas();
|
||||
API void* window_handle();
|
||||
API char* window_stats();
|
||||
API void window_debug(bool visible);
|
||||
|
||||
API uint64_t window_frame();
|
||||
API int window_width();
|
||||
|
|
24
engine/v4k.c
24
engine/v4k.c
|
@ -2239,6 +2239,8 @@ void ui_hue_cycle( unsigned num_cycles ) {
|
|||
}
|
||||
}
|
||||
|
||||
extern bool debug_visible;
|
||||
|
||||
static
|
||||
void ui_render() {
|
||||
|
||||
|
@ -2253,11 +2255,15 @@ void ui_render() {
|
|||
* rendering the UI. */
|
||||
//nk_sdl_render(NK_ANTI_ALIASING_ON, MAX_VERTEX_MEMORY, MAX_ELEMENT_MEMORY);
|
||||
|
||||
GLfloat bkColor[4]; glGetFloatv(GL_COLOR_CLEAR_VALUE, bkColor); // @transparent
|
||||
glClearColor(0,0,0,1); // @transparent
|
||||
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,!bkColor[3] ? GL_TRUE : GL_FALSE); // @transparent
|
||||
nk_glfw3_render(&nk_glfw, NK_ANTI_ALIASING_ON, MAX_VERTEX_MEMORY, MAX_ELEMENT_MEMORY);
|
||||
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); // @transparent
|
||||
if (debug_visible) {
|
||||
GLfloat bkColor[4]; glGetFloatv(GL_COLOR_CLEAR_VALUE, bkColor); // @transparent
|
||||
glClearColor(0,0,0,1); // @transparent
|
||||
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,!bkColor[3] ? GL_TRUE : GL_FALSE); // @transparent
|
||||
nk_glfw3_render(&nk_glfw, NK_ANTI_ALIASING_ON, MAX_VERTEX_MEMORY, MAX_ELEMENT_MEMORY);
|
||||
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); // @transparent
|
||||
} else {
|
||||
nk_clear(&nk_glfw.ctx);
|
||||
}
|
||||
|
||||
#if is(ems)
|
||||
glFinish();
|
||||
|
@ -26182,6 +26188,7 @@ static char title[128] = {0};
|
|||
static char screenshot_file[DIR_MAX];
|
||||
static int locked_aspect_ratio = 0;
|
||||
static vec4 winbgcolor = {0,0,0,1};
|
||||
static bool debug_visible = true;
|
||||
|
||||
vec4 window_getcolor_() { return winbgcolor; } // internal
|
||||
|
||||
|
@ -26610,6 +26617,9 @@ int window_frame_begin() {
|
|||
}
|
||||
}
|
||||
|
||||
if (!debug_visible)
|
||||
may_render_debug_panel = 0;
|
||||
|
||||
// generate Debug panel contents
|
||||
if( may_render_debug_panel ) {
|
||||
if( has_menu ? ui_window("Debug " ICON_MD_SETTINGS, 0) : ui_panel("Debug " ICON_MD_SETTINGS, 0) ) {
|
||||
|
@ -26819,6 +26829,10 @@ double window_delta() {
|
|||
return dt;
|
||||
}
|
||||
|
||||
void window_debug(bool visible) {
|
||||
debug_visible = visible;
|
||||
}
|
||||
|
||||
double window_fps() {
|
||||
return fps;
|
||||
}
|
||||
|
|
|
@ -4739,6 +4739,7 @@ API void window_color(unsigned color);
|
|||
API vec2 window_canvas();
|
||||
API void* window_handle();
|
||||
API char* window_stats();
|
||||
API void window_debug(bool visible);
|
||||
|
||||
API uint64_t window_frame();
|
||||
API int window_width();
|
||||
|
|
Binary file not shown.
|
@ -1,28 +0,0 @@
|
|||
#pragma once
|
||||
#define API IMPORT
|
||||
#include "v4k.h"
|
||||
|
||||
struct asset_t;
|
||||
|
||||
typedef int (*ed_proc)(struct asset_t *asset);
|
||||
|
||||
typedef struct {
|
||||
ed_proc init;
|
||||
ed_proc tick;
|
||||
ed_proc quit;
|
||||
char* (*ext)();
|
||||
} editor_vtable_t;
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
editor_vtable_t f;
|
||||
} editor_t;
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
editor_t *ed;
|
||||
|
||||
int slot; //<< internal, used by plugin
|
||||
bool opened;
|
||||
uint64_t last_modified;
|
||||
} asset_t;
|
|
@ -1,170 +0,0 @@
|
|||
#include "pluginapi.h"
|
||||
|
||||
enum { WIDTH = 1024, HEIGHT = 1024 };
|
||||
enum { UI_WIDTH = 512, UI_HEIGHT = 512 };
|
||||
enum { VS, FS, FX, SHADERTOY };
|
||||
|
||||
typedef struct {
|
||||
char kind;
|
||||
bool reload;
|
||||
|
||||
// preview
|
||||
handle fb, flipFB;
|
||||
texture_t tex, flipTex;
|
||||
texture_t texDepth;
|
||||
|
||||
union {
|
||||
struct {
|
||||
shadertoy_t shadertoy;
|
||||
bool flip_y;
|
||||
bool allow_mouse;
|
||||
};
|
||||
|
||||
struct {
|
||||
int model;
|
||||
int fx_slot;
|
||||
};
|
||||
};
|
||||
} shader_asset_t;
|
||||
|
||||
array(shader_asset_t) shaders = 0;
|
||||
|
||||
__declspec(dllexport) char *plug_ext() {
|
||||
return "fx,glsl,vs,fs";
|
||||
}
|
||||
|
||||
static inline
|
||||
void reload_shader(asset_t *f, shader_asset_t *s) {
|
||||
if (s->kind == SHADERTOY) {
|
||||
s->shadertoy = shadertoy(f->name, (s->flip_y?SHADERTOY_FLIP_Y:0)|(s->allow_mouse?0:SHADERTOY_IGNORE_MOUSE)|SHADERTOY_IGNORE_FBO);
|
||||
s->shadertoy.dims.x = WIDTH;
|
||||
s->shadertoy.dims.y = HEIGHT;
|
||||
}
|
||||
else if (s->kind == FX) {
|
||||
s->fx_slot = fx_load_from_mem(f->name, vfs_read(f->name));
|
||||
}
|
||||
|
||||
s->reload = 0;
|
||||
}
|
||||
|
||||
__declspec(dllexport) int plug_init(asset_t *f) {
|
||||
shader_asset_t a = {0};
|
||||
a.reload = 1;
|
||||
|
||||
if (strstri(f->name, "shadertoys")) {
|
||||
a.kind = SHADERTOY;
|
||||
}
|
||||
// else if (strbegi(file_name(f->name), "vs_") || strendi(f->name, ".vs")) {
|
||||
// a.kind = VS;
|
||||
// }
|
||||
// else if (strbegi(file_name(f->name), "fs_") || strendi(f->name, ".fs")) {
|
||||
// a.kind = FS;
|
||||
// }
|
||||
else if (strbegi(file_name(f->name), "fx") && strendi(f->name, ".fs")) {
|
||||
a.kind = FX;
|
||||
} else {
|
||||
PRINTF("unsupported shader: %s\n", f->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
a.tex = texture_create(WIDTH, HEIGHT, 4, NULL, TEXTURE_RGBA);
|
||||
a.flipTex = texture_create(WIDTH, HEIGHT, 4, NULL, TEXTURE_RGBA);
|
||||
a.texDepth = texture_create(WIDTH, HEIGHT, 1, NULL, TEXTURE_DEPTH|TEXTURE_FLOAT);
|
||||
a.fb = fbo(a.tex.id, a.texDepth.id, 0);
|
||||
a.flipFB = fbo(a.flipTex.id, 0, 0);
|
||||
|
||||
f->slot = array_count(shaders);
|
||||
array_push(shaders, a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
__declspec(dllexport) int plug_tick(asset_t *f) {
|
||||
shader_asset_t *s = (shaders+f->slot);
|
||||
|
||||
if (s->reload) {
|
||||
reload_shader(f, s);
|
||||
ui_dims(f->name, UI_WIDTH, UI_HEIGHT*1.45);
|
||||
}
|
||||
|
||||
fx_enable_all(0);
|
||||
|
||||
// vec2 win_dims = ui_get_dims();
|
||||
// ui_dims(f->name, win_dims.x, win_dims.x*1.45);
|
||||
|
||||
fbo_bind(s->fb);
|
||||
glViewport(0,0,WIDTH,HEIGHT);
|
||||
glClearDepth(1);
|
||||
glClearColor(0.0f,0.0f,0.0f,0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||
if (s->kind == SHADERTOY) {
|
||||
shadertoy_render(&s->shadertoy, window_delta());
|
||||
}
|
||||
else if (s->kind == FX) {
|
||||
fx_enable(s->fx_slot, 1);
|
||||
// fx_begin();
|
||||
fx_begin_res(WIDTH, HEIGHT);
|
||||
enum { CUBE, SPHERE, SUZANNE, SHADERBALL, MAX_MODELS };
|
||||
static camera_t cam;
|
||||
static skybox_t sky;
|
||||
static model_t models[MAX_MODELS];
|
||||
do_once {
|
||||
cam = camera();
|
||||
sky = skybox(0,0);
|
||||
camera_fps(&cam, 0,45);
|
||||
models[CUBE] = model("meshes/cube.obj", MODEL_NO_ANIMATIONS);
|
||||
// model_set_texture(models[CUBE], texture_checker());
|
||||
rotation44(models[CUBE].pivot, -90, 1,0,0);
|
||||
models[SPHERE] = model("meshes/sphere.obj", MODEL_NO_ANIMATIONS);
|
||||
rotation44(models[SPHERE].pivot, -90, 1,0,0);
|
||||
models[SUZANNE] = model("meshes/suzanne.obj", MODEL_NO_ANIMATIONS);
|
||||
rotation44(models[SUZANNE].pivot, -90, 1,0,0);
|
||||
models[SHADERBALL] = model("meshes/shaderBall.glb", MODEL_NO_ANIMATIONS);
|
||||
mat44 sca; scale44(sca, 1,1,1);
|
||||
mat44 rot; rotation44(rot, -90, 1,0,0);
|
||||
multiply44x2(models[SHADERBALL].pivot, sca, rot);
|
||||
}
|
||||
|
||||
bool active = (ui_active() || ui_hover()) && input(MOUSE_L) || input(MOUSE_M) || input(MOUSE_R);
|
||||
vec2 mouse = scale2(vec2(input_diff(MOUSE_X), -input_diff(MOUSE_Y)), 0.2f * active);
|
||||
// camera_move(&cam, wasdecq.x,wasdecq.y,wasdecq.z);
|
||||
camera_orbit(&cam, mouse.x,mouse.y, input_diff(MOUSE_W));
|
||||
perspective44(cam.proj, cam.fov, UI_WIDTH/(float)UI_HEIGHT, 0.1f, 100.f);
|
||||
skybox_render(&sky, cam.proj, cam.view);
|
||||
ddraw_grid(0);
|
||||
ddraw_flush();
|
||||
model_render(models[s->model], cam.proj, cam.view, models[s->model].pivot, 0);
|
||||
fx_end();
|
||||
|
||||
// fbo_bind(s->fb);
|
||||
// fullscreen_quad_rgb(s->tex, 1.0);
|
||||
// fbo_unbind();
|
||||
}
|
||||
|
||||
fbo_bind(s->flipFB);
|
||||
fullscreen_quad_rgb(s->tex, 1.0);
|
||||
fbo_unbind();
|
||||
|
||||
ui_image(0, s->flipTex.id, UI_WIDTH, UI_HEIGHT);
|
||||
|
||||
if (s->kind == SHADERTOY) {
|
||||
if (ui_bool("Flip Y", &s->flip_y)) {
|
||||
s->reload = 1;
|
||||
}
|
||||
if (ui_bool("Allow mouse", &s->allow_mouse)) {
|
||||
s->reload = 1;
|
||||
}
|
||||
}
|
||||
else if (s->kind == FX) {
|
||||
static char* model_selections[] = {"Cube", "Sphere", "Suzanne", "Shader ball"};
|
||||
ui_list("Model", model_selections, 4, &s->model);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
__declspec(dllexport) int plug_quit(asset_t *f) {
|
||||
shader_asset_t *s = (shaders+f->slot);
|
||||
|
||||
fbo_destroy(s->fb);
|
||||
fbo_destroy(s->flipFB);
|
||||
return 0;
|
||||
}
|
Binary file not shown.
Binary file not shown.
|
@ -1,153 +0,0 @@
|
|||
// #define COOK_ON_DEMAND 1
|
||||
// #define MAX_CACHED_FILES 0
|
||||
// #define VFS_ALWAYS_PACK 1
|
||||
#include "pluginapi.h"
|
||||
|
||||
array(editor_t) editors = 0;
|
||||
array(asset_t) assets = 0;
|
||||
|
||||
#define PLUGINS\
|
||||
X(shader_editor)
|
||||
|
||||
#define X(name) extern editor_vtable_t name##__procs;
|
||||
PLUGINS
|
||||
#undef X
|
||||
|
||||
editor_vtable_t load_editor_vtable(char *pname) {
|
||||
char *name = va("%s.dll", pname);
|
||||
editor_vtable_t f;
|
||||
f.init = dll(name, "plug_init");
|
||||
f.tick = dll(name, "plug_tick");
|
||||
f.quit = dll(name, "plug_quit");
|
||||
f.ext = dll(name, "plug_ext");
|
||||
if (!f.init || !f.tick || !f.quit || !f.ext)
|
||||
return (editor_vtable_t){0};
|
||||
return f;
|
||||
}
|
||||
|
||||
void load_editor(char *pname) {
|
||||
editor_t ed = {0};
|
||||
ed.name = file_base(STRDUP(pname)); // @leak
|
||||
ed.f = load_editor_vtable(pname);
|
||||
if (!ed.f.init) {
|
||||
// PRINTF("unsupported plugin: '%s'\n", ed.name);
|
||||
return;
|
||||
}
|
||||
PRINTF("loaded plugin: '%s'\n", ed.name);
|
||||
array_push(editors, ed);
|
||||
}
|
||||
|
||||
void load_editors() {
|
||||
#define X(name) load_editor(#name);
|
||||
PLUGINS
|
||||
#undef X
|
||||
}
|
||||
|
||||
map(char*, editor_t*) assocs;
|
||||
|
||||
void register_extensions() {
|
||||
map_init(assocs, less_str, hash_str);
|
||||
|
||||
for (int i=0; i<array_count(editors); i++) {
|
||||
char *types = editors[i].f.ext();
|
||||
|
||||
for each_substring(types, ",", ext) {
|
||||
map_find_or_add(assocs, STRDUP(ext), (editors+i));
|
||||
PRINTF("extension '%s' mapped to '%s'\n", ext, editors[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void edit_asset(char *fname) {
|
||||
app_spawn(va("%s \"\" \"%s\"", ifdef(win32, "start", ifdef(osx, "open", "xdg-open")), fname));
|
||||
}
|
||||
|
||||
void load_asset(const char *fname) {
|
||||
char *ext = (file_ext(fname)+1);
|
||||
PRINTF("opened asset: %s (%s)\n", fname, ext);
|
||||
|
||||
// see if we have a supported editor plugin registered
|
||||
editor_t **ed = map_find(assocs, ext);
|
||||
if (!ed) {
|
||||
PRINTF("fallback exec %s\n", fname);
|
||||
edit_asset(fname);
|
||||
return;
|
||||
}
|
||||
|
||||
asset_t asset = {0};
|
||||
asset.name = STRDUP(fname);
|
||||
asset.ed = *ed;
|
||||
asset.opened = 1;
|
||||
asset.last_modified = file_stamp(fname);
|
||||
array_push(assets, asset);
|
||||
if (asset.ed->f.init((struct asset_t*)array_back(assets))) {
|
||||
FREE(asset.name);
|
||||
array_pop(assets);
|
||||
PRINTF("fallback exec %s\n", fname);
|
||||
edit_asset(fname);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
window_create(75.0, WINDOW_MSAA8);
|
||||
window_fps_unlock();
|
||||
|
||||
camera_t cam = camera();
|
||||
camera_enable(&cam);
|
||||
|
||||
load_editors();
|
||||
register_extensions();
|
||||
|
||||
#if 0
|
||||
load_asset("demos/art/shadertoys/!default.fs");
|
||||
load_asset("demos/art/fx/fxDithering.fs");
|
||||
|
||||
#endif
|
||||
|
||||
while( window_swap() && !input(KEY_ESC) ) {
|
||||
if (ui_panel("Workbench", PANEL_OPEN)) {
|
||||
static const char *file;
|
||||
static bool show_browser = 1;
|
||||
if( ui_browse(&file, &show_browser) ) {
|
||||
load_asset(file);
|
||||
show_browser = 1;
|
||||
}
|
||||
}
|
||||
ui_panel_end();
|
||||
|
||||
// static bool show_main_window = 1;
|
||||
// if ( ui_window("Workbench", &show_main_window) ) {
|
||||
// ui_label("v4.games");
|
||||
// }
|
||||
// ui_window_end();
|
||||
|
||||
for (int i=0; i<array_count(assets); i++) {
|
||||
asset_t *f = (assets+i);
|
||||
if (ui_window(f->name, &f->opened)) {
|
||||
f->ed->f.tick(f);
|
||||
|
||||
// was the asset modified?
|
||||
bool modified = f->last_modified != file_stamp(f->name);
|
||||
|
||||
ui_separator();
|
||||
|
||||
if (ui_button("reload asset") || modified) {
|
||||
f->last_modified = file_stamp(f->name);
|
||||
f->ed->f.quit(f);
|
||||
f->ed->f.init(f);
|
||||
}
|
||||
if (ui_button("edit asset")) {
|
||||
edit_asset(assets[i].name);
|
||||
}
|
||||
if (ui_button("close asset") || !f->opened) {
|
||||
f->ed->f.quit(f);
|
||||
FREE(assets[i].name);
|
||||
array_erase(assets, i);
|
||||
--i;
|
||||
}
|
||||
}
|
||||
ui_window_end();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue