public static ClientOptions getClientOptions()
 {
     if (co == null)
     {
         try
         {
             co = ClientOptions.Load("./conf/gmp.xml");
         }
         catch (Exception ex)
         {
             co = new ClientOptions();
             co.Save("./conf/gmp.xml");
         }
     }
     return(co);
 }
        public static void StartGothic(ClientOptions co, String nickname, String ip, ushort port, String serverpassword, int logLevel, int maxFPS, bool startWindowed)
        {
            if (!Datei2MD5("../Gothic2.exe", "3c436bd199caaaa64e9736e3cc1c9c32"))// &&  !Datei2MD5("../Gothic2.exe", "b75d03422af54286f1f4ed846b8fd4b8")
            {
                throw new Exception("Wrong Gothic Version. Gothic2.exe needs a MD5 hash of 3c436bd199caaaa64e9736e3cc1c9c32");
            }

            String vdfsFile = "[VDFS]\r\n";

            vdfsFile += "Data\\*.VDF\r\n";
            vdfsFile += "Data\\*.MOD\r\n";
            vdfsFile += "System\\UntoldChapter\\Data\\*.VDF\r\n";
            vdfsFile += "System\\UntoldChapter\\Downloads\\" + ip + "_" + port + "\\*.VDF\r\n";
            vdfsFile += "[END]\r\n";


            if (System.IO.File.Exists("../../vdfs.cfg"))
            {
                System.IO.File.Delete("../../vdfs.cfg");
            }
            System.IO.File.WriteAllText("../../vdfs.cfg", vdfsFile);



            if (co == null)
            {
                co = getClientOptions();
            }

            if (serverpassword == null)
            {
                serverpassword = "";
            }


            co.name     = nickname;
            co.ip       = ip;
            co.port     = port;
            co.password = serverpassword;

            co.loglevel      = logLevel;
            co.fps           = maxFPS;
            co.startWindowed = startWindowed;
            co.Save("./conf/gmp.xml");


            String dll       = "UntoldChapter/DLL/NetInject.dll";
            String RakNetDLL = "UntoldChapter/DLL/RakNet.dll";


            if (!System.IO.File.Exists("../" + dll))
            {
                throw new FileNotFoundException(dll + " nicht gefunden");
            }
            if (!System.IO.File.Exists("../" + RakNetDLL))
            {
                throw new FileNotFoundException(RakNetDLL + " nicht gefunden");
            }

            System.Diagnostics.ProcessStartInfo psi = null;
            //zSpy starten
            if (logLevel != -1 && System.IO.File.Exists("..\\..\\_work\\tools\\zSpy\\zSpy.exe"))
            {
                psi = new System.Diagnostics.ProcessStartInfo();
                psi.UseShellExecute  = true;
                psi.WorkingDirectory = Environment.CurrentDirectory + "\\Log";

                psi.FileName = "..\\..\\..\\_work\\tools\\zSpy\\zSpy.exe";
                WinApi.Process.Start(psi);
            }


            //Starten...
            psi = new System.Diagnostics.ProcessStartInfo();
            psi.WorkingDirectory = Path.GetDirectoryName(Environment.CurrentDirectory);
            psi.Arguments        = "-nomenu";

            if (startWindowed)
            {
                psi.Arguments += " -zwindow";
            }

            if (logLevel != -1)
            {
                psi.Arguments += " -zlog:" + logLevel + ",s";
            }

            if (maxFPS > 9 && maxFPS <= 999)
            {
                psi.Arguments += " -zMaxFrameRate:" + maxFPS;
            }


            //Weitere:  -ztexconvert  -zautoconvertdata  -zconvertall  -vdfs:physicalfirst

            psi.FileName = "Gothic2.exe";
            WinApi.Process process = WinApi.Process.Start(psi);

            if (process.LoadLibary(dll) == IntPtr.Zero)
            {
                Error.GetLastError();
            }
        }
Esempio n. 3
0
        public override void HandleInput(InputState input)
        {
            if (input.IsNewKeyPress(Keys.Up))
            {
                if (!ResolutionActive)
                {
                    SelectedEntry--;

                    if (SelectedEntry < 0)
                    {
                        SelectedEntry = MenuEntries.Count - 1;
                    }
                }
                else if (ResolutionActive)
                {
                    ResolutionSelectedEntry--;

                    if (ResolutionSelectedEntry < 0)
                    {
                        ResolutionSelectedEntry = ResolutionEntries.Count - 1;
                    }
                }
            }
            if (input.IsNewKeyPress(Keys.Down))
            {
                if (!ResolutionActive)
                {
                    SelectedEntry++;

                    if (SelectedEntry >= MenuEntries.Count)
                    {
                        SelectedEntry = 0;
                    }
                }
                else if (ResolutionActive)
                {
                    ResolutionSelectedEntry++;

                    if (ResolutionSelectedEntry >= ResolutionEntries.Count)
                    {
                        ResolutionSelectedEntry = 0;
                    }
                }
            }
            if (input.IsNewKeyPress(Keys.Enter))
            {
                switch (SelectedEntry)
                {
                case (int)OptionsEntry.Resolution:
                    if (ResolutionActive)
                    {
                        Resolution res = Resolutions[ResolutionSelectedEntry];
                        this.ScreenManager.Graphics.PreferredBackBufferWidth  = res.Width;
                        this.ScreenManager.Graphics.PreferredBackBufferHeight = res.Height;
                        ClientOptions.SetResolution(res.Height, res.Width);

                        ResolutionChanged = true;
                        ResolutionActive  = false;
                    }
                    else if (!ResolutionActive)
                    {
                        ResolutionActive = true;
                    }
                    break;

                case (int)OptionsEntry.Fullscreen:
                    if (ClientOptions.Fullscreen)
                    {
                        this.ScreenManager.Graphics.ToggleFullScreen();
                        ClientOptions.SetFullscreen(false);
                    }
                    else
                    {
                        this.ScreenManager.Graphics.ToggleFullScreen();
                        ClientOptions.SetFullscreen(true);
                    }
                    FullscreenChanged = true;
                    break;

                case (int)OptionsEntry.Exit:
                    ClientOptions.Save();     // save client options
                    ScreenManager.RemoveScreen(this);
                    ParentScreen.CurrentScreenState = ScreenState.Active;
                    break;
                }
            }
            if (input.IsNewKeyPress(Keys.Escape))
            {
                if (ResolutionActive)
                {
                    ResolutionActive = false;
                }
                else
                {
                    ClientOptions.Save();
                    ScreenManager.RemoveScreen(this);
                    ParentScreen.CurrentScreenState = ScreenState.Active;
                }
            }
        }