-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
bm_mode.dm
98 lines (80 loc) · 2.55 KB
/
bm_mode.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/// Corner A area section for buildmode
#define AREASELECT_CORNERA "corner A"
/// Corner B area selection for buildmode
#define AREASELECT_CORNERB "corner B"
/datum/buildmode_mode
var/key = "oops"
var/datum/buildmode/BM
// would corner selection work better as a component?
var/use_corner_selection = FALSE
var/list/preview
var/turf/cornerA
var/turf/cornerB
/datum/buildmode_mode/New(datum/buildmode/BM)
src.BM = BM
preview = list()
return ..()
/datum/buildmode_mode/Destroy()
cornerA = null
cornerB = null
QDEL_LIST(preview)
preview = null
return ..()
/datum/buildmode_mode/proc/enter_mode(datum/buildmode/BM)
return
/datum/buildmode_mode/proc/exit_mode(datum/buildmode/BM)
return
/datum/buildmode_mode/proc/get_button_iconstate()
return "buildmode_[key]"
/datum/buildmode_mode/proc/show_help(client/c)
CRASH("No help defined, yell at a coder")
/datum/buildmode_mode/proc/change_settings(client/c)
to_chat(c, span_warning("There is no configuration available for this mode"))
return
/datum/buildmode_mode/proc/Reset()
deselect_region()
/datum/buildmode_mode/proc/select_tile(turf/T, corner_to_select)
var/overlaystate
BM.holder.images -= preview
switch(corner_to_select)
if(AREASELECT_CORNERA)
overlaystate = "greenOverlay"
if(AREASELECT_CORNERB)
overlaystate = "blueOverlay"
var/image/I = image('icons/turf/overlays.dmi', T, overlaystate)
I.plane = ABOVE_LIGHTING_PLANE
preview += I
BM.holder.images += preview
return T
/datum/buildmode_mode/proc/highlight_region(region)
BM.holder.images -= preview
for(var/t in region)
var/image/I = image('icons/turf/overlays.dmi', t, "redOverlay")
I.plane = ABOVE_LIGHTING_PLANE
preview += I
BM.holder.images += preview
/datum/buildmode_mode/proc/deselect_region()
BM.holder.images -= preview
preview.Cut()
cornerA = null
cornerB = null
/datum/buildmode_mode/proc/handle_click(client/c, params, object)
var/list/modifiers = params2list(params)
if(use_corner_selection)
if(LAZYACCESS(modifiers, LEFT_CLICK))
if(!cornerA)
cornerA = select_tile(get_turf(object), AREASELECT_CORNERA)
return
if(cornerA && !cornerB)
cornerB = select_tile(get_turf(object), AREASELECT_CORNERB)
to_chat(c, span_boldwarning("Region selected, if you're happy with your selection left click again, otherwise right click."))
return
handle_selected_area(c, params)
deselect_region()
else
to_chat(c, span_notice("Region selection canceled!"))
deselect_region()
return
/datum/buildmode_mode/proc/handle_selected_area(client/c, params)
#undef AREASELECT_CORNERA
#undef AREASELECT_CORNERB