From df3fcbc9b23039d6dd81bf32a209f109b16526fa Mon Sep 17 00:00:00 2001 From: JimTheCactus Date: Mon, 28 Jul 2014 11:54:01 -0600 Subject: [PATCH] Ported nearest-neighbor scaling from TG --- code/__HELPERS/icons.dm | 19 +++++++++++++++++++ code/modules/paperwork/photography.dm | 25 +++++++++---------------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/code/__HELPERS/icons.dm b/code/__HELPERS/icons.dm index 8c400df60c..e7a6bbba96 100644 --- a/code/__HELPERS/icons.dm +++ b/code/__HELPERS/icons.dm @@ -836,3 +836,22 @@ proc/adjust_brightness(var/color, var/value) RGB[2] = Clamp(RGB[2]+value,0,255) RGB[3] = Clamp(RGB[3]+value,0,255) return rgb(RGB[1],RGB[2],RGB[3]) + +proc/sort_atoms_by_layer(var/list/atoms) + // Comb sort icons based on levels + var/list/result = atoms.Copy() + var/gap = result.len + var/swapped = 1 + while (gap > 1 || swapped) + swapped = 0 + if(gap > 1) + gap = round(gap / 1.3) // 1.3 is the emperic comb sort coefficient + if(gap < 1) + gap = 1 + for(var/i = 1; gap + i <= result.len; i++) + var/atom/l = result[i] //Fucking hate + var/atom/r = result[gap+i] //how lists work here + if(l.layer > r.layer) //no "result[i].layer" for me + result.Swap(i, gap + i) + swapped = 1 + return result diff --git a/code/modules/paperwork/photography.dm b/code/modules/paperwork/photography.dm index 948b023ac4..da6edc63ea 100644 --- a/code/modules/paperwork/photography.dm +++ b/code/modules/paperwork/photography.dm @@ -53,10 +53,10 @@ /obj/item/weapon/photo/proc/show(mob/user as mob) user << browse_rsc(img, "tmp_photo.png") user << browse("[name]" \ - + "" \ - + "
Written on the back:
[scribble]" : ]"\ - + "", "window=book;size=200x[scribble ? 400 : 200]") + + "" \ + + "" \ + + "[scribble ? "
Written on the back:
[scribble]" : ""]"\ + + "", "window=book;size=192x[scribble ? 400 : 192]") onclose(user, "[name]") return @@ -164,18 +164,8 @@ if(A.invisibility) continue atoms.Add(A) - //Sorting icons based on levels. - //JMO: I have no idea what they were doing here before, but the magic number alone - // was worth replacing it over. "gap = round(gap / 1.247330950103979)" really? - var/list/sorted = list() - var/j - for(var/i = 1 to atoms.len) - var/atom/c = atoms[i] - for(j = sorted.len, j > 0, --j) - var/atom/c2 = sorted[j] - if(c2.layer <= c.layer) - break - sorted.Insert(j+1, c) + // Sort the atoms into their layers + var/list/sorted = sort_atoms_by_layer(atoms) for(var/i; i <= sorted.len; i++) var/atom/A = sorted[i] @@ -220,6 +210,9 @@ var/icon/temp = icon('icons/effects/96x96.dmi',"") var/icon/black = icon('icons/turf/space.dmi', "black") + // Initialize the photograph to black. + temp.Blend("#000", ICON_OVERLAY) + var/mobs = "" for(var/i = 1; i <= 3; i++) for(var/j = 1; j <= 3; j++)