mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Lunatic translator: qgetsysstr.
git-svn-id: https://svn.eduke32.com/eduke32@3512 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
db2c24b7ef
commit
e6fd95dde8
5 changed files with 76 additions and 3 deletions
|
@ -615,6 +615,46 @@ function _getkeyname(qdst, gfuncnum, which)
|
|||
end
|
||||
end
|
||||
|
||||
local EDUKE32_VERSION_STR = "EDuke32 2.0.0devel "..ffi.string(ffiC.s_buildRev)
|
||||
|
||||
local function quote_strcpy(dst, src)
|
||||
local i=-1
|
||||
repeat
|
||||
i = i+1
|
||||
dst[i] = src[i]
|
||||
until (src[i]==0 or i==MAXQUOTELEN-1)
|
||||
dst[i] = 0
|
||||
end
|
||||
|
||||
function _qgetsysstr(qdst, what, pli)
|
||||
local dst = bcheck.quote_idx(qdst)
|
||||
|
||||
local idx = ffiC.ud.volume_number*con_lang.MAXLEVELS + ffiC.ud.level_number
|
||||
local MAXIDX = ffi.sizeof(ffiC.MapInfo) / ffi.sizeof(ffiC.MapInfo[0])
|
||||
|
||||
if (what == ffiC.STR_MAPNAME) then
|
||||
assert(not (idx >= MAXIDX+0ULL))
|
||||
local src = ffiC.MapInfo[idx].name
|
||||
assert(src ~= nil)
|
||||
quote_strcpy(dst, src)
|
||||
elseif (what == ffiC.STR_MAPFILENAME) then
|
||||
assert(not (idx >= MAXIDX+0ULL))
|
||||
local src = ffiC.MapInfo[idx].filename
|
||||
assert(src ~= nil)
|
||||
quote_strcpy(dst, src)
|
||||
elseif (what == ffiC.STR_PLAYERNAME) then
|
||||
ffi.copy(dst, ffiC.g_player[pli].user_name, ffi.sizeof(ffiC.g_player[0].user_name))
|
||||
elseif (what == ffiC.STR_VERSION) then
|
||||
ffi.copy(dst, EDUKE32_VERSION_STR)
|
||||
elseif (what == ffiC.STR_GAMETYPE) then
|
||||
ffi.copy(dst, "multiplayer not yet implemented") -- TODO_MP
|
||||
elseif (what == ffiC.STR_VOLUMENAME) then
|
||||
ffi.copy(dst, "STR_VOLUMENAME: NYI")
|
||||
else
|
||||
error("unknown system string ID "..what, 2)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- text rendering
|
||||
function _minitext(x, y, qnum, shade, pal)
|
||||
|
|
|
@ -37,7 +37,7 @@ local gv_access = {}
|
|||
-- Notes: do not declare multiple pointers on one line (this is bad:
|
||||
-- "int32_t *a, *b"). Do not name array arguments (or add a space
|
||||
-- between the identifier and the '[' instead).
|
||||
function decl(str)
|
||||
function decl(str, ...)
|
||||
-- NOTE that the regexp also catches non-array/non-function identifiers
|
||||
-- like "user_defs ud;"
|
||||
for varname in string.gmatch(str, "([%a_][%w_]*)[[(;]") do
|
||||
|
@ -47,7 +47,7 @@ function decl(str)
|
|||
gv_access[varname] = true
|
||||
end
|
||||
|
||||
ffi.cdef(str)
|
||||
ffi.cdef(str, ...)
|
||||
end
|
||||
|
||||
-- Load the definitions common to the game's and editor's Lua interface.
|
||||
|
@ -473,6 +473,12 @@ typedef struct {
|
|||
char display_bonus_screen;
|
||||
char show_level_text;
|
||||
} user_defs;
|
||||
|
||||
typedef struct {
|
||||
int32_t partime, designertime;
|
||||
char *name, *filename, *musicfn, *alt_musicfn;
|
||||
void *savedstate;
|
||||
} map_t;
|
||||
]])
|
||||
|
||||
-- EXTERNALLY EXPOSED GAME VARIABLES
|
||||
|
@ -482,7 +488,10 @@ hudweapon_t hudweap;
|
|||
]]
|
||||
|
||||
-- INTERNAL VARIABLES/FUNCTIONS
|
||||
decl("map_t MapInfo[($+1)*$];", con_lang.MAXVOLUMES, con_lang.MAXLEVELS)
|
||||
|
||||
decl[[
|
||||
const char *s_buildRev;
|
||||
const char *g_sizes_of_what[];
|
||||
int32_t g_sizes_of[];
|
||||
int32_t g_elCallDepth;
|
||||
|
|
|
@ -68,6 +68,7 @@ luaJIT_BC_defs_common;
|
|||
|
||||
|
||||
|
||||
s_buildRev;
|
||||
g_sizes_of_what;
|
||||
g_sizes_of;
|
||||
g_elCallDepth;
|
||||
|
|
|
@ -1760,7 +1760,7 @@ local Cinner = {
|
|||
qsprintf = sp1 * tok.rvar * sp1 * tok.rvar * (sp1 * tok.rvar)^-32
|
||||
/ handle.qsprintf,
|
||||
qgetsysstr = cmd(R,R)
|
||||
/ handle.NYI,
|
||||
/ "_con._qgetsysstr(%1,%2,_pli)",
|
||||
qstrcat = cmd(R,R)
|
||||
/ "_con._qstrcat(%1,%2)",
|
||||
qstrcpy = cmd(R,R)
|
||||
|
|
|
@ -6,6 +6,14 @@ gamevar n -12345678 0 // a number having length 9 in the decimal representation
|
|||
// overlong string at definition (should warn)
|
||||
definequote 400 123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789=123456789-
|
||||
|
||||
// alloc some quotes, test empty quote syntax
|
||||
definequote 401
|
||||
definequote 402
|
||||
definequote 403
|
||||
definequote 404
|
||||
definequote 405
|
||||
definequote 406
|
||||
|
||||
onevent EVENT_ENTERLEVEL
|
||||
redefinequote 114 QWE
|
||||
|
||||
|
@ -63,4 +71,19 @@ onevent EVENT_ENTERLEVEL
|
|||
redefinequote 117 123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789=123456789-
|
||||
userquote 117 // should end in "=1234567" (= total length 127 = MAXQUOTELEN-1)
|
||||
userquote 400 // same thing
|
||||
|
||||
// test passing empty quote
|
||||
userquote 401
|
||||
|
||||
// qgetsysstr test
|
||||
qgetsysstr 401 STR_MAPNAME
|
||||
qgetsysstr 402 STR_MAPFILENAME
|
||||
qgetsysstr 403 STR_PLAYERNAME
|
||||
qgetsysstr 404 STR_VERSION
|
||||
qgetsysstr 405 STR_GAMETYPE
|
||||
qgetsysstr 406 STR_VOLUMENAME
|
||||
|
||||
redefinequote 400 %s | %s | %s | %s | %s | %s
|
||||
qsprintf 400 /*<-*/ 400 /*args:*/ 401 402 403 404 405 406
|
||||
userquote 400
|
||||
endevent
|
||||
|
|
Loading…
Reference in a new issue