Skip to content

Commit bee8e31

Browse files
committed
Merge branch 'develop' of https://github.com/CapsAdmin/pac3 into develop
2 parents 8c47e74 + 1a2d63b commit bee8e31

File tree

7 files changed

+38
-17
lines changed

7 files changed

+38
-17
lines changed

lua/pac3/core/client/util.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ function pac.Handleurltex(part, url, callback, shader, additionalData)
440440
if not url:match("https?://.+/%S*") then return false end
441441

442442
pac.urltex.GetMaterialFromURL(
443-
pac.FixUrl(url),
443+
pac.FixUrl(url, "image"),
444444

445445
function(mat, tex)
446446
if not part:IsValid() then return end

lua/pac3/core/shared/http.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ local function http(method, url, headers, cb, failcb)
6262
})
6363
end
6464

65-
function pac.FixUrl(url)
65+
function pac.FixUrl(url, expectedContentType)
6666
url = url:Trim()
6767
url = url:gsub("[\"'<>\n\\]+", "")
6868

@@ -75,14 +75,21 @@ function pac.FixUrl(url)
7575
return url
7676
end
7777

78-
if url:find("drive.google.com", 1, true) and not url:find("export=download", 1, true) then
78+
if url:find("drive.google.com", 1, true) then
7979
local id =
8080
url:match("https://drive.google.com/file/d/(.-)/") or
8181
url:match("https://drive.google.com/file/d/(.-)$") or
82-
url:match("https://drive.google.com/open%?id=(.-)$")
82+
url:match("https://drive.google.com/open%?id=(.-)$") or
83+
url:match("https://drive.google.com/uc%?export=download&id=(.-)$") or
84+
url:match("https://drive.google.com/uc%?id=(.-)&export=download$")
8385

8486
if id then
85-
return "https://drive.google.com/uc?export=download&id=" .. id
87+
if expectedContentType == "image" then
88+
local thumbnailSize = math.Clamp( pac.urltex.TextureSize, 32, 4096 )
89+
return "https://drive.google.com/thumbnail?id=" .. id .. "&sz=s" .. string.format("%.0f", thumbnailSize)
90+
elseif not url:find("export=download", 1, true) then
91+
return "https://drive.google.com/uc?export=download&id=" .. id
92+
end
8693
end
8794
return url
8895
end

lua/pac3/editor/client/panels/browser.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function PANEL:AddOutfits(folder, callback)
5454
local filenode = self:AddLine(
5555
name:gsub("%.txt", ""),
5656
raw_size:GetBool() and file.Size(outfit, "DATA") or string.NiceSize(file.Size(outfit, "DATA")),
57-
os.date("%m/%d/%Y %H:%M", file.Time(outfit, "DATA"))
57+
raw_size:GetBool() and file.Time(outfit, "DATA") or os.date("%m/%d/%Y %H:%M", file.Time(outfit, "DATA"))
5858
)
5959
filenode.FileName = name
6060
filenode.OnSelect = callback
@@ -72,7 +72,7 @@ function PANEL:AddOutfits(folder, callback)
7272
local filenode = self:AddLine(
7373
name,
7474
"<folder>",
75-
os.date("%m/%d/%Y %H:%M", file.Time(folder2, "DATA"))
75+
raw_size:GetBool() and file.Time(folder2, "DATA") or os.date("%m/%d/%Y %H:%M", file.Time(folder2, "DATA"))
7676
)
7777
filenode.FileName = name
7878
filenode.OnSelect = function() self:SetDir(string.sub(folder2, 6, #folder2)) end
@@ -107,4 +107,4 @@ function PANEL.OnRowRightClick(_self,id, self)
107107
m:Open()
108108
end
109109

110-
pace.RegisterPanel(PANEL)
110+
pace.RegisterPanel(PANEL)

lua/pac3/editor/client/saved_parts.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ end
9696

9797
local last_backup
9898
local maxBackups = CreateConVar("pac_backup_limit", "100", {FCVAR_ARCHIVE}, "Maximal amount of backups")
99-
local autoload_prompt = CreateConVar("pac_prompt_for_autoload", "1", {FCVAR_ARCHIVE}, "Whether to ask before loading autoload. The prompt can let you choose to not load, pick autoload or the newest backup")
99+
local autoload_prompt = CreateConVar("pac_prompt_for_autoload", "0", {FCVAR_ARCHIVE}, "Whether to ask before loading autoload. The prompt can let you choose to not load, pick autoload or the newest backup")
100100
local auto_spawn_prop = CreateConVar("pac_autoload_preferred_prop", "2", {FCVAR_ARCHIVE}, "When loading a pac with an owner name suggesting a prop, notify you and then wait before auto-applying the outfit next time you spawn a prop.\n" ..
101101
"0 : do not check\n1 : check if only 1 such group is present\n2 : check if multiple such groups are present and queue one group at a time")
102102

lua/pac3/editor/client/wear.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ do
306306
local backup_files, directories = file.Find( "pac3/__backup/*.txt", "DATA", "datedesc")
307307
local latest_outfit = cookie.GetString( "pac_last_loaded_outfit", "" )
308308
if not backup_files then
309-
local pnl = Derma_Query("Do you want to load your autoload outfit?", "PAC3 autoload (pac_prompt_for_autoload)",
309+
local pnl = Derma_Query("Do you want to load your autoload outfit?\nclick outside the window to cancel", "PAC3 autoload (pac_prompt_for_autoload)",
310310
"load pac3/autoload.txt : " .. string.NiceSize(file.Size("pac3/autoload.txt", "DATA")), function()
311311
pac.Message("Wearing autoload...")
312312
pace.LoadParts("autoload")
@@ -322,13 +322,13 @@ do
322322
end
323323
end,
324324

325-
"cancel", function() pac.Message("Not loading autoload or backups...") end
325+
"don't show this again", function() GetConVar("pac_prompt_for_autoload"):SetBool(false) end
326326
)
327327
pnl.Think = function() if not pnl:HasFocus() or (input.IsMouseDown(MOUSE_LEFT) and not (pnl:IsHovered() or pnl:IsChildHovered())) then pnl:Remove() end end
328328
else
329329
if backup_files[1] then
330330
local latest_autosave = "pac3/__backup/" .. backup_files[1]
331-
local pnl = Derma_Query("Do you want to load an outfit?", "PAC3 autoload (pac_prompt_for_autoload)",
331+
local pnl = Derma_Query("Do you want to load an outfit?\nclick outside the window to cancel", "PAC3 autoload (pac_prompt_for_autoload)",
332332
"load pac3/autoload.txt : " .. string.NiceSize(file.Size("pac3/autoload.txt", "DATA")), function()
333333
pac.Message("Wearing autoload...")
334334
pace.LoadParts("autoload")
@@ -349,18 +349,18 @@ do
349349
end
350350
end,
351351

352-
"cancel", function() pac.Message("Not loading autoload or backups...") end
352+
"don't show this again", function() GetConVar("pac_prompt_for_autoload"):SetBool(false) end
353353
)
354354
pnl.Think = function() if not pnl:HasFocus() or (input.IsMouseDown(MOUSE_LEFT) and not (pnl:IsHovered() or pnl:IsChildHovered())) then pnl:Remove() end end
355355
else
356-
local pnl = Derma_Query("Do you want to load your autoload outfit?", "PAC3 autoload (pac_prompt_for_autoload)",
356+
local pnl = Derma_Query("Do you want to load your autoload outfit?\nclick outside the window to cancel", "PAC3 autoload (pac_prompt_for_autoload)",
357357
"load pac3/autoload.txt : " .. string.NiceSize(file.Size("pac3/autoload.txt", "DATA")), function()
358358
pac.Message("Wearing autoload...")
359359
pace.LoadParts("autoload")
360360
pace.WearParts()
361361
end,
362362

363-
"cancel", function() pac.Message("Not loading autoload or backups...") end
363+
"don't show this again", function() GetConVar("pac_prompt_for_autoload"):SetBool(false) end
364364
)
365365
pnl.Think = function() if not pnl:HasFocus() or (input.IsMouseDown(MOUSE_LEFT) and not (pnl:IsHovered() or pnl:IsChildHovered())) then pnl:Remove() end end
366366
end

lua/pac3/libraries/resource.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ local function download(from, to, callback, on_fail, on_header, check_etag, etag
139139

140140
local allowed = {
141141
[".txt"] = true,
142+
[".jpeg"] = true,
142143
[".jpg"] = true,
143144
[".png"] = true,
144145
[".vtf"] = true,
@@ -150,7 +151,20 @@ local function download(from, to, callback, on_fail, on_header, check_etag, etag
150151
function(body, len, header)
151152
do
152153
if need_extension then
153-
local ext = header["Content-Type"] and (header["Content-Type"]:match(".-/(.-);") or header["Content-Type"]:match(".-/(.+)")) or "dat"
154+
local ext = "dat"
155+
if header["Content-Type"] then
156+
for _, mime in ipairs( string.Split(header["Content-Type"], ',') ) do -- some common services, including google, serve multi-item mime strings like "image/png,application/binary"
157+
subtype = mime:match(".-/(.-);") or mime:match(".-/(.+)")
158+
if subtype then
159+
subtype = subtype:lower()
160+
if allowed['.' .. subtype] then
161+
ext = subtype
162+
break -- take the first subtype (if any) found in our whitelist
163+
end
164+
end
165+
end
166+
end
167+
154168
if ext == "jpeg" then ext = "jpg" end
155169

156170
if body:StartWith("VTF") then

lua/pac3/libraries/urltex.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function urltex.StartDownload(url, data)
113113
urltex.ActivePanel:Remove()
114114
end
115115

116-
url = pac.FixUrl(url)
116+
url = pac.FixUrl(url, "image")
117117
local size = tonumber(data.size or urltex.TextureSize)
118118
local id = "urltex_download_" .. url
119119
local pnl

0 commit comments

Comments
 (0)