mirror of
https://github.com/fulpstation/fulpstation.git
synced 2025-12-10 10:01:40 +00:00
* Update beefman.dm * Update beefman.dm * xsaxsfvvvvvvvv * Update shaded_bloodsucker.dm * yeah that thing * FUCK you * Update hunting_contract.dm * dd * vdvdfv * Update monsterhunter_weapons.dm * Update whiterabbit.dm * onokkn * Update monsterhunter_weapons.dm * Update monsterhunter_weapons.dm * efe * Update whiterabbit.dm * yeaywa * Update red_rabbit.dmi * oihop * Update HunterContract.js * wonderland.dm * gs * dcd * Update rabbit.dmi * ass * fvd * Update paradox_rabbit.dm * f * Update tgstation.dme * Delete heartbeatmoon.dmi * shtntb * sed * sfe * Update monsterhunter_weapons.dm * cdc * Update wonderland.dm * dgrd * wef * b * pipkk * Update hunting_contract.dm * Update paradox_rabbit.dm * wr * Update worn_mask.dmi * some documenting * Update areas.dm * eg * Update white_rabbit.dm * Update HunterContract.js * s * Update weapons.dmi * Update weapons.dmi * Jack in the bomb * some signals * ui * h * y * music * Update wonderlandmusic.ogg * f * v * cleanups * g * a * t * y * g * a * o * first commit * Adding our stuff back in * k * Before procs * proc refs * carps * Fixes * shuttles * dumb dumb names * I hate windows I hate windows * I hate windows I hate windows * h * Selenestation has issues * Update monsterhunter_weapons.dm * eretics * Update weapons.dmi * Update monsterhunter_weapons.dm * g * kpop * r * m * grgr * Update simple_animal_freeze.dm * Update wonderland_apocalypse.dm * Update wonderland_apocalypse.dm * d * Update fulp_defines.dm * ff * Update wonderland.dmm * Update tgstation.dme * Update infil_objectives.dm * Update infil_objectives.dm * Update monsterhunter_weapons.dm * Update monsterhunter_event.dm * Update monsterhunter_event.dm * Update areas.dm * Update monsterhunter_event.dm * Update monsterhunter_weapons.dm * Step 0, version 2 * step 0.5 - version 2 * step 1 - version 2 * 2.5 version 2 * fix * Mapping * okay fine * more mapping * uuuuu hhhh * fixes * help me * hurry * I'm killing the mf that did access helpers on this map * Welp, we lost. * Or did we? --------- Co-authored-by: SmoSmoSmoSmok <95004236+SmoSmoSmoSmok@users.noreply.github.com> Co-authored-by: Pepsilawn <reisenrui@gmail.com> Co-authored-by: SgtHunk <68669754+SgtHunk@users.noreply.github.com>
104 lines
4.0 KiB
Plaintext
104 lines
4.0 KiB
Plaintext
/// Takes a screen loc string in the format
|
|
/// "+-left-offset:+-pixel,+-bottom-offset:+-pixel"
|
|
/// Where the :pixel is optional, and returns
|
|
/// A list in the format (x_offset, y_offset)
|
|
/// We require context to get info out of screen locs that contain relative info, so NORTH, SOUTH, etc
|
|
/proc/screen_loc_to_offset(screen_loc, view)
|
|
if(!screen_loc)
|
|
return list(64, 64)
|
|
var/list/view_size = view_to_pixels(view)
|
|
var/x = 0
|
|
var/y = 0
|
|
// Time to parse for directional relative offsets
|
|
if(findtext(screen_loc, "EAST")) // If you're starting from the east, we start from the east too
|
|
x += view_size[1]
|
|
if(findtext(screen_loc, "WEST")) // HHHHHHHHHHHHHHHHHHHHHH WEST is technically a 1 tile offset from the start. Shoot me please
|
|
x += world.icon_size
|
|
if(findtext(screen_loc, "NORTH"))
|
|
y += view_size[2]
|
|
if(findtext(screen_loc, "SOUTH"))
|
|
y += world.icon_size
|
|
|
|
var/list/x_and_y = splittext(screen_loc, ",")
|
|
|
|
var/list/x_pack = splittext(x_and_y[1], ":")
|
|
var/list/y_pack = splittext(x_and_y[2], ":")
|
|
|
|
var/x_coord = x_pack[1]
|
|
var/y_coord = y_pack[1]
|
|
|
|
if (findtext(x_coord, "CENTER"))
|
|
x += view_size[1] / 2
|
|
|
|
if (findtext(y_coord, "CENTER"))
|
|
y += view_size[2] / 2
|
|
|
|
x_coord = text2num(cut_relative_direction(x_coord))
|
|
y_coord = text2num(cut_relative_direction(y_coord))
|
|
|
|
x += x_coord * world.icon_size
|
|
y += y_coord * world.icon_size
|
|
|
|
if(length(x_pack) > 1)
|
|
x += text2num(x_pack[2])
|
|
if(length(y_pack) > 1)
|
|
y += text2num(y_pack[2])
|
|
return list(x, y)
|
|
|
|
/// Takes a list in the form (x_offset, y_offset)
|
|
/// And converts it to a screen loc string
|
|
/// Accepts an optional view string/size to force the screen_loc around, so it can't go out of scope
|
|
/proc/offset_to_screen_loc(x_offset, y_offset, view = null)
|
|
if(view)
|
|
var/list/view_bounds = view_to_pixels(view)
|
|
x_offset = clamp(x_offset, world.icon_size, view_bounds[1])
|
|
y_offset = clamp(y_offset, world.icon_size, view_bounds[2])
|
|
|
|
// Round with no argument is floor, so we get the non pixel offset here
|
|
var/x = round(x_offset / world.icon_size)
|
|
var/pixel_x = x_offset % world.icon_size
|
|
var/y = round(y_offset / world.icon_size)
|
|
var/pixel_y = y_offset % world.icon_size
|
|
|
|
var/list/generated_loc = list()
|
|
generated_loc += "[x]"
|
|
if(pixel_x)
|
|
generated_loc += ":[pixel_x]"
|
|
generated_loc += ",[y]"
|
|
if(pixel_y)
|
|
generated_loc += ":[pixel_y]"
|
|
return jointext(generated_loc, "")
|
|
|
|
/**
|
|
* Returns a valid location to place a screen object without overflowing the viewport
|
|
*
|
|
* * target: The target location as a purely number based screen_loc string "+-left-offset:+-pixel,+-bottom-offset:+-pixel"
|
|
* * target_offset: The amount we want to offset the target location by. We explictly don't care about direction here, we will try all 4
|
|
* * view: The view variable of the client we're doing this for. We use this to get the size of the screen
|
|
*
|
|
* Returns a screen loc representing the valid location
|
|
**/
|
|
/proc/get_valid_screen_location(target_loc, target_offset, view)
|
|
var/list/offsets = screen_loc_to_offset(target_loc)
|
|
var/base_x = offsets[1]
|
|
var/base_y = offsets[2]
|
|
|
|
var/list/view_size = view_to_pixels(view)
|
|
|
|
// Bias to the right, down, left, and then finally up
|
|
if(base_x + target_offset < view_size[1])
|
|
return offset_to_screen_loc(base_x + target_offset, base_y, view)
|
|
if(base_y - target_offset > world.icon_size)
|
|
return offset_to_screen_loc(base_x, base_y - target_offset, view)
|
|
if(base_x - target_offset > world.icon_size)
|
|
return offset_to_screen_loc(base_x - target_offset, base_y, view)
|
|
if(base_y + target_offset < view_size[2])
|
|
return offset_to_screen_loc(base_x, base_y + target_offset, view)
|
|
stack_trace("You passed in a scren location {[target_loc]} and offset {[target_offset]} that can't be fit in the viewport Width {[view_size[1]]}, Height {[view_size[2]]}. what did you do lad")
|
|
return null // The fuck did you do lad
|
|
|
|
/// Takes a screen_loc string and cut out any directions like NORTH or SOUTH
|
|
/proc/cut_relative_direction(fragment)
|
|
var/static/regex/regex = regex(@"([A-Z])\w+", "g")
|
|
return regex.Replace(fragment, "")
|