Beispiel #1
0
        public static async void PlaySound(string sound, bool loop)
        {
            Logger.WriteLine($"attempting to play sound: {sound}");

            try
            {
                // gc isn't happy rn
                // create wave out event and initialize it with the vorbis wave reader
                using (WaveOutEvent waveOut = new WaveOutEvent())
                {
                    // create vorbis wave reader
                    using (VorbisWaveReader v = new VorbisWaveReader($"{Static.audioPath}\\{sound}.ogg"))
                    {
                        // also create a loop stream and initialize the wave out event with the loop stream instead of loop is true
                        using (LoopStream loopStream = new LoopStream(v))
                        {
                            if (loop)
                            {
                                waveOut.Init(loopStream);
                            }
                            else
                            {
                                waveOut.Init(v);
                            }

                            // flush and dispose the streams after playback stops
                            void Dispose(object sender, StoppedEventArgs e)
                            {
                                v.Flush();
                                v.Dispose();
                                waveOut.Dispose();
                                loopStream.Flush();
                                loopStream.Dispose();
                            }
                            waveOut.PlaybackStopped += Dispose;

                            // play
                            waveOut.Play();

                            // add the wave out event to the active audio list so it can be stopped manually
                            activeAudio.Add(waveOut);

                            // wait the duration of the sound
                            await Task.Delay(v.TotalTime);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionMessage.New(ex, true);
            }
        }
Beispiel #2
0
 public static void LaunchOneShot()
 {
     try
     {
         Logger.WriteLine("starting oneshot");
         if (File.Exists(baseOneShotPath + "\\steamshim.exe"))
         {
             Logger.WriteLine("steamshim.exe");
             Process.Start(baseOneShotPath + "\\steamshim.exe");
         }
         else
         {
             Logger.WriteLine("oneshot.exe");
             Process.Start(baseOneShotPath + "\\oneshot.exe");
         }
     }
     catch (Exception ex)
     {
         ExceptionMessage.New(ex, false);
         MessageBox.Show("Failed to start OneShot.\nThe log may contain more information.");
     }
 }
Beispiel #3
0
        public ModBox(string path)
        {
            try
            {
                modPath = path;
                Size    = new Size(230, 50);

                Label      displayName = new Label();
                Label      author      = new Label();
                Label      desc        = new Label();
                PictureBox icon        = new PictureBox();

                modName    = modPath.Substring(modPath.LastIndexOf("Mods") + 5);
                desc.Text  = "Metadata is nonexistent or unreadable";
                icon.Image = Image.FromFile(Static.spritesPath + "mmd_icon_default.png");

                // read from metadata
                if (File.Exists(modPath + "\\.osml\\metadata.ini"))
                {
                    IniData data = INIManage.Read(modPath + "\\.osml\\metadata.ini");

                    modName     = data["config"]["displayName"] + " - " + data["config"]["version"];
                    author.Text = "by " + data["config"]["author"];
                    desc.Text   = data["config"]["description"];
                }
                // and the icon
                if (File.Exists(modPath + "\\.osml\\icon.png"))
                {
                    icon.Image = Image.FromFile(modPath + "\\.osml\\icon.png");
                }

                displayName.Text = modName;

                // position
                icon.Location        = new Point(0, 0);
                displayName.Location = new Point(50, 0);
                author.Location      = new Point(50, 10);
                desc.Location        = new Point(50, 20);

                // icon size
                icon.Size     = new Size(50, 50);
                icon.SizeMode = PictureBoxSizeMode.StretchImage;

                // font
                displayName.Font = Static.GetTerminusFont(9);
                author.Font      = Static.GetTerminusFont(9);
                desc.Font        = Static.GetTerminusFont(9);

                // colour
                displayName.ForeColor = Color.MediumPurple;
                author.ForeColor      = Color.MediumPurple;
                desc.ForeColor        = Color.MediumPurple;

                displayName.AutoSize = true;
                author.AutoSize      = true;
                desc.AutoSize        = true;

                Controls.Add(displayName);
                Controls.Add(author);
                Controls.Add(desc);
                Controls.Add(icon);
            }
            catch (Exception ex)
            {
                ExceptionMessage.New(ex, true);
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            try
            {
                // initialize logger
                if (!Directory.Exists(Static.appDataPath + "logs"))
                {
                    Directory.CreateDirectory(Static.appDataPath + "logs");
                }
                Logger.Init();

                Logger.WriteLine("les goooooooooooooo");
                Logger.WriteLine(Static.ver);

                // base os stuff
                doneSetup = Directory.Exists(Static.modsPath + "/base oneshot") && File.Exists(Static.appDataPath + "path.molly");

                if (File.Exists(Static.appDataPath + "path.molly"))
                {
                    Static.baseOneShotPath = File.ReadAllText(Static.appDataPath + "path.molly");
                }
                else
                {
                    Static.baseOneShotPath = "woah";
                }

                // create modinfo path (this will be used in a future update)
                if (!Directory.Exists(Static.modInfoPath))
                {
                    Directory.CreateDirectory(Static.modInfoPath);
                }

                // append contents of osmlargs.txt to args
                ReadArgsFile(ref args);

                // add terminus to the font collection
                Static.AddFonts();

                // start divide by zero thread
                Thread divideByZeroThread = new Thread(new ThreadStart(DivideByZeroThread));
                divideByZeroThread.Start();

                //////////////////////////////////////////////////////////////
                // Run Application
                //////////////////////////////////////////////////////////////

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                if (args.Length == 0)
                {
                    Application.Run(new MainForm());
                }
                else
                {
                    ProcessArgs(args);
                }

                //////////////////////////////////////////////////////////////
                // After the application has finished running
                //////////////////////////////////////////////////////////////

                // abort background threads
                divideByZeroThread.Abort();

                // write the logger to a file
                Logger.ToFile();
            }
            catch (ObjectDisposedException) { }
            catch (Exception ex)
            {
                Logger.WriteLine("caught in Program.Main():");
                ExceptionMessage.New(ex, true, "OneShot ModLoader will now close.");
            }
        }