Added: Struct spawn automatic size fill-ups

Changed: Strict spawn debug mode is drawn on the left
This commit is contained in:
Deyan Dobromirov 2019-05-25 21:50:05 +03:00
parent 17bd6c9f0c
commit c9174b59e7
3 changed files with 23 additions and 17 deletions

View File

@ -49,7 +49,7 @@ local gtInitLogs = {"*Init", false, 0}
------ CONFIGURE ASMLIB ------
asmlib.InitBase("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","6.530")
asmlib.SetOpVar("TOOL_VERSION","6.531")
asmlib.SetIndexes("V" , "x", "y", "z")
asmlib.SetIndexes("A" ,"pitch","yaw","roll")
asmlib.SetIndexes("WV",1,2,3)
@ -152,11 +152,12 @@ local conWorkMode = asmlib.MakeContainer("WorkMode"); asmlib.SetOpVar("CONTAINER
-------- RECORDS ----------
asmlib.SetOpVar("STRUCT_SPAWN",{
Name = "Spawn data definition", Size = 4,
Name = "Spawn data definition",
Draw = {"%+6s",
["REC"] = function(scr, key, typ, inf, def, spn)
["TAB"] = function(scr, key, typ, inf, def, spn)
local fmt = asmlib.GetOpVar("FORM_DRAWDBG")
local out = tostring(spn[key] or ""):sub(8, -1)
local nav = asmlib.GetOpVar("MISS_NOAV")
local out = (spn[key] and tostring(spn[key]):sub(8, -1) or nav)
local fky = tostring(def.Draw[1] or "%s")
scr:DrawText(fmt:format(fky:format(key), typ, out, inf))
end,
@ -170,7 +171,7 @@ asmlib.SetOpVar("STRUCT_SPAWN",{
end
end,
},
{Name = "Origin", Size = 11,
{Name = "Origin",
{"F" , "VEC", "Origin forward vector"},
{"R" , "VEC", "Origin right vector"},
{"U" , "VEC", "Origin up vector"},
@ -183,23 +184,23 @@ asmlib.SetOpVar("STRUCT_SPAWN",{
{"SMtx", "MTX", "Spawn translation and rotation matrix"},
{"RLen", "NUM", "Piece active radius"}
},
{Name = "Holder", Size = 6,
{"HRec", "REC", "Pointer to the holder record"},
{Name = "Holder",
{"HRec", "TAB", "Pointer to the holder record"},
{"HID" , "NUM", "Point ID the holder has selected"},
{"HPnt", "VEC", "P # Holder active point location"},
{"HOrg", "VEC", "O # Holder piece location origin when snapped"},
{"HAng", "ANG", "A # Holder piece orientation origin when snapped"},
{"HMtx", "MTX", "Holder translation and rotation matrix"}
},
{Name = "Traced", Size = 6,
{"TRec", "REC", "Pointer to the trace record"},
{Name = "Traced",
{"TRec", "TAB", "Pointer to the trace record"},
{"TID" , "NUM", "Point ID that the trace has found"},
{"TPnt", "VEC", "P # Trace active point location"},
{"TOrg", "VEC", "O # Trace piece location origin when snapped"},
{"TAng", "ANG", "A # Trace piece orientation origin when snapped"},
{"TMtx", "MTX", "Trace translation and rotation matrix"}
},
{Name = "Offsets", Size = 2,
{Name = "Offsets",
{"ANxt", "ANG", "Origin angle offsets"},
{"PNxt", "VEC", "Piece position offsets"}
}

View File

@ -1373,7 +1373,7 @@ function SnapReview(ivPoID, ivPnID, ivMaxN)
return iPoID, iPnID
end
function SwitchID(vID,vDir,oRec)
function SwitchID(vID,vDir,oRec)
local stPOA, ID = LocatePOA(oRec,vID); if(not IsHere(stPOA)) then
LogInstance("ID #"..GetReport(vID).." not located"); return 1 end
local nDir = (tonumber(vDir) or 0); nDir = (((nDir > 0) and 1) or ((nDir < 0) and -1) or 0)
@ -1709,16 +1709,22 @@ function GetCacheSpawn(pPly)
LogInstance("Spawn definition invalid"); return false end
LogInstance("Allocate <"..pPly:Nick()..">")
stSpot["SPAWN"] = {}; stData = stSpot["SPAWN"]
for iD = 1, stSpawn.Size do local tSec = stSpawn[iD]
for iK = 1, tSec.Size do local def = tSec[iK]
local iD = 1; stSpawn.Size = 0 -- Initialize length
while(stSpawn[iD]) do stSpawn.Size = iD
local tSec, iK = stSpawn[iD], 1
while(tSec[iK]) do tSec.Size = iK
local def = tSec[iK]
local key = tostring(def[1] or "")
local typ = tostring(def[2] or "")
local inf = tostring(def[3] or "")
if (typ == "VEC") then stData[key] = Vector()
elseif(typ == "ANG") then stData[key] = Angle()
elseif(typ == "MTX") then stData[key] = Matrix()
else stData[key] = 0 end -- Default non-nil
end
elseif(typ == "TAB") then stData[key] = nil
elseif(typ == "NUM") then stData[key] = 0
else LogInstance("Spawn skip <"..typ..">")
end; iK = iK + 1 -- Update members count
end; iD = iD + 1 -- Update categories count
end
end; return stData
end

View File

@ -901,11 +901,10 @@ end
]]--
function TOOL:DrawTextSpawn(oScreen, sCol, sMeth, tArgs)
local ply = LocalPlayer()
local gnR = asmlib.GetOpVar("GOLDEN_RATIO")
local stS = asmlib.GetCacheSpawn(ply)
local arK = asmlib.GetOpVar("STRUCT_SPAWN")
local w,h = oScreen:GetSize()
oScreen:SetTextEdge(w - (2 - gnR)*w,0)
oScreen:SetTextEdge(0,230)
oScreen:DrawText(tostring(arK.Name),sCol,sMeth,tArgs)
for iD = 1, arK.Size, 1 do local def = arK[iD]
oScreen:DrawText("---- "..tostring(def.Name).." ----")