Ready for testmerge
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
/*
|
||||
Asset cache quick users guide:
|
||||
|
||||
Make a datum at the bottom of this file with your assets for your thing.
|
||||
The simple subsystem will most like be of use for most cases.
|
||||
Then call get_asset_datum() with the type of the datum you created and store the return
|
||||
Then call .send(client) on that stored return value.
|
||||
|
||||
You can set verify to TRUE if you want send() to sleep until the client has the assets.
|
||||
*/
|
||||
|
||||
@@ -26,7 +28,7 @@ You can set verify to TRUE if you want send() to sleep until the client has the
|
||||
|
||||
//This proc sends the asset to the client, but only if it needs it.
|
||||
//This proc blocks(sleeps) unless verify is set to false
|
||||
/proc/send_asset(var/client/client, var/asset_name, var/verify = TRUE)
|
||||
/proc/send_asset(client/client, asset_name, verify = TRUE)
|
||||
if(!istype(client))
|
||||
if(ismob(client))
|
||||
var/mob/M = client
|
||||
@@ -70,7 +72,7 @@ You can set verify to TRUE if you want send() to sleep until the client has the
|
||||
return 1
|
||||
|
||||
//This proc blocks(sleeps) unless verify is set to false
|
||||
/proc/send_asset_list(var/client/client, var/list/asset_list, var/verify = TRUE)
|
||||
/proc/send_asset_list(client/client, list/asset_list, verify = TRUE)
|
||||
if(!istype(client))
|
||||
if(ismob(client))
|
||||
var/mob/M = client
|
||||
@@ -120,7 +122,7 @@ You can set verify to TRUE if you want send() to sleep until the client has the
|
||||
|
||||
//This proc will download the files without clogging up the browse() queue, used for passively sending files on connection start.
|
||||
//The proc calls procs that sleep for long times.
|
||||
/proc/getFilesSlow(var/client/client, var/list/files, var/register_asset = TRUE)
|
||||
/proc/getFilesSlow(client/client, list/files, register_asset = TRUE)
|
||||
var/concurrent_tracker = 1
|
||||
for(var/file in files)
|
||||
if (!client)
|
||||
@@ -138,13 +140,13 @@ You can set verify to TRUE if you want send() to sleep until the client has the
|
||||
|
||||
//This proc "registers" an asset, it adds it to the cache for further use, you cannot touch it from this point on or you'll fuck things up.
|
||||
//if it's an icon or something be careful, you'll have to copy it before further use.
|
||||
/proc/register_asset(var/asset_name, var/asset)
|
||||
/proc/register_asset(asset_name, asset)
|
||||
SSassets.cache[asset_name] = asset
|
||||
|
||||
//Generated names do not include file extention.
|
||||
//Used mainly for code that deals with assets in a generic way
|
||||
//The same asset will always lead to the same asset name
|
||||
/proc/generate_asset_name(var/file)
|
||||
/proc/generate_asset_name(file)
|
||||
return "asset.[md5(fcopy_rsc(file))]"
|
||||
|
||||
|
||||
@@ -154,7 +156,7 @@ You can set verify to TRUE if you want send() to sleep until the client has the
|
||||
GLOBAL_LIST_EMPTY(asset_datums)
|
||||
|
||||
//get an assetdatum or make a new one
|
||||
/proc/get_asset_datum(var/type)
|
||||
/proc/get_asset_datum(type)
|
||||
return GLOB.asset_datums[type] || new type()
|
||||
|
||||
/datum/asset
|
||||
@@ -321,6 +323,13 @@ GLOBAL_LIST_EMPTY(asset_datums)
|
||||
var/size_id = sprite[SPR_SIZE]
|
||||
return {"<span class="[name][size_id] [sprite_name]"></span>"}
|
||||
|
||||
/datum/asset/spritesheet/proc/icon_class_name(sprite_name)
|
||||
var/sprite = sprites[sprite_name]
|
||||
if (!sprite)
|
||||
return null
|
||||
var/size_id = sprite[SPR_SIZE]
|
||||
return {"[name][size_id] [sprite_name]"}
|
||||
|
||||
#undef SPR_SIZE
|
||||
#undef SPR_IDX
|
||||
#undef SPRSZ_COUNT
|
||||
@@ -388,7 +397,7 @@ GLOBAL_LIST_EMPTY(asset_datums)
|
||||
"shim-html5shiv.js" = 'tgui-next/packages/tgui/public/shim-html5shiv.js',
|
||||
"shim-ie8.js" = 'tgui-next/packages/tgui/public/shim-ie8.js',
|
||||
"shim-dom4.js" = 'tgui-next/packages/tgui/public/shim-dom4.js',
|
||||
"shim-css-om.js" = 'tgui-next/packages/tgui/public/shim-css-om.js'
|
||||
"shim-css-om.js" = 'tgui-next/packages/tgui/public/shim-css-om.js',
|
||||
)
|
||||
|
||||
/datum/asset/group/tgui
|
||||
@@ -519,7 +528,7 @@ GLOBAL_LIST_EMPTY(asset_datums)
|
||||
"pill21" = 'icons/UI_Icons/Pills/pill21.png',
|
||||
"pill22" = 'icons/UI_Icons/Pills/pill22.png',
|
||||
)
|
||||
|
||||
|
||||
/datum/asset/simple/IRV
|
||||
assets = list(
|
||||
"jquery-ui.custom-core-widgit-mouse-sortable-min.js" = 'html/IRV/jquery-ui.custom-core-widgit-mouse-sortable-min.js',
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<link rel="stylesheet" type="text/css" href="browserOutput.css" />
|
||||
<link rel="stylesheet" type="text/css" href="spritesheet_chat.css" />
|
||||
<link rel="stylesheet" type="text/css" id="colorPresetLink"/>
|
||||
<script type="text/javascript" src="errorHandler.js"></script>
|
||||
<script type="text/javascript" src="jquery.min.js"></script>
|
||||
<script type="text/javascript" src="json2.min.js"></script>
|
||||
</head>
|
||||
@@ -56,4 +55,4 @@
|
||||
<audio class="hidden" id="adminMusic" autoplay></audio>
|
||||
<script type="text/javascript" src="browserOutput.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
******************************************/
|
||||
|
||||
//DEBUG STUFF
|
||||
var triggerError = attachErrorHandler('chatDebug', true);
|
||||
var escaper = encodeURIComponent || escape;
|
||||
var decoder = decodeURIComponent || unescape;
|
||||
window.onerror = function(msg, url, line, col, error) {
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
(function(window, navigator) {
|
||||
|
||||
var escaper = encodeURIComponent || escape;
|
||||
|
||||
var triggerError = function(msg, url, line, col, error) {
|
||||
window.onerror(msg, url, line, col, error);
|
||||
};
|
||||
|
||||
/**
|
||||
* Directs JS errors to a byond proc for logging
|
||||
*
|
||||
* @param string file Name of the logfile to dump errors in, do not prepend with data/
|
||||
* @param boolean overrideDefault True to prevent default JS errors (an big honking error prompt thing)
|
||||
* @return boolean
|
||||
*/
|
||||
var attach = function(file, overrideDefault) {
|
||||
overrideDefault = typeof overrideDefault === 'undefined' ? false : overrideDefault;
|
||||
file = escaper(file);
|
||||
|
||||
window.onerror = function(msg, url, line, col, error) {
|
||||
var extra = !col ? '' : ' | column: ' + col;
|
||||
extra += !error ? '' : ' | error: ' + error;
|
||||
extra += !navigator.userAgent ? '' : ' | user agent: ' + navigator.userAgent;
|
||||
var debugLine = 'Error: ' + msg + ' | url: ' + url + ' | line: ' + line + extra;
|
||||
window.location = '?action=debugFileOutput&file=' + file + '&message=' + escaper(debugLine);
|
||||
return overrideDefault;
|
||||
};
|
||||
|
||||
return triggerError;
|
||||
};
|
||||
|
||||
window.attachErrorHandler = attach;
|
||||
|
||||
}(window, window.navigator));
|
||||
@@ -1,102 +0,0 @@
|
||||
/**
|
||||
* This is a generic handler for logging your dumb JS errors generated by html popups
|
||||
*
|
||||
* 1. Add your logfile to the validFiles list
|
||||
* 2. Include the "browserassets/js/errorHandler.js" file in your html file (if using chui, skip this step) (look at browserOutput.html for an example)
|
||||
* 3. Call attachErrorHandler('yourLogFile'); at the top of your JS (again see browserOutput.js for an example)
|
||||
*/
|
||||
|
||||
/datum/debugFileOutput
|
||||
var/directory = "data/popupErrors" //where to shove all the logfiles
|
||||
var/ext = "log" //file extension
|
||||
var/logFileLimit = 52428800 //50mb, so yeah pretty permissive
|
||||
|
||||
//Add your dumb file here. This is so some schmuck can't just shit out a bunch of spam logfiles and use all the diskspace. Relative to src.directory
|
||||
var/list/validFiles = list(
|
||||
"chatDebug",
|
||||
"tooltipDebug",
|
||||
"chemDispenser",
|
||||
"banPanel",
|
||||
"stationNamer"
|
||||
)
|
||||
|
||||
/datum/debugFileOutput/proc/error(fileName, message, client/C)
|
||||
if (!fileName || !message)
|
||||
return 0
|
||||
|
||||
if (!(fileName in src.validFiles))
|
||||
throw EXCEPTION("Debug log file '[fileName].[src.ext]' is not a valid path.")
|
||||
|
||||
var/logFile = file("[src.directory]/[fileName].[src.ext]")
|
||||
var/fileSize = length(logFile)
|
||||
if (fileSize >= src.logFileLimit)
|
||||
CRASH("Debug Error Handling encountered an error! This is highly ironic! File: '[fileName]' has exceeded the filesize limit of: [src.logFileLimit] bytes")
|
||||
|
||||
message = "\[[time2text(world.realtime, "YYYY-MM-DD hh:mm:ss")]\] Client: \[[C && C.key ? C.key : "Unknown Client"]\] triggered: [message]"
|
||||
WRITE_FILE(logFile, message)
|
||||
return 1
|
||||
|
||||
/datum/debugFileOutput/proc/clear(fileName)
|
||||
if (!fileName)
|
||||
return 0
|
||||
|
||||
if (!fexists("[src.directory]/[fileName].[src.ext]"))
|
||||
throw EXCEPTION("Debug log file '[fileName].[src.ext]' does not exist.")
|
||||
|
||||
if (!(fileName in src.validFiles))
|
||||
throw EXCEPTION("Debug log file '[fileName].[src.ext]' is not a valid path.")
|
||||
|
||||
fdel("[src.directory]/[fileName].[src.ext]")
|
||||
return 1
|
||||
|
||||
/datum/debugFileOutput/proc/clearAll()
|
||||
var/list/deleted = new()
|
||||
for (var/fileName in src.validFiles)
|
||||
if (fexists("[src.directory]/[fileName].[src.ext]"))
|
||||
fdel("[src.directory]/[fileName].[src.ext]")
|
||||
deleted += fileName
|
||||
|
||||
return deleted
|
||||
|
||||
|
||||
GLOBAL_DATUM_INIT(debugFileOutput, /datum/debugFileOutput, new)
|
||||
|
||||
/client/Topic(href, href_list)
|
||||
..()
|
||||
|
||||
if (href_list["action"] && href_list["action"] == "debugFileOutput" && href_list["file"] && href_list["message"])
|
||||
var/file = href_list["file"]
|
||||
var/message = href_list["message"]
|
||||
GLOB.debugFileOutput.error(file, message, src)
|
||||
|
||||
/client/proc/deleteJsLogFile(fileName as text)
|
||||
set category = "Debug"
|
||||
set name = "Delete JS Logfile"
|
||||
set desc = "Delete a logfile for JS error reporting. Be sure you want to do this!"
|
||||
set popup_menu = 0
|
||||
if(!holder)
|
||||
return
|
||||
if (!fileName)
|
||||
return
|
||||
|
||||
GLOB.debugFileOutput.clear(fileName)
|
||||
|
||||
log_admin("[key_name(usr)] deleted the '[fileName]' JS logfile")
|
||||
message_admins("[key_name_admin(usr)] deleted the '[fileName]' JS logfile")
|
||||
|
||||
/client/proc/deleteAllJsLogFiles()
|
||||
set category = null
|
||||
set name = "Delete All JS Logfiles"
|
||||
set desc = "Delete all logfiles for JS error reporting. Be extra sure you want to do this!"
|
||||
|
||||
if(!holder)
|
||||
return
|
||||
|
||||
if (alert("Are you really sure you want to delete every single JS logfile?", "No", "Yes") == "No")
|
||||
return
|
||||
|
||||
var/list/summary = GLOB.debugFileOutput.clearAll()
|
||||
var/friendlySummary = summary.Join(", ")
|
||||
|
||||
log_admin("[key_name(usr)] deleted every JS logfile! ([friendlySummary])")
|
||||
message_admins("[key_name_admin(usr)] deleted every JS logfile! ([friendlySummary])")
|
||||
Reference in New Issue
Block a user