Skip to content

Commit

Permalink
server: port tgui4 from paradise (ss220-space#4981)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimach authored Jul 8, 2024
1 parent 0e3f611 commit 555c043
Show file tree
Hide file tree
Showing 719 changed files with 41,833 additions and 31,820 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,28 @@ jobs:
with:
path: $HOME/SpacemanDMM
key: ${{ runner.os }}-spacemandmm

- name: Install Tools
run: |
bash tools/ci/install_build_deps.sh
bash tools/ci/install_dreamchecker.sh
- uses: actions/setup-python@v5
with:
python-version: '3.11.6'
cache: 'pip'

- name: Install python packages
run: pip3 install -r tools/requirements.txt

- name: Run Linters
run: |
find . -name "*.json" -not -path "*/node_modules/*" -print0 | xargs -0 python3 ./tools/ci/json_verifier.py
tools/ci/build_tgui.sh
tools/ci/check_grep.sh
python3 tools/ci/check_line_endings.py
python3 tools/ci/unticked_files.py ${GITHUB_WORKSPACE}
- name: Run DreamChecker
shell: bash
run: ~/dreamchecker 2>&1 | bash tools/ci/annotate_dm.sh
Expand Down
48 changes: 47 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,51 @@
{
"eslint.workingDirectories": ["tgui/"],
"eslint.nodePath": "tgui/.yarn/sdks",
"prettier.configPath": "tgui/.prettierrc.yml",
"prettier.prettierPath": "tgui/.yarn/sdks/prettier/index.cjs",
"typescript.tsdk": "tgui/.yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"eslint.format.enable": true,
"eslint.rules.customizations": [
{ "rule": "*", "severity": "warn" }
],

"[javascript]": {
"editor.rulers": [80],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[javascriptreact]": {
"editor.rulers": [80],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[typescript]": {
"editor.rulers": [80],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[typescriptreact]": {
"editor.rulers": [80],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[scss]": {
"editor.rulers": [80],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},

"editor.formatOnSave": true,
"gitlens.advanced.blame.customArguments": [
"--ignore-revs-file",
"${workspaceRoot}/.git-blame-ignore-revs"
],
"workbench.editorAssociations": {
"*.dmi": "dmiEditor.dmiEditor"
}
},
}
8 changes: 8 additions & 0 deletions code/__DEFINES/asset_defines.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// Get html to load a url.
/// for use inside of browse() calls to html assets that might be loaded on a cdn.
#define URL2HTMLLOADER(url) {"<html><head><meta http-equiv="refresh" content="0;URL='[url]'"/></head><body onLoad="parent.location='[url]'"></body></html>"}

/// Generate a filename for this asset
/// The same asset will always lead to the same asset name
/// Generated names do not include file extension.
#define GENERATE_ASSET_NAME(file) "asset.[md5(fcopy_rsc(file))]"
26 changes: 13 additions & 13 deletions code/__DEFINES/construction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@
#define FULLTILE_WINDOW_DIR NORTHEAST

//Material defines, for determining how much of a given material an item contains
#define MAT_METAL "$metal"
#define MAT_GLASS "$glass"
#define MAT_SILVER "$silver"
#define MAT_GOLD "$gold"
#define MAT_DIAMOND "$diamond"
#define MAT_URANIUM "$uranium"
#define MAT_PLASMA "$plasma"
#define MAT_BLUESPACE "$bluespace"
#define MAT_BANANIUM "$bananium"
#define MAT_TRANQUILLITE "$tranquillite"
#define MAT_TITANIUM "$titanium"
#define MAT_BIOMASS "$biomass"
#define MAT_PLASTIC "$plastic"
#define MAT_METAL "metal"
#define MAT_GLASS "glass"
#define MAT_SILVER "silver"
#define MAT_GOLD "gold"
#define MAT_DIAMOND "diamond"
#define MAT_URANIUM "uranium"
#define MAT_PLASMA "plasma"
#define MAT_BLUESPACE "bluespace"
#define MAT_BANANIUM "bananium"
#define MAT_TRANQUILLITE "tranquillite"
#define MAT_TITANIUM "titanium"
#define MAT_BIOMASS "biomass"
#define MAT_PLASTIC "plastic"
//The amount of materials you get from a sheet of mineral like iron/diamond/glass etc
#define MINERAL_MATERIAL_AMOUNT 2000
//The maximum size of a stack object.
Expand Down
6 changes: 0 additions & 6 deletions code/__DEFINES/stat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
#define UNCONSCIOUS 1
#define DEAD 2

// TGUI flags
#define STATUS_INTERACTIVE 2 // GREEN Visability
#define STATUS_UPDATE 1 // ORANGE Visability
#define STATUS_DISABLED 0 // RED Visability
#define STATUS_CLOSE -1 // Close the interface

// bitflags for machine stat variable
#define BROKEN (1<<0)
#define NOPOWER (1<<1)
Expand Down
8 changes: 0 additions & 8 deletions code/__DEFINES/tgui.dm

This file was deleted.

46 changes: 46 additions & 0 deletions code/__DEFINES/tgui_defines.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// TGUI Modal defines
#define UI_MODAL_INPUT_MAX_LENGTH 1024
#define UI_MODAL_INPUT_MAX_LENGTH_NAME 64 // Names for generally anything don't go past 32, let alone 64.

#define UI_MODAL_OPEN 1
#define UI_MODAL_DELEGATE 2
#define UI_MODAL_ANSWER 3
#define UI_MODAL_CLOSE 4

/// Green eye; fully interactive
#define UI_INTERACTIVE 2
/// Orange eye; updates but is not interactive
#define UI_UPDATE 1
/// Red eye; disabled, does not update
#define UI_DISABLED 0
/// UI Should close
#define UI_CLOSE -1

/// Maximum number of windows that can be suspended/reused
#define TGUI_WINDOW_SOFT_LIMIT 5
/// Maximum number of open windows
#define TGUI_WINDOW_HARD_LIMIT 9

/// Maximum ping timeout allowed to detect zombie windows
#define TGUI_PING_TIMEOUT (4 SECONDS)
/// Used for rate-limiting to prevent DoS by excessively refreshing a TGUI window
#define TGUI_REFRESH_FULL_UPDATE_COOLDOWN (1 SECONDS)

/// Window does not exist
#define TGUI_WINDOW_CLOSED 0
/// Window was just opened, but is still not ready to be sent data
#define TGUI_WINDOW_LOADING 1
/// Window is free and ready to receive data
#define TGUI_WINDOW_READY 2

/// Get a window id based on the provided pool index
#define TGUI_WINDOW_ID(index) "tgui-window-[index]"
/// Get a pool index of the provided window id
#define TGUI_WINDOW_INDEX(window_id) text2num(copytext(window_id, 13))

/// Creates a message packet for sending via output()
#define TGUI_CREATE_MESSAGE(type, payload) ( \
url_encode(json_encode(list( \
"type" = type, \
"payload" = payload, \
))))
15 changes: 13 additions & 2 deletions code/__HELPERS/_logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,19 @@ GLOBAL_PROTECT(log_end)
/proc/log_runtime_summary(text)
WRITE_LOG(GLOB.runtime_summary_log, "[text][GLOB.log_end]")

/proc/log_tgui(text)
WRITE_LOG(GLOB.tgui_log, "[text][GLOB.log_end]")
/proc/log_tgui(user_or_client, text)
var/list/messages = list()
if(!user_or_client)
messages.Add("no user")
else if(ismob(user_or_client))
var/mob/user = user_or_client
messages.Add("[user.ckey] (as [user])")
else if(isclient(user_or_client))
var/client/client = user_or_client
messages.Add("[client.ckey]")
messages.Add(": [text]")
messages.Add("[GLOB.log_end]")
WRITE_LOG(GLOB.tgui_log, messages.Join())

/proc/log_sql(text)
WRITE_LOG(GLOB.sql_log, "[text][GLOB.log_end]")
Expand Down
15 changes: 15 additions & 0 deletions code/__HELPERS/files.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,18 @@
GLOB.fileaccess_timer = world.time + FTPDELAY
return 0
#undef FTPDELAY

/// Returns the md5 of a file at a given path.
/proc/md5filepath(path)
. = md5(file(path))

/// Save file as an external file then md5 it.
/// Used because md5ing files stored in the rsc sometimes gives incorrect md5 results.
/proc/md5asfile(file)
var/static/notch = 0
// Its importaint this code can handle md5filepath sleeping instead of hard blocking, if it's converted to use rust_g.
var/filename = "tmp/md5asfile.[world.realtime].[world.timeofday].[world.time].[world.tick_usage].[notch]"
notch = WRAP(notch+1, 0, 2**15)
fcopy(file, filename)
. = md5filepath(filename)
fdel(filename)
129 changes: 129 additions & 0 deletions code/__HELPERS/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@

GLOB.emote_list = init_emote_list()
GLOB.uplink_items = init_uplink_items_list()
GLOB.mining_vendor_items = init_mining_vendor_items_list()

// Keybindings
for(var/path in subtypesof(/datum/keybinding))
Expand Down Expand Up @@ -231,6 +232,134 @@
var/datum/uplink_item/item = new item_path
. += item

// Use this define to register something as a purchasable!
// * n — The proper name of the purchasable
// * o — The object type path of the purchasable to spawn
// * p — The price of the purchasable in mining points
#define EQUIPMENT(n, o, p) n = new /datum/data/mining_equipment(n, o, p)

/proc/init_mining_vendor_items_list()
var/prize_list = list()
prize_list["Gear"] = list(
EQUIPMENT("Automatic Scanner", /obj/item/t_scanner/adv_mining_scanner/lesser, 800),
EQUIPMENT("Advanced Scanner", /obj/item/t_scanner/adv_mining_scanner, 3000),
EQUIPMENT("Explorer's Webbing", /obj/item/storage/belt/mining, 700),
EQUIPMENT("Mining Weather Radio", /obj/item/radio/weather_monitor, 700),
EQUIPMENT("Fulton Beacon", /obj/item/fulton_core, 500),
EQUIPMENT("Mining Conscription Kit", /obj/item/storage/backpack/duffel/mining_conscript, 2000),
EQUIPMENT("Jump Boots", /obj/item/clothing/shoes/bhop, 3000),
EQUIPMENT("Jump Boots Implants", /obj/item/storage/box/jumpbootimplant, 7000),
EQUIPMENT("Lazarus Capsule", /obj/item/mobcapsule, 300),
EQUIPMENT("Lazarus Capsule belt", /obj/item/storage/belt/lazarus, 400),
EQUIPMENT("Mining Hardsuit", /obj/item/clothing/suit/space/hardsuit/mining, 2500),
EQUIPMENT("Tracking Implant Kit", /obj/item/storage/box/minertracker, 800),
EQUIPMENT("Industrial Mining Satchel", /obj/item/storage/bag/ore/bigger, 500),
EQUIPMENT("Meson Health Scanner HUD", /obj/item/clothing/glasses/hud/health/meson, 1500),
EQUIPMENT("Mining Charge Detonator", /obj/item/detonator, 150),
)
prize_list["Consumables"] = list(
EQUIPMENT("Marker Beacons (10)", /obj/item/stack/marker_beacon/ten, 100),
EQUIPMENT("Marker Beacons (30)", /obj/item/stack/marker_beacon/thirty, 300),
EQUIPMENT("Pocket Fire Extinguisher", /obj/item/extinguisher/mini, 400),
EQUIPMENT("Brute First-Aid Kit", /obj/item/storage/firstaid/brute, 800),
EQUIPMENT("Fire First-Aid Kit", /obj/item/storage/firstaid/fire, 800),
EQUIPMENT("Emergency Charcoal Injector", /obj/item/reagent_containers/hypospray/autoinjector/charcoal, 400),
EQUIPMENT("Mining Charge", /obj/item/grenade/plastic/miningcharge/lesser, 150),
EQUIPMENT("Industrial Mining Charge", /obj/item/grenade/plastic/miningcharge, 500),
EQUIPMENT("Whetstone", /obj/item/whetstone, 500),
EQUIPMENT("Fulton Pack", /obj/item/extraction_pack, 1500),
EQUIPMENT("Jaunter", /obj/item/wormhole_jaunter, 900),
EQUIPMENT("Chasm Jaunter Recovery Grenade", /obj/item/grenade/jaunter_grenade, 3000), //fishing rod supremacy
EQUIPMENT("Lazarus Injector", /obj/item/lazarus_injector, 600),
EQUIPMENT("Point Transfer Card (500)", /obj/item/card/mining_point_card, 500),
EQUIPMENT("Point Transfer Card (1000)", /obj/item/card/mining_point_card/thousand, 1000),
EQUIPMENT("Point Transfer Card (5000)", /obj/item/card/mining_point_card/fivethousand, 5000),
EQUIPMENT("Shelter Capsule", /obj/item/survivalcapsule, 700),
EQUIPMENT("Stabilizing Serum", /obj/item/hivelordstabilizer, 600),
EQUIPMENT("Survival Medipen", /obj/item/reagent_containers/hypospray/autoinjector/survival, 800),
)
prize_list["Kinetic Accelerator"] = list(
EQUIPMENT("Kinetic Accelerator", /obj/item/gun/energy/kinetic_accelerator, 1000),
EQUIPMENT("KA Adjustable Tracer Rounds", /obj/item/borg/upgrade/modkit/tracer/adjustable, 200),
EQUIPMENT("KA AoE Damage", /obj/item/borg/upgrade/modkit/aoe/mobs, 2500),
EQUIPMENT("KA Cooldown Decrease", /obj/item/borg/upgrade/modkit/cooldown/haste, 1500),
EQUIPMENT("KA Damage Increase", /obj/item/borg/upgrade/modkit/damage, 1500),
EQUIPMENT("KA Range Increase", /obj/item/borg/upgrade/modkit/range, 1500),
EQUIPMENT("KA Hardness Increase", /obj/item/borg/upgrade/modkit/hardness, 2500),
EQUIPMENT("KA Offensive Mining Explosion", /obj/item/borg/upgrade/modkit/aoe/turfs/andmobs, 3000),
EQUIPMENT("KA Rapid Repeater", /obj/item/borg/upgrade/modkit/cooldown/repeater, 2000),
EQUIPMENT("KA Resonator Blast", /obj/item/borg/upgrade/modkit/resonator_blasts, 2000),
EQUIPMENT("KA Minebot Passthrough", /obj/item/borg/upgrade/modkit/minebot_passthrough, 300),
EQUIPMENT("KA Super Chassis", /obj/item/borg/upgrade/modkit/chassis_mod, 300),
EQUIPMENT("KA Hyper Chassis", /obj/item/borg/upgrade/modkit/chassis_mod/orange, 500),
EQUIPMENT("KA White Tracer Rounds", /obj/item/borg/upgrade/modkit/tracer, 250),
)
prize_list["Digging Tools"] = list(
EQUIPMENT("Diamond Pickaxe", /obj/item/pickaxe/diamond, 1500),
EQUIPMENT("Kinetic Accelerator", /obj/item/gun/energy/kinetic_accelerator, 1000),
EQUIPMENT("Kinetic Crusher", /obj/item/twohanded/kinetic_crusher, 1000),
EQUIPMENT("Resonator", /obj/item/resonator, 400),
EQUIPMENT("Silver Pickaxe", /obj/item/pickaxe/silver, 800),
EQUIPMENT("Super Resonator", /obj/item/resonator/upgraded, 1200),
EQUIPMENT("Plasma Cutter", /obj/item/gun/energy/plasmacutter, 1500),
)
prize_list["Minebot"] = list(
EQUIPMENT("Nanotrasen Minebot", /obj/item/mining_drone_cube, 800),
EQUIPMENT("Minebot AI Upgrade", /obj/item/slimepotion/sentience/mining, 1000),
EQUIPMENT("Minebot Armor Upgrade", /obj/item/mine_bot_upgrade/health, 400),
EQUIPMENT("Minebot Cooldown Upgrade", /obj/item/borg/upgrade/modkit/cooldown/haste/minebot, 600),
EQUIPMENT("Minebot Melee Upgrade", /obj/item/mine_bot_upgrade, 400),
)
prize_list["Miscellaneous"] = list(
EQUIPMENT("Absinthe", /obj/item/reagent_containers/food/drinks/bottle/absinthe/premium, 500),
EQUIPMENT("Alien Toy", /obj/item/clothing/mask/facehugger/toy, 300),
EQUIPMENT("Cigar", /obj/item/clothing/mask/cigarette/cigar/havana, 300),
EQUIPMENT("GAR Meson Scanners", /obj/item/clothing/glasses/meson/gar, 800),
EQUIPMENT("GPS upgrade", /obj/item/gpsupgrade, 1500),
EQUIPMENT("Laser Pointer", /obj/item/laser_pointer, 500),
EQUIPMENT("Luxury Shelter Capsule", /obj/item/survivalcapsule/luxury, 5000),
EQUIPMENT("Luxury Elite Bar Capsule", /obj/item/survivalcapsule/luxuryelite, 10000),
EQUIPMENT("Soap", /obj/item/soap/nanotrasen, 400),
EQUIPMENT("Space Cash", /obj/item/stack/spacecash/c1000, 2500),
EQUIPMENT("Whiskey", /obj/item/reagent_containers/food/drinks/bottle/whiskey, 500),
EQUIPMENT("HRD-MDE Project Box", /obj/item/storage/box/hardmode_box, 2500),
)
prize_list["Extra"] = list(
EQUIPMENT("Extra ID", /obj/item/card/id/golem, 250),
EQUIPMENT("Science Backpack", /obj/item/storage/backpack/science, 250),
EQUIPMENT("Full Toolbelt", /obj/item/storage/belt/utility/full/multitool, 250),
EQUIPMENT("Monkey Cube", /obj/item/reagent_containers/food/snacks/monkeycube, 250),
EQUIPMENT("Royal Cape of the Liberator", /obj/item/bedsheet/rd/royal_cape, 500),
EQUIPMENT("Grey Slime Extract", /obj/item/slime_extract/grey, 1000),
EQUIPMENT("KA Trigger Modification Kit", /obj/item/borg/upgrade/modkit/trigger_guard, 1000),
EQUIPMENT("Shuttle Console Board", /obj/item/circuitboard/shuttle/golem_ship, 2000),
EQUIPMENT("The Liberator's Legacy", /obj/item/storage/box/rndboards, 2000),
)
prize_list["Scum"] = list(
EQUIPMENT("Trauma Kit", /obj/item/stack/medical/bruise_pack/advanced, 150),
EQUIPMENT("Whisky", /obj/item/reagent_containers/food/drinks/bottle/whiskey, 100),
EQUIPMENT("Beer", /obj/item/reagent_containers/food/drinks/cans/beer, 50),
EQUIPMENT("Absinthe", /obj/item/reagent_containers/food/drinks/bottle/absinthe/premium, 250),
EQUIPMENT("Cigarettes", /obj/item/storage/fancy/cigarettes, 100),
EQUIPMENT("Medical Marijuana", /obj/item/storage/fancy/cigarettes/cigpack_med, 250),
EQUIPMENT("Cigar", /obj/item/clothing/mask/cigarette/cigar/havana, 150),
EQUIPMENT("Box of matches", /obj/item/storage/box/matches, 50),
EQUIPMENT("Cheeseburger", /obj/item/reagent_containers/food/snacks/cheeseburger, 150),
EQUIPMENT("Big Burger", /obj/item/reagent_containers/food/snacks/bigbiteburger, 250),
EQUIPMENT("Recycled Prisoner", /obj/item/reagent_containers/food/snacks/soylentgreen, 500),
EQUIPMENT("Crayons", /obj/item/storage/fancy/crayons, 350),
EQUIPMENT("Plushie", /obj/random/plushie, 750),
EQUIPMENT("Dnd set", /obj/item/storage/box/characters, 500),
EQUIPMENT("Dice set", /obj/item/storage/box/dice, 250),
EQUIPMENT("Cards", /obj/item/deck/cards, 150),
EQUIPMENT("Guitar", /obj/item/instrument/guitar, 750),
EQUIPMENT("Synthesizer", /obj/item/instrument/piano_synth, 1500),
EQUIPMENT("Diamond Pickaxe", /obj/item/pickaxe/diamond, 2000)
)
return prize_list

#undef EQUIPMENT


/proc/update_config_movespeed_type_lookup(update_mobs = TRUE)
var/list/mob_types = list()
Expand Down
5 changes: 5 additions & 0 deletions code/_compile_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@
// If this is uncommented, will attempt to load and initialize prof.dll/libprof.so.
// We do not ship byond-tracy. Build it yourself here: https://github.com/mafemergency/byond-tracy/
// #define USE_BYOND_TRACY

#ifndef PRELOAD_RSC //set to:
#define PRELOAD_RSC 0 // 0 to allow using external resources or on-demand behaviour;
#endif // 1 to use the default behaviour;
// 2 for preloading absolutely everything;
2 changes: 2 additions & 0 deletions code/_globalvars/lists/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ GLOBAL_LIST_EMPTY(emote_list)

GLOBAL_LIST_EMPTY(uplink_items)

GLOBAL_LIST_EMPTY(mining_vendor_items)

GLOBAL_LIST_EMPTY(mob_config_movespeed_type_lookup)

Loading

0 comments on commit 555c043

Please sign in to comment.