Exemple #1
0
        // TODO remove forced mode checkbox?

        public BmpMain()
        {
            InitializeComponent();
            SetupCommands();

            this.UpdatePerformance();

            BmpUpdate update = new BmpUpdate();

            if (!Program.programOptions.DisableUpdate)
            {
                updateResult = update.ShowDialog();
                if (updateResult == DialogResult.Yes)
                {
                    updateTitle  = update.version.updateTitle;
                    updateText   = update.version.updateText;
                    updateResult = DialogResult.Yes;
                }
            }
            this.Text = update.version.ToString();

            // Clear local orchestra
            InfoTabs.TabPages.Remove(localOrchestraTab);

            FFXIV.findProcessRequest += delegate(Object o, EventArgs empty) {
                this.Invoke(t => t.FindProcess());
            };

            FFXIV.findProcessError += delegate(Object o, BmpHook.ProcessError error) {
                this.Invoke(t => t.ErrorProcess(error));
            };

            FFXIV.hotkeys.OnFileLoad += delegate(Object o, EventArgs empty) {
                this.Invoke(t => t.Hotkeys_OnFileLoad(FFXIV.hotkeys));
            };
            FFXIV.hook.OnKeyPressed     += Hook_OnKeyPressed;
            FFXIV.memory.OnProcessReady += delegate(object o, Process proc) {
                this.Log(string.Format("[{0}] Process scanned and ready.", proc.Id));
            };
            FFXIV.memory.OnProcessLost += delegate(object o, EventArgs arg) {
                this.Log("Attached process exited.");
            };
            FFXIV.memory.OnChatReceived += delegate(object o, ChatLogItem item) {
                this.Invoke(t => t.Memory_OnChatReceived(item));
            };
            FFXIV.memory.OnPerformanceChanged += delegate(object o, List <uint> ids) {
                this.Invoke(t => t.LocalOrchestraUpdate((o as FFXIVMemory).GetActorItems(ids)));
            };
            FFXIV.memory.OnPerformanceReadyChanged += delegate(object o, bool performance) {
                this.Invoke(t => t.Memory_OnPerformanceReadyChanged(performance));
            };
            FFXIV.memory.OnCurrentPlayerJobChange += delegate(object o, CurrentPlayerResult res) {
                this.Invoke(t => t.Memory_OnCurrentPlayerJobChange(res));
            };
            FFXIV.memory.OnCurrentPlayerLogin += delegate(object o, CurrentPlayerResult res) {
                string format = string.Format("Character [{0}] logged in.", res.CurrentPlayer.Name);
                this.Log(format);

                this.Invoke(t => t.UpdatePerformance());
            };
            FFXIV.memory.OnCurrentPlayerLogout += delegate(object o, CurrentPlayerResult res) {
                string format = string.Format("Character [{0}] logged out.", res.CurrentPlayer.Name);
                this.Log(format);
            };
            FFXIV.memory.OnPartyChanged += delegate(object o, PartyResult res) {
                this.Invoke(t => t.LocalOrchestraUpdate());
            };

            Player.OnStatusChange += delegate(object o, PlayerStatus status) {
                this.Invoke(t => t.UpdatePerformance());
            };

            Player.OnSongSkip  += OnSongSkip;
            Player.OnMidiLyric += OnMidiLyric;

            Player.OnMidiStatusChange += OnPlayStatusChange;
            Player.OnMidiStatusEnded  += OnPlayStatusEnded;

            Player.OnMidiNote  += OnMidiVoice;
            Player.OffMidiNote += OffMidiVoice;

            Player.Player.OpenInputDevice(Settings.GetMidiInput().name);

            Settings.OnMidiInputChange += delegate(object o, MidiInput input) {
                Player.Player.CloseInputDevice();
                if (input.id != -1)
                {
                    Player.Player.OpenInputDevice(input.name);
                    Log(string.Format("Switched to {0} ({1})", input.name, input.id));
                }
            };
            Settings.OnKeyboardTest += delegate(object o, EventArgs arg) {
                foreach (FFXIVKeybindDat.Keybind keybind in FFXIV.hotkeys.GetPerformanceKeybinds())
                {
                    FFXIV.hook.SendSyncKeybind(keybind);
                    Thread.Sleep(100);
                }
            };

            Settings.OnForcedOpen += delegate(object o, bool open) {
                this.Invoke(t => t.UpdatePerformance());
            };

            chordNotes            = new NoteChordSimulation <BmpPlayer.NoteEvent>();
            chordNotes.NoteEvent += OnMidiVoice;

            Explorer.OnBrowserVisibleChange += delegate(object o, bool visible) {
                MainTable.RowStyles[MainTable.GetRow(ChatPlaylistTable)].Height   = visible ? 0 : 100;
                MainTable.RowStyles[MainTable.GetRow(ChatPlaylistTable)].SizeType = visible ? SizeType.Absolute : SizeType.Percent;
                //ChatPlaylistTable.Invoke(t => t.Visible = !visible);

                MainTable.RowStyles[MainTable.GetRow(Explorer)].Height   = visible ? 100 : 30;
                MainTable.RowStyles[MainTable.GetRow(Explorer)].SizeType = visible ? SizeType.Percent : SizeType.Absolute;
            };
            Explorer.OnBrowserSelect += Browser_OnMidiSelect;

            Playlist.OnMidiSelect         += Playlist_OnMidiSelect;
            Playlist.OnPlaylistRequestAdd += Playlist_OnPlaylistRequestAdd;

            if (Properties.Settings.Default.SaveLog)
            {
                FileTarget target = new NLog.Targets.FileTarget("chatlog")
                {
                    FileName          = "logs/ff14log.txt",
                    Layout            = @"${date:format=yyyy-MM-dd HH\:mm\:ss} ${message}",
                    ArchiveDateFormat = "${shortdate}",
                    ArchiveEvery      = FileArchivePeriod.Day,
                    ArchiveFileName   = "logs/ff14log-${shortdate}.txt",
                    Encoding          = Encoding.UTF8,
                };

                var config = new NLog.Config.LoggingConfiguration();
                config.AddRule(LogLevel.Info, LogLevel.Info, target);
                NLog.LogManager.Configuration = config;
            }

            string upath = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming).FilePath;

            //Console.WriteLine(string.Format(".config: [{0}]", upath));

            Settings.RefreshMidiInput();

            Log("Bard Music Player initialized.");
        }