removed edtior

This commit is contained in:
John Alanbrook 2023-05-30 16:39:22 +00:00
parent 0d432c32ef
commit 16f7a28c23
18 changed files with 60 additions and 1340 deletions

View file

@ -71,13 +71,13 @@ includeflag != find source -type d -name include
includeflag += $(engincs) source/engine/thirdparty/Nuklear includeflag += $(engincs) source/engine/thirdparty/Nuklear
includeflag := $(addprefix -I, $(includeflag)) includeflag := $(addprefix -I, $(includeflag))
WARNING_FLAGS = -Wall -Wno-unused-function# -pedantic -Wextra -Wwrite-strings -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function WARNING_FLAGS = -Wall -Wno-incompatible-function-pointer-types -Wno-unused-function# -pedantic -Wextra -Wwrite-strings -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function
SEM = 0.0.1 SEM = 0.0.1
COM != git rev-parse --short HEAD COM != git rev-parse --short HEAD
VER = $(SEM)-$(COM) VER = $(SEM)-$(COM)
COMPILER_FLAGS = $(includeflag) $(QFLAGS) -MD $(WARNING_FLAGS) -I. -DCP_USE_DOUBLES=0 -DTINYSPLINE_FLOAT_PRECISION -DVER=\"$(VER)\" -DINFO=\"$(INFO)\" -march=native -std=c99 -c $< -o $@ COMPILER_FLAGS = $(includeflag) $(QFLAGS) -MD $(WARNING_FLAGS) -I. -DCP_USE_DOUBLES=0 -DTINYSPLINE_FLOAT_PRECISION -DVER=\"$(VER)\" -DINFO=\"$(INFO)\" -c $< -o $@
LIBPATH = -L$(BIN) LIBPATH = -L$(BIN)
@ -87,8 +87,8 @@ ifeq ($(OS), WIN32)
CLIBS = CLIBS =
EXT = .exe EXT = .exe
else else
LINKER_FLAGS = $(QFLAGS) -L/usr/local/lib -rdynamic LINKER_FLAGS = $(QFLAGS) -L/usr/local/lib -pthread -rdynamic
ELIBS = engine pthread yughc glfw3 quickjs c m dl GL ELIBS = engine pthread yughc quickjs glfw3 GL c m dl
CLIBS = CLIBS =
endif endif

View file

@ -4,6 +4,7 @@
#define THIRDPERSONFOLLOW_H #define THIRDPERSONFOLLOW_H
#include "transform.h" #include "transform.h"
#include "HandmadeMath.h"
struct follow { struct follow {
float distance; float distance;

View file

@ -44,7 +44,7 @@ static void render_audio(plm_t *mpeg, plm_samples_t *samples, void *user) {
for (int i = 0; i < samples->count * CHANNELS; i++) { for (int i = 0; i < samples->count * CHANNELS; i++) {
t = (short)(samples->interleaved[i] * SHRT_MAX); t = (short)(samples->interleaved[i] * SHRT_MAX);
cbuf_push(ds->astream->buf, t * 5); // cbuf_push(ds->astream->buf, t * 5);
} }
} }

View file

@ -1,96 +0,0 @@
#include "ed_project.h"
#include <string.h>
#include <stdlib.h>
#include "editor.h"
void editor_init_project(struct gameproject *gp)
{
/*
cur_project = gp;
DATA_PATH = strdup(gp->path);
stemlen = strlen(DATA_PATH);
findPrefabs();
get_levels();
get_all_files();
*/
}
void editor_make_project(char *path)
{
FILE *f = path_open("w", "%s%s", path, "/project.yugh");
cur_project = malloc(sizeof(struct gameproject));
strncpy(cur_project->name, "New Game", 127);
strncpy(cur_project->path, path, 2048);
vec_add(projects, cur_project);
fwrite(cur_project, sizeof(*cur_project), 1, f);
fclose(f);
editor_init_project(cur_project);
editor_save_projects();
}
void editor_import_project(char *path)
{
FILE *f = path_open("r", "%s%s", path, "/project.yugh");
if (!f)
return;
struct gameproject *gp = malloc(sizeof(*gp));
fread(gp, sizeof(*gp), 1, f);
fclose(f);
vec_add(projects, gp);
}
void editor_project_btn_gui(struct gameproject *gp)
{
/*
if (ImGui::Button(gp->name))
editor_init_project(gp);
ImGui::SameLine();
ImGui::Text("%s", gp->path);
*/
}
void editor_proj_select_gui()
{
/*
ImGui::Begin("Project Select");
vec_walk(projects, (void (*)(void *)) &editor_project_btn_gui);
ImGui::InputText("Project import path", setpath, MAXPATH);
ImGui::SameLine();
if (ImGui::Button("Create")) {
editor_make_project(setpath);
}
ImGui::SameLine();
if (ImGui::Button("Import")) {
editor_import_project(setpath);
}
ImGui::End();
*/
}
void editor_load_projects()
{
FILE *f = fopen("projects.yugh", "r");
if (!f)
return;
vec_load(projects, f);
fclose(f);
}
void editor_save_projects()
{
FILE *f = fopen("projects.yugh", "w");
vec_store(projects, f);
fclose(f);
}

View file

@ -1,18 +0,0 @@
#ifndef ED_PROJECT_H
#define ED_PROJECT_H
#include "config.h"
struct gameproject {
char name[127];
char path[MAXPATH];
};
void editor_init_project(struct gameproject *gp);
void editor_save_projects();
void editor_load_projects();
void editor_proj_select_gui();
void editor_import_project(char *path);
void editor_make_project(char *path);
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,108 +0,0 @@
#ifndef EDITOR_H
#define EDITOR_H
#include "config.h"
#include <stdbool.h>
#include "resources.h"
#include "nuke.h"
#define ASSET_TYPE_NULL 0
#define ASSET_TYPE_IMAGE 1
#define ASSET_TYPE_TEXT 2
#define ASSET_TYPE_SOUND 3
struct fileasset {
char *filename;
bool searched;
short type;
void *data; // Struct of the underlying asset - Texture struct, etc
};
typedef struct {
bool show;
struct nk_rect rect;
} editor_win;
struct editorVars {
editor_win stats;
editor_win hierarchy;
editor_win gamesettings;
editor_win viewmode;
editor_win debug;
editor_win assets;
editor_win asset;
editor_win repl;
editor_win export;
editor_win level;
editor_win gameobject;
editor_win components;
editor_win simulate;
editor_win prefab;
nk_flags text_ed;
nk_flags asset_srch;
};
struct gameobject;
extern int show_desktop;
#define NK_MENU_START(VAR) if (editor.VAR.show && !show_desktop) { \
if (editor.VAR.rect.w == 0) editor.VAR.rect = nk_rect_std; \
if (nuke_begin(#VAR, editor.VAR.rect, nuk_std)) { \
editor.VAR.rect = nuke_win_get_bounds();
#define NK_MENU_END() } nuke_stop(); }
#define NK_FORCE(VAR) if (editor.VAR.rect.w == 0) editor.VAR.rect = nk_rect_std; \
if (!show_desktop && nuke_begin(#VAR, editor.VAR.rect, nuk_std)) { \
editor.VAR.rect = nuke_win_get_bounds();
#define NK_FORCE_END() nuke_stop(); }
#define NEGATE(VAR) VAR = ! VAR
struct vec;
struct gameproject;
struct sprite;
extern struct gameproject *cur_project;
extern struct vec *projects;
struct Texture;
struct window;
void pickGameObject(int pickID);
int is_allowed_extension(const char *ext);
void editor_init(struct window *window);
void editor_input();
void editor_render();
int editor_wantkeyboard();
void editor_save();
void editor_makenewobject();
void editor_project_gui();
void editor_selectasset(struct fileasset *asset);
void editor_selectasset_str(const char *path);
void editor_asset_gui(struct fileasset *asset);
void editor_asset_tex_gui(struct Texture *tex);
void editor_asset_text_gui(char *text);
void editor_level_btn(char *level);
void editor_prefab_btn(char *prefab);
void game_start();
void game_resume();
void game_stop();
void game_pause();
void get_levels();
int obj_gui_hierarchy(struct gameobject *selected);
void sprite_gui(struct sprite *sprite);
#endif

View file

@ -1,19 +0,0 @@
#include "editorstate.h"
#include <stdio.h>
/*
void (*asset_command)(char *asset) = print_file;
void print_file(char *file)
{
YughInfo("File path: %s", file);
}
void set_new_model(char *modelPath)
{
printf("Loading new model: %s\n", modelPath);
curActor->model = GetExistingModel(modelPath);
strcpy(curActor->currentModelPath, modelPath);
}
*/

View file

@ -1,12 +0,0 @@
#ifndef EDITORSTATE_H
#define EDITORSTATE_H
void set_new_model(char *modelPath);
extern void (*asset_command)(char *asset);
void print_file(char *file);
#endif

View file

@ -16,10 +16,6 @@
#define PL_MPEG_IMPLEMENTATION #define PL_MPEG_IMPLEMENTATION
#include <pl_mpeg.h> #include <pl_mpeg.h>
#ifdef EDITOR
#include "editor.h"
#endif
#include "render.h" #include "render.h"
#include "2dphysics.h" #include "2dphysics.h"
@ -33,9 +29,7 @@
#include "sprite.h" #include "sprite.h"
#include "timer.h" #include "timer.h"
#include "window.h" #include "window.h"
#include "sound.h" #include "sound.h"
#include "engine.h" #include "engine.h"
void error_callback(int error, const char *description) { void error_callback(int error, const char *description) {
@ -44,6 +38,7 @@ void error_callback(int error, const char *description) {
} }
void engine_init() { void engine_init() {
glfwSetErrorCallback(error_callback); glfwSetErrorCallback(error_callback);
/* Initialize GLFW */ /* Initialize GLFW */
if (!glfwInit()) { if (!glfwInit()) {

View file

@ -5,7 +5,6 @@
#include "anim.h" #include "anim.h"
#include "debug.h" #include "debug.h"
#include "debugdraw.h" #include "debugdraw.h"
#include "editor.h"
#include "engine.h" #include "engine.h"
#include "font.h" #include "font.h"
#include "gameobject.h" #include "gameobject.h"

View file

@ -235,7 +235,7 @@ void draw_char_box(struct Character c, cpVect cursor, float scale, struct rgba c
cursor.x += wh.x / 2.f; cursor.x += wh.x / 2.f;
cursor.y += wh.y / 2.f; cursor.y += wh.y / 2.f;
draw_box(cursor, wh, color); // draw_box(cursor, wh, color);
} }
void text_flush() { void text_flush() {

View file

@ -42,6 +42,34 @@ void script_startup() {
JSValue num_cache[100] = {0}; JSValue num_cache[100] = {0};
int js_print_exception(JSValue v) {
#ifdef DBG
if (JS_IsException(v)) {
JSValue exception = JS_GetException(js);
/* TODO: Does it need freed if null? */
if (JS_IsNull(exception))
return 0;
JSValue val = JS_GetPropertyStr(js, exception, "stack");
const char *name = JS_ToCString(js, JS_GetPropertyStr(js, exception, "name"));
const char *msg = JS_ToCString(js, JS_GetPropertyStr(js, exception, "message"));
const char *stack = JS_ToCString(js, val);
YughLog(LOG_SCRIPT, LOG_ERROR, "%s :: %s\n%s", name, msg,stack);
JS_FreeCString(js, name);
JS_FreeCString(js, msg);
JS_FreeCString(js, stack);
JS_FreeValue(js,val);
JS_FreeValue(js,exception);
return 1;
}
#endif
return 0;
}
void script_init() { void script_init() {
/* Load all prefabs into memory */ /* Load all prefabs into memory */
// if (DBG) // if (DBG)
@ -89,32 +117,6 @@ void js_dump_stack() {
js_stacktrace(); js_stacktrace();
} }
int js_print_exception(JSValue v) {
#ifdef DBG
if (JS_IsException(v)) {
JSValue exception = JS_GetException(js);
/* TODO: Does it need freed if null? */
if (JS_IsNull(exception))
return 0;
JSValue val = JS_GetPropertyStr(js, exception, "stack");
const char *name = JS_ToCString(js, JS_GetPropertyStr(js, exception, "name"));
const char *msg = JS_ToCString(js, JS_GetPropertyStr(js, exception, "message"));
const char *stack = JS_ToCString(js, val);
YughLog(LOG_SCRIPT, LOG_ERROR, "%s :: %s\n%s", name, msg,stack);
JS_FreeCString(js, name);
JS_FreeCString(js, msg);
JS_FreeCString(js, stack);
JS_FreeValue(js,val);
JS_FreeValue(js,exception);
return 1;
}
#endif
return 0;
}

View file

@ -151,7 +151,7 @@ void free_sound(const char *wav) {
struct soundstream *soundstream_make() { struct soundstream *soundstream_make() {
struct soundstream *new = malloc(sizeof(*new)); struct soundstream *new = malloc(sizeof(*new));
new->buf = circbuf_make(sizeof(short), BUF_FRAMES * CHANNELS * 2); // new->buf = circbuf_make(sizeof(short), BUF_FRAMES * CHANNELS * 2);
return new; return new;
} }
@ -278,10 +278,10 @@ void mp3_fillbuf(struct sound *s, short *buf, int n) {
} }
void soundstream_fillbuf(struct soundstream *s, short *buf, int n) { void soundstream_fillbuf(struct soundstream *s, short *buf, int n) {
int max = s->buf->write - s->buf->read; int max = 1;//s->buf->write - s->buf->read;
int lim = (max < n * CHANNELS) ? max : n * CHANNELS; int lim = (max < n * CHANNELS) ? max : n * CHANNELS;
for (int i = 0; i < lim; i++) { for (int i = 0; i < lim; i++) {
buf[i] = cbuf_shift(s->buf); // buf[i] = cbuf_shift(s->buf);
} }
} }

View file

@ -426,10 +426,10 @@ struct dsp_delay dsp_delay_make(unsigned int ms_delay)
/* Circular buffer size is enough to have the delay */ /* Circular buffer size is enough to have the delay */
unsigned int datasize = ms_delay * CHANNELS * (SAMPLERATE / 1000); unsigned int datasize = ms_delay * CHANNELS * (SAMPLERATE / 1000);
new.buf = circbuf_init(sizeof(short), datasize); // new.buf = circbuf_init(sizeof(short), datasize);
new.buf.write = datasize; // new.buf.write = datasize;
YughInfo("Buffer size is %u.", new.buf.len); // YughInfo("Buffer size is %u.", new.buf.len);
return new; return new;
} }
@ -440,8 +440,8 @@ void dsp_delay_filbuf(struct dsp_delay *delay, short *buf, int n)
dsp_run(delay->in, cache, n); dsp_run(delay->in, cache, n);
for (int i = 0; i < n*CHANNELS; i++) { for (int i = 0; i < n*CHANNELS; i++) {
cbuf_push(&delay->buf, cache[i] / 2); // cbuf_push(&delay->buf, cache[i] / 2);
buf[i] = cache[i] + cbuf_shift(&delay->buf); // buf[i] = cache[i] + cbuf_shift(&delay->buf);
} }
} }

View file

@ -5,8 +5,7 @@
#define BUF_FRAMES 128 /* At 48k, 128 needed for 240fps consistency */ #define BUF_FRAMES 128 /* At 48k, 128 needed for 240fps consistency */
#define CHANNELS 2 #define CHANNELS 2
//#include "circbuf.h"
#include "circbuf.h"
struct dsp_iir; struct dsp_iir;
@ -66,7 +65,7 @@ struct dsp_filter make_adsr(unsigned int atk, unsigned int dec, unsigned int sus
struct dsp_delay { struct dsp_delay {
unsigned int ms_delay; unsigned int ms_delay;
struct circbuf buf; // struct circbuf buf;
struct dsp_filter in; struct dsp_filter in;
}; };

View file

@ -233,6 +233,7 @@ void window_makecurrent(struct window *w) {
if (w->window != glfwGetCurrentContext()) if (w->window != glfwGetCurrentContext())
glfwMakeContextCurrent(w->window); glfwMakeContextCurrent(w->window);
glViewport(0, 0, w->width, w->height); glViewport(0, 0, w->width, w->height);
} }

View file

@ -24,7 +24,10 @@
#include "2dphysics.h" #include "2dphysics.h"
#ifdef __linux__
#include <execinfo.h> #include <execinfo.h>
#endif
#include <signal.h> #include <signal.h>
#include <time.h> #include <time.h>
@ -32,7 +35,7 @@
#define SOKOL_TRACE_HOOKS #define SOKOL_TRACE_HOOKS
#define SOKOL_GFX_IMPL #define SOKOL_GFX_IMPL
#define SOKOL_GLCORE33 #define SOKOL_GLES3
#include "sokol/sokol_gfx.h" #include "sokol/sokol_gfx.h"
int physOn = 0; int physOn = 0;
@ -81,7 +84,9 @@ int backtrace(void **buffer, int size) {
} }
#endif #endif
void print_stacktrace() { void print_stacktrace() {
#ifdef __linux__
void *ents[512]; void *ents[512];
size_t size = backtrace(ents, 512); size_t size = backtrace(ents, 512);
@ -94,6 +99,7 @@ void print_stacktrace() {
YughCritical(stackstr[i]); YughCritical(stackstr[i]);
js_stacktrace(); js_stacktrace();
#endif
} }
void seghandle(int sig) { void seghandle(int sig) {