mirror of
https://github.com/fulpstation/fulpstation.git
synced 2025-12-10 10:01:40 +00:00
Fixed coloring, overlays on overlays, and blood trails.
This commit is contained in:
@@ -624,25 +624,59 @@ as a single icon. Useful for when you want to manipulate an icon via the above a
|
|||||||
The _flatIcons list is a cache for generated icon files.
|
The _flatIcons list is a cache for generated icon files.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
proc
|
proc // Creates a single icon from a given /atom or /image. Only the first argument is required.
|
||||||
getFlatIcon(atom/A, dir) // 1 = use cache, 2 = override cache, 0 = ignore cache
|
getFlatIcon(image/A, defdir=A.dir, deficon=A.icon, defstate=A.icon_state, defblend=A.blend_mode)
|
||||||
|
// We start with a blank canvas, otherwise some icon procs crash silently
|
||||||
|
var/icon/flat = icon('icons/effects/effects.dmi', "nothing") // Final flattened icon
|
||||||
|
if(!A)
|
||||||
|
return flat
|
||||||
|
if(A.alpha <= 0)
|
||||||
|
return flat
|
||||||
|
var/noIcon = FALSE
|
||||||
|
|
||||||
|
var/curicon
|
||||||
|
if(A.icon)
|
||||||
|
curicon = A.icon
|
||||||
|
else
|
||||||
|
curicon = deficon
|
||||||
|
|
||||||
|
if(!curicon)
|
||||||
|
noIcon = TRUE // Do not render this object.
|
||||||
|
|
||||||
|
var/curstate
|
||||||
|
if(A.icon_state)
|
||||||
|
curstate = A.icon_state
|
||||||
|
else
|
||||||
|
curstate = defstate
|
||||||
|
|
||||||
|
if(!noIcon && !(curstate in icon_states(curicon)))
|
||||||
|
if("" in icon_states(curicon))
|
||||||
|
curstate = ""
|
||||||
|
else
|
||||||
|
noIcon = TRUE // Do not render this object.
|
||||||
|
|
||||||
|
var/curdir
|
||||||
|
if(A.dir)
|
||||||
|
curdir = A.dir
|
||||||
|
else
|
||||||
|
curdir = defdir
|
||||||
|
|
||||||
|
var/curblend
|
||||||
|
if(A.blend_mode == BLEND_DEFAULT)
|
||||||
|
curblend = defblend
|
||||||
|
else
|
||||||
|
curblend = A.blend_mode
|
||||||
|
|
||||||
// Layers will be a sorted list of icons/overlays, based on the order in which they are displayed
|
// Layers will be a sorted list of icons/overlays, based on the order in which they are displayed
|
||||||
var/list/layers = list()
|
var/list/layers = list()
|
||||||
|
var/image/copy
|
||||||
// dir defaults to A's dir
|
// Add the atom's icon itself, without pixel_x/y offsets.
|
||||||
if(!dir) dir = A.dir
|
if(!noIcon)
|
||||||
|
copy = image(icon=curicon, icon_state=curstate, layer=A.layer, dir=curdir)
|
||||||
// Add the atom's icon itself
|
copy.color = A.color
|
||||||
if(A.icon)
|
copy.alpha = A.alpha
|
||||||
var/list/states = icon_states(A.icon)
|
copy.blend_mode = curblend
|
||||||
var/image/copy
|
layers[copy] = A.layer
|
||||||
if(A.icon_state in states)
|
|
||||||
// Make a copy without pixel_x/y settings
|
|
||||||
copy = image(icon=A.icon, icon_state=A.icon_state, layer=A.layer, dir=dir)
|
|
||||||
layers[copy] = A.layer
|
|
||||||
else if("" in states)
|
|
||||||
copy = image(icon=A.icon, icon_state="", layer=A.layer, dir=dir)
|
|
||||||
layers[copy] = A.layer
|
|
||||||
|
|
||||||
// Loop through the underlays, then overlays, sorting them into the layers list
|
// Loop through the underlays, then overlays, sorting them into the layers list
|
||||||
var/list/process = A.underlays // Current list being processed
|
var/list/process = A.underlays // Current list being processed
|
||||||
@@ -658,7 +692,7 @@ proc
|
|||||||
if(!current) continue
|
if(!current) continue
|
||||||
currentLayer = current:layer
|
currentLayer = current:layer
|
||||||
if(currentLayer<0) // Special case for FLY_LAYER
|
if(currentLayer<0) // Special case for FLY_LAYER
|
||||||
if(currentLayer <= -1000) return 0
|
if(currentLayer <= -1000) return flat
|
||||||
if(pSet == 0) // Underlay
|
if(pSet == 0) // Underlay
|
||||||
currentLayer = A.layer+currentLayer/1000
|
currentLayer = A.layer+currentLayer/1000
|
||||||
else // Overlay
|
else // Overlay
|
||||||
@@ -684,8 +718,6 @@ proc
|
|||||||
else // All done
|
else // All done
|
||||||
break
|
break
|
||||||
|
|
||||||
// We start with a blank canvas, otherwise some icon procs crash silently
|
|
||||||
var/icon/flat = icon('icons/effects/effects.dmi', "nothing") // Final flattened icon
|
|
||||||
var/icon/add // Icon of overlay being added
|
var/icon/add // Icon of overlay being added
|
||||||
|
|
||||||
// Current dimensions of flattened icon
|
// Current dimensions of flattened icon
|
||||||
@@ -698,23 +730,11 @@ proc
|
|||||||
if(I:alpha == 0)
|
if(I:alpha == 0)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if(I:icon)
|
if(I == copy) // 'I' is an /image based on the object being flattened.
|
||||||
if(I:icon_state)
|
curblend = BLEND_OVERLAY
|
||||||
// Has icon and state set
|
add = icon(I:icon, I:icon_state, I:dir)
|
||||||
add = icon(I:icon, I:icon_state)
|
else // 'I' is an appearance object.
|
||||||
else
|
add = getFlatIcon(new/image(I), curdir, curicon, curstate, curblend)
|
||||||
if(A.icon_state in icon_states(I:icon))
|
|
||||||
// Inherits icon_state from atom
|
|
||||||
add = icon(I:icon, A.icon_state)
|
|
||||||
else
|
|
||||||
// Uses default state ("")
|
|
||||||
add = icon(I:icon)
|
|
||||||
else if(I:icon_state)
|
|
||||||
// Inherits icon from atom
|
|
||||||
add = icon(A.icon, I:icon_state)
|
|
||||||
else
|
|
||||||
// Unknown
|
|
||||||
continue
|
|
||||||
|
|
||||||
// Find the new dimensions of the flat icon to fit the added overlay
|
// Find the new dimensions of the flat icon to fit the added overlay
|
||||||
addX1 = min(flatX1, I:pixel_x+1)
|
addX1 = min(flatX1, I:pixel_x+1)
|
||||||
@@ -722,30 +742,21 @@ proc
|
|||||||
addY1 = min(flatY1, I:pixel_y+1)
|
addY1 = min(flatY1, I:pixel_y+1)
|
||||||
addY2 = max(flatY2, I:pixel_y+add.Height())
|
addY2 = max(flatY2, I:pixel_y+add.Height())
|
||||||
|
|
||||||
if(I:color)
|
|
||||||
add.Blend(I:color, ICON_MULTIPLY)
|
|
||||||
if(I:alpha < 255)
|
|
||||||
add.Blend(rgb(255, 255, 255, I:alpha), ICON_MULTIPLY)
|
|
||||||
|
|
||||||
if(addX1!=flatX1 || addX2!=flatX2 || addY1!=flatY1 || addY2!=flatY2)
|
if(addX1!=flatX1 || addX2!=flatX2 || addY1!=flatY1 || addY2!=flatY2)
|
||||||
// Resize the flattened icon so the new icon fits
|
// Resize the flattened icon so the new icon fits
|
||||||
flat.Crop(addX1-flatX1+1, addY1-flatY1+1, addX2-flatX1+1, addY2-flatY1+1)
|
flat.Crop(addX1-flatX1+1, addY1-flatY1+1, addX2-flatX1+1, addY2-flatY1+1)
|
||||||
flatX1=addX1;flatX2=addX2
|
flatX1=addX1;flatX2=addX2
|
||||||
flatY1=addY1;flatY2=addY2
|
flatY1=addY1;flatY2=addY2
|
||||||
|
|
||||||
var/blendMode = I:blend_mode
|
|
||||||
if(blendMode == BLEND_DEFAULT)
|
|
||||||
blendMode = A.blend_mode
|
|
||||||
switch(blendMode)
|
|
||||||
if(BLEND_MULTIPLY) blendMode = ICON_MULTIPLY
|
|
||||||
if(BLEND_ADD) blendMode = ICON_ADD
|
|
||||||
if(BLEND_SUBTRACT) blendMode = ICON_SUBTRACT
|
|
||||||
else blendMode = ICON_OVERLAY
|
|
||||||
|
|
||||||
// Blend the overlay into the flattened icon
|
// Blend the overlay into the flattened icon
|
||||||
flat.Blend(add,blendMode,I:pixel_x+2-flatX1,I:pixel_y+2-flatY1)
|
flat.Blend(add, blendMode2iconMode(curblend), I:pixel_x + 2 - flatX1, I:pixel_y + 2 - flatY1)
|
||||||
|
|
||||||
return flat
|
if(A.color)
|
||||||
|
flat.Blend(A.color, ICON_MULTIPLY)
|
||||||
|
if(A.alpha < 255)
|
||||||
|
flat.Blend(rgb(255, 255, 255, A.alpha), ICON_MULTIPLY)
|
||||||
|
|
||||||
|
return icon(flat, "", SOUTH)
|
||||||
|
|
||||||
getIconMask(atom/A)//By yours truly. Creates a dynamic mask for a mob/whatever. /N
|
getIconMask(atom/A)//By yours truly. Creates a dynamic mask for a mob/whatever. /N
|
||||||
var/icon/alpha_mask = new(A.icon,A.icon_state)//So we want the default icon and icon state of A.
|
var/icon/alpha_mask = new(A.icon,A.icon_state)//So we want the default icon and icon state of A.
|
||||||
|
|||||||
@@ -265,6 +265,13 @@ proc/tg_list2text(list/list, glue=",")
|
|||||||
/proc/angle2text(var/degree)
|
/proc/angle2text(var/degree)
|
||||||
return dir2text(angle2dir(degree))
|
return dir2text(angle2dir(degree))
|
||||||
|
|
||||||
|
//Converts a blend_mode constant to one acceptable to icon.Blend()
|
||||||
|
/proc/blendMode2iconMode(blend_mode)
|
||||||
|
switch(blend_mode)
|
||||||
|
if(BLEND_MULTIPLY) return ICON_MULTIPLY
|
||||||
|
if(BLEND_ADD) return ICON_ADD
|
||||||
|
if(BLEND_SUBTRACT) return ICON_SUBTRACT
|
||||||
|
else return ICON_OVERLAY
|
||||||
|
|
||||||
//Converts a rights bitfield into a string
|
//Converts a rights bitfield into a string
|
||||||
/proc/rights2text(rights, seperator="", list/adds, list/subs)
|
/proc/rights2text(rights, seperator="", list/adds, list/subs)
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ var/record_id_num = 1001
|
|||||||
L.fields["b_dna"] = H.dna.unique_enzymes
|
L.fields["b_dna"] = H.dna.unique_enzymes
|
||||||
L.fields["enzymes"] = H.dna.struc_enzymes
|
L.fields["enzymes"] = H.dna.struc_enzymes
|
||||||
L.fields["identity"] = H.dna.uni_identity
|
L.fields["identity"] = H.dna.uni_identity
|
||||||
L.fields["image"] = getFlatIcon(H,0) //This is god-awful
|
L.fields["image"] = getFlatIcon(H) //This is god-awful
|
||||||
locked += L
|
locked += L
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,6 @@
|
|||||||
var/j
|
var/j
|
||||||
for(var/i = 1 to atoms.len)
|
for(var/i = 1 to atoms.len)
|
||||||
var/atom/c = atoms[i]
|
var/atom/c = atoms[i]
|
||||||
j = sorted.len
|
|
||||||
for(j = sorted.len, j > 0, --j)
|
for(j = sorted.len, j > 0, --j)
|
||||||
var/atom/c2 = sorted[j]
|
var/atom/c2 = sorted[j]
|
||||||
if(c2.layer <= c.layer)
|
if(c2.layer <= c.layer)
|
||||||
@@ -171,30 +170,19 @@
|
|||||||
if(istype(A, /mob/living) && A:lying)
|
if(istype(A, /mob/living) && A:lying)
|
||||||
img.Turn(A:lying)
|
img.Turn(A:lying)
|
||||||
|
|
||||||
var/blendMode = A.blend_mode
|
|
||||||
switch(blendMode)
|
|
||||||
if(BLEND_MULTIPLY) blendMode = ICON_MULTIPLY
|
|
||||||
if(BLEND_ADD) blendMode = ICON_ADD
|
|
||||||
if(BLEND_SUBTRACT) blendMode = ICON_SUBTRACT
|
|
||||||
else blendMode = ICON_OVERLAY
|
|
||||||
|
|
||||||
var/offX = 32 * (A.x - center.x) + A.pixel_x + 33
|
var/offX = 32 * (A.x - center.x) + A.pixel_x + 33
|
||||||
var/offY = 32 * (A.y - center.y) + A.pixel_y + 33
|
var/offY = 32 * (A.y - center.y) + A.pixel_y + 33
|
||||||
if(istype(A, /atom/movable))
|
if(istype(A, /atom/movable))
|
||||||
offX += A:step_x
|
offX += A:step_x
|
||||||
offY += A:step_y
|
offY += A:step_y
|
||||||
|
|
||||||
if(istype(img, /icon))
|
res.Blend(img, blendMode2iconMode(A.blend_mode), offX, offY)
|
||||||
res.Blend(new/icon(img, "", A.dir), blendMode, offX, offY)
|
|
||||||
|
|
||||||
if(istype(A, /obj/item/blueprints))
|
if(istype(A, /obj/item/blueprints))
|
||||||
blueprints = 1
|
blueprints = 1
|
||||||
|
|
||||||
for(var/turf/T in turfs)
|
for(var/turf/T in turfs)
|
||||||
//res.Blend(getFlatIcon(T.loc), ICON_OVERLAY, 32 * (T.x - center.x) + 33, 32 * (T.y - center.y) + 33)
|
res.Blend(getFlatIcon(T.loc), blendMode2iconMode(T.blend_mode), 32 * (T.x - center.x) + 33, 32 * (T.y - center.y) + 33)
|
||||||
var/image/shading = T.loc:lighting_overlay
|
|
||||||
if(istype(shading))
|
|
||||||
res.Blend(icon(shading.icon, shading.icon_state), ICON_OVERLAY, 32 * (T.x - center.x) + 33, 32 * (T.y - center.y) + 33)
|
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user