示例#1
0
        //private SeString nowPlayingString;
        //private TextPayload currentSongPayload;

        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            this.pi = pluginInterface;

            this.configuration = pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
            this.configuration.Initialize(pluginInterface);
            this.enableFallbackPlayer = this.configuration.UseOldPlayback;

            this.localDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            var songlistPath = Path.Combine(this.localDir, songListFile);

            this.songList = new SongList(songlistPath, this.configuration, this, this);

            // TODO: eventually it might be nice to do this only if the fallback player isn't being used
            // and to add/remove it on-demand if that changes
            var addressResolver = new AddressResolver();

            try
            {
                addressResolver.Setup(pluginInterface.TargetModuleScanner);
                this.bgmControl = new BGMControl(addressResolver);
                this.bgmControl.OnSongChanged  += HandleSongChanged;
                this.bgmControl.OnSongChanged2 += HandleSongChanged2;
                this.bgmControl.StartUpdate();
            }
            catch (Exception e)
            {
                PluginLog.LogError(e, "Failed to find BGM playback objects");
                this.bgmControl?.Dispose();
                this.bgmControl = null;

                this.enableFallbackPlayer = true;
            }

            // TODO: for new payload system
            // cached string so we don't have to rebuild this entire payload set each time
            //this.currentSongPayload = new TextPayload("");           // dummy, filled in when needed
            //this.nowPlayingString = new SeString(new Payload[] {
            //    new TextPayload("Now playing "),
            //    EmphasisItalicPayload.ItalicsOn,
            //    this.currentSongPayload,
            //    EmphasisItalicPayload.ItalicsOff,
            //    new TextPayload(".")
            //});

            // caches all the payloads - future updates will only have to reencode the song name payload
            // this.nowPlayingString.Encode();

            pluginInterface.CommandManager.AddHandler(commandName, new CommandInfo(OnDisplayCommand)
            {
                HelpMessage = "Displays the orchestrion player, to view, change, or stop in-game BGM."
            });
            pluginInterface.UiBuilder.OnBuildUi += Display;

            pluginInterface.UiBuilder.OnOpenConfigUi += (sender, args) => this.songList.SettingsVisible = true;
            this.songReplacementCfg = new SongReplacementList(this);
        }
示例#2
0
        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            this.pi = pluginInterface;

            var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), songListFile);

            this.songList = new SongList(path, this, customSongs);

            this.config      = pi.GetPluginConfig() as CustomSongConfiguration ?? new CustomSongConfiguration();
            this.customSongs = new CustomSongController(this.config, this.pi);

            pluginInterface.CommandManager.AddHandler(commandName, new CommandInfo(OnDisplayCommand));
            pluginInterface.UiBuilder.OnBuildUi += Display;
        }