예제 #1
0
        /// <summary>
        /// Checks whether the ExitButton has been found and executes Actions setted inside the Settings
        /// </summary>
        private void ExitCheck()
        {
            IntPtr?sodaGame = CheckGameRunning();

            if (sodaGame == null)
            {
                return;
            }
            Bitmap image;

            try{
                image = Logic.TakeScreenshot((IntPtr)sodaGame);
            }
            catch (System.Runtime.InteropServices.ExternalException)
            {
                return;
            }
            ScreenshotImage = ScreenCapture.ImageSourceFromBitmap(image);
            screenshots.Add(image);
            if (Logic.HasExitButton(image))
            {
                screenshots.Save();
                Logic.ExitButtonFound(image, Config, StartStopTimer);
            }
        }
예제 #2
0
        private bool SaveThreadRoutine(string filename)
        {
#if !DEBUG
            try
            {
#endif
            System.Threading.Thread.CurrentThread.Name = "Save";
            // Ensure we're using the invariant culture.
            System.Threading.Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
            System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
            DirectoryInfo worldDirectory =
                Directory.CreateDirectory(DwarfGame.GetWorldDirectory() +
                                          Path.DirectorySeparatorChar + Overworld.Name);

            // This is a hack. Why does the overworld have this as a static field??
            Overworld.NativeFactions = this.Natives;
            NewOverworldFile file = new NewOverworldFile(Game.GraphicsDevice, Overworld.Map, Overworld.Name, SeaLevel);
            file.WriteFile(worldDirectory.FullName);

            try
            {
                file.SaveScreenshot(worldDirectory.FullName + Path.DirectorySeparatorChar + "screenshot.png");
            }
            catch (Exception exception)
            {
                Console.Error.WriteLine(exception.ToString());
            }

            gameFile = SaveGame.CreateFromWorld(this);
            var path = DwarfGame.GetSaveDirectory() + Path.DirectorySeparatorChar +
                       filename;
            SaveGame.DeleteOldestSave(path, GameSettings.Default.MaxSaves, "Autosave");
            gameFile.WriteFile(path);
            ComponentManager.CleanupSaveData();

            lock (ScreenshotLock)
            {
                Screenshots.Add(new Screenshot()
                {
                    FileName = DwarfGame.GetSaveDirectory() +
                               Path.DirectorySeparatorChar + filename + Path.DirectorySeparatorChar +
                               "screenshot.png",
                    Resolution = new Point(128, 128)
                });
            }
#if !DEBUG
        }

        catch (Exception exception)
        {
            Console.Error.Write(exception.ToString());
            Game.CaptureException(exception);
            throw new WaitStateException(exception.Message);
        }
#endif
            return(true);
        }
예제 #3
0
        public override void TakeScreenshot()
        {
            try
            {
                Debug.WriteLine("Creating a MTN process...");
                string assemblyMTN = (Program.IsUNIX ? Program.Settings.MTNPath.Replace(".exe", "") : Program.Settings.MTNPath);
                if (string.IsNullOrEmpty(Path.GetDirectoryName(assemblyMTN)))
                {
                    assemblyMTN = Path.Combine(System.Windows.Forms.Application.StartupPath, assemblyMTN);
                    Program.Settings.MTNPath = assemblyMTN;
                }

                string args = string.Format("{0} \"{1}\"", Adapter.GetMtnArg(ScreenshotDir, Program.mtnProfileMgr.GetMtnProfileActive()), MediaFile.FilePath);

                Process          p   = new Process();
                ProcessStartInfo psi = new ProcessStartInfo(assemblyMTN);

                if (Program.IsUNIX)
                {
                    psi.UseShellExecute = false;
                }

                Debug.WriteLine("MTN Path: " + assemblyMTN);
                Debug.WriteLine("MTN Args: " + args);

                psi.WindowStyle = (Program.Settings.ShowMTNWindow ? ProcessWindowStyle.Normal : ProcessWindowStyle.Minimized);
                Debug.WriteLine("MTN Window: " + psi.WindowStyle.ToString());
                psi.Arguments = args;

                p.StartInfo = psi;
                p.Start();
                p.WaitForExit(1000 * 30);

                string ssPath = Path.Combine(ScreenshotDir, Path.GetFileNameWithoutExtension(MediaFile.FilePath) + Program.mtnProfileMgr.GetMtnProfileActive().o_OutputSuffix);
                Screenshots.Add(new Screenshot(ssPath)
                {
                    Args = args
                });

                if (Program.IsUNIX)
                {
                    string info = Path.Combine(FileSystem.GetScreenShotsDir(MediaFile.FilePath), Path.GetFileNameWithoutExtension(MediaFile.FilePath) + Program.mtnProfileMgr.GetMtnProfileActive().N_InfoSuffix);

                    using (StreamReader sr = new StreamReader(info))
                    {
                        MediaSummary = sr.ReadToEnd();
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
        }
예제 #4
0
        public GameViewModel(Game game) : this()
        {
            GameID           = game.GameID;
            GameName         = game.GameName;
            URL              = game.URL;
            CoverImageURL    = game.CoverImageURL;
            StoryLine        = game.StoreLine;
            Summary          = game.Summary;
            FirstReleaseDate = game.FirstReleaseDate;
            Published        = game.Published.HasValue ? game.Published.Value : false;

            foreach (var gameGenre in game.GameGenres)
            {
                Genres.Add(
                    new GenreViewModel(gameGenre.Genre)
                    );
            }

            foreach (var gameTheme in game.GameThemes)
            {
                Themes.Add(
                    new ThemeViewModel(gameTheme.Theme)
                    );
            }

            foreach (var gameMode in game.GameModes)
            {
                Modes.Add(
                    new ModeViewModel(gameMode.Mode)
                    );
            }

            foreach (var gamePerspective in game.GamePerspectives)
            {
                Perspectives.Add(
                    new PerspectiveViewModel(gamePerspective.Perspective)
                    );
            }

            foreach (var gameScreenshots in game.GameScreenshots)
            {
                Screenshots.Add(
                    new ScreenshotViewModel(gameScreenshots.Screenshot)
                    );
            }

            foreach (var gamePlatform in game.GamePlatforms)
            {
                Platforms.Add(
                    new PlatformViewModel(
                        gamePlatform.Platform,
                        gamePlatform.ReleaseDate.Value)
                    );

                foreach (var history in gamePlatform.VendorGameHistories)
                {
                    PriceHistory.Add(
                        new PriceHistoryViewModel(history)
                        );
                }
            }


            if (PriceHistory.Count() > 0)
            {
                TodaysPrices  = PriceHistory?.Where(ph => ph.CreatedDate >= DateTime.Today).ToList();
                Cheapest      = TodaysPrices?.GroupBy(ph => ph.Price)?.OrderBy(ph => double.Parse(ph.Key))?.FirstOrDefault()?.Select(ph => ph).ToList();
                CheapestPrice = Cheapest?.FirstOrDefault().Price;
            }

            foreach (var settings in game.GamePlatforms.Select(gp => gp.VendorGameSettings))
            {
                foreach (var setting in settings)
                {
                    Settings.Add(new VendorGameSettingViewModel(setting));
                }
            }
        }
예제 #5
0
        public override void TakeScreenshot()
        {
            string tempFp     = Path.Combine(ScreenshotDir, MplayerScreenshotFileName);
            int    time_slice = (int)(MediaFile.SegmentDuration / ((Options.NumberOfScreenshots + 1) * 1000));

            if (File.Exists(tempFp))
            {
                File.Delete(tempFp);
            }

            List <string>     fpPaths = new List <string>();
            List <Screenshot> tempSS  = new List <Screenshot>();

            for (int i = 0; i < Options.NumberOfScreenshots; i++)
            {
                int    time_slice_elapsed = time_slice * (i + 1);
                string arg = string.Format("-nosound -ss {0} -zoom -vf screenshot -frames 1 -vo png:z=9:outdir=\\\"{1}\\\" \"{2}\"", time_slice_elapsed,
                                           ScreenshotDir,
                                           MediaFile.FilePath);
                ProcessStartInfo psi = new ProcessStartInfo(Program.Settings.MPlayerPath);
                psi.WindowStyle = ProcessWindowStyle.Minimized;
                psi.Arguments   = arg;

                Process p = new Process();
                p.StartInfo = psi;
                p.Start();
                p.WaitForExit(1000 * 30);

                string temp_fp = Path.Combine(ScreenshotDir, string.Format("{0}-{1}.png", Path.GetFileNameWithoutExtension(MediaFile.FilePath), time_slice_elapsed));

                if (File.Exists(temp_fp))
                {
                    File.Delete(temp_fp);
                }

                if (File.Exists(tempFp))
                {
                    File.Move(tempFp, temp_fp);
                    fpPaths.Add(temp_fp);
                    tempSS.Add(new Screenshot(temp_fp)
                    {
                        Args = arg
                    });
                }
            }

            if (fpPaths.Count > 0)
            {
                if (Options.CombineScreenshots)
                {
                    System.Drawing.Image img = Combine(fpPaths.ToArray(), 5, Options.CombineScreenshotsAddMovieInfo ? MediaFile.GetMTNString() : "");
                    string temp_fp           = Path.Combine(ScreenshotDir, Path.GetFileNameWithoutExtension(MediaFile.FilePath) + "_s.png");
                    img.Save(temp_fp, ImageFormat.Png);
                    Screenshots.Add(new Screenshot(temp_fp)
                    {
                        Args = tempSS[0].Args
                    });
                }
                else
                {
                    Screenshots.AddRange(tempSS);
                }
            }
        }