Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the parameter input for slider set control #52

Merged
merged 7 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
64 changes: 52 additions & 12 deletions lua/trackassembly/trackasmlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ local mathSqrt = math and math.sqrt
local mathFloor = math and math.floor
local mathClamp = math and math.Clamp
local mathAtan2 = math and math.atan2
local mathRemap = math and math.Remap
local mathRound = math and math.Round
local mathRandom = math and math.random
local drawRoundedBox = draw and draw.RoundedBox
Expand Down Expand Up @@ -397,7 +398,7 @@ function GetOwner(oEnt)
ows = oEnt.player; if(IsPlayer(ows)) then return ows else ows = nil end
ows = oEnt.Owner; if(IsPlayer(ows)) then return ows else ows = nil end
ows = oEnt.owner; if(IsPlayer(ows)) then return ows else ows = nil end
if(set) then -- Duplicator die functions are registered
if(set) then -- Duplicator the functions are registered
set = set.GetCountUpdate; ows = (set.Args and set.Args[1] or nil)
if(IsPlayer(ows)) then return ows else ows = nil end
set = set.undo1; ows = (set.Args and set.Args[1] or nil)
Expand Down Expand Up @@ -834,6 +835,7 @@ function InitBase(sName, sPurp)
SetOpVar("TABLE_WSIDADDON", {})
SetOpVar("ARRAY_GHOST",{Size=0, Slot=GetOpVar("MISS_NOMD")})
SetOpVar("TABLE_CATEGORIES",{})
SetOpVar("CLIPBOARD_TEXT","")
SetOpVar("TREE_KEYPANEL","#$@KEY&*PAN*&OBJ@$#")
end; LogInstance("Success"); return true
end
Expand Down Expand Up @@ -1803,7 +1805,7 @@ function SetComboBoxList(cPanel, sVar)
end -- Copy the combo box content shown
pItem.OnSelect = function(pnSelf, nInd, sVal, anyData)
SetAsmConvar(nil, sVar, anyData)
end -- Apply the settinc to the specified variable
end -- Apply the setting to the specified variable
for iD = 1, #tSet do local sI = tSet[iD]
local sIco = ToIcon(sNam.."_"..sI:lower())
local sPrv = (sBase.."_"..sI:lower())
Expand Down Expand Up @@ -1831,7 +1833,7 @@ function SetNumSlider(cPanel, sVar, vDig, vMin, vMax, vDev)
-- Read minimum value form the first available
if(not IsHere(nMin)) then nMin, nDum = GetBorder(sKey)
if(not IsHere(nMin)) then nMin = GetAsmConvar(sVar, "MIN")
if(not IsHere(nMin)) then -- Mininum bound is not located
if(not IsHere(nMin)) then -- Minimum bound is not located
nMin = -mathAbs(2 * mathFloor(GetAsmConvar(sVar, "FLT")))
LogInstance("(L) Miss "..GetReport1(sKey))
else LogInstance("(L) Cvar "..GetReport2(sKey, nMin)) end
Expand Down Expand Up @@ -1874,15 +1876,53 @@ function SetButtonSlider(cPanel, sVar, nMin, nMax, nDec, tBtn)
pPanel:SetSlider(sKey, languageGetPhrase(sBase.."_con"), languageGetPhrase(sBase))
pPanel:Configure(nMin, nMax, tConv[sKey], nDec)
for iD = 1, #tBtn do
local vBtn, sTip = tBtn[iD]
local sTxt = tostring(vBtn.N):Trim()
if(vBtn.T) then
if(vBtn.T == syRev) then
sTip = languageGetPhrase(sBase.."_bas"..sTxt)
elseif(vBtn.T == syDis) then
sTip = languageGetPhrase("tool."..sTool..".buttonas"..sTxt)
else
sTip = tostring(vBtn.T):Trim()
local vBtn = tBtn[iD] -- Button info
local sTxt = tostring(vBtn.N or syDis):Trim()
local sTip = tostring(vBtn.T or syDis):Trim()
if(sTip:sub(1,1) == syRev) then
sTip = languageGetPhrase(sBase.."_bas"..sTxt)
elseif(sTip:sub(1,1) == syDis) then
sTip = languageGetPhrase("tool."..sTool..".buttonas"..sTxt)
end
if(sTxt:sub(1,1) == syRev) then
local sVam = sTxt:sub(2,-1)
if(tonumber(sVam)) then
local nAmt = (tonumber(sVam) or 0)
if(not vBtn.L) then
vBtn.L=function(pB, pS, nS) pS:SetValue(-nAmt) end
end
if(not vBtn.R) then
vBtn.R=function(pB, pS, nS) pS:SetValue(nAmt) end
end
sTip = languageGetPhrase("tool."..sTool..".buttonas"..syRev).." "..nAmt
elseif(sVam == "D") then
if(not vBtn.L) then
vBtn.L=function(pB, pS, nS) pS:SetValue(pS:GetDefaultValue()) end
end
if(not vBtn.R) then
vBtn.R=function(pB, pS, nS) SetClipboardText(pS:GetDefaultValue()) end
end
elseif(sVam == "M") then
if(not vBtn.L) then
vBtn.L=function(pB, pS, nS) pS:SetValue(tonumber(GetOpVar("CLIPBOARD_TEXT")) or 0) end
end
if(not vBtn.R) then
vBtn.R=function(pB, pS, nS) SetClipboardText(nS); SetOpVar("CLIPBOARD_TEXT", nS) end
end
end
elseif(sTxt == "+/-") then
if(not vBtn.L) then
vBtn.L=function(pB, pS, nS) pS:SetValue(-nS) end
end
if(not vBtn.R) then
vBtn.R=function(pB, pS, nS) pS:SetValue(mathRemap(nS, pS:GetMin(), pS:GetMax(), pS:GetMax(), pS:GetMin())) end
end
elseif(sTxt == "<>") then
if(not vBtn.L) then
vBtn.L=function(pB, pS, nS) pS:SetValue(GetSnap(nS,-GetAsmConvar("incsnpang","FLT"))) end
end
if(not vBtn.R) then
vBtn.R=function(pB, pS, nS) pS:SetValue(GetSnap(nS, GetAsmConvar("incsnpang","FLT"))) end
end
end
pPanel:SetButton(sTxt, sTip)
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
22 changes: 5 additions & 17 deletions lua/weapons/gmod_tool/stools/trackassembly.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2462,24 +2462,12 @@ function TOOL.BuildCPanel(CPanel)
asmlib.SetNumSlider(CPanel, "angsnap" , iMaxDec)
asmlib.SetButton(CPanel, "resetvars")
local tBAng = { -- Button interactive slider ( angle offsets )
{N="<>" , T = "#", -- Left click to decrease, right to increase
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="<>" }, {N="+/-"}, {N="@M" }, {N="@D" },
{N="@45"}, {N="@90"}, {N="@135"}, {N="@180"}
} -- Use the same initialization table for multiple BIS
local tBpos = { -- Button interactive slider ( position offsets )
{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="<>" }, {N="+/-"}, {N="@M" }, {N="@D" },
{N="@25"}, {N="@50"}, {N="@75" }, {N="@100"}
} -- 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=Вы достигли предела созданных кусков дороги!
Loading