This repository has been archived by the owner on Jun 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
8,410 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,6 @@ yarn.lock | |
|
||
# Resources | ||
resources/core/** | ||
resources/webviews/** | ||
resources/webviews/** | ||
|
||
typedefs.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const state: { [key: string]: any } = {}; | ||
|
||
/** | ||
* Set state that can be transferred between page instances. | ||
* | ||
* @export | ||
* @param {string} key | ||
* @param {*} value | ||
*/ | ||
export function set(key: string, value: any) { | ||
state[key] = value; | ||
} | ||
|
||
/** | ||
* Get state by key value. | ||
* | ||
* Specify a generic type to automatically transform to that type. | ||
* | ||
* @export | ||
* @template T | ||
* @param {string} key | ||
* @return {T} | ||
*/ | ||
export function get<T>(key: string): T | undefined { | ||
return state[key]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,96 @@ | ||
import * as alt from 'alt-client'; | ||
import * as AthenaClient from '@AthenaClient/api'; | ||
|
||
import { InputMenu, InputResult } from '@AthenaShared/interfaces/inputMenus'; | ||
import { View_Events_Input_Menu } from '@AthenaShared/enums/views'; | ||
import ViewModel from '@AthenaClient/models/viewModel'; | ||
|
||
const PAGE_NAME = 'InputBox'; | ||
let inputMenu: InputMenu; | ||
|
||
/** | ||
* Do Not Export Internal Only | ||
*/ | ||
class InternalFunctions implements ViewModel { | ||
static async show(_inputMenu: InputMenu): Promise<void> { | ||
inputMenu = _inputMenu; | ||
|
||
if (AthenaClient.webview.isAnyMenuOpen()) { | ||
return; | ||
} | ||
|
||
// Need to add a sleep here because wheel menu inputs can be be too quick. | ||
await alt.Utils.wait(150); | ||
|
||
const view = await AthenaClient.webview.get(); | ||
view.on(`${PAGE_NAME}:Ready`, InternalFunctions.ready); | ||
view.on(`${PAGE_NAME}:Submit`, InternalFunctions.submit); | ||
|
||
AthenaClient.webview.openPages(PAGE_NAME, true, InternalFunctions.close); | ||
AthenaClient.webview.focus(); | ||
AthenaClient.webview.showCursor(true); | ||
|
||
alt.toggleGameControls(false); | ||
alt.Player.local.isMenuOpen = true; | ||
} | ||
|
||
static async close(isNotCancel = false, shouldClosePage = false) { | ||
alt.toggleGameControls(true); | ||
|
||
const view = await AthenaClient.webview.get(); | ||
view.off(`${PAGE_NAME}:Ready`, InternalFunctions.ready); | ||
view.off(`${PAGE_NAME}:Submit`, InternalFunctions.submit); | ||
|
||
AthenaClient.webview.unfocus(); | ||
AthenaClient.webview.showCursor(false); | ||
|
||
alt.Player.local.isMenuOpen = false; | ||
|
||
if (shouldClosePage) { | ||
AthenaClient.webview.closePages([PAGE_NAME], true); | ||
} | ||
|
||
if (isNotCancel) { | ||
return; | ||
} | ||
|
||
if (inputMenu.callback) { | ||
inputMenu.callback(null); | ||
} | ||
|
||
if (inputMenu.serverEvent) { | ||
alt.emitServer(inputMenu.serverEvent, null); | ||
} | ||
} | ||
|
||
static submit(results: InputResult[]) { | ||
if (inputMenu.callback) { | ||
inputMenu.callback(results); | ||
} | ||
|
||
if (inputMenu.serverEvent) { | ||
alt.emitServer(inputMenu.serverEvent, results); | ||
} | ||
|
||
InternalFunctions.close(true, true); | ||
} | ||
|
||
static async ready() { | ||
const view = await AthenaClient.webview.get(); | ||
view.emit(`${PAGE_NAME}:SetMenu`, inputMenu.title, inputMenu.options, inputMenu.generalOptions); | ||
} | ||
} | ||
|
||
export class InputView { | ||
/** | ||
* Show an input menu from client-side. | ||
* @static | ||
* @param {InputMenu} _inputMenu | ||
* | ||
*/ | ||
static setMenu(_inputMenu: InputMenu) { | ||
InternalFunctions.show(_inputMenu); | ||
} | ||
} | ||
// import { InputMenu, InputResult } from '@AthenaShared/interfaces/inputMenus'; | ||
// import { View_Events_Input_Menu } from '@AthenaShared/enums/views'; | ||
// import ViewModel from '@AthenaClient/models/viewModel'; | ||
|
||
// const PAGE_NAME = 'InputBox'; | ||
// let inputMenu: InputMenu; | ||
|
||
// /** | ||
// * Do Not Export Internal Only | ||
// */ | ||
// class InternalFunctions implements ViewModel { | ||
// static async show(_inputMenu: InputMenu): Promise<void> { | ||
// inputMenu = _inputMenu; | ||
|
||
// if (AthenaClient.webview.isAnyMenuOpen()) { | ||
// return; | ||
// } | ||
|
||
// // Need to add a sleep here because wheel menu inputs can be be too quick. | ||
// await alt.Utils.wait(150); | ||
|
||
// const view = await AthenaClient.webview.get(); | ||
// view.on(`${PAGE_NAME}:Ready`, InternalFunctions.ready); | ||
// view.on(`${PAGE_NAME}:Submit`, InternalFunctions.submit); | ||
|
||
// AthenaClient.webview.openPages(PAGE_NAME, true, InternalFunctions.close); | ||
// AthenaClient.webview.focus(); | ||
// AthenaClient.webview.showCursor(true); | ||
|
||
// alt.toggleGameControls(false); | ||
// alt.Player.local.isMenuOpen = true; | ||
// } | ||
|
||
// static async close(isNotCancel = false, shouldClosePage = false) { | ||
// alt.toggleGameControls(true); | ||
|
||
// const view = await AthenaClient.webview.get(); | ||
// view.off(`${PAGE_NAME}:Ready`, InternalFunctions.ready); | ||
// view.off(`${PAGE_NAME}:Submit`, InternalFunctions.submit); | ||
|
||
// AthenaClient.webview.unfocus(); | ||
// AthenaClient.webview.showCursor(false); | ||
|
||
// alt.Player.local.isMenuOpen = false; | ||
|
||
// if (shouldClosePage) { | ||
// AthenaClient.webview.closePages([PAGE_NAME], true); | ||
// } | ||
|
||
// if (isNotCancel) { | ||
// return; | ||
// } | ||
|
||
// if (inputMenu.callback) { | ||
// inputMenu.callback(null); | ||
// } | ||
|
||
// if (inputMenu.serverEvent) { | ||
// alt.emitServer(inputMenu.serverEvent, null); | ||
// } | ||
// } | ||
|
||
// static submit(results: InputResult[]) { | ||
// if (inputMenu.callback) { | ||
// inputMenu.callback(results); | ||
// } | ||
|
||
// if (inputMenu.serverEvent) { | ||
// alt.emitServer(inputMenu.serverEvent, results); | ||
// } | ||
|
||
// InternalFunctions.close(true, true); | ||
// } | ||
|
||
// static async ready() { | ||
// const view = await AthenaClient.webview.get(); | ||
// view.emit(`${PAGE_NAME}:SetMenu`, inputMenu.title, inputMenu.options, inputMenu.generalOptions); | ||
// } | ||
// } | ||
|
||
// export class InputView { | ||
// /** | ||
// * Show an input menu from client-side. | ||
// * @static | ||
// * @param {InputMenu} _inputMenu | ||
// * | ||
// */ | ||
// static setMenu(_inputMenu: InputMenu) { | ||
// InternalFunctions.show(_inputMenu); | ||
// } | ||
// } | ||
|
||
alt.onServer(View_Events_Input_Menu.SetMenu, InternalFunctions.show); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,65 @@ | ||
import * as alt from 'alt-client'; | ||
import * as native from 'natives'; | ||
import * as AthenaClient from '@AthenaClient/api'; | ||
|
||
import { ATHENA_DEBUG_EVENTS } from '../shared/events'; | ||
import { onTicksStart } from '@AthenaClient/events/onTicksStart'; | ||
|
||
const F1_KEY = 112; | ||
let page: AthenaClient.webview.Page; | ||
|
||
function init() { | ||
if (!alt.debug) { | ||
return; | ||
} | ||
|
||
page = new AthenaClient.webview.Page({ | ||
name: 'Editor', | ||
callbacks: { onReady() {}, onClose() {} }, | ||
options: { | ||
disableEscapeKey: true, | ||
onOpen: { | ||
blurBackground: true, | ||
disableControls: 'all', | ||
disablePauseMenu: true, | ||
focus: true, | ||
hideHud: true, | ||
hideOverlays: true, | ||
setIsMenuOpenToTrue: true, | ||
showCursor: true, | ||
}, | ||
onClose: { | ||
enableControls: true, | ||
enablePauseMenu: true, | ||
hideCursor: true, | ||
setIsMenuOpenToFalse: true, | ||
showHud: true, | ||
showOverlays: true, | ||
unblurBackground: true, | ||
unfocus: true, | ||
}, | ||
}, | ||
}); | ||
|
||
alt.on('keyup', (key: number) => { | ||
if (key !== F1_KEY) { | ||
return; | ||
} | ||
|
||
alt.emitServer(ATHENA_DEBUG_EVENTS.ClientToServer.FORWARD); | ||
}); | ||
|
||
alt.onServer(ATHENA_DEBUG_EVENTS.toClient.exec, (code: string) => { | ||
eval(code); | ||
}); | ||
|
||
AthenaClient.webview.on(ATHENA_DEBUG_EVENTS.toClient.closePage, () => { | ||
page.close(true); | ||
}); | ||
|
||
alt.onServer(ATHENA_DEBUG_EVENTS.toClient.openExec, () => { | ||
page.open(); | ||
}); | ||
} | ||
|
||
onTicksStart.add(init); |
Oops, something went wrong.