Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/connector/websocketOutgoing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ export class WebsocketOutgoing {
timeoutEndTimeout,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
timeoutRemainingLoop,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
toastEndTimeout,

...formattedData
} = data;
} = data;

const deepMod: any = structuredClone(formattedData);
if (
Expand Down
28 changes: 28 additions & 0 deletions src/model/Match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export class Match {
private timeoutRemainingLoop: any = undefined;
private timeoutGracePeriodPassed: boolean = false;

private toastEndTimeout: any = undefined;

private hasEnteredOvertime: boolean = false;

private tools: ToolsData;
Expand Down Expand Up @@ -346,6 +348,10 @@ export class Match {
case DataTypes.SWITCH_KDA_CREDITS:
this.showAliveKDA = !this.showAliveKDA;
break;

case DataTypes.TOAST:
this.handleToast();
break;
}

this.eventNumber++;
Expand Down Expand Up @@ -481,6 +487,28 @@ export class Match {
this.spikeDetonationTime = timestamp + 45 * 1000; // Add 45 seconds to the current time
}

private handleToast() {
if (this.tools.toastInfo.active) {
// Toast is active — deactivate it immediately
this.tools.toastInfo.active = false;
clearTimeout(this.toastEndTimeout);
this.toastEndTimeout = undefined;
} else {
// Activate the toast
this.tools.toastInfo.active = true;

if (this.tools.toastInfo.duration !== null) {
// Auto-deactivate after the configured duration (ms)
this.toastEndTimeout = setTimeout(() => {
this.tools.toastInfo.active = false;
this.toastEndTimeout = undefined;
this.eventNumber++;
}, this.tools.toastInfo.duration);
}
// If duration is null, the toast stays until the hotkey is pressed again
}
}

private handleTeamTimeout(team: "left" | "right") {
const isLeftTeam = team === "left";
const currentState = isLeftTeam ? this.timeoutState.leftTeam : this.timeoutState.rightTeam;
Expand Down
15 changes: 15 additions & 0 deletions src/model/ToolsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ export class ToolsData {
type: "disabled",
sponsors: [],
};
public toastInfo: IToastInfo = {
duration: null,
message: "",
eventLogoEnabled: true,
selectedTeam: undefined,
active: false,
};

public constructor(init?: Partial<ToolsData>) {
Object.assign(this, init);
Expand Down Expand Up @@ -120,6 +127,14 @@ export type IOverridesPlayercamsData = {
enabledPlayers: string[];
};

export type IToastInfo = {
duration: number | null;
message: string;
eventLogoEnabled: boolean;
selectedTeam ?: "left" | "right";
active: boolean;
};

type BaseMapPoolInfo = {
type: "past" | "present" | "future" | "disabled";
};
Expand Down
1 change: 1 addition & 0 deletions src/model/eventData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export enum DataTypes {
LEFT_TIMEOUT = "left_timeout",
RIGHT_TIMEOUT = "right_timeout",
SWITCH_KDA_CREDITS = "switch_kda_credits",
TOAST = "toast",
// Preview data types
PREVIEW = "preview",
}
Expand Down
Loading