Files
ec22fccc6a TGUI Faction Select (#21737)
## Description
Hello! First PR here so I figured I'd do a big one ~~and stress out the
maintainers as quickly as possible~~. :)

While going through the process of creating a character the 'faction
select' UI stuck out to me as *functional*, but difficult to parse
visually and pretty dated looking by modern SS13 standards. (Not too
bad, but you know what I mean)
The new version is realistically *bit* too flashy for what it is (a
single-use interface hidden away in the character creation menu), but it
was very good practise for me to get back into DM/TGUI programming so it
works out either way.

I'm very happy to implement any feedback or suggested changes that could
help improve it.

## Actual Description
This PR replaces the old HTML 'faction select' interface with a new TGUI
one, and also cleans up and fixes some adjacent code I bumped into while
working on it.

A couple of notes about the current version:
* The 'Citizenship Check' line is currently non-functional and will
always show a checkmark. I know a lot of the corporations have specific
backgrounds/origins they won't hire people from, but I wasn't sure where
exactly that's enforced in code, if at all.
(I noticed `/datum/faction` has a `blacklisted_citizenship_types`
variable, but it's currently unused.)
* De-adminning or changing species doesn't immediately update the UI to
reflect the changes, you have to click on something new to trigger an
update manually. This doesn't have any actual consequences since I made
sure to sanitise everything, but it is a visual thing.

## Screenshots

<details><summary><b>Collapsed so it doesn't take up so much
room:</b></summary>

### Before
<img width="752" height="482" alt="xziPCYXbkn"
src="https://github.com/user-attachments/assets/334e0609-c2e3-4a33-92ad-15120b78ab35"
/>

### After
<img width="900" height="645" alt="NT"
src="https://github.com/user-attachments/assets/476702c7-c83c-4fee-a2cd-34d912468903"
/>

### Unathi attempting to join Zeng-Hu (Button disabled)
<img width="900" height="645" alt="Unathi fail"
src="https://github.com/user-attachments/assets/c5a256c1-5531-4cbe-8198-27411c1aab9a"
/>

### Faction Pages
<details><summary><b>Stellar Corporate Conglomerate</b></summary>
<img width="900" height="645" alt="SCC"
src="https://github.com/user-attachments/assets/6e8bdb64-a220-41d4-a503-1268f9f93a30"
/>

</details>
<details><summary><b>Nanotrasen</b></summary>
<img width="900" height="645" alt="NT"
src="https://github.com/user-attachments/assets/1ff107b5-7b3e-40e2-8f86-390ce29e165b"
/>

</details>
<details><summary><b>Hephaestus Industries</b></summary>
<img width="900" height="645" alt="HI"
src="https://github.com/user-attachments/assets/6fc23159-990d-4de2-9745-827e11ca0442"
/>

</details>
<details><summary><b>Idris Incorporated</b></summary>
<img width="900" height="645" alt="II"
src="https://github.com/user-attachments/assets/366a9824-81f1-4dd1-b385-4fa3968e39e0"
/>

</details>
<details><summary><b>Orion Express</b></summary>
<img width="900" height="645" alt="OE"
src="https://github.com/user-attachments/assets/5588f0fe-d6c3-44b4-8297-cca4ed991bd8"
/>

</details>
<details><summary><b>Private Military Contracting Group</b></summary>
<img width="900" height="645" alt="PMCG"
src="https://github.com/user-attachments/assets/a3dc6540-bfde-4fb2-939d-11e066b1e316"
/>

</details>
<details><summary><b>Zavodskoi Interstellar</b></summary>
<img width="900" height="645" alt="ZI"
src="https://github.com/user-attachments/assets/a8c2c33d-7138-4164-a9f1-6a2dc3eb3e61"
/>

</details>
<details><summary><b>Zeng-Hu Pharmaceuticals</b></summary>
<img width="900" height="645" alt="ZHP"
src="https://github.com/user-attachments/assets/4535ba80-efcb-4e50-9396-299bc16db2b5"
/>

</details>
<details><summary><b>Independent</b></summary>
<img width="900" height="645" alt="Independent"
src="https://github.com/user-attachments/assets/dcf7b46c-edce-4104-a4f5-000479a9f963"
/>

</details>
<hr>
</details>

## Changelog
- rscadd: "Revamped the 'Faction Select' UI in the occupation menu of
character setup."
- bugfix: "Fixed changing species in character setup not resetting your
faction if it became invalid."
  - Not player-facing:
- Fixed the TGUI dev server not working by bumping up the 'source-map'
version. You still have to manually refresh the interface with Ctrl+R or
Ctrl+F5 but it actually links now.
- Added a `wiki_page` variable to each faction to allow for it to be
manually set rather than being exclusively based on the name. (Mostly
just futureproofing)
- Added some line breaks to the faction descriptions to make them more
easily readable.

---------

Signed-off-by: SabreML <57483089+SabreML@users.noreply.github.com>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>
2026-01-26 23:39:22 +00:00

114 lines
3.3 KiB
Plaintext

/datum/faction
var/name
var/description
var/title_suffix
var/list/departments
var/wiki_page
/// Number indicating the list index of this faction in the 'faction select' interface.
var/ui_priority
var/list/allowed_role_types
var/list/allowed_species_types
var/list/job_species_blacklist //will override the normal job species list for a member of this faction
var/list/blacklisted_citizenship_types
var/is_default = FALSE
var/list/titles_to_loadout = list()
/datum/faction/New()
var/list/l = list()
for (var/path in allowed_species_types)
if (allowed_species_types[path] != TRUE)
l |= typecacheof(path, FALSE)
else
l[path] = TRUE
allowed_species_types = l
var/list/b = list()
for(var/path in blacklisted_citizenship_types)
if(blacklisted_citizenship_types[path] != TRUE)
b |= typecacheof(path, FALSE)
else
b[path] = TRUE
blacklisted_citizenship_types = b
/datum/faction/proc/get_occupations()
. = list()
for (var/path in allowed_role_types)
if(islist(path))
for(var/role_path in path)
var/datum/job/role = SSjobs.type_occupations[role_path]
if(!istype(role))
continue
if(LAZYACCESS(job_species_blacklist, role.title))
role.blacklisted_species = job_species_blacklist[role.title]
else
var/datum/job/J = new role.type
role.blacklisted_species = J.blacklisted_species
. += role
else
var/datum/job/role = SSjobs.type_occupations[path]
if(!role)
continue
if(LAZYACCESS(job_species_blacklist, role.title))
role.blacklisted_species = job_species_blacklist[role.title]
else
var/datum/job/J = new role.type
role.blacklisted_species = J.blacklisted_species
. += role
/datum/faction/proc/get_selection_error(datum/preferences/prefs, mob/user)
if(length(allowed_species_types))
var/datum/species/S = prefs.get_species_datum()
if(!S)
return "No valid species"
if(!is_type_in_typecache(S, allowed_species_types))
return "Invalid species"
if(length(blacklisted_citizenship_types))
var/datum/citizenship/C = SSrecords.citizenships[prefs.citizenship]
if(!C)
return "No valid nation"
if(is_type_in_typecache(C, blacklisted_citizenship_types))
return "Invalid nation"
if(!is_visible(user))
return "This faction is not available to you"
return null
/datum/faction/proc/can_select(datum/preferences/prefs, mob/user)
return !get_selection_error(prefs, user)
/datum/faction/proc/get_logo_name()
return "faction_[title_suffix].png"
/datum/faction/proc/get_corporate_objectives(var/mission_level)
var/objective
switch(mission_level)
if(REPRESENTATIVE_MISSION_HIGH)
objective = pick("Assist your contractor in smuggling [rand(1,4)] items of value",
"Collect evidence of [SSatlas.current_map.company_short] being unfair or oppressive against your contractors to be used as leverage in future talks")
if(REPRESENTATIVE_MISSION_MEDIUM)
objective = pick("Convince [rand(1,3)] non-[name] employees to join [name] instead",
"Have [rand(1,3)] of your contractors write down their grievances with the company, and present the report to [SSatlas.current_map.station_name] command.")
else
objective = pick("Collect [rand(3,7)] pictures of secure areas",
"Make sure that [rand(2,4)] complaints related to contractors are solved on the [SSatlas.current_map.station_name]")
return objective
/datum/faction/proc/is_visible(var/mob/user)
return TRUE