From cf6f064e21233727615a6c6cebd604cc32f1754f Mon Sep 17 00:00:00 2001 From: Tad Hardesty Date: Wed, 9 May 2018 19:34:57 -0700 Subject: [PATCH] Use spritesheets to reduce time spent sending PNG assets by 90+% (#37399) The total number of assets to be sent has been reduced from 1532 to 76, with time between first asset and last going from about 112s to about 7s (a 93% reduction) by my measure. The following assets have been coalesced: 705 pipe images (used by RPD) -> 1 spritesheet + css 595 research design icons (used by R&D console) -> 3 spritesheets + css 116 OOC emoji + 15 language icons -> 1 spritesheet + css 27 PDA icons -> 1 spritesheet + css 11 paperwork stamps -> 1 spritesheet + css --- .travis.yml | 3 +- code/__DEFINES/misc.dm | 3 + code/controllers/subsystem/assets.dm | 7 +- code/game/objects/items/RPD.dm | 4 +- code/game/objects/items/devices/PDA/PDA.dm | 78 ++--- code/game/objects/items/devices/PDA/cart.dm | 37 ++- code/modules/client/asset_cache.dm | 290 ++++++++++++++---- code/modules/emoji/emoji_parse.dm | 6 +- code/modules/goonchat/browserOutput.dm | 3 +- .../browserassets/html/browserOutput.html | 1 + code/modules/language/language.dm | 3 +- code/modules/paperwork/paper.dm | 7 +- code/modules/research/designs.dm | 5 +- code/modules/research/rdconsole.dm | 2 + rust_g.dll | Bin 240128 -> 410624 bytes tgui/assets/tgui.js | 37 +-- tgui/src/interfaces/rpd.ract | 4 +- tools/travis/build_dependencies.sh | 7 +- 18 files changed, 345 insertions(+), 152 deletions(-) diff --git a/.travis.yml b/.travis.yml index 60a2a7e7b44..dd59f657edb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ env: - BYOND_MAJOR="512" - BYOND_MINOR="1418" - NODE_VERSION="4" - - RUST_G_VERSION="0.2.0" + - RUST_G_VERSION="0.3.0" - BUILD_TOOLS=false - BUILD_TESTING=false - DM_MAPFILE="loadallmaps" @@ -34,6 +34,7 @@ addons: - gcc-multilib - python3 - python3-pip + - libssl-dev:i386 install: - tools/travis/install_build_tools.sh diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index 8b4d413c92d..0478d203dfb 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -440,5 +440,8 @@ GLOBAL_LIST_INIT(ghost_others_options, list(GHOST_OTHERS_SIMPLE, GHOST_OTHERS_DE #define EGG_LAYING_MESSAGES list("lays an egg.","squats down and croons.","begins making a huge racket.","begins clucking raucously.") +// Used by PDA and cartridge code to reduce repetitiveness of spritesheets +#define PDAIMG(what) {""} + //Filters #define AMBIENT_OCCLUSION filter(type="drop_shadow", x=0, y=-2, size=4, border=4, color="#04080FAA") diff --git a/code/controllers/subsystem/assets.dm b/code/controllers/subsystem/assets.dm index fd27c9424fb..7285298283c 100644 --- a/code/controllers/subsystem/assets.dm +++ b/code/controllers/subsystem/assets.dm @@ -6,9 +6,10 @@ SUBSYSTEM_DEF(assets) var/list/preload = list() /datum/controller/subsystem/assets/Initialize(timeofday) - for(var/type in typesof(/datum/asset) - list(/datum/asset, /datum/asset/simple)) - var/datum/asset/A = new type() - A.register() + for(var/type in typesof(/datum/asset)) + var/datum/asset/A = type + if (type != initial(A._abstract)) + get_asset_datum(type) preload = cache.Copy() //don't preload assets generated during the round diff --git a/code/game/objects/items/RPD.dm b/code/game/objects/items/RPD.dm index 019a21d07bd..5bf2b25238b 100644 --- a/code/game/objects/items/RPD.dm +++ b/code/game/objects/items/RPD.dm @@ -140,7 +140,7 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list( return "makepipe=[id]&type=[dirtype]" /datum/pipe_info/meter - icon_state = "meterX" + icon_state = "meter" dirtype = PIPE_ONEDIR /datum/pipe_info/meter/New(label) @@ -234,7 +234,7 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list( datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state) ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) if(!ui) - var/datum/asset/assets = get_asset_datum(/datum/asset/simple/icon_states/multiple_icons/pipes) + var/datum/asset/assets = get_asset_datum(/datum/asset/spritesheet/pipes) assets.send(user) ui = new(user, src, ui_key, "rpd", name, 300, 550, master_ui, state) diff --git a/code/game/objects/items/devices/PDA/PDA.dm b/code/game/objects/items/devices/PDA/PDA.dm index c43155fc53a..b03ce51d08c 100644 --- a/code/game/objects/items/devices/PDA/PDA.dm +++ b/code/game/objects/items/devices/PDA/PDA.dm @@ -178,20 +178,20 @@ GLOBAL_LIST_EMPTY(PDAs) . = ..() - var/datum/asset/assets = get_asset_datum(/datum/asset/simple/pda) + var/datum/asset/spritesheet/assets = get_asset_datum(/datum/asset/spritesheet/simple/pda) assets.send(user) user.set_machine(src) var/dat = "Personal Data Assistant" + dat += assets.css_tag() - - dat += "Refresh" + dat += "[PDAIMG(refresh)]Refresh" if ((!isnull(cartridge)) && (mode == 0)) - dat += " | Eject [cartridge]" + dat += " | [PDAIMG(eject)]Eject [cartridge]" if (mode) - dat += " | Return" + dat += " | [PDAIMG(menu)]Return" if (mode == 0) dat += "
" @@ -205,7 +205,7 @@ GLOBAL_LIST_EMPTY(PDAs) if (!owner) dat += "Warning: No owner information entered. Please swipe card.

" - dat += "Retry" + dat += "[PDAIMG(refresh)]Retry" else switch (mode) if (0) @@ -221,38 +221,38 @@ GLOBAL_LIST_EMPTY(PDAs) dat += "

General Functions

" dat += "" if (cartridge.access & CART_ENGINE) dat += "

Engineering Functions

" dat += "" if (cartridge.access & CART_MEDICAL) dat += "

Medical Functions

" dat += "" if (cartridge.access & CART_SECURITY) dat += "

Security Functions

" dat += "" if(cartridge.access & CART_QUARTERMASTER) dat += "

Quartermaster Functions:

" dat += "" dat += "" @@ -260,25 +260,25 @@ GLOBAL_LIST_EMPTY(PDAs) dat += "" if (1) - dat += "

Notekeeper V2.2

" + dat += "

[PDAIMG(notes)] Notekeeper V2.2

" dat += "Edit
" if(notescanned) dat += "(This is a scanned image, editing it may cause some text formatting to change.)
" dat += "
[(!notehtml ? note : notehtml)]" if (2) - dat += "

SpaceMessenger V3.9.6

" - dat += "Ringer: [silent == 1 ? "Off" : "On"] | " - dat += "Send / Receive: [toff == 1 ? "Off" : "On"] | " - dat += "Set Ringtone | " - dat += "Messages
" + dat += "

[PDAIMG(mail)] SpaceMessenger V3.9.6

" + dat += "[PDAIMG(bell)]Ringer: [silent == 1 ? "Off" : "On"] | " + dat += "[PDAIMG(mail)]Send / Receive: [toff == 1 ? "Off" : "On"] | " + dat += "[PDAIMG(bell)]Set Ringtone | " + dat += "[PDAIMG(mail)]Messages
" if(cartridge) dat += cartridge.message_header() - dat += "

Detected PDAs

" + dat += "

[PDAIMG(menu)] Detected PDAs

" dat += "