import { IUi, IBrowser } from "../../game"; import { Menu } from "../../libs/NativeUI/index"; export default class RageUi implements IUi { setHelpText(text: string): void { mp.game.ui.setTextComponentFormat('STRING'); mp.game.ui.addTextComponentSubstringPlayerName(text); mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1); } clearHelpText(): void { mp.game.ui.clearHelp(true); } 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); } } }