ID:1918720
 
I was in the middle of working on a combat system when I needed maptext to better demonstrate the transition between combat "states" (e.g. neutral, melee mode, ...). No doubt I'll likely put this to use for other things as well (such as on-screen dialogue).

I decided to share since there was a question posted recently about this exact topic. That topic was of use to me, so I'm sure there are others who will find this handy.

proc/shadowed_maptext(text, text_color = "#fff", x = 0, y = 0, width = 256, height = 256, offset = 1, shadow_dir = SOUTH, shadow_color = "#000")
var obj/temp = new/obj
temp.maptext = "<span style=\"color:[shadow_color];\">[text]</span>"
temp.maptext_width = width
temp.maptext_height = height
temp.maptext_x = x + ((shadow_dir & (EAST | WEST)) ? ((shadow_dir & EAST && offset) || -offset) : (0))
temp.maptext_y = y + ((shadow_dir & (NORTH | SOUTH)) ? ((shadow_dir & NORTH && offset) || -offset) : (0))
temp.underlays += temp.appearance

temp.maptext = "<span style=\"color:[text_color];\">[text]</span>"
temp.maptext_x = 0
temp.maptext_y = 0
temp.layer = MOB_LAYER + 1
temp.overlays += temp.appearance
return temp


Here's an example of how it's used:

proc/stun_maptext(turf/effect_loc, atom/movable/ref, fade_time = 10)
var obj/o = shadowed_maptext(span("stun_graphic", "Stunned!"))
o.loc = effect_loc
if(ref) o.SetCenter(ref.Cx(), ref.Cy(), ref.z)
animate(o, pixel_y = o.pixel_y + tiles(1), alpha = 0, time = fade_time)
new/timed_event(fade_time, "soft_dispose", o)


Edit: Minor edit switching from using the color variable to using inline CSS.
Testing this, it seems to have an issue with not creating the shadow until partway through any word.





Used your vanilla code, but sent those values to text.
In response to Albro1
May I see the code?
Just opened up a test environment and plugged this in.

/*
These are simple defaults for your project.
*/


world
fps = 25 // 25 frames per second
icon_size = 32 // 32x32 icon size by default

view = 6 // show up to 6 tiles outward from center (13x13 view)


// Make objects move 8 pixels per tick when walking

mob
step_size = 8
var/obj/maptext_name
Login()
..()
loc = locate(5,5,1)
src.maptext_name = shadowed_maptext("Albro123456")
maptext_name.loc = locate(5,5,1)

obj
step_size = 8

atom
icon = 'icon.dmi'

proc/shadowed_maptext(text, text_color = "#fff", x = 0, y = 0, width = 256, height = 256, offset = 1, shadow_dir = SOUTH, shadow_color = "#000")
var obj/temp = new/obj
temp.maptext = "<span style=\"color:[shadow_color];\">[text]</span>"
temp.maptext_width = width
temp.maptext_height = height
temp.maptext_x = x + ((shadow_dir & (EAST | WEST)) ? ((shadow_dir & EAST && offset) || -offset) : (0))
temp.maptext_y = y + ((shadow_dir & (NORTH | SOUTH)) ? ((shadow_dir & NORTH && offset) || -offset) : (0))
temp.layer = FLOAT_LAYER
temp.underlays += temp.appearance

temp.maptext = "<span style=\"color:[text_color];\">[text]</span>"
temp.maptext_x = 0
temp.maptext_y = 0
temp.layer = MOB_LAYER + 1
temp.overlays += temp.appearance
return temp
In response to Albro1
I had no problems. Are you using the latest beta build?
Yes, I am.
In response to Albro1


I'm thinking the issue lies in the project you were using. I can't seem to replicate the problem.
Strange, I have no clue why only my project is doing this. The code above is the only code in the entire environment. The result has not changed.
Upon testing it with new directions a bit more, I do seem to get a small outline on SOUTHWEST and WEST - but it is just a small 1-2 pixel block sticking off of the "A", and nothing more.

EDIT: I created an interface file and used 11pt Courier New as a different font. The result gave me an outline around the "ro", but still nothing on "Alb".
In response to Albro1
I didn't have an interface included in the first run, I made a fresh one as you did though and used the same font:



Also tested it on my VPS (runs Windows 2008 64-bit) and got the same result. My main computer runs Windows 7 Pro 64-bit. I wrote and tested this using a old Macbook and the webclient. Even did a run without hardware mode and nothing.

No idea what's going on to say the least.
In response to FKI
Well, I'm running Windows 10. Perhaps that is the issue?
In response to Albro1
I really wouldn't doubt it. I remember Lummox saying somewhere that there wasn't a sufficient way of testing Windows 10 yet. I don't know if that's still the case, but I wouldn't rule the OS out entirely.

Sucks I couldn't help, hope you find a solution or a workaround that's just as good, if not better though.
I'm on windows 10 and plugged in the same code as Albro1 and experienced the same issue.



EDIT: Might be time for a bug report.
In response to Lavenblade
Indeed. Thanks for confirming it. I'll make the post right now before I forget.

Edit: Did you guys use DS, the webclient, or both during your tests? If it's not too much to ask, if I could get one of you to try both for the report, I'd appreciate it.
I think another relevant and helpful piece of information might be our graphics card. I'll start with my specs:



To open that window, I went to the Start Menu -> Run -> typed 'dxdiag'.

When I do make the bug report (after, and IF, we find a lead to the cause), I'll just link back to this topic and request these posts be moved there.




Edit: I have an appointment today, so I'll try and test out the web client. I'm going to guess that it'll be fine though.

Edit2: Webclient-
In response to Lavenblade
Lavenblade wrote:
Edit2: Webclient-

I've also encountered this on my ancient AMD HD6870 in the webclient.