Example #1
0
        public MainWindow()
        {
            InitializeComponent();
            Resources.MergedDictionaries.Clear();
            helper = Program.helper;
            Resources.MergedDictionaries.Add(helper.langRd);

            Desc.Text = helper.GetString("L_SelectEXE");
        }
Example #2
0
        private void Patch_Click(object sender, RoutedEventArgs e)
        {
            string path = SelectPath();

            if (path == null)
            {
                return;
            }
            if (isSDVExe(path) || EnsureSDVExe(path))
            {
                try
                {
                    FileVersionInfo SelectedVersion = FileVersionInfo.GetVersionInfo(path);
                    Stream          source          = new FileStream(path, FileMode.Open);
                    if (Program.patchData.version != SelectedVersion.FileVersion)
                    {
                        Program.logger.Log("PatchData Version: {0}\n Selected Version: {1}\n Selected Path: {2}",
                                           ConsoleLogger.LogLevel.Warn,
                                           Program.patchData.version,
                                           SelectedVersion.FileVersion,
                                           path);
                        Desc.Text = helper.GetString("L_Patch_ExeVersion", Program.patchData.version);
                        return;
                    }
                    if (!Program.CheckSHA1(Program.patchData.Source_SHA1, source))
                    {
                        Desc.Text = helper.GetString("L_Patch_ExeSHA1", Program.patchData.version);
                        return;
                    }
                    Stream dest = PatchHelper.GetPatched(source, Program.patchData.patch);
                    if (!Program.CheckSHA1(Program.patchData.Dest_SHA1, dest))
                    {
                        Desc.Text = helper.GetString("L_Patch_Fail_SHA1", Program.patchData.version);
                        return;
                    }
                    string destDict  = Path.GetDirectoryName(path);
                    string destName  = "Stardew Valley_Patched.exe";
                    string finalPath = Path.Combine(destDict, destName);
                    StreamHelper.WriteFile(dest, finalPath);
                    Program.ExtractDlls(destDict);
                    Desc.Text    = helper.GetString("L_Patch_Done", destName);
                    Command.Text = string.Format("\"{0}\" %command%", finalPath);
                    source.Close();
                }
                catch (Exception ex)
                {
                    Desc.Text = helper.GetString("L_Patch_Fail");
                    Program.logger.Log(ex.Message, ConsoleLogger.LogLevel.Error);
                    Program.logger.Log(ex.StackTrace, ConsoleLogger.LogLevel.Error);
                }
            }
        }
 internal void LogTrans(string resxPath, LogLevel level = LogLevel.Info, params string[] args)
 {
     Log(helper.GetString(resxPath, args), level);
 }