Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
Overrides for client/menus/x
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuyk committed Apr 5, 2023
1 parent 8f61820 commit 8e03099
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Overrides -> src/core/client/cameras/gameplay
Overrides -> src/core/client/cameras/pedEdit
Overrides -> src/core/client/cameras/switch
Overrides -> src/core/client/rmlui/commands/index
Overrides -> src/core/client/menus/npc
Overrides -> src/core/client/menus/object
Overrides -> src/core/client/menus/player
Overrides -> src/core/client/menus/vehicle
--------------------------------------
--- Everything Below is Before April 2
Expand Down
39 changes: 39 additions & 0 deletions src/core/client/menus/npc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { IPed } from '@AthenaShared/interfaces/iPed';
export type NpcMenuInjection = (scriptID: number, ped: IPed, options: Array<IWheelOptionExt>) => Array<IWheelOptionExt>;

const Injections: Array<NpcMenuInjection> = [];
let disabled = false;

/**
* Allows the current Menu Options to be modified.
Expand All @@ -19,6 +20,14 @@ const Injections: Array<NpcMenuInjection> = [];
*
*/
export function addInjection(callback: NpcMenuInjection) {
if (Overrides.addInjection) {
return Overrides.addInjection(callback);
}

if (disabled) {
return;
}

Injections.push(callback);
}

Expand All @@ -31,6 +40,14 @@ export function addInjection(callback: NpcMenuInjection) {
*
*/
export function open(scriptID: number): void {
if (Overrides.open) {
return Overrides.open(scriptID);
}

if (disabled) {
return;
}

if (AthenaClient.webview.isAnyMenuOpen()) {
return;
}
Expand Down Expand Up @@ -67,3 +84,25 @@ export function open(scriptID: number): void {

AthenaClient.systems.wheelMenu.open('NPC', options);
}

/**
* Disable the NPC Wheel Menu
*
* @export
*/
export function disable() {
disabled = true;
}

interface NpcMenuFuncs {
addInjection: typeof addInjection;
open: typeof open;
}

const Overrides: Partial<NpcMenuFuncs> = {};

export function override(functionName: 'addInjection', callback: typeof addInjection);
export function override(functionName: 'open', callback: typeof open);
export function override(functionName: keyof NpcMenuFuncs, callback: any): void {
Overrides[functionName] = callback;
}
39 changes: 39 additions & 0 deletions src/core/client/menus/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type ObjectMenuInjection = (
) => Array<IWheelOptionExt>;

const Injections: Array<ObjectMenuInjection> = [];
let disabled = false;

/**
* Allows the current Menu Options to be modified.
Expand All @@ -22,6 +23,14 @@ const Injections: Array<ObjectMenuInjection> = [];
*
*/
export function addInjection(callback: ObjectMenuInjection): void {
if (Overrides.addInjection) {
return Overrides.addInjection(callback);
}

if (disabled) {
return;
}

Injections.push(callback);
}

Expand All @@ -34,6 +43,14 @@ export function addInjection(callback: ObjectMenuInjection): void {
*
*/
export function open(object: CreatedObject): void {
if (Overrides.open) {
return Overrides.open(object);
}

if (disabled) {
return;
}

if (AthenaClient.webview.isAnyMenuOpen()) {
return;
}
Expand Down Expand Up @@ -72,3 +89,25 @@ export function open(object: CreatedObject): void {

AthenaClient.systems.wheelMenu.open('Object', options);
}

/**
* Disable the Object Wheel Menu
*
* @export
*/
export function disable() {
disabled = true;
}

interface ObjectMenuFuncs {
addInjection: typeof addInjection;
open: typeof open;
}

const Overrides: Partial<ObjectMenuFuncs> = {};

export function override(functionName: 'addInjection', callback: typeof addInjection);
export function override(functionName: 'open', callback: typeof open);
export function override(functionName: keyof ObjectMenuFuncs, callback: any): void {
Overrides[functionName] = callback;
}
39 changes: 39 additions & 0 deletions src/core/client/menus/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IWheelOptionExt } from '@AthenaShared/interfaces/wheelMenu';
export type PlayerMenuInjection = (target: alt.Player, options: Array<IWheelOptionExt>) => Array<IWheelOptionExt>;

const Injections: Array<PlayerMenuInjection> = [];
let disabled = false;

/**
* Allows the current Menu Options to be modified.
Expand All @@ -15,6 +16,14 @@ const Injections: Array<PlayerMenuInjection> = [];
*
*/
export function addInjection(callback: PlayerMenuInjection) {
if (Overrides.addInjection) {
return Overrides.addInjection(callback);
}

if (disabled) {
return;
}

Injections.push(callback);
}

Expand All @@ -26,6 +35,14 @@ export function addInjection(callback: PlayerMenuInjection) {
*
*/
export function open(target: alt.Player) {
if (Overrides.open) {
return Overrides.open(target);
}

if (disabled) {
return;
}

if (AthenaClient.webview.isAnyMenuOpen()) {
return;
}
Expand Down Expand Up @@ -58,3 +75,25 @@ export function open(target: alt.Player) {

AthenaClient.systems.wheelMenu.open('Player', options);
}

/**
* Disable the Player Wheel Menu
*
* @export
*/
export function disable() {
disabled = true;
}

interface PlayerWheelMenuFuncs {
addInjection: typeof addInjection;
open: typeof open;
}

const Overrides: Partial<PlayerWheelMenuFuncs> = {};

export function override(functionName: 'addInjection', callback: typeof addInjection);
export function override(functionName: 'open', callback: typeof open);
export function override(functionName: keyof PlayerWheelMenuFuncs, callback: any): void {
Overrides[functionName] = callback;
}
45 changes: 45 additions & 0 deletions src/core/client/menus/vehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { IWheelOptionExt } from '@AthenaShared/interfaces/wheelMenu';
export type VehicleMenuInjection = (target: alt.Vehicle, options: Array<IWheelOptionExt>) => Array<IWheelOptionExt>;

const Injections: Array<VehicleMenuInjection> = [];
let disabled = false;

/**
* Create a vehicle wheel menu injection.
Expand All @@ -19,6 +20,10 @@ const Injections: Array<VehicleMenuInjection> = [];
*
*/
export function addInjection(callback: VehicleMenuInjection) {
if (Overrides.addInjection) {
return Overrides.addInjection(callback);
}

Injections.push(callback);
}

Expand All @@ -31,6 +36,14 @@ export function addInjection(callback: VehicleMenuInjection) {
*
*/
export function openInVehicleMenu(vehicle: alt.Vehicle) {
if (Overrides.openInVehicleMenu) {
return Overrides.openInVehicleMenu(vehicle);
}

if (disabled) {
return;
}

if (AthenaClient.webview.isAnyMenuOpen()) {
return;
}
Expand Down Expand Up @@ -72,6 +85,14 @@ export function openInVehicleMenu(vehicle: alt.Vehicle) {
}

export function open(vehicle: alt.Vehicle) {
if (Overrides.open) {
return Overrides.open(vehicle);
}

if (disabled) {
return;
}

if (AthenaClient.webview.isAnyMenuOpen()) {
return;
}
Expand Down Expand Up @@ -125,3 +146,27 @@ export function open(vehicle: alt.Vehicle) {

AthenaClient.systems.wheelMenu.open('Vehicle Options', options);
}

/**
* Disable the Vehicle Wheel Menu
*
* @export
*/
export function disable() {
disabled = true;
}

interface VehicleWheelMenuFuncs {
addInjection: typeof addInjection;
open: typeof open;
openInVehicleMenu: typeof openInVehicleMenu;
}

const Overrides: Partial<VehicleWheelMenuFuncs> = {};

export function override(functionName: 'addInjection', callback: typeof addInjection);
export function override(functionName: 'open', callback: typeof open);
export function override(functionName: 'openInVehicleMenu', callback: typeof openInVehicleMenu);
export function override(functionName: keyof VehicleWheelMenuFuncs, callback: any): void {
Overrides[functionName] = callback;
}

0 comments on commit 8e03099

Please sign in to comment.