Skip to content

Commit

Permalink
Added: Alt + E Closes frequent pieces in the client think
Browse files Browse the repository at this point in the history
Changed: Alt is now used for selecting points instead of E
  • Loading branch information
dvdvideo1234 committed Aug 30, 2016
1 parent 63d0d6f commit ef2a393
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
15 changes: 4 additions & 11 deletions lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ local asmlib = trackasmlib

------ CONFIGURE ASMLIB ------
asmlib.Init("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","5.292")
asmlib.SetOpVar("TOOL_VERSION","5.293")
asmlib.SetIndexes("V",1,2,3)
asmlib.SetIndexes("A",1,2,3)
asmlib.SetIndexes("S",4,5,6,7)
Expand Down Expand Up @@ -113,21 +113,14 @@ if(CLIENT) then
if(actSwep:GetClass() ~= "gmod_tool") then return asmlib.StatusLog(nil,"BIND_PRESS: Swep not tool") end
if(actSwep:GetMode() ~= gsToolNameL) then return asmlib.StatusLog(nil,"BIND_PRESS: Tool different") end
-- Here player is holding the track assembly tool
if(not inputIsKeyDown(KEY_LALT)) then return asmlib.StatusLog(nil,"BIND_PRESS: Active key missing") end
local actTool = actSwep:GetToolObject() -- Switch functionality of the mouse wheel only for TA
if(not actTool) then return asmlib.StatusLog(nil,"BIND_PRESS: Tool invalid") end
if((sBind == "invnext") or (sBind == "invprev")) then -- Process the scroll events here
if(not actTool:GetScrollMouse()) then return asmlib.StatusLog(nil,"BIND_PRESS(Scroll): Scrolling disabled") end
if(not inputIsKeyDown(KEY_E)) then return asmlib.StatusLog(nil,"BIND_PRESS(Scroll): Active key missing") end
local Dir = ((sBind == "invnext") and 1) or ((sBind == "invprev") and -1) or 0
actTool:SwitchPoint(Dir,inputIsKeyDown(KEY_LSHIFT))
return asmlib.StatusLog(true,"BIND_PRESS("..sBind.."): Processed")
if(sBind == "alt") then -- Shortcut to close the frequent models panel
if(not inputIsKeyDown(KEY_Q)) then return asmlib.StatusLog(nil,"BIND_PRESS(Close): Active key missing") end
local actFrame = asmlib.GetOpVar("PANEL_FREQUENT_MODELS")
if(not asmlib.IsExistent(actFrame)) then return asmlib.StatusLog(nil,"BIND_PRESS(Close): Frame missing") end
if(not IsValid(actFrame)) then return asmlib.StatusLog(nil,"BIND_PRESS(Close): Frame not valid") end
actFrame.OnClose() -- Removing the frame is the same like pressing close
return asmlib.StatusLog(true,"BIND_PRESS("..sBind.."): Processed")
end -- Override only for TA and skip touching anything else
return asmlib.StatusLog(nil,"BIND_PRESS("..sBind.."): Skipped")
end) -- Read client configuration
Expand Down Expand Up @@ -222,7 +215,7 @@ if(CLIENT) then
local pnElements = asmlib.MakeContainer("FREQ_VGUI")
pnElements:Insert(1,{Label = { "DButton" ,"Export DB" ,"Click to export the client database as a file"}})
pnElements:Insert(2,{Label = { "DListView" ,"Routine Items" ,"The list of your frequently used track pieces"}})
pnElements:Insert(3,{Label = { "DAdjustableModelPanel","Piece Display" ,"The model of your track piece is displayed here"}})
pnElements:Insert(3,{Label = { "DModelPanel","Piece Display" ,"The model of your track piece is displayed here"}})
pnElements:Insert(4,{Label = { "DTextEntry" ,"Enter Pattern" ,"Enter a pattern here and hit enter to preform a search"}})
pnElements:Insert(5,{Label = { "DComboBox" ,"Select Column" ,"Choose which list column you want to preform a search on"}})
------------ Manage the invalid panels -------------------
Expand Down Expand Up @@ -281,7 +274,7 @@ if(CLIENT) then
pnElements:Delete(iNdex)
iNdex = iNdex + 1
end
pnFrame:Remove(); collectgarbage()
pnFrame:Remove(); asmlib.SetOpVar("PANEL_FREQUENT_MODELS",nil); collectgarbage()
asmlib.LogInstance("OPEN_FRAME: Frame.OnClose: Form removed")
end; asmlib.SetOpVar("PANEL_FREQUENT_MODELS",pnFrame)
------------ Button --------------
Expand Down
34 changes: 23 additions & 11 deletions lua/weapons/gmod_tool/stools/trackassembly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local mathClamp = math and math.Clamp
local fileExists = file and file.Exists
local hookAdd = hook and hook.Add
local tableGetKeys = table and table.GetKeys
local inputIsKeyDown = input and input.IsKeyDown
local stringLen = string and string.len
local stringRep = string and string.rep
local stringSub = string and string.sub
Expand Down Expand Up @@ -280,6 +281,7 @@ function TOOL:GetScrollMouse()
end

function TOOL:SwitchPoint(nDir,bIsNext)
local Dir = (tonumber(nDir) or 0)
local Rec = asmlib.CacheQueryPiece(self:GetModel())
local pointid, pnextid = self:GetPointID()
local pointbu = pointid -- Create backup
Expand Down Expand Up @@ -1161,18 +1163,28 @@ function TOOL:UpdateGhost(oEnt, oPly)
end

function TOOL:Think()
local model = self:GetModel()
if(self:GetGhostHolder() and utilIsValidModel(model)) then
if (not self.GhostEntity or -- Ghost irrelevant
not self.GhostEntity:IsValid() or
self.GhostEntity:GetModel() ~= model) then
self:MakeGhostEntity(model,VEC_ZERO,ANG_ZERO)
local model = self:GetModel() -- Ghost irrelevant
if(utilIsValidModel(model)) then
if(self:GetGhostHolder()) then
if (not (self.GhostEntity and
self.GhostEntity:IsValid() and
self.GhostEntity:GetModel() == model)) then
self:MakeGhostEntity(model,VEC_ZERO,ANG_ZERO)
end
self:UpdateGhost(self.GhostEntity, self:GetOwner())
else
self:ReleaseGhostEntity()
if(self.GhostEntity and self.GhostEntity:IsValid()) then
self.GhostEntity:Remove()
end
end
self:UpdateGhost(self.GhostEntity, self:GetOwner())
else
self:ReleaseGhostEntity()
if(self.GhostEntity and self.GhostEntity:IsValid()) then
self.GhostEntity:Remove()
if(CLIENT and inputIsKeyDown(KEY_LALT)) then
if(inputIsKeyDown(KEY_E)) then
local pnFrame = asmlib.GetOpVar("PANEL_FREQUENT_MODELS")
if(pnFrame and IsValid(pnFrame)) then
pnFrame.OnClose()
end
end
end
end
end

0 comments on commit ef2a393

Please sign in to comment.