Compare commits

..

No commits in common. "cf0f402da357ec13998f66dd8fea4e207b4e3f8c" and "a1439664ca2f1267145fc3fb4a4563a1971708cc" have entirely different histories.

5 changed files with 21 additions and 62 deletions

View File

@ -1,17 +1 @@
Homepage: https://mid.net.ua/k4.html
## Changelog
## v2
1. k3Menu objects now have stylable properties ala CSS
2. Exposed `game.ui.obj` "base object" which allows you to create your own widgets
3. Revamped the animation system to one with blend trees
4. Added scrollboxes and image objects to k3Menu
5. Replaced the font subsystem with one that uses TrueType fonts directly, and they are drawn using signed distance fields when possible
6. Added `game.near` and `game.far` values for editing the camera planes
7. Added vsync parameter to command line
## v1
Initial release.

View File

@ -1017,7 +1017,7 @@ void game_killentity(uint16_t eid) {
if(cr) {
if(cr->cache) {
if(resman_rev(cr->cache)) {
resman_unref_ptr(RESMAN_MODEL, cr->cache);
resman_unref(RESMAN_MODEL, cr->cache);
}
}

View File

@ -45,5 +45,3 @@ void k4_set_texture_reduction(int);
void k4_set_clipboard_text(const char *str);
const char *k4_get_clipboard_text();
void k4_set_ui_mode(bool yes);

View File

@ -1294,7 +1294,7 @@ static int game_get(lua_State *L) {
if(UiActive) {
struct menuitem *item = lua_newuserdata(L, sizeof(*item));
item->type = MENUITEM_SCREEN;
item->ptr = (struct k3MObj*) UiActive;
item->ptr = UiActive;
} else {
lua_pushnil(L);
}
@ -1317,16 +1317,16 @@ static int game_set(lua_State *L) {
LuaapiFar = lua_tonumber(L, 3);
} else if(!strcmp(i, "menu")) {
struct menuitem *item = lua_touserdata(L, 3);
UiActive = item ? (struct k3MScreen*) item->ptr : NULL;
UiActive = item ? item->ptr : NULL;
k4_set_ui_mode(!!UiActive);
set_ui_mode(!!UiActive);
if(UiActive) {
UiActive->w = UiActive->wDesired = GameWndW;
UiActive->h = UiActive->hDesired = GameWndH;
k3MMeasure((struct k3MObj*) UiActive);
k3MArrange((struct k3MObj*) UiActive);
k3MMeasure(UiActive);
k3MArrange(UiActive);
}
} else {
lua_pushvalue(L, 2);
@ -1493,7 +1493,7 @@ static int luaapi_require(lua_State *L) {
}
for(int i = 0; i < nameLen;) {
if(!isalpha(name[i]) && !isdigit(name[i]) && name[i] != '_' && name[i] != '-' && name[i] != '.') {
if(!isalpha(name[i]) && !isdigit(name[i]) && name[i] != '_' && name[i] != '-') {
memmove(name + i + 1, name + i, --nameLen - i);
} else i++;
}
@ -1511,7 +1511,7 @@ static int luaapi_require(lua_State *L) {
}
char buf[128];
snprintf(buf, sizeof(buf), "%.*s.lua", (int) nameLen, name);
snprintf(buf, sizeof(buf), "%s.lua", name);
buf[127] = 0;
for(size_t i = 0; buf[i] && i < strlen(buf) - 4; i++) {
if(buf[i] == '.') buf[i] = '/';
@ -2095,17 +2095,6 @@ static int dagame_k3menuitem_add_child(lua_State *L) {
return 1;
}
static int dagame_k3menuitem_remove_child(lua_State *L) {
struct menuitem *parent = lua_touserdata(L, 1);
struct menuitem *child = lua_touserdata(L, 2);
k3MRemoveChild(parent->ptr, child->ptr);
lua_pushvalue(L, 1);
return 1;
}
static bool k3menuitem_event_callback(struct k3MEvent *ev, uint8_t *ud_) {
void **ud = ud_;
@ -2223,8 +2212,6 @@ static int dagame_k3menuitem_get(lua_State *L) {
lua_pushcfunction(L, dagame_k3menuitem_set_bounds);
} else if(!strcmp(lua_tostring(L, 2), "add_child")) {
lua_pushcfunction(L, dagame_k3menuitem_add_child);
} else if(!strcmp(lua_tostring(L, 2), "remove_child")) {
lua_pushcfunction(L, dagame_k3menuitem_remove_child);
} else if(!strcmp(lua_tostring(L, 2), "on")) {
lua_pushcfunction(L, dagame_k3menuitem_on);
} else if(!strcmp(lua_tostring(L, 2), "measure")) {
@ -3381,17 +3368,13 @@ void luaapi_init() {
k3Log(k3_DEBUG, "Loading Lua stdlib");
size_t numpkgs = 0;
numpkgs++, luaL_requiref(L, "_G", luaopen_base, 1);
numpkgs++, luaL_requiref(L, LUA_TABLIBNAME, luaopen_table, 1);
numpkgs++, luaL_requiref(L, LUA_STRLIBNAME, luaopen_string, 1);
numpkgs++, luaL_requiref(L, LUA_MATHLIBNAME, luaopen_math, 1);
numpkgs++, luaL_requiref(L, LUA_DBLIBNAME, luaopen_debug, 1);
numpkgs++, luaL_requiref(L, LUA_UTF8LIBNAME, luaopen_utf8, 1);
#ifdef LUAAPI_EXPOSE_PACKAGE_LIB
numpkgs++, luaL_requiref(L, "package", luaopen_package, 1);
#endif
lua_pop(L, numpkgs);
luaL_requiref(L, "_G", luaopen_base, 1);
luaL_requiref(L, LUA_TABLIBNAME, luaopen_table, 1);
luaL_requiref(L, LUA_STRLIBNAME, luaopen_string, 1);
luaL_requiref(L, LUA_MATHLIBNAME, luaopen_math, 1);
luaL_requiref(L, LUA_DBLIBNAME, luaopen_debug, 1);
luaL_requiref(L, LUA_UTF8LIBNAME, luaopen_utf8, 1);
lua_pop(L, 6);
k3Log(k3_DEBUG, "Setting custom require");
@ -4392,11 +4375,7 @@ void luaapi_fillmaterial_direct(struct k3Mat *mat) {
lua_pop(L, 1);
lua_getfield(L, -1, "alphatest");
if(lua_type(L, -1) == LUA_TBOOLEAN) {
mat->passes[0].alphatest = lua_toboolean(L, -1);
} else {
mat->passes[0].alphatest = lua_tonumber(L, -1);
}
lua_pop(L, 1);
lua_getfield(L, -1, "depthwrite");

View File

@ -28,7 +28,6 @@
#include"k3font.h"
#include"k3menu.h"
#include"k3bloom.h"
#include"k3batch.h"
#include"resman.h"
@ -38,7 +37,6 @@
#include"net_server.h"
#include"net_client.h"
#include"net_hi.h"
#include<ctype.h>
@ -62,7 +60,7 @@ static double LastTime;
#include"loaders.inc"
void k4_set_ui_mode(bool yes) {
void set_ui_mode(int yes) {
glfwSetInputMode(GameWnd, GLFW_CURSOR, yes ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED);
}
@ -132,7 +130,7 @@ static void motioncallback(GLFWwindow *GameWnd, double xpos, double ypos) {
static void keycallback(GLFWwindow *GameWnd, int key, int scancode, int action, int mods) {
if(action == GLFW_RELEASE && key == GLFW_KEY_ESCAPE) {
luaapi_escape();
k4_set_ui_mode(!!UiActive);
set_ui_mode(!!UiActive);
} else {
if(UiActive) {
struct k3MEvent ev = {
@ -207,7 +205,7 @@ void k4k3LogCallback(enum k3LogLevel lvl, const char *str, size_t len) {
//if(lvl == k3_ERR) raise(SIGINT);
fprintf(stdout, "%s : %s\n", prefixes[lvl], str);
fprintf(stderr, "%s : %s\n", prefixes[lvl], str);
}
struct k4Control {
@ -322,7 +320,7 @@ static void fix_resol() {
}
static void eng_ui_init() {
k4_set_ui_mode(!!UiActive);
set_ui_mode(!!UiActive);
}
static void fps_counter_step(double newDT) {
@ -625,7 +623,7 @@ int main(int argc_, char **argv_) {
}
if(!IrregularShadows) {
k3PassShadowmap(proj, cam, shadowmapOffscreen, 8);
k3PassShadowmap(proj, cam, shadowmapOffscreen, fmaxf(k3TexSzMax() / 8, 512));
}
if(lowresOffscreen) {