Пример #1
0
        // RUN
        public static void Run(ToolkitType type)
        {
            Upgrade();

            // Initialize XWT
            Application.Initialize(type);

            Icon = Image.CreateMultiSizeIcon(new[] { Resources.GetImage("4P.png"), Resources.GetImage("4P 16.png") });

            // Init scripting async
            Script.InitializeScripting();

            // count users
            string fplugLocal = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ".4plug");

            try
            {
                string idPath = Path.Combine(fplugLocal, "id10");
                if (!Directory.Exists(fplugLocal))
                    Directory.CreateDirectory(fplugLocal);

                string id = null;
                if (File.Exists(idPath))
                {
                    try
                    {
                        id = File.ReadAllText(idPath);
                        if (id.Length != 10)
                            id = null;
                    }
                    catch { }
                }
                if (id == null)
                {
                    id = getRandomID10();
                    File.WriteAllText(idPath, id);
                    new WebClient().DownloadData("http://164.132.197.197/four/4plug/registeruser.php?id10=" + id);
                }
            }
            catch { }

            // Check if started for the first time
            FirstTime = !File.Exists("config.xml");

            if (FirstTime)
            {
                XSettings.Load("config.xml");
                if (Directory.Exists(@"C:\Program Files\Steam\steamapps\common"))
                    DefaultSteamLibrary = @"C:\Program Files\Steam\steamapps\common";
                else if (Directory.Exists(@"C:\Program Files (x86)\Steam\steamapps\common"))
                    DefaultSteamLibrary = @"C:\Program Files (x86)\Steam\steamapps\common";

                new SplashWindow().Run();
            }

            // testing
            SettingsWindow w;
            if (Directory.Exists("C:\\"))
                w = new SettingsWindow(@"C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\custom\7HUD-master\mod.xml", @"C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\custom\7HUD-master", true);
            else
                w = new SettingsWindow(@"/home/daniel/Desktop/7HUD-master/mod.xml", @"/home/daniel/Desktop/7HUD-master/", true);

            // Show main window
            //using (MainWindow w = MainWindow = new MainWindow())
            {

                XSettings.Load("config.xml");
                w.Closed += (s, e) =>
                {
                    Application.Exit();
                };

                //if (Games.Count == 0)
                //{
                //    var w = new AddGamesWindow();
                //    w.Run();
                //}

                //SetCurrentGame(Games[Math.Min(Math.Max((int)XSettings.Games.Attribute("selectedindex"), Games.Count - 1), 0)]);

                w.Show();

                Application.Run();
            }

            // Save settings
            XSettings.Save();

            // Apply updates
            if (ApplyUpdate)
            {
                File.Copy("4PlugUpdate.exe", "_update.exe");
                Process.Start("_update.exe");
            }

            Application.Dispose();
        }
Пример #2
0
 public override void ShowSettings()
 {
     if (SettingsActive)
     {
         if (settingsWindow != null)
             settingsWindow.Present();
     }
     else
     {
         settingsWindow = new FPlug.Options.SettingsWindow(System.IO.Path.Combine(Path, pluginDotXmlPath), Path, true);
         MainWindow.OpenWindows.Add(settingsWindow);
         SettingsActive = true;
         settingsWindow.Closed += (s, e) => { SettingsActive = false; MainWindow.OpenWindows.Remove(settingsWindow); };
         settingsWindow.Show();
     }
 }