Add Network Settings

This commit is contained in:
Wojciech Figat
2022-09-03 12:54:37 +02:00
parent 569808af6d
commit 9ad4665270
7 changed files with 73 additions and 0 deletions

View File

@@ -529,6 +529,7 @@ namespace FlaxEditor
GameSettings.Save(new LayersAndTagsSettings());
GameSettings.Save(new InputSettings());
GameSettings.Save(new GraphicsSettings());
GameSettings.Save(new NetworkSettings());
GameSettings.Save(new NavigationSettings());
GameSettings.Save(new LocalizationSettings());
GameSettings.Save(new BuildSettings());

View File

@@ -935,6 +935,7 @@ namespace FlaxEditor.Modules
Proxy.Add(new SettingsProxy(typeof(LayersAndTagsSettings), Editor.Instance.Icons.LayersTagsSettings128));
Proxy.Add(new SettingsProxy(typeof(PhysicsSettings), Editor.Instance.Icons.PhysicsSettings128));
Proxy.Add(new SettingsProxy(typeof(GraphicsSettings), Editor.Instance.Icons.GraphicsSettings128));
Proxy.Add(new SettingsProxy(typeof(NetworkSettings), Editor.Instance.Icons.Document128));
Proxy.Add(new SettingsProxy(typeof(NavigationSettings), Editor.Instance.Icons.NavigationSettings128));
Proxy.Add(new SettingsProxy(typeof(LocalizationSettings), Editor.Instance.Icons.LocalizationSettings128));
Proxy.Add(new SettingsProxy(typeof(AudioSettings), Editor.Instance.Icons.AudioSettings128));

View File

@@ -400,6 +400,7 @@ namespace FlaxEditor.Modules
{ "FlaxEditor.Content.Settings.BuildSettings", "Settings" },
{ "FlaxEditor.Content.Settings.GameSettings", "Settings" },
{ "FlaxEditor.Content.Settings.GraphicsSettings", "Settings" },
{ "FlaxEditor.Content.Settings.NetworkSettings", "Settings" },
{ "FlaxEditor.Content.Settings.InputSettings", "Settings" },
{ "FlaxEditor.Content.Settings.LayersAndTagsSettings", "Settings" },
{ "FlaxEditor.Content.Settings.NavigationSettings", "Settings" },

View File

@@ -12,6 +12,7 @@
#include "BuildSettings.h"
#include "Engine/Input/InputSettings.h"
#include "Engine/Audio/AudioSettings.h"
#include "Engine/Networking/NetworkSettings.h"
#include "Engine/Navigation/NavigationSettings.h"
#include "Engine/Localization/LocalizationSettings.h"
#include "Engine/Content/Content.h"
@@ -41,6 +42,7 @@ public:
IMPLEMENT_ENGINE_SETTINGS_GETTER(BuildSettings, GameCooking);
IMPLEMENT_ENGINE_SETTINGS_GETTER(GraphicsSettings, Graphics);
IMPLEMENT_ENGINE_SETTINGS_GETTER(NetworkSettings, Network);
IMPLEMENT_ENGINE_SETTINGS_GETTER(LayersAndTagsSettings, LayersAndTags);
IMPLEMENT_ENGINE_SETTINGS_GETTER(TimeSettings, Time);
IMPLEMENT_ENGINE_SETTINGS_GETTER(AudioSettings, Audio);
@@ -146,6 +148,7 @@ bool GameSettings::Load()
PRELOAD_SETTINGS(Physics);
PRELOAD_SETTINGS(Input);
PRELOAD_SETTINGS(Graphics);
PRELOAD_SETTINGS(Network);
PRELOAD_SETTINGS(Navigation);
PRELOAD_SETTINGS(Localization);
PRELOAD_SETTINGS(GameCooking);
@@ -180,6 +183,7 @@ void GameSettings::Apply()
APPLY_SETTINGS(StreamingSettings);
APPLY_SETTINGS(InputSettings);
APPLY_SETTINGS(GraphicsSettings);
APPLY_SETTINGS(NetworkSettings);
APPLY_SETTINGS(NavigationSettings);
APPLY_SETTINGS(LocalizationSettings);
APPLY_SETTINGS(BuildSettings);
@@ -220,6 +224,7 @@ void GameSettings::Deserialize(DeserializeStream& stream, ISerializeModifier* mo
DESERIALIZE(Physics);
DESERIALIZE(Input);
DESERIALIZE(Graphics);
DESERIALIZE(Network);
DESERIALIZE(Navigation);
DESERIALIZE(Localization);
DESERIALIZE(GameCooking);

View File

@@ -75,6 +75,12 @@ namespace FlaxEditor.Content.Settings
[EditorOrder(1040), EditorDisplay("Other Settings"), AssetReference(typeof(GraphicsSettings), true), Tooltip("Reference to Graphics Settings asset")]
public JsonAsset Graphics;
/// <summary>
/// Reference to <see cref="NetworkSettings"/> asset.
/// </summary>
[EditorOrder(1043), EditorDisplay("Other Settings"), AssetReference(typeof(NetworkSettings), true), Tooltip("Reference to Network Settings asset")]
public JsonAsset Network;
/// <summary>
/// Reference to <see cref="NavigationSettings"/> asset.
/// </summary>
@@ -255,6 +261,8 @@ namespace FlaxEditor.Content.Settings
return LoadAsset<PhysicsSettings>(gameSettings.Physics) as T;
if (type == typeof(GraphicsSettings))
return LoadAsset<GraphicsSettings>(gameSettings.Graphics) as T;
if (type == typeof(NetworkSettings))
return LoadAsset<NetworkSettings>(gameSettings.Network) as T;
if (type == typeof(NavigationSettings))
return LoadAsset<NavigationSettings>(gameSettings.Navigation) as T;
if (type == typeof(LocalizationSettings))
@@ -373,6 +381,8 @@ namespace FlaxEditor.Content.Settings
return SaveAsset(gameSettings, ref gameSettings.Physics, obj);
if (type == typeof(GraphicsSettings))
return SaveAsset(gameSettings, ref gameSettings.Graphics, obj);
if (type == typeof(NetworkSettings))
return SaveAsset(gameSettings, ref gameSettings.Network, obj);
if (type == typeof(NavigationSettings))
return SaveAsset(gameSettings, ref gameSettings.Navigation, obj);
if (type == typeof(LocalizationSettings))

View File

@@ -67,6 +67,7 @@ public:
Guid Physics;
Guid Input;
Guid Graphics;
Guid Network;
Guid Navigation;
Guid Localization;
Guid GameCooking;

View File

@@ -0,0 +1,54 @@
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Core/Types/BaseTypes.h"
#include "Engine/Core/Config/Settings.h"
/// <summary>
/// Network settings container.
/// </summary>
API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API NetworkSettings : public SettingsBase
{
API_AUTO_SERIALIZATION();
DECLARE_SCRIPTING_TYPE_MINIMAL(NetworkSettings);
public:
/// <summary>
/// Maximum amount of active network clients in a game session. Used by server or host to limit amount of players and spectators.
/// </summary>
API_FIELD(Attributes="EditorOrder(0), EditorDisplay(\"General\")")
int32 MaxClients = 100;
/// <summary>
/// The target amount of the network system updates per second. Higher values provide better network synchronization (eg. 60 for shooters), lower values reduce network usage and performance impact (eg. 30 for strategy games). Can be used to tweak networking performance impact on game. Cannot be higher that UpdateFPS (from Time Settings). Use 0 to run every game update.
/// </summary>
API_FIELD(Attributes="EditorOrder(100), Limit(0, 1000), EditorDisplay(\"General\", \"Network FPS\")")
float NetworkFPS = 60.0f;
/// <summary>
/// Address of the server (server/host always runs on localhost). Only IPv4 is supported.
/// </summary>
API_FIELD(Attributes="EditorOrder(1000), EditorDisplay(\"Transport\")")
String Address = TEXT("127.0.0.1");
/// <summary>
/// The port for the network peer.
/// </summary>
API_FIELD(Attributes="EditorOrder(1010), EditorDisplay(\"Transport\")")
uint16 Port = 7777;
/// <summary>
/// The type of the network driver (implements INetworkDriver) that will be used to create, manage, send and receive messages over the network.
/// </summary>
API_FIELD(Attributes="EditorOrder(1100), EditorDisplay(\"Transport\"), TypeReference(typeof(INetworkDriver)), CustomEditorAlias(\"FlaxEditor.CustomEditors.Editors.TypeNameEditor\")")
StringAnsi NetworkDriver = "FlaxEngine.Networking.ENetDriver";
public:
/// <summary>
/// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use.
/// </summary>
static NetworkSettings* Get();
// [SettingsBase]
void Apply() override;
};