Converted to 'nuke' commands
This commit is contained in:
parent
8729892939
commit
06b8bba27f
48
Makefile
48
Makefile
|
@ -3,29 +3,32 @@ MAKEFLAGS = --jobs=$(PROCS)
|
|||
|
||||
UNAME != uname
|
||||
|
||||
QFLAGS = -O3 -DDBG=0 -DED=1
|
||||
INFO = rel
|
||||
PTYPE != uname -m
|
||||
|
||||
# Options
|
||||
# DBG=0,1 --- build with debugging symbols and logging
|
||||
# ED=0,1 --- build with or without editor
|
||||
|
||||
|
||||
|
||||
ED ?= 1
|
||||
DBG ?= 1
|
||||
|
||||
ifeq ($(DBG), 1)
|
||||
QFLAGS = -O0 -g -DDBG=1 -DED=1
|
||||
ifeq ($(CC), tcc)
|
||||
QFLAGS += -b -bt24
|
||||
endif
|
||||
LVL = -O0 -g
|
||||
INFO = dbg
|
||||
|
||||
ifeq ($(CC), tcc)
|
||||
LVL +=
|
||||
endif
|
||||
|
||||
else
|
||||
LVL = -O2 -DNDEBUG
|
||||
INFO = rel
|
||||
endif
|
||||
|
||||
ifeq ($(ED), 0)
|
||||
QFLAGS = -DED=0
|
||||
INFO = ed
|
||||
endif
|
||||
|
||||
|
||||
|
||||
QFLAGS = $(LVL) -DDBG=$(DBG) -DED=$(ED)
|
||||
|
||||
PTYPE != uname -m
|
||||
|
||||
BIN = bin/$(CC)/$(INFO)/
|
||||
objprefix = $(BIN)obj
|
||||
|
@ -43,13 +46,26 @@ endef
|
|||
|
||||
# All other sources
|
||||
edirs != find source -type d -name include
|
||||
subengs = sound debug editor 3d
|
||||
subengs = sound 3d
|
||||
|
||||
ifeq ($(ED), 1)
|
||||
subengs += editor
|
||||
endif
|
||||
|
||||
ifeq ($(DBG), 1)
|
||||
subengs += debug
|
||||
endif
|
||||
|
||||
|
||||
edirs += source/engine $(addprefix source/engine/, $(subengs)) source/engine/thirdparty/Nuklear
|
||||
ehead != find source/engine source/engine/sound source/engine/debug source/engine/editor -maxdepth 1 -type f -name *.h
|
||||
eobjects != find source/engine -type f -name '*.c' | sed -r 's|^(.*)\.c|$(objprefix)/\1.o|' # Gets all .c files and makes .o refs
|
||||
eobjects != $(call rm,$(eobjects),sqlite pl_mpeg_extract_frames pl_mpeg_player yugine nuklear)
|
||||
|
||||
includeflag != $(call prefix,$(edirs),-I)
|
||||
engincs != find source/engine -maxdepth 1 -type d
|
||||
includeflag != find source -type d -name include
|
||||
includeflag += engincs
|
||||
includeflag := $(addprefix -I, $(includeflag))
|
||||
|
||||
WARNING_FLAGS = -Wall# -pedantic -Wextra -Wwrite-strings -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function
|
||||
|
||||
|
|
|
@ -79,8 +79,8 @@ void phys2d_circledel(struct phys2d_circle *c)
|
|||
|
||||
void circle_gui(struct phys2d_circle *circle)
|
||||
{
|
||||
nk_property_float(ctx, "Radius", 1.f, &circle->radius, 10000.f, 1.f, 1.f);
|
||||
nk_property_float2(ctx, "Offset", 0.f, circle->offset, 1.f, 0.01f, 0.01f);
|
||||
nuke_property_float("Radius", 1.f, &circle->radius, 10000.f, 1.f, 1.f);
|
||||
nuke_property_float2("Offset", 0.f, circle->offset, 1.f, 0.01f, 0.01f);
|
||||
|
||||
phys2d_applycircle(circle);
|
||||
}
|
||||
|
@ -121,8 +121,8 @@ void phys2d_segdel(struct phys2d_segment *seg)
|
|||
|
||||
void segment_gui(struct phys2d_segment *seg)
|
||||
{
|
||||
nk_property_float2(ctx, "a", 0.f, seg->a, 1.f, 0.01f, 0.01f);
|
||||
nk_property_float2(ctx, "b", 0.f, seg->b, 1.f, 0.01f, 0.01f);
|
||||
nuke_property_float2("a", 0.f, seg->a, 1.f, 0.01f, 0.01f);
|
||||
nuke_property_float2("b", 0.f, seg->b, 1.f, 0.01f, 0.01f);
|
||||
|
||||
phys2d_applyseg(seg);
|
||||
}
|
||||
|
@ -154,9 +154,9 @@ void phys2d_boxdel(struct phys2d_box *box)
|
|||
|
||||
void box_gui(struct phys2d_box *box)
|
||||
{
|
||||
nk_property_float(ctx, "Width", 0.f, &box->w, 1000.f, 1.f, 1.f);
|
||||
nk_property_float(ctx, "Height", 0.f, &box->h, 1000.f, 1.f, 1.f);
|
||||
nk_property_float2(ctx, "Offset", 0.f, box->offset, 1.f, 0.01f, 0.01f);
|
||||
nuke_property_float("Width", 0.f, &box->w, 1000.f, 1.f, 1.f);
|
||||
nuke_property_float("Height", 0.f, &box->h, 1000.f, 1.f, 1.f);
|
||||
nuke_property_float2("Offset", 0.f, box->offset, 1.f, 0.01f, 0.01f);
|
||||
|
||||
phys2d_applybox(box);
|
||||
}
|
||||
|
@ -199,13 +199,13 @@ void phys2d_polyaddvert(struct phys2d_poly *poly)
|
|||
void poly_gui(struct phys2d_poly *poly)
|
||||
{
|
||||
|
||||
if (nk_button_label(ctx, "Add Poly Vertex")) phys2d_polyaddvert(poly);
|
||||
if (nuke_btn("Add Poly Vertex")) phys2d_polyaddvert(poly);
|
||||
|
||||
for (int i = 0; i < poly->n; i++) {
|
||||
nk_property_float2(ctx, "#P", 0.f, &poly->points[i*2], 1.f, 0.1f, 0.1f);
|
||||
nuke_property_float2("#P", 0.f, &poly->points[i*2], 1.f, 0.1f, 0.1f);
|
||||
}
|
||||
|
||||
nk_property_float(ctx, "Radius", 0.01f, &poly->radius, 1000.f, 1.f, 0.1f);
|
||||
nuke_property_float("Radius", 0.01f, &poly->radius, 1000.f, 1.f, 0.1f);
|
||||
|
||||
phys2d_applypoly(poly);
|
||||
}
|
||||
|
@ -271,12 +271,12 @@ void phys2d_edgeaddvert(struct phys2d_edge *edge)
|
|||
|
||||
void edge_gui(struct phys2d_edge *edge)
|
||||
{
|
||||
if (nk_button_label(ctx, "Add Edge Vertex")) phys2d_edgeaddvert(edge);
|
||||
if (nuke_btn("Add Edge Vertex")) phys2d_edgeaddvert(edge);
|
||||
|
||||
for (int i = 0; i < edge->n; i++)
|
||||
nk_property_float2(ctx, "E", 0.f, &edge->points[i*2], 1.f, 0.01f, 0.01f);
|
||||
nuke_property_float2("E", 0.f, &edge->points[i*2], 1.f, 0.01f, 0.01f);
|
||||
|
||||
nk_property_float(ctx, "Thickness", 0.01f, &edge->thickness, 1.f, 0.01f, 0.01f);
|
||||
nuke_property_float("Thickness", 0.01f, &edge->thickness, 1.f, 0.01f, 0.01f);
|
||||
|
||||
phys2d_applyedge(edge);
|
||||
}
|
||||
|
|
|
@ -17,15 +17,9 @@ char *catstr[] = {"ENGINE", "SCRIPT"};
|
|||
FILE *logfile = NULL;
|
||||
|
||||
#define CONSOLE_BUF 1024*1024/* 1MB */
|
||||
char con[CONSOLE_BUF] = {'\0'};
|
||||
int coni = 0;
|
||||
|
||||
char lastlog[ERROR_BUFFER] = {'\0'};
|
||||
|
||||
const char *console() {
|
||||
return console;
|
||||
}
|
||||
|
||||
void mYughLog(int category, int priority, int line, const char *file, const char *message, ...)
|
||||
{
|
||||
if (priority >= logLevel) {
|
||||
|
@ -50,10 +44,6 @@ void mYughLog(int category, int priority, int line, const char *file, const char
|
|||
fflush(logfile);
|
||||
}
|
||||
|
||||
int add = snprintf(con+coni, CONSOLE_BUF-coni, "%s\n", buffer);
|
||||
coni += add;
|
||||
if (coni > CONSOLE_BUF) coni = CONSOLE_BUF;
|
||||
|
||||
snprintf(lastlog, ERROR_BUFFER, "%s", buffer);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,25 +10,27 @@
|
|||
#define LOG_ERROR 2
|
||||
#define LOG_CRITICAL 3
|
||||
|
||||
extern char con[];
|
||||
extern int coni;
|
||||
extern char lastlog[];
|
||||
|
||||
#if DBG
|
||||
#define YughLog(cat, pri, msg, ...) mYughLog(cat, pri, __LINE__, __FILE__, msg, ##__VA_ARGS__)
|
||||
#define YughInfo(msg, ...) mYughLog(0, 0, __LINE__, __FILE__, msg, ##__VA_ARGS__);
|
||||
#define YughWarn(msg, ...) mYughLog(0, 1, __LINE__, __FILE__, msg, ##__VA_ARGS__);
|
||||
#define YughError(msg, ...) mYughLog(0, 2, __LINE__, __FILE__, msg, ##__VA_ARGS__);
|
||||
#define YughCritical(msg, ...) mYughLog(0, 3, __LINE__, __FILE__, msg, ##__VA_ARGS__);
|
||||
#else
|
||||
#define YughLog(cat, pri, msg, ...)
|
||||
#define YughInfo(msg, ...)
|
||||
#define YughWarn(msg, ...)
|
||||
#define YughError(msg, ...)
|
||||
#define YughCritical(msg, ...)
|
||||
#endif
|
||||
|
||||
void mYughLog(int category, int priority, int line, const char *file, const char *message, ...);
|
||||
|
||||
void FlushGLErrors();
|
||||
|
||||
int TestSDLError(int sdlErr);
|
||||
|
||||
void log_setfile(char *file);
|
||||
void log_cat(FILE *f);
|
||||
|
||||
const char *console();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include "ftw.h"
|
||||
|
||||
extern struct nk_context *ctx;
|
||||
|
||||
#include <stb_ds.h>
|
||||
#define ASSET_TEXT_BUF 1024 * 1024 /* 1 MB buffer for editing text files */
|
||||
|
||||
|
@ -502,12 +504,12 @@ void editor_project_gui() {
|
|||
nuke_labelf("Current level: %s", current_level[0] == '\0' ? "No level loaded." : current_level);
|
||||
|
||||
nuke_nel(3);
|
||||
if (nk_button_label(ctx, "New")) {
|
||||
if (nuke_btn("New")) {
|
||||
new_level();
|
||||
current_level[0] = '\0';
|
||||
}
|
||||
|
||||
if (nk_button_label(ctx, "Save")) {
|
||||
if (nuke_btn("Save")) {
|
||||
if (strlen(current_level) == 0) {
|
||||
YughWarn("Can't save level that has no name.");
|
||||
} else {
|
||||
|
@ -516,7 +518,7 @@ void editor_project_gui() {
|
|||
}
|
||||
}
|
||||
|
||||
if (nk_button_label(ctx, "Save as")) {
|
||||
if (nuke_btn("Save as")) {
|
||||
if (strlen(current_level) == 0) {
|
||||
YughWarn("Can't save level that has no name.");
|
||||
} else {
|
||||
|
@ -552,13 +554,13 @@ void editor_project_gui() {
|
|||
// nk_edit_string_zero_terminated(ctx, NK_EDIT_SIMPLE, cur_project->name,
|
||||
// 126, nk_filter_default);
|
||||
|
||||
if (nk_tree_push(ctx, NK_TREE_NODE, "Physics", NK_MINIMIZED)) {
|
||||
if (nuke_push_tree_id("Physics", 0)) {
|
||||
nuke_prop_float("2d Gravity", -5000.f, &phys2d_gravity, 0.f, 1.f, 0.1f);
|
||||
phys2d_apply();
|
||||
nk_tree_pop(ctx);
|
||||
}
|
||||
|
||||
if (nk_tree_push(ctx, NK_TREE_NODE, "Quality", NK_MINIMIZED)) {
|
||||
if (nuke_push_tree_id("Quality", 0)) {
|
||||
nk_tree_pop(ctx);
|
||||
}
|
||||
|
||||
|
@ -571,18 +573,8 @@ void editor_project_gui() {
|
|||
|
||||
NK_MENU_START(repl)
|
||||
|
||||
/*
|
||||
nk_layout_row_dynamic(ctx, 300, 1);
|
||||
|
||||
static char bigbuf[10000] = {\0'};
|
||||
nuke_label(bigbuf);
|
||||
|
||||
|
||||
*/
|
||||
nk_layout_row_dynamic(ctx, 300, 1);
|
||||
//nk_text(ctx, con, coni, NK_TEXT_ALIGN_TOP|NK_TEXT_ALIGN_LEFT);
|
||||
nk_edit_string_zero_terminated(ctx, NK_EDIT_MULTILINE|NK_EDIT_READ_ONLY|NK_EDIT_GOTO_END_ON_ACTIVATE, lastlog, ERROR_BUFFER, NULL);
|
||||
//nuke_label(lastlog);
|
||||
static char buffer[512] = {'\0'};
|
||||
nk_layout_row_dynamic(ctx, 25, 2);
|
||||
nk_flags active = nk_edit_string_zero_terminated(ctx, NK_EDIT_BOX | NK_EDIT_SIG_ENTER|NK_EDIT_AUTO_SELECT, buffer, 512-1, nk_filter_ascii);
|
||||
|
@ -631,7 +623,7 @@ void editor_project_gui() {
|
|||
nuke_nel(1);
|
||||
editor.asset_srch = nk_edit_string_zero_terminated(ctx, NK_EDIT_SIMPLE, asset_search_buffer, 100, nk_filter_ascii);
|
||||
|
||||
if (nk_button_label(ctx, "Reload all files"))
|
||||
if (nuke_btn("Reload all files"))
|
||||
get_all_files();
|
||||
|
||||
|
||||
|
@ -639,7 +631,7 @@ void editor_project_gui() {
|
|||
if (!assets[i].value->searched)
|
||||
continue;
|
||||
|
||||
if (nk_button_label(ctx, assets[i].key))
|
||||
if (nuke_btn(assets[i].key))
|
||||
editor_selectasset_str(assets[i].key);
|
||||
|
||||
}
|
||||
|
@ -703,7 +695,7 @@ startobjectgui:
|
|||
goto startobjectgui;
|
||||
}
|
||||
|
||||
if (selectedobject->editor.prefabSync && nk_button_label(ctx, "Revert"))
|
||||
if (selectedobject->editor.prefabSync && nuke_btn("Revert"))
|
||||
gameobject_revertprefab(selectedobject);
|
||||
|
||||
nuke_label("Name");
|
||||
|
@ -927,7 +919,7 @@ void editor_asset_gui(struct fileasset *asset) {
|
|||
nuke_nel(2);
|
||||
nk_labelf(ctx, NK_TEXT_LEFT, "%s", selected_asset->filename);
|
||||
|
||||
if (nk_button_label(ctx, "Close"))
|
||||
if (nuke_btn("Close"))
|
||||
selected_asset = NULL;
|
||||
|
||||
nuke_nel(1);
|
||||
|
@ -970,7 +962,7 @@ int obj_gui_hierarchy(struct gameobject *selected) {
|
|||
void get_levels() { fill_extensions(levels, DATA_PATH, EXT_LEVEL); }
|
||||
|
||||
void editor_prefab_btn(char *prefab) {
|
||||
if (nk_button_label(ctx, prefab)) {
|
||||
if (nuke_btn(prefab)) {
|
||||
YughInfo("Making prefab '%s'.", prefab);
|
||||
gameobject_makefromprefab(prefab);
|
||||
}
|
||||
|
@ -991,7 +983,7 @@ void sprite_gui(struct sprite *sprite) {
|
|||
|
||||
|
||||
|
||||
if (nk_button_label(ctx, "Load texture") && selected_asset != NULL) {
|
||||
if (nuke_btn("Load texture") && selected_asset != NULL) {
|
||||
sprite_loadtex(sprite, selected_asset->filename);
|
||||
}
|
||||
|
||||
|
@ -1006,20 +998,20 @@ void sprite_gui(struct sprite *sprite) {
|
|||
}
|
||||
|
||||
|
||||
nk_property_float2(ctx, "Sprite Position", -1.f, sprite->pos, 0.f, 0.01f, 0.01f);
|
||||
nuke_property_float2("Sprite Position", -1.f, sprite->pos, 0.f, 0.01f, 0.01f);
|
||||
|
||||
nuke_nel(3);
|
||||
if (nk_button_label(ctx, "C")) {
|
||||
if (nuke_btn("C")) {
|
||||
sprite->pos[0] = -0.5f;
|
||||
sprite->pos[1] = -0.5f;
|
||||
}
|
||||
|
||||
if (nk_button_label(ctx, "U")) {
|
||||
if (nuke_btn("U")) {
|
||||
sprite->pos[0] = -0.5f;
|
||||
sprite->pos[1] = -1.f;
|
||||
}
|
||||
|
||||
if (nk_button_label(ctx, "D")) {
|
||||
if (nuke_btn("D")) {
|
||||
sprite->pos[0] = -0.5f;
|
||||
sprite->pos[1] = 0.f;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <stdbool.h>
|
||||
#include "resources.h"
|
||||
|
||||
#include "nuke.h"
|
||||
#include "nuklear.h"
|
||||
|
||||
#define ASSET_TYPE_NULL 0
|
||||
#define ASSET_TYPE_IMAGE 1
|
||||
|
@ -49,16 +49,16 @@ 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 (nk_begin(ctx, #VAR, editor.VAR.rect, nuk_std)) { \
|
||||
editor.VAR.rect = nk_window_get_bounds(ctx);
|
||||
if (nuke_begin(#VAR, editor.VAR.rect, nuk_std)) { \
|
||||
editor.VAR.rect = nuke_win_get_bounds();
|
||||
|
||||
#define NK_MENU_END() } nk_end(ctx); }
|
||||
#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 && nk_begin(ctx, #VAR, editor.VAR.rect, nuk_std)) { \
|
||||
editor.VAR.rect = nk_window_get_bounds(ctx);
|
||||
if (!show_desktop && nuke_begin(#VAR, editor.VAR.rect, nuk_std)) { \
|
||||
editor.VAR.rect = nuke_win_get_bounds();
|
||||
|
||||
#define NK_FORCE_END() nk_end(ctx); }
|
||||
#define NK_FORCE_END() nuke_stop(); }
|
||||
|
||||
#define NEGATE(VAR) VAR = ! VAR
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ void font_init(struct shader *textshader) {
|
|||
|
||||
|
||||
// Default font
|
||||
font = MakeFont("teenytinypixels.ttf", 300);
|
||||
font = MakeFont("teenytinypixels.ttf", 16);
|
||||
}
|
||||
|
||||
void font_frame(struct window *w) {
|
||||
|
|
|
@ -259,7 +259,7 @@ void object_gui(struct gameobject *go)
|
|||
|
||||
draw_point(temp_pos[0], temp_pos[1], 3);
|
||||
|
||||
nk_property_float2(ctx, "Position", -1000000.f, temp_pos, 1000000.f, 1.f, 0.5f);
|
||||
nuke_property_float2("Position", -1000000.f, temp_pos, 1000000.f, 1.f, 0.5f);
|
||||
|
||||
cpVect tvect = { temp_pos[0], temp_pos[1] };
|
||||
cpBodySetPosition(go->body, tvect);
|
||||
|
@ -270,13 +270,13 @@ void object_gui(struct gameobject *go)
|
|||
modtry += 360.f;
|
||||
|
||||
float modtry2 = modtry;
|
||||
nk_property_float(ctx, "Angle", -1000.f, &modtry, 1000.f, 0.5f, 0.5f);
|
||||
nuke_property_float("Angle", -1000.f, &modtry, 1000.f, 0.5f, 0.5f);
|
||||
modtry -= modtry2;
|
||||
cpBodySetAngle(go->body, mtry + (modtry * DEG2RADS));
|
||||
|
||||
nk_property_float(ctx, "Scale", 0.f, &go->scale, 1000.f, 0.01f, go->scale * 0.01f);
|
||||
nuke_property_float("Scale", 0.f, &go->scale, 1000.f, 0.01f, go->scale * 0.01f);
|
||||
|
||||
nk_layout_row_dynamic(ctx, 25, 3);
|
||||
nuke_nel(3);
|
||||
nuke_radio_btn("Static", &go->bodytype, CP_BODY_TYPE_STATIC);
|
||||
nuke_radio_btn("Dynamic", &go->bodytype, CP_BODY_TYPE_DYNAMIC);
|
||||
nuke_radio_btn("Kinematic", &go->bodytype, CP_BODY_TYPE_KINEMATIC);
|
||||
|
@ -284,12 +284,12 @@ void object_gui(struct gameobject *go)
|
|||
cpBodySetType(go->body, go->bodytype);
|
||||
|
||||
if (go->bodytype == CP_BODY_TYPE_DYNAMIC) {
|
||||
nk_property_float(ctx, "Mass", 0.01f, &go->mass, 1000.f, 0.01f, 0.01f);
|
||||
nuke_property_float("Mass", 0.01f, &go->mass, 1000.f, 0.01f, 0.01f);
|
||||
cpBodySetMass(go->body, go->mass);
|
||||
}
|
||||
|
||||
nk_property_float(ctx, "Friction", 0.f, &go->f, 10.f, 0.01f, 0.01f);
|
||||
nk_property_float(ctx, "Elasticity", 0.f, &go->e, 2.f, 0.01f, 0.01f);
|
||||
nuke_property_float("Friction", 0.f, &go->f, 10.f, 0.01f, 0.01f);
|
||||
nuke_property_float("Elasticity", 0.f, &go->e, 2.f, 0.01f, 0.01f);
|
||||
|
||||
int n = -1;
|
||||
|
||||
|
@ -302,13 +302,12 @@ void object_gui(struct gameobject *go)
|
|||
c->draw_debug(c->data);
|
||||
|
||||
|
||||
nuke_nel(5);
|
||||
if (nk_button_label(ctx, "Del")) n = i;
|
||||
if (nk_tree_push_id(ctx, NK_TREE_NODE, c->name, NK_MINIMIZED, i)) {
|
||||
nuke_nel(5);
|
||||
if (nuke_btn("Del")) n = i;
|
||||
|
||||
if (nuke_push_tree_id(c->name, i)) {
|
||||
c->draw_gui(c->data);
|
||||
|
||||
nk_tree_pop(ctx);
|
||||
nuke_tree_pop();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -280,19 +280,14 @@ s7_pointer s7_set_pawn(s7_scheme *sc, s7_pointer args) {
|
|||
s7_pointer s7_set_body(s7_scheme *sc, s7_pointer args) {
|
||||
int id = s7_integer(s7_car(args));
|
||||
int cmd = s7_integer(s7_cadr(args));
|
||||
double val1;
|
||||
double val2;
|
||||
|
||||
switch (cmd) {
|
||||
case 0:
|
||||
val1 = s7_real(s7_caddr(args));
|
||||
gameobject_setangle(get_gameobject_from_id(id), val1);
|
||||
gameobject_setangle(get_gameobject_from_id(id), s7_real(s7_caddr(args)));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
val1 = s7_real(s7_car(s7_caddr(args)));
|
||||
val2 = s7_real(s7_cadr(s7_caddr(args)));
|
||||
gameobject_setpos(get_gameobject_from_id(id), val1, val2);
|
||||
cpBodySetType(get_gameobject_from_id(id)->body, s7_integer(s7_caddr(args)));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -367,14 +362,19 @@ void ffi_load() {
|
|||
S7_FUNC(ui_nel, 1);
|
||||
S7_FUNC(ui_prop, 6);
|
||||
S7_FUNC(ui_text, 2);
|
||||
S7_FUNC(gui_text, 4);
|
||||
S7_FUNC(settings_cmd, 2);
|
||||
S7_FUNC(win_cmd, 2);
|
||||
S7_FUNC(ui_rendertext, 3);
|
||||
S7_FUNC(log, 4);
|
||||
S7_FUNC(win_make, 3);
|
||||
|
||||
S7_FUNC(gui_text, 4);
|
||||
|
||||
S7_FUNC(gen_cmd, 2);
|
||||
S7_FUNC(sys_cmd, 1);
|
||||
S7_FUNC(settings_cmd, 2);
|
||||
|
||||
|
||||
S7_FUNC(win_cmd, 2);
|
||||
S7_FUNC(win_make, 3);
|
||||
|
||||
|
||||
S7_FUNC(sound_cmd, 2);
|
||||
S7_FUNC(gui_hook, 1);
|
||||
S7_FUNC(register, 2);
|
||||
|
@ -385,5 +385,7 @@ void ffi_load() {
|
|||
S7_FUNC(phys_q, 2);
|
||||
S7_FUNC(phys_set, 3);
|
||||
S7_FUNC(int_cmd, 2);
|
||||
|
||||
S7_FUNC(log, 4);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,12 @@
|
|||
#define NK_GLFW_GL3_IMPLEMENTATION
|
||||
#define NK_KEYSTATE_BASED_INPUT
|
||||
|
||||
|
||||
#include "nuke.h"
|
||||
#include "nuklear_glfw_gl3.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "window.h"
|
||||
|
||||
#define MAX_VERTEX_BUFFER 512 * 1024
|
||||
|
@ -27,6 +30,7 @@ void nuke_init(struct window *win) {
|
|||
|
||||
ctx = nk_glfw3_init(&nkglfw, win->window, NK_GLFW3_INSTALL_CALLBACKS);
|
||||
|
||||
|
||||
struct nk_font_atlas *atlas;
|
||||
nk_glfw3_font_stash_begin(&nkglfw, &atlas);
|
||||
struct nk_font *noto = nk_font_atlas_add_from_file(atlas, "fonts/notosans.tff", 14, 0);
|
||||
|
@ -43,21 +47,33 @@ void nuke_end()
|
|||
nk_glfw3_render(&nkglfw, NK_ANTI_ALIASING_ON, MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER);
|
||||
}
|
||||
|
||||
void nk_property_float3(struct nk_context *ctx, const char *label, float min, float *val, float max, float step, float dragstep) {
|
||||
|
||||
int nuke_begin(const char *lbl, struct nk_rect rect, int flags) {
|
||||
return nk_begin(ctx, lbl, rect, flags);
|
||||
}
|
||||
void nuke_stop() {
|
||||
nk_end(ctx);
|
||||
}
|
||||
|
||||
struct nk_rect nuke_win_get_bounds() {
|
||||
return nk_window_get_bounds(ctx);
|
||||
}
|
||||
|
||||
void nuke_property_float3(const char *label, float min, float *val, float max, float step, float dragstep) {
|
||||
nk_layout_row_dynamic(ctx, 25, 1);
|
||||
nk_label(ctx, label, NK_TEXT_LEFT);
|
||||
nk_layout_row_dynamic(ctx, 25, 3);
|
||||
nk_property_float(ctx, "#X", min, &val[0], max, step, dragstep);
|
||||
nk_property_float(ctx, "#Y", min, &val[1], max, step, dragstep);
|
||||
nk_property_float(ctx, "#Z", min, &val[2], max, step, dragstep);
|
||||
nuke_property_float("#X", min, &val[0], max, step, dragstep);
|
||||
nuke_property_float("#Y", min, &val[1], max, step, dragstep);
|
||||
nuke_property_float("#Z", min, &val[2], max, step, dragstep);
|
||||
}
|
||||
|
||||
void nk_property_float2(struct nk_context *ctx, const char *label, float min, float *val, float max, float step, float dragstep) {
|
||||
void nuke_property_float2(const char *label, float min, float *val, float max, float step, float dragstep) {
|
||||
nk_layout_row_dynamic(ctx, 25, 1);
|
||||
nk_label(ctx, label, NK_TEXT_LEFT);
|
||||
nk_layout_row_dynamic(ctx, 25, 2);
|
||||
nk_property_float(ctx, "#X", min, &val[0], max, step, dragstep);
|
||||
nk_property_float(ctx, "#Y", min, &val[1], max, step, dragstep);
|
||||
nuke_property_float("#X", min, &val[0], max, step, dragstep);
|
||||
nuke_property_float("#Y", min, &val[1], max, step, dragstep);
|
||||
}
|
||||
|
||||
void nuke_property_float(const char *lbl, float min, float *val, float max, float step, float dragstep) {
|
||||
|
@ -72,12 +88,7 @@ void nuke_property_int(const char *lbl, int min, int *val, int max, int step) {
|
|||
nk_property_int(ctx, lbl, min, val, max, step, step);
|
||||
}
|
||||
|
||||
void nk_radio_button_label(struct nk_context *ctx, const char *label, int *val, int cmp) {
|
||||
if (nk_option_label(ctx, label, *val == cmp)) *val = cmp;
|
||||
}
|
||||
|
||||
void nuke_radio_btn(const char *lbl, int *val, int cmp) {
|
||||
//nk_radio_button_label(ctx, lbl, val, cmp);
|
||||
if (nk_option_label(ctx, lbl, *val==cmp)) *val = cmp;
|
||||
}
|
||||
|
||||
|
@ -95,4 +106,17 @@ void nuke_label(const char *s) {
|
|||
|
||||
void nuke_edit_str(char *str) {
|
||||
nk_edit_string_zero_terminated(ctx, NK_EDIT_BOX|NK_EDIT_NO_HORIZONTAL_SCROLL, str, 130, nk_filter_ascii);
|
||||
}
|
||||
|
||||
int nuke_push_tree_id(const char *name, int id) {
|
||||
return nk_tree_push_id(ctx, NK_TREE_NODE, name, NK_MINIMIZED, id);
|
||||
}
|
||||
|
||||
void nuke_tree_pop() {
|
||||
nk_tree_pop(ctx);
|
||||
}
|
||||
|
||||
void nuke_labelf(const char *fmt, ...) {
|
||||
va_list args;
|
||||
nk_labelf(ctx, NK_TEXT_LEFT, fmt, args);
|
||||
}
|
|
@ -1,23 +1,24 @@
|
|||
#ifndef NUKE_H
|
||||
#define NUKE_H
|
||||
#define NK_INCLUDE_FIXED_TYPES
|
||||
|
||||
#include "nuklear.h"
|
||||
|
||||
|
||||
extern struct nk_context *ctx;
|
||||
|
||||
struct window;
|
||||
|
||||
void nuke_init(struct window *win);
|
||||
void nuke_start();
|
||||
void nuke_end();
|
||||
|
||||
void nk_property_float3(struct nk_context *ctx, const char *label, float min, float *val, float max, float step, float dragstep);
|
||||
void nk_property_float2(struct nk_context *ctx, const char *label, float min, float *val, float max, float step, float dragstep);
|
||||
int nuke_begin(const char *lbl, struct nk_rect rect, int flags);
|
||||
void nuke_stop();
|
||||
struct nk_rect nuke_win_get_bounds();
|
||||
|
||||
void nuke_property_float(const char *lbl, float min, float *val, float max, float step, float dragstep);
|
||||
#define nuke_prop_float nuke_property_float
|
||||
void nuke_property_float2(const char *label, float min, float *val, float max, float step, float dragstep);
|
||||
void nuke_property_float3(const char *label, float min, float *val, float max, float step, float dragstep);
|
||||
|
||||
void nuke_property_int(const char *lbl, int min, int *val, int max, int step);
|
||||
void nk_radio_button_label(struct nk_context *ctx, const char *label, int *val, int cmp);
|
||||
void nuke_radio_btn(const char *lbl, int *val, int cmp);
|
||||
void nuke_checkbox(const char *lbl, int *val);
|
||||
void nuke_nel(int cols);
|
||||
|
@ -25,9 +26,11 @@ void nuke_label(const char *s);
|
|||
void nuke_prop_float(const char *label, float min, float *val, float max, float step, float dragstep);
|
||||
void nuke_edit_str(char *str);
|
||||
|
||||
int nuke_push_tree_id(const char *name, int id);
|
||||
void nuke_tree_pop();
|
||||
|
||||
int nuke_btn(const char *lbl);
|
||||
|
||||
#define nuke_labelf(STR, ...) nk_labelf(ctx, NK_TEXT_LEFT, STR, __VA_ARGS__)
|
||||
#define nuke_prop_float(LABEL, MIN, VAL, MAX, STEP, DRAG) nk_property_float(ctx, LABEL, MIN, VAL, MAX, STEP, DRAG)
|
||||
void nuke_labelf(const char *fmt, ...);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -47,7 +47,7 @@ mfloat_t *trans_left(mfloat_t * res, const struct mTransform *trans)
|
|||
|
||||
void trans_drawgui(struct mTransform *T)
|
||||
{
|
||||
nk_property_float3(ctx, "Position", -1000.f, T->position, 1000.f, 1.f, 1.f);
|
||||
nk_property_float3(ctx, "Rotation", 0.f, T->rotation, 360.f, 1.f, 0.1f);
|
||||
nk_property_float(ctx, "Scale", 0.f, &T->scale, 1000.f, 0.1f, 0.1f);
|
||||
nuke_property_float3("Position", -1000.f, T->position, 1000.f, 1.f, 1.f);
|
||||
nuke_property_float3("Rotation", 0.f, T->rotation, 360.f, 1.f, 0.1f);
|
||||
nuke_property_float("Scale", 0.f, &T->scale, 1000.f, 0.1f, 0.1f);
|
||||
}
|
||||
|
|
|
@ -5,16 +5,20 @@
|
|||
#include "input.h"
|
||||
#include "openglrender.h"
|
||||
#include "script.h"
|
||||
#include "editor.h"
|
||||
|
||||
#include "log.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "editorstate.h"
|
||||
|
||||
#include "yugine.h"
|
||||
#include "2dphysics.h"
|
||||
|
||||
|
||||
#if ED
|
||||
#include "editor.h"
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
@ -109,7 +113,8 @@ int main(int argc, char **args) {
|
|||
}
|
||||
}
|
||||
|
||||
if (DBG && logout) {
|
||||
#if DBG
|
||||
if (logout) {
|
||||
time_t now = time(NULL);
|
||||
char fname[100];
|
||||
snprintf(fname, 100, "yugine-%d.log", now);
|
||||
|
@ -118,8 +123,6 @@ int main(int argc, char **args) {
|
|||
|
||||
YughInfo("Starting yugine version %s.", VER);
|
||||
|
||||
signal(SIGSEGV, seghandle);
|
||||
|
||||
FILE *sysinfo = NULL;
|
||||
sysinfo = popen("uname -a", "r");
|
||||
if (!sysinfo) {
|
||||
|
@ -129,6 +132,13 @@ int main(int argc, char **args) {
|
|||
pclose(sysinfo);
|
||||
}
|
||||
|
||||
|
||||
signal(SIGSEGV, seghandle);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
FILE *gameinfo = NULL;
|
||||
gameinfo = fopen("game.info", "w");
|
||||
fprintf(gameinfo, "Yugine v. %s, sys %s.", VER, INFO);
|
||||
|
@ -191,9 +201,6 @@ int main(int argc, char **args) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int sim_playing() { return sim_play; }
|
||||
int sim_paused() { return (!sim_play && gameobjects_saved()); }
|
||||
|
||||
|
|
|
@ -92,6 +92,12 @@
|
|||
(* deg 0.01745329252))
|
||||
|
||||
(define (body_angle! body angle) (set_body body 0 angle))
|
||||
(define-macro (body_type! body type)
|
||||
`(set_body ,body 1 ,(case type
|
||||
((static) 2)
|
||||
((dynamic) 0)
|
||||
((kinematic) 1))))
|
||||
|
||||
(define (body_pos! body x y) (set_body_pos body 0 x y))
|
||||
(define (body_move! body x y) (set_body_pos body 1 x y))
|
||||
|
||||
|
|
Loading…
Reference in a new issue