From f2813a6730ab7eca79718da1d52f3ffcc0d42b0d Mon Sep 17 00:00:00 2001 From: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com> Date: Sat, 9 Jul 2022 09:55:12 -0400 Subject: [PATCH] Complete Library Overhaul Part 1 (#17832) * first edits * more commits yay * more changes * Update paradise.dme * changes * more edits * more edits * changes * more changes * changes * more stuff stuff Update tgui.bundle.js * FUCK * Many UI changes * Update Lib Computer UI and Correct Map Issues * squashed commits :) Guts Old Book/Manual Code and Reworks it final (almost) touches * this should pass tests now * fixes random ruin having a removed object * adds review suggestions Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com> * squashed commits :) update schema adds python requested changes implements proper python & sql scripts applies some requested changes + minor fixes bump SQL version to 40 Co-Authored-By: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> * applies requested changes from code review * lets pass some tests today more fixes * Apply suggestions from code review Co-authored-by: Farie82 * more requested changes fulfilled * should fix map issues + a couple other things * fixes & sanitization stuff * Apply suggestions from code review Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com> * updates UI and implements more requested changes * mother of bug fixes & UI cleanup * removes unused code * Apply suggestions from code review Co-authored-by: Farie82 * fixes * adds GC checks * Apply suggestions from code review Co-authored-by: Farie82 * requested changes + TGUI Cleanup and Styling Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com> Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Co-authored-by: Farie82 Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com> --- SQL/paradise_schema.sql | 27 +- SQL/updates/37-38.sql | 26 + SQL/updates/38-39.py | 130 ++ SQL/updates/39-40.sql | 3 + SQL/updates/Readme.md | 2 +- _maps/map_files/Delta/delta.dmm | 91 +- _maps/map_files/MetaStation/MetaStation.dmm | 93 +- .../RandomRuins/SpaceRuins/debris3.dmm | 2 +- .../SpaceRuins/intactemptyship.dmm | 2 +- .../RandomRuins/SpaceRuins/oldstation.dmm | 2 +- .../SpaceRuins/syndie_space_base.dmm | 4 +- .../map_files/RandomRuins/SpaceRuins/ussp.dmm | 2 +- .../RandomRuins/SpaceRuins/wizardcrash.dmm | 2 +- _maps/map_files/RandomZLevels/example.dmm | 2 +- .../map_files/RandomZLevels/moonoutpost19.dmm | 4 +- .../map_files/RandomZLevels/terrorspiders.dmm | 4 +- _maps/map_files/cyberiad/cyberiad.dmm | 215 ++- _maps/map_files/generic/centcomm.dmm | 2 +- .../map_files/shuttles/emergency_cramped.dmm | 2 +- _maps/map_files/shuttles/emergency_meta.dmm | 2 +- code/__DEFINES/library.dm | 47 + code/__DEFINES/misc.dm | 2 +- code/__DEFINES/text.dm | 4 +- code/_globalvars/misc.dm | 3 + code/game/jobs/job/support.dm | 2 +- .../game/objects/effects/spawners/lootdrop.dm | 4 +- code/game/objects/items/weapons/cards_ids.dm | 5 + code/game/objects/items/weapons/manuals.dm | 1304 +++++------------ .../items/weapons/storage/uplink_kits.dm | 2 +- .../crates_lockers/closets/secure/security.dm | 8 +- code/modules/admin/admin_verbs.dm | 6 +- code/modules/admin/topic.dm | 58 - code/modules/library/admin.dm | 64 - code/modules/library/book.dm | 377 +++++ code/modules/library/codex_gigas.dm | 11 - code/modules/library/computers/base.dm | 110 -- code/modules/library/computers/checkout.dm | 477 ------ code/modules/library/computers/public.dm | 127 -- code/modules/library/lib_items.dm | 327 ----- code/modules/library/lib_machines.dm | 225 --- code/modules/library/lib_readme.dm | 61 - code/modules/library/library_admin.dm | 206 +++ code/modules/library/library_catalog.dm | 653 +++++++++ code/modules/library/library_computer.dm | 583 ++++++++ code/modules/library/library_datums.dm | 134 ++ code/modules/library/library_equipment.dm | 424 ++++++ code/modules/library/library_readme.dm | 40 + code/modules/library/random_books.dm | 96 -- .../reagents/chemistry/reagents/alcohol.dm | 3 +- config/example/config.toml | 2 +- icons/obj/library.dmi | Bin 29755 -> 26447 bytes paradise.dme | 17 +- sound/items/scannerbeep.ogg | Bin 0 -> 9535 bytes tgui/packages/tgui/interfaces/BookBinder.js | 112 ++ .../tgui/interfaces/LibraryComputer.js | 704 +++++++++ .../tgui/interfaces/LibraryManager.js | 221 +++ tgui/packages/tgui/public/tgui.bundle.css | 2 +- tgui/packages/tgui/public/tgui.bundle.js | 6 +- .../styles/interfaces/LibraryComputer.scss | 29 + tgui/packages/tgui/styles/main.scss | 1 + tools/ci/generate_sql_scripts.py | 4 +- wire1.dmi | Bin 0 -> 249 bytes 62 files changed, 4366 insertions(+), 2712 deletions(-) create mode 100644 SQL/updates/37-38.sql create mode 100644 SQL/updates/38-39.py create mode 100644 SQL/updates/39-40.sql create mode 100644 code/__DEFINES/library.dm delete mode 100644 code/modules/library/admin.dm create mode 100644 code/modules/library/book.dm delete mode 100644 code/modules/library/codex_gigas.dm delete mode 100644 code/modules/library/computers/base.dm delete mode 100644 code/modules/library/computers/checkout.dm delete mode 100644 code/modules/library/computers/public.dm delete mode 100644 code/modules/library/lib_items.dm delete mode 100644 code/modules/library/lib_machines.dm delete mode 100644 code/modules/library/lib_readme.dm create mode 100644 code/modules/library/library_admin.dm create mode 100644 code/modules/library/library_catalog.dm create mode 100644 code/modules/library/library_computer.dm create mode 100644 code/modules/library/library_datums.dm create mode 100644 code/modules/library/library_equipment.dm create mode 100644 code/modules/library/library_readme.dm delete mode 100644 code/modules/library/random_books.dm create mode 100644 sound/items/scannerbeep.ogg create mode 100644 tgui/packages/tgui/interfaces/BookBinder.js create mode 100644 tgui/packages/tgui/interfaces/LibraryComputer.js create mode 100644 tgui/packages/tgui/interfaces/LibraryManager.js create mode 100644 tgui/packages/tgui/styles/interfaces/LibraryComputer.scss create mode 100644 wire1.dmi diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index 38c881c25c2..4784f58fe90 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -367,17 +367,22 @@ DROP TABLE IF EXISTS `library`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `library` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `author` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, - `title` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, - `content` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, - `category` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, - `ckey` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL, - `flagged` int(11) NOT NULL, - PRIMARY KEY (`id`), - KEY `ckey` (`ckey`), - KEY `flagged` (`flagged`) -) ENGINE=InnoDB AUTO_INCREMENT=4537 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + `id` INT(11) NOT NULL AUTO_INCREMENT, + `author` MEDIUMTEXT NOT NULL COLLATE 'utf8mb4_unicode_ci', + `title` MEDIUMTEXT NOT NULL COLLATE 'utf8mb4_unicode_ci', + `content` MEDIUMTEXT NOT NULL COLLATE 'utf8mb4_unicode_ci', + `ckey` VARCHAR(32) NOT NULL COLLATE 'utf8mb4_unicode_ci', + `reports` MEDIUMTEXT NOT NULL COLLATE 'utf8mb3_general_ci', + `summary` MEDIUMTEXT NOT NULL COLLATE 'utf8mb3_general_ci', + `rating` DOUBLE NULL DEFAULT '0', + `raters` MEDIUMTEXT NOT NULL COLLATE 'utf8mb3_general_ci', + `primary_category` INT(11) NULL DEFAULT '0', + `secondary_category` INT(11) NOT NULL DEFAULT '0', + `tertiary_category` INT(11) NULL DEFAULT '0', + PRIMARY KEY (`id`) USING BTREE, + INDEX `ckey` (`ckey`) USING BTREE, + INDEX `flagged` (`reports`(1024)) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- diff --git a/SQL/updates/37-38.sql b/SQL/updates/37-38.sql new file mode 100644 index 00000000000..645c1234a36 --- /dev/null +++ b/SQL/updates/37-38.sql @@ -0,0 +1,26 @@ +# Updates DB from 37 to 38 -Sirryan2002 +# Creates new tables in preparation for library table conversion + +#Renames old table +ALTER TABLE library RENAME TO library_old; + +# Create new table to track library books +CREATE TABLE `library` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `author` MEDIUMTEXT NOT NULL COLLATE 'utf8mb4_unicode_ci', + `title` MEDIUMTEXT NOT NULL COLLATE 'utf8mb4_unicode_ci', + `content` MEDIUMTEXT NOT NULL COLLATE 'utf8mb4_unicode_ci', + `ckey` VARCHAR(32) NULL DEFAULT '' COLLATE 'utf8mb4_unicode_ci', + `reports` MEDIUMTEXT NOT NULL COLLATE 'utf8mb3_general_ci', + `summary` MEDIUMTEXT NOT NULL COLLATE 'utf8mb3_general_ci', + `rating` DOUBLE NULL DEFAULT '0', + `raters` MEDIUMTEXT NOT NULL COLLATE 'utf8mb3_general_ci', + `primary_category` INT(11) NULL DEFAULT '0', + `secondary_category` INT(11) NOT NULL DEFAULT '0', + `tertiary_category` INT(11) NULL DEFAULT '0', + PRIMARY KEY (`id`) USING BTREE, + INDEX `ckey` (`ckey`) USING BTREE, + INDEX `flagged` (`reports`(1024)) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +# YOU MUST NOW RUN 38-39.py diff --git a/SQL/updates/38-39.py b/SQL/updates/38-39.py new file mode 100644 index 00000000000..3b8edbf2154 --- /dev/null +++ b/SQL/updates/38-39.py @@ -0,0 +1,130 @@ +# :wave: hello fellow contributors, this script is brought to you ad-free by -sirryan2002- +# In order to run this script on Windows, you need to make sure you have Python **3** installed. Tested on 3.10.4 +# In addition you must have the mysql-connector-python module installed (can be done through pip :D) +# if you do not have that module installed, you cannot run this script + +# To run this, supply the following args in a command shell +# python 38-39.py address username password database +# Example: +# python 38-39.py 127.0.0.1 sirryan2002 myubersecretdbpassword paradise_gamedb + +import json +import mysql.connector, argparse + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("address", help="MySQL server address (use localhost for the current computer)") + parser.add_argument("username", help="MySQL login username") + parser.add_argument("password", help="MySQL login password") + parser.add_argument("database", help="Database name") + + args = parser.parse_args() + db = mysql.connector.connect(host=args.address, user=args.username, passwd=args.password, db=args.database) + cursor = db.cursor() + print("Connected to {}".format(args.database)) + #A List of old categories names + the new id number they will be assigned + category_name_to_id_map = { + "Fiction": 1, + "Non-Fiction": 2, + "Adult": 0, #0 represents a "removed"/unused category that no longer will be included + "Reference": 16, + "Religion": 3, + } + + cursor.execute("SELECT id, author, title, content, category, ckey FROM library_old") + data = cursor.fetchall() + + print("Loaded {} rows from library table...".format(len(data))) + + new_rows = [] + print("Modifying Categories...") + for entry in data: + book_id = entry[0] + author = entry[1] + title = entry[2] + content = entry[3] + category = entry[4] + ckey = entry[5] + + update_entry = False + new_entry = [ + book_id, + author, + title, + content, + category, + ckey, + ] + if category not in category_name_to_id_map.keys(): + update_entry = True + new_entry[4] = 0 + print("Corrupted Category Detected: removing \"{}\"...".format(category)) + else: + for cat in category_name_to_id_map.keys(): + if cat == category: + update_entry = True + new_entry[4] = category_name_to_id_map[cat] + if update_entry: + new_rows.append(new_entry) + else: + print("ERROR: Book {} did not have its category changed".format(book_id)) + + print("Modifying Content...") + for entry in new_rows: + new_content = json.dumps([entry[3]]) + entry[3] = new_content + #here we're turning our content string into a JSON list + print("Modified Content...") + print("Vetting Book Titles & Contents...") + duplicate_books = 0 + programmatic_books = 0 + notitle_books = 0 + short_books = 0 + for entry in new_rows: + if "Print Job" in entry[2]: + print("Book {} had \"Print Job\" in title: removing record...".format(entry[0])) + notitle_books += 1 + new_rows.remove(entry) + continue + if "Standard Operating Procedure" in entry[2] or "