Continue script abstraction
This commit is contained in:
73
ReallifeGamemode.Client/core/rage-mp/ui.ts
Normal file
73
ReallifeGamemode.Client/core/rage-mp/ui.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import { IUi, IBrowser } from "../../game";
|
||||
import { Menu } from "../../libs/NativeUI/index";
|
||||
|
||||
export default class RageUi implements IUi {
|
||||
private _inMenu: boolean = false;
|
||||
private _activeMenu: Menu = null;
|
||||
|
||||
inChat: boolean = false;
|
||||
|
||||
get activeMenu(): Menu {
|
||||
return this._activeMenu;
|
||||
}
|
||||
|
||||
set activeMenu(value: Menu) {
|
||||
if (this.activeMenu && this.activeMenu.Visible) {
|
||||
this.activeMenu.Close(true);
|
||||
}
|
||||
|
||||
this._activeMenu = value;
|
||||
|
||||
if (this.activeMenu) {
|
||||
this.activeMenu.Open();
|
||||
}
|
||||
|
||||
this.inMenu = this.activeMenu != null;
|
||||
}
|
||||
|
||||
get inMenu() {
|
||||
return this._inMenu;
|
||||
}
|
||||
|
||||
set inMenu(value: boolean) {
|
||||
this._inMenu = value;
|
||||
this.toggleChat(!value);
|
||||
}
|
||||
|
||||
toggleChat(toggle: boolean) {
|
||||
mp.gui.chat.show(toggle);
|
||||
}
|
||||
|
||||
openBrower(path: string): IBrowser {
|
||||
return new RageBrowser(path);
|
||||
}
|
||||
|
||||
sendChatMessage(message: string) {
|
||||
mp.gui.chat.push(message);
|
||||
}
|
||||
|
||||
setCursor(freeze: boolean, show: boolean): void {
|
||||
mp.gui.cursor.show(freeze, show);
|
||||
}
|
||||
}
|
||||
|
||||
export class RageBrowser implements IBrowser {
|
||||
private rageBrowser: BrowserMp;
|
||||
|
||||
constructor(path: string) {
|
||||
this.rageBrowser = mp.browsers.new(path);
|
||||
}
|
||||
|
||||
close(): void {
|
||||
if (this.rageBrowser) {
|
||||
this.rageBrowser.destroy();
|
||||
this.rageBrowser = null;
|
||||
}
|
||||
}
|
||||
|
||||
executeJs(script: string) {
|
||||
if (this.rageBrowser) {
|
||||
this.rageBrowser.execute(script);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user