Skip to content

Commit

Permalink
Move handover data type to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
D4isDAVID committed Jul 18, 2024
1 parent 35e486b commit 71962b4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 42 deletions.
41 changes: 1 addition & 40 deletions html/js/util/handover.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,5 @@
/**
* @typedef {Object} NuiHandoverPaths
* @property {string[]} images
* @property {string[]} music
* @property {string[]} videos
* @property {string} [logo]
*/

/**
* @typedef {Object} NuiHandoverConfig
* @property {string} style
* @property {string} background
* @property {number} backgroundBrightness
* @property {string} textColor
* @property {string} primaryColor
* @property {string} secondaryColor
* @property {string} shadowColor
* @property {string} fontFamily
* @property {boolean} logo
* @property {string} serverMessage
* @property {boolean} primaryBar
* @property {boolean} secondaryBar
* @property {boolean} loadingAction
* @property {string} finishingMessage
* @property {boolean} logLine
* @property {boolean} audioControls
* @property {boolean} errorLog
* @property {number} initialAudioVolume
* @property {boolean} music
* @property {boolean} musicShuffle
* @property {number} imageRate
* @property {boolean} imageShuffle
* @property {boolean} videoShuffle
*/

/**
* @typedef {Object} NuiHandoverData
* @property {string} playerName
* @property {string} serverName
* @property {NuiHandoverPaths} paths
* @property {NuiHandoverConfig} config
* @typedef {import('../../../types/handover.d.ts').NuiHandoverData} NuiHandoverData
*/

/**
Expand Down
7 changes: 5 additions & 2 deletions server/handover.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ const paths = {
* @param {Deferrals} deferrals
*/
function onPlayerConnecting(name, _setKickReason, deferrals) {
deferrals.handover({
/** @type {import('../types/handover.d.ts').NuiHandoverData} */
const data = {
playerName: name,
serverName: GetConvar('sv_projectName', GetConvar('sv_hostname', '')),

Expand Down Expand Up @@ -122,7 +123,9 @@ function onPlayerConnecting(name, _setKickReason, deferrals) {
imageShuffle: GetConvarInt('loadscreen:imageShuffle', 0) == 1,
videoShuffle: GetConvarInt('loadscreen:videoShuffle', 0) == 1,
},
});
};

deferrals.handover(/** @type {any} */ (data));
}

on('playerConnecting', onPlayerConnecting);
37 changes: 37 additions & 0 deletions types/handover.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export interface NuiHandoverData {
playerName: string;
serverName: string;

paths: {
images: string[];
music: string[];
videos: string[];
logo?: string | undefined;
};

config: {
style: string;
background: string;
backgroundBrightness: number;
textColor: string;
primaryColor: string;
secondaryColor: string;
shadowColor: string;
fontFamily: string;
logo: boolean;
serverMessage: string;
primaryBar: boolean;
secondaryBar: boolean;
loadingAction: boolean;
finishingMessage: string;
logLine: boolean;
audioControls: boolean;
errorLog: boolean;
initialAudioVolume: number;
music: boolean;
musicShuffle: boolean;
imageRate: number;
imageShuffle: boolean;
videoShuffle: boolean;
};
}

0 comments on commit 71962b4

Please sign in to comment.