Skip to content

Commit

Permalink
Port TGUI react migration and fixes, Part 1 (#342)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Mullen <[email protected]>
Co-authored-by: SabreML <[email protected]>
Co-authored-by: Drathek <[email protected]>
Co-authored-by: Jeremiah <[email protected]>
Co-authored-by: Contrabang <[email protected]>
Co-authored-by: private-tristan <[email protected]>
Co-authored-by: harryob <[email protected]>
Co-authored-by: fira <[email protected]>
Co-authored-by: harryob <[email protected]>
Co-authored-by: Birdtalon <[email protected]>
Co-authored-by: Jerm <[email protected]>
Co-authored-by: Cthulhu80 <[email protected]>
Co-authored-by: ihatethisengine <[email protected]>
Co-authored-by: cuberound <[email protected]>
Co-authored-by: vincibrv <[email protected]>
Co-authored-by: Drulikar <[email protected]>
Co-authored-by: Vero <[email protected]>
Co-authored-by: Vicacrov <[email protected]>
  • Loading branch information
19 people committed Aug 5, 2024
1 parent 6e5aef8 commit 90ef5a2
Show file tree
Hide file tree
Showing 650 changed files with 31,708 additions and 22,673 deletions.
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# We don't want prettier to run on anything outside of the TGUI folder, so we have to do this.
/*

# We want it to run into the TGUI folder, however.
!/tgui
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"eslint.nodePath": "./tgui/.yarn/sdks",
"eslint.workingDirectories": ["./tgui"],
"prettier.prettierPath": "./tgui/.yarn/sdks/prettier/index.js",
"prettier.prettierPath": "./tgui/.yarn/sdks/prettier/index.cjs",
"typescript.tsdk": "./tgui/.yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"search.exclude": {
Expand All @@ -14,6 +14,7 @@
"files.eol": "\n",
"files.insertFinalNewline": true,
"gitlens.advanced.blame.customArguments": ["-w"],
"tgstationTestExplorer.project.resultsType": "json",
"[javascript]": {
"editor.rulers": [80],
"editor.defaultFormatter": "esbenp.prettier-vscode",
Expand Down
7 changes: 1 addition & 6 deletions code/__DEFINES/__game.dm
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#define RANGE_TURFS(RADIUS, CENTER) \
block( \
locate(max(CENTER.x-(RADIUS),1), max(CENTER.y-(RADIUS),1), CENTER.z), \
locate(min(CENTER.x+(RADIUS),world.maxx), min(CENTER.y+(RADIUS),world.maxy), CENTER.z) \
)

//Admin perms are in global.dm.

/// To make it even more clear that something is a bitfield.
Expand Down Expand Up @@ -396,6 +390,7 @@ block( \
#define FIRE_MISSION_WEAPON_REMOVED 8
#define FIRE_MISSION_WEAPON_UNUSABLE 16
#define FIRE_MISSION_WEAPON_OUT_OF_AMMO 32
#define FIRE_MISSION_BAD_DIRECTION 64
#define FIRE_MISSION_NOT_EXECUTABLE -1

//Defines for firemission state
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/_math.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#define CEILING(x, y) ( -round(-(x) / (y)) * (y) )

#define ROUND_UP(x) ( -round(-(x)))

// round() acts like floor(x, 1) by default but can't handle other values
#define FLOOR(x, y) ( round((x) / (y)) * (y) )

Expand Down
3 changes: 2 additions & 1 deletion code/__DEFINES/dcs/signals/atom/signals_atom.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// From /atom/proc/Decorate
#define COMSIG_ATOM_DECORATED "atom_decorated"

//from SSatoms InitAtom - Only if the atom was not deleted or failed initialization and has a loc
#define COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON "atom_init_success_on"
///from base of atom/setDir(): (old_dir, new_dir). Called before the direction changes.
#define COMSIG_ATOM_DIR_CHANGE "atom_dir_change"

Expand Down
10 changes: 10 additions & 0 deletions code/__DEFINES/dcs/signals/atom/signals_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,13 @@

//Additional procs on items that will be triggered right after the human finishes spawns in
#define COMSIG_POST_SPAWN_UPDATE "post_spawn_update"

#define COMSIG_CAMERA_MAPNAME_ASSIGNED "camera_manager_mapname_assigned"
#define COMSIG_CAMERA_REGISTER_UI "camera_manager_register_ui"
#define COMSIG_CAMERA_UNREGISTER_UI "camera_manager_unregister_ui"
#define COMSIG_CAMERA_SET_NVG "camera_manager_set_nvg"
#define COMSIG_CAMERA_CLEAR_NVG "camera_manager_clear_nvg"
#define COMSIG_CAMERA_SET_TARGET "camera_manager_set_target"
#define COMSIG_CAMERA_SET_AREA "camera_manager_set_area"
#define COMSIG_CAMERA_CLEAR "camera_manager_clear_target"
#define COMSIG_CAMERA_REFRESH "camera_manager_refresh"
2 changes: 2 additions & 0 deletions code/__DEFINES/dcs/signals/atom/signals_obj.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@
/// from /obj/proc/afterbuckle()
#define COSMIG_OBJ_AFTER_BUCKLE "signal_obj_after_buckle"

#define COMSIG_DROPSHIP_ADD_EQUIPMENT "dropship_add_equipment"
#define COMSIG_DROPSHIP_REMOVE_EQUIPMENT "dropship_remove_equipment"
#define COMSIG_STRUCTURE_CRATE_SQUAD_LAUNCHED "structure_crate_squad_launched"
3 changes: 3 additions & 0 deletions code/__DEFINES/dcs/signals/atom/signals_turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@

///from /turf/closed/wall/proc/place_poster
#define COMSIG_POSTER_PLACED "poster_placed"

///from base of /datum/turf_reservation/proc/Release: (datum/turf_reservation/reservation)
#define COMSIG_TURF_RESERVATION_RELEASED "turf_reservation_released"
2 changes: 2 additions & 0 deletions code/__DEFINES/dcs/signals/signals_global.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

///from base of datum/controller/subsystem/mapping/proc/add_new_zlevel(): (list/args)
#define COMSIG_GLOB_NEW_Z "!new_z"
/// sent after world.maxx and/or world.maxy are expanded: (has_exapnded_world_maxx, has_expanded_world_maxy)
#define COMSIG_GLOB_EXPANDED_WORLD_BOUNDS "!expanded_world_bounds"
///from base of datum/controller/subsystem/mapping/proc/add_new_zlevel(): (list/args)
#define COMSIG_GLOB_VEHICLE_ORDERED "!vehicle_ordered"
/// from /datum/controller/subsystem/ticker/fire
Expand Down
12 changes: 8 additions & 4 deletions code/__DEFINES/equipment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
#define ANIMATED_SURGICAL_TOOL (1<<12)
/// Has heat source but isn't 'on fire' and thus can be stored
#define IGNITING_ITEM (1<<13)
/// Overrides NODROP in some cases (stripping)
#define FORCEDROP_CONDITIONAL (1<<14)
/// Overrides smartgunner not being able to wear backpacks
#define SMARTGUNNER_BACKPACK_OVERRIDE (1<<15)
//==========================================================================================


Expand Down Expand Up @@ -550,10 +554,10 @@ var/global/list/uniform_categories = list(
#define PHONE_UPP_SOLDIER "Soldier"
#define PHONE_IO "IO"

#define PHONE_DO_NOT_DISTURB_FORCED 2
#define PHONE_DO_NOT_DISTURB_ON 1
#define PHONE_DO_NOT_DISTURB_OFF 0
#define PHONE_DO_NOT_DISTURB_FORBIDDEN -1
#define PHONE_DND_FORCED 2
#define PHONE_DND_ON 1
#define PHONE_DND_OFF 0
#define PHONE_DND_FORBIDDEN -1

#define PHONE_ON_BASE_UNIT_ICON_STATE "[initial(icon_state)]"
#define PHONE_OFF_BASE_UNIT_ICON_STATE "[initial(icon_state)]_ear"
Expand Down
1 change: 1 addition & 0 deletions code/__DEFINES/layers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
///--------------- FULLSCREEN RUNECHAT BUBBLES ------------
#define LIGHTING_PLANE 100
#define EXTERIOR_LIGHTING_PLANE 101
#define NVG_PLANE 110

///Popup Chat Messages
#define RUNECHAT_PLANE 501
Expand Down
7 changes: 2 additions & 5 deletions code/__DEFINES/maps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,5 @@ require only minor tweaks.
#define MAP_ARMOR_STYLE_JUNGLE "jungle"
#define MAP_ARMOR_STYLE_PRISON "prison"

//turf-only flags
#define NOJAUNT_1 (1<<0)
#define UNUSED_RESERVATION_TURF (1<<1)
/// If a turf can be made dirty at roundstart. This is also used in areas.
#define CAN_BE_DIRTY_1 (1<<2)
/// A map key that corresponds to being one exclusively for Space.
#define SPACE_KEY "space"
1 change: 1 addition & 0 deletions code/__DEFINES/mob_hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define STATUS_HUD_XENO_CULTIST "24" // Whether they are a xeno cultist or not
#define HUNTER_CLAN "25" //Displays a colored icon to represent ingame Hunter Clans
#define HUNTER_HUD "26" //Displays various statuses on mobs for Hunters to identify targets
#define HOLOCARD_HUD "27" //Displays the holocards set by medical personnel

//data HUD (medhud, sechud) defines
#define MOB_HUD_SECURITY_BASIC 1
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,8 @@ var/list/RESTRICTED_CAMERA_NETWORKS = list( //Those networks can only be accesse
#define CHECKS_PASSED 1
#define STILL_ON_COOLDOWN 2
#define NO_LIGHT_STATE_CHANGE 3

//tool capabilities or something i don't know
#define REMOVE_CROWBAR (1<<0)
#define BREAK_CROWBAR (1<<1)
#define REMOVE_SCREWDRIVER (1<<2)
2 changes: 1 addition & 1 deletion code/__DEFINES/shuttles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#define TRANSIT_REQUEST 1
#define TRANSIT_READY 2

#define SHUTTLE_TRANSIT_BORDER 8
#define SHUTTLE_TRANSIT_BORDER 16

#define PARALLAX_LOOP_TIME 25
#define HYPERSPACE_END_TIME 5
Expand Down
6 changes: 6 additions & 0 deletions code/__DEFINES/tgui.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
"%7b%22type%22%3a%22[type]%22%2c%22payload%22%3a[url_encode(json_encode(payload))]%7d" \
)

/// Creates a message packet for sending via output() specifically for opening tgsay using an embedded winget
// This is {"type":"open","payload":{"channel":channel,"mapfocus":[[map.focus]]}}, but pre-encoded.
#define TGUI_CREATE_OPEN_MESSAGE(channel) ( \
"%7b%22type%22%3a%22open%22%2c%22payload%22%3a%7B%22channel%22%3a%22[channel]%22%2c%22mapfocus%22%3a\[\[map.focus\]\]%7d%7d" \
)

/*
*Defines for the TGUI health analyser interface
*The higher the level, the more information you can see
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ GLOBAL_LIST(trait_name_map)
#define XENO_WEED_TRAIT "xeno_weed"
/// traits associated with actively interacted machinery
#define INTERACTION_TRAIT "interaction"
/// traits associated with interacting with a dropship
#define TRAIT_SOURCE_DROPSHIP_INTERACTION "dropship_interaction"
/// traits bound by stunned status effects
#define STUNNED_TRAIT "stunned"
/// traits bound by knocked_down status effect
Expand Down
18 changes: 9 additions & 9 deletions code/__DEFINES/turf_flags.dm
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//turf_flags values
/// Marks a turf as organic. Used for alien wall and membranes.
#define TURF_ORGANIC (1<<0)
/// If a turf is an usused reservation turf awaiting assignment
#define UNUSED_RESERVATION_TURF (1<<1)
/// If a turf is a reserved turf
#define RESERVATION_TURF (1<<2)

//ChangeTurf options to change its behavior
#define CHANGETURF_DEFER_CHANGE (1<<0)
/// This flag prevents changeturf from gathering air from nearby turfs to fill the new turf with an approximation of local air
#define CHANGETURF_IGNORE_AIR (1<<1)
#define CHANGETURF_FORCEOP (1<<2)
/// A flag for PlaceOnTop to just instance the new turf instead of calling ChangeTurf. Used for uninitialized turfs NOTHING ELSE
#define CHANGETURF_SKIP (1<<3)

#define IS_OPAQUE_TURF(turf) (turf.directional_opacity == ALL_CARDINALS)

/// Marks a turf as organic. Used for alien wall and membranes.
#define TURF_ORGANIC (1<<0)


#define REMOVE_CROWBAR (1<<0)
#define BREAK_CROWBAR (1<<1)
#define REMOVE_SCREWDRIVER (1<<2)
29 changes: 29 additions & 0 deletions code/__DEFINES/turfs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#define RANGE_TURFS(RADIUS, CENTER) \
block( \
locate(max(CENTER.x-(RADIUS),1), max(CENTER.y-(RADIUS),1), CENTER.z), \
locate(min(CENTER.x+(RADIUS),world.maxx), min(CENTER.y+(RADIUS),world.maxy), CENTER.z) \
)

#define RECT_TURFS(H_RADIUS, V_RADIUS, CENTER) \
block( \
locate(max((CENTER).x-(H_RADIUS),1), max((CENTER).y-(V_RADIUS),1), (CENTER).z), \
locate(min((CENTER).x+(H_RADIUS),world.maxx), min((CENTER).y+(V_RADIUS),world.maxy), (CENTER).z) \
)

///Returns all turfs in a zlevel
#define Z_TURFS(ZLEVEL) block(locate(1,1,ZLEVEL), locate(world.maxx, world.maxy, ZLEVEL))

/// Returns a list of turfs in the rectangle specified by BOTTOM LEFT corner and height/width, checks for being outside the world border for you
#define CORNER_BLOCK(corner, width, height) CORNER_BLOCK_OFFSET(corner, width, height, 0, 0)

/// Returns a list of turfs similar to CORNER_BLOCK but with offsets
#define CORNER_BLOCK_OFFSET(corner, width, height, offset_x, offset_y) ((block(locate(corner.x + offset_x, corner.y + offset_y, corner.z), locate(min(corner.x + (width - 1) + offset_x, world.maxx), min(corner.y + (height - 1) + offset_y, world.maxy), corner.z))))

/// Returns an outline (neighboring turfs) of the given block
#define CORNER_OUTLINE(corner, width, height) ( \
CORNER_BLOCK_OFFSET(corner, width + 2, 1, -1, -1) + \
CORNER_BLOCK_OFFSET(corner, width + 2, 1, -1, height) + \
CORNER_BLOCK_OFFSET(corner, 1, height, -1, 0) + \
CORNER_BLOCK_OFFSET(corner, 1, height, width, 0))

#define TURF_FROM_COORDS_LIST(List) (locate(List[1], List[2], List[3]))
1 change: 1 addition & 0 deletions code/__DEFINES/typecheck/generic_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define ismovableatom(A) (ismovable(A))
#define isatom(A) (isloc(A))
#define isfloorturf(A) (istype(A, /turf/open/floor))
#define isclosedturf(A) (istype(A, /turf/closed))
#define isweakref(D) (istype(D, /datum/weakref))
#define isgenerator(A) (istype(A, /generator))

Expand Down
2 changes: 2 additions & 0 deletions code/__HELPERS/lighting.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define IS_OPAQUE_TURF(turf) (turf.directional_opacity == ALL_CARDINALS)

/// Produces a mutable appearance glued to the [EMISSIVE_PLANE] dyed to be the [EMISSIVE_COLOR].
/proc/emissive_appearance(icon, icon_state = "", layer = FLOAT_LAYER, alpha = 255, appearance_flags = NONE)
var/mutable_appearance/appearance = mutable_appearance(icon, icon_state, layer, EMISSIVE_PLANE, alpha, appearance_flags | EMISSIVE_APPEARANCE_FLAGS)
Expand Down
6 changes: 3 additions & 3 deletions code/__HELPERS/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@

//Copies a list, and all lists inside it recusively
//Does not copy any other reference type
/proc/deepCopyList(list/L)
/proc/deep_copy_list(list/L)
if(!islist(L))
return L
. = L.Copy()
Expand All @@ -532,10 +532,10 @@
continue
var/value = .[key]
if(islist(value))
value = deepCopyList(value)
value = deep_copy_list(value)
.[key] = value
if(islist(key))
key = deepCopyList(key)
key = deep_copy_list(key)
.[i] = key
.[key] = value

Expand Down
10 changes: 10 additions & 0 deletions code/__HELPERS/logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,16 @@ GLOBAL_PROTECT(config_error_log)
WRITE_LOG(GLOB.config_error_log, text)
SEND_TEXT(world.log, text)

/// Logging for mapping errors
/proc/log_mapping(text, skip_world_log)
#ifdef UNIT_TESTS
GLOB.unit_test_mapping_logs += text
#endif
if(skip_world_log)
return
WRITE_LOG(GLOB.mapping_log, text)
SEND_TEXT(world.log, text)

/proc/log_admin_private(text)
log_admin(text)

Expand Down
23 changes: 23 additions & 0 deletions code/__HELPERS/string_lists.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
GLOBAL_LIST_EMPTY(string_lists)

/**
* Caches lists with non-numeric stringify-able values (text or typepath).
*/
/proc/string_list(list/values)
var/string_id = values.Join("-")

. = GLOB.string_lists[string_id]

if(.)
return .

return GLOB.string_lists[string_id] = values

///A wrapper for baseturf string lists, to offer support of non list values, and a stack_trace if we have major issues
/proc/baseturfs_string_list(list/values, turf/baseturf_holder)
if(!islist(values))
return values //baseturf things
// return values
if(length(values) > 10)
return string_list(list(/turf/closed/cordon/debug))
return string_list(values)
18 changes: 18 additions & 0 deletions code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,24 @@

return ""

//Returns a string with reserved characters and spaces after the first and last letters removed
//Like trim(), but very slightly faster. worth it for niche usecases
/proc/trim_reduced(text)
var/starting_coord = 1
var/text_len = length(text)
for (var/i in 1 to text_len)
if (text2ascii(text, i) > 32)
starting_coord = i
break

for (var/i = text_len, i >= starting_coord, i--)
if (text2ascii(text, i) > 32)
return copytext(text, starting_coord, i + 1)

if(starting_coord > 1)
return copytext(text, starting_coord)
return ""

//Returns a string with reserved characters and spaces before the first word and after the last word removed.
/proc/trim(text)
return trim_left(trim_right(text))
Expand Down
14 changes: 11 additions & 3 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -888,14 +888,24 @@
animation.master = target
flick(flick_anim, animation)

//Will return the contents of an atom recursivly to a depth of 'searchDepth'
///Will return the contents of an atom recursivly to a depth of 'searchDepth', not including starting atom
/atom/proc/GetAllContents(searchDepth = 5, list/toReturn = list())
for(var/atom/part as anything in contents)
toReturn += part
if(part.contents.len && searchDepth)
part.GetAllContents(searchDepth - 1, toReturn)
return toReturn

///Returns the src and all recursive contents as a list. Includes the starting atom.
/atom/proc/get_all_contents(ignore_flag_1)
. = list(src)
var/i = 0
while(i < length(.))
var/atom/checked_atom = .[++i]
if(checked_atom.flags_atom & ignore_flag_1)
continue
. += checked_atom.contents

/// Returns list of contents of a turf recursively, much like GetAllContents
/// We only get containing atoms in the turf, excluding multitiles bordering on it
/turf/proc/GetAllTurfStrictContents(searchDepth = 5, list/toReturn = list())
Expand Down Expand Up @@ -2022,8 +2032,6 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)

return list(region_x1 & region_x2, region_y1 & region_y2)

#define TURF_FROM_COORDS_LIST(List) (locate(List[1], List[2], List[3]))

//Vars that will not be copied when using /DuplicateObject
GLOBAL_LIST_INIT(duplicate_forbidden_vars,list(
"tag", "datum_components", "area", "type", "loc", "locs", "vars", "parent", "parent_type", "verbs", "ckey", "key",
Expand Down
6 changes: 6 additions & 0 deletions code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ DEFINE_BITFIELD(flags_atom, list(
"USES_HEARING" = USES_HEARING,
))

DEFINE_BITFIELD(turf_flags, list(
"TURF_ORGANIC" = TURF_ORGANIC,
"UNUSED_RESERVATION_TURF" = UNUSED_RESERVATION_TURF,
"RESERVATION_TURF" = RESERVATION_TURF,
))

DEFINE_BITFIELD(flags_item, list(
"NODROP" = NODROP,
"NOBLUDGEON" = NOBLUDGEON,
Expand Down
Loading

0 comments on commit 90ef5a2

Please sign in to comment.