mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 03:33:21 +00:00
Revert "Fixes cameras making completely black photos"
This commit is contained in:
@@ -634,16 +634,26 @@ 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Creates a single icon from a given /atom or /image. Only the first argument is required.
|
// Creates a single icon from a given /atom or /image. Only the first argument is required.
|
||||||
/proc/getFlatIcon(image/A, defdir=2, deficon=null, defstate="", defblend=BLEND_DEFAULT, always_use_defdir = 0, picture_planes = list(PLANE_WORLD))
|
/proc/getFlatIcon(image/A, defdir, deficon, defstate, defblend, start = TRUE, no_anim = FALSE)
|
||||||
// We start with a blank canvas, otherwise some icon procs crash silently
|
// We start with a blank canvas, otherwise some icon procs crash silently
|
||||||
var/icon/flat = icon('icons/effects/effects.dmi', "icon_state"="nothing") // Final flattened icon
|
var/icon/flat = icon('icons/effects/effects.dmi', "nothing") // Final flattened icon
|
||||||
if(!A)
|
if(!A)
|
||||||
return flat
|
return flat
|
||||||
if(A.alpha <= 0)
|
if(A.alpha <= 0)
|
||||||
return flat
|
return flat
|
||||||
var/noIcon = FALSE
|
var/noIcon = FALSE
|
||||||
|
|
||||||
|
if(start)
|
||||||
|
if(!defdir)
|
||||||
|
defdir = A.dir
|
||||||
|
if(!deficon)
|
||||||
|
deficon = A.icon
|
||||||
|
if(!defstate)
|
||||||
|
defstate = A.icon_state
|
||||||
|
if(!defblend)
|
||||||
|
defblend = A.blend_mode
|
||||||
|
|
||||||
var/curicon
|
var/curicon
|
||||||
if(A.icon)
|
if(A.icon)
|
||||||
curicon = A.icon
|
curicon = A.icon
|
||||||
@@ -666,10 +676,31 @@ The _flatIcons list is a cache for generated icon files.
|
|||||||
noIcon = TRUE // Do not render this object.
|
noIcon = TRUE // Do not render this object.
|
||||||
|
|
||||||
var/curdir
|
var/curdir
|
||||||
if(A.dir != 2 && !always_use_defdir)
|
var/base_icon_dir //We'll use this to get the icon state to display if not null BUT NOT pass it to overlays as the dir we have
|
||||||
curdir = A.dir
|
|
||||||
else
|
//These should use the parent's direction (most likely)
|
||||||
|
if(!A.dir || A.dir == SOUTH)
|
||||||
curdir = defdir
|
curdir = defdir
|
||||||
|
else
|
||||||
|
curdir = A.dir
|
||||||
|
|
||||||
|
//Let's check if the icon actually contains any diagonals, just skip if it's south to save (lot of) time
|
||||||
|
if(curdir != SOUTH)
|
||||||
|
var/icon/test_icon
|
||||||
|
var/directionals_exist = FALSE
|
||||||
|
var/list/dirs_to_check = cardinal - SOUTH
|
||||||
|
outer:
|
||||||
|
for(var/possible_dir in dirs_to_check)
|
||||||
|
test_icon = icon(curicon,curstate,possible_dir,frame=1)
|
||||||
|
for(var/x in 1 to world.icon_size)
|
||||||
|
for(var/y in 1 to world.icon_size)
|
||||||
|
if(!isnull(test_icon.GetPixel(x,y)))
|
||||||
|
directionals_exist = TRUE
|
||||||
|
break outer
|
||||||
|
if(!directionals_exist)
|
||||||
|
base_icon_dir = SOUTH
|
||||||
|
if(!base_icon_dir)
|
||||||
|
base_icon_dir = curdir
|
||||||
|
|
||||||
var/curblend
|
var/curblend
|
||||||
if(A.blend_mode == BLEND_DEFAULT)
|
if(A.blend_mode == BLEND_DEFAULT)
|
||||||
@@ -677,12 +708,18 @@ The _flatIcons list is a cache for generated icon files.
|
|||||||
else
|
else
|
||||||
curblend = A.blend_mode
|
curblend = A.blend_mode
|
||||||
|
|
||||||
|
// Before processing overlays, make sure any pending overlays are applied
|
||||||
|
if (isloc(A))
|
||||||
|
var/atom/aAtom = A
|
||||||
|
if(aAtom.flags & OVERLAY_QUEUED)
|
||||||
|
COMPILE_OVERLAYS(aAtom)
|
||||||
|
|
||||||
// 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
|
var/image/copy
|
||||||
// Add the atom's icon itself, without pixel_x/y offsets.
|
// Add the atom's icon itself, without pixel_x/y offsets.
|
||||||
if(!noIcon)
|
if(!noIcon)
|
||||||
copy = image(icon=curicon, icon_state=curstate, layer=A.layer, dir=curdir)
|
copy = image(icon=curicon, icon_state=curstate, layer=A.layer, dir=base_icon_dir)
|
||||||
copy.color = A.color
|
copy.color = A.color
|
||||||
copy.alpha = A.alpha
|
copy.alpha = A.alpha
|
||||||
copy.blend_mode = curblend
|
copy.blend_mode = curblend
|
||||||
@@ -699,78 +736,71 @@ The _flatIcons list is a cache for generated icon files.
|
|||||||
while(TRUE)
|
while(TRUE)
|
||||||
if(curIndex<=process.len)
|
if(curIndex<=process.len)
|
||||||
current = process[curIndex]
|
current = process[curIndex]
|
||||||
if(current)
|
if(!current)
|
||||||
var/currentPlane = current:plane
|
curIndex++ //Try the next layer
|
||||||
if (currentPlane != FLOAT_PLANE && !(currentPlane in picture_planes))
|
continue
|
||||||
curIndex++
|
var/image/I = current
|
||||||
continue;
|
if(I.plane != FLOAT_PLANE && I.plane != A.plane)
|
||||||
currentLayer = current:layer
|
curIndex++
|
||||||
if(currentLayer<0) // Special case for FLY_LAYER
|
continue
|
||||||
if(currentLayer <= -1000) return flat
|
currentLayer = I.layer
|
||||||
if(pSet == 0) // Underlay
|
if(currentLayer<0) // Special case for FLOAT_LAYER
|
||||||
currentLayer = A.layer+currentLayer/1000
|
if(currentLayer <= -1000)
|
||||||
else // Overlay
|
return flat
|
||||||
currentLayer = A.layer+(1000+currentLayer)/1000
|
if(pSet == 0) // Underlay
|
||||||
|
currentLayer = A.layer+currentLayer/1000
|
||||||
|
else // Overlay
|
||||||
|
currentLayer = A.layer+(1000+currentLayer)/1000
|
||||||
|
|
||||||
// Sort add into layers list
|
// Sort add into layers list
|
||||||
for(cmpIndex=1,cmpIndex<=layers.len,cmpIndex++)
|
for(cmpIndex=1,cmpIndex<=layers.len,cmpIndex++)
|
||||||
compare = layers[cmpIndex]
|
compare = layers[cmpIndex]
|
||||||
if(currentLayer < layers[compare]) // Associated value is the calculated layer
|
if(currentLayer < layers[compare]) // Associated value is the calculated layer
|
||||||
layers.Insert(cmpIndex,current)
|
layers.Insert(cmpIndex,current)
|
||||||
layers[current] = currentLayer
|
layers[current] = currentLayer
|
||||||
break
|
break
|
||||||
if(cmpIndex>layers.len) // Reached end of list without inserting
|
if(cmpIndex>layers.len) // Reached end of list without inserting
|
||||||
layers[current]=currentLayer // Place at end
|
layers[current]=currentLayer // Place at end
|
||||||
|
|
||||||
curIndex++
|
curIndex++
|
||||||
else if(pSet == 0) // Switch to overlays
|
|
||||||
curIndex = 1
|
if(curIndex>process.len)
|
||||||
pSet = 1
|
if(pSet == 0) // Switch to overlays
|
||||||
process = A.overlays
|
curIndex = 1
|
||||||
else // All done
|
pSet = 1
|
||||||
break
|
process = A.overlays
|
||||||
|
else // All done
|
||||||
|
break
|
||||||
|
|
||||||
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
|
||||||
var/{flatX1=1;flatX2=flat.Width();flatY1=1;flatY2=flat.Height()}
|
var/flatX1=1
|
||||||
// Dimensions of overlay being added
|
var/flatX2=flat.Width()
|
||||||
var/{addX1;addX2;addY1;addY2}
|
var/flatY1=1
|
||||||
|
var/flatY2=flat.Height()
|
||||||
|
// Dimensions of overlay being added
|
||||||
|
var/addX1
|
||||||
|
var/addX2
|
||||||
|
var/addY1
|
||||||
|
var/addY2
|
||||||
|
|
||||||
for(var/I in layers)
|
for(var/V in layers)
|
||||||
|
var/image/I = V
|
||||||
if(I:alpha == 0)
|
if(I.alpha == 0)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if(I == copy) // 'I' is an /image based on the object being flattened.
|
if(I == copy) // 'I' is an /image based on the object being flattened.
|
||||||
curblend = BLEND_OVERLAY
|
curblend = BLEND_OVERLAY
|
||||||
add = icon(I:icon, I:icon_state, I:dir)
|
add = icon(I.icon, I.icon_state, base_icon_dir)
|
||||||
// This checks for a silent failure mode of the icon routine. If the requested dir
|
|
||||||
// doesn't exist in this icon state it returns a 32x32 icon with 0 alpha.
|
|
||||||
if (I:dir != SOUTH && add.Width() == 32 && add.Height() == 32)
|
|
||||||
// Check every pixel for blank (computationally expensive, but the process is limited
|
|
||||||
// by the amount of film on the station, only happens when we hit something that's
|
|
||||||
// turned, and bails at the very first pixel it sees.
|
|
||||||
var/blankpixel;
|
|
||||||
for(var/y;y<=32;y++)
|
|
||||||
for(var/x;x<32;x++)
|
|
||||||
blankpixel = isnull(add.GetPixel(x,y))
|
|
||||||
if(!blankpixel)
|
|
||||||
break
|
|
||||||
if(!blankpixel)
|
|
||||||
break
|
|
||||||
// If we ALWAYS returned a null (which happens when GetPixel encounters something with alpha 0)
|
|
||||||
if (blankpixel)
|
|
||||||
// Pull the default direction.
|
|
||||||
add = icon(I:icon, I:icon_state)
|
|
||||||
else // 'I' is an appearance object.
|
else // 'I' is an appearance object.
|
||||||
add = getFlatIcon(new/image(I), curdir, curicon, curstate, curblend, picture_planes = picture_planes)
|
add = getFlatIcon(new/image(I), curdir, curicon, curstate, curblend, FALSE, no_anim)
|
||||||
|
|
||||||
// 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)
|
||||||
addX2 = max(flatX2, I:pixel_x+add.Width())
|
addX2 = max(flatX2, I.pixel_x+add.Width())
|
||||||
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(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
|
||||||
@@ -779,14 +809,20 @@ The _flatIcons list is a cache for generated icon files.
|
|||||||
flatY1=addY1;flatY2=addY2
|
flatY1=addY1;flatY2=addY2
|
||||||
|
|
||||||
// Blend the overlay into the flattened icon
|
// Blend the overlay into the flattened icon
|
||||||
flat.Blend(add, blendMode2iconMode(curblend), 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)
|
||||||
|
|
||||||
if(A.color)
|
if(A.color)
|
||||||
flat.Blend(A.color, ICON_MULTIPLY)
|
flat.Blend(A.color, ICON_MULTIPLY)
|
||||||
if(A.alpha < 255)
|
if(A.alpha < 255)
|
||||||
flat.Blend(rgb(255, 255, 255, A.alpha), ICON_MULTIPLY)
|
flat.Blend(rgb(255, 255, 255, A.alpha), ICON_MULTIPLY)
|
||||||
|
|
||||||
return icon(flat, "", SOUTH)
|
if(no_anim)
|
||||||
|
//Clean up repeated frames
|
||||||
|
var/icon/cleaned = new /icon()
|
||||||
|
cleaned.Insert(flat, "", SOUTH, 1, 0)
|
||||||
|
return cleaned
|
||||||
|
else
|
||||||
|
return icon(flat, "", SOUTH)
|
||||||
|
|
||||||
/proc/getIconMask(atom/A)//By yours truly. Creates a dynamic mask for a mob/whatever. /N
|
/proc/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.
|
||||||
@@ -799,10 +835,10 @@ The _flatIcons list is a cache for generated icon files.
|
|||||||
|
|
||||||
//getFlatIcon but generates an icon that can face ALL four directions. The only four.
|
//getFlatIcon but generates an icon that can face ALL four directions. The only four.
|
||||||
/proc/getCompoundIcon(atom/A)
|
/proc/getCompoundIcon(atom/A)
|
||||||
var/icon/north = getFlatIcon(A,defdir=NORTH,always_use_defdir=1)
|
var/icon/north = getFlatIcon(A,defdir=NORTH)
|
||||||
var/icon/south = getFlatIcon(A,defdir=SOUTH,always_use_defdir=1)
|
var/icon/south = getFlatIcon(A,defdir=SOUTH)
|
||||||
var/icon/east = getFlatIcon(A,defdir=EAST,always_use_defdir=1)
|
var/icon/east = getFlatIcon(A,defdir=EAST)
|
||||||
var/icon/west = getFlatIcon(A,defdir=WEST,always_use_defdir=1)
|
var/icon/west = getFlatIcon(A,defdir=WEST)
|
||||||
|
|
||||||
//Starts with a blank icon because of byond bugs.
|
//Starts with a blank icon because of byond bugs.
|
||||||
var/icon/full = icon('icons/effects/effects.dmi', "icon_state"="nothing")
|
var/icon/full = icon('icons/effects/effects.dmi', "icon_state"="nothing")
|
||||||
@@ -818,7 +854,7 @@ The _flatIcons list is a cache for generated icon files.
|
|||||||
return full
|
return full
|
||||||
|
|
||||||
/proc/downloadImage(atom/A, dir)
|
/proc/downloadImage(atom/A, dir)
|
||||||
var/icon/this_icon = getFlatIcon(A,defdir=dir||A.dir,always_use_defdir=1)
|
var/icon/this_icon = getFlatIcon(A,defdir=dir)
|
||||||
|
|
||||||
usr << ftp(this_icon,"[A.name].png")
|
usr << ftp(this_icon,"[A.name].png")
|
||||||
|
|
||||||
@@ -886,7 +922,8 @@ proc/sort_atoms_by_layer(var/list/atoms)
|
|||||||
/proc/gen_hud_image(var/file, var/person, var/state, var/plane)
|
/proc/gen_hud_image(var/file, var/person, var/state, var/plane)
|
||||||
var/image/img = image(file, person, state)
|
var/image/img = image(file, person, state)
|
||||||
img.plane = plane //Thanks Byond.
|
img.plane = plane //Thanks Byond.
|
||||||
img.appearance_flags = APPEARANCE_UI|KEEP_APART
|
img.layer = MOB_LAYER-0.2
|
||||||
|
img.appearance_flags = APPEARANCE_UI
|
||||||
return img
|
return img
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user