mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Mapster32/Lunatic: hook up shadexfog.save() and saveLookupDat() to [;]+[F] menu.
git-svn-id: https://svn.eduke32.com/eduke32@4420 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
494c00713b
commit
5fd9d1d7a9
3 changed files with 66 additions and 9 deletions
|
@ -110,6 +110,7 @@ g_argv;
|
|||
|
||||
|
||||
_getnumber16;
|
||||
getstring_simple;
|
||||
listsearchpath;
|
||||
LM_Register;
|
||||
LM_Clear;
|
||||
|
|
|
@ -31,6 +31,7 @@ int32_t setpalookup(int32_t palnum, const uint8_t *shtab);
|
|||
if (ismapster32) then
|
||||
ffi.cdef[[
|
||||
int32_t _getnumber16(const char *namestart, int32_t num, int32_t maxnumber, char sign, const char *(func)(int32_t));
|
||||
const char *getstring_simple(const char *querystr, const char *defaultstr, int32_t maxlen, int32_t completion);
|
||||
|
||||
typedef const char *(*luamenufunc_t)(void);
|
||||
void LM_Register(const char *name, luamenufunc_t funcptr);
|
||||
|
@ -298,7 +299,7 @@ if (ismapster32) then
|
|||
return blendnumtab, blendptrtab
|
||||
end
|
||||
|
||||
-- ok, errmsg = engine.savePaletteDat(filename [, palnum [, blendnum [, moreblends]]])
|
||||
-- ok, errmsg, nummoreblends = engine.savePaletteDat(filename [, palnum [, blendnum [, moreblends]]])
|
||||
function engine.savePaletteDat(filename, palnum, blendnum, moreblends)
|
||||
local sht = engine.getshadetab(palnum or 0)
|
||||
local tab = engine.getblendtab(blendnum or 0)
|
||||
|
@ -340,7 +341,7 @@ if (ismapster32) then
|
|||
|
||||
f:close()
|
||||
|
||||
return true
|
||||
return true, nil, (blendnumtab ~= nil) and #blendnumtab or 0
|
||||
end
|
||||
|
||||
-- ok, errmsg = engine.saveLookupDat(filename, lookups)
|
||||
|
@ -474,7 +475,15 @@ if (ismapster32) then
|
|||
error("invalid argument #1: must be a string", 2)
|
||||
end
|
||||
|
||||
return C._getnumber16(namestart, num, maxnumber, flags, nil)
|
||||
return C._getnumber16(namestart, num, maxnumber, flags or 8, nil) -- RET_M1_ON_CANCEL
|
||||
end
|
||||
|
||||
function engine.getstring(querystr)
|
||||
if (type(querystr) ~= "string") then
|
||||
error("invalid argument #2: must be a string", 2)
|
||||
end
|
||||
local cstr = C.getstring_simple(querystr, nil, 0, 0)
|
||||
return cstr~=nil and ffi.string(cstr) or nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -268,14 +268,14 @@ end
|
|||
if (gv.LUNATIC_CLIENT == gv.LUNATIC_CLIENT_MAPSTER32) then
|
||||
-- Wrapper around engine.savePaletteDat() that errors on unexpected events.
|
||||
function shadexfog.save(filename, palnum, blendnum, moreblends)
|
||||
local ok, errmsg = engine.savePaletteDat(filename, palnum, blendnum, moreblends)
|
||||
local ok, errmsg, nummoreblends = engine.savePaletteDat(filename, palnum, blendnum, moreblends)
|
||||
if (not ok) then
|
||||
error(errmsg)
|
||||
end
|
||||
|
||||
printf('Wrote base palette, shade and translucency tables to "%s".', filename)
|
||||
if (moreblends ~= nil) then
|
||||
printf(" Also wrote additional translucency tables.")
|
||||
if (nummoreblends > 0) then
|
||||
printf(" Also wrote %d additional translucency tables.", nummoreblends)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -525,14 +525,14 @@ engine.registerMenuFunc(
|
|||
engine.registerMenuFunc(
|
||||
"Create c.index remapping",
|
||||
function()
|
||||
local palnum = getnumber16("Pal number: ", 100, MAXUSERPALOOKUP, df)
|
||||
local palnum = getnumber16("Pal number: ", 100, MAXUSERPALOOKUP)
|
||||
if (palnum < 0) then return end
|
||||
|
||||
local remaptab = {}
|
||||
while (true) do
|
||||
local srchex = getnumber16("Source hexadecatuple (0: finish): ", 0, 14, df)
|
||||
local srchex = getnumber16("Source hexadecatuple (0: finish): ", 0, 14)
|
||||
if (srchex < 0) then return end
|
||||
local dsthex = getnumber16("Destn. hexadecatuple (0: finish): ", 0, 14, df)
|
||||
local dsthex = getnumber16("Destn. hexadecatuple (0: finish): ", 0, 14)
|
||||
if (dsthex < 0) then return end
|
||||
|
||||
if (srchex == 0 and dsthex == 0) then
|
||||
|
@ -546,6 +546,53 @@ engine.registerMenuFunc(
|
|||
end
|
||||
)
|
||||
|
||||
engine.registerMenuFunc(
|
||||
"Save pal+sh+trans DAT f.",
|
||||
function()
|
||||
local filename = engine.getstring("File name: ")
|
||||
if (filename == nil) then return end
|
||||
|
||||
local palnum = getnumber16("Pal number of base shade table: ", 0, MAXUSERPALOOKUP)
|
||||
if (palnum < 0) then return end
|
||||
local blendnum = getnumber16("Blendnum of base transluc. table: ", 0, 255)
|
||||
if (blendnum < 0) then return end
|
||||
|
||||
local str = engine.getstring("Additional blend numbers (e.g. '64,100-131,255'): ")
|
||||
if (str == nil or str=="") then return end
|
||||
|
||||
if (not str:find("^[%d,%-]+$")) then
|
||||
error("Additional blending numbers string must contain only digits or ',' or '-'", 2)
|
||||
end
|
||||
|
||||
local moreblends = {}
|
||||
local didnumstr = {}
|
||||
|
||||
for n1, n2 in str:gmatch("(%d+)%-(%d+)") do -- parse number ranges
|
||||
moreblends[#moreblends+1] = { tonumber(n1), tonumber(n2) }
|
||||
didnumstr[n1] = true
|
||||
didnumstr[n2] = true
|
||||
end
|
||||
|
||||
for n in str:gmatch("%d+") do -- parse single numbers
|
||||
if (not didnumstr[n]) then
|
||||
moreblends[#moreblends+1] = tonumber(n)
|
||||
end
|
||||
end
|
||||
|
||||
shadexfog.save(filename, palnum, blendnum, moreblends)
|
||||
end
|
||||
)
|
||||
|
||||
engine.registerMenuFunc(
|
||||
"Save lookups DAT file",
|
||||
function()
|
||||
local filename = engine.getstring("File name: ")
|
||||
if (filename ~= nil and filename ~= "") then
|
||||
shadexfog.saveLookupDat(filename)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
engine.registerMenuFunc("_________DEBUG_________", function() end)
|
||||
engine.registerMenuFunc("Setup dbg. water basepal", engine.setupDebugBasePal)
|
||||
engine.registerMenuFunc("Linearize default basep.", engine.linearizeBasePal)
|
||||
|
|
Loading…
Reference in a new issue