diff --git a/code/game/objects/effects/spawners/windowspawner.dm b/code/game/objects/effects/spawners/windowspawner.dm
index 1d498888588..20f43f6eea2 100644
--- a/code/game/objects/effects/spawners/windowspawner.dm
+++ b/code/game/objects/effects/spawners/windowspawner.dm
@@ -59,6 +59,12 @@
window_to_spawn_regular = /obj/structure/window/reinforced/tinted
window_to_spawn_full = /obj/structure/window/full/reinforced/tinted
+/obj/effect/spawner/window/reinforced/polarized
+ name = "electrochromic reinforced window spawner"
+ icon_state = "pwindow_spawner"
+ window_to_spawn_regular = /obj/structure/window/reinforced/polarized
+ window_to_spawn_full = /obj/structure/window/full/reinforced/polarized
+
/obj/effect/spawner/window/shuttle
name = "shuttle window spawner"
icon_state = "swindow_spawner"
diff --git a/code/game/objects/items/mountable_frames/buttons_switches.dm b/code/game/objects/items/mountable_frames/buttons_switches.dm
index 76e4f0ecfd4..30b77ea2f33 100644
--- a/code/game/objects/items/mountable_frames/buttons_switches.dm
+++ b/code/game/objects/items/mountable_frames/buttons_switches.dm
@@ -21,3 +21,11 @@
/obj/item/mounted/frame/light_switch/do_build(turf/on_wall, mob/user)
new /obj/machinery/light_switch(get_turf(user), get_dir(user, on_wall))
qdel(src)
+
+/obj/item/mounted/frame/light_switch/windowtint
+ name = "window tint control button frame"
+ desc = "Used for repairing or building window tint control buttons"
+
+/obj/item/mounted/frame/light_switch/windowtint/do_build(turf/on_wall, mob/user)
+ new /obj/machinery/button/windowtint(get_turf(user), get_dir(user, on_wall))
+ qdel(src)
diff --git a/code/game/objects/items/stacks/sheets/glass.dm b/code/game/objects/items/stacks/sheets/glass.dm
index c9901c8b0fe..1f8ae46083e 100644
--- a/code/game/objects/items/stacks/sheets/glass.dm
+++ b/code/game/objects/items/stacks/sheets/glass.dm
@@ -89,7 +89,10 @@ GLOBAL_LIST_INIT(reinforced_glass_recipes, list ( \
new/datum/stack_recipe/window("windoor frame", /obj/structure/windoor_assembly, 5, time = 0, on_floor = TRUE, window_checks = TRUE), \
null, \
new/datum/stack_recipe/window("directional reinforced window", /obj/structure/window/reinforced, time = 0, on_floor = TRUE, window_checks = TRUE), \
- new/datum/stack_recipe/window("fulltile reinforced window", /obj/structure/window/full/reinforced, 2, time = 0, on_floor = TRUE, window_checks = TRUE) \
+ new/datum/stack_recipe/window("fulltile reinforced window", /obj/structure/window/full/reinforced, 2, time = 0, on_floor = TRUE, window_checks = TRUE), \
+ null, \
+ new/datum/stack_recipe/window("directional electrochromic window", /obj/structure/window/reinforced/polarized, 2, time = 0, on_floor = TRUE, window_checks = TRUE), \
+ new/datum/stack_recipe/window("fulltile electrochromic window", /obj/structure/window/full/reinforced/polarized, 4, time = 0, on_floor = TRUE, window_checks = TRUE) \
))
/obj/item/stack/sheet/rglass
diff --git a/code/game/objects/items/stacks/sheets/sheet_types.dm b/code/game/objects/items/stacks/sheets/sheet_types.dm
index c617860643e..2e5b492684b 100644
--- a/code/game/objects/items/stacks/sheets/sheet_types.dm
+++ b/code/game/objects/items/stacks/sheets/sheet_types.dm
@@ -92,6 +92,7 @@ GLOBAL_LIST_INIT(metal_recipes, list(
null,
new /datum/stack_recipe("mass driver button frame", /obj/item/mounted/frame/driver_button, 1, time = 50, one_per_turf = 0, on_floor = 1),
new /datum/stack_recipe("light switch frame", /obj/item/mounted/frame/light_switch, 1, time = 50, one_per_turf = 0, on_floor = 1),
+ new /datum/stack_recipe("window tint control button frame", /obj/item/mounted/frame/light_switch/windowtint, 1, time = 50, one_per_turf = 0, on_floor = 1),
null,
new /datum/stack_recipe("grenade casing", /obj/item/grenade/chem_grenade),
new /datum/stack_recipe("light fixture frame", /obj/item/mounted/frame/light_fixture, 2),
diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm
index a2d13ad8afb..7872c395d1e 100644
--- a/code/game/objects/structures/window.dm
+++ b/code/game/objects/structures/window.dm
@@ -27,6 +27,8 @@
var/real_explosion_block //ignore this, just use explosion_block
var/breaksound = "shatter"
var/hitsound = 'sound/effects/Glasshit.ogg'
+ /// Used to restore colours from polarised glass
+ var/old_color
/obj/structure/window/examine(mob/user)
. = ..()
@@ -69,6 +71,17 @@
air_update_turf(TRUE)
+/obj/structure/window/proc/toggle_polarization()
+ if(opacity)
+ if(!old_color)
+ old_color = "#FFFFFF"
+ animate(src, color = old_color, time = 0.5 SECONDS)
+ set_opacity(FALSE)
+ else
+ old_color = color
+ animate(src, color = "#222222", time = 0.5 SECONDS)
+ set_opacity(TRUE)
+
/obj/structure/window/narsie_act()
color = NARSIE_WINDOW_COLOUR
@@ -497,14 +510,6 @@
desc = "Adjusts its tint with voltage. Might take a few good hits to shatter it."
var/id
-/obj/structure/window/reinforced/polarized/proc/toggle()
- if(opacity)
- animate(src, color="#FFFFFF", time=5)
- set_opacity(0)
- else
- animate(src, color="#222222", time=5)
- set_opacity(1)
-
/obj/machinery/button/windowtint
name = "window tint control"
icon = 'icons/obj/power.dmi'
@@ -514,12 +519,35 @@
var/id = 0
var/active = 0
+/obj/machinery/button/windowtint/Initialize(mapload, w_dir = null)
+ . = ..()
+ switch(w_dir)
+ if(NORTH)
+ pixel_y = 25
+ if(SOUTH)
+ pixel_y = -25
+ if(EAST)
+ pixel_x = 25
+ if(WEST)
+ pixel_x = -25
+
/obj/machinery/button/windowtint/attack_hand(mob/user)
if(..())
- return 1
+ return TRUE
toggle_tint()
+/obj/machinery/button/windowtint/wrench_act(mob/user, obj/item/I)
+ . = TRUE
+ if(!I.tool_use_check(user, 0))
+ return
+ user.visible_message("[user] starts unwrenching [src] from the wall...", "You are unwrenching [src] from the wall...", "You hear ratcheting.")
+ if(!I.use_tool(src, user, 50, volume = I.tool_volume))
+ return
+ WRENCH_UNANCHOR_WALL_MESSAGE
+ new /obj/item/mounted/frame/light_switch/windowtint(get_turf(src))
+ qdel(src)
+
/obj/machinery/button/windowtint/proc/toggle_tint()
use_power(5)
@@ -528,9 +556,11 @@
for(var/obj/structure/window/reinforced/polarized/W in range(src,range))
if(W.id == src.id || !W.id)
- spawn(0)
- W.toggle()
- return
+ W.toggle_polarization()
+
+ for(var/obj/structure/window/full/reinforced/polarized/W in range(src, range))
+ if(W.id == id || !W.id)
+ W.toggle_polarization()
/obj/machinery/button/windowtint/power_change()
..()
@@ -589,7 +619,7 @@
icon_state = "window"
max_integrity = 50
smooth = SMOOTH_TRUE
- canSmoothWith = list(/obj/structure/window/full/basic, /obj/structure/window/full/reinforced, /obj/structure/window/full/reinforced/tinted, /obj/structure/window/full/plasmabasic, /obj/structure/window/full/plasmareinforced, /turf/simulated/wall/indestructible/fakeglass)
+ canSmoothWith = list(/obj/structure/window/full/basic, /obj/structure/window/full/reinforced, /obj/structure/window/full/reinforced/polarized, /obj/structure/window/full/reinforced/tinted, /obj/structure/window/full/plasmabasic, /obj/structure/window/full/plasmareinforced, /turf/simulated/wall/indestructible/fakeglass)
/obj/structure/window/full/plasmabasic
name = "plasma window"
@@ -602,7 +632,7 @@
heat_resistance = 32000
max_integrity = 300
smooth = SMOOTH_TRUE
- canSmoothWith = list(/obj/structure/window/full/basic, /obj/structure/window/full/reinforced, /obj/structure/window/full/reinforced/tinted, /obj/structure/window/full/plasmabasic, /obj/structure/window/full/plasmareinforced, /turf/simulated/wall/indestructible/fakeglass)
+ canSmoothWith = list(/obj/structure/window/full/basic, /obj/structure/window/full/reinforced, /obj/structure/window/full/reinforced/polarized, /obj/structure/window/full/reinforced/tinted, /obj/structure/window/full/plasmabasic, /obj/structure/window/full/plasmareinforced, /turf/simulated/wall/indestructible/fakeglass)
explosion_block = 1
armor = list("melee" = 75, "bullet" = 5, "laser" = 0, "energy" = 0, "bomb" = 45, "bio" = 100, "rad" = 100, "fire" = 99, "acid" = 100)
rad_insulation = RAD_NO_INSULATION
@@ -616,7 +646,7 @@
shardtype = /obj/item/shard/plasma
glass_type = /obj/item/stack/sheet/plasmarglass
smooth = SMOOTH_TRUE
- canSmoothWith = list(/obj/structure/window/full/basic, /obj/structure/window/full/reinforced, /obj/structure/window/full/reinforced/tinted, /obj/structure/window/full/plasmabasic, /obj/structure/window/full/plasmareinforced, /turf/simulated/wall/indestructible/fakeglass)
+ canSmoothWith = list(/obj/structure/window/full/basic, /obj/structure/window/full/reinforced, /obj/structure/window/full/reinforced/polarized, /obj/structure/window/full/reinforced/tinted, /obj/structure/window/full/plasmabasic, /obj/structure/window/full/plasmareinforced, /turf/simulated/wall/indestructible/fakeglass)
reinf = TRUE
max_integrity = 1000
explosion_block = 2
@@ -632,7 +662,7 @@
icon = 'icons/obj/smooth_structures/reinforced_window.dmi'
icon_state = "r_window"
smooth = SMOOTH_TRUE
- canSmoothWith = list(/obj/structure/window/full/basic, /obj/structure/window/full/reinforced, /obj/structure/window/full/reinforced/tinted, /obj/structure/window/full/plasmabasic, /obj/structure/window/full/plasmareinforced, /turf/simulated/wall/indestructible/fakeglass)
+ canSmoothWith = list(/obj/structure/window/full/basic, /obj/structure/window/full/reinforced, /obj/structure/window/full/reinforced/polarized, /obj/structure/window/full/reinforced/tinted, /obj/structure/window/full/plasmabasic, /obj/structure/window/full/plasmareinforced, /turf/simulated/wall/indestructible/fakeglass)
max_integrity = 100
reinf = TRUE
heat_resistance = 1600
@@ -641,6 +671,11 @@
explosion_block = 1
glass_type = /obj/item/stack/sheet/rglass
+/obj/structure/window/full/reinforced/polarized
+ name = "electrochromic window"
+ desc = "Adjusts its tint with voltage. Might take a few good hits to shatter it."
+ var/id
+
/obj/structure/window/full/reinforced/tinted
name = "tinted window"
desc = "It looks rather strong and opaque. Might take a few good hits to shatter it."