Beispiel #1
0
        public void UnloadModules()
        {
            this.Loadables.OnModsUnload();

            this.Loadables                  = null;
            this.ReflectionHelpers          = null;
            this.PacketProtocolMngr         = null;
            this.ExceptionMngr              = null;
            this.Timers                     = null;
            this.LogHelpers                 = null;
            this.ModFeaturesHelpers         = null;
            this.BuffHelpers                = null;
            this.NetHelpers                 = null;
            this.NPCAttributeHelpers        = null;
            this.ProjectileAttributeHelpers = null;
            this.BuffIdentityHelpers        = null;
            this.NPCBannerHelpers           = null;
            this.RecipeFinderHelpers        = null;
            this.RecipeGroupHelpers         = null;
            this.PlayerHooks                = null;
            this.LoadHelpers                = null;
            this.GetModInfo                 = null;
            this.GetModTags                 = null;
            this.WorldStateHelpers          = null;
            this.ModLock                    = null;
            this.EntityGroups               = null;
            this.AnimatedColors             = null;
            this.AnimatedTextures           = null;
            this.PlayerMessages             = null;
            this.Inbox                 = null;
            this.ControlPanel          = null;
            this.MenuItemMngr          = null;
            this.MenuContextMngr       = null;
            this.MusicHelpers          = null;
            this.PlayerIdentityHelpers = null;
            this.LoadHooks             = null;
            this.CustomLoadHooks       = null;
            this.DataStore             = null;
            this.CustomHotkeys         = null;
            this.XnaHelpers            = null;
            this.Server                = null;
            //this.PlayerDataMngr = null;
            this.SupportInfo          = null;
            this.RecipeHack           = null;
            this.ModListHelpers       = null;
            this.ItemAttributeHelpers = null;
            this.WorldTimeHooks       = null;

            this.ControlPanelHotkey = null;
            this.DataDumpHotkey     = null;
        }
        public void UnloadOuter()
        {
            this.ReflectionHelpers         = null;
            this.PacketProtocolMngr        = null;
            this.ExceptionMngr             = null;
            this.Timers                    = null;
            this.ConfigJson                = null;
            this.LogHelpers                = null;
            this.ModFeaturesHelpers        = null;
            this.BuffHelpers               = null;
            this.NetHelpers                = null;
            this.ItemIdentityHelpers       = null;
            this.NPCIdentityHelpers        = null;
            this.ProjectileIdentityHelpers = null;
            this.BuffIdentityHelpers       = null;
            this.NPCBannerHelpers          = null;
            this.RecipeIdentityHelpers     = null;
            this.RecipeGroupHelpers        = null;
            this.PlayerHooks               = null;
            this.LoadHelpers               = null;
            this.GetModInfo                = null;
            this.GetModTags                = null;
            this.WorldStateHelpers         = null;
            this.ModLock                   = null;
            this.EntityGroups              = null;
            this.AnimatedColors            = null;
            this.PlayerMessages            = null;
            this.Inbox                 = null;
            this.ControlPanel          = null;
            this.MenuItemMngr          = null;
            this.MenuContextMngr       = null;
            this.MusicHelpers          = null;
            this.PlayerIdentityHelpers = null;
            this.CustomEntMngr         = null;
            this.Promises              = null;
            this.DataStore             = null;
            this.CustomHotkeys         = null;
            this.XnaHelpers            = null;
            this.ServerInfo            = null;
            //this.PlayerDataMngr = null;
            this.SupportInfo    = null;
            this.RecipeHack     = null;
            this.ModListHelpers = null;

            this.ControlPanelHotkey = null;
            this.DataDumpHotkey     = null;
        }
Beispiel #3
0
        private void LoadModules()
        {
            this.Loadables.OnModsLoad();

            this.ReflectionHelpers = new ReflectionHelpers();
            this.DataStore         = new DataStore();
            this.LoadHooks         = new LoadHooks();
            this.CustomLoadHooks   = new CustomLoadHooks();
            this.LoadHelpers       = new LoadHelpers();

            this.Timers             = new Timers();
            this.LogHelpers         = new LogHelpers();
            this.ModFeaturesHelpers = new ModFeaturesHelpers();
            this.PacketProtocolMngr = new PacketProtocolManager();

            this.BuffHelpers                = new BuffHelpers();
            this.NetHelpers                 = new NetPlayHelpers();
            this.NPCAttributeHelpers        = new NPCAttributeHelpers();
            this.ProjectileAttributeHelpers = new ProjectileAttributeHelpers();
            this.BuffIdentityHelpers        = new BuffAttributesHelpers();
            this.NPCBannerHelpers           = new NPCBannerHelpers();
            this.RecipeFinderHelpers        = new RecipeFinderHelpers();
            this.RecipeGroupHelpers         = new RecipeGroupHelpers();
            this.PlayerHooks                = new ExtendedPlayerHooks();
            this.WorldTimeHooks             = new WorldTimeHooks();
            this.WorldStateHelpers          = new WorldStateHelpers();
            this.ControlPanel               = new UIControlPanel();
            this.ModLock               = new ModLockService();
            this.EntityGroups          = new EntityGroups();
            this.PlayerMessages        = new PlayerMessages();
            this.Inbox                 = new InboxControl();
            this.GetModInfo            = new GetModInfo();
            this.GetModTags            = new GetModTags();
            this.MenuItemMngr          = new MenuItemManager();
            this.MenuContextMngr       = new MenuContextServiceManager();
            this.MusicHelpers          = new MusicHelpers();
            this.PlayerIdentityHelpers = new PlayerIdentityHelpers();
            this.CustomHotkeys         = new CustomHotkeys();
            this.XnaHelpers            = new XNAHelpers();
            this.Server                = new Server();
            //this.PlayerDataMngr = new PlayerDataManager();
            this.SupportInfo          = new SupportInfoDisplay();
            this.RecipeHack           = new RecipeHack();
            this.ModListHelpers       = new ModListHelpers();
            this.ItemAttributeHelpers = new ItemAttributeHelpers();
        }
Beispiel #4
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (File.Exists(Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameOldServersJSON))))
                {
                    File.Move(
                        Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameOldServersJSON)),
                        Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameNewServersJSON)));
                }
                else if (!File.Exists(
                             Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameNewServersJSON))))
                {
                    try
                    {
                        File.WriteAllText(
                            Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameNewServersJSON)), "[]");
                    }
                    catch (Exception Error)
                    {
                        LogToFileAddons.OpenLog("JSON SERVER FILE", null, Error, null, true);
                    }
                }
            }
            catch (Exception Error)
            {
                LogToFileAddons.OpenLog("JSON SERVER FILE", null, Error, null, true);
            }

            Error.Visible = false;
            this.Refresh();
            if (IsNullOrWhiteSpace(ServerAddress.Text) || IsNullOrWhiteSpace(Strings.Encode(ServerName.Text)))
            {
                if (IsNullOrWhiteSpace(ServerAddress.Text))
                {
                    Error.Text = "Fix Empty IP";
                    DrawErrorAroundTextBox(ServerAddress);
                }
                else
                {
                    Error.Text = "Fix Empty Name";
                    DrawErrorAroundTextBox(ServerName);
                }

                Error.Visible = true;
                return;
            }

            if (Error.Visible)
            {
                Error.Visible = false;
            }

            bool CorrectFormat = Uri.TryCreate(ServerAddress.Text, UriKind.Absolute, out Uri Result) && (Result.Scheme == Uri.UriSchemeHttp || Result.Scheme == Uri.UriSchemeHttps);

            string FormattedURL;

            if (!CorrectFormat)
            {
                DrawErrorAroundTextBox(ServerAddress);
                return;
            }
            else
            {
                FormattedURL = Result.ToString();
            }

            ButtonControls(false);

            try
            {
                string ServerInfomationJSON = Empty;
                try
                {
                    Uri StringToUri = new Uri(FormattedURL + "/GetServerInformation");
                    ServicePointManager.FindServicePoint(StringToUri).ConnectionLeaseTimeout = (int)TimeSpan.FromMinutes(1).TotalMilliseconds;
                    var Client = new WebClient
                    {
                        Encoding = Encoding.UTF8
                    };

                    if (!WebCalls.Alternative())
                    {
                        Client = new WebClientWithTimeout {
                            Encoding = Encoding.UTF8
                        };
                    }
                    else
                    {
                        Client.Headers.Add("user-agent", "SBRW Launcher " +
                                           Application.ProductVersion + " (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)");
                    }

                    try
                    {
                        ServerInfomationJSON = Client.DownloadString(StringToUri);
                    }
                    catch (Exception Error)
                    {
                        string LogMessage = "Add Server Check Encountered an Error:";
                        LogToFileAddons.OpenLog("Add Server", LogMessage, Error, null, false);
                    }
                    finally
                    {
                        if (Client != null)
                        {
                            Client.Dispose();
                        }
                    }
                }
                catch (Exception Error)
                {
                    string LogMessage = "Add Server Check Encountered an Error:";
                    LogToFileAddons.OpenLog("Add Server", LogMessage, Error, null, false);
                }

                if (IsNullOrWhiteSpace(ServerInfomationJSON))
                {
                    ButtonControls(true);
                    return;
                }
                else if (!IsJSONValid.ValidJson(ServerInfomationJSON))
                {
                    Error.Text = "Unstable Connection";
                    DrawErrorAroundTextBox(ServerAddress);
                    Error.Visible = true;
                    ButtonControls(true);
                    ServerInfomationJSON = null;
                    return;
                }
                else
                {
                    GetServerInformation ServerInformationData = null;

                    try
                    {
                        ServerInformationData = JsonConvert.DeserializeObject <GetServerInformation>(ServerInfomationJSON);
                    }
                    catch (Exception Error)
                    {
                        string LogMessage = "Add Server Get Information Encountered an Error:";
                        LogToFileAddons.OpenLog("Add Server", LogMessage, Error, null, false);
                    }

                    if (ServerInformationData == null)
                    {
                        ButtonControls(true);
                        ServerInfomationJSON = null;
                        return;
                    }
                    else
                    {
                        string ServerID     = Empty;
                        Uri    newModNetUri = new Uri(FormattedURL + "/Modding/GetModInfo");
                        ServicePointManager.FindServicePoint(newModNetUri).ConnectionLeaseTimeout = (int)TimeSpan.FromMinutes(1).TotalMilliseconds;
                        var Client = new WebClient
                        {
                            Encoding = Encoding.UTF8
                        };

                        if (!WebCalls.Alternative())
                        {
                            Client = new WebClientWithTimeout {
                                Encoding = Encoding.UTF8
                            };
                        }
                        else
                        {
                            Client.Headers.Add("user-agent", "SBRW Launcher " +
                                               Application.ProductVersion + " (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)");
                        }

                        try
                        {
                            GetModInfo ServerGetInfo = JsonConvert.DeserializeObject <GetModInfo>(Client.DownloadString(newModNetUri));
                            ServerID = IsNullOrWhiteSpace(ServerGetInfo.serverID) ? Result.Host : ServerGetInfo.serverID;
                        }
                        catch (Exception Error)
                        {
                            LogToFileAddons.OpenLog("Add Server", null, Error, null, true);
                            ServerID = Result.Host;
                        }
                        finally
                        {
                            if (Client != null)
                            {
                                Client.Dispose();
                            }
                        }

                        try
                        {
                            StreamReader sr         = new StreamReader(Locations.LauncherCustomServers);
                            String       oldcontent = sr.ReadToEnd();
                            sr.Close();

                            if (IsNullOrWhiteSpace(oldcontent))
                            {
                                oldcontent = "[]";
                            }

                            var Servers = JsonConvert.DeserializeObject <List <ServerList> >(oldcontent);

                            Servers.Add(new ServerList
                            {
                                Name      = Strings.Encode(ServerName.Text),
                                IPAddress = FormattedURL,
                                IsSpecial = false,
                                ID        = ServerID,
                                Category  = IsNullOrWhiteSpace(Strings.Encode(ServerCategory.Text)) ? "Custom" : Strings.Encode(ServerCategory.Text)
                            });

                            File.WriteAllText(Locations.LauncherCustomServers, JsonConvert.SerializeObject(Servers));

                            MessageBox.Show(null, "The New server will be added on the next start of the Launcher.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch (Exception Error)
                        {
                            string LogMessage = "Failed to Add New Server:";
                            LogToFileAddons.OpenLog("Add Server", LogMessage, Error, null, false);
                            ButtonControls(true);
                            return;
                        }
                        finally
                        {
                            if (ServerID != null)
                            {
                                ServerID = null;
                            }

                            if (ServerInfomationJSON != null)
                            {
                                ServerInfomationJSON = null;
                            }
                        }

                        CancelButton_Click(sender, e);
                    }
                }
            }
            catch
            {
                DrawErrorAroundTextBox(ServerAddress);
                ButtonControls(true);
            }
        }