mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +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;
|
_getnumber16;
|
||||||
|
getstring_simple;
|
||||||
listsearchpath;
|
listsearchpath;
|
||||||
LM_Register;
|
LM_Register;
|
||||||
LM_Clear;
|
LM_Clear;
|
||||||
|
|
|
@ -31,6 +31,7 @@ int32_t setpalookup(int32_t palnum, const uint8_t *shtab);
|
||||||
if (ismapster32) then
|
if (ismapster32) then
|
||||||
ffi.cdef[[
|
ffi.cdef[[
|
||||||
int32_t _getnumber16(const char *namestart, int32_t num, int32_t maxnumber, char sign, const char *(func)(int32_t));
|
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);
|
typedef const char *(*luamenufunc_t)(void);
|
||||||
void LM_Register(const char *name, luamenufunc_t funcptr);
|
void LM_Register(const char *name, luamenufunc_t funcptr);
|
||||||
|
@ -298,7 +299,7 @@ if (ismapster32) then
|
||||||
return blendnumtab, blendptrtab
|
return blendnumtab, blendptrtab
|
||||||
end
|
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)
|
function engine.savePaletteDat(filename, palnum, blendnum, moreblends)
|
||||||
local sht = engine.getshadetab(palnum or 0)
|
local sht = engine.getshadetab(palnum or 0)
|
||||||
local tab = engine.getblendtab(blendnum or 0)
|
local tab = engine.getblendtab(blendnum or 0)
|
||||||
|
@ -340,7 +341,7 @@ if (ismapster32) then
|
||||||
|
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
return true
|
return true, nil, (blendnumtab ~= nil) and #blendnumtab or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ok, errmsg = engine.saveLookupDat(filename, lookups)
|
-- ok, errmsg = engine.saveLookupDat(filename, lookups)
|
||||||
|
@ -474,7 +475,15 @@ if (ismapster32) then
|
||||||
error("invalid argument #1: must be a string", 2)
|
error("invalid argument #1: must be a string", 2)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -268,14 +268,14 @@ end
|
||||||
if (gv.LUNATIC_CLIENT == gv.LUNATIC_CLIENT_MAPSTER32) then
|
if (gv.LUNATIC_CLIENT == gv.LUNATIC_CLIENT_MAPSTER32) then
|
||||||
-- Wrapper around engine.savePaletteDat() that errors on unexpected events.
|
-- Wrapper around engine.savePaletteDat() that errors on unexpected events.
|
||||||
function shadexfog.save(filename, palnum, blendnum, moreblends)
|
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
|
if (not ok) then
|
||||||
error(errmsg)
|
error(errmsg)
|
||||||
end
|
end
|
||||||
|
|
||||||
printf('Wrote base palette, shade and translucency tables to "%s".', filename)
|
printf('Wrote base palette, shade and translucency tables to "%s".', filename)
|
||||||
if (moreblends ~= nil) then
|
if (nummoreblends > 0) then
|
||||||
printf(" Also wrote additional translucency tables.")
|
printf(" Also wrote %d additional translucency tables.", nummoreblends)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -525,14 +525,14 @@ engine.registerMenuFunc(
|
||||||
engine.registerMenuFunc(
|
engine.registerMenuFunc(
|
||||||
"Create c.index remapping",
|
"Create c.index remapping",
|
||||||
function()
|
function()
|
||||||
local palnum = getnumber16("Pal number: ", 100, MAXUSERPALOOKUP, df)
|
local palnum = getnumber16("Pal number: ", 100, MAXUSERPALOOKUP)
|
||||||
if (palnum < 0) then return end
|
if (palnum < 0) then return end
|
||||||
|
|
||||||
local remaptab = {}
|
local remaptab = {}
|
||||||
while (true) do
|
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
|
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 (dsthex < 0) then return end
|
||||||
|
|
||||||
if (srchex == 0 and dsthex == 0) then
|
if (srchex == 0 and dsthex == 0) then
|
||||||
|
@ -546,6 +546,53 @@ engine.registerMenuFunc(
|
||||||
end
|
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("_________DEBUG_________", function() end)
|
||||||
engine.registerMenuFunc("Setup dbg. water basepal", engine.setupDebugBasePal)
|
engine.registerMenuFunc("Setup dbg. water basepal", engine.setupDebugBasePal)
|
||||||
engine.registerMenuFunc("Linearize default basep.", engine.linearizeBasePal)
|
engine.registerMenuFunc("Linearize default basep.", engine.linearizeBasePal)
|
||||||
|
|
Loading…
Reference in a new issue