Alien Ruin fix, various cherrypicked upstream fixes
Also adds new buildmode
This commit is contained in:
@@ -0,0 +1,215 @@
|
||||
# Buildmode
|
||||
|
||||
## Code layout
|
||||
|
||||
### Buildmode
|
||||
|
||||
Manager for buildmode modes. Contains logic to manage switching between each mode, and presenting a suitable user interface.
|
||||
|
||||
### Effects
|
||||
|
||||
Special graphics used by buildmode modes for user interface purposes.
|
||||
|
||||
### Buildmode Mode
|
||||
|
||||
Implementer of buildmode behaviors.
|
||||
|
||||
Existing varieties:
|
||||
|
||||
+ Basic
|
||||
|
||||
**Description**:
|
||||
|
||||
Allows creation of simple structures consisting of floors, walls, windows, and airlocks.
|
||||
|
||||
**Controls**:
|
||||
|
||||
+ *Left click a turf*:
|
||||
|
||||
"Upgrades" the turf based on the following rules below:
|
||||
|
||||
+ Space -> Tiled floor
|
||||
+ Simulated floor -> Regular wall
|
||||
+ Wall -> Reinforced wall
|
||||
|
||||
+ *Right click a turf*:
|
||||
|
||||
"Downgrades" the turf based on the following rules below:
|
||||
|
||||
+ Reinforced wall -> Regular wall
|
||||
+ Wall -> Tiled floor
|
||||
+ Simulated floor -> Space
|
||||
|
||||
+ *Right click an object*:
|
||||
|
||||
Deletes the clicked object.
|
||||
|
||||
+ *Alt+Left click a location*:
|
||||
|
||||
Places an airlock at the clicked location.
|
||||
|
||||
+ *Ctrl+Left click a location*:
|
||||
|
||||
Places a window at the clicked location.
|
||||
|
||||
+ Advanced
|
||||
|
||||
**Description**:
|
||||
|
||||
Creates an instance of a configurable atom path where you click.
|
||||
|
||||
**Controls**:
|
||||
|
||||
+ *Right click on the mode selector*:
|
||||
|
||||
Choose a path to spawn.
|
||||
|
||||
+ *Left click a location* (requires chosen path):
|
||||
|
||||
Place an instance of the chosen path at the location.
|
||||
|
||||
+ *Right click an object*:
|
||||
|
||||
Delete the object.
|
||||
|
||||
+ Fill
|
||||
|
||||
**Description**:
|
||||
|
||||
Creates an instance of an atom path on every tile in a chosen region.
|
||||
|
||||
With a special control input, instead deletes everything within the region.
|
||||
|
||||
**Controls**:
|
||||
|
||||
+ *Right click on the mode selector*:
|
||||
|
||||
Choose a path to spawn.
|
||||
|
||||
+ *Left click on a region* (requires chosen path):
|
||||
|
||||
Fill the region with the chosen path.
|
||||
|
||||
+ *Alt+Left click on a region*:
|
||||
|
||||
Deletes everything within the region.
|
||||
|
||||
+ *Right click during region selection*:
|
||||
|
||||
Cancel region selection.
|
||||
|
||||
+ Copy
|
||||
|
||||
**Description**:
|
||||
|
||||
Take an existing object in the world, and place duplicates with identical attributes where you click.
|
||||
|
||||
May not always work nicely - "deep" variables such as lists or datums may malfunction.
|
||||
|
||||
**Controls**:
|
||||
|
||||
+ *Right click an existing object*:
|
||||
|
||||
Select the clicked object as a template.
|
||||
|
||||
+ *Left click a location* (Requires a selected object as template):
|
||||
|
||||
Place a duplicate of the template at the clicked location.
|
||||
|
||||
+ Area Edit
|
||||
|
||||
**Description**:
|
||||
|
||||
Modifies and creates areas.
|
||||
|
||||
The active area will be highlighted in yellow.
|
||||
|
||||
**Controls**:
|
||||
|
||||
+ *Right click the mode selector*:
|
||||
|
||||
Create a new area, and make it active.
|
||||
|
||||
+ *Right click an existing area*:
|
||||
|
||||
Make the clicked area active.
|
||||
|
||||
+ *Left click a turf*:
|
||||
|
||||
When an area is active, adds the turf to the active area.
|
||||
|
||||
+ Var Edit
|
||||
|
||||
**Description**:
|
||||
|
||||
Allows for setting and resetting variables of objects with a click.
|
||||
|
||||
If the object does not have the var, will do nothing and print a warning message.
|
||||
|
||||
**Controls**:
|
||||
|
||||
+ *Right click the mode selector*:
|
||||
|
||||
Choose which variable to set, and what to set it to.
|
||||
|
||||
+ *Left click an atom*:
|
||||
|
||||
Change the clicked atom's variables as configured.
|
||||
|
||||
+ *Right click an atom*:
|
||||
|
||||
Reset the targeted variable to its original value in the code.
|
||||
|
||||
+ Map Generator
|
||||
|
||||
**Description**:
|
||||
|
||||
Fills rectangular regions with algorithmically generated content. Right click during region selection to cancel.
|
||||
|
||||
See the `procedural_mapping` module for the generators themselves.
|
||||
|
||||
**Controls**:
|
||||
|
||||
+ *Right-click on the mode selector*:
|
||||
|
||||
Select a map generator from all the generators present in the codebase.
|
||||
|
||||
+ *Left click two corners of an area*:
|
||||
|
||||
Use the generator to populate the region.
|
||||
|
||||
+ *Right click during region selection*:
|
||||
|
||||
Cancel region selection.
|
||||
|
||||
+ Throwing
|
||||
|
||||
**Description**:
|
||||
|
||||
Select an object with left click, and right click to throw it towards where you clicked.
|
||||
|
||||
**Controls**:
|
||||
|
||||
+ *Left click on a movable atom*:
|
||||
|
||||
Select the atom for throwing.
|
||||
|
||||
+ *Right click on a location*:
|
||||
|
||||
Throw the selected atom towards that location.
|
||||
|
||||
+ Boom
|
||||
|
||||
**Description**:
|
||||
|
||||
Make explosions where you click.
|
||||
|
||||
**Controls**:
|
||||
|
||||
+ *Right click the mode selector*:
|
||||
|
||||
Configure the explosion size.
|
||||
|
||||
+ *Left click a location*:
|
||||
|
||||
Cause an explosion where you clicked.
|
||||
@@ -0,0 +1,91 @@
|
||||
/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 class='warning'>There is no configuration available for this mode</span>")
|
||||
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/pa = params2list(params)
|
||||
var/left_click = pa.Find("left")
|
||||
if(use_corner_selection)
|
||||
if(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 class='boldwarning'>Region selected, if you're happy with your selection left click again, otherwise right click.</span>")
|
||||
return
|
||||
handle_selected_area(c, params)
|
||||
deselect_region()
|
||||
else
|
||||
to_chat(c, "<span class='notice'>Region selection canceled!</span>")
|
||||
deselect_region()
|
||||
return
|
||||
|
||||
/datum/buildmode_mode/proc/handle_selected_area(client/c, params)
|
||||
@@ -0,0 +1,161 @@
|
||||
#define BM_SWITCHSTATE_NONE 0
|
||||
#define BM_SWITCHSTATE_MODE 1
|
||||
#define BM_SWITCHSTATE_DIR 2
|
||||
|
||||
/datum/buildmode
|
||||
var/build_dir = SOUTH
|
||||
var/datum/buildmode_mode/mode
|
||||
var/client/holder
|
||||
|
||||
// login callback
|
||||
var/li_cb
|
||||
|
||||
// SECTION UI
|
||||
var/list/buttons
|
||||
|
||||
// Switching management
|
||||
var/switch_state = BM_SWITCHSTATE_NONE
|
||||
var/switch_width = 5
|
||||
// modeswitch UI
|
||||
var/obj/screen/buildmode/mode/modebutton
|
||||
var/list/modeswitch_buttons = list()
|
||||
// dirswitch UI
|
||||
var/obj/screen/buildmode/bdir/dirbutton
|
||||
var/list/dirswitch_buttons = list()
|
||||
|
||||
/datum/buildmode/New(client/c)
|
||||
mode = new /datum/buildmode_mode/basic(src)
|
||||
holder = c
|
||||
buttons = list()
|
||||
li_cb = CALLBACK(src, .proc/post_login)
|
||||
holder.player_details.post_login_callbacks += li_cb
|
||||
holder.show_popup_menus = FALSE
|
||||
create_buttons()
|
||||
holder.screen += buttons
|
||||
holder.click_intercept = src
|
||||
mode.enter_mode(src)
|
||||
|
||||
/datum/buildmode/proc/quit()
|
||||
mode.exit_mode(src)
|
||||
holder.screen -= buttons
|
||||
holder.click_intercept = null
|
||||
holder.show_popup_menus = TRUE
|
||||
qdel(src)
|
||||
|
||||
/datum/buildmode/Destroy()
|
||||
close_switchstates()
|
||||
holder.player_details.post_login_callbacks -= li_cb
|
||||
holder = null
|
||||
QDEL_NULL(mode)
|
||||
QDEL_LIST(modeswitch_buttons)
|
||||
QDEL_LIST(dirswitch_buttons)
|
||||
return ..()
|
||||
|
||||
/datum/buildmode/proc/post_login()
|
||||
// since these will get wiped upon login
|
||||
holder.screen += buttons
|
||||
// re-open the according switch mode
|
||||
switch(switch_state)
|
||||
if(BM_SWITCHSTATE_MODE)
|
||||
open_modeswitch()
|
||||
if(BM_SWITCHSTATE_DIR)
|
||||
open_dirswitch()
|
||||
|
||||
/datum/buildmode/proc/create_buttons()
|
||||
// keep a reference so we can update it upon mode switch
|
||||
modebutton = new /obj/screen/buildmode/mode(src)
|
||||
buttons += modebutton
|
||||
buttons += new /obj/screen/buildmode/help(src)
|
||||
// keep a reference so we can update it upon dir switch
|
||||
dirbutton = new /obj/screen/buildmode/bdir(src)
|
||||
buttons += dirbutton
|
||||
buttons += new /obj/screen/buildmode/quit(src)
|
||||
// build the lists of switching buttons
|
||||
build_options_grid(subtypesof(/datum/buildmode_mode), modeswitch_buttons, /obj/screen/buildmode/modeswitch)
|
||||
build_options_grid(list(SOUTH,EAST,WEST,NORTH,NORTHWEST), dirswitch_buttons, /obj/screen/buildmode/dirswitch)
|
||||
|
||||
// this creates a nice offset grid for choosing between buildmode options,
|
||||
// because going "click click click ah hell" sucks.
|
||||
/datum/buildmode/proc/build_options_grid(list/elements, list/buttonslist, buttontype)
|
||||
var/pos_idx = 0
|
||||
for(var/thing in elements)
|
||||
var/x = pos_idx % switch_width
|
||||
var/y = FLOOR(pos_idx / switch_width, 1)
|
||||
var/obj/screen/buildmode/B = new buttontype(src, thing)
|
||||
// extra .5 for a nice offset look
|
||||
B.screen_loc = "NORTH-[(1 + 0.5 + y*1.5)],WEST+[0.5 + x*1.5]"
|
||||
buttonslist += B
|
||||
pos_idx++
|
||||
|
||||
/datum/buildmode/proc/close_switchstates()
|
||||
switch(switch_state)
|
||||
if(BM_SWITCHSTATE_MODE)
|
||||
close_modeswitch()
|
||||
if(BM_SWITCHSTATE_DIR)
|
||||
close_dirswitch()
|
||||
|
||||
/datum/buildmode/proc/toggle_modeswitch()
|
||||
if(switch_state == BM_SWITCHSTATE_MODE)
|
||||
close_modeswitch()
|
||||
else
|
||||
close_switchstates()
|
||||
open_modeswitch()
|
||||
|
||||
/datum/buildmode/proc/open_modeswitch()
|
||||
switch_state = BM_SWITCHSTATE_MODE
|
||||
holder.screen += modeswitch_buttons
|
||||
|
||||
/datum/buildmode/proc/close_modeswitch()
|
||||
switch_state = BM_SWITCHSTATE_NONE
|
||||
holder.screen -= modeswitch_buttons
|
||||
|
||||
/datum/buildmode/proc/toggle_dirswitch()
|
||||
if(switch_state == BM_SWITCHSTATE_DIR)
|
||||
close_dirswitch()
|
||||
else
|
||||
close_switchstates()
|
||||
open_dirswitch()
|
||||
|
||||
/datum/buildmode/proc/open_dirswitch()
|
||||
switch_state = BM_SWITCHSTATE_DIR
|
||||
holder.screen += dirswitch_buttons
|
||||
|
||||
/datum/buildmode/proc/close_dirswitch()
|
||||
switch_state = BM_SWITCHSTATE_NONE
|
||||
holder.screen -= dirswitch_buttons
|
||||
|
||||
/datum/buildmode/proc/change_mode(newmode)
|
||||
mode.exit_mode(src)
|
||||
QDEL_NULL(mode)
|
||||
close_switchstates()
|
||||
mode = new newmode(src)
|
||||
mode.enter_mode(src)
|
||||
modebutton.update_icon()
|
||||
|
||||
/datum/buildmode/proc/change_dir(newdir)
|
||||
build_dir = newdir
|
||||
close_dirswitch()
|
||||
dirbutton.update_icon()
|
||||
return 1
|
||||
|
||||
/datum/buildmode/proc/InterceptClickOn(mob/user, params, atom/object)
|
||||
mode.handle_click(user.client, params, object)
|
||||
return TRUE // no doing underlying actions
|
||||
|
||||
/proc/togglebuildmode(mob/M as mob in GLOB.player_list)
|
||||
set name = "Toggle Build Mode"
|
||||
set category = "Event"
|
||||
|
||||
if(M.client)
|
||||
if(istype(M.client.click_intercept,/datum/buildmode))
|
||||
var/datum/buildmode/B = M.client.click_intercept
|
||||
B.quit()
|
||||
log_admin("[key_name(usr)] has left build mode.")
|
||||
else
|
||||
new /datum/buildmode(M.client)
|
||||
message_admins("[key_name_admin(usr)] has entered build mode.")
|
||||
log_admin("[key_name(usr)] has entered build mode.")
|
||||
|
||||
#undef BM_SWITCHSTATE_NONE
|
||||
#undef BM_SWITCHSTATE_MODE
|
||||
#undef BM_SWITCHSTATE_DIR
|
||||
@@ -0,0 +1,90 @@
|
||||
/obj/screen/buildmode
|
||||
icon = 'icons/misc/buildmode.dmi'
|
||||
var/datum/buildmode/bd
|
||||
// If we don't do this, we get occluded by item action buttons
|
||||
layer = ABOVE_HUD_LAYER
|
||||
|
||||
/obj/screen/buildmode/New(bld)
|
||||
bd = bld
|
||||
return ..()
|
||||
|
||||
/obj/screen/buildmode/Destroy()
|
||||
bd = null
|
||||
return ..()
|
||||
|
||||
/obj/screen/buildmode/mode
|
||||
name = "Toggle Mode"
|
||||
icon_state = "buildmode_basic"
|
||||
screen_loc = "NORTH,WEST"
|
||||
|
||||
/obj/screen/buildmode/mode/Click(location, control, params)
|
||||
var/list/pa = params2list(params)
|
||||
|
||||
if(pa.Find("left"))
|
||||
bd.toggle_modeswitch()
|
||||
else if(pa.Find("right"))
|
||||
bd.mode.change_settings(usr.client)
|
||||
update_icon()
|
||||
return 1
|
||||
|
||||
/obj/screen/buildmode/mode/update_icon()
|
||||
icon_state = bd.mode.get_button_iconstate()
|
||||
|
||||
/obj/screen/buildmode/help
|
||||
icon_state = "buildhelp"
|
||||
screen_loc = "NORTH,WEST+1"
|
||||
name = "Buildmode Help"
|
||||
|
||||
/obj/screen/buildmode/help/Click(location, control, params)
|
||||
bd.mode.show_help(usr.client)
|
||||
return 1
|
||||
|
||||
/obj/screen/buildmode/bdir
|
||||
icon_state = "build"
|
||||
screen_loc = "NORTH,WEST+2"
|
||||
name = "Change Dir"
|
||||
|
||||
/obj/screen/buildmode/bdir/update_icon()
|
||||
dir = bd.build_dir
|
||||
return
|
||||
|
||||
/obj/screen/buildmode/bdir/Click()
|
||||
bd.toggle_dirswitch()
|
||||
update_icon()
|
||||
return 1
|
||||
|
||||
// used to switch between modes
|
||||
/obj/screen/buildmode/modeswitch
|
||||
var/datum/buildmode_mode/modetype
|
||||
|
||||
/obj/screen/buildmode/modeswitch/New(bld, mt)
|
||||
modetype = mt
|
||||
icon_state = "buildmode_[initial(modetype.key)]"
|
||||
name = initial(modetype.key)
|
||||
return ..(bld)
|
||||
|
||||
/obj/screen/buildmode/modeswitch/Click()
|
||||
bd.change_mode(modetype)
|
||||
return 1
|
||||
|
||||
// used to switch between dirs
|
||||
/obj/screen/buildmode/dirswitch
|
||||
icon_state = "build"
|
||||
|
||||
/obj/screen/buildmode/dirswitch/New(bld, dir)
|
||||
src.dir = dir
|
||||
name = dir2text(dir)
|
||||
return ..(bld)
|
||||
|
||||
/obj/screen/buildmode/dirswitch/Click()
|
||||
bd.change_dir(dir)
|
||||
return 1
|
||||
|
||||
/obj/screen/buildmode/quit
|
||||
icon_state = "buildquit"
|
||||
screen_loc = "NORTH,WEST+3"
|
||||
name = "Quit Buildmode"
|
||||
|
||||
/obj/screen/buildmode/quit/Click()
|
||||
bd.quit()
|
||||
return 1
|
||||
@@ -0,0 +1,28 @@
|
||||
/obj/effect/buildmode_line
|
||||
var/image/I
|
||||
var/client/cl
|
||||
|
||||
/obj/effect/buildmode_line/New(client/C, atom/atom_a, atom/atom_b, linename)
|
||||
name = linename
|
||||
loc = get_turf(atom_a)
|
||||
I = image('icons/misc/mark.dmi', src, "line", 19.0)
|
||||
var/x_offset = ((atom_b.x * 32) + atom_b.pixel_x) - ((atom_a.x * 32) + atom_a.pixel_x)
|
||||
var/y_offset = ((atom_b.y * 32) + atom_b.pixel_y) - ((atom_a.y * 32) + atom_a.pixel_y)
|
||||
|
||||
var/matrix/mat = matrix()
|
||||
mat.Translate(0, 16)
|
||||
mat.Scale(1, sqrt((x_offset * x_offset) + (y_offset * y_offset)) / 32)
|
||||
mat.Turn(90 - ATAN2(x_offset, y_offset)) // So... You pass coords in order x,y to this version of atan2. It should be called acsc2.
|
||||
mat.Translate(atom_a.pixel_x, atom_a.pixel_y)
|
||||
|
||||
transform = mat
|
||||
cl = C
|
||||
cl.images += I
|
||||
|
||||
/obj/effect/buildmode_line/Destroy()
|
||||
if(I)
|
||||
if(istype(cl))
|
||||
cl.images -= I
|
||||
cl = null
|
||||
QDEL_NULL(I)
|
||||
return ..()
|
||||
@@ -0,0 +1,50 @@
|
||||
/datum/buildmode_mode/advanced
|
||||
key = "advanced"
|
||||
var/objholder = null
|
||||
|
||||
// FIXME: add logic which adds a button displaying the icon
|
||||
// of the currently selected path
|
||||
|
||||
/datum/buildmode_mode/advanced/show_help(client/c)
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
to_chat(c, "<span class='notice'>Right Mouse Button on buildmode button = Set object type</span>")
|
||||
to_chat(c, "<span class='notice'>Left Mouse Button on turf/obj = Place objects</span>")
|
||||
to_chat(c, "<span class='notice'>Right Mouse Button = Delete objects</span>")
|
||||
to_chat(c, "")
|
||||
to_chat(c, "<span class='notice'>Use the button in the upper left corner to</span>")
|
||||
to_chat(c, "<span class='notice'>change the direction of built objects.</span>")
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
|
||||
/datum/buildmode_mode/advanced/change_settings(client/c)
|
||||
var/target_path = input(c, "Enter typepath:", "Typepath", "/obj/structure/closet")
|
||||
objholder = text2path(target_path)
|
||||
if(!ispath(objholder))
|
||||
objholder = pick_closest_path(target_path)
|
||||
if(!objholder)
|
||||
alert("No path was selected")
|
||||
return
|
||||
else if(ispath(objholder, /area))
|
||||
objholder = null
|
||||
alert("That path is not allowed.")
|
||||
return
|
||||
|
||||
/datum/buildmode_mode/advanced/handle_click(client/c, params, obj/object)
|
||||
var/list/pa = params2list(params)
|
||||
var/left_click = pa.Find("left")
|
||||
var/right_click = pa.Find("right")
|
||||
if(left_click)
|
||||
if(ispath(objholder,/turf))
|
||||
var/turf/T = get_turf(object)
|
||||
log_admin("Build Mode: [key_name(c)] modified [T] in [AREACOORD(object)] to [objholder]")
|
||||
T.ChangeTurf(objholder)
|
||||
else if(!isnull(objholder))
|
||||
var/obj/A = new objholder (get_turf(object))
|
||||
A.setDir(BM.build_dir)
|
||||
log_admin("Build Mode: [key_name(c)] modified [A]'s [COORD(A)] dir to [BM.build_dir]")
|
||||
else
|
||||
to_chat(c, "<span class='warning'>Select object type first.</span>")
|
||||
else if(right_click)
|
||||
if(isobj(object))
|
||||
log_admin("Build Mode: [key_name(c)] deleted [object] at [AREACOORD(object)]")
|
||||
qdel(object)
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/datum/buildmode_mode/area_edit
|
||||
key = "areaedit"
|
||||
var/area/storedarea
|
||||
var/image/areaimage
|
||||
|
||||
/datum/buildmode_mode/area_edit/New()
|
||||
areaimage = image('icons/turf/areas.dmi', null, "yellow")
|
||||
..()
|
||||
|
||||
/datum/buildmode_mode/area_edit/enter_mode(datum/buildmode/BM)
|
||||
BM.holder.images += areaimage
|
||||
|
||||
/datum/buildmode_mode/area_edit/exit_mode(datum/buildmode/BM)
|
||||
areaimage.loc = null // de-color the area
|
||||
BM.holder.images -= areaimage
|
||||
return ..()
|
||||
|
||||
/datum/buildmode_mode/area_edit/Destroy()
|
||||
QDEL_NULL(areaimage)
|
||||
storedarea = null
|
||||
return ..()
|
||||
|
||||
/datum/buildmode_mode/area_edit/show_help(client/c)
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
to_chat(c, "<span class='notice'>Left Mouse Button on obj/turf/mob = Paint area</span>")
|
||||
to_chat(c, "<span class='notice'>Right Mouse Button on obj/turf/mob = Select area to paint</span>")
|
||||
to_chat(c, "<span class='notice'>Right Mouse Button on buildmode button = Create new area</span>")
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
|
||||
/datum/buildmode_mode/area_edit/change_settings(client/c)
|
||||
var/target_path = input(c, "Enter typepath:", "Typepath", "/area")
|
||||
var/areatype = text2path(target_path)
|
||||
if(ispath(areatype,/area))
|
||||
var/areaname = input(c, "Enter area name:", "Area name", "Area")
|
||||
if(!areaname || !length(areaname))
|
||||
return
|
||||
storedarea = new areatype
|
||||
storedarea.power_equip = 0
|
||||
storedarea.power_light = 0
|
||||
storedarea.power_environ = 0
|
||||
storedarea.always_unpowered = 0
|
||||
storedarea.name = areaname
|
||||
areaimage.loc = storedarea // color our area
|
||||
|
||||
/datum/buildmode_mode/area_edit/handle_click(client/c, params, object)
|
||||
var/list/pa = params2list(params)
|
||||
var/left_click = pa.Find("left")
|
||||
var/right_click = pa.Find("right")
|
||||
|
||||
if(left_click)
|
||||
if(!storedarea)
|
||||
to_chat(c, "<span class='warning'>Configure or select the area you want to paint first!</span>")
|
||||
return
|
||||
var/turf/T = get_turf(object)
|
||||
if(get_area(T) != storedarea)
|
||||
log_admin("Build Mode: [key_name(c)] added [AREACOORD(T)] to [storedarea]")
|
||||
storedarea.contents.Add(T)
|
||||
else if(right_click)
|
||||
var/turf/T = get_turf(object)
|
||||
storedarea = get_area(T)
|
||||
areaimage.loc = storedarea // color our area
|
||||
@@ -0,0 +1,52 @@
|
||||
/datum/buildmode_mode/basic
|
||||
key = "basic"
|
||||
|
||||
/datum/buildmode_mode/basic/show_help(client/c)
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
to_chat(c, "<span class='notice'>Left Mouse Button = Construct / Upgrade</span>")
|
||||
to_chat(c, "<span class='notice'>Right Mouse Button = Deconstruct / Delete / Downgrade</span>")
|
||||
to_chat(c, "<span class='notice'>Left Mouse Button + ctrl = R-Window</span>")
|
||||
to_chat(c, "<span class='notice'>Left Mouse Button + alt = Airlock</span>")
|
||||
to_chat(c, "")
|
||||
to_chat(c, "<span class='notice'>Use the button in the upper left corner to</span>")
|
||||
to_chat(c, "<span class='notice'>change the direction of built objects.</span>")
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
|
||||
/datum/buildmode_mode/basic/handle_click(client/c, params, obj/object)
|
||||
var/list/pa = params2list(params)
|
||||
var/left_click = pa.Find("left")
|
||||
var/right_click = pa.Find("right")
|
||||
var/ctrl_click = pa.Find("ctrl")
|
||||
var/alt_click = pa.Find("alt")
|
||||
|
||||
if(istype(object,/turf) && left_click && !alt_click && !ctrl_click)
|
||||
var/turf/T = object
|
||||
if(isspaceturf(object))
|
||||
T.PlaceOnTop(/turf/open/floor/plating)
|
||||
else if(isplatingturf(object))
|
||||
T.PlaceOnTop(/turf/open/floor/plasteel)
|
||||
else if(isfloorturf(object))
|
||||
T.PlaceOnTop(/turf/closed/wall)
|
||||
else if(iswallturf(object))
|
||||
T.PlaceOnTop(/turf/closed/wall/r_wall)
|
||||
log_admin("Build Mode: [key_name(c)] built [T] at [AREACOORD(T)]")
|
||||
return
|
||||
else if(right_click)
|
||||
log_admin("Build Mode: [key_name(c)] deleted [object] at [AREACOORD(object)]")
|
||||
if(isturf(object))
|
||||
var/turf/T = object
|
||||
T.ScrapeAway()
|
||||
else if(isobj(object))
|
||||
qdel(object)
|
||||
return
|
||||
else if(istype(object,/turf) && alt_click && left_click)
|
||||
log_admin("Build Mode: [key_name(c)] built an airlock at [AREACOORD(object)]")
|
||||
new/obj/machinery/door/airlock(get_turf(object))
|
||||
else if(istype(object,/turf) && ctrl_click && left_click)
|
||||
var/obj/structure/window/reinforced/window
|
||||
if(BM.build_dir == NORTHWEST)
|
||||
window = new /obj/structure/window/reinforced/fulltile(get_turf(object))
|
||||
else
|
||||
window = new /obj/structure/window/reinforced(get_turf(object))
|
||||
window.setDir(BM.build_dir)
|
||||
log_admin("Build Mode: [key_name(c)] built a window at [AREACOORD(object)]")
|
||||
@@ -0,0 +1,38 @@
|
||||
/datum/buildmode_mode/boom
|
||||
key = "boom"
|
||||
|
||||
var/devastation = -1
|
||||
var/heavy = -1
|
||||
var/light = -1
|
||||
var/flash = -1
|
||||
var/flames = -1
|
||||
|
||||
/datum/buildmode_mode/boom/show_help(client/c)
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
to_chat(c, "<span class='notice'>Mouse Button on obj = Kaboom</span>")
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
|
||||
/datum/buildmode_mode/boom/change_settings(client/c)
|
||||
devastation = input(c, "Range of total devastation. -1 to none", text("Input")) as num|null
|
||||
if(devastation == null)
|
||||
devastation = -1
|
||||
heavy = input(c, "Range of heavy impact. -1 to none", text("Input")) as num|null
|
||||
if(heavy == null)
|
||||
heavy = -1
|
||||
light = input(c, "Range of light impact. -1 to none", text("Input")) as num|null
|
||||
if(light == null)
|
||||
light = -1
|
||||
flash = input(c, "Range of flash. -1 to none", text("Input")) as num|null
|
||||
if(flash == null)
|
||||
flash = -1
|
||||
flames = input(c, "Range of flames. -1 to none", text("Input")) as num|null
|
||||
if(flames == null)
|
||||
flames = -1
|
||||
|
||||
/datum/buildmode_mode/boom/handle_click(client/c, params, obj/object)
|
||||
var/list/pa = params2list(params)
|
||||
var/left_click = pa.Find("left")
|
||||
|
||||
if(left_click)
|
||||
explosion(object, devastation, heavy, light, flash, FALSE, TRUE, flames)
|
||||
log_admin("Build Mode: [key_name(c)] caused an explosion(dev=[devastation], hvy=[heavy], lgt=[light], flash=[flash], flames=[flames]) at [AREACOORD(object)]")
|
||||
@@ -0,0 +1,28 @@
|
||||
/datum/buildmode_mode/copy
|
||||
key = "copy"
|
||||
var/atom/movable/stored = null
|
||||
|
||||
/datum/buildmode_mode/copy/Destroy()
|
||||
stored = null
|
||||
return ..()
|
||||
|
||||
/datum/buildmode_mode/copy/show_help(client/c)
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
to_chat(c, "<span class='notice'>Left Mouse Button on obj/turf/mob = Spawn a Copy of selected target</span>")
|
||||
to_chat(c, "<span class='notice'>Right Mouse Button on obj/mob = Select target to copy</span>")
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
|
||||
/datum/buildmode_mode/copy/handle_click(client/c, params, obj/object)
|
||||
var/list/pa = params2list(params)
|
||||
var/left_click = pa.Find("left")
|
||||
var/right_click = pa.Find("right")
|
||||
|
||||
if(left_click)
|
||||
var/turf/T = get_turf(object)
|
||||
if(stored)
|
||||
DuplicateObject(stored, perfectcopy=1, sameloc=0,newloc=T)
|
||||
log_admin("Build Mode: [key_name(c)] copied [stored] to [AREACOORD(object)]")
|
||||
else if(right_click)
|
||||
if(ismovableatom(object)) // No copying turfs for now.
|
||||
to_chat(c, "<span class='notice'>[object] set as template.</span>")
|
||||
stored = object
|
||||
@@ -0,0 +1,62 @@
|
||||
/datum/buildmode_mode/fill
|
||||
key = "fill"
|
||||
|
||||
use_corner_selection = TRUE
|
||||
var/objholder = null
|
||||
|
||||
/datum/buildmode_mode/fill/show_help(client/c)
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
to_chat(c, "<span class='notice'>Left Mouse Button on turf/obj/mob = Select corner</span>")
|
||||
to_chat(c, "<span class='notice'>Left Mouse Button + Alt on turf/obj/mob = Delete region</span>")
|
||||
to_chat(c, "<span class='notice'>Right Mouse Button on buildmode button = Select object type</span>")
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
|
||||
/datum/buildmode_mode/fill/change_settings(client/c)
|
||||
var/target_path = input(c, "Enter typepath:" ,"Typepath","/obj/structure/closet")
|
||||
objholder = text2path(target_path)
|
||||
if(!ispath(objholder))
|
||||
objholder = pick_closest_path(target_path)
|
||||
if(!objholder)
|
||||
alert("No path has been selected.")
|
||||
return
|
||||
else if(ispath(objholder, /area))
|
||||
objholder = null
|
||||
alert("Area paths are not supported for this mode, use the area edit mode instead.")
|
||||
return
|
||||
deselect_region()
|
||||
|
||||
/datum/buildmode_mode/fill/handle_click(client/c, params, obj/object)
|
||||
if(isnull(objholder))
|
||||
to_chat(c, "<span class='warning'>Select an object type first.</span>")
|
||||
deselect_region()
|
||||
return
|
||||
..()
|
||||
|
||||
/datum/buildmode_mode/fill/handle_selected_area(client/c, params)
|
||||
var/list/pa = params2list(params)
|
||||
var/left_click = pa.Find("left")
|
||||
var/alt_click = pa.Find("alt")
|
||||
|
||||
if(left_click) //rectangular
|
||||
if(alt_click)
|
||||
var/list/deletion_area = block(get_turf(cornerA),get_turf(cornerB))
|
||||
for(var/beep in deletion_area)
|
||||
var/turf/T = beep
|
||||
for(var/atom/movable/AM in T)
|
||||
qdel(AM)
|
||||
// extreme haircut
|
||||
T.ScrapeAway(INFINITY, CHANGETURF_DEFER_CHANGE)
|
||||
for(var/beep in deletion_area)
|
||||
var/turf/T = beep
|
||||
T.AfterChange()
|
||||
log_admin("Build Mode: [key_name(c)] deleted turfs from [AREACOORD(cornerA)] through [AREACOORD(cornerB)]")
|
||||
// if there's an analogous proc for this on tg lmk
|
||||
// empty_region(block(get_turf(cornerA),get_turf(cornerB)))
|
||||
else
|
||||
for(var/turf/T in block(get_turf(cornerA),get_turf(cornerB)))
|
||||
if(ispath(objholder,/turf))
|
||||
T.PlaceOnTop(objholder)
|
||||
else
|
||||
var/obj/A = new objholder(T)
|
||||
A.setDir(BM.build_dir)
|
||||
log_admin("Build Mode: [key_name(c)] with path [objholder], filled the region from [AREACOORD(cornerA)] through [AREACOORD(cornerB)]")
|
||||
@@ -0,0 +1,48 @@
|
||||
/datum/buildmode_mode/mapgen
|
||||
key = "mapgen"
|
||||
|
||||
use_corner_selection = TRUE
|
||||
var/generator_path
|
||||
|
||||
/datum/buildmode_mode/mapgen/show_help(client/c)
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
to_chat(c, "<span class='notice'>Left Mouse Button on turf/obj/mob = Select corner</span>")
|
||||
to_chat(c, "<span class='notice'>Right Mouse Button on buildmode button = Select generator</span>")
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
|
||||
/datum/buildmode_mode/mapgen/change_settings(client/c)
|
||||
var/list/gen_paths = subtypesof(/datum/mapGenerator)
|
||||
var/list/options = list()
|
||||
for(var/path in gen_paths)
|
||||
var/datum/mapGenerator/MP = path
|
||||
options[initial(MP.buildmode_name)] = path
|
||||
var/type = input(c,"Select Generator Type","Type") as null|anything in options
|
||||
if(!type)
|
||||
return
|
||||
|
||||
generator_path = options[type]
|
||||
deselect_region()
|
||||
|
||||
/datum/buildmode_mode/mapgen/handle_click(client/c, params, obj/object)
|
||||
if(isnull(generator_path))
|
||||
to_chat(c, "<span class='warning'>Select generator type first.</span>")
|
||||
deselect_region()
|
||||
return
|
||||
..()
|
||||
|
||||
/datum/buildmode_mode/mapgen/handle_selected_area(client/c, params)
|
||||
var/list/pa = params2list(params)
|
||||
var/left_click = pa.Find("left")
|
||||
if(left_click)
|
||||
var/datum/mapGenerator/G = new generator_path
|
||||
if(istype(G, /datum/mapGenerator/repair/reload_station_map))
|
||||
if(GLOB.reloading_map)
|
||||
to_chat(c, "<span class='boldwarning'>You are already reloading an area! Please wait for it to fully finish loading before trying to load another!</span>")
|
||||
deselect_region()
|
||||
return
|
||||
G.defineRegion(cornerA, cornerB, 1)
|
||||
highlight_region(G.map)
|
||||
var/confirm = alert("Are you sure you want run the map generator?", "Run generator", "Yes", "No")
|
||||
if(confirm == "Yes")
|
||||
G.generate()
|
||||
log_admin("Build Mode: [key_name(c)] ran the map generator '[G.buildmode_name]' in the region from [AREACOORD(cornerA)] to [AREACOORD(cornerB)]")
|
||||
@@ -0,0 +1,29 @@
|
||||
/datum/buildmode_mode/throwing
|
||||
key = "throw"
|
||||
|
||||
var/atom/movable/throw_atom = null
|
||||
|
||||
/datum/buildmode_mode/throwing/Destroy()
|
||||
throw_atom = null
|
||||
return ..()
|
||||
|
||||
/datum/buildmode_mode/throwing/show_help(client/c)
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
to_chat(c, "<span class='notice'>Left Mouse Button on turf/obj/mob = Select</span>")
|
||||
to_chat(c, "<span class='notice'>Right Mouse Button on turf/obj/mob = Throw</span>")
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
|
||||
/datum/buildmode_mode/throwing/handle_click(client/c, params, obj/object)
|
||||
var/list/pa = params2list(params)
|
||||
var/left_click = pa.Find("left")
|
||||
var/right_click = pa.Find("right")
|
||||
|
||||
if(left_click)
|
||||
if(isturf(object))
|
||||
return
|
||||
throw_atom = object
|
||||
to_chat(c, "Selected object '[throw_atom]'")
|
||||
if(right_click)
|
||||
if(throw_atom)
|
||||
throw_atom.throw_at(object, 10, 1, c.mob)
|
||||
log_admin("Build Mode: [key_name(c)] threw [throw_atom] at [object] ([AREACOORD(object)])")
|
||||
@@ -0,0 +1,62 @@
|
||||
/datum/buildmode_mode/varedit
|
||||
key = "edit"
|
||||
// Varedit mode
|
||||
var/varholder = null
|
||||
var/valueholder = null
|
||||
|
||||
/datum/buildmode_mode/varedit/Destroy()
|
||||
varholder = null
|
||||
valueholder = null
|
||||
return ..()
|
||||
|
||||
/datum/buildmode_mode/varedit/show_help(client/c)
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
to_chat(c, "<span class='notice'>Right Mouse Button on buildmode button = Select var(type) & value</span>")
|
||||
to_chat(c, "<span class='notice'>Left Mouse Button on turf/obj/mob = Set var(type) & value</span>")
|
||||
to_chat(c, "<span class='notice'>Right Mouse Button on turf/obj/mob = Reset var's value</span>")
|
||||
to_chat(c, "<span class='notice'>***********************************************************</span>")
|
||||
|
||||
/datum/buildmode_mode/varedit/Reset()
|
||||
. = ..()
|
||||
varholder = null
|
||||
valueholder = null
|
||||
|
||||
/datum/buildmode_mode/varedit/change_settings(client/c)
|
||||
varholder = input(c, "Enter variable name:" ,"Name", "name")
|
||||
|
||||
if(!vv_varname_lockcheck(varholder))
|
||||
return
|
||||
|
||||
var/temp_value = c.vv_get_value()
|
||||
if(isnull(temp_value["class"]))
|
||||
Reset()
|
||||
to_chat(c, "<span class='notice'>Variable unset.</span>")
|
||||
return
|
||||
valueholder = temp_value["value"]
|
||||
|
||||
/datum/buildmode_mode/varedit/handle_click(client/c, params, obj/object)
|
||||
var/list/pa = params2list(params)
|
||||
var/left_click = pa.Find("left")
|
||||
var/right_click = pa.Find("right")
|
||||
|
||||
if(isnull(varholder))
|
||||
to_chat(c, "<span class='warning'>Choose a variable to modify first.</span>")
|
||||
return
|
||||
if(left_click)
|
||||
if(object.vars.Find(varholder))
|
||||
if(object.vv_edit_var(varholder, valueholder) == FALSE)
|
||||
to_chat(c, "<span class='warning'>Your edit was rejected by the object.</span>")
|
||||
return
|
||||
log_admin("Build Mode: [key_name(c)] modified [object.name]'s [varholder] to [valueholder]")
|
||||
else
|
||||
to_chat(c, "<span class='warning'>[initial(object.name)] does not have a var called '[varholder]'</span>")
|
||||
if(right_click)
|
||||
if(object.vars.Find(varholder))
|
||||
var/reset_value = initial(object.vars[varholder])
|
||||
if(object.vv_edit_var(varholder, reset_value) == FALSE)
|
||||
to_chat(c, "<span class='warning'>Your edit was rejected by the object.</span>")
|
||||
return
|
||||
log_admin("Build Mode: [key_name(c)] modified [object.name]'s [varholder] to [reset_value]")
|
||||
else
|
||||
to_chat(c, "<span class='warning'>[initial(object.name)] does not have a var called '[varholder]'</span>")
|
||||
|
||||
Reference in New Issue
Block a user