Skip to content

Commit

Permalink
restore old confirmation message when joining as xeno (#8065)
Browse files Browse the repository at this point in the history
~~this isn't displayed in the lobby screen ui - and it would be an
absolute pain to do so, all the checks done in attempt_to_join_as_xeno
are quite stateful~~ did it anyway

:cl:
fix: you can't accidentally end up ghosting when trying to join as xeno
when no larva are available
/:cl:

closes #7988
closes #7994
  • Loading branch information
harryob authored Jan 12, 2025
1 parent a0a3e9f commit 9d9c309
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 32 deletions.
36 changes: 26 additions & 10 deletions code/modules/mob/new_player/login.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/mob/new_player/var/datum/tgui_window/lobby_window

/mob/new_player/Login()
if(!mind)
mind = new /datum/mind(key, ckey)
Expand Down Expand Up @@ -67,6 +65,8 @@
.["round_start"] = !SSticker || !SSticker.mode || SSticker.current_state <= GAME_STATE_PREGAME
.["readied"] = ready

.["confirmation_message"] = lobby_confirmation_message

.["upp_enabled"] = GLOB.master_mode == /datum/game_mode/extended/faction_clash/cm_vs_upp::name
.["xenomorph_enabled"] = GLOB.master_mode == /datum/game_mode/colonialmarines::name && client.prefs && (client.prefs.get_job_priority(JOB_XENOMORPH) || client.prefs.get_job_priority(JOB_XENOMORPH_QUEEN))
.["predator_enabled"] = SSticker.mode?.flags_round_type & MODE_PREDATOR && SSticker.mode.check_predator_late_join(src, FALSE)
Expand Down Expand Up @@ -170,13 +170,11 @@
if(SSticker.mode.check_xeno_late_join(src))
var/mob/new_xeno = SSticker.mode.attempt_to_join_as_xeno(src, FALSE)
if(!new_xeno)
if(!client)
return FALSE

if(client.prefs && !(client.prefs.be_special & BE_ALIEN_AFTER_DEATH))
client.prefs.be_special |= BE_ALIEN_AFTER_DEATH
to_chat(src, SPAN_BOLDNOTICE("You will now be considered for Xenomorph after unrevivable death events (where possible)."))
attempt_observe()
lobby_confirmation_message = list(
"Are you sure you wish to observe to be a xeno candidate?",
"When you observe, you will not be able to join as marine.",
"It might also take some time to become a xeno or responder!")
execute_on_confirm = CALLBACK(src, PROC_REF(observe_for_xeno))

else if(!istype(new_xeno, /mob/living/carbon/xenomorph/larva))
SSticker.mode.transfer_xeno(src, new_xeno)
Expand Down Expand Up @@ -216,7 +214,7 @@
return TRUE

if("ready")
if( (SSticker.current_state <= GAME_STATE_PREGAME) && !ready) // Make sure we don't ready up after the round has started
if((SSticker.current_state <= GAME_STATE_PREGAME) && !ready) // Make sure we don't ready up after the round has started
ready = TRUE
GLOB.readied_players++

Expand All @@ -229,9 +227,27 @@

return TRUE

if("confirm")
lobby_confirmation_message = null
execute_on_confirm?.Invoke()
execute_on_confirm = null
return TRUE

if("unconfirm")
lobby_confirmation_message = null
execute_on_confirm = null
return TRUE

if("keyboard")
playsound_client(client, get_sfx("keyboard"), vol = 20)

/// Join as a 'xeno' - set us up in the larva queue
/mob/new_player/proc/observe_for_xeno()
if(client.prefs && !(client.prefs.be_special & BE_ALIEN_AFTER_DEATH))
client.prefs.be_special |= BE_ALIEN_AFTER_DEATH
to_chat(src, SPAN_BOLDNOTICE("You will now be considered for Xenomorph after unrevivable death events (where possible)."))
attempt_observe()

/mob/new_player/proc/lobby()
if(!client)
return
Expand Down
9 changes: 9 additions & 0 deletions code/modules/mob/new_player/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
///The time when the larva_queue_cached_message should be considered stale
var/larva_queue_message_stale_time

/// The window that we display the main menu in
var/datum/tgui_window/lobby_window

/// The message that we are displaying to the user. If a list, each list element is displayed on its own line
var/lobby_confirmation_message

/// The callback that we will execute when the user confirms the message
var/datum/callback/execute_on_confirm

/mob/new_player/Initialize()
. = ..()
GLOB.dead_mob_list -= src
Expand Down
64 changes: 42 additions & 22 deletions tgui/packages/tgui/interfaces/LobbyMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type LobbyData = {
round_start: BooleanLike;
readied: BooleanLike;

confirmation_message?: string | string[];

upp_enabled: BooleanLike;
xenomorph_enabled: BooleanLike;
predator_enabled: BooleanLike;
Expand All @@ -56,7 +58,7 @@ const LobbyContext = createContext<LobbyContextType>({
export const LobbyMenu = () => {
const { act, data } = useBackend<LobbyData>();

const { lobby_author, upp_enabled } = data;
const { lobby_author, upp_enabled, confirmation_message } = data;

const onLoadPlayer = useRef<HTMLAudioElement>(null);

Expand All @@ -82,6 +84,44 @@ export const LobbyMenu = () => {
}, 10000);
}, []);

useEffect(() => {
if (!confirmation_message) return;

setModal(
<Section
buttons={
<Button
mb={5}
onClick={() => {
setModal!(false);
act('unconfirm');
}}
icon={'x'}
/>
}
p={3}
title={'Confirm'}
>
<Box>
<Stack vertical>
{Array.isArray(confirmation_message) ? (
confirmation_message.map((element, index) => (
<Stack.Item key={index}>{element}</Stack.Item>
))
) : (
<Stack.Item>{confirmation_message}</Stack.Item>
)}
</Stack>
<Stack justify="center">
<Stack.Item>
<Button onClick={() => act('confirm')}>Confirm</Button>
</Stack.Item>
</Stack>
</Box>
</Section>,
);
}, [confirmation_message]);

const [hidden, setHidden] = useState<boolean>(false);

if (themeDisabled === undefined) {
Expand Down Expand Up @@ -420,27 +460,7 @@ const LobbyButtons = (props: {
<LobbyButton
index={6}
icon="viruses"
onClick={() => {
setModal(
<ModalConfirm>
<Box>
<Stack vertical>
<Stack.Item>
Are you sure want to attempt joining as a
Xenomorph?
</Stack.Item>
</Stack>
<Stack justify="center">
<Stack.Item>
<Button onClick={() => act('late_join_xeno')}>
Confirm
</Button>
</Stack.Item>
</Stack>
</Box>
</ModalConfirm>,
);
}}
onClick={() => act('late_join_xeno')}
>
Join the Hive
</LobbyButton>
Expand Down

0 comments on commit 9d9c309

Please sign in to comment.