mirror of
				https://github.com/chev2/gmod-addons.git
				synced 2025-10-30 06:31:35 +00:00 
			
		
		
		
	Screenshot Editor: Fix alphanumeric filenames not being detected
If a file started with a name with numbers in it, like "c1m3_mall", the screenshot would not be loaded for the player to select. This has been fixed.
This commit is contained in:
		
							parent
							
								
									851b5f71c1
								
							
						
					
					
						commit
						1938adbf7e
					
				
					 1 changed files with 23 additions and 9 deletions
				
			
		|  | @ -3,28 +3,42 @@ screenshot_editor = screenshot_editor or {} | ||||||
| local SCREENSHOT_FILES = {} | local SCREENSHOT_FILES = {} | ||||||
| local SCREENSHOT_ITERATE_ACTIVE = false | local SCREENSHOT_ITERATE_ACTIVE = false | ||||||
| 
 | 
 | ||||||
| -- Not a fantastic method, but it's a little smoother than file.Find("*.*") | -- We check filenames that start with these characters in IterateScreenshotFiles() | ||||||
|  | local charCheckList = {} | ||||||
|  | 
 | ||||||
|  | for i = 65, 65 + 25 do charCheckList[#charCheckList + 1] = string.char(i) end | ||||||
|  | for i = 97, 97 + 25 do charCheckList[#charCheckList + 1] = string.char(i) end | ||||||
|  | for i = 0, 9 do charCheckList[#charCheckList + 1] = tostring(i) end | ||||||
|  | table.Add(charCheckList, {"_", "-", "(", ")", " "}) | ||||||
|  | 
 | ||||||
|  | -- Not a fantastic method, but it's smoother than file.Find("*.*") | ||||||
| local function IterateScreenshotFiles() | local function IterateScreenshotFiles() | ||||||
|     local fileQueue = {} |     local fileQueue = {} | ||||||
| 
 | 
 | ||||||
|     --local ctime = SysTime() |     --local ctime = SysTime() | ||||||
| 
 | 
 | ||||||
|     -- a through z |     -- a through z | ||||||
|     for i = 97, 97 + 25 do |     -- ! LIMITATION: This will skip over filenames NOT starting with these characters. | ||||||
|         for j = 97, 97 + 25 do |     --      ! - this is a small edge case, as maps and screenshots usually shouldn't start with weird characters.. | ||||||
|             local fileBeginner = string.char(i, j) |     for i = 1, #charCheckList do | ||||||
|  |         for j = 1, #charCheckList do | ||||||
|  |             local char1 = charCheckList[i] | ||||||
|  |             local char2 = charCheckList[j] | ||||||
|  | 
 | ||||||
|  |             local fileBeginner = char1 .. char2 | ||||||
| 
 | 
 | ||||||
|             local foundScreenshotFiles = file.Find("screenshots/" .. fileBeginner .. "*.*", "MOD") |             local foundScreenshotFiles = file.Find("screenshots/" .. fileBeginner .. "*.*", "MOD") | ||||||
|             table.Add(fileQueue, foundScreenshotFiles) |             table.Add(fileQueue, foundScreenshotFiles) | ||||||
| 
 | 
 | ||||||
|             --[[if #foundScreenshotFiles > 0 then |             -- if #foundScreenshotFiles > 0 then | ||||||
|                 print(fileBeginner, #foundScreenshotFiles) |             --     print(fileBeginner, #foundScreenshotFiles) | ||||||
|             end]] |             -- end | ||||||
| 
 |  | ||||||
|             coroutine.yield() |  | ||||||
|         end |         end | ||||||
|  | 
 | ||||||
|  |         coroutine.yield() | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  |     -- Organize files by modified time, so more recently-created screenshots appear at the top of the UI | ||||||
|     while #fileQueue > 0 do |     while #fileQueue > 0 do | ||||||
|         for i = 1, 200 do |         for i = 1, 200 do | ||||||
|             if #fileQueue == 0 then continue end |             if #fileQueue == 0 then continue end | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue