Skip to content

Commit

Permalink
Create automatic BAS for setting the slider to various degrees
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdvideo1234 committed Nov 14, 2023
1 parent 0dca743 commit 0bbe745
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 28 deletions.
2 changes: 1 addition & 1 deletion lua/autorun/trackassembly_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present
------------ CONFIGURE ASMLIB ------------

asmlib.InitBase("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","8.738")
asmlib.SetOpVar("TOOL_VERSION","8.739")
asmlib.SetIndexes("V" ,1,2,3)
asmlib.SetIndexes("A" ,1,2,3)
asmlib.SetIndexes("WV",1,2,3)
Expand Down
12 changes: 12 additions & 0 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,18 @@ function SetButtonSlider(cPanel, sVar, nMin, nMax, nDec, tBtn)
sTip = tostring(vBtn.T):Trim()
end
end
if(sTxt:sub(1,1) = syRev and tonumber(sTxt:sub(2,-1))) then
local nAmt = tonumber(sTxt:sub(2,-1))
if(not vBtn.L) then
vBtn.L=function(pB, pS, nS)
pS:SetValue(GetSign((nS < 0) and nS or (nS+1))*nAmt) end
end
if(not vBtn.R) then
vBtn.R=function(pB, pS, nS)
pS:SetValue(-GetSign((nS < 0) and nS or (nS+1))*nAmt) end
end
sTip = languageGetPhrase("tool."..sTool..".buttonas"..syRev).." "..nAmt
end
pPanel:SetButton(sTxt, sTip)
pPanel:SetAction(vBtn.L, vBtn.R)
end
Expand Down
16 changes: 12 additions & 4 deletions lua/vgui/dasminsliderbutton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,25 @@ function PANEL:SetAction(fLef, fRgh, vIdx)
local iIdx = self:GetButtonID(vIdx)
if(iIdx == 0) then return self end
local pBut, pSer = self.Array[iIdx], self.Slider
pBut.DoClick = function()
local pS, sE = pcall(fLef, pBut, pSer, pSer:GetValue())
if(not pS) then error("["..pBut:GetText().."]: "..sE) end
if(fLef) then
pBut.DoClick = function()
local pS, sE = pcall(fLef, pBut, pSer, pSer:GetValue())
if(not pS) then error("["..pBut:GetText().."]: "..sE) end
end
else
if(not pBut.DoClick) then
pBut.DoClick = function() SetClipboardText(pBut:GetText()) end
end
end
if(fRgh) then
pBut.DoRightClick = function()
local pS, sE = pcall(fRgh, pBut, pSer, pSer:GetValue())
if(not pS) then error("["..pBut:GetText().."]: "..sE) end
end
else
pBut.DoRightClick = function() SetClipboardText(pBut:GetText()) end
if(not pBut.DoRightClick) then
pBut.DoRightClick = function() SetClipboardText(pBut:GetText()) end
end
end; return self
end

Expand Down
24 changes: 13 additions & 11 deletions lua/weapons/gmod_tool/stools/trackassembly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2466,20 +2466,22 @@ function TOOL.BuildCPanel(CPanel)
L=function(pB, pS, nS) pS:SetValue(asmlib.GetSnap(nS,-asmlib.GetAsmConvar("incsnpang","FLT"))) end,
R=function(pB, pS, nS) pS:SetValue(asmlib.GetSnap(nS, asmlib.GetAsmConvar("incsnpang","FLT"))) end},
{N="+/-" , T = "#", L=function(pB, pS, nS) pS:SetValue(-nS) end},
{N="@M" , T = "#", L=function(pB, pS, nS) SetClipboardText(nS) end},
{N="@D" , T = "#", L=function(pB, pS, nS) pS:SetValue(pS:GetDefaultValue()) end},
{N="@45" , T = "#", L=function(pB, pS, nS) pS:SetValue(asmlib.GetSign((nS < 0) and nS or (nS+1))* 45) end},
{N="@90" , T = "#", L=function(pB, pS, nS) pS:SetValue(asmlib.GetSign((nS < 0) and nS or (nS+1))* 90) end},
{N="@135", T = "#", L=function(pB, pS, nS) pS:SetValue(asmlib.GetSign((nS < 0) and nS or (nS+1))*135) end},
{N="@180", T = "#", L=function(pB, pS, nS) pS:SetValue(asmlib.GetSign((nS < 0) and nS or (nS+1))*180) end}
}
{N="@M" , T = "#", L=function(pB, pS, nS) SetClipboardText(nS) end,
R=function(pB, pS, nS) pS:SetValue(GetClipboardText(nS) end},
{N="@D" , T = "#", L=function(pB, pS, nS) pS:SetValue(pS:GetDefaultValue()) end
R=function(pB, pS, nS) SetClipboardText(pS:GetDefaultValue()) end},
{N="@45" , T = "#"}, {N="@90" , T = "#"}, {N="@135", T = "#"}, {N="@180", T = "#"}
} -- Use the same initialization table for multiple BIS
local tBpos = { -- Button interactive slider ( position offsets )
{N="<>" , T = "#", -- Left click to decrease, right to increase
{N="<>" , T = "#", -- Left click to decrease, right to increase
L=function(pB, pS, nS) pS:SetValue(asmlib.GetSnap(nS,-asmlib.GetAsmConvar("incsnplin","FLT"))) end,
R=function(pB, pS, nS) pS:SetValue(asmlib.GetSnap(nS, asmlib.GetAsmConvar("incsnplin","FLT"))) end},
{N="+/-", T = "#", L=function(pB, pS, nS) pS:SetValue(-nS) end},
{N="@M" , T = "#", L=function(pB, pS, nS) SetClipboardText(nS) end},
{N="@D" , T = "#", L=function(pB, pS, nS) pS:SetValue(pS:GetDefaultValue()) end}
{N="+/-" , T = "#", L=function(pB, pS, nS) pS:SetValue(-nS) end},
{N="@M" , T = "#", L=function(pB, pS, nS) SetClipboardText(nS) end,
R=function(pB, pS, nS) pS:SetValue(GetClipboardText(nS) end},
{N="@D" , T = "#", L=function(pB, pS, nS) pS:SetValue(pS:GetDefaultValue()) end
R=function(pB, pS, nS) SetClipboardText(pS:GetDefaultValue()) end},
{N="@25" , T = "#"}, {N="@50" , T = "#"}, {N="@75", T = "#"}, {N="@100", T = "#"}
} -- Use the same initialization table for multiple BIS
asmlib.SetButtonSlider(CPanel, "nextpic", -gnMaxRot, gnMaxRot, iMaxDec, tBAng)
asmlib.SetButtonSlider(CPanel, "nextyaw", -gnMaxRot, gnMaxRot, iMaxDec, tBAng)
Expand Down
5 changes: 1 addition & 4 deletions resource/localization/bg/trackassembly.properties
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,7 @@ tool.trackassembly.buttonas<>=Намали/Увеличи
tool.trackassembly.buttonas+/-=Обърни знака
tool.trackassembly.buttonas@M=Запомни стойност
tool.trackassembly.buttonas@D=Дефолтна стойност
tool.trackassembly.buttonas@45=Обнови 45
tool.trackassembly.buttonas@90=Обнови 90
tool.trackassembly.buttonas@135=Обнови 135
tool.trackassembly.buttonas@180=Обнови 180
tool.trackassembly.buttonas@=Обнови стойност\:
sbox_maxasmtracks=Променете тук за да настроите нещата които са създадени от инструмента на сървъра
sbox_maxasmtracks_con=Общо сегменти\:
Cleanup_asmtracks=Сглобени парчета трасе
Expand Down
5 changes: 1 addition & 4 deletions resource/localization/en/trackassembly.properties
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,7 @@ tool.trackassembly.buttonas<>=Decrement/Increment
tool.trackassembly.buttonas+/-=Negate value
tool.trackassembly.buttonas@M=Memorize value
tool.trackassembly.buttonas@D=Default value
tool.trackassembly.buttonas@45=Update 45
tool.trackassembly.buttonas@90=Update 90
tool.trackassembly.buttonas@135=Update 135
tool.trackassembly.buttonas@180=Update 180
tool.trackassembly.buttonas@=Apply value\:
sbox_maxasmtracks=Change this to adjust the things spawned via track assembly tool on the server
sbox_maxasmtracks_con=Total segments\:
Cleanup_asmtracks=Assembled track pieces
Expand Down
5 changes: 1 addition & 4 deletions resource/localization/ru/trackassembly.properties
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ tool.trackassembly.buttonas<>=Уменьшить/Увеличить
tool.trackassembly.buttonas+/-=Начение по умолчаниюз
tool.trackassembly.buttonas@M=Запомнить стоимость
tool.trackassembly.buttonas@D=Значение по умолчанию
tool.trackassembly.buttonas@45=Обновить 45
tool.trackassembly.buttonas@90=Обновить 90
tool.trackassembly.buttonas@135=Обновить 135
tool.trackassembly.buttonas@180=Обновить 180
tool.trackassembly.buttonas@=Обновить стоимость\:
Cleanup_asmtracks=Собранные куски дороги
Cleaned_asmtracks=Все куски дороги очищены
SBoxLimit_asmtracks=Вы достигли предела созданных кусков дороги!

0 comments on commit 0bbe745

Please sign in to comment.