/// <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";
            }
        }
Exemple #2
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 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();
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Settings"/> class.
        /// </summary>
        public Settings()
        {
            this.InitializeComponent();
            txtName.Focus();
            try
            {
                if (File.Exists("teknogods.ini") == true)
                {
                    var parser = new IniParser("teknogods.ini");
                    txtName.Text = parser.GetSetting("Settings", "Name");
                    this.steamid = parser.GetSetting("Settings", "ID");
                    this.txtFov.Text = parser.GetSetting("Settings", "FOV");
                    try
                    {
                        var fov = Convert.ToInt32(txtFov.Text);

                        if (fov > 90 || fov < 65)
                        {
                            txtFov.Text = "65";
                            return;
                        }

                        txtFov.Text = fov.ToString();
                    }
                    catch (Exception)
                    {
                        txtFov.Text = "65";
                    }
                }
                else
                {
                    var files = Directory.GetFiles(".\\players2\\", "*.stat");
                    for (var i = 0; i < files.Length; i++)
                    {
                        files[i] = files[i].Replace(".\\players2\\", string.Empty);
                    }

                    var ids = new List<string>();
                    for (var i = 0; i < files.Length; i++)
                    {
                        if (files[i].StartsWith("iw5") == true)
                        {
                            var parts = files[i].Split("_".ToCharArray());
                            if (parts.Length == 5)
                            {
                                ids.Add(parts[4].Substring(7, 8));
                            }
                        }
                    }

                    if (ids.Count < 1)
                    {
                        return;
                    }

                    var counts = ids.GroupBy(x => x).ToDictionary(g => g.Key, g => g.Count());
                    foreach (var pair in counts)
                    {
                        this.steamid = pair.Key;
                        break;
                    }
                    
                }
            }
            catch (Exception)
            {
                File.Delete("teknogods.ini");
            }
            // Insert code required on object creation below this point.
        }