コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: Drakulix/TeknoMW3
        /// <summary>
        /// The window_ loaded.
        /// </summary>
        /// <param name="sender">
        /// The sender. 
        /// </param>
        /// <param name="e">
        /// The e. 
        /// </param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.Window.Title = "TeknoGods Modern Warfare 3 Offline/LAN gameplay MOD "
                                + Assembly.GetExecutingAssembly().GetName().Version;

#if (!DEBUG)

    // if (Directory.GetCurrentDirectory().Contains(@"\steamapps\common\") == false)
    // {
    // MessageBox.Show(
    // "It seems that you are not running legit version of the game, please buy it!",
    // "Error",
    // MessageBoxButton.OK,
    // MessageBoxImage.Error);
    // this.Close();
    // return;
    // }

            var dir = Read("SteamPath");

            if(dir == null)
            {
                MessageBox.Show("Cannot find Steam installation directory!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
                return;
            }

            if (dir.Substring(dir.Length - 1, 1) != "/" || dir.Substring(dir.Length - 1, 1) != "\\")
            {
                dir += "/";
            }

            if(Directory.Exists(dir) == false)
            {
                MessageBox.Show("Cannot find Steam installation directory!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
                return;
            }

            if (File.Exists(dir + "ClientRegistry.blob") == false)
            {
                MessageBox.Show("Cannot open Steam registry!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
                return;                
            }

            var file = File.ReadAllBytes(dir + "ClientRegistry.blob");

            var found = IndexOf(file, Encoding.ASCII.GetBytes("115300"));

            var found2 = IndexOf(file, Encoding.ASCII.GetBytes("42690"));

            if(found == -1 && found2 == -1)
            {
                MessageBox.Show(
                    "It appears you've never used a legitimate Call of Duty - Modern Warfare 3 copy on this computer. Please launch Steam and the game at least once.", 
                    "Error", 
                    MessageBoxButton.OK, 
                    MessageBoxImage.Error);
                this.Close();
                return;
            }

            if (File.Exists("teknomw3.dll") == false)
            {
                MessageBox.Show(
                    "Cannot find teknomw3.dll", 
                    "Error", 
                    MessageBoxButton.OK, 
                MessageBoxImage.Error);
                this.Close();
                return;
            }

            if (this.GetMD5HashFromFile("teknomw3.dll") != "fa61fa41dca866f57c4eb7d189a937c6")
            {
                MessageBox.Show(
                "Please extract the TeknoGods teknomw3.dll in the game folder", 
                "Error", 
                MessageBoxButton.OK, 
                MessageBoxImage.Error);
                this.Close();
                return;
            }


#endif
            if (File.Exists(@".\devraw\video\startup.bik") == false)
            {
                if (Directory.Exists(@".\devraw\video") == false)
                {
                    Directory.CreateDirectory(@".\devraw\video");
                }

                // Here we extract it
                string strPath = @".\devraw\video\startup.bik";
                if (File.Exists(strPath))
                {
                    File.Delete(strPath);
                }

                Assembly assembly = Assembly.GetExecutingAssembly();
                Stream input = assembly.GetManifestResourceStream("TeknoMW3.tekntup.bik");
                FileStream output = File.Open(strPath, FileMode.CreateNew);
                this.CopyStream(input, output);
                input.Dispose();
                output.Dispose();
            }

            if (File.Exists("teknogods.ini") == false)
            {
                MessageBox.Show(
                    "It seems that this is your first time running our loader, you must first set your nickname.", 
                    "Information", 
                    MessageBoxButton.OK, 
                    MessageBoxImage.Information);
                var settings = new Settings();
                settings.ShowDialog();
            }
            else
            {
                try
                {
                    if (File.Exists("teknogods.ini"))
                    {
                        var parser = new IniParser("teknogods.ini");
                        string name = parser.GetSetting("Settings", "Name");
                        string id = parser.GetSetting("Settings", "ID");
                        if (id == "/")
                        {
                            File.Delete("teknogods.ini");
                            MessageBox.Show(
                                "It seems that you have malformed SteamID because of bug in 1.2 version, you are required to refill info.", 
                                "Information", 
                                MessageBoxButton.OK, 
                                MessageBoxImage.Information);
                            var settings = new Settings();
                            settings.ShowDialog();
                        }

                        if (string.IsNullOrEmpty(name))
                        {
                            File.Delete("teknogods.ini");
                            MessageBox.Show(
                                "It seems that this is your first time running our loader, you must first set your nickname.", 
                                "Information", 
                                MessageBoxButton.OK, 
                                MessageBoxImage.Information);
                            var settings = new Settings();
                            settings.ShowDialog();
                        }
                    }
                }
                catch (Exception)
                {
                    File.Delete("teknogods.ini");
                    MessageBox.Show(
                        "It seems that this is your first time running our loader, you must first set your nickname.", 
                        "Information", 
                        MessageBoxButton.OK, 
                        MessageBoxImage.Information);
                    var settings = new Settings();
                    settings.ShowDialog();
                }
            }

            this.IpBox.Text = Properties.Settings.Default.IP.Replace(",", ".");
            this.PortBox.Text = Properties.Settings.Default.Port;
            if (string.IsNullOrEmpty(this.PortBox.Text))
            {
                this.PortBox.Text = "27016";
            }

            if (string.IsNullOrEmpty(this.IpBox.Text))
            {
                this.IpBox.Text = "127.0.0.1";
            }

            var thread = new Thread(CheckNewVersion);
            thread.Start();

            this.FetchNews();
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: Drakulix/TeknoMW3
 /// <summary>
 /// The button_ click.
 /// </summary>
 /// <param name="sender">
 /// The sender. 
 /// </param>
 /// <param name="e">
 /// The e. 
 /// </param>
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     var settings = new Settings();
     settings.ShowDialog();
 }
コード例 #3
0
        /// <summary>
        /// The window_ loaded.
        /// </summary>
        /// <param name="sender">
        /// The sender. 
        /// </param>
        /// <param name="e">
        /// The e. 
        /// </param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.Window.Title = "TeknoGods Modern Warfare 3 Offline/LAN "
                                + Assembly.GetExecutingAssembly().GetName().Version;

            #if (!DEBUG)

            if (File.Exists("TeknoMW3.dll") == false)
            {
                MessageBox.Show(
                    "Cannot find TeknoMW3.dll",
                    "Error",
                    MessageBoxButton.OK,
                MessageBoxImage.Error);
                this.Close();
                return;
            }

            if (this.GetMD5HashFromFile("TeknoMW3.dll") != "72703455c07768ace8e7386344d5168f")
            {
                MessageBox.Show(
                "Please extract the TeknoGods TeknoMW3.dll in the game folder",
                "Error",
                MessageBoxButton.OK,
                MessageBoxImage.Error);
                this.Close();
                return;
            }

            #endif

            if (File.Exists("TeknoGods.ini") == false)
            {
                MessageBox.Show(
                    "It seems that this is your first time running our loader, you must first set your nickname.",
                    "Information",
                    MessageBoxButton.OK,
                    MessageBoxImage.Information);
                var settings = new Settings();
                settings.ShowDialog();
            }
            else
            {
                try
                {
                    if (File.Exists("TeknoGods.ini"))
                    {
                        var parser = new IniParser("TeknoGods.ini");
                        string name = parser.GetSetting("Settings", "Name");
                        string id = parser.GetSetting("Settings", "ID");
                        if (id == "/")
                        {
                            File.Delete("TeknoGods.ini");
                            MessageBox.Show(
                                "It seems that you have malformed SteamID because of bug in 1.2 version, you are required to refill info.",
                                "Information",
                                MessageBoxButton.OK,
                                MessageBoxImage.Information);
                            var settings = new Settings();
                            settings.ShowDialog();
                        }

                        if (string.IsNullOrEmpty(name))
                        {
                            File.Delete("TeknoGods.ini");
                            MessageBox.Show(
                                "It seems that this is your first time running our loader, you must first set your nickname.",
                                "Information",
                                MessageBoxButton.OK,
                                MessageBoxImage.Information);
                            var settings = new Settings();
                            settings.ShowDialog();
                        }
                    }
                }
                catch (Exception)
                {
                    File.Delete("TeknoGods.ini");
                    MessageBox.Show(
                        "It seems that this is your first time running our loader, you must first set your nickname.",
                        "Information",
                        MessageBoxButton.OK,
                        MessageBoxImage.Information);
                    var settings = new Settings();
                    settings.ShowDialog();
                }
            }

            this.IpBox.Text = Properties.Settings.Default.IP.Replace(",", ".");
            this.PortBox.Text = Properties.Settings.Default.Port;
            if (string.IsNullOrEmpty(this.PortBox.Text))
            {
                this.PortBox.Text = "27016";
            }

            if (string.IsNullOrEmpty(this.IpBox.Text))
            {
                this.IpBox.Text = "127.0.0.1";
            }
        }