"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const IModLoaderAPI_1 = require("modloader64_api/IModLoaderAPI");
const PluginLifecycle_1 = require("modloader64_api/PluginLifecycle");
const EventHandler_1 = require("modloader64_api/EventHandler");
const vec_1 = require("modloader64_api/Sylvain/vec");
const path_1 = __importDefault(require("path"));
const fs_1 = __importDefault(require("fs"));
const Announcements_1 = require("modloader64_api/Announcements");
const NetworkHandler_1 = require("modloader64_api/NetworkHandler");
class TexturePack {
    name;
    folder;
    enabled;
    constructor(name, folder) {
        this.name = name;
        this.folder = folder;
        this.enabled = [false];
    }
}
class TexturePackManager {
    ModLoader;
    packs = [];
    isWindowOpen = false;
    config;
    constructor(ModLoader) {
        this.ModLoader = ModLoader;
        let p = path_1.default.resolve("./texture_packs");
        if (!fs_1.default.existsSync(p)) {
            fs_1.default.mkdirSync(p);
        }
        EventHandler_1.bus.on(IModLoaderAPI_1.ModLoaderEvents.LOAD_HD_TEXTURES, this.onRegister.bind(this));
        fs_1.default.readdirSync(p).forEach((f) => {
            let file = path_1.default.resolve(p, f);
            if (fs_1.default.lstatSync(file).isDirectory()) {
                EventHandler_1.bus.emit(IModLoaderAPI_1.ModLoaderEvents.LOAD_HD_TEXTURES, { name: path_1.default.parse(file).name, folder: file });
            }
        });
        this.config = this.ModLoader.config.registerConfigCategory("N64TexturePacks");
        this.ModLoader.config.setData('N64TexturePacks', 'texturePackStatus', {});
        for (let i = 0; i < this.packs.length; i++) {
            if (this.config.texturePackStatus.hasOwnProperty(this.packs[i].name)) {
                this.packs[i].enabled[0] = Boolean(this.config.texturePackStatus[this.packs[i].name]);
            }
            this.config.texturePackStatus[this.packs[i].name] = this.packs[i].enabled[0];
        }
        this.ModLoader.config.save();
    }
    onRegister(evt) {
        console.log(evt);
        this.packs.push(new TexturePack(evt.name, evt.folder));
    }
    clearAll() {
        for (let i = 0; i < this.packs.length; i++) {
            this.ModLoader.hires_texture_management.RemoveHiresTexturePath(this.packs[i].folder);
        }
    }
    enableSelected() {
        this.config.texturePackStatus = {};
        for (let i = 0; i < this.packs.length; i++) {
            if (this.packs[i].enabled[0]) {
                this.ModLoader.hires_texture_management.AddHiresTexturePath(this.packs[i].folder);
            }
        }
        for (let i = 0; i < this.packs.length; i++) {
            this.config.texturePackStatus[this.packs[i].name] = this.packs[i].enabled[0];
        }
        this.ModLoader.config.save();
    }
    moveItem(index, dir) {
        if (dir === 2 /* Dir.Up */ && index === 0)
            return;
        if (dir === 3 /* Dir.Down */ && index === (this.packs.length - 1))
            return;
        let itr = dir === 2 /* Dir.Up */ ? -1 : 1;
        let next = index + itr;
        let item = this.packs[next];
        let cur = this.packs[index];
        if (item === undefined || cur === undefined)
            return;
        this.packs[next] = cur;
        this.packs[index] = item;
        this.clearAll();
        this.enableSelected();
    }
    post() {
        this.ModLoader.utils.setTimeoutFrames(() => {
            this.clearAll();
            this.enableSelected();
        }, 20);
    }
    update() {
        if (this.ModLoader.ImGui.beginMainMenuBar()) {
            if (this.ModLoader.ImGui.beginMenu("Utility")) {
                if (this.ModLoader.ImGui.beginMenu("Texture Packs")) {
                    if (this.ModLoader.ImGui.menuItem("Open Texture Pack Manager", undefined, this.isWindowOpen)) {
                        this.isWindowOpen = !this.isWindowOpen;
                    }
                    this.ModLoader.ImGui.endMenu();
                }
                this.ModLoader.ImGui.endMenu();
            }
        }
        this.ModLoader.ImGui.endMainMenuBar();
        if (this.isWindowOpen) {
            if (this.ModLoader.ImGui.begin("Texture Pack Manager")) {
                for (let i = 0; i < this.packs.length; i++) {
                    if (this.ModLoader.ImGui.arrowButton(`up###${this.packs[i].name}_dirup`, 2 /* Dir.Up */)) {
                        this.moveItem(i, 2 /* Dir.Up */);
                    }
                    this.ModLoader.ImGui.sameLine();
                    if (this.ModLoader.ImGui.arrowButton(`down###${this.packs[i].name}_dirdown`, 3 /* Dir.Down */)) {
                        this.moveItem(i, 3 /* Dir.Down */);
                    }
                    this.ModLoader.ImGui.sameLine();
                    if (this.ModLoader.ImGui.checkbox(this.packs[i].name, this.packs[i].enabled)) {
                        this.clearAll();
                        this.enableSelected();
                    }
                }
            }
            this.ModLoader.ImGui.end();
        }
    }
}
class TopNotification {
    text;
    pos;
    color;
    offscreen;
    constructor(text) {
        this.text = text;
        this.offscreen = (text.length * 50) / -1;
        this.pos = (0, vec_1.xy)(500, 0);
        this.color = (0, vec_1.rgba)(255, 255, 255, 255);
    }
}
class MenubarWidget {
    cheatMenuEnabled = true;
    memoryViewerEnabled = true;
    ModLoader;
    openScriptEditor = false;
    script = [fs_1.default.readFileSync(path_1.default.resolve(__dirname, "resources", "basescript.js2")).toString()];
    scriptTick;
    scriptVi;
    openPlayerList = false;
    constructor(ModLoader) {
        this.ModLoader = ModLoader;
    }
    update() {
        if (this.ModLoader.ImGui.beginMainMenuBar()) {
            if (this.ModLoader.ImGui.beginMenu("Utility")) {
                if (this.ModLoader.ImGui.menuItem("Input config")) {
                    EventHandler_1.bus.emit('openInputConfig', {});
                }
                if (this.cheatMenuEnabled) {
                    if (this.ModLoader.ImGui.menuItem("Cheats")) {
                        EventHandler_1.bus.emit('openCheatConfig', {});
                    }
                }
                if (this.memoryViewerEnabled) {
                    if (this.ModLoader.ImGui.menuItem("Memory viewer")) {
                        EventHandler_1.bus.emit('openMemViewer', {});
                    }
                }
                /* if (this.ModLoader.ImGui.menuItem("Script Editor")) {
                    this.openScriptEditor = true;
                } */
                this.ModLoader.ImGui.endMenu();
            }
            if (this.ModLoader.ImGui.beginMenu("View")) {
                if (this.ModLoader.ImGui.menuItem("Toggle FullScreen")) {
                    EventHandler_1.bus.emit('toggleFullScreen', {});
                }
                this.ModLoader.ImGui.endMenu();
            }
        }
        this.ModLoader.ImGui.endMainMenuBar();
        if (this.openScriptEditor) {
            this.ModLoader.ImGui.begin("Script Editor", [this.openScriptEditor]);
            this.ModLoader.ImGui.inputTextMultiline("code", this.script, (0, vec_1.xy)(500, 500));
            if (this.ModLoader.ImGui.button("Run", (0, vec_1.xy)(100, 60))) {
                try {
                    if (this.scriptTick === undefined) {
                        var requireFromString = require('require-from-string');
                        let m = requireFromString(this.script[0]);
                        let i = new m();
                        i["ModLoader"] = this.ModLoader;
                        this.scriptTick = i["onTick"].bind(i);
                        this.scriptVi = i["onVi"].bind(i);
                        i["start"].bind(i)();
                    }
                }
                catch (err) {
                    console.log(err);
                }
            }
            if (this.ModLoader.ImGui.button("Stop", (0, vec_1.xy)(100, 60))) {
                this.scriptTick = undefined;
                this.scriptVi = undefined;
            }
            this.ModLoader.ImGui.end();
            if (this.scriptVi !== undefined) {
                try {
                    this.scriptVi();
                }
                catch (err) {
                    this.ModLoader.logger.error("Script error");
                    this.ModLoader.logger.error(err.stack);
                    this.scriptVi = undefined;
                    this.scriptTick = undefined;
                }
            }
        }
        if (this.openPlayerList) {
            this.ModLoader.ImGui.begin("Player List", [true]);
            this.ModLoader.ImGui.text(this.ModLoader.me.nickname);
            this.ModLoader.ImGui.end();
        }
    }
    onTick() {
        if (this.scriptTick !== undefined) {
            try {
                this.scriptTick();
            }
            catch (err) {
                this.ModLoader.logger.error("Script error");
                this.ModLoader.logger.error(err.stack);
                this.scriptVi = undefined;
                this.scriptTick = undefined;
            }
        }
    }
}
class TopBarWidget {
    topNotifications = [];
    currentTopNotification;
    topBarHeight = 0;
    topBarMaxHeight = 36;
    retracttopBar = false;
    ModLoader;
    constructor(ModLoader) {
        this.ModLoader = ModLoader;
    }
    add(notif) {
        this.topNotifications.push(new TopNotification(notif.text));
    }
    update() {
        if (this.topNotifications.length > 0 && this.currentTopNotification === undefined) {
            this.currentTopNotification = this.topNotifications.shift();
            return;
        }
        if (this.topBarHeight > 0) {
            this.ModLoader.ImGui.getWindowDrawList().addRectFilled((0, vec_1.xy)(0, 0), (0, vec_1.xy)(this.ModLoader.ImGui.getWindowWidth(), this.topBarHeight), (0, vec_1.rgba)(0, 0, 0, 255));
        }
        if (this.currentTopNotification !== undefined) {
            if (this.currentTopNotification.pos.x < this.ModLoader.ImGui.getWindowWidth() + this.currentTopNotification.offscreen) {
                this.currentTopNotification = undefined;
                this.retracttopBar = true;
            }
            else {
                if (this.topBarHeight < this.topBarMaxHeight) {
                    this.topBarHeight++;
                }
                else {
                    this.ModLoader.ImGui.getWindowDrawList().addTextEx(this.ModLoader.ImGui.getFont(), 36, this.currentTopNotification.pos, this.currentTopNotification.color, this.currentTopNotification.text);
                    this.currentTopNotification.pos.x -= 1;
                }
            }
        }
        else {
            if (this.retracttopBar && this.topBarHeight > 0) {
                this.topBarHeight--;
                if (this.topBarHeight === 0) {
                    this.retracttopBar = false;
                }
            }
        }
    }
}
class BottomRightNotification {
    text;
    fgcolor;
    bgcolor;
    pos;
    icon;
    timer = 0;
    MAX_TIMER = 200;
    constructor(text, icon, color) {
        this.text = text;
        this.pos = (0, vec_1.xy)(0, 0);
        this.bgcolor = (0, vec_1.rgba)(0, 0, 0, 255);
        if (color !== undefined) {
            this.fgcolor = color;
        }
        else {
            this.fgcolor = (0, vec_1.rgba)(255, 255, 255, 255);
        }
        if (icon !== undefined) {
            this.icon = icon;
        }
    }
}
class BottomRightWidget {
    ModLoader;
    pos = (0, vec_1.xy)(0, 0);
    size = (0, vec_1.xy)(0, 0);
    timer = 0;
    TIMER_MAX = 200;
    targetPos = (0, vec_1.xy)(0, 0);
    notifs = [];
    currentNotif;
    font;
    constructor(ModLoader) {
        this.ModLoader = ModLoader;
    }
    add(kill) {
        this.notifs.push(new BottomRightNotification(kill.text, kill.icon, kill.color));
    }
    loadResources() {
        if (this.font === undefined) {
            try {
                this.font = this.ModLoader.Gfx.createFont();
                fs_1.default.writeFileSync("./PolygonParty-3KXM.ttf", fs_1.default.readFileSync(path_1.default.resolve(__dirname, "resources", "PolygonParty-3KXM.ttf")));
                this.font.loadFromFile("./PolygonParty-3KXM.ttf", 30, 2);
                this.ModLoader.logger.debug("Loading default font.");
            }
            catch (err) {
                this.ModLoader.logger.error(err);
            }
        }
    }
    update() {
        if (this.currentNotif === undefined && this.notifs.length > 0) {
            this.currentNotif = this.notifs.shift();
            let textSize = (0, vec_1.xy)(this.currentNotif.text.length * 20, 0);
            this.targetPos = (0, vec_1.xy)(0 + this.ModLoader.ImGui.getWindowWidth() - textSize.x, 0 + this.ModLoader.ImGui.getWindowHeight() - 200);
            this.pos = (0, vec_1.xy)(0 + this.ModLoader.ImGui.getWindowWidth() - textSize.x, 0 + this.ModLoader.ImGui.getWindowHeight());
            return;
        }
        if (this.currentNotif !== undefined) {
            this.pos.x = this.targetPos.x;
            if (this.pos.y > this.targetPos.y) {
                if (this.notifs.length > 5) {
                    this.pos.y -= 1 * 5;
                }
                else {
                    this.pos.y -= 1;
                }
            }
            else {
                if (this.notifs.length > 5) {
                    this.currentNotif.fgcolor.w -= 2 * 5 / 255;
                    this.currentNotif.bgcolor.w -= 2 * 5 / 255;
                }
                else {
                    this.currentNotif.fgcolor.w -= 2 / 255;
                    this.currentNotif.bgcolor.w -= 2 / 255;
                }
                if (this.currentNotif.fgcolor.w <= 0) {
                    this.currentNotif = undefined;
                    return;
                }
            }
            try {
                if (this.currentNotif.icon !== undefined) {
                    let f = this.ModLoader.Gfx.calcTextSize(this.font, "Test", (0, vec_1.xy)(1, 1));
                    let dst = (0, vec_1.xywh)(this.pos.x - 32, this.pos.y, f.y, f.y);
                    this.ModLoader.Gfx.addSprite(this.ModLoader.ImGui.getWindowDrawList(), this.currentNotif.icon, (0, vec_1.xywh)(0, 0, this.currentNotif.icon.width, this.currentNotif.icon.height), dst, (0, vec_1.rgba)(255, 255, 255, this.currentNotif.fgcolor.w * 255), 0 /* FlipFlags.None */);
                }
                this.ModLoader.Gfx.addText(this.ModLoader.ImGui.getWindowDrawList(), this.font, this.currentNotif.text, this.pos, this.currentNotif.fgcolor, this.currentNotif.bgcolor, (0, vec_1.xy)(1, 1));
            }
            catch (err) {
                this.ModLoader.logger.error(err.stack);
            }
        }
    }
}
class MenubarPlugin {
    ModLoader;
    Binding;
    resourcesLoaded = false;
    menubar;
    topNotifications;
    bottomRight;
    texturePacks;
    aspect = [0];
    aspect_options = ['Stretch', 'Force 4:3', 'Force 16:9', 'Adjust'];
    highres = false;
    ScreenWidth = [0];
    ScreenHeight = [0];
    fxaa = false;
    ms = [0];
    ani = [0];
    ms_options = [0, 2, 4, 8, 16];
    ani_options = [0, 2, 4, 8, 16];
    htc = false;
    hts = false;
    audio_options = ["trivial", "speex-fixed-4", "speex-fixed-10"];
    audio_options_display = ["Fast", "Normal", "Best"];
    audio_selection = [0];
    preinit() {
        this.menubar = new MenubarWidget(this.ModLoader);
        this.topNotifications = new TopBarWidget(this.ModLoader);
        this.bottomRight = new BottomRightWidget(this.ModLoader);
        this.texturePacks = new TexturePackManager(this.ModLoader);
    }
    init() {
    }
    onAnnounce(packet) {
        (0, Announcements_1.addToSystemNotificationQueue)(packet.text);
    }
    postinit() {
        try {
            this.aspect[0] = this.Binding["mupen"].M64p.Config.openSection("Video-GLideN64").getIntOr("AspectRatio", 1);
            this.highres = this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').getBoolOr('txHiresEnable', false);
            this.ScreenWidth[0] = this.Binding["mupen"].M64p.Config.openSection("Video-General").getIntOr("ScreenWidth", 800);
            this.ScreenHeight[0] = this.Binding["mupen"].M64p.Config.openSection("Video-General").getIntOr("ScreenHeight", 600);
            this.fxaa = this.Binding["mupen"].M64p.Config.openSection("Video-GLideN64").getBoolOr("FXAA", false);
            this.htc = this.Binding["mupen"].M64p.Config.openSection("Video-GLideN64").getBoolOr("txHiresTextureFileStorage", false);
            this.hts = this.Binding["mupen"].M64p.Config.openSection("Video-GLideN64").getBoolOr("txHiresTextureFileStorage", false);
            this.ms[0] = this.Binding["mupen"].M64p.Config.openSection("Video-GLideN64").getIntOr("MultiSampling", 0);
            this.ani[0] = this.Binding["mupen"].M64p.Config.openSection("Video-GLideN64").getIntOr("MaxAnisotropy", 0);
            let audio = this.Binding["mupen"].M64p.Config.openSection("Audio-SDL").getStringOr("RESAMPLE", "trivial");
            let volumeAdjust = this.Binding.mupen.M64p.Config.openSection('Audio-SDL').getIntOr('VOLUME_ADJUST', 5);
            for (let i = 0; i < this.audio_options.length; i++) {
                if (audio === this.audio_options[i]) {
                    this.audio_selection[0] = i;
                    break;
                }
            }
            this.Binding.on('core-event', (event, v) => {
                if (event == 13 /* CoreEvent.VolumeDown */)
                    this.Binding.mupen.M64p.setAudioVolume(this.Binding.mupen.M64p.getAudioVolume() - volumeAdjust);
                else if (event == 12 /* CoreEvent.VolumeUp */)
                    this.Binding.mupen.M64p.setAudioVolume(this.Binding.mupen.M64p.getAudioVolume() + volumeAdjust);
            });
            this.Binding.on('core-state-changed', (param, newValue) => {
                if (param == 7 /* CoreParam.AudioVolume */) {
                    if (this.ModLoader.sound.listener !== undefined) {
                        this.ModLoader.sound.listener.globalVolume = newValue;
                    }
                    else {
                        console.log("wtf");
                    }
                }
            });
        }
        catch (err) {
            this.ModLoader.logger.error(err);
        }
        this.texturePacks.post();
    }
    onTick(frame) {
        this.menubar.onTick();
    }
    onDisableCheats(evt) {
        this.menubar.cheatMenuEnabled = false;
    }
    onDisableMemoryViewer(evt) {
        this.menubar.memoryViewerEnabled = false;
    }
    onNotif(notif) {
        this.topNotifications.add(notif);
    }
    onKillfeed(notif) {
        this.bottomRight.add(notif);
    }
    onResourceLoad() {
    }
    onViUpdate() {
        if (!this.resourcesLoaded) {
            this.bottomRight.loadResources();
            this.resourcesLoaded = true;
        }
        this.menubar.update();
        this.topNotifications.update();
        this.bottomRight.update();
        this.texturePacks.update();
        if (this.ModLoader.ImGui.beginMainMenuBar()) {
            if (this.ModLoader.ImGui.beginMenu("Emulation")) {
                if (this.ModLoader.ImGui.combo('Aspect ratio', this.aspect, this.aspect_options)) {
                    this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setInt('AspectRatio', this.aspect[0]);
                }
                if (this.ModLoader.ImGui.inputInt("Screen Width", this.ScreenWidth)) {
                    let w = Math.floor(this.ScreenWidth[0]);
                    this.Binding["mupen"].M64p.Config.openSection("Video-General").setInt("ScreenWidth", w);
                }
                if (this.ModLoader.ImGui.inputInt("Screen Height", this.ScreenHeight)) {
                    let w = Math.floor(this.ScreenHeight[0]);
                    this.Binding["mupen"].M64p.Config.openSection("Video-General").setInt("ScreenHeight", w);
                }
                if (this.ModLoader.ImGui.beginMenu("Enable High Res Texture Packs")) {
                    if (this.ModLoader.ImGui.menuItem("Rice/HTC", undefined, this.htc, true)) {
                        this.htc = !this.htc;
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setBool('txHiresEnable', true);
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setInt('txCacheSize', 1000);
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setBool('txHiresFullAlphaChannel', true);
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setBool('txEnhancedTextureFileStorage', false);
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setBool('txHiresTextureFileStorage', false);
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setBool('txSaveCache', true);
                    }
                    if (this.ModLoader.ImGui.menuItem("HTS", undefined, this.hts, true)) {
                        this.hts = !this.hts;
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setBool('txHiresEnable', true);
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setInt('txCacheSize', 1000);
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setBool('txHiresFullAlphaChannel', true);
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setBool('txEnhancedTextureFileStorage', true);
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setBool('txHiresTextureFileStorage', true);
                    }
                    this.ModLoader.ImGui.endMenu();
                }
                if (this.ModLoader.ImGui.menuItem("FXAA", undefined, this.fxaa, true)) {
                    this.fxaa = !this.fxaa;
                    this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setBool('FXAA', this.fxaa);
                }
                if (this.ModLoader.ImGui.combo("Max Anisotropy", this.ani, this.ani_options)) {
                    if (this.ani[0] === 0) {
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setInt('MaxAnisotropy', 0);
                    }
                    if (this.ani[0] === 1) {
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setInt('MaxAnisotropy', 2);
                    }
                    if (this.ani[0] === 2) {
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setInt('MaxAnisotropy', 4);
                    }
                    if (this.ani[0] === 3) {
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setInt('MaxAnisotropy', 8);
                    }
                    if (this.ani[0] === 4) {
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setInt('MaxAnisotropy', 16);
                    }
                }
                if (this.ModLoader.ImGui.combo("MultiSampling", this.ms, this.ms_options)) {
                    if (this.ms[0] === 0) {
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setInt('MultiSampling', 0);
                    }
                    if (this.ms[0] === 1) {
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setInt('MultiSampling', 2);
                    }
                    if (this.ms[0] === 2) {
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setInt('MultiSampling', 4);
                    }
                    if (this.ms[0] === 3) {
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setInt('MultiSampling', 8);
                    }
                    if (this.ms[0] === 4) {
                        this.Binding["mupen"].M64p.Config.openSection('Video-GLideN64').setInt('MultiSampling', 16);
                    }
                }
                if (this.ModLoader.ImGui.combo("Audio", this.audio_selection, this.audio_options_display)) {
                    this.Binding["mupen"].M64p.Config.openSection("Audio-SDL").setString("RESAMPLE", this.audio_options[this.audio_selection[0]]);
                }
                this.ModLoader.ImGui.text("These settings require a restart to take effect.");
                this.ModLoader.ImGui.endMenu();
            }
            this.ModLoader.ImGui.endMainMenuBar();
        }
    }
    onFontChange(font) {
        this.bottomRight.font = font;
    }
}
__decorate([
    (0, NetworkHandler_1.NetworkHandler)('AnnouncePacket')
], MenubarPlugin.prototype, "onAnnounce", null);
__decorate([
    (0, EventHandler_1.EventHandler)("disableCheatMenu" /* MenuEvents.DISABLE_CHEATS */)
], MenubarPlugin.prototype, "onDisableCheats", null);
__decorate([
    (0, EventHandler_1.EventHandler)("disableMemoryViewer" /* MenuEvents.DISABLE_MEMORY_VIEWER */)
], MenubarPlugin.prototype, "onDisableMemoryViewer", null);
__decorate([
    (0, EventHandler_1.EventHandler)("SYSTEM_NOTIFICATION" /* AnnouncementChannels.SYSTEM_NOTIFICATION */)
], MenubarPlugin.prototype, "onNotif", null);
__decorate([
    (0, EventHandler_1.EventHandler)("KILL_FEED" /* AnnouncementChannels.KILL_FEED */)
], MenubarPlugin.prototype, "onKillfeed", null);
__decorate([
    (0, PluginLifecycle_1.onCreateResources)()
], MenubarPlugin.prototype, "onResourceLoad", null);
__decorate([
    (0, PluginLifecycle_1.onViUpdate)()
], MenubarPlugin.prototype, "onViUpdate", null);
__decorate([
    (0, EventHandler_1.EventHandler)("CHANGE_FONT" /* NotificationEvents.CHANGE_FONT */)
], MenubarPlugin.prototype, "onFontChange", null);
module.exports = MenubarPlugin;
//# sourceMappingURL=MenubarPlugin.js.map