-
Notifications
You must be signed in to change notification settings - Fork 69
Disc dots, an admin UI, disc teaching, and over a dozen hours of buffy's life #752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
247c1a2
guh
buffyuwu a109b6b
Update preferences_savefile.dm
buffyuwu ec2b04f
local woman stays in the office until 7pm to work on vampire erp code
buffyuwu e329933
fuck
buffyuwu b8c486f
YOU GOT TOO MUCH DIP ON YOUR CHIP
buffyuwu 63275e9
readability
buffyuwu d9c3e19
AAAAAAAAAAAAAAA
buffyuwu 3f7d75b
eheheheheheheh
buffyuwu a631c45
SCREAM
buffyuwu 4e324a4
refactor
buffyuwu d47e41e
Update admin_discipline_editor.dm
buffyuwu 1415c9f
disc teaching fix
buffyuwu 11ba066
slots slots slots slots
buffyuwu 45a90d8
this should match the style of the char setup page
buffyuwu 6bd12e8
save it after teaching so it shows up in the admin ui that reads prefs
buffyuwu f1731c2
ghoul stuff
buffyuwu da18ebe
e
buffyuwu 557cb42
refactoring a bit more
buffyuwu 5a05758
removing unused stuff
buffyuwu 21406a8
move fileeeeee
buffyuwu df33073
changes requested
buffyuwu e5e8b9a
Merge branch 'master' into disc-dots
buffyuwu 3f3c07f
Update tgstation.dme
buffyuwu 17cc0fa
Merge branch 'master' into disc-dots
buffyuwu e17cf88
Update tgstation.dme
buffyuwu ee0eec8
Merge branch 'disc-dots' of https://github.com/buffyuwu/SecondCity in…
buffyuwu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // Second City admin verb category | ||
| #define ADMIN_CATEGORY_SECOND_CITY "Admin.Second City" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
212 changes: 212 additions & 0 deletions
212
modular_darkpack/modules/powers/code/admin_discipline_editor.dm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,212 @@ | ||
| /datum/admin_discipline_editor | ||
| var/target_ckey = "" | ||
| var/selected_slot = 0 | ||
| var/datum/preferences/target_prefs = null | ||
| var/loaded_offline = FALSE | ||
| var/not_found = FALSE | ||
| var/list/discipline_cache = null | ||
|
|
||
| /datum/admin_discipline_editor/Destroy() | ||
| if(loaded_offline) | ||
| QDEL_NULL(target_prefs) | ||
| target_prefs = null | ||
| return ..() | ||
|
|
||
| /datum/admin_discipline_editor/ui_interact(mob/user, datum/tgui/ui) | ||
| ui = SStgui.try_update_ui(user, src, ui) | ||
| if(!ui) | ||
| ui = new(user, src, "AdminDisciplineEditor") | ||
| ui.open() | ||
|
|
||
| /datum/admin_discipline_editor/ui_state(mob/user) | ||
| return ADMIN_STATE(R_ADMIN) | ||
|
|
||
| /datum/admin_discipline_editor/ui_data(mob/user) | ||
| var/list/data = list() | ||
| data["target_ckey"] = target_ckey | ||
| data["selected_slot"] = selected_slot | ||
| data["not_found"] = not_found | ||
| data["is_trusted"] = target_prefs?.discipline_trusted || FALSE | ||
| data["character_slots"] = list() | ||
| data["discipline_levels"] = list() | ||
| data["clan_disciplines"] = list() | ||
| data["disciplines"] = build_discipline_cache() | ||
| data["discipline_validation"] = null | ||
| data["character_name"] = null | ||
| data["character_age"] = null | ||
| data["immortal_age"] = null | ||
| data["clan_name"] = null | ||
| data["splat_name"] = null | ||
| data["flavor_text"] = null | ||
| data["headshot"] = null | ||
|
|
||
| var/list/connected = list() | ||
| var/list/invalid_ckeys = list() | ||
| var/list/trusted_ckeys = list() | ||
| for(var/ckey in GLOB.directory) | ||
| var/client/C = GLOB.directory[ckey] | ||
| if(!C || !C.mob) | ||
| continue | ||
| connected += ckey | ||
| if(C.prefs?.discipline_trusted) | ||
| trusted_ckeys += ckey | ||
| if(ishuman(C.mob)) | ||
| var/list/validation = validate_mob_sheet(C.mob) | ||
| if(validation && !validation["valid"]) | ||
| invalid_ckeys += ckey | ||
| data["connected_ckeys"] = connected | ||
| data["invalid_ckeys"] = invalid_ckeys | ||
| data["trusted_ckeys"] = trusted_ckeys | ||
|
|
||
| if(target_prefs) | ||
| var/list/profiles = target_prefs.create_character_profiles() | ||
| for(var/i in 1 to target_prefs.max_save_slots) | ||
| if(profiles[i]) | ||
| data["character_slots"] += list(list("slot" = i, "name" = profiles[i])) | ||
|
|
||
| if(selected_slot > 0) | ||
| data["character_name"] = target_prefs.read_preference(/datum/preference/name/real_name) | ||
| data["character_age"] = target_prefs.read_preference(/datum/preference/numeric/age) | ||
| data["immortal_age"] = target_prefs.read_preference(/datum/preference/numeric/immortal_age) | ||
| data["flavor_text"] = target_prefs.read_preference(/datum/preference/text/flavor_text) | ||
| data["headshot"] = target_prefs.read_preference(/datum/preference/text/headshot) | ||
|
|
||
| var/splat_path = target_prefs.read_preference(/datum/preference/choiced/splats) | ||
| if(ispath(splat_path, /datum/splat)) | ||
| var/datum/splat/splat_proto = GLOB.splat_prototypes[splat_path] | ||
| data["splat_name"] = splat_proto?.name | ||
| else | ||
| data["splat_name"] = "Human" | ||
|
|
||
| var/list/clan_discs = list() | ||
| for(var/disc_path in target_prefs.discipline_levels) | ||
| data["discipline_levels"]["[disc_path]"] = target_prefs.discipline_levels[disc_path] | ||
|
|
||
| var/clan_value = target_prefs.read_preference(/datum/preference/choiced/subsplat/vampire_clan) | ||
| if(clan_value) | ||
| var/datum/subsplat/vampire_clan/clan_datum = get_vampire_clan(clan_value) | ||
| if(clan_datum) | ||
| data["clan_name"] = clan_datum.name | ||
| for(var/disc_type in clan_datum.clan_disciplines) | ||
| if(ispath(disc_type, /datum/discipline)) | ||
| var/disc_str = "[disc_type]" | ||
| data["clan_disciplines"] += disc_str | ||
| clan_discs += disc_str | ||
|
|
||
| data["discipline_validation"] = validate_discipline_sheet(target_prefs.discipline_levels, clan_discs, target_prefs.discipline_trusted) | ||
|
|
||
| return data | ||
|
|
||
| /datum/admin_discipline_editor/proc/build_discipline_cache() | ||
| if(discipline_cache) | ||
| return discipline_cache | ||
|
|
||
| discipline_cache = list() | ||
| for(var/discipline_type in subtypesof(/datum/discipline)) | ||
| var/datum/discipline/discipline = new discipline_type | ||
| if(!discipline.selectable) | ||
| qdel(discipline) | ||
| continue | ||
| if(ispath(discipline_type, /datum/discipline/path)) | ||
| qdel(discipline) | ||
| continue | ||
| var/list/disc_data = list() | ||
| disc_data["name"] = discipline.name | ||
| disc_data["desc"] = discipline.desc | ||
| disc_data["max_level"] = discipline.max_selectable_level || length(discipline.all_powers) | ||
| disc_data["rarity"] = (discipline_type in RARE_DISCIPLINE_TYPES) ? "rare" : "common" | ||
| disc_data["icon"] = initial(discipline.icon) | ||
| disc_data["icon_state"] = discipline.icon_state | ||
| discipline_cache["[discipline_type]"] = disc_data | ||
| qdel(discipline) | ||
|
|
||
| return discipline_cache | ||
|
|
||
| /datum/admin_discipline_editor/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) | ||
| . = ..() | ||
| if(.) | ||
| return | ||
|
|
||
| switch(action) | ||
| if("search_ckey") | ||
| var/search = params["ckey"] | ||
| if(!search) | ||
| return FALSE | ||
| search = ckey(search) | ||
| not_found = !load_target(search) | ||
| log_admin_private("[key_name_admin(ui.user)] searched for [search] in the discipline UI.") | ||
| return TRUE | ||
|
|
||
| if("select_slot") | ||
| if(!target_prefs) | ||
| return FALSE | ||
| var/slot = round(text2num(params["slot"])) | ||
| if(!slot) | ||
| return FALSE | ||
| slot = clamp(slot, 1, target_prefs.max_save_slots) | ||
| target_prefs.load_character(slot) | ||
| target_prefs.default_slot = slot | ||
| selected_slot = slot | ||
| return TRUE | ||
|
|
||
| if("set_discipline_level") | ||
| if(!target_prefs || !selected_slot) | ||
| return FALSE | ||
| var/disc_path = params["discipline"] | ||
| var/new_level = text2num(params["level"]) | ||
| if(!disc_path || isnull(new_level)) | ||
| return FALSE | ||
| new_level = round(new_level) | ||
| if(new_level < 0 || new_level > 5) | ||
| return FALSE | ||
| if(new_level == 0) | ||
| target_prefs.discipline_levels -= disc_path | ||
| else | ||
| target_prefs.discipline_levels[disc_path] = new_level | ||
| target_prefs.save_character() | ||
| var/character_name = target_prefs.read_preference(/datum/preference/name/real_name) | ||
| message_admins("[key_name_admin(ui.user)] set [disc_path] to level [new_level] for [ADMIN_LOOKUPFLW(target_ckey)]'s character [character_name]).") | ||
| log_admin("[key_name_admin(ui.user)] set [disc_path] to level [new_level] for [ADMIN_LOOKUPFLW(target_ckey)]'s character [character_name]).") | ||
| return TRUE | ||
|
|
||
| if("toggle_trusted") | ||
| if(!target_prefs) | ||
| return FALSE | ||
| target_prefs.discipline_trusted = !target_prefs.discipline_trusted | ||
| target_prefs.save_preferences() | ||
| message_admins("[ui.user] [target_prefs.discipline_trusted ? "granted" : "revoked"] trusted discipline whitelist for [ADMIN_LOOKUPFLW(target_ckey)].") | ||
| return TRUE | ||
|
|
||
| /datum/admin_discipline_editor/proc/load_target(search_ckey) | ||
| if(loaded_offline && target_prefs) | ||
| qdel(target_prefs) | ||
| target_prefs = null | ||
| loaded_offline = FALSE | ||
|
|
||
| target_ckey = search_ckey | ||
| selected_slot = 0 | ||
|
|
||
| var/client/found_client = GLOB.directory[search_ckey] | ||
| if(found_client?.prefs) | ||
| target_prefs = found_client.prefs | ||
| loaded_offline = FALSE | ||
| selected_slot = target_prefs.default_slot | ||
| return TRUE | ||
| var/prefs_path = "data/player_saves/[search_ckey[1]]/[search_ckey]/preferences.json" | ||
| if(!fexists(prefs_path)) | ||
| return FALSE | ||
| var/datum/client_interface/mock = new | ||
| mock.ckey = search_ckey | ||
| mock.key = search_ckey | ||
| var/datum/preferences/offline_prefs = new(mock) | ||
| offline_prefs.load_character(1) | ||
| offline_prefs.default_slot = 1 | ||
| target_prefs = offline_prefs | ||
| loaded_offline = TRUE | ||
| selected_slot = 1 | ||
| return TRUE | ||
|
|
||
| ADMIN_VERB(discipline_menu, R_ADMIN, "Discipline Menu", "Edit a player's disciplines.", ADMIN_CATEGORY_SECOND_CITY) | ||
| var/datum/admin_discipline_editor/editor = new | ||
| editor.ui_interact(user.mob) | ||
| BLACKBOX_LOG_ADMIN_VERB("Discipline Menu") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.