diff --git a/Robust.Client.Godot/.gitignore b/Robust.Client.Godot/.gitignore deleted file mode 100644 index 8abdb2d7e..000000000 --- a/Robust.Client.Godot/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.import -.mono -/Engine -/Content diff --git a/Robust.Client.Godot/Art/background.png b/Robust.Client.Godot/Art/background.png deleted file mode 100755 index cab3aa7e2..000000000 Binary files a/Robust.Client.Godot/Art/background.png and /dev/null differ diff --git a/Robust.Client.Godot/Art/background.png.import b/Robust.Client.Godot/Art/background.png.import deleted file mode 100644 index e55ae5770..000000000 --- a/Robust.Client.Godot/Art/background.png.import +++ /dev/null @@ -1,29 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/background.png-a03655cdb9c7980d756b35ecf60c4ef1.stex" - -[deps] - -source_file="res://Art/background.png" -dest_files=[ "res://.import/background.png-a03655cdb9c7980d756b35ecf60c4ef1.stex" ] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/Robust.Client.Godot/Art/bootsplash.png b/Robust.Client.Godot/Art/bootsplash.png deleted file mode 100644 index 73c75e4bd..000000000 Binary files a/Robust.Client.Godot/Art/bootsplash.png and /dev/null differ diff --git a/Robust.Client.Godot/Art/bootsplash.png.import b/Robust.Client.Godot/Art/bootsplash.png.import deleted file mode 100644 index c106ed7fb..000000000 --- a/Robust.Client.Godot/Art/bootsplash.png.import +++ /dev/null @@ -1,29 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/bootsplash.png-edab0c323b941bd4e8220bfb7e423146.stex" - -[deps] - -source_file="res://Art/bootsplash.png" -dest_files=[ "res://.import/bootsplash.png-edab0c323b941bd4e8220bfb7e423146.stex" ] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=true -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/Robust.Client.Godot/Art/copyright.md b/Robust.Client.Godot/Art/copyright.md deleted file mode 100755 index 5ab2a230b..000000000 --- a/Robust.Client.Godot/Art/copyright.md +++ /dev/null @@ -1,3 +0,0 @@ -* `background.png` a modified version from http://imgarcade.com/16-bit-space-background.html -* `bootsplash.png` is a modified version of the logo on http://spacestation13.com -* `Animal Silence.otf` is [this font](https://www.dafont.com/animal-silence.font). Somebody asked for permission years ago. diff --git a/Robust.Client.Godot/ControlWrap.cs b/Robust.Client.Godot/ControlWrap.cs deleted file mode 100644 index 57ab56e70..000000000 --- a/Robust.Client.Godot/ControlWrap.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Godot; -using System; - -namespace Robust.Client.GodotGlue -{ - /// - /// Wraps a Godot control so we get access to its virtual functions. - /// - public class ControlWrap : Godot.Control - { - public Func GetMinimumSizeOverride { get; set; } - public Func HasPointOverride { get; set; } - public Action DrawOverride { get; set; } - - public override Vector2 _GetMinimumSize() - { - return GetMinimumSizeOverride?.Invoke() ?? new Vector2(); - } - - public override bool HasPoint(Vector2 point) - { - return HasPointOverride?.Invoke(point) ?? false; - } - - public override void _Draw() - { - DrawOverride?.Invoke(); - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - - GetMinimumSizeOverride = null; - HasPointOverride = null; - DrawOverride = null; - } - } -} diff --git a/Robust.Client.Godot/MSBuild/SS14.SolutionSpecific.targets b/Robust.Client.Godot/MSBuild/SS14.SolutionSpecific.targets deleted file mode 100644 index e390f7c7b..000000000 --- a/Robust.Client.Godot/MSBuild/SS14.SolutionSpecific.targets +++ /dev/null @@ -1,10 +0,0 @@ - - - - $(SolutionDir)..\packages\ - Yes - - diff --git a/Robust.Client.Godot/MainScene.tscn b/Robust.Client.Godot/MainScene.tscn deleted file mode 100644 index 34eada999..000000000 --- a/Robust.Client.Godot/MainScene.tscn +++ /dev/null @@ -1,9 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://SS14Loader.cs" type="Script" id=1] - -[node name="MainScene" type="Node" index="0"] - -script = ExtResource( 1 ) - - diff --git a/Robust.Client.Godot/Properties/AssemblyInfo.cs b/Robust.Client.Godot/Properties/AssemblyInfo.cs deleted file mode 100644 index 7d1209de6..000000000 --- a/Robust.Client.Godot/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Reflection; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle("Robust.Client.Godot")] -[assembly: AssemblyDescription("SS14 Client glue code to connect the main client to Godot.")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] diff --git a/Robust.Client.Godot/Robust.Client.Godot.csproj b/Robust.Client.Godot/Robust.Client.Godot.csproj deleted file mode 100644 index 2bb6597ca..000000000 --- a/Robust.Client.Godot/Robust.Client.Godot.csproj +++ /dev/null @@ -1,61 +0,0 @@ - - - - - Debug - AnyCPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB} - Library - .mono\temp\bin\$(Configuration) - Robust.Client.Godot - Robust.Client.Godot - v4.7.1 - .mono\temp\obj - $(BaseIntermediateOutputPath)\$(Configuration) - prompt - 4 - false - 7.2 - - - true - portable - false - DEBUG; - - - portable - true - - - - $(ProjectDir)\.mono\assemblies\GodotSharp.dll - False - - - $(ProjectDir)\..\Dependencies\godot\GodotSharp.dll - False - - - $(ProjectDir)\.mono\assemblies\GodotSharpEditor.dll - False - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Robust.Client.Godot/SS14.Client.Godot.sln b/Robust.Client.Godot/SS14.Client.Godot.sln deleted file mode 100644 index ed1578d9a..000000000 --- a/Robust.Client.Godot/SS14.Client.Godot.sln +++ /dev/null @@ -1,19 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Client.Godot", "Robust.Client.Godot.csproj", "{8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - Tools|Any CPU = Tools|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Release|Any CPU.Build.0 = Release|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|Any CPU.ActiveCfg = Tools|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|Any CPU.Build.0 = Tools|Any CPU - EndGlobalSection -EndGlobal diff --git a/Robust.Client.Godot/SS14Loader.cs b/Robust.Client.Godot/SS14Loader.cs deleted file mode 100644 index d81358468..000000000 --- a/Robust.Client.Godot/SS14Loader.cs +++ /dev/null @@ -1,240 +0,0 @@ -using Godot; -using System; -using System.Reflection; -using System.Collections.Generic; -using Environment = System.Environment; - -// NOT Robust.Client.Godot so you can still use Godot.xxx without a using statement. -namespace Robust.Client.GodotGlue -{ - /// - /// AutoLoad Node that starts the rest of the SS14 Client through . - /// - public class SS14Loader : Node - { - public static SS14Loader Instance { get; private set; } - public bool ShuttingDown { get; private set; } = false; - public Assembly SS14Assembly { get; private set; } - public IReadOnlyList EntryPoints => entryPoints; - private List entryPoints = new List(); - - private bool Started = false; - - public override void _Ready() - { - Instance = this; - CallDeferred(nameof(AnnounceMain)); - } - - public void AnnounceMain() - { - if (Started) - { - return; - } - - // Hahahah fuck you Mono - // Mono's incorrectly versioned bullshit copy of SharpZipLib is prioritized over the correct NuGet version. - // This breaks our shit because they're not compatible. - // This completely bypasses that. - // Good fucking riddance. - // I win. - // Fucking deal with it. - var path = Environment.CurrentDirectory; - Assembly.LoadFile(System.IO.Path.Combine(path, "../bin/Client/ICSharpCode.SharpZipLib.dll")); - - Started = true; - SS14Assembly = Assembly.LoadFrom("../bin/Client/Robust.Client.exe"); - var entryType = typeof(ClientEntryPoint); - foreach (var type in SS14Assembly.GetTypes()) - { - if (entryType.IsAssignableFrom(type) && !type.IsAbstract) - { - var instance = (ClientEntryPoint) Activator.CreateInstance(type); - try - { - instance.Main(GetTree()); - } - catch (Exception e) - { - GD.Print($"Caught exception inside Main:\n{e}"); - GD.Print("TO PREVENT LOG SPAM MAKING THE FORMER A PAIN TO FIND, THIS IS A FATAL ERROR."); - GetTree().Quit(); - return; - } - - entryPoints.Add(instance); - } - } - } - - public override void _PhysicsProcess(float delta) - { - try - { - if (!ShuttingDown) - { - foreach (var entrypoint in EntryPoints) - { - try - { - entrypoint.PhysicsProcess(delta); - } - catch (Exception e) - { - ExceptionCaught(e); - } - } - } - } - catch - { - GD.Print("Whoops"); - } - } - - public override void _Process(float delta) - { - if (!ShuttingDown) - { - foreach (var entrypoint in EntryPoints) - { - try - { - entrypoint.FrameProcess(delta); - } - catch (Exception e) - { - ExceptionCaught(e); - } - } - } - } - - public override void _UnhandledInput(InputEvent inputEvent) - { - if (!ShuttingDown) - { - foreach (var entrypoint in EntryPoints) - { - try - { - entrypoint.Input(inputEvent); - } - catch (Exception e) - { - ExceptionCaught(e); - } - } - } - } - - public override void _Input(InputEvent inputEvent) - { - if (!ShuttingDown) - { - foreach (var entrypoint in EntryPoints) - { - try - { - entrypoint.PreInput(inputEvent); - } - catch (Exception e) - { - ExceptionCaught(e); - } - } - } - } - - public override void _Notification(int what) - { - if (!ShuttingDown) - { - switch (what) - { - case MainLoop.NotificationWmQuitRequest: - ShuttingDown = true; - foreach (var entrypoint in EntryPoints) - { - entrypoint.QuitRequest(); - } - - break; - } - } - } - - public void ExceptionCaught(Exception exception) - { - foreach (var entrypoint in EntryPoints) - { - entrypoint.HandleException(exception); - } - } - } - - /// - /// Automatically gets created on AutoLoad by . - /// - public abstract class ClientEntryPoint - { - /// - /// Called when the entry point gets created. - /// - public virtual void Main(SceneTree tree) - { - } - - /// - /// Called every rendering frame by Godot. - /// - /// Time delta since last process tick. - public virtual void FrameProcess(float delta) - { - } - - /// - /// Called every physics process by Godot. - /// This should be a fixed update rate. - /// - /// - /// Time delta since the last process tick. - /// Should be constant if the CPU isn't being tortured. - /// - public virtual void PhysicsProcess(float delta) - { - } - - /// - /// Called whenever we receive input. - /// The UI system can still intercept this beforehand. - /// - public virtual void Input(InputEvent inputEvent) - { - } - - /// - /// Called before all other input events. This is before the UI system. - /// - public virtual void PreInput(InputEvent inputEvent) - { - } - - /// - /// Called when the OS sends a quit request, such as the user clicking the window's close button. - /// - public virtual void QuitRequest() - { - } - - /// - /// Invoked whenever an exception was caught going into Godot. - /// - /// The exception that was caught. - public virtual void HandleException(Exception exception) - { - GD.Print($"Caught unhandled exception:\n{exception}"); - } - } -} diff --git a/Robust.Client.Godot/SignalSubscriber/BaseGodotSignalSubscriber.cs b/Robust.Client.Godot/SignalSubscriber/BaseGodotSignalSubscriber.cs deleted file mode 100644 index a4f16dcf1..000000000 --- a/Robust.Client.Godot/SignalSubscriber/BaseGodotSignalSubscriber.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -// Godot *really* doesn't like it if you inherit Godot.Object outside the main project. -// in fact, it hard crashes. -// So we use these tiny dummies to register signals. -// It's not clean but do you have a better idea? -namespace Robust.Client.GodotGlue -{ - public abstract class BaseGodotSignalSubscriber : Godot.Reference - { - public void Connect(Godot.Object obj, string signal) - { - obj.Connect(signal, this, "SignalInvoker"); - } - - public void Disconnect(Godot.Object obj, string signal) - { - obj.Disconnect(signal, this, "SignalInvoker"); - } - - protected void HandleException(Exception exception) - { - SS14Loader.Instance.ExceptionCaught(exception); - } - } -} diff --git a/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber0.cs b/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber0.cs deleted file mode 100644 index 211e3b897..000000000 --- a/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber0.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace Robust.Client.GodotGlue -{ - public class GodotSignalSubscriber0 : BaseGodotSignalSubscriber - { - public event Action Signal; - - public void SignalInvoker() - { - try - { - Signal?.Invoke(); - } - catch (Exception e) - { - HandleException(e); - } - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - - if (disposing) - { - Signal = null; - } - } - } -} diff --git a/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber1.cs b/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber1.cs deleted file mode 100644 index ad634c184..000000000 --- a/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber1.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace Robust.Client.GodotGlue -{ - public class GodotSignalSubscriber1 : BaseGodotSignalSubscriber - { - public event Action Signal; - - public void SignalInvoker(object a) - { - try - { - Signal?.Invoke(a); - } - catch (Exception e) - { - HandleException(e); - } - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - - if (disposing) - { - Signal = null; - } - } - } -} diff --git a/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber2.cs b/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber2.cs deleted file mode 100644 index f99612c7e..000000000 --- a/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber2.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace Robust.Client.GodotGlue -{ - public class GodotSignalSubscriber2 : BaseGodotSignalSubscriber - { - public event Action Signal; - - public void SignalInvoker(object a, object b) - { - try - { - Signal?.Invoke(a, b); - } - catch (Exception e) - { - HandleException(e); - } - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - - if (disposing) - { - Signal = null; - } - } - } -} diff --git a/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber3.cs b/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber3.cs deleted file mode 100644 index 10e8ab777..000000000 --- a/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber3.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace Robust.Client.GodotGlue -{ - public class GodotSignalSubscriber3 : BaseGodotSignalSubscriber - { - public event Action Signal; - - public void SignalInvoker(object a, object b, object c) - { - try - { - Signal?.Invoke(a, b, c); - } - catch (Exception e) - { - HandleException(e); - } - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - - if (disposing) - { - Signal = null; - } - } - } -} diff --git a/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber4.cs b/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber4.cs deleted file mode 100644 index 4240fad35..000000000 --- a/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber4.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace Robust.Client.GodotGlue -{ - public class GodotSignalSubscriber4 : BaseGodotSignalSubscriber - { - public event Action Signal; - - public void SignalInvoker(object a, object b, object c, object d) - { - try - { - Signal?.Invoke(a, b, c, d); - } - catch (Exception e) - { - HandleException(e); - } - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - - if (disposing) - { - Signal = null; - } - } - } -} diff --git a/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber5.cs b/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber5.cs deleted file mode 100644 index eb289d9c4..000000000 --- a/Robust.Client.Godot/SignalSubscriber/GodotSignalSubscriber5.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace Robust.Client.GodotGlue -{ - public class GodotSignalSubscriber5 : BaseGodotSignalSubscriber - { - public event Action Signal; - - public void SignalInvoker(object a, object b, object c, object d, object e) - { - try - { - Signal?.Invoke(a, b, c, d, e); - } - catch (Exception ex) - { - HandleException(ex); - } - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - - if (disposing) - { - Signal = null; - } - } - } -} diff --git a/Robust.Client.Godot/SpriteView.cs b/Robust.Client.Godot/SpriteView.cs deleted file mode 100644 index 93b0c61bc..000000000 --- a/Robust.Client.Godot/SpriteView.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Godot; - -namespace Robust.Client.GodotGlue -{ - public class SpriteView : Control - { - - } -} diff --git a/Robust.Client.Godot/default_bus_layout.tres b/Robust.Client.Godot/default_bus_layout.tres deleted file mode 100644 index 0d74642f2..000000000 --- a/Robust.Client.Godot/default_bus_layout.tres +++ /dev/null @@ -1,11 +0,0 @@ -[gd_resource type="AudioBusLayout" format=2] - -[resource] - -bus/0/name = "Master" -bus/0/solo = false -bus/0/mute = false -bus/0/bypass_fx = false -bus/0/volume_db = -0.2 -bus/0/send = "" - diff --git a/Robust.Client.Godot/default_env.tres b/Robust.Client.Godot/default_env.tres deleted file mode 100644 index 8edf1e3a2..000000000 --- a/Robust.Client.Godot/default_env.tres +++ /dev/null @@ -1,102 +0,0 @@ -[gd_resource type="Environment" load_steps=2 format=2] - -[sub_resource type="ProceduralSky" id=1] - -radiance_size = 4 -sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 ) -sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 ) -sky_curve = 0.25 -sky_energy = 1.0 -ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 ) -ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 ) -ground_curve = 0.01 -ground_energy = 1.0 -sun_color = Color( 1, 1, 1, 1 ) -sun_latitude = 35.0 -sun_longitude = 0.0 -sun_angle_min = 1.0 -sun_angle_max = 100.0 -sun_curve = 0.05 -sun_energy = 16.0 -texture_size = 2 - -[resource] - -background_mode = 2 -background_sky = SubResource( 1 ) -background_sky_custom_fov = 0.0 -background_color = Color( 0, 0, 0, 1 ) -background_energy = 1.0 -background_canvas_max_layer = 0 -ambient_light_color = Color( 0, 0, 0, 1 ) -ambient_light_energy = 1.0 -ambient_light_sky_contribution = 1.0 -fog_enabled = false -fog_color = Color( 0.5, 0.6, 0.7, 1 ) -fog_sun_color = Color( 1, 0.9, 0.7, 1 ) -fog_sun_amount = 0.0 -fog_depth_enabled = true -fog_depth_begin = 10.0 -fog_depth_curve = 1.0 -fog_transmit_enabled = false -fog_transmit_curve = 1.0 -fog_height_enabled = false -fog_height_min = 0.0 -fog_height_max = 100.0 -fog_height_curve = 1.0 -tonemap_mode = 0 -tonemap_exposure = 1.0 -tonemap_white = 1.0 -auto_exposure_enabled = false -auto_exposure_scale = 0.4 -auto_exposure_min_luma = 0.05 -auto_exposure_max_luma = 8.0 -auto_exposure_speed = 0.5 -ss_reflections_enabled = false -ss_reflections_max_steps = 64 -ss_reflections_fade_in = 0.15 -ss_reflections_fade_out = 2.0 -ss_reflections_depth_tolerance = 0.2 -ss_reflections_roughness = true -ssao_enabled = false -ssao_radius = 1.0 -ssao_intensity = 1.0 -ssao_radius2 = 0.0 -ssao_intensity2 = 1.0 -ssao_bias = 0.01 -ssao_light_affect = 0.0 -ssao_ao_channel_affect = 0.0 -ssao_color = Color( 0, 0, 0, 1 ) -ssao_quality = 0 -ssao_blur = 3 -ssao_edge_sharpness = 4.0 -dof_blur_far_enabled = false -dof_blur_far_distance = 10.0 -dof_blur_far_transition = 5.0 -dof_blur_far_amount = 0.1 -dof_blur_far_quality = 1 -dof_blur_near_enabled = false -dof_blur_near_distance = 2.0 -dof_blur_near_transition = 1.0 -dof_blur_near_amount = 0.1 -dof_blur_near_quality = 1 -glow_enabled = false -glow_levels/1 = false -glow_levels/2 = false -glow_levels/3 = true -glow_levels/4 = false -glow_levels/5 = true -glow_levels/6 = false -glow_levels/7 = false -glow_intensity = 0.8 -glow_strength = 1.0 -glow_bloom = 0.0 -glow_blend_mode = 2 -glow_hdr_threshold = 1.0 -glow_hdr_scale = 2.0 -glow_bicubic_upscale = false -adjustment_enabled = false -adjustment_brightness = 1.0 -adjustment_contrast = 1.0 -adjustment_saturation = 1.0 - diff --git a/Robust.Client.Godot/export_presets.cfg b/Robust.Client.Godot/export_presets.cfg deleted file mode 100644 index 3d6dca4ab..000000000 --- a/Robust.Client.Godot/export_presets.cfg +++ /dev/null @@ -1,76 +0,0 @@ -[preset.0] - -name="mac" -platform="Mac OSX" -runnable=true -custom_features="" -export_filter="all_resources" -include_filter="" -exclude_filter="" -patch_list=PoolStringArray( ) - -[preset.0.options] - -custom_package/debug="/home/pjbriers/builds_shared/mac_export_template.zip" -custom_package/release="" -application/name="Space Station 14" -application/info="In space, nobody can hear you honk." -application/icon="" -application/identifier="io.spacestation14" -application/signature="ss14" -application/short_version="0.1" -application/version="0.1" -application/copyright="" -application/bits_mode=0 -display/high_res=false -texture_format/s3tc=true -texture_format/etc=false -texture_format/etc2=false - -[preset.1] - -name="win" -platform="Windows Desktop" -runnable=true -custom_features="" -export_filter="all_resources" -include_filter="" -exclude_filter="" -patch_list=PoolStringArray( ) - -[preset.1.options] - -texture_format/s3tc=true -texture_format/etc=false -texture_format/etc2=false -binary_format/64_bits=true -custom_template/release="" -custom_template/debug="/home/pjbriers/builds_shared/win/Robust.Client.exe" -application/icon="" -application/file_version="" -application/product_version="" -application/company_name="Space Wizards Federation" -application/product_name="Space Station 14" -application/file_description="" -application/copyright="" -application/trademarks="" - -[preset.2] - -name="x11" -platform="Linux/X11" -runnable=true -custom_features="" -export_filter="all_resources" -include_filter="" -exclude_filter="" -patch_list=PoolStringArray( ) - -[preset.2.options] - -texture_format/s3tc=true -texture_format/etc=false -texture_format/etc2=false -binary_format/64_bits=true -custom_template/release="" -custom_template/debug="/home/pjbriers/builds_shared/linux/Robust.Client.x86_64" diff --git a/Robust.Client.Godot/logo.png b/Robust.Client.Godot/logo.png deleted file mode 100644 index 347f15202..000000000 Binary files a/Robust.Client.Godot/logo.png and /dev/null differ diff --git a/Robust.Client.Godot/logo.png.import b/Robust.Client.Godot/logo.png.import deleted file mode 100644 index cc4aac331..000000000 --- a/Robust.Client.Godot/logo.png.import +++ /dev/null @@ -1,29 +0,0 @@ -[remap] - -importer="texture" -type="StreamTexture" -path="res://.import/logo.png-cca8726399059c8d4f806e28e356b14d.stex" - -[deps] - -source_file="res://logo.png" -dest_files=[ "res://.import/logo.png-cca8726399059c8d4f806e28e356b14d.stex" ] - -[params] - -compress/mode=0 -compress/lossy_quality=0.7 -compress/hdr_mode=0 -compress/normal_map=0 -flags/repeat=0 -flags/filter=false -flags/mipmaps=false -flags/anisotropic=false -flags/srgb=2 -process/fix_alpha_border=true -process/premult_alpha=false -process/HDR_as_SRGB=false -stream=false -size_limit=0 -detect_3d=true -svg/scale=1.0 diff --git a/Robust.Client.Godot/project.godot b/Robust.Client.Godot/project.godot deleted file mode 100644 index 145c3aa0a..000000000 --- a/Robust.Client.Godot/project.godot +++ /dev/null @@ -1,37 +0,0 @@ -; Engine configuration file. -; It's best edited using the editor UI and not directly, -; since the parameters that go here are not all obvious. -; -; Format: -; [section] ; section goes between [] -; param=value ; assign values to parameters - -config_version=3 - -[application] - -config/name="Robust.Client.Godot" -run/main_scene="res://MainScene.tscn" -config/use_custom_user_dir=true -boot_splash/image="res://Art/bootsplash.png" -boot_splash/fullsize=false -config/icon="res://logo.png" - -[gdnative] - -singletons=[ ] - -[mono] - -debugger_agent/wait_timeout=10000 - -[network] - -limits/debugger_stdout/max_chars_per_second=8128 - -[rendering] - -quality/intended_usage/framebuffer_allocation=0 -quality/2d/use_pixel_snap=true -environment/default_clear_color=Color( 0, 0, 0, 1 ) -environment/default_environment="res://default_env.tres" diff --git a/Robust.Client.Godot/ss14.ico b/Robust.Client.Godot/ss14.ico deleted file mode 100644 index fc36e8195..000000000 Binary files a/Robust.Client.Godot/ss14.ico and /dev/null differ diff --git a/Robust.Client/Audio/AudioStream.cs b/Robust.Client/Audio/AudioStream.cs index a47d8cd02..dc70eba95 100644 --- a/Robust.Client/Audio/AudioStream.cs +++ b/Robust.Client/Audio/AudioStream.cs @@ -6,7 +6,6 @@ namespace Robust.Client.Audio public sealed class AudioStream { public TimeSpan Length { get; } - internal Godot.AudioStream GodotAudioStream { get; } internal Clyde.Handle? ClydeHandle { get; } // Constructor used on headless. @@ -21,12 +20,5 @@ namespace Robust.Client.Audio ClydeHandle = handle; Length = length; } - - // Constructor used on Godot. - internal AudioStream(Godot.AudioStream godotStream) - { - GodotAudioStream = godotStream; - Length = TimeSpan.FromSeconds(godotStream.GetLength()); - } } } diff --git a/Robust.Client/Console/Commands/Debug.cs b/Robust.Client/Console/Commands/Debug.cs index 5eb1ba249..2b778a732 100644 --- a/Robust.Client/Console/Commands/Debug.cs +++ b/Robust.Client/Console/Commands/Debug.cs @@ -183,37 +183,6 @@ namespace Robust.Client.Console.Commands } } - internal class DumpDeferredLightingCommand : IConsoleCommand - { - public string Command => "dumpdeferredlighting"; - public string Help => ""; - public string Description => ""; - - public bool Execute(IDebugConsole console, params string[] args) - { - var viewport = - IoCManager.Resolve().SceneTree.Root.GetNode("LightingViewport") as Godot.Viewport; - var tex = viewport.GetTexture().GetData(); - tex.SavePng("res://deferredlightingdump.png"); - return false; - } - } - - internal class GetRootViewportTransformCommand : IConsoleCommand - { - public string Command => "rootvptransform"; - public string Help => ""; - public string Description => ""; - - public bool Execute(IDebugConsole console, params string[] args) - { - var vp = IoCManager.Resolve().SceneTree.Root; - console.AddLine( - $"canvas_transform: {vp.CanvasTransform}, global_canvas_transform: {vp.GlobalCanvasTransform}, size: {vp.Size}"); - return false; - } - } - internal class DisconnectCommand : IConsoleCommand { public string Command => "disconnect"; diff --git a/Robust.Client/GameController.cs b/Robust.Client/GameController.cs index 36aea2d4a..881fb4d5f 100644 --- a/Robust.Client/GameController.cs +++ b/Robust.Client/GameController.cs @@ -46,27 +46,17 @@ using Robust.Shared.Interfaces.Resources; namespace Robust.Client { - // Gets automatically ran by Robust.Client.Godot. [UsedImplicitly] internal sealed partial class GameController : IGameControllerInternal { public enum DisplayMode { Headless, - Godot, Clyde } internal static DisplayMode Mode { get; private set; } = DisplayMode.Headless; - internal static bool OnGodot => Mode == DisplayMode.Godot; - - /// - /// QueueFreeing a Godot node during finalization can cause segfaults. - /// As such, this var is set as soon as we tell Godot to shut down proper. - /// - public static bool ShuttingDownHard { get; private set; } = false; - [Dependency] private readonly IConfigurationManager _configurationManager; [Dependency] private readonly IResourceCacheInternal _resourceCache; [Dependency] private readonly IResourceManager _resourceManager; @@ -168,7 +158,6 @@ namespace Robust.Client _lightManager.Initialize(); _entityManager.Initialize(); _gameStateManager.Initialize(); - _overlayManager.Initialize(); _placementManager.Initialize(); _viewVariablesManager.Initialize(); @@ -197,17 +186,10 @@ namespace Robust.Client Logger.Info("Shutting down!"); } - if (Mode != DisplayMode.Godot) - { - _mainLoop.Running = false; - } + _mainLoop.Running = false; Logger.Debug("Goodbye"); IoCManager.Clear(); - ShuttingDownHard = true; - // Hahaha Godot is crashing absurdly and I can't be bothered to fix it. - // Hey now it shuts down easily. - Environment.Exit(0); } private void Update(float frameTime) @@ -242,14 +224,7 @@ namespace Robust.Client private void SetupLogging() { - if (OnGodot) - { - _logManager.RootSawmill.AddHandler(new GodotLogHandler()); - } - else - { - _logManager.RootSawmill.AddHandler(new ConsoleLogHandler()); - } + _logManager.RootSawmill.AddHandler(new ConsoleLogHandler()); _logManager.GetSawmill("res.typecheck").Level = LogLevel.Info; _logManager.GetSawmill("res.tex").Level = LogLevel.Info; @@ -264,7 +239,7 @@ namespace Robust.Client public static ICollection GetCommandLineArgs() { - return OnGodot ? Godot.OS.GetCmdlineArgs() : Environment.GetCommandLineArgs(); + return Environment.GetCommandLineArgs(); } private static string _getUserDataDir(ICollection commandLineArgs) diff --git a/Robust.Client/GameController/GameController.Godot.cs b/Robust.Client/GameController/GameController.Godot.cs deleted file mode 100644 index a4b11338a..000000000 --- a/Robust.Client/GameController/GameController.Godot.cs +++ /dev/null @@ -1,252 +0,0 @@ -using System; -using Godot; -using Robust.Client.GodotGlue; -using Robust.Client.Input; -using Robust.Client.Interfaces; -using Robust.Client.Utility; -using Robust.Shared.Interfaces.Timing; -using Robust.Shared.IoC; -using Robust.Shared.Timing; - -namespace Robust.Client -{ - internal partial class GameController : ClientEntryPoint - { - private GameTimingGodot _gameTimingGodotGodot; - - public override void Main(Godot.SceneTree tree) - { -#if !X64 - throw new InvalidOperationException("The client cannot start outside x64."); -#endif - Mode = DisplayMode.Godot; - tree.SetAutoAcceptQuit(false); - IoCManager.InitThread(); - IoCManager.Register(); - IoCManager.BuildGraph(); - IoCManager.Resolve().Initialize(tree); - -#if DEBUG - // Ensure Godot's side of the resources are up to date. - GodotResourceCopy.DoDirCopy("../Resources", "Engine"); -#endif - - Startup(); - - _gameTimingGodotGodot = IoCManager.Resolve(); - } - - public override void QuitRequest() - { - Shutdown("OS quit request"); - } - - public override void PhysicsProcess(float delta) - { - // Can't be too certain. - _gameTimingGodotGodot.InSimulation = true; - _gameTimingGodotGodot._tickRemainderTimer.Restart(); - try - { - if (!_gameTimingGodotGodot.Paused) - { - _gameTimingGodotGodot.CurTick = new GameTick(_gameTimingGodotGodot.CurTick.Value + 1); - Update(delta); - } - } - finally - { - _gameTimingGodotGodot.InSimulation = false; - } - } - - public override void FrameProcess(float delta) - { - _gameTimingGodotGodot.InSimulation = false; // Better safe than sorry. - _gameTimingGodotGodot.RealFrameTime = TimeSpan.FromSeconds(delta); - _gameTimingGodotGodot.TickRemainder = _gameTimingGodotGodot._tickRemainderTimer.Elapsed; - - _frameProcessMain(delta); - } - - public override void HandleException(Exception exception) - { - try - { - if (_logManager != null) - { - _logManager.GetSawmill("root").Error($"Unhandled exception:\n{exception}"); - } - else - { - Godot.GD.Print($"Unhandled exception:\n{exception}"); - } - } - catch (Exception e) - { - Godot.GD.Print($"Welp. The unhandled exception handler threw an exception.\n{e}\nException that was being handled:\n{exception}"); - } - } - - - // Override that converts and distributes the input events - // to the more sane methods above. - public override void Input(Godot.InputEvent inputEvent) - { - switch (inputEvent) - { - case Godot.InputEventKey keyEvent: - var keyEventArgs = (KeyEventArgs)keyEvent; - if (keyEvent.Echo) - { - return; - } - else if (keyEvent.Pressed) - { - KeyDown(keyEventArgs); - } - else - { - KeyUp(keyEventArgs); - } - break; - - case Godot.InputEventMouseButton mouseButtonEvent: - if (mouseButtonEvent.ButtonIndex >= (int)Godot.ButtonList.WheelUp && mouseButtonEvent.ButtonIndex <= (int)Godot.ButtonList.WheelRight) - { - // Mouse wheel event. - var mouseWheelEventArgs = (MouseWheelEventArgs)mouseButtonEvent; - MouseWheel(mouseWheelEventArgs); - } - else - { - // Mouse button event. - var mouseButtonEventArgs = (MouseButtonEventArgs)mouseButtonEvent; - if (mouseButtonEvent.Pressed) - { - MouseDown(mouseButtonEventArgs); - if (!mouseButtonEventArgs.Handled) - { - KeyDown((KeyEventArgs) mouseButtonEvent); - } - } - else - { - MouseUp(mouseButtonEventArgs); - if (!mouseButtonEventArgs.Handled) - { - KeyUp((KeyEventArgs)mouseButtonEvent); - } - } - } - break; - - case Godot.InputEventMouseMotion mouseMotionEvent: - var mouseMoveEventArgs = (MouseMoveEventArgs)mouseMotionEvent; - MouseMove(mouseMoveEventArgs); - break; - } - } - - public override void PreInput(Godot.InputEvent inputEvent) - { - if (inputEvent is Godot.InputEventKey keyEvent) - { - var keyEventArgs = (KeyEventArgs)keyEvent; - if (keyEvent.Echo) - { - return; - } - else if (keyEvent.Pressed) - { - // TODO: these hacks are in right now for toggling the debug console. - // Somehow find a way to make the console use the key binds system? - _userInterfaceManager.GDPreKeyDown(keyEventArgs); - } - else - { - _userInterfaceManager.GDPreKeyUp(keyEventArgs); - } - } - } - - // TODO: This class is basically just a bunch of stubs. - private class GameTimingGodot : IGameTiming - { - private static readonly IStopwatch _realTimer = new Stopwatch(); - public readonly IStopwatch _tickRemainderTimer = new Stopwatch(); - - public GameTimingGodot() - { - _realTimer.Start(); - // Not sure if Restart() starts it implicitly so... - _tickRemainderTimer.Start(); - } - - public bool InSimulation { get; set; } - public bool Paused { get; set; } - - public TimeSpan CurTime => CalcCurTime(); - - public TimeSpan RealTime => _realTimer.Elapsed; - - public TimeSpan FrameTime => CalcFrameTime(); - - public TimeSpan RealFrameTime { get; set; } - - public TimeSpan RealFrameTimeAvg => throw new NotImplementedException(); - - public TimeSpan RealFrameTimeStdDev => throw new NotImplementedException(); - - public double FramesPerSecondAvg => Godot.Performance.GetMonitor(Performance.Monitor.TimeFps); - - public GameTick CurTick { get; set; } - - public byte TickRate - { - get => (byte) Godot.Engine.IterationsPerSecond; - set => Godot.Engine.IterationsPerSecond = value; - } - - public TimeSpan TickPeriod => TimeSpan.FromTicks((long)(1.0 / TickRate * TimeSpan.TicksPerSecond)); - - public TimeSpan TickRemainder { get; set; } - public uint CurFrame { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - public bool FastForward { get; set; } //TODO: Not implemented - public float TickTimingAdjustment { get; set; } = 1; //TODO: Not implemented - - public void ResetRealTime() - { - throw new NotImplementedException(); - } - - public void StartFrame() - { - throw new NotImplementedException(); - } - - private TimeSpan CalcCurTime() - { - // calculate simulation CurTime - var time = TimeSpan.FromTicks(TickPeriod.Ticks * CurTick.Value); - - if (!InSimulation) // rendering can draw frames between ticks - return time + TickRemainder; - return time; - } - - private TimeSpan CalcFrameTime() - { - // calculate simulation FrameTime - if (InSimulation) - { - return TimeSpan.FromTicks(TickPeriod.Ticks); - } - else - { - return Paused ? TimeSpan.Zero : RealFrameTime; - } - } - } - } -} diff --git a/Robust.Client/GameController/GameController.Input.cs b/Robust.Client/GameController/GameController.Input.cs index 166bbd9a0..0dd1c66c8 100644 --- a/Robust.Client/GameController/GameController.Input.cs +++ b/Robust.Client/GameController/GameController.Input.cs @@ -9,14 +9,11 @@ namespace Robust.Client /// public void KeyDown(KeyEventArgs keyEvent) { - if (!OnGodot) - { - _userInterfaceManager.KeyDown(keyEvent); + _userInterfaceManager.KeyDown(keyEvent); - if (keyEvent.Handled) - { - return; - } + if (keyEvent.Handled) + { + return; } _inputManager.KeyDown(keyEvent); } @@ -28,10 +25,7 @@ namespace Robust.Client { // Unlike KeyDown, InputManager still gets key ups. // My logic is that it should be fine dealing with redundant key ups and this *might* prevent edge cases. - if (!OnGodot) - { - _userInterfaceManager.KeyUp(keyEvent); - } + _userInterfaceManager.KeyUp(keyEvent); _inputManager.KeyUp(keyEvent); } @@ -45,14 +39,7 @@ namespace Robust.Client /// public void MouseDown(MouseButtonEventArgs mouseEvent) { - if (GameController.OnGodot) - { - _userInterfaceManager.GDUnhandledMouseDown(mouseEvent); - } - else - { - _userInterfaceManager.MouseDown(mouseEvent); - } + _userInterfaceManager.MouseDown(mouseEvent); _stateManager.MouseDown(mouseEvent); } @@ -61,14 +48,7 @@ namespace Robust.Client /// public void MouseUp(MouseButtonEventArgs mouseButtonEventArgs) { - if (GameController.OnGodot) - { - _userInterfaceManager.GDUnhandledMouseUp(mouseButtonEventArgs); - } - else - { - _userInterfaceManager.MouseUp(mouseButtonEventArgs); - } + _userInterfaceManager.MouseUp(mouseButtonEventArgs); _stateManager.MouseUp(mouseButtonEventArgs); } @@ -77,10 +57,7 @@ namespace Robust.Client /// public void MouseMove(MouseMoveEventArgs mouseMoveEventArgs) { - if (!GameController.OnGodot) - { - _userInterfaceManager.MouseMove(mouseMoveEventArgs); - } + _userInterfaceManager.MouseMove(mouseMoveEventArgs); _stateManager.MouseMove(mouseMoveEventArgs); } diff --git a/Robust.Client/GameController/GameController.IoC.cs b/Robust.Client/GameController/GameController.IoC.cs index 45d35db74..dbecabe29 100644 --- a/Robust.Client/GameController/GameController.IoC.cs +++ b/Robust.Client/GameController/GameController.IoC.cs @@ -91,20 +91,10 @@ namespace Robust.Client IoCManager.Register(); IoCManager.Register(); IoCManager.Register(); - if (OnGodot) - { - IoCManager.Register(); - IoCManager.Register(); - IoCManager.Register(); - IoCManager.Register(); - } - else - { - IoCManager.Register(); - IoCManager.Register(); - IoCManager.Register(); - IoCManager.Register(); - } + IoCManager.Register(); + IoCManager.Register(); + IoCManager.Register(); + IoCManager.Register(); IoCManager.Register(); IoCManager.Register(); IoCManager.Register(); @@ -141,10 +131,6 @@ namespace Robust.Client IoCManager.Register(); IoCManager.Register(); break; - case DisplayMode.Godot: - IoCManager.Register(); - IoCManager.Register(); - break; case DisplayMode.Clyde: IoCManager.Register(); IoCManager.Register(); @@ -156,16 +142,7 @@ namespace Robust.Client throw new ArgumentOutOfRangeException(); } IoCManager.Register(); - if (OnGodot) - { - IoCManager.Register(); - // Only GameController can access this because the type is private so it's fine. - IoCManager.Register(); - } - else - { - IoCManager.Register(); - } + IoCManager.Register(); IoCManager.Register(); IoCManager.Register(); @@ -173,20 +150,13 @@ namespace Robust.Client IoCManager.Register(); IoCManager.Register(); - if (OnGodot) - { - IoCManager.Register(); - } - else - { #if LINUX - IoCManager.Register(); + IoCManager.Register(); #elif WINDOWS - IoCManager.Register(); + IoCManager.Register(); #else - IoCManager.Register(); + IoCManager.Register(); #endif - } IoCManager.BuildGraph(); } diff --git a/Robust.Client/GameController/GameController.Standalone.cs b/Robust.Client/GameController/GameController.Standalone.cs index 04f1d5207..59231e347 100644 --- a/Robust.Client/GameController/GameController.Standalone.cs +++ b/Robust.Client/GameController/GameController.Standalone.cs @@ -22,8 +22,6 @@ namespace Robust.Client #endif IoCManager.InitThread(); - IoCManager.Register(); - IoCManager.BuildGraph(); if (Environment.GetCommandLineArgs().Contains("--headless")) { @@ -47,21 +45,39 @@ namespace Robust.Client SleepMode = Mode == DisplayMode.Headless ? SleepMode.Delay : SleepMode.None }; - _mainLoop.Tick += (sender, args) => Update(args.DeltaSeconds); + _mainLoop.Tick += (sender, args) => + { + if (_mainLoop.Running) + { + Update(args.DeltaSeconds); + } + }; if (Mode == DisplayMode.Clyde) { _mainLoop.Render += (sender, args) => { - _gameTimingHeadless.CurFrame++; - _clyde.Render(new FrameEventArgs(args.DeltaSeconds)); + if (_mainLoop.Running) + { + _gameTimingHeadless.CurFrame++; + _clyde.Render(new FrameEventArgs(args.DeltaSeconds)); + } + }; + _mainLoop.Input += (sender, args) => + { + if (_mainLoop.Running) + { + _clyde.ProcessInput(new FrameEventArgs(args.DeltaSeconds)); + } }; - _mainLoop.Input += (sender, args) => _clyde.ProcessInput(new FrameEventArgs(args.DeltaSeconds)); } _mainLoop.Update += (sender, args) => { - _frameProcessMain(args.DeltaSeconds); + if (_mainLoop.Running) + { + _frameProcessMain(args.DeltaSeconds); + } }; // set GameLoop.Running to false to return from this function. diff --git a/Robust.Client/GameObjects/Components/Eye/EyeComponent.cs b/Robust.Client/GameObjects/Components/Eye/EyeComponent.cs index 74f5f631e..885a7d8da 100644 --- a/Robust.Client/GameObjects/Components/Eye/EyeComponent.cs +++ b/Robust.Client/GameObjects/Components/Eye/EyeComponent.cs @@ -79,11 +79,6 @@ namespace Robust.Client.GameObjects }; transform.OnMove += Transform_OnMove; - - if (GameController.OnGodot) - { - Owner.GetComponent().SceneNode.AddChild(eye.GodotCamera); - } } public override void OnRemove() diff --git a/Robust.Client/GameObjects/Components/Light/PointLightComponent.cs b/Robust.Client/GameObjects/Components/Light/PointLightComponent.cs index f3e479d03..423eeb47a 100644 --- a/Robust.Client/GameObjects/Components/Light/PointLightComponent.cs +++ b/Robust.Client/GameObjects/Components/Light/PointLightComponent.cs @@ -85,22 +85,12 @@ namespace Robust.Client.GameObjects { if (Owner.Transform.Parent == null) return; - if (GameController.OnGodot) - { - Light.ParentTo((GodotTransformComponent) Owner.Transform.Parent); - } - _lightOnParent = true; } else { if (!_lightOnParent) return; - if (GameController.OnGodot) - { - Light.ParentTo((GodotTransformComponent) Owner.Transform); - } - _lightOnParent = false; } } @@ -123,12 +113,6 @@ namespace Robust.Client.GameObjects var tex = _resourceCache.GetResource(new ResourcePath("/Textures/Effects/Light/") / $"lighting_falloff_{(int) radius}.png"); - if (GameController.OnGodot) - { - // TODO: Maybe editing the global texture resource is not a good idea. - tex.Texture.GodotTexture.SetFlags(tex.Texture.GodotTexture.GetFlags() | - (int) Godot.Texture.FlagsEnum.Filter); - } Light.Texture = tex.Texture; } @@ -138,11 +122,6 @@ namespace Robust.Client.GameObjects { base.Initialize(); - if (GameController.OnGodot) - { - Light.ParentTo((GodotTransformComponent) Owner.Transform); - } - Owner.Transform.OnParentChanged += TransformOnOnParentChanged; } @@ -156,20 +135,11 @@ namespace Robust.Client.GameObjects if (obj.New.IsValid() && Owner.EntityManager.TryGetEntity(obj.New, out var entity)) { - if (GameController.OnGodot) - { - Light.ParentTo((GodotTransformComponent) entity.Transform); - } _lightOnParent = true; } else { - if (GameController.OnGodot) - { - Light.ParentTo((GodotTransformComponent) Owner.Transform); - } - _lightOnParent = false; } } diff --git a/Robust.Client/GameObjects/Components/Renderable/SpriteComponent.cs b/Robust.Client/GameObjects/Components/Renderable/SpriteComponent.cs index f3ea90d17..f47ab1208 100644 --- a/Robust.Client/GameObjects/Components/Renderable/SpriteComponent.cs +++ b/Robust.Client/GameObjects/Components/Renderable/SpriteComponent.cs @@ -22,7 +22,6 @@ using System.Linq; using System.Text; using Robust.Shared.Interfaces.Reflection; using Robust.Shared.ViewVariables; -using VS = Godot.VisualServer; namespace Robust.Client.GameObjects { @@ -35,18 +34,7 @@ namespace Robust.Client.GameObjects public bool Visible { get => _visible; - set - { - _visible = value; - if (value) - { - RedrawQueued = true; - } - else - { - ClearDraw(); - } - } + set => _visible = value; } private DrawDepth drawDepth = DrawDepth.Objects; @@ -58,15 +46,7 @@ namespace Robust.Client.GameObjects public DrawDepth DrawDepth { get => drawDepth; - set - { - drawDepth = value; - - if (GameController.OnGodot && SceneNode != null) - { - SceneNode.ZIndex = (int) value; - } - } + set => drawDepth = value; } private Vector2 scale = Vector2.One; @@ -78,14 +58,7 @@ namespace Robust.Client.GameObjects public Vector2 Scale { get => scale; - set - { - scale = value; - if (GameController.OnGodot && SceneNode != null) - { - SceneNode.Scale = value.Convert(); - } - } + set => scale = value; } private Angle rotation; @@ -94,14 +67,7 @@ namespace Robust.Client.GameObjects public Angle Rotation { get => rotation; - set - { - rotation = value; - if (GameController.OnGodot && SceneNode != null) - { - SceneNode.Rotation = (float) value; - } - } + set => rotation = value; } private Vector2 offset = Vector2.Zero; @@ -113,14 +79,7 @@ namespace Robust.Client.GameObjects public Vector2 Offset { get => offset; - set - { - offset = value; - if (GameController.OnGodot && SceneNode != null) - { - SceneNode.Position = value.Convert() * EyeManager.PIXELSPERMETER; - } - } + set => offset = value; } private Color color = Color.White; @@ -129,14 +88,7 @@ namespace Robust.Client.GameObjects public Color Color { get => color; - set - { - color = value; - if (GameController.OnGodot && SceneNode != null) - { - SceneNode.Modulate = value.Convert(); - } - } + set => color = value; } /// @@ -149,17 +101,11 @@ namespace Robust.Client.GameObjects public bool Directional { get => _directional; - set - { - _directional = value; - RedrawQueued = true; - } + set => _directional = value; } private bool _directional = true; - [ViewVariables(VVAccess.ReadWrite)] private bool RedrawQueued = true; - private RSI _baseRsi; [ViewVariables] @@ -210,8 +156,6 @@ namespace Robust.Client.GameObjects // This may be worth the overhead of basically reimplementing List. [ViewVariables] private List Layers; - private Godot.Node2D SceneNode; - [Dependency] private readonly IResourceCache resourceCache; [Dependency] private readonly IPrototypeManager prototypes; [Dependency] private readonly IReflectionManager reflectionManager; @@ -228,7 +172,6 @@ namespace Robust.Client.GameObjects // Do not directly store mirror instances, so that they can be picked up by the GC is not disposed correctly. // Don't need em anyways. readonly Dictionary Mirrors = new Dictionary(); - ISpriteProxy MainMirror; private static Shader _defaultShader; @@ -298,8 +241,6 @@ namespace Robust.Client.GameObjects { var layer = Layer.New(); layer.Visible = false; - // Redraw is probably not needed but eh? - RedrawQueued = true; return AddLayer(layer, newIndex); } @@ -327,7 +268,6 @@ namespace Robust.Client.GameObjects { var layer = Layer.New(); layer.Texture = texture; - RedrawQueued = true; return AddLayer(layer, newIndex); } @@ -345,7 +285,6 @@ namespace Robust.Client.GameObjects Environment.StackTrace); } - RedrawQueued = true; return AddLayer(layer, newIndex); } @@ -394,7 +333,6 @@ namespace Robust.Client.GameObjects Environment.StackTrace); } - RedrawQueued = true; return AddLayer(layer, newIndex); } @@ -462,8 +400,6 @@ namespace Robust.Client.GameObjects LayerMap[kv.Key] = kv.Value - 1; } } - - RedrawQueued = true; } public void RemoveLayer(object layerKey) @@ -490,7 +426,6 @@ namespace Robust.Client.GameObjects var thelayer = Layers[layer]; thelayer.Shader = shader; Layers[layer] = thelayer; - RedrawQueued = true; } public void LayerSetShader(object layerKey, Shader shader) @@ -576,7 +511,6 @@ namespace Robust.Client.GameObjects thelayer.State = null; thelayer.Texture = texture; Layers[layer] = thelayer; - RedrawQueued = true; } public void LayerSetTexture(object layerKey, Texture texture) @@ -668,7 +602,6 @@ namespace Robust.Client.GameObjects } Layers[layer] = thelayer; - RedrawQueued = true; } public void LayerSetState(object layerKey, RSI.StateId stateId) @@ -719,7 +652,6 @@ namespace Robust.Client.GameObjects } Layers[layer] = thelayer; - RedrawQueued = true; } public void LayerSetState(object layerKey, RSI.StateId stateId, RSI rsi) @@ -806,7 +738,6 @@ namespace Robust.Client.GameObjects } Layers[layer] = thelayer; - RedrawQueued = true; } public void LayerSetRSI(object layerKey, RSI rsi) @@ -865,7 +796,6 @@ namespace Robust.Client.GameObjects var thelayer = Layers[layer]; thelayer.Scale = scale; Layers[layer] = thelayer; - RedrawQueued = true; } public void LayerSetScale(object layerKey, Vector2 scale) @@ -893,7 +823,6 @@ namespace Robust.Client.GameObjects var thelayer = Layers[layer]; thelayer.Rotation = rotation; Layers[layer] = thelayer; - RedrawQueued = true; } public void LayerSetRotation(object layerKey, Angle rotation) @@ -920,7 +849,6 @@ namespace Robust.Client.GameObjects var thelayer = Layers[layer]; thelayer.Visible = visible; Layers[layer] = thelayer; - RedrawQueued = true; } public void LayerSetVisible(object layerKey, bool visible) @@ -947,7 +875,6 @@ namespace Robust.Client.GameObjects var thelayer = Layers[layer]; thelayer.Color = color; Layers[layer] = thelayer; - RedrawQueued = true; } public void LayerSetColor(object layerKey, Color color) @@ -1028,7 +955,6 @@ namespace Robust.Client.GameObjects // And set to said frame. theLayer.Texture = state.GetFrame(correctDir, theLayer.AnimationFrame).icon; Layers[layer] = theLayer; - RedrawQueued = true; } public void LayerSetAnimationTime(object layerKey, float animationTime) @@ -1106,51 +1032,12 @@ namespace Robust.Client.GameObjects public ISpriteProxy CreateProxy() { - if (GameController.OnGodot) - { - var item = VS.CanvasItemCreate(); - RedrawQueued = true; - return CreateMirror(item); - } - var key = NextMirrorKey++; var mirror = new SpriteMirror(key, this); Mirrors.Add(key, new MirrorData()); return mirror; } - ISpriteProxy CreateMirror(Godot.RID item) - { - var key = NextMirrorKey++; - var mirror = new SpriteMirror(key, this, item); - var data = new MirrorData - { - Root = item, - Children = new List(), - Visible = true, - }; - Mirrors.Add(key, data); - return mirror; - } - - public override void OnAdd() - { - base.OnAdd(); - - if (GameController.OnGodot) - { - SceneNode = new Godot.Node2D() - { - Name = "Sprite", - ZIndex = (int) drawDepth, - Scale = scale.Convert(), - Position = offset.Convert(), - Modulate = color.Convert(), - Rotation = (float) rotation, - }; - } - } - public override void OnRemove() { base.OnRemove(); @@ -1159,91 +1046,6 @@ namespace Robust.Client.GameObjects { DisposeMirror(key); } - - if (GameController.OnGodot) - { - MainMirror.Dispose(); - } - - if (GameController.OnGodot) - { - SceneNode.QueueFree(); - } - } - - public override void Initialize() - { - base.Initialize(); - - if (!GameController.OnGodot) - { - return; - } - - MainMirror = CreateMirror(SceneNode.GetCanvasItem()); - var mir = Mirrors[0]; - mir.DontFree = true; - Mirrors[0] = mir; - ((IGodotTransformComponent) Owner.Transform).SceneNode.AddChild(SceneNode); - } - - private void ClearDraw() - { - if (!GameController.OnGodot) - { - return; - } - - foreach (var data in Mirrors.Values) - { - foreach (var item in data.Children) - { - VS.FreeRid(item); - } - - data.Children.Clear(); - } - } - - private void Redraw() - { - ClearDraw(); - - if (!GameController.OnGodot) - { - return; - } - - foreach (var data in Mirrors.Values) - { - if (!data.Visible) - { - continue; - } - - foreach (var layer in Layers) - { - if (!layer.Visible) - { - continue; - } - - var shader = layer.Shader ?? DefaultShader; - var texture = layer.Texture ?? resourceCache.GetFallback(); - - var currentItem = VS.CanvasItemCreate(); - VS.CanvasItemSetParent(currentItem, data.Root); - data.Children.Add(currentItem); - VS.CanvasItemSetMaterial(currentItem, shader.GodotMaterial.GetRid()); - - var transform = Godot.Transform2D.Identity; - DrawingHandle.SetTransform2DRotationAndScale(ref transform, -layer.Rotation, layer.Scale); - VS.CanvasItemAddSetTransform(currentItem, transform); - // Not instantiating a DrawingHandle here because those are ref types, - // and I really don't want the extra allocation. - texture.GodotTexture.Draw(currentItem, -texture.GodotTexture.GetSize() / 2, layer.Color.Convert()); - } - } } internal void OpenGLRender(DrawingHandleWorld drawingHandle, bool useWorldTransform=true) @@ -1481,12 +1283,6 @@ namespace Robust.Client.GameObjects // TODO: This entire method is a hotspot of redundant code. // This is definitely gonna deserve some optimizations later down the line. - // Counteract world rotation so this thing gets rendered straight. - if (Directional && GameController.OnGodot) - { - SceneNode.Rotation = (float) (Owner.Transform.WorldRotation - Rotation) - MathHelper.PiOver2; - } - var dirWeAreFacing = GetDir(); var dirChanged = false; @@ -1546,15 +1342,8 @@ namespace Robust.Client.GameObjects _advanceFrameAnimation(ref layer, state, layerSpecificDir); layer.Texture = state.GetFrame(layerSpecificDir, layer.AnimationFrame).icon; - RedrawQueued = true; Layers[i] = layer; } - - if (GameController.OnGodot && RedrawQueued) - { - Redraw(); - RedrawQueued = false; - } } private static void _advanceFrameAnimation(ref Layer layer, RSI.State state, RSI.State.Direction layerSpecificDir) @@ -1751,14 +1540,6 @@ namespace Robust.Client.GameObjects return; } - // TODO: Doing a full redraw when a mirror is disposed is kinda a waste. - ClearDraw(); - RedrawQueued = true; - if (!val.DontFree && GameController.OnGodot) - { - VS.FreeRid(val.Root); - } - Mirrors.Remove(key); } @@ -1772,7 +1553,6 @@ namespace Robust.Client.GameObjects var mirror = Mirrors[key]; mirror.Visible = visible; Mirrors[key] = mirror; - RedrawQueued = true; } /// @@ -1834,8 +1614,6 @@ namespace Robust.Client.GameObjects { readonly int Key; readonly SpriteComponent Master; - private Godot.RID CanvasItem; - private Godot.RID Parent; private Vector2 _offset; public Vector2 Offset @@ -1845,7 +1623,6 @@ namespace Robust.Client.GameObjects { CheckDisposed(); _offset = value; - UpdateTransform(); } } @@ -1861,11 +1638,6 @@ namespace Robust.Client.GameObjects } } - public SpriteMirror(int key, SpriteComponent master, Godot.RID canvasItem) : this(key, master) - { - CanvasItem = canvasItem; - } - public SpriteMirror(int key, SpriteComponent master) { Master = master; @@ -1882,24 +1654,6 @@ namespace Robust.Client.GameObjects } } - private void UpdateTransform() - { - if (!GameController.OnGodot) - { - return; - } - - var transform = new Godot.Transform2D(0, Offset.Convert()); - VS.CanvasItemSetTransform(CanvasItem, transform); - } - - public void AttachToItem(Godot.RID item) - { - CheckDisposed(); - Parent = item; - VS.CanvasItemSetParent(CanvasItem, Parent); - } - public void Dispose() { if (Disposed) @@ -1916,24 +1670,16 @@ namespace Robust.Client.GameObjects Dispose(false); } - void Dispose(bool disposing) + private void Dispose(bool disposing) { Master.DisposeMirror(Key); - if (GameController.OnGodot) - { - CanvasItem = null; - } - Disposed = true; } } - struct MirrorData + private struct MirrorData { - public Godot.RID Root; - public List Children; - public bool Visible; // Don't free the canvas item if it's the scene node item. diff --git a/Robust.Client/GameObjects/Components/Transform/GodotTransformComponent.cs b/Robust.Client/GameObjects/Components/Transform/GodotTransformComponent.cs deleted file mode 100644 index 65f9a81bb..000000000 --- a/Robust.Client/GameObjects/Components/Transform/GodotTransformComponent.cs +++ /dev/null @@ -1,100 +0,0 @@ -using Robust.Client.Graphics.ClientEye; -using Robust.Client.Interfaces; -using Robust.Client.Interfaces.GameObjects.Components; -using Robust.Client.Utility; -using Robust.Shared.GameObjects.Components.Transform; -using Robust.Shared.Interfaces.GameObjects.Components; -using Robust.Shared.IoC; -using Robust.Shared.Maths; - -namespace Robust.Client.GameObjects -{ - internal class GodotTransformComponent : TransformComponent, IGodotTransformComponent - { - public Godot.Node2D SceneNode { get; private set; } - - IGodotTransformComponent IGodotTransformComponent.Parent => (IGodotTransformComponent)Parent; - - private bool visibleWhileParented; - - [Dependency] private readonly ISceneTreeHolder _sceneTreeHolder; - - public override bool VisibleWhileParented - { - get => visibleWhileParented; - set - { - visibleWhileParented = value; - UpdateSceneVisibility(); - } - } - - protected override void SetPosition(Vector2 position) - { - base.SetPosition(position); - SceneNode.Position = (position * EyeManager.PIXELSPERMETER * new Vector2(1, -1)).Rounded().Convert(); - } - - protected override void SetRotation(Angle rotation) - { - base.SetRotation(rotation); - SceneNode.Rotation = -(float) rotation + MathHelper.PiOver2; - } - - private void UpdateSceneVisibility() - { - SceneNode.Visible = VisibleWhileParented || IsMapTransform; - } - - public override void AttachParent(ITransformComponent parent) - { - if (parent == null) - { - return; - } - - base.AttachParent(parent); - SceneNode.GetParent().RemoveChild(SceneNode); - ((IGodotTransformComponent)parent).SceneNode.AddChild(SceneNode); - UpdateSceneVisibility(); - } - - public override void DetachParent() - { - if (Parent == null) - { - return; - } - - ((IGodotTransformComponent)Parent)?.SceneNode?.RemoveChild(SceneNode); - base.DetachParent(); - _sceneTreeHolder.WorldRoot.AddChild(SceneNode); - UpdateSceneVisibility(); - } - - public override void OnAdd() - { - base.OnAdd(); - SceneNode = new Godot.Node2D - { - Name = $"Transform {Owner.Uid} ({Owner.Name})", - Rotation = MathHelper.PiOver2 - }; - _sceneTreeHolder.WorldRoot.AddChild(SceneNode); - } - - public override void OnRemove() - { - base.OnRemove(); - - foreach (var child in SceneNode.GetChildren()) - { - SceneNode.RemoveChild((Godot.Node)child); - } - - SceneNode.QueueFree(); - SceneNode.Dispose(); - SceneNode = null; - } - } -} diff --git a/Robust.Client/GameObjects/EntitySystems/AudioSystem.cs b/Robust.Client/GameObjects/EntitySystems/AudioSystem.cs index a4d37ca64..c5a8ce8c1 100644 --- a/Robust.Client/GameObjects/EntitySystems/AudioSystem.cs +++ b/Robust.Client/GameObjects/EntitySystems/AudioSystem.cs @@ -1,7 +1,5 @@ using Robust.Client.Audio; -using Robust.Client.Graphics.ClientEye; using Robust.Client.Interfaces; -using Robust.Client.Interfaces.GameObjects.Components; using Robust.Client.Interfaces.ResourceManagement; using Robust.Client.ResourceManagement; using Robust.Shared.Audio; @@ -12,7 +10,6 @@ using Robust.Shared.Interfaces.Network; using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Client.Interfaces.Graphics; -using Robust.Client.Utility; using Robust.Shared.Interfaces.Map; using Robust.Shared.Map; using Robust.Shared.Utility; @@ -23,17 +20,11 @@ namespace Robust.Client.GameObjects.EntitySystems { public class AudioSystem : EntitySystem { - [Dependency] private readonly ISceneTreeHolder sceneTree; [Dependency] private readonly IResourceCache resourceCache; [Dependency] private readonly IMapManager _mapManager; private IClyde _clyde; - private uint LastPlayKey; - - private readonly Dictionary PlayingGodotStreams = - new Dictionary(); - private readonly List PlayingClydeStreams = new List(); public override void Initialize() @@ -117,30 +108,7 @@ namespace Robust.Client.GameObjects.EntitySystems Source = source, }; PlayingClydeStreams.Add(playing); - return; } - - if (GameController.Mode != GameController.DisplayMode.Godot) - { - return; - } - - var player = new Godot.AudioStreamPlayer() - { - Stream = stream.GodotAudioStream, - Playing = true, - }; - if (audioParams != null) - { - var val = audioParams.Value; - player.Bus = val.BusName; - player.VolumeDb = val.Volume; - //player.PitchScale = val.PitchScale; - player.MixTarget = (Godot.AudioStreamPlayer.MixTargetEnum) val.MixTarget; - } - - sceneTree.WorldRoot.AddChild(player); - TrackGodotPlayer(player); } /// @@ -179,32 +147,7 @@ namespace Robust.Client.GameObjects.EntitySystems TrackingEntity = entity, }; PlayingClydeStreams.Add(playing); - return; } - - if (GameController.Mode != GameController.DisplayMode.Godot) - { - return; - } - - var parent = entity.GetComponent().SceneNode; - var player = new Godot.AudioStreamPlayer2D() - { - Stream = stream.GodotAudioStream, - Playing = true - }; - if (audioParams != null) - { - var val = audioParams.Value; - player.Bus = val.BusName; - player.VolumeDb = val.Volume; - //player.PitchScale = val.PitchScale; - player.Attenuation = val.Attenuation; - player.MaxDistance = EyeManager.PIXELSPERMETER * val.MaxDistance; - } - - parent.AddChild(player); - TrackGodotPlayer(player); } /// @@ -243,33 +186,7 @@ namespace Robust.Client.GameObjects.EntitySystems TrackingCoordinates = coordinates }; PlayingClydeStreams.Add(playing); - return; } - - if (GameController.Mode != GameController.DisplayMode.Godot) - { - return; - } - - var player = new Godot.AudioStreamPlayer2D() - { - Stream = stream.GodotAudioStream, - Playing = true, - // TODO: Handle grid and map of the coordinates. - Position = (coordinates.Position * EyeManager.PIXELSPERMETER).Convert() - }; - if (audioParams != null) - { - var val = audioParams.Value; - player.Bus = audioParams.Value.BusName; - player.VolumeDb = val.Volume; - //player.PitchScale = val.PitchScale; - player.Attenuation = val.Attenuation; - player.MaxDistance = EyeManager.PIXELSPERMETER * val.MaxDistance; - } - - sceneTree.WorldRoot.AddChild(player); - TrackGodotPlayer(player); } public override void HandleNetMessage(INetChannel channel, EntitySystemMessage message) @@ -311,35 +228,6 @@ namespace Robust.Client.GameObjects.EntitySystems } } - private void TrackGodotPlayer(Godot.Node player) - { - var key = LastPlayKey++; - var signal = new GodotGlue.GodotSignalSubscriber0(); - signal.Connect(player, "finished"); - signal.Signal += () => { CleanupAudioPlayer(key); }; - PlayingGodotStreams[key] = new PlayingGodotStream() - { - Player = player, - Signal = signal - }; - } - - private void CleanupAudioPlayer(uint key) - { - var stream = PlayingGodotStreams[key]; - stream.Signal.Disconnect(stream.Player, "finished"); - stream.Signal.Dispose(); - stream.Player.QueueFree(); - stream.Player.Dispose(); - PlayingGodotStreams.Remove(key); - } - - private struct PlayingGodotStream - { - public Godot.Node Player; - public GodotGlue.GodotSignalSubscriber0 Signal; - } - private class PlayingClydeStream { public IClydeAudioSource Source; diff --git a/Robust.Client/GameObjects/GodotComponentFactory.cs b/Robust.Client/GameObjects/GodotComponentFactory.cs deleted file mode 100644 index 0a7b65265..000000000 --- a/Robust.Client/GameObjects/GodotComponentFactory.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Robust.Client.Interfaces.GameObjects.Components; -using Robust.Shared.Interfaces.GameObjects.Components; - -namespace Robust.Client.GameObjects -{ - public class GodotComponentFactory : ClientComponentFactory - { - public GodotComponentFactory() : base() - { - Register(overwrite: true); - RegisterReference(); - RegisterReference(); - } - } -} diff --git a/Robust.Client/Graphics/ClientEye/Eye.cs b/Robust.Client/Graphics/ClientEye/Eye.cs index 84036f54f..3d7b07c60 100644 --- a/Robust.Client/Graphics/ClientEye/Eye.cs +++ b/Robust.Client/Graphics/ClientEye/Eye.cs @@ -10,7 +10,6 @@ namespace Robust.Client.Graphics.ClientEye public class Eye : IEye, IDisposable { protected IEyeManager eyeManager; - public Godot.Camera2D GodotCamera { get; private set; } private bool disposed = false; public bool Current @@ -34,19 +33,7 @@ namespace Robust.Client.Graphics.ClientEye } } - private Vector2 _zoom = Vector2.One; - public Vector2 Zoom - { - get => _zoom; - set - { - _zoom = value; - if (GameController.OnGodot) - { - GodotCamera.Zoom = value.Convert(); - } - } - } + public Vector2 Zoom { get; set; } = Vector2.One; private MapCoordinates _position; @@ -61,14 +48,6 @@ namespace Robust.Client.Graphics.ClientEye public Eye() { eyeManager = IoCManager.Resolve(); - if (GameController.OnGodot) - { - GodotCamera = new Godot.Camera2D() - { - DragMarginHEnabled = false, - DragMarginVEnabled = false, - }; - } } protected virtual void Dispose(bool disposing) @@ -80,14 +59,6 @@ namespace Robust.Client.Graphics.ClientEye Current = false; eyeManager = null; } - - if (!GameController.OnGodot) - { - return; - } - GodotCamera.QueueFree(); - GodotCamera.Dispose(); - GodotCamera = null; } public void Dispose() diff --git a/Robust.Client/Graphics/ClientEye/EyeManager.cs b/Robust.Client/Graphics/ClientEye/EyeManager.cs index ba04c6bbf..b7ee52411 100644 --- a/Robust.Client/Graphics/ClientEye/EyeManager.cs +++ b/Robust.Client/Graphics/ClientEye/EyeManager.cs @@ -32,24 +32,7 @@ namespace Robust.Client.Graphics.ClientEye return; } - if (GameController.OnGodot) - { - currentEye.GodotCamera.Current = false; - } - - if (value != null) - { - currentEye = value; - } - else - { - currentEye = defaultEye; - } - - if (GameController.OnGodot) - { - currentEye.GodotCamera.Current = true; - } + currentEye = value ?? defaultEye; } } @@ -76,11 +59,6 @@ namespace Robust.Client.Graphics.ClientEye { defaultEye = new FixedEye(); currentEye = defaultEye; - - if (GameController.OnGodot) - { - currentEye.GodotCamera.Current = true; - } } public void Dispose() diff --git a/Robust.Client/Graphics/ClientEye/FixedEye.cs b/Robust.Client/Graphics/ClientEye/FixedEye.cs index d1a9e5173..50665ba6a 100644 --- a/Robust.Client/Graphics/ClientEye/FixedEye.cs +++ b/Robust.Client/Graphics/ClientEye/FixedEye.cs @@ -1,41 +1,9 @@ -using Robust.Client.Interfaces; -using Robust.Client.Utility; -using Robust.Shared.IoC; -using Robust.Shared.Map; -using Robust.Shared.Maths; - -namespace Robust.Client.Graphics.ClientEye +namespace Robust.Client.Graphics.ClientEye { /// /// A fixed eye is an eye which is fixed to one point, its position. /// public class FixedEye : Eye { - public override MapCoordinates Position - { - get => base.Position; - internal set - { - if (GameController.OnGodot) - { - GodotCamera.Position = value.Position.Convert(); - } - - base.Position = value; - } - } - - private readonly ISceneTreeHolder sceneTree; - - public FixedEye() - { - if (!GameController.OnGodot) - { - return; - } - - sceneTree = IoCManager.Resolve(); - sceneTree.WorldRoot.AddChild(GodotCamera); - } } } diff --git a/Robust.Client/Graphics/DisplayManagerGodot.cs b/Robust.Client/Graphics/DisplayManagerGodot.cs deleted file mode 100644 index 6765a0fd8..000000000 --- a/Robust.Client/Graphics/DisplayManagerGodot.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using Robust.Client.GodotGlue; -using Robust.Client.Interfaces; -using Robust.Client.Interfaces.Graphics; -using Robust.Client.Utility; -using Robust.Shared.IoC; -using Robust.Shared.Maths; - -namespace Robust.Client.Graphics -{ - internal class DisplayManagerGodot : DisplayManager - { - [Dependency] private readonly ISceneTreeHolder _sceneTreeHolder; - - public override Vector2i ScreenSize => (Vector2i)Godot.OS.WindowSize.Convert(); - - private GodotSignalSubscriber0 _rootViewportSizeChangedSubscriber; - - public override void SetWindowTitle(string title) - { - Godot.OS.SetWindowTitle(title); - } - - public override void Initialize() - { - ReloadConfig(); - - _rootViewportSizeChangedSubscriber = new GodotSignalSubscriber0(); - _rootViewportSizeChangedSubscriber.Connect(_sceneTreeHolder.SceneTree.Root, "size_changed"); - _rootViewportSizeChangedSubscriber.Signal += () => - { - // TODO: Uh maybe send oldSize correctly here. - OnWindowResized?.Invoke(new WindowResizedEventArgs(Vector2i.Zero, ScreenSize)); - }; - } - - protected override void ReloadConfig() - { - base.ReloadConfig(); - - Godot.OS.VsyncEnabled = VSync; - Godot.OS.WindowFullscreen = WindowMode == WindowMode.Fullscreen; - } - - public override event Action OnWindowResized; - } -} diff --git a/Robust.Client/Graphics/Drawing/DrawingHandle.cs b/Robust.Client/Graphics/Drawing/DrawingHandle.cs index 82d71a8de..7400c3022 100644 --- a/Robust.Client/Graphics/Drawing/DrawingHandle.cs +++ b/Robust.Client/Graphics/Drawing/DrawingHandle.cs @@ -6,7 +6,6 @@ using Robust.Client.Utility; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Maths; using Robust.Shared.Utility; -using VS = Godot.VisualServer; namespace Robust.Client.Graphics.Drawing { @@ -15,21 +14,11 @@ namespace Robust.Client.Graphics.Drawing /// public abstract class DrawingHandle : IDisposable { - // Use RIDs in the theoretical case some nerd wants to draw something WITHOUT consulting the scene tree. - // Also it's probably faster or some shit. - - internal Godot.RID Item { get; } private protected IRenderHandle _renderHandle; private protected readonly int _handleId; public bool Disposed { get; private set; } public Color Modulate { get; set; } = Color.White; - internal DrawingHandle(Godot.RID item) - { - DebugTools.Assert(GameController.Mode == GameController.DisplayMode.Godot); - Item = item ?? throw new ArgumentNullException(nameof(item)); - } - internal DrawingHandle() { DebugTools.Assert(GameController.Mode == GameController.DisplayMode.Headless); @@ -58,26 +47,12 @@ namespace Robust.Client.Graphics.Drawing matrix.R1C2 += position.Y; _renderHandle.SetModelTransform(matrix, _handleId); } - else if (Item != null) - { - var transform = Godot.Transform2D.Identity.Rotated((float) rotation.Theta).Scaled(scale.Convert()); - SetTransform2DRotationAndScale(ref transform, rotation.Theta, scale); - transform.origin = position.Convert(); - VS.CanvasItemAddSetTransform(Item, transform); - } } public void SetTransform(in Matrix3 matrix) { CheckDisposed(); - if (_renderHandle != null) - { - _renderHandle.SetModelTransform(matrix, _handleId); - } - else if (Item != null) - { - VS.CanvasItemAddSetTransform(Item, matrix.Convert()); - } + _renderHandle?.SetModelTransform(matrix, _handleId); } internal void UseShader(Shader shader) @@ -86,13 +61,6 @@ namespace Robust.Client.Graphics.Drawing _renderHandle?.UseShader(shader, _handleId); } - // Effectively equivalent to Godot's internal Transform2D::set_rotation_and_scale defined in math_2d.h. - internal static void SetTransform2DRotationAndScale(ref Godot.Transform2D transform, double rot, Vector2 scale) - { - transform.x = new Godot.Vector2((float) Math.Cos(rot), (float) Math.Sin(rot)) * scale.X; - transform.y = new Godot.Vector2(-(float) Math.Sin(rot), (float) Math.Cos(rot)) * scale.Y; - } - protected void CheckDisposed() { if (Disposed) @@ -114,10 +82,6 @@ namespace Robust.Client.Graphics.Drawing { private const int PPM = EyeManager.PIXELSPERMETER; - internal DrawingHandleWorld(Godot.RID item) : base(item) - { - } - internal DrawingHandleWorld(IRenderHandle handle, int handleId) : base(handle, handleId) { } @@ -129,10 +93,7 @@ namespace Robust.Client.Graphics.Drawing public override void DrawCircle(Vector2 position, float radius, Color color) { CheckDisposed(); - if (Item != null) - { - VS.CanvasItemAddCircle(Item, ToPixelCoords(position), radius * PPM, (Modulate * color).Convert()); - } + // TODO: Implement this. } public override void DrawLine(Vector2 from, Vector2 to, Color color, float width = 1, bool antiAliased = false) @@ -142,11 +103,6 @@ namespace Robust.Client.Graphics.Drawing { _renderHandle.DrawLine(from, to, color, _handleId); } - else if (Item != null) - { - VS.CanvasItemAddLine(Item, ToPixelCoords(from), ToPixelCoords(to), (Modulate * color).Convert(), width, - antiAliased); - } } public override void DrawTexture(Texture texture, Vector2 position, Color? modulate = null, @@ -160,10 +116,6 @@ namespace Robust.Client.Graphics.Drawing _renderHandle.DrawTextureRect(texture, position, position + (texture.Size / (float) EyeManager.PIXELSPERMETER), actualModulate, null, _handleId); } - else if (Item != null) - { - texture.GodotTexture.Draw(Item, ToPixelCoords(position), actualModulate.Convert(), false, normalMap); - } } public void DrawTextureRect(Texture texture, Box2 rect, bool tile, Color? modulate = null, @@ -176,28 +128,16 @@ namespace Robust.Client.Graphics.Drawing _renderHandle.DrawTextureRect(texture, rect.BottomLeft, rect.TopRight, actualModulate, null, _handleId); } - else if (Item != null) - { - texture.GodotTexture.DrawRect(Item, ToPixelCoords(rect), tile, actualModulate.Convert(), transpose, - normalMap); - } } public void DrawRect(Box2 rect, Color color, bool filled = true) { CheckDisposed(); color *= Modulate; - if (filled) + if (filled && _renderHandle != null) { - if (_renderHandle != null) - { - _renderHandle.DrawTextureRect(Texture.White, rect.BottomLeft, rect.TopRight, color, null, - _handleId); - } - else if (Item != null) - { - VS.CanvasItemAddRect(Item, ToPixelCoords(rect), color.Convert()); - } + _renderHandle.DrawTextureRect(Texture.White, rect.BottomLeft, rect.TopRight, color, null, + _handleId); } else { @@ -207,24 +147,10 @@ namespace Robust.Client.Graphics.Drawing DrawLine(rect.BottomLeft, rect.TopLeft, color); } } - - private static Godot.Vector2 ToPixelCoords(Vector2 vec) - { - return (vec * new Vector2(1, -1) * PPM).Convert(); - } - - private static Godot.Rect2 ToPixelCoords(Box2 box) - { - return new Godot.Rect2(box.Left * PPM, -box.Top * PPM, box.Width * PPM, box.Height * PPM); - } } public sealed class DrawingHandleScreen : DrawingHandle { - internal DrawingHandleScreen(Godot.RID item) : base(item) - { - } - internal DrawingHandleScreen(IRenderHandle handle, int handleId) : base(handle, handleId) { } @@ -236,13 +162,8 @@ namespace Robust.Client.Graphics.Drawing public override void DrawCircle(Vector2 position, float radius, Color color) { - if (!GameController.OnGodot) - { - return; - } - CheckDisposed(); - VS.CanvasItemAddCircle(Item, position.Convert(), radius, (color * Modulate).Convert()); + // TODO: Implement this. } public void DrawStyleBox(StyleBox styleBox, UIBox2 box) @@ -253,14 +174,7 @@ namespace Robust.Client.Graphics.Drawing } CheckDisposed(); - if (GameController.OnGodot) - { - styleBox.GodotStyleBox.Draw(Item, box.Convert()); - } - else - { - styleBox.Draw(this, box); - } + styleBox.Draw(this, box); } public override void DrawLine(Vector2 from, Vector2 to, Color color, float width = 1, bool antiAliased = false) @@ -270,28 +184,16 @@ namespace Robust.Client.Graphics.Drawing { _renderHandle.DrawLine(from, to, color, _handleId); } - else if (Item != null) - { - VS.CanvasItemAddLine(Item, from.Convert(), to.Convert(), (Modulate * color).Convert(), width, - antiAliased); - } } public void DrawRect(UIBox2 rect, Color color, bool filled = true) { CheckDisposed(); color *= Modulate; - if (filled) + if (filled && _renderHandle != null) { - if (_renderHandle != null) - { _renderHandle.DrawTextureRect(Texture.White, rect.TopLeft, rect.BottomRight, color, null, _handleId); - } - else if (Item != null) - { - VS.CanvasItemAddRect(Item, rect.Convert(), color.Convert()); - } } else { @@ -309,15 +211,8 @@ namespace Robust.Client.Graphics.Drawing var actualModulate = (modulate ?? Color.White) * Modulate; - if (_renderHandle != null) - { - _renderHandle.DrawTextureRect(texture, position, position + texture.Size, actualModulate, null, - _handleId); - } - else if (Item != null) - { - texture.GodotTexture.Draw(Item, position.Convert(), actualModulate.Convert(), false, normalMap); - } + _renderHandle?.DrawTextureRect(texture, position, position + texture.Size, actualModulate, null, + _handleId); } public void DrawTextureRect(Texture texture, UIBox2 rect, bool tile, Color? modulate = null, @@ -325,30 +220,15 @@ namespace Robust.Client.Graphics.Drawing { CheckDisposed(); var actualModulate = (modulate ?? Color.White) * Modulate; - if (_renderHandle != null) - { - _renderHandle.DrawTextureRect(texture, rect.TopLeft, rect.BottomRight, actualModulate, null, _handleId); - } - else if (Item != null) - { - texture.GodotTexture.DrawRect(Item, rect.Convert(), tile, actualModulate.Convert(), transpose, - normalMap); - } + _renderHandle?.DrawTextureRect(texture, rect.TopLeft, rect.BottomRight, actualModulate, null, _handleId); } public void DrawTextureRectRegion(Texture texture, UIBox2 rect, UIBox2 subRegion, Color? modulate = null) { CheckDisposed(); var actualModulate = (modulate ?? Color.White) * Modulate; - if (_renderHandle != null) - { - _renderHandle.DrawTextureRect(texture, rect.TopLeft, rect.BottomRight, actualModulate, subRegion, - _handleId); - } - else if (Item != null) - { - texture.GodotTexture.DrawRect(Item, rect.Convert(), false, actualModulate.Convert()); - } + _renderHandle?.DrawTextureRect(texture, rect.TopLeft, rect.BottomRight, actualModulate, subRegion, + _handleId); } public void SetScissor(in UIBox2i? scissorBox) diff --git a/Robust.Client/Graphics/Drawing/StyleBox.cs b/Robust.Client/Graphics/Drawing/StyleBox.cs index 7c772f42f..21f1bfb05 100644 --- a/Robust.Client/Graphics/Drawing/StyleBox.cs +++ b/Robust.Client/Graphics/Drawing/StyleBox.cs @@ -12,8 +12,6 @@ namespace Robust.Client.Graphics.Drawing [PublicAPI] public abstract class StyleBox { - internal abstract Godot.StyleBox GodotStyleBox { get; } - public Vector2 MinimumSize => new Vector2(GetContentMargin(Margin.Left) + GetContentMargin(Margin.Right), GetContentMargin(Margin.Top) + GetContentMargin(Margin.Bottom)); @@ -25,21 +23,7 @@ namespace Robust.Client.Graphics.Drawing public float? ContentMarginLeftOverride { - get - { - if (!GameController.OnGodot) - { - return _contentMarginLeft; - } - - var c = GodotStyleBox.ContentMarginLeft; - if (c < 0) - { - return null; - } - - return c; - } + get => _contentMarginLeft; set { if (value < 0) @@ -47,34 +31,13 @@ namespace Robust.Client.Graphics.Drawing throw new ArgumentOutOfRangeException(nameof(value), value, "Value cannot be less than zero."); } - if (GameController.OnGodot) - { - GodotStyleBox.ContentMarginLeft = value ?? -1; - } - else - { - _contentMarginLeft = value; - } + _contentMarginLeft = value; } } public float? ContentMarginTopOverride { - get - { - if (!GameController.OnGodot) - { - return _contentMarginTop; - } - - var c = GodotStyleBox.ContentMarginTop; - if (c < 0) - { - return null; - } - - return c; - } + get => _contentMarginTop; set { if (value < 0) @@ -82,34 +45,13 @@ namespace Robust.Client.Graphics.Drawing throw new ArgumentOutOfRangeException(nameof(value), value, "Value cannot be less than zero."); } - if (GameController.OnGodot) - { - GodotStyleBox.ContentMarginTop = value ?? -1; - } - else - { - _contentMarginTop = value; - } + _contentMarginTop = value; } } public float? ContentMarginRightOverride { - get - { - if (!GameController.OnGodot) - { - return _contentMarginRight; - } - - var c = GodotStyleBox.ContentMarginRight; - if (c < 0) - { - return null; - } - - return c; - } + get => _contentMarginRight; set { if (value < 0) @@ -117,34 +59,13 @@ namespace Robust.Client.Graphics.Drawing throw new ArgumentOutOfRangeException(nameof(value), value, "Value cannot be less than zero."); } - if (GameController.OnGodot) - { - GodotStyleBox.ContentMarginRight = value ?? -1; - } - else - { - _contentMarginRight = value; - } + _contentMarginRight = value; } } public float? ContentMarginBottomOverride { - get - { - if (!GameController.OnGodot) - { - return _contentMarginBottom; - } - - var c = GodotStyleBox.ContentMarginBottom; - if (c < 0) - { - return null; - } - - return c; - } + get => _contentMarginBottom; set { if (value < 0) @@ -152,36 +73,17 @@ namespace Robust.Client.Graphics.Drawing throw new ArgumentOutOfRangeException(nameof(value), value, "Value cannot be less than zero."); } - if (GameController.OnGodot) - { - GodotStyleBox.ContentMarginBottom = value ?? -1; - } - else - { - _contentMarginBottom = value; - } + _contentMarginBottom = value; } } public void Draw(DrawingHandleScreen handle, UIBox2 box) { - if (GameController.OnGodot) - { - GodotStyleBox.Draw(handle.Item, box.Convert()); - } - else - { - DoDraw(handle, box); - } + DoDraw(handle, box); } public float GetContentMargin(Margin margin) { - if (GameController.OnGodot) - { - return GodotStyleBox.GetMargin((Godot.Margin) margin); - } - float? marginData; switch (margin) { @@ -301,23 +203,14 @@ namespace Robust.Client.Graphics.Drawing /// public class StyleBoxTexture : StyleBox { - private readonly Godot.StyleBoxTexture gdStyleBox; - internal override Godot.StyleBox GodotStyleBox => gdStyleBox; - public StyleBoxTexture() { - if (!GameController.OnGodot) - { - return; - } - - gdStyleBox = new Godot.StyleBoxTexture(); } /// /// Clones a stylebox so it can be separately modified. /// - public StyleBoxTexture(StyleBoxTexture copy) : this() + public StyleBoxTexture(StyleBoxTexture copy) { PatchMarginTop = copy.PatchMarginTop; PatchMarginLeft = copy.PatchMarginLeft; @@ -327,80 +220,19 @@ namespace Robust.Client.Graphics.Drawing Modulate = copy.Modulate; } - private float _expandMarginLeft; - private float _expandMarginRight; - private float _expandMarginTop; - private float _expandMarginBottom; + public float ExpandMarginLeft { get; set; } - public float ExpandMarginLeft - { - get => GameController.OnGodot ? gdStyleBox.ExpandMarginLeft : _expandMarginLeft; - set - { - if (GameController.OnGodot) - { - gdStyleBox.ExpandMarginLeft = value; - } - else - { - _expandMarginLeft = value; - } - } - } + public float ExpandMarginTop { get; set; } - public float ExpandMarginTop - { - get => GameController.OnGodot ? gdStyleBox.ExpandMarginTop : _expandMarginTop; - set - { - if (GameController.OnGodot) - { - gdStyleBox.ExpandMarginTop = value; - } - else - { - _expandMarginTop = value; - } - } - } + public float ExpandMarginBottom { get; set; } - public float ExpandMarginBottom - { - get => GameController.OnGodot ? gdStyleBox.ExpandMarginBottom : _expandMarginBottom; - set - { - if (GameController.OnGodot) - { - gdStyleBox.ExpandMarginBottom = value; - } - else - { - _expandMarginBottom = value; - } - } - } - - public float ExpandMarginRight - { - get => GameController.OnGodot ? gdStyleBox.ExpandMarginRight : _expandMarginRight; - set - { - if (GameController.OnGodot) - { - gdStyleBox.ExpandMarginRight = value; - } - else - { - _expandMarginRight = value; - } - } - } + public float ExpandMarginRight { get; set; } private float _patchMarginLeft; public float PatchMarginLeft { - get => GameController.OnGodot ? gdStyleBox.MarginLeft : _patchMarginLeft; + get => _patchMarginLeft; set { if (value < 0) @@ -408,14 +240,7 @@ namespace Robust.Client.Graphics.Drawing throw new ArgumentOutOfRangeException(nameof(value), value, "Value cannot be less than zero."); } - if (GameController.OnGodot) - { - gdStyleBox.MarginLeft = value; - } - else - { - _patchMarginLeft = value; - } + _patchMarginLeft = value; } } @@ -423,7 +248,7 @@ namespace Robust.Client.Graphics.Drawing public float PatchMarginRight { - get => GameController.OnGodot ? gdStyleBox.MarginRight : _patchMarginRight; + get => _patchMarginRight; set { if (value < 0) @@ -431,14 +256,7 @@ namespace Robust.Client.Graphics.Drawing throw new ArgumentOutOfRangeException(nameof(value), value, "Value cannot be less than zero."); } - if (GameController.OnGodot) - { - gdStyleBox.MarginRight = value; - } - else - { - _patchMarginRight = value; - } + _patchMarginRight = value; } } @@ -446,7 +264,7 @@ namespace Robust.Client.Graphics.Drawing public float PatchMarginTop { - get => GameController.OnGodot ? gdStyleBox.MarginTop : _patchMarginTop; + get => _patchMarginTop; set { if (value < 0) @@ -454,14 +272,7 @@ namespace Robust.Client.Graphics.Drawing throw new ArgumentOutOfRangeException(nameof(value), value, "Value cannot be less than zero."); } - if (GameController.OnGodot) - { - gdStyleBox.MarginTop = value; - } - else - { - _patchMarginTop = value; - } + _patchMarginTop = value; } } @@ -469,7 +280,7 @@ namespace Robust.Client.Graphics.Drawing public float PatchMarginBottom { - get => GameController.OnGodot ? gdStyleBox.MarginBottom : _patchMarginBottom; + get => _patchMarginBottom; set { if (value < 0) @@ -477,53 +288,13 @@ namespace Robust.Client.Graphics.Drawing throw new ArgumentOutOfRangeException(nameof(value), value, "Value cannot be less than zero."); } - if (GameController.OnGodot) - { - gdStyleBox.MarginBottom = value; - } - else - { - _patchMarginBottom = value; - } + _patchMarginBottom = value; } } - private Color _modulate = Color.White; + public Color Modulate { get; set; } = Color.White; - public Color Modulate - { - get => GameController.OnGodot ? gdStyleBox.ModulateColor.Convert() : _modulate; - set - { - if (GameController.OnGodot) - { - gdStyleBox.ModulateColor = value.Convert(); - } - else - { - _modulate = value; - } - } - } - - private Texture _texture; - - public Texture Texture - { - // In Godot 3.0, StyleBoxTexture.Texture is a plain resource. - // So we need this cast. - // ReSharper disable once RedundantCast - get => _texture ?? (GameController.OnGodot ? new GodotTextureSource((Godot.Texture)gdStyleBox.Texture) : null); - // Woo implicit casts. - set - { - _texture = value; - if (GameController.OnGodot) - { - gdStyleBox.Texture = value; - } - } - } + public Texture Texture { get; set; } [Obsolete("Use SetPatchMargin")] public void SetMargin(Margin margin, float value) @@ -592,7 +363,7 @@ namespace Robust.Client.Graphics.Drawing // Draw top left var topLeftBox = new UIBox2(0, 0, PatchMarginLeft, PatchMarginTop) .Translated(box.TopLeft); - handle.DrawTextureRectRegion(_texture, topLeftBox, + handle.DrawTextureRectRegion(Texture, topLeftBox, new UIBox2(0, 0, PatchMarginLeft, PatchMarginTop), Modulate); } @@ -601,7 +372,7 @@ namespace Robust.Client.Graphics.Drawing var leftBox = new UIBox2(0, PatchMarginTop, PatchMarginLeft, box.Height - PatchMarginBottom) .Translated(box.TopLeft); - handle.DrawTextureRectRegion(_texture, leftBox, + handle.DrawTextureRectRegion(Texture, leftBox, new UIBox2(0, PatchMarginTop, PatchMarginLeft, Texture.Height - PatchMarginBottom), Modulate); } @@ -611,7 +382,7 @@ namespace Robust.Client.Graphics.Drawing var bottomLeftBox = new UIBox2(0, box.Height - PatchMarginBottom, PatchMarginLeft, box.Height) .Translated(box.TopLeft); - handle.DrawTextureRectRegion(_texture, bottomLeftBox, + handle.DrawTextureRectRegion(Texture, bottomLeftBox, new UIBox2(0, Texture.Height - PatchMarginBottom, PatchMarginLeft, Texture.Height), Modulate); } } @@ -623,7 +394,7 @@ namespace Robust.Client.Graphics.Drawing // Draw top right var topRightBox = new UIBox2(box.Width - PatchMarginRight, 0, box.Width, PatchMarginTop) .Translated(box.TopLeft); - handle.DrawTextureRectRegion(_texture, topRightBox, + handle.DrawTextureRectRegion(Texture, topRightBox, new UIBox2(Texture.Width - PatchMarginRight, 0, Texture.Width, PatchMarginTop), Modulate); } @@ -633,7 +404,7 @@ namespace Robust.Client.Graphics.Drawing new UIBox2(box.Width - PatchMarginRight, PatchMarginTop, box.Width, box.Height - PatchMarginBottom) .Translated(box.TopLeft); - handle.DrawTextureRectRegion(_texture, rightBox, + handle.DrawTextureRectRegion(Texture, rightBox, new UIBox2(Texture.Width - PatchMarginRight, PatchMarginTop, Texture.Width, Texture.Height - PatchMarginBottom), Modulate); } @@ -644,7 +415,7 @@ namespace Robust.Client.Graphics.Drawing var bottomRightBox = new UIBox2(box.Width - PatchMarginRight, box.Height - PatchMarginBottom, box.Width, box.Height) .Translated(box.TopLeft); - handle.DrawTextureRectRegion(_texture, bottomRightBox, + handle.DrawTextureRectRegion(Texture, bottomRightBox, new UIBox2(Texture.Width - PatchMarginRight, Texture.Height - PatchMarginBottom, Texture.Width, Texture.Height), Modulate); } @@ -656,7 +427,7 @@ namespace Robust.Client.Graphics.Drawing var topBox = new UIBox2(PatchMarginLeft, 0, box.Width - PatchMarginRight, PatchMarginTop) .Translated(box.TopLeft); - handle.DrawTextureRectRegion(_texture, topBox, + handle.DrawTextureRectRegion(Texture, topBox, new UIBox2(PatchMarginLeft, 0, Texture.Width - PatchMarginRight, PatchMarginTop), Modulate); } @@ -667,7 +438,7 @@ namespace Robust.Client.Graphics.Drawing new UIBox2(PatchMarginLeft, box.Height - PatchMarginBottom, box.Width - PatchMarginRight, box.Height) .Translated(box.TopLeft); - handle.DrawTextureRectRegion(_texture, bottomBox, + handle.DrawTextureRectRegion(Texture, bottomBox, new UIBox2(PatchMarginLeft, Texture.Height - PatchMarginBottom, Texture.Width - PatchMarginRight, Texture.Height), Modulate); } @@ -677,7 +448,7 @@ namespace Robust.Client.Graphics.Drawing var centerBox = new UIBox2(PatchMarginLeft, PatchMarginTop, box.Width - PatchMarginRight, box.Height - PatchMarginBottom).Translated(box.TopLeft); - handle.DrawTextureRectRegion(_texture, centerBox, + handle.DrawTextureRectRegion(Texture, centerBox, new UIBox2(PatchMarginLeft, PatchMarginTop, Texture.Width - PatchMarginRight, Texture.Height - PatchMarginBottom), Modulate); } @@ -703,73 +474,19 @@ namespace Robust.Client.Graphics.Drawing public class StyleBoxFlat : StyleBox { - private Color _backgroundColor; - - public Color BackgroundColor - { - get => GameController.OnGodot ? stylebox.BgColor.Convert() : _backgroundColor; - set - { - if (GameController.OnGodot) - { - stylebox.BgColor = value.Convert(); - } - else - { - _backgroundColor = value; - } - } - } - - private readonly Godot.StyleBoxFlat stylebox; - internal override Godot.StyleBox GodotStyleBox => stylebox; - - public StyleBoxFlat() - { - if (GameController.OnGodot) - { - stylebox = new Godot.StyleBoxFlat(); - } - } + public Color BackgroundColor { get; set; } protected override void DoDraw(DrawingHandleScreen handle, UIBox2 box) { - handle.DrawRect(box, _backgroundColor); + handle.DrawRect(box, BackgroundColor); } } public class StyleBoxEmpty : StyleBox { - internal override Godot.StyleBox GodotStyleBox { get; } - - public StyleBoxEmpty() - { - if (!GameController.OnGodot) - { - return; - } - - GodotStyleBox = new Godot.StyleBoxEmpty(); - } - protected override void DoDraw(DrawingHandleScreen handle, UIBox2 box) { // It's empty what more do you want? } } - - internal class GodotStyleBoxWrap : StyleBox - { - public GodotStyleBoxWrap(Godot.StyleBox godotStyleBox) - { - GodotStyleBox = godotStyleBox; - } - - internal override Godot.StyleBox GodotStyleBox { get; } - - protected override void DoDraw(DrawingHandleScreen handle, UIBox2 box) - { - throw new NotImplementedException(); - } - } } diff --git a/Robust.Client/Graphics/Font.cs b/Robust.Client/Graphics/Font.cs index ee97209a5..1e68e2a14 100644 --- a/Robust.Client/Graphics/Font.cs +++ b/Robust.Client/Graphics/Font.cs @@ -14,22 +14,20 @@ namespace Robust.Client.Graphics /// public abstract class Font { - internal abstract Godot.Font GodotFont { get; } - /// /// The maximum amount a glyph goes above the baseline. /// - public virtual int Ascent => (int?)GodotFont?.GetAscent() ?? default; + public virtual int Ascent => default; /// /// The maximum glyph height of a line of text, not relative to the baseline. /// - public virtual int Height => (int?)GodotFont?.GetHeight() ?? default; + public virtual int Height => default; /// /// The maximum amount a glyph drops below the baseline. /// - public virtual int Descent => (int?)GodotFont?.GetDescent() ?? default; + public virtual int Descent => default; /// /// The distance between the baselines of two consecutive lines. @@ -42,11 +40,6 @@ namespace Robust.Client.Graphics /// public int LineSeparation => LineHeight - Height; - public static implicit operator Godot.Font(Font font) - { - return font?.GodotFont; - } - // Yes, I am aware that using char is bad. // At the same time the font system is nowhere close to rendering Unicode so... /// @@ -97,10 +90,6 @@ namespace Robust.Client.Graphics { public int Size { get; } - internal override Godot.Font GodotFont => _font; - - private readonly Godot.DynamicFont _font; - internal IFontInstanceHandle Handle { get; } public override int Ascent => Handle?.Ascent ?? base.Ascent; @@ -111,24 +100,11 @@ namespace Robust.Client.Graphics public VectorFont(FontResource res, int size) { Size = size; - if (GameController.OnGodot) - { - _font = new Godot.DynamicFont - { - FontData = res.FontData, - Size = size, - }; - } - else - { - Handle = IoCManager.Resolve().MakeInstance(res.FontFaceHandle, size); - } + Handle = IoCManager.Resolve().MakeInstance(res.FontFaceHandle, size); } public override float DrawChar(DrawingHandleScreen handle, char chr, Vector2 baseline, Color color) { - DebugTools.Assert(!GameController.OnGodot); - var metrics = Handle.GetCharMetrics(chr); if (!metrics.HasValue) { @@ -154,13 +130,6 @@ namespace Robust.Client.Graphics internal sealed class GodotWrapFont : Font { - public GodotWrapFont(Godot.Font godotFont) - { - GodotFont = godotFont; - } - - internal override Godot.Font GodotFont { get; } - public override float DrawChar(DrawingHandleScreen handle, char chr, Vector2 baseline, Color color) { throw new NotImplementedException(); @@ -174,7 +143,6 @@ namespace Robust.Client.Graphics public sealed class DummyFont : Font { - internal override Godot.Font GodotFont => null; public override float DrawChar(DrawingHandleScreen handle, char chr, Vector2 baseline, Color color) { // Nada, it's a dummy after all. diff --git a/Robust.Client/Graphics/Lighting/LightManager.Light.cs b/Robust.Client/Graphics/Lighting/LightManager.Light.cs index 0c51e6285..c48127bec 100644 --- a/Robust.Client/Graphics/Lighting/LightManager.Light.cs +++ b/Robust.Client/Graphics/Lighting/LightManager.Light.cs @@ -15,25 +15,17 @@ namespace Robust.Client.Graphics.Lighting { public Vector2 Offset { - get => GameController.OnGodot ? Light2D.Offset.Convert() : default; + get => default; set { - if (GameController.OnGodot) - { - Light2D.Offset = value.Convert(); - } } } public Angle Rotation { - get => GameController.OnGodot ? new Angle(Light2D.GlobalRotation) : default; + get => default; set { - if (GameController.OnGodot) - { - Light2D.GlobalRotation = (float) value.Theta; - } } } @@ -50,11 +42,6 @@ namespace Robust.Client.Graphics.Lighting } color = value; - - if (GameController.OnGodot) - { - Light2D.Color = value.Convert(); - } } } @@ -71,11 +58,6 @@ namespace Robust.Client.Graphics.Lighting } textureScale = value; - - if (GameController.OnGodot) - { - Light2D.TextureScale = value; - } } } @@ -92,10 +74,6 @@ namespace Robust.Client.Graphics.Lighting } energy = value; - if (GameController.OnGodot) - { - Light2D.Energy = value; - } } } @@ -133,10 +111,6 @@ namespace Robust.Client.Graphics.Lighting } texture = value; - if (GameController.OnGodot) - { - Light2D.Texture = value; - } } } @@ -156,74 +130,22 @@ namespace Robust.Client.Graphics.Lighting private LightManager Manager; private LightingSystem System => Manager.System; - private Godot.Light2D Light2D; - private IGodotTransformComponent parentTransform; - private Godot.Vector2 CurrentPos; public Light(LightManager manager) { Manager = manager; - if (GameController.OnGodot) - { - Light2D = new Godot.Light2D() - { - // TODO: Allow this to be modified. - ShadowEnabled = true, - ShadowFilter = Godot.Light2D.ShadowFilterEnum.Pcf5, - }; - - if (Manager.System == LightingSystem.Disabled) - { - Light2D.Enabled = Light2D.Visible = false; - } - } - Mode = new LightModeConstant(); Mode.Start(this); - - if (GameController.OnGodot && System == LightingSystem.Deferred) - { - Manager.deferredViewport.AddChild(Light2D); - } } public void DeParent() { - if (GameController.OnGodot) - { - if (System == LightingSystem.Deferred) - { - Light2D.Position = new Godot.Vector2(0, 0); - } - else - { - parentTransform.SceneNode.RemoveChild(Light2D); - } - } - UpdateEnabled(); } public void ParentTo(ITransformComponent node) { - if (!GameController.OnGodot) - { - return; - } - - if (System != LightingSystem.Deferred) - { - if (parentTransform != null) - { - DeParent(); - } - - ((IGodotTransformComponent) node).SceneNode.AddChild(Light2D); - } - - parentTransform = (IGodotTransformComponent) node; - UpdateEnabled(); } public void Dispose() @@ -238,14 +160,6 @@ namespace Robust.Client.Graphics.Lighting Manager.RemoveLight(this); Disposed = true; - - if (!GameController.OnGodot) - { - return; - } - - Light2D.QueueFree(); - Light2D.Dispose(); } private static ILightMode GetModeInstance(LightModeClass modeClass) @@ -262,26 +176,10 @@ namespace Robust.Client.Graphics.Lighting public void UpdateEnabled() { - if (GameController.OnGodot) - { - Light2D.Visible = Enabled && Manager.Enabled && parentTransform != null; - } } public void FrameProcess(FrameEventArgs args) { -// TODO: Maybe use OnMove events to make this less expensive. - if (!GameController.OnGodot || Manager.System != LightingSystem.Deferred || - parentTransform == null) - { - return; - } - - var newpos = parentTransform.SceneNode.GlobalPosition; - if (CurrentPos != newpos) - { - Light2D.Position = newpos; - } } } } diff --git a/Robust.Client/Graphics/Lighting/LightManager.Occluder.cs b/Robust.Client/Graphics/Lighting/LightManager.Occluder.cs index 273d44480..7d8d9f773 100644 --- a/Robust.Client/Graphics/Lighting/LightManager.Occluder.cs +++ b/Robust.Client/Graphics/Lighting/LightManager.Occluder.cs @@ -28,46 +28,19 @@ namespace Robust.Client.Graphics.Lighting private LightManager Manager; - private Godot.OccluderPolygon2D occluderPolygon; - private Godot.LightOccluder2D occluder; - private bool Deferred => Manager.System == LightingSystem.Deferred; public OccluderCullMode CullMode { - get => GameController.OnGodot ? (OccluderCullMode) occluderPolygon.CullMode : default; + get => default; set { - if (GameController.OnGodot) - { - occluderPolygon.CullMode = (Godot.OccluderPolygon2D.CullModeEnum) value; - } } } - - private IGodotTransformComponent parentTransform; - private Godot.Vector2 CurrentPos; - public Occluder(LightManager manager) { Manager = manager; - - if (!GameController.OnGodot) - { - return; - } - - occluderPolygon = new Godot.OccluderPolygon2D(); - occluder = new Godot.LightOccluder2D() - { - Occluder = occluderPolygon, - }; - - if (Deferred) - { - Manager.deferredViewport.AddChild(occluder); - } } public void Dispose() @@ -80,94 +53,27 @@ namespace Robust.Client.Graphics.Lighting Manager.RemoveOccluder(this); Disposed = true; - - if (!GameController.OnGodot) - { - return; - } - - occluder.QueueFree(); - occluder.Dispose(); - - occluderPolygon.Dispose(); } public void SetPolygon(Vector2[] polygon) { - if (!GameController.OnGodot) - { - return; - } - - var converted = new Godot.Vector2[polygon.Length]; - for (var i = 0; i < polygon.Length; i++) - { - converted[i] = polygon[i].Convert(); - } - - occluderPolygon.Polygon = converted; } public void DeParent() { - if (!GameController.OnGodot) - { - return; - } - - if (Deferred) - { - occluder.Position = new Godot.Vector2(0, 0); - } - else - { - parentTransform.SceneNode.RemoveChild(occluder); - } - - UpdateEnabled(); } public void ParentTo(ITransformComponent node) { - if (!GameController.OnGodot) - { - return; - } - - if (!Deferred) - { - ((IGodotTransformComponent) node).SceneNode.AddChild(occluder); - } - - parentTransform = (IGodotTransformComponent) node; - UpdateEnabled(); } private void UpdateEnabled() { - if (GameController.OnGodot) - { - occluder.Visible = parentTransform != null && Enabled; - } } public void FrameProcess(FrameEventArgs args) { - if (!GameController.OnGodot) - { - return; - } - - // TODO: Maybe use OnMove events to make this less expensive. - if (Deferred && parentTransform != null) - { - var newPos = parentTransform.SceneNode.GlobalPosition; - if (CurrentPos != newPos) - { - occluder.Position = newPos; - } - } } } } diff --git a/Robust.Client/Graphics/Lighting/LightManager.cs b/Robust.Client/Graphics/Lighting/LightManager.cs index 52b268a21..e45858c4a 100644 --- a/Robust.Client/Graphics/Lighting/LightManager.cs +++ b/Robust.Client/Graphics/Lighting/LightManager.cs @@ -24,7 +24,6 @@ namespace Robust.Client.Graphics.Lighting { public sealed partial class LightManager : ILightManager, IDisposable, IPostInjectInit { - [Dependency] readonly ISceneTreeHolder sceneTreeHolder; [Dependency] readonly IConfigurationManager configManager; [Dependency] readonly IResourceCache resourceCache; @@ -41,7 +40,6 @@ namespace Robust.Client.Graphics.Lighting } enabled = value; - UpdateEnabled(); } } @@ -50,14 +48,6 @@ namespace Robust.Client.Graphics.Lighting private LightingSystem System = LightingSystem.Normal; - private Godot.CanvasModulate canvasModulate; - private Godot.Viewport rootViewport; - private Godot.Viewport deferredViewport; - private Godot.CanvasLayer deferredMaskLayer; - private Godot.Sprite deferredMaskBackground; - private Godot.Sprite deferredMaskSprite; - private GodotGlue.GodotSignalSubscriber0 deferredSizeChangedSubscriber; - private bool disposed = false; public void PostInject() @@ -69,97 +59,8 @@ namespace Robust.Client.Graphics.Lighting public void Initialize() { System = configManager.GetCVar("display.lighting_system"); - if (!GameController.OnGodot) - { - return; - } - - canvasModulate = new Godot.CanvasModulate() - { - // Black - Color = new Godot.Color(0.1f, 0.1f, 0.1f), - Name = "LightingCanvasModulate" - }; - rootViewport = sceneTreeHolder.SceneTree.Root; - - if (System == LightingSystem.Deferred) - { - deferredViewport = new Godot.Viewport - { - Name = "LightingViewport", - RenderTargetUpdateMode = Godot.Viewport.UpdateMode.Always, - RenderTargetVFlip = true, - }; - deferredViewport.AddChild(canvasModulate); - rootViewport.AddChild(deferredViewport); - - var whiteTex = - resourceCache.GetResource(new ResourcePath(@"/Textures/Effects/Light/white.png")); - deferredMaskBackground = new Godot.Sprite() - { - Name = "DeferredMaskBackground", - Texture = whiteTex.Texture.GodotTexture, - Centered = false, - }; - deferredViewport.AddChild(deferredMaskBackground); - - deferredSizeChangedSubscriber = new GodotGlue.GodotSignalSubscriber0(); - deferredSizeChangedSubscriber.Connect(rootViewport, "size_changed"); - deferredSizeChangedSubscriber.Signal += OnWindowSizeChanged; - - deferredMaskLayer = new Godot.CanvasLayer() - { - Name = "LightingMaskLayer", - Layer = CanvasLayers.LAYER_DEFERRED_LIGHTING, - }; - rootViewport.AddChild(deferredMaskLayer); - - CreateDeferMaskSprite(); - OnWindowSizeChanged(); - } - else if (System == LightingSystem.Normal) - { - sceneTreeHolder.WorldRoot.AddChild(canvasModulate); - } } - - private void OnWindowSizeChanged() - { - if (System == LightingSystem.Deferred) - { - var size = sceneTreeHolder.SceneTree.Root.Size; - deferredViewport.Size = size; - deferredMaskBackground.Scale = size; - // Needs to be re-created because otherwise it seems to not acknowledge the updated texture size? - // Might be a better way to do this. - CreateDeferMaskSprite(); - } - } - - private void CreateDeferMaskSprite() - { - if (deferredMaskSprite != null) - { - deferredMaskSprite.QueueFree(); - deferredMaskSprite.Dispose(); - } - - var mat = new Godot.CanvasItemMaterial() - { - BlendMode = Godot.CanvasItemMaterial.BlendModeEnum.Mul - }; - deferredMaskSprite = new Godot.Sprite - { - Name = "LightingDeferMask", - Texture = deferredViewport.GetTexture(), - Centered = false, - Material = mat, - }; - deferredMaskLayer.AddChild(deferredMaskSprite); - } - - public void Dispose() { if (disposed) @@ -172,41 +73,6 @@ namespace Robust.Client.Graphics.Lighting { light.Dispose(); } - - if (!GameController.OnGodot) - { - return; - } - - if (System == LightingSystem.Deferred) - { - deferredSizeChangedSubscriber.Disconnect(rootViewport, "size_changed"); - deferredSizeChangedSubscriber.Dispose(); - deferredSizeChangedSubscriber = null; - } - - rootViewport = null; - - if (System == LightingSystem.Deferred) - { - deferredViewport.QueueFree(); - deferredViewport.Dispose(); - deferredViewport = null; - - deferredMaskLayer.QueueFree(); - deferredMaskLayer.Dispose(); - deferredMaskLayer = null; - - // These are implicitly freed by the other free calls. - deferredMaskBackground.Dispose(); - deferredMaskBackground = null; - deferredMaskSprite.Dispose(); - deferredMaskSprite = null; - } - - canvasModulate.QueueFree(); - canvasModulate.Dispose(); - canvasModulate = null; } public ILight MakeLight() @@ -240,33 +106,8 @@ namespace Robust.Client.Graphics.Lighting occluders.Remove(occluder); } - private void UpdateEnabled() - { - if (!GameController.OnGodot) - { - return; - } - if (System == LightingSystem.Deferred) - { - deferredMaskSprite.Visible = Enabled; - } - - foreach (var light in lights) - { - light.UpdateEnabled(); - } - } - public void FrameUpdate(RenderFrameEventArgs args) { - if (GameController.OnGodot && System == LightingSystem.Deferred) - { - var transform = rootViewport.CanvasTransform; - deferredViewport.CanvasTransform = transform; - deferredMaskBackground.Transform = transform.Inverse(); - deferredMaskBackground.Scale = rootViewport.Size; - } - foreach (var light in lights) { light.FrameProcess(args); diff --git a/Robust.Client/Graphics/Overlays/Overlay.cs b/Robust.Client/Graphics/Overlays/Overlay.cs index e8c953c49..674c0e7b5 100644 --- a/Robust.Client/Graphics/Overlays/Overlay.cs +++ b/Robust.Client/Graphics/Overlays/Overlay.cs @@ -7,7 +7,6 @@ using System.Collections.Generic; using JetBrains.Annotations; using Robust.Client.Graphics.Clyde; using Robust.Shared.Utility; -using VS = Godot.VisualServer; namespace Robust.Client.Graphics.Overlays { @@ -32,44 +31,14 @@ namespace Robust.Client.Graphics.Overlays private IRenderHandle _renderHandle; - private Shader _shader; + public Shader Shader { get; set; } - public Shader Shader - { - get => _shader; - set - { - _shader = value; - if (GameController.OnGodot && MainCanvasItem != null) - { - VS.CanvasItemSetMaterial(MainCanvasItem, value?.GodotMaterial?.GetRid()); - } - } - } - - private int? _zIndex; - public int? ZIndex - { - get => _zIndex; - set - { - if (value != null && (_zIndex > VS.CanvasItemZMax || _zIndex < VS.CanvasItemZMin)) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - - _zIndex = value; - UpdateZIndex(); - } - } + public int? ZIndex { get; set; } public virtual bool SubHandlesUseMainShader { get; } = true; private bool _isDirty = true; - private Godot.RID MainCanvasItem; - - private readonly List CanvasItems = new List(); private readonly List TempHandles = new List(); private bool Disposed; @@ -80,13 +49,6 @@ namespace Robust.Client.Graphics.Overlays ID = id; } - internal void AssignCanvasItem(Godot.RID canvasItem) - { - MainCanvasItem = canvasItem; - Shader?.ApplyToCanvasItem(MainCanvasItem); - UpdateZIndex(); - } - public void Dispose() { if (Disposed) @@ -106,7 +68,6 @@ namespace Robust.Client.Graphics.Overlays protected virtual void Dispose(bool disposing) { - ClearDraw(); } protected abstract void Draw(DrawingHandle handle); @@ -162,37 +123,6 @@ namespace Robust.Client.Graphics.Overlays return handle; } - case GameController.DisplayMode.Godot: - { - var item = VS.CanvasItemCreate(); - VS.CanvasItemSetParent(item, MainCanvasItem); - CanvasItems.Add(item); - if (shader != null) - { - shader.ApplyToCanvasItem(item); - } - else - { - VS.CanvasItemSetUseParentMaterial(item, SubHandlesUseMainShader); - } - - DrawingHandle handle; - switch (Space) - { - case OverlaySpace.ScreenSpaceBelowWorld: - case OverlaySpace.ScreenSpace: - handle = new DrawingHandleScreen(item); - break; - case OverlaySpace.WorldSpace: - handle = new DrawingHandleWorld(item); - break; - default: - throw new ArgumentOutOfRangeException(); - } - - TempHandles.Add(handle); - return handle; - } default: throw new ArgumentOutOfRangeException(); } @@ -205,42 +135,6 @@ namespace Robust.Client.Graphics.Overlays internal void FrameUpdate(RenderFrameEventArgs args) { - if (!IsDirty || !GameController.OnGodot) - { - return; - } - - ClearDraw(); - - try - { - Drawing = true; - DrawingHandle handle; - switch (Space) - { - case OverlaySpace.ScreenSpaceBelowWorld: - case OverlaySpace.ScreenSpace: - handle = new DrawingHandleScreen(MainCanvasItem); - break; - case OverlaySpace.WorldSpace: - handle = new DrawingHandleWorld(MainCanvasItem); - break; - default: - throw new ArgumentOutOfRangeException(); - } - - Draw(handle); - } - finally - { - Drawing = false; - foreach (var handle in TempHandles) - { - handle.Dispose(); - } - - TempHandles.Clear(); - } } internal void OpenGLRender(IRenderHandle renderHandle) @@ -265,42 +159,6 @@ namespace Robust.Client.Graphics.Overlays Drawing = false; } } - - private void ClearDraw() - { - if (!GameController.OnGodot) - { - return; - } - - foreach (var item in CanvasItems) - { - VS.FreeRid(item); - } - - VS.CanvasItemClear(MainCanvasItem); - - CanvasItems.Clear(); - } - - private void UpdateZIndex() - { - if (MainCanvasItem == null || !GameController.OnGodot) - { - return; - } - - if (Space != OverlaySpace.WorldSpace || ZIndex == null) - { - VS.CanvasItemSetZIndex(MainCanvasItem, 0); - VS.CanvasItemSetZAsRelativeToParent(MainCanvasItem, true); - } - else - { - VS.CanvasItemSetZIndex(MainCanvasItem, ZIndex.Value); - VS.CanvasItemSetZAsRelativeToParent(MainCanvasItem, false); - } - } } diff --git a/Robust.Client/Graphics/Overlays/OverlayManager.cs b/Robust.Client/Graphics/Overlays/OverlayManager.cs index 7d07bcbad..9d789cffa 100644 --- a/Robust.Client/Graphics/Overlays/OverlayManager.cs +++ b/Robust.Client/Graphics/Overlays/OverlayManager.cs @@ -5,40 +5,12 @@ using Robust.Shared.IoC; using System; using System.Collections.Generic; using Robust.Shared.Utility; -using VS = Godot.VisualServer; namespace Robust.Client.Graphics.Overlays { internal class OverlayManager : IOverlayManagerInternal { - private Godot.Node2D RootNodeWorld; - private Godot.Node2D RootNodeScreen; - private Godot.Node2D RootNodeScreenBelowWorld; - - [Dependency] readonly ISceneTreeHolder sceneTreeHolder; - private readonly Dictionary _overlays = new Dictionary(); - private readonly Dictionary _canvasItems = new Dictionary(); - - public void Initialize() - { - if (!GameController.OnGodot) - { - return; - } - - DebugTools.AssertNull(RootNodeScreenBelowWorld); - - RootNodeScreenBelowWorld = new Godot.Node2D { Name = "OverlayRoot" }; - sceneTreeHolder.BelowWorldScreenSpace.AddChild(RootNodeScreenBelowWorld); - - RootNodeWorld = new Godot.Node2D { Name = "OverlayRoot" }; - sceneTreeHolder.WorldRoot.AddChild(RootNodeWorld); - RootNodeWorld.ZIndex = (int) DrawDepth.Overlays; - - RootNodeScreen = new Godot.Node2D {Name = "OverlayRoot"}; - sceneTreeHolder.SceneTree.Root.GetNode("UILayer").AddChild(RootNodeScreen); - } public void FrameUpdate(RenderFrameEventArgs args) { @@ -56,29 +28,6 @@ namespace Robust.Client.Graphics.Overlays } _overlays.Add(overlay.ID, overlay); - if (GameController.OnGodot) - { - Godot.RID parent; - switch (overlay.Space) - { - case OverlaySpace.ScreenSpace: - parent = RootNodeScreen.GetCanvasItem(); - break; - case OverlaySpace.WorldSpace: - parent = RootNodeWorld.GetCanvasItem(); - break; - case OverlaySpace.ScreenSpaceBelowWorld: - parent = RootNodeScreenBelowWorld.GetCanvasItem(); - break; - default: - throw new NotImplementedException($"Unknown overlay space: {overlay.Space}"); - } - - var item = VS.CanvasItemCreate(); - VS.CanvasItemSetParent(item, parent); - overlay.AssignCanvasItem(item); - _canvasItems.Add(overlay, item); - } } public Overlay GetOverlay(string id) @@ -105,13 +54,6 @@ namespace Robust.Client.Graphics.Overlays overlay.Dispose(); _overlays.Remove(id); - - if (GameController.OnGodot) - { - var item = _canvasItems[overlay]; - _canvasItems.Remove(overlay); - VS.FreeRid(item); - } } public bool TryGetOverlay(string id, out Overlay overlay) diff --git a/Robust.Client/Graphics/Shaders/Shader.cs b/Robust.Client/Graphics/Shaders/Shader.cs index 0544191e0..fc349ada9 100644 --- a/Robust.Client/Graphics/Shaders/Shader.cs +++ b/Robust.Client/Graphics/Shaders/Shader.cs @@ -4,7 +4,6 @@ namespace Robust.Client.Graphics.Shaders { public sealed class Shader { - internal readonly Godot.Material GodotMaterial; internal readonly int ClydeHandle = -1; // We intentionally leak shaders to work around Godot issue #24108 @@ -16,20 +15,9 @@ namespace Robust.Client.Graphics.Shaders } - internal Shader(Godot.Material godotMaterial) - { - LeakyLeaky.Add(this); - GodotMaterial = godotMaterial; - } - internal Shader(int clydeHandle) { ClydeHandle = clydeHandle; } - - internal void ApplyToCanvasItem(Godot.RID item) - { - Godot.VisualServer.CanvasItemSetMaterial(item, GodotMaterial.GetRid()); - } } } diff --git a/Robust.Client/Graphics/Shaders/ShaderPrototype.cs b/Robust.Client/Graphics/Shaders/ShaderPrototype.cs index c0bd4609d..803078df5 100644 --- a/Robust.Client/Graphics/Shaders/ShaderPrototype.cs +++ b/Robust.Client/Graphics/Shaders/ShaderPrototype.cs @@ -10,8 +10,6 @@ using System; using System.Collections.Generic; using Robust.Client.Interfaces.Graphics; using YamlDotNet.RepresentationModel; -using BlendModeEnum = Godot.CanvasItemMaterial.BlendModeEnum; -using LightModeEnum = Godot.CanvasItemMaterial.LightModeEnum; namespace Robust.Client.Graphics.Shaders { @@ -28,7 +26,10 @@ namespace Robust.Client.Graphics.Shaders // Canvas shader variables. private LightModeEnum LightMode; +#pragma warning disable 414 + // TODO: Use this. private BlendModeEnum BlendMode; +#pragma warning restore 414 private Shader _canvasKindInstance; @@ -41,8 +42,6 @@ namespace Robust.Client.Graphics.Shaders { case GameController.DisplayMode.Headless: return new Shader(); - case GameController.DisplayMode.Godot: - return _instanceGodot(); case GameController.DisplayMode.Clyde: return _instanceOpenGL(); default: @@ -83,41 +82,6 @@ namespace Robust.Client.Graphics.Shaders } } - private Shader _instanceGodot() - { - Godot.Material mat; - - switch (Kind) - { - case ShaderKind.Source: - var shaderMat = new Godot.ShaderMaterial - { - Shader = Source.GodotShader - }; - mat = shaderMat; - if (ShaderParams != null) - { - foreach (var pair in ShaderParams) - { - shaderMat.SetShaderParam(pair.Key, pair.Value); - } - } - - break; - case ShaderKind.Canvas: - mat = new Godot.CanvasItemMaterial - { - LightMode = LightMode, - BlendMode = BlendMode, - }; - break; - default: - throw new InvalidOperationException(); - } - - return new Shader(mat); - } - public void LoadFrom(YamlMappingNode mapping) { ID = mapping.GetNode("id").ToString(); @@ -201,15 +165,15 @@ namespace Robust.Client.Graphics.Shaders break; case "subtract": - BlendMode = BlendModeEnum.Sub; + BlendMode = BlendModeEnum.Subtract; break; case "multiply": - BlendMode = BlendModeEnum.Mul; + BlendMode = BlendModeEnum.Multiply; break; case "premultiplied_alpha": - BlendMode = BlendModeEnum.PremultAlpha; + BlendMode = BlendModeEnum.PremultipliedAlpha; break; default: @@ -218,49 +182,6 @@ namespace Robust.Client.Graphics.Shaders } } - private object ParseShaderParamFor(YamlNode node, ShaderParamType type) - { - if (!GameController.OnGodot) - { - throw new NotImplementedException(); - } - switch (type) - { - case ShaderParamType.Void: - throw new NotSupportedException(); - case ShaderParamType.Bool: - return node.AsBool(); - case ShaderParamType.Int: - case ShaderParamType.UInt: - return node.AsInt(); - case ShaderParamType.Float: - return node.AsFloat(); - case ShaderParamType.Vec2: - return node.AsVector2().Convert(); - case ShaderParamType.Vec3: - return node.AsVector3().Convert(); - case ShaderParamType.Vec4: - try - { - return node.AsColor().Convert(); - } - catch - { - var vec4 = node.AsVector4(); - return new Godot.Quat(vec4.X, vec4.Y, vec4.Z, vec4.W); - } - - case ShaderParamType.Sampler2D: - var path = node.AsResourcePath(); - var resc = IoCManager.Resolve(); - return resc.GetResource(path).Texture.GodotTexture; - - // If something's not handled here, then that's probably because I was lazy. - default: - throw new NotImplementedException(); - } - } - enum ShaderKind { Source, @@ -279,5 +200,21 @@ void fragment() { COLOR = texture(TEXTURE, UV); } "; + + private enum LightModeEnum + { + Normal = 0, + Unshaded = 1, + LightOnly = 2, + } + + private enum BlendModeEnum + { + Mix = 0, + Add = 1, + Subtract = 2, + Multiply = 3, + PremultipliedAlpha = 4, + } } } diff --git a/Robust.Client/Graphics/Texture.cs b/Robust.Client/Graphics/Texture.cs index ba4cd239c..0aa1f0505 100644 --- a/Robust.Client/Graphics/Texture.cs +++ b/Robust.Client/Graphics/Texture.cs @@ -21,8 +21,6 @@ namespace Robust.Client.Graphics [PublicAPI] public abstract class Texture : IDirectionalTextureProvider { - internal abstract Godot.Texture GodotTexture { get; } - /// /// The width of the texture, in pixels. /// @@ -35,11 +33,6 @@ namespace Robust.Client.Graphics public Vector2i Size => new Vector2i(Width, Height); - public static implicit operator Godot.Texture(Texture src) - { - return src?.GodotTexture; - } - public static Texture Transparent { get; internal set; } public static Texture White { get; internal set; } @@ -60,32 +53,6 @@ namespace Robust.Client.Graphics { case GameController.DisplayMode.Headless: return new DummyTexture(image.Width, image.Height); - case GameController.DisplayMode.Godot: - { - var stream = new MemoryStream(); - - try - { - image.SaveAsPng(stream, new PngEncoder {CompressionLevel = 1}); - - var gdImage = new Godot.Image(); - var ret = gdImage.LoadPngFromBuffer(stream.ToArray()); - if (ret != Godot.Error.Ok) - { - throw new InvalidDataException(ret.ToString()); - } - - // Godot does not provide a way to load from memory directly so we turn it into a PNG I guess. - var texture = new Godot.ImageTexture(); - texture.CreateFromImage(gdImage); - (loadParameters ?? TextureLoadParameters.Default).SampleParameters.ApplyToGodotTexture(texture); - return new GodotTextureSource(texture); - } - finally - { - stream.Dispose(); - } - } case GameController.DisplayMode.Clyde: { var manager = IoCManager.Resolve(); @@ -112,24 +79,6 @@ namespace Robust.Client.Graphics { case GameController.DisplayMode.Headless: return new DummyTexture(); - case GameController.DisplayMode.Godot: - using (var memoryStream = new MemoryStream()) - { - stream.CopyTo(memoryStream); - - var data = memoryStream.ToArray(); - var gdImage = new Godot.Image(); - var ret = gdImage.LoadPngFromBuffer(data); - if (ret != Godot.Error.Ok) - { - throw new InvalidDataException(ret.ToString()); - } - - var texture = new Godot.ImageTexture(); - texture.CreateFromImage(gdImage); - (loadParameters ?? TextureLoadParameters.Default).SampleParameters.ApplyToGodotTexture(texture); - return new GodotTextureSource(texture); - } case GameController.DisplayMode.Clyde: { var manager = IoCManager.Resolve(); @@ -186,8 +135,6 @@ namespace Robust.Client.Graphics internal sealed class DummyTexture : Texture { - internal override Godot.Texture GodotTexture => null; - public override int Width { get; } public override int Height { get; } @@ -217,21 +164,10 @@ namespace Robust.Client.Graphics DebugTools.Assert(SubRegion.Left >= 0); DebugTools.Assert(SubRegion.Top >= 0); - if (GameController.OnGodot) - { - GodotTexture = new Godot.AtlasTexture - { - Atlas = texture, - Region = subRegion.Convert() - }; - } - SubRegion = subRegion; SourceTexture = texture; } - internal override Godot.Texture GodotTexture { get; } - /// /// The texture this texture is a sub region of. /// @@ -294,39 +230,6 @@ namespace Robust.Client.Graphics /// public TextureWrapMode WrapMode { get; set; } - internal void ApplyToGodotTexture(Godot.Texture texture) - { - var flags = texture.Flags; - if (Filter) - { - flags |= (int) Godot.Texture.FlagsEnum.Filter; - } - else - { - flags &= ~(int) Godot.Texture.FlagsEnum.Filter; - } - - switch (WrapMode) - { - case TextureWrapMode.None: - flags &= ~(int) Godot.Texture.FlagsEnum.Repeat; - flags &= ~(int) Godot.Texture.FlagsEnum.MirroredRepeat; - break; - case TextureWrapMode.Repeat: - flags |= (int) Godot.Texture.FlagsEnum.Repeat; - flags &= ~(int) Godot.Texture.FlagsEnum.MirroredRepeat; - break; - case TextureWrapMode.MirroredRepeat: - flags &= ~(int) Godot.Texture.FlagsEnum.Repeat; - flags |= (int) Godot.Texture.FlagsEnum.MirroredRepeat; - break; - default: - throw new ArgumentOutOfRangeException(); - } - - texture.Flags = flags; - } - public static TextureSampleParameters FromYaml(YamlMappingNode node) { var wrap = TextureWrapMode.None; @@ -389,7 +292,6 @@ namespace Robust.Client.Graphics internal class OpenGLTexture : Texture { - internal override Godot.Texture GodotTexture => null; internal int OpenGLTextureId { get; } internal int ArrayIndex { get; } @@ -411,21 +313,4 @@ namespace Robust.Client.Graphics ArrayIndex = arrayIndex; } } - - /// - /// Wraps a texture returned by Godot itself, - /// for example when the texture was set in a GUI scene. - /// - internal class GodotTextureSource : Texture - { - internal override Godot.Texture GodotTexture { get; } - public override int Width => GodotTexture.GetWidth(); - public override int Height => GodotTexture.GetHeight(); - - public GodotTextureSource(Godot.Texture texture) - { - DebugTools.Assert(GameController.OnGodot); - GodotTexture = texture; - } - } } diff --git a/Robust.Client/Input/Events.cs b/Robust.Client/Input/Events.cs index cc52502df..39fb30e22 100644 --- a/Robust.Client/Input/Events.cs +++ b/Robust.Client/Input/Events.cs @@ -47,12 +47,6 @@ namespace Robust.Client.Input /// public void Handle() { - if (GameController.OnGodot) - { - var tree = IoCManager.Resolve(); - tree.SceneTree.SetInputAsHandled(); - } - Handled = true; } } @@ -86,22 +80,6 @@ namespace Robust.Client.Input IsRepeat = repeat; } - public static explicit operator KeyEventArgs(Godot.InputEventKey args) - { - return new KeyEventArgs(Keyboard.ConvertGodotKey(args.Scancode), - args.Echo, - args.Alt, - args.Control, - args.Shift, - args.Command); - } - - public static explicit operator KeyEventArgs(Godot.InputEventMouseButton args) - { - var key = Mouse.MouseButtonToKey((Mouse.Button) args.ButtonIndex); - return new KeyEventArgs(key, false, false, false, false, false); - } - public static explicit operator KeyEventArgs(OpenTK.Input.KeyboardKeyEventArgs args) { return new KeyEventArgs(Keyboard.ConvertOpenTKKey(args.Key), args.IsRepeat, args.Alt, args.Control, args.Shift, false); @@ -200,20 +178,6 @@ namespace Robust.Client.Input DoubleClick = doubleClick; } - public static explicit operator MouseButtonEventArgs(Godot.InputEventMouseButton inputEvent) - { - // Before cutting this up, - // this line was 281 characters long. - return new MouseButtonEventArgs((Mouse.Button) inputEvent.ButtonIndex, - inputEvent.Doubleclick, - (Mouse.ButtonMask) inputEvent.ButtonMask, - inputEvent.Position.Convert(), - inputEvent.Alt, - inputEvent.Control, - inputEvent.Shift, - inputEvent.Command); - } - public static explicit operator MouseButtonEventArgs(OpenTK.Input.MouseButtonEventArgs inputEvent) { return new MouseButtonEventArgs( @@ -244,19 +208,6 @@ namespace Robust.Client.Input WheelDirection = wheelDirection; } - public static explicit operator MouseWheelEventArgs(Godot.InputEventMouseButton inputEvent) - { - // Before cutting this up, - // this line was 281 characters long. - return new MouseWheelEventArgs((Mouse.Wheel) inputEvent.ButtonIndex, - (Mouse.ButtonMask) inputEvent.ButtonMask, - inputEvent.Position.Convert(), - inputEvent.Alt, - inputEvent.Control, - inputEvent.Shift, - inputEvent.Command); - } - public static explicit operator MouseWheelEventArgs(OpenTK.Input.MouseWheelEventArgs inputEvent) { var direction = inputEvent.Delta > 0 ? Mouse.Wheel.Up : Mouse.Wheel.Down; @@ -297,18 +248,6 @@ namespace Robust.Client.Input Speed = speed; } - public static explicit operator MouseMoveEventArgs(Godot.InputEventMouseMotion inputEvent) - { - return new MouseMoveEventArgs(inputEvent.Relative.Convert(), - inputEvent.Speed.Convert(), - (Mouse.ButtonMask) inputEvent.ButtonMask, - inputEvent.Position.Convert(), - inputEvent.Alt, - inputEvent.Control, - inputEvent.Shift, - inputEvent.Command); - } - public static explicit operator MouseMoveEventArgs(OpenTK.Input.MouseMoveEventArgs inputEvent) { return new MouseMoveEventArgs( diff --git a/Robust.Client/Input/GodotInputManager.cs b/Robust.Client/Input/GodotInputManager.cs deleted file mode 100644 index f841029df..000000000 --- a/Robust.Client/Input/GodotInputManager.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Robust.Client.Interfaces; -using Robust.Client.Utility; -using Robust.Shared.IoC; -using Robust.Shared.Maths; - -namespace Robust.Client.Input -{ - internal class GodotInputManager : InputManager - { - [Dependency] - readonly ISceneTreeHolder sceneTree; - - public override Vector2 MouseScreenPosition => sceneTree.SceneTree.Root.GetMousePosition().Convert(); - } -} diff --git a/Robust.Client/Input/InputDevices.cs b/Robust.Client/Input/InputDevices.cs index fb3bbf703..44bedc898 100644 --- a/Robust.Client/Input/InputDevices.cs +++ b/Robust.Client/Input/InputDevices.cs @@ -7,8 +7,6 @@ namespace Robust.Client.Input { public static class Mouse { - public static bool IsButtonPressed(Button button) => GameController.OnGodot ? Godot.Input.IsMouseButtonPressed((int) button) : default; - /// /// Represents one of three mouse buttons. /// @@ -212,227 +210,7 @@ namespace Robust.Client.Input F15, Pause, } - - public static Key ConvertGodotKey(int key) - { - // As far as I can tell, Godot's KeyList has complete arbitrary ordering. Seriously. - // They don't even prevent overlap if you remove the SPKEY flag (they totally could too...). - // The macOS, X11 and Windows platform layers *all* have scancode translation tables so it literally can't be "oh they took them from X11!" - // Also there are dumb scan codes like YACCUTE which *literally don't get fired ever*. - switch ((Godot.KeyList) key) - { - // Dear mother of .NET optimize this nicely for me. - case Godot.KeyList.A: - return Key.A; - case Godot.KeyList.B: - return Key.B; - case Godot.KeyList.C: - return Key.C; - case Godot.KeyList.D: - return Key.D; - case Godot.KeyList.E: - return Key.E; - case Godot.KeyList.F: - return Key.F; - case Godot.KeyList.G: - return Key.G; - case Godot.KeyList.H: - return Key.H; - case Godot.KeyList.I: - return Key.I; - case Godot.KeyList.J: - return Key.J; - case Godot.KeyList.K: - return Key.K; - case Godot.KeyList.L: - return Key.L; - case Godot.KeyList.M: - return Key.M; - case Godot.KeyList.N: - return Key.N; - case Godot.KeyList.O: - return Key.O; - case Godot.KeyList.P: - return Key.P; - case Godot.KeyList.Q: - return Key.Q; - case Godot.KeyList.R: - return Key.R; - case Godot.KeyList.S: - return Key.S; - case Godot.KeyList.T: - return Key.T; - case Godot.KeyList.U: - return Key.U; - case Godot.KeyList.V: - return Key.V; - case Godot.KeyList.W: - return Key.W; - case Godot.KeyList.X: - return Key.X; - case Godot.KeyList.Y: - return Key.Y; - case Godot.KeyList.Z: - return Key.Z; - case Godot.KeyList.Key0: - return Key.Num0; - case Godot.KeyList.Key1: - return Key.Num1; - case Godot.KeyList.Key2: - return Key.Num2; - case Godot.KeyList.Key3: - return Key.Num3; - case Godot.KeyList.Key4: - return Key.Num4; - case Godot.KeyList.Key5: - return Key.Num5; - case Godot.KeyList.Key6: - return Key.Num6; - case Godot.KeyList.Key7: - return Key.Num7; - case Godot.KeyList.Key8: - return Key.Num8; - case Godot.KeyList.Key9: - return Key.Num9; - case Godot.KeyList.Kp0: - return Key.NumpadNum0; - case Godot.KeyList.Kp1: - return Key.NumpadNum1; - case Godot.KeyList.Kp2: - return Key.NumpadNum2; - case Godot.KeyList.Kp3: - return Key.NumpadNum3; - case Godot.KeyList.Kp4: - return Key.NumpadNum4; - case Godot.KeyList.Kp5: - return Key.NumpadNum5; - case Godot.KeyList.Kp6: - return Key.NumpadNum6; - case Godot.KeyList.Kp7: - return Key.NumpadNum7; - case Godot.KeyList.Kp8: - return Key.NumpadNum8; - case Godot.KeyList.Kp9: - return Key.NumpadNum9; - case Godot.KeyList.Escape: - return Key.Escape; - case Godot.KeyList.Control: - return Key.Control; - case Godot.KeyList.Shift: - return Key.Shift; - case Godot.KeyList.Alt: - return Key.Alt; - case Godot.KeyList.SuperL: - return Key.LSystem; - case Godot.KeyList.SuperR: - return Key.RSystem; - case Godot.KeyList.Menu: - return Key.Menu; - case Godot.KeyList.Bracketleft: - return Key.LBracket; - case Godot.KeyList.Bracketright: - return Key.RBracket; - case Godot.KeyList.Semicolon: - return Key.SemiColon; - case Godot.KeyList.Comma: - return Key.Comma; - case Godot.KeyList.Period: - return Key.Period; - case Godot.KeyList.Quoteleft: - return Key.Quote; - case Godot.KeyList.Apostrophe: - return Key.Apostrophe; - case Godot.KeyList.Slash: - return Key.Slash; - case Godot.KeyList.Backslash: - return Key.BackSlash; - case Godot.KeyList.Asciitilde: - return Key.Tilde; - case Godot.KeyList.Equal: - return Key.Equal; - case Godot.KeyList.Hyphen: - return Key.Dash; - case Godot.KeyList.Space: - return Key.Space; - case Godot.KeyList.Enter: - return Key.Return; - case Godot.KeyList.KpEnter: - return Key.NumpadEnter; - case Godot.KeyList.Backspace: - return Key.BackSpace; - case Godot.KeyList.Tab: - return Key.Tab; - case Godot.KeyList.Pageup: - return Key.PageUp; - case Godot.KeyList.Pagedown: - return Key.PageDown; - case Godot.KeyList.End: - return Key.End; - case Godot.KeyList.Home: - return Key.Home; - case Godot.KeyList.Insert: - return Key.Insert; - case Godot.KeyList.Delete: - return Key.Delete; - case Godot.KeyList.Plus: - return Key.Plus; - case Godot.KeyList.Minus: - return Key.Minus; - case Godot.KeyList.Asterisk: - return Key.Asterisk; - case Godot.KeyList.KpAdd: - return Key.NumpadAdd; - case Godot.KeyList.KpSubtract: - return Key.NumpadSubtract; - case Godot.KeyList.KpDivide: - return Key.NumpadDivide; - case Godot.KeyList.KpMultiply: - return Key.NumpadMultiply; - case Godot.KeyList.Left: - return Key.Left; - case Godot.KeyList.Right: - return Key.Right; - case Godot.KeyList.Up: - return Key.Up; - case Godot.KeyList.Down: - return Key.Down; - case Godot.KeyList.F1: - return Key.F1; - case Godot.KeyList.F2: - return Key.F2; - case Godot.KeyList.F3: - return Key.F3; - case Godot.KeyList.F4: - return Key.F4; - case Godot.KeyList.F5: - return Key.F5; - case Godot.KeyList.F6: - return Key.F6; - case Godot.KeyList.F7: - return Key.F7; - case Godot.KeyList.F8: - return Key.F8; - case Godot.KeyList.F9: - return Key.F9; - case Godot.KeyList.F10: - return Key.F10; - case Godot.KeyList.F11: - return Key.F11; - case Godot.KeyList.F12: - return Key.F12; - case Godot.KeyList.F13: - return Key.F13; - case Godot.KeyList.F14: - return Key.F14; - case Godot.KeyList.F15: - return Key.F15; - case Godot.KeyList.Pause: - return Key.Pause; - default: - return Key.Unknown; - } - } - + internal static Key ConvertOpenTKKey(TKKey key) { if (OpenTKKeyMap.TryGetValue(key, out var result)) diff --git a/Robust.Client/Interfaces/GameObjects/Components/IGodotTransformComponent.cs b/Robust.Client/Interfaces/GameObjects/Components/IGodotTransformComponent.cs deleted file mode 100644 index 48ad8c904..000000000 --- a/Robust.Client/Interfaces/GameObjects/Components/IGodotTransformComponent.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Robust.Shared.Interfaces.GameObjects.Components; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Robust.Client.Interfaces.GameObjects.Components -{ - public interface IGodotTransformComponent : ITransformComponent - { - new IGodotTransformComponent Parent { get; } - - Godot.Node2D SceneNode { get; } - } -} diff --git a/Robust.Client/Interfaces/GameObjects/Components/ISpriteComponent.cs b/Robust.Client/Interfaces/GameObjects/Components/ISpriteComponent.cs index b7175c3e3..46868b3dd 100644 --- a/Robust.Client/Interfaces/GameObjects/Components/ISpriteComponent.cs +++ b/Robust.Client/Interfaces/GameObjects/Components/ISpriteComponent.cs @@ -198,17 +198,5 @@ namespace Robust.Client.Interfaces.GameObjects.Components public interface ISpriteProxy : IDisposable { Vector2 Offset { get; set; } - void AttachToItem(Godot.RID item); - } - - public static class SpriteProxyExt - { - public static void AttachToControl(this ISpriteProxy mirror, Control control) - { - if (GameController.OnGodot) - { - mirror.AttachToItem(control.SceneControl.GetCanvasItem()); - } - } } } diff --git a/Robust.Client/Interfaces/Graphics/ClientEye/IEye.cs b/Robust.Client/Interfaces/Graphics/ClientEye/IEye.cs index b699545d5..f41067fef 100644 --- a/Robust.Client/Interfaces/Graphics/ClientEye/IEye.cs +++ b/Robust.Client/Interfaces/Graphics/ClientEye/IEye.cs @@ -9,8 +9,6 @@ namespace Robust.Client.Interfaces.Graphics.ClientEye /// public interface IEye { - Godot.Camera2D GodotCamera { get; } - /// /// Whether this is the current eye. If true, this one will be used. /// diff --git a/Robust.Client/Interfaces/Graphics/Overlays/IOverlayManager.cs b/Robust.Client/Interfaces/Graphics/Overlays/IOverlayManager.cs index 6b3282e50..8b3b59edf 100644 --- a/Robust.Client/Interfaces/Graphics/Overlays/IOverlayManager.cs +++ b/Robust.Client/Interfaces/Graphics/Overlays/IOverlayManager.cs @@ -22,7 +22,6 @@ namespace Robust.Client.Interfaces.Graphics.Overlays internal interface IOverlayManagerInternal : IOverlayManager { - void Initialize(); void FrameUpdate(RenderFrameEventArgs args); } } diff --git a/Robust.Client/Interfaces/ISceneTreeHolder.cs b/Robust.Client/Interfaces/ISceneTreeHolder.cs deleted file mode 100644 index 9d2e4730f..000000000 --- a/Robust.Client/Interfaces/ISceneTreeHolder.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Robust.Client.Interfaces -{ - internal interface ISceneTreeHolder - { - void Initialize(Godot.SceneTree tree); - - Godot.CanvasLayer BelowWorldScreenSpace { get; } - Godot.SceneTree SceneTree { get; } - Godot.Node2D WorldRoot { get; } - } -} diff --git a/Robust.Client/Interfaces/Map/IGodotTileDefinitionManager.cs b/Robust.Client/Interfaces/Map/IGodotTileDefinitionManager.cs deleted file mode 100644 index 54a7543c9..000000000 --- a/Robust.Client/Interfaces/Map/IGodotTileDefinitionManager.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Robust.Shared.Interfaces.Map; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Robust.Client.Interfaces.Map -{ - internal interface IGodotTileDefinitionManager : ITileDefinitionManager - { - Godot.TileSet TileSet { get; } - } -} diff --git a/Robust.Client/Log/GodotLogHandler.cs b/Robust.Client/Log/GodotLogHandler.cs deleted file mode 100644 index 09a1a461f..000000000 --- a/Robust.Client/Log/GodotLogHandler.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Robust.Shared.Interfaces.Log; -using Robust.Shared.Log; - -namespace Robust.Client.Log -{ - /// - /// Handles logs using Godot's . - /// - class GodotLogHandler : ILogHandler - { - private readonly object locker = new object(); - - public void Log(in LogMessage message) - { - var name = message.LogLevelToName(); - var msg = $"[{name}] {message.SawmillName}: {message.Message}"; - lock (locker) - { - Godot.GD.Print(msg); - } - } - } -} diff --git a/Robust.Client/Map/GodotMapManager.cs b/Robust.Client/Map/GodotMapManager.cs deleted file mode 100644 index 87f1dd064..000000000 --- a/Robust.Client/Map/GodotMapManager.cs +++ /dev/null @@ -1,75 +0,0 @@ -using Robust.Shared.Map; -using System.Collections.Generic; -using Robust.Shared.Interfaces.Map; -using Robust.Client.Interfaces.Map; -using Robust.Shared.IoC; -using Robust.Client.Interfaces; -using Robust.Shared.Log; -using Robust.Client.Graphics.ClientEye; - -namespace Robust.Client.Map -{ - public class GodotMapManager : MapManager - { - [Dependency] - private IGodotTileDefinitionManager tileDefinitionManager; - [Dependency] - private ISceneTreeHolder sceneTree; - - private Dictionary RenderTileMaps = new Dictionary(); - - public GodotMapManager() - { - if (!GameController.OnGodot) - { - return; - } - TileChanged += UpdateTileMapOnUpdate; - OnGridCreated += UpdateOnGridCreated; - OnGridRemoved += UpdateOnGridRemoved; - GridChanged += UpdateOnGridModified; - } - - private void UpdateOnGridModified(object sender, GridChangedEventArgs args) - { - var tilemap = RenderTileMaps[args.Grid.Index]; - foreach (var (index, tile) in args.Modified) - { - tilemap.SetCell(index.X, -1-index.Y, tile.TypeId); - } - } - - private void UpdateTileMapOnUpdate(object sender, TileChangedEventArgs args) - { - var tilemap = RenderTileMaps[args.NewTile.GridIndex]; - tilemap.SetCell(args.NewTile.X, -1-args.NewTile.Y, args.NewTile.Tile.TypeId); - } - - private void UpdateOnGridCreated(GridId gridId) - { - var tilemap = new Godot.TileMap - { - TileSet = tileDefinitionManager.TileSet, - // TODO: Unhardcode this cell size. - CellSize = new Godot.Vector2(EyeManager.PIXELSPERMETER, EyeManager.PIXELSPERMETER), - ZIndex = -10, - // Fiddle with this some more maybe. Increases lighting performance a TON. - CellQuadrantSize = 4, - //Visible = false, - }; - tilemap.SetName($"Grid {gridId}"); - sceneTree.WorldRoot.AddChild(tilemap); - // Creating a map makes a grid before mapcreated is fired, so... - RenderTileMaps[gridId] = tilemap; - } - - private void UpdateOnGridRemoved(GridId gridId) - { - Logger.Debug($"Removing grid {gridId}"); - var tilemap = RenderTileMaps[gridId]; - tilemap.QueueFree(); - tilemap.Dispose(); - RenderTileMaps.Remove(gridId); - } - } -} diff --git a/Robust.Client/Map/GodotTileDefinitionManager.cs b/Robust.Client/Map/GodotTileDefinitionManager.cs deleted file mode 100644 index fe841b844..000000000 --- a/Robust.Client/Map/GodotTileDefinitionManager.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Robust.Client.Interfaces.Map; -using Robust.Client.Interfaces.ResourceManagement; -using Robust.Client.ResourceManagement; -using Robust.Shared.Interfaces.Map; -using Robust.Shared.IoC; -using Robust.Shared.Map; -using System.Collections.Generic; -using Robust.Shared.Utility; - -namespace Robust.Client.Map -{ - /// - /// Special TileDefinitionManager that makes a Godot TileSet for usage by TileMaps. - /// - internal sealed class GodotTileDefinitionManager : TileDefinitionManager, IGodotTileDefinitionManager - { - [Dependency] readonly IResourceCache resourceCache; - - public Godot.TileSet TileSet { get; private set; } - - private Dictionary Textures = new Dictionary(); - - public GodotTileDefinitionManager() - { - TileSet = new Godot.TileSet(); - } - - public override void Register(ITileDefinition tileDef) - { - base.Register(tileDef); - - var id = tileDef.TileId; - TileSet.CreateTile(id); - if (string.IsNullOrEmpty(tileDef.SpriteName)) - { - return; - } - - var texture = - resourceCache.GetResource( - new ResourcePath("/Textures/Tiles/") / $@"{tileDef.SpriteName}.png"); - TileSet.TileSetTexture(id, texture.Texture.GodotTexture); - Textures[id] = texture; - } - } -} diff --git a/Robust.Client/Placement/PlacementManager.cs b/Robust.Client/Placement/PlacementManager.cs index 7c6eeb707..3fd457559 100644 --- a/Robust.Client/Placement/PlacementManager.cs +++ b/Robust.Client/Placement/PlacementManager.cs @@ -52,8 +52,6 @@ namespace Robust.Client.Placement [Dependency] public readonly IEyeManager eyeManager; [Dependency] - internal readonly ISceneTreeHolder sceneTree; - [Dependency] private readonly IInputManager _inputManager; [Dependency] private readonly IEntitySystemManager _entitySystemManager; diff --git a/Robust.Client/ResourceManagement/ResourceTypes/AudioResource.cs b/Robust.Client/ResourceManagement/ResourceTypes/AudioResource.cs index 8d9784dee..2e36ae415 100644 --- a/Robust.Client/ResourceManagement/ResourceTypes/AudioResource.cs +++ b/Robust.Client/ResourceManagement/ResourceTypes/AudioResource.cs @@ -24,20 +24,6 @@ namespace Robust.Client.ResourceManagement case GameController.DisplayMode.Headless: AudioStream = new AudioStream(); break; - case GameController.DisplayMode.Godot: - using (var fileStream = cache.ContentFileRead(path)) - { - var stream = new Godot.AudioStreamOGGVorbis() - { - Data = fileStream.ToArray(), - }; - if (stream.GetLength() == 0) - { - throw new InvalidDataException(); - } - AudioStream = new AudioStream(stream); - } - break; case GameController.DisplayMode.Clyde: using (var fileStream = cache.ContentFileRead(path)) { diff --git a/Robust.Client/ResourceManagement/ResourceTypes/FontResource.cs b/Robust.Client/ResourceManagement/ResourceTypes/FontResource.cs index 0c9110181..9dee32308 100644 --- a/Robust.Client/ResourceManagement/ResourceTypes/FontResource.cs +++ b/Robust.Client/ResourceManagement/ResourceTypes/FontResource.cs @@ -14,7 +14,6 @@ namespace Robust.Client.ResourceManagement { public class FontResource : BaseResource { - internal Godot.DynamicFontData FontData { get; private set; } internal IFontFaceHandle FontFaceHandle { get; private set; } public override void Load(IResourceCache cache, ResourcePath path) @@ -26,20 +25,6 @@ namespace Robust.Client.ResourceManagement switch (GameController.Mode) { - case GameController.DisplayMode.Godot: - if (!cache.TryGetDiskFilePath(path, out string diskPath)) - { - throw new InvalidOperationException("Fonts can only be loaded from disk."); - } - - var res = Godot.ResourceLoader.Load(diskPath); - if (!(res is Godot.DynamicFontData fontData)) - { - throw new InvalidDataException("Path does not point to a font."); - } - - FontData = fontData; - break; case GameController.DisplayMode.Headless: case GameController.DisplayMode.Clyde: FontFaceHandle = IoCManager.Resolve().Load(cache.ContentFileRead(path).ToArray()); @@ -54,13 +39,5 @@ namespace Robust.Client.ResourceManagement { return new VectorFont(this, 12); } - - public override void Dispose() - { - if (GameController.OnGodot) - { - FontData.Dispose(); - } - } } } diff --git a/Robust.Client/ResourceManagement/ResourceTypes/ShaderSourceResource.cs b/Robust.Client/ResourceManagement/ResourceTypes/ShaderSourceResource.cs index 929dffc99..aa4ae1c59 100644 --- a/Robust.Client/ResourceManagement/ResourceTypes/ShaderSourceResource.cs +++ b/Robust.Client/ResourceManagement/ResourceTypes/ShaderSourceResource.cs @@ -16,7 +16,6 @@ namespace Robust.Client.ResourceManagement.ResourceTypes /// public class ShaderSourceResource : BaseResource { - internal Godot.Shader GodotShader { get; private set; } internal int ClydeHandle { get; private set; } = -1; internal ParsedShader ParsedShader { get; private set; } @@ -32,12 +31,6 @@ namespace Robust.Client.ResourceManagement.ResourceTypes { case GameController.DisplayMode.Headless: return; - case GameController.DisplayMode.Godot: - GodotShader = new Godot.Shader - { - Code = _getGodotCode(), - }; - break; case GameController.DisplayMode.Clyde: ClydeHandle = IoCManager.Resolve().LoadShader(ParsedShader); break; @@ -45,19 +38,9 @@ namespace Robust.Client.ResourceManagement.ResourceTypes throw new ArgumentOutOfRangeException(); } - if (GameController.OnGodot) - { - GodotShader = new Godot.Shader - { - Code = _getGodotCode(), - }; - } - else - { - var clyde = IoCManager.Resolve(); - // TODO: vertex shaders. - ClydeHandle = clyde.LoadShader(ParsedShader, path.ToString()); - } + var clyde = IoCManager.Resolve(); + // TODO: vertex shaders. + ClydeHandle = clyde.LoadShader(ParsedShader, path.ToString()); } private string _getGodotCode() diff --git a/Robust.Client/ResourceManagement/ResourceTypes/TextureResource.cs b/Robust.Client/ResourceManagement/ResourceTypes/TextureResource.cs index 4c9901997..7f5a2f252 100644 --- a/Robust.Client/ResourceManagement/ResourceTypes/TextureResource.cs +++ b/Robust.Client/ResourceManagement/ResourceTypes/TextureResource.cs @@ -16,7 +16,6 @@ namespace Robust.Client.ResourceManagement { public override ResourcePath Fallback { get; } = new ResourcePath("/Textures/noSprite.png"); public Texture Texture { get; private set; } - private Godot.ImageTexture godotTexture; public override void Load(IResourceCache cache, ResourcePath path) { @@ -36,9 +35,6 @@ namespace Robust.Client.ResourceManagement var image = Image.Load(cache.ContentFileRead(path).ToArray()); Texture = new DummyTexture(image.Width, image.Height); break; - case GameController.DisplayMode.Godot: - _loadGodot(cache, path, loadParameters); - break; case GameController.DisplayMode.Clyde: _loadOpenGL(cache, path, loadParameters); break; @@ -70,28 +66,6 @@ namespace Robust.Client.ResourceManagement return null; } - private void _loadGodot(IResourceCache cache, ResourcePath path, TextureLoadParameters? parameters) - { - DebugTools.Assert(GameController.Mode == GameController.DisplayMode.Godot); - - using (var stream = cache.ContentFileRead(path)) - { - var buffer = stream.ToArray(); - var image = new Godot.Image(); - var error = image.LoadPngFromBuffer(buffer); - if (error != Godot.Error.Ok) - { - throw new InvalidDataException($"Unable to load texture from buffer, reason: {error}"); - } - godotTexture = new Godot.ImageTexture(); - godotTexture.CreateFromImage(image); - } - - // Disable filter by default because pixel art. - (parameters ?? TextureLoadParameters.Default).SampleParameters.ApplyToGodotTexture(godotTexture); - Texture = new GodotTextureSource(godotTexture); - } - private void _loadOpenGL(IResourceCache cache, ResourcePath path, TextureLoadParameters? parameters) { DebugTools.Assert(GameController.Mode == GameController.DisplayMode.Clyde); @@ -105,13 +79,5 @@ namespace Robust.Client.ResourceManagement { return res?.Texture; } - - public override void Dispose() - { - if (GameController.OnGodot) - { - godotTexture.Dispose(); - } - } } } diff --git a/Robust.Client/Robust.Client.csproj b/Robust.Client/Robust.Client.csproj index 1815994ab..256b991f3 100644 --- a/Robust.Client/Robust.Client.csproj +++ b/Robust.Client/Robust.Client.csproj @@ -89,12 +89,6 @@ - - ..\Robust.Client.Godot\.mono\assemblies\GodotSharp.dll - - - ..\Dependencies\godot\GodotSharp.dll - @@ -106,7 +100,6 @@ - @@ -120,7 +113,6 @@ - @@ -131,7 +123,6 @@ - @@ -157,7 +148,6 @@ - @@ -177,7 +167,6 @@ - @@ -192,9 +181,7 @@ - - @@ -203,9 +190,6 @@ - - - @@ -219,8 +203,6 @@ - - @@ -255,12 +237,10 @@ - - @@ -272,7 +252,6 @@ - @@ -299,7 +278,6 @@ - @@ -362,10 +340,6 @@ {59250baf-0000-0000-0000-000000000000} Lidgren.Network - - {8af31169-49b1-4a12-b8f4-2a0674a9e7cb} - Robust.Client.Godot - {93f23a82-00c5-4572-964e-e7c9457726d4} Robust.Shared.Maths diff --git a/Robust.Client/SceneTreeHolder.cs b/Robust.Client/SceneTreeHolder.cs deleted file mode 100644 index d3767757b..000000000 --- a/Robust.Client/SceneTreeHolder.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Robust.Client.Interfaces; -using System; -using Robust.Client.Graphics; - -namespace Robust.Client -{ - internal class SceneTreeHolder : ISceneTreeHolder - { - public Godot.CanvasLayer BelowWorldScreenSpace { get; private set; } - public Godot.SceneTree SceneTree { get; private set; } - public Godot.Node2D WorldRoot { get; private set; } - - public void Initialize(Godot.SceneTree tree) - { - SceneTree = tree ?? throw new ArgumentNullException(nameof(tree)); - - BelowWorldScreenSpace = new Godot.CanvasLayer - { - Name = "ScreenSubWorld", - Layer = CanvasLayers.LAYER_SCREEN_BELOW_WORLD - }; - SceneTree.GetRoot().AddChild(BelowWorldScreenSpace); - - WorldRoot = new Godot.Node2D - { - Name = "WorldRoot" - }; - SceneTree.GetRoot().AddChild(WorldRoot); - } - } -} diff --git a/Robust.Client/UserInterface/ClipboardManagerGodot.cs b/Robust.Client/UserInterface/ClipboardManagerGodot.cs deleted file mode 100644 index 507b71c3e..000000000 --- a/Robust.Client/UserInterface/ClipboardManagerGodot.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Robust.Client.Interfaces.UserInterface; - -namespace Robust.Client.UserInterface -{ - internal sealed class ClipboardManagerGodot : IClipboardManager - { - public bool Available => true; - public string NotAvailableReason => ""; - public string GetText() - { - return Godot.OS.Clipboard; - } - - public void SetText(string text) - { - Godot.OS.Clipboard = text; - } - } -} diff --git a/Robust.Client/UserInterface/Control.Input.cs b/Robust.Client/UserInterface/Control.Input.cs index baa7f0cbb..62e21620a 100644 --- a/Robust.Client/UserInterface/Control.Input.cs +++ b/Robust.Client/UserInterface/Control.Input.cs @@ -52,86 +52,6 @@ namespace Robust.Client.UserInterface protected internal virtual void TextEntered(GUITextEventArgs args) { } - - private void HandleGuiInput(Godot.InputEvent input) - { - switch (input) - { - case Godot.InputEventKey keyEvent: - var keyEventArgs = new GUIKeyEventArgs(this, - Keyboard.ConvertGodotKey(keyEvent.Scancode), - keyEvent.Echo, - keyEvent.Alt, - keyEvent.Control, - keyEvent.Shift, - keyEvent.Command); - if (keyEvent.Pressed) - { - KeyDown(keyEventArgs); - } - else - { - KeyUp(keyEventArgs); - } - - break; - - case Godot.InputEventMouseButton buttonEvent: - if (buttonEvent.ButtonIndex >= (int) Godot.ButtonList.WheelUp && - buttonEvent.ButtonIndex <= (int) Godot.ButtonList.WheelRight) - { - // Mouse wheel event. - var mouseWheelEventArgs = new GUIMouseWheelEventArgs((Mouse.Wheel) buttonEvent.ButtonIndex, - this, - (Mouse.ButtonMask) buttonEvent.ButtonMask, - buttonEvent.GlobalPosition.Convert(), - buttonEvent.Position.Convert(), - buttonEvent.Alt, - buttonEvent.Control, - buttonEvent.Shift, - buttonEvent.Command); - MouseWheel(mouseWheelEventArgs); - } - else - { - // Mouse button event. - var mouseButtonEventArgs = new GUIMouseButtonEventArgs((Mouse.Button) buttonEvent.ButtonIndex, - buttonEvent.Doubleclick, - this, - (Mouse.ButtonMask) buttonEvent.ButtonMask, - buttonEvent.GlobalPosition.Convert(), - buttonEvent.Position.Convert(), - buttonEvent.Alt, - buttonEvent.Control, - buttonEvent.Shift, - buttonEvent.Command); - if (buttonEvent.Pressed) - { - MouseDown(mouseButtonEventArgs); - } - else - { - MouseUp(mouseButtonEventArgs); - } - } - - break; - - case Godot.InputEventMouseMotion motionEvent: - var mouseMoveEventArgs = new GUIMouseMoveEventArgs(motionEvent.Relative.Convert(), - motionEvent.Speed.Convert(), - this, - (Mouse.ButtonMask) motionEvent.ButtonMask, - motionEvent.GlobalPosition.Convert(), - motionEvent.Position.Convert(), - motionEvent.Alt, - motionEvent.Control, - motionEvent.Shift, - motionEvent.Command); - MouseMove(mouseMoveEventArgs); - break; - } - } } public class GUIKeyEventArgs : KeyEventArgs diff --git a/Robust.Client/UserInterface/Control.Signals.cs b/Robust.Client/UserInterface/Control.Signals.cs deleted file mode 100644 index 39c68a6e3..000000000 --- a/Robust.Client/UserInterface/Control.Signals.cs +++ /dev/null @@ -1,142 +0,0 @@ -using Robust.Client.GodotGlue; -using Robust.Client.Input; -using Robust.Shared.Log; - -namespace Robust.Client.UserInterface -{ - // Signal registration is a lot of annoying, hacky and ugly boiler plate - // so we put it in here! - public partial class Control - { - private GodotSignalSubscriber0 __mouseEnteredSubscriber; - private GodotSignalSubscriber0 __mouseExitedSubscriber; - private GodotSignalSubscriber1 __guiInputSubscriber; - private GodotSignalSubscriber0 __focusEnteredSubscriber; - private GodotSignalSubscriber0 __focusExitedSubscriber; - private GodotSignalSubscriber0 __treeExitedSubscriber; - private GodotSignalSubscriber0 __resizedSubscriber; - - protected virtual void SetupSignalHooks() - { - __mouseEnteredSubscriber = new GodotSignalSubscriber0(); - __mouseEnteredSubscriber.Connect(SceneControl, "mouse_entered"); - __mouseEnteredSubscriber.Signal += __mouseEnteredHook; - - __mouseExitedSubscriber = new GodotSignalSubscriber0(); - __mouseExitedSubscriber.Connect(SceneControl, "mouse_exited"); - __mouseExitedSubscriber.Signal += __mouseExitedHook; - - __guiInputSubscriber = new GodotSignalSubscriber1(); - __guiInputSubscriber.Connect(SceneControl, "gui_input"); - __guiInputSubscriber.Signal += __guiInputHook; - - __focusEnteredSubscriber = new GodotSignalSubscriber0(); - __focusEnteredSubscriber.Connect(SceneControl, "focus_entered"); - __focusEnteredSubscriber.Signal += __focusEnteredHook; - - __focusExitedSubscriber = new GodotSignalSubscriber0(); - __focusExitedSubscriber.Connect(SceneControl, "focus_exited"); - __focusExitedSubscriber.Signal += __focusExitedHook; - - __treeExitedSubscriber = new GodotSignalSubscriber0(); - __treeExitedSubscriber.Connect(SceneControl, "tree_exited"); - __treeExitedSubscriber.Signal += __treeExitedHook; - - __resizedSubscriber = new GodotSignalSubscriber0(); - __resizedSubscriber.Connect(SceneControl, "resized"); - __resizedSubscriber.Signal += __resizedHook; - } - - protected virtual void DisposeSignalHooks() - { - if (__mouseEnteredSubscriber != null) - { - __mouseEnteredSubscriber.Disconnect(SceneControl, "mouse_entered"); - __mouseEnteredSubscriber.Dispose(); - __mouseEnteredSubscriber = null; - } - - if (__mouseExitedSubscriber != null) - { - __mouseExitedSubscriber.Disconnect(SceneControl, "mouse_exited"); - __mouseExitedSubscriber.Dispose(); - __mouseExitedSubscriber = null; - } - - if (__guiInputSubscriber != null) - { - __guiInputSubscriber.Disconnect(SceneControl, "gui_input"); - __guiInputSubscriber.Dispose(); - __guiInputSubscriber = null; - } - - if (__focusEnteredSubscriber != null) - { - __focusEnteredSubscriber.Disconnect(SceneControl, "focus_entered"); - __focusEnteredSubscriber.Dispose(); - __focusEnteredSubscriber = null; - } - - if (__focusExitedSubscriber != null) - { - __focusExitedSubscriber.Disconnect(SceneControl, "focus_exited"); - __focusExitedSubscriber.Dispose(); - __focusExitedSubscriber = null; - } - - if (__treeExitedSubscriber != null) - { - __treeExitedSubscriber.Disconnect(SceneControl, "tree_exited"); - __treeExitedSubscriber.Dispose(); - __treeExitedSubscriber = null; - } - - if (__resizedSubscriber != null) - { - __resizedSubscriber.Disconnect(SceneControl, "resized"); - __resizedSubscriber.Dispose(); - __resizedSubscriber = null; - } - } - - private void __mouseEnteredHook() - { - UserInterfaceManagerInternal.GDMouseEntered(this); - MouseEntered(); - } - - private void __mouseExitedHook() - { - UserInterfaceManagerInternal.GDMouseExited(this); - MouseExited(); - } - - private void __guiInputHook(object ev) - { - HandleGuiInput((Godot.InputEvent) ev); - } - - private void __focusEnteredHook() - { - FocusEntered(); - } - - private void __focusExitedHook() - { - UserInterfaceManagerInternal.GDFocusExited(this); - FocusExited(); - } - - private void __treeExitedHook() - { - // Eh maybe make a separate event later. - UserInterfaceManagerInternal.GDFocusEntered(this); - FocusExited(); - } - - private void __resizedHook() - { - Resized(); - } - } -} diff --git a/Robust.Client/UserInterface/Control.cs b/Robust.Client/UserInterface/Control.cs index dacdf8be0..4537362db 100644 --- a/Robust.Client/UserInterface/Control.cs +++ b/Robust.Client/UserInterface/Control.cs @@ -1,5 +1,4 @@ -using Robust.Client.GodotGlue; -using Robust.Client.Interfaces.UserInterface; +using Robust.Client.Interfaces.UserInterface; using Robust.Shared.IoC; using System; using System.Collections; @@ -29,7 +28,7 @@ namespace Robust.Client.UserInterface /// See the official docs for more help: https://godot.readthedocs.io/en/3.0/classes/class_control.html /// [PublicAPI] - [ControlWrap(typeof(Godot.Control))] + [ControlWrap("Control")] // ReSharper disable once RequiredBaseTypesIsNotInherited public partial class Control : IDisposable { @@ -67,11 +66,6 @@ namespace Robust.Client.UserInterface _name = value; - if (GameController.OnGodot) - { - SceneControl.SetName(_name); - } - if (Parent != null) { Parent._children[_name] = (this, index); @@ -100,11 +94,6 @@ namespace Robust.Client.UserInterface [ViewVariables] public int ChildCount => _orderedChildren.Count; - /// - /// The control's representation in Godot's scene tree. - /// - internal Godot.Control SceneControl => WrappedSceneControl; - /// /// Path to the .tscn file for this scene in the VFS. /// This is mainly intended for content loading tscn files. @@ -112,8 +101,6 @@ namespace Robust.Client.UserInterface /// protected virtual ResourcePath ScenePath => null; - private ControlWrap WrappedSceneControl; - public const float ANCHOR_BEGIN = 0; public const float ANCHOR_END = 1; @@ -122,18 +109,11 @@ namespace Robust.Client.UserInterface [ViewVariables] public float AnchorBottom { - get => GameController.OnGodot ? SceneControl.AnchorBottom : _anchorBottom; + get => _anchorBottom; set { - if (GameController.OnGodot) - { - SceneControl.AnchorBottom = value; - } - else - { - _anchorBottom = value; - _updateLayout(); - } + _anchorBottom = value; + _updateLayout(); } } @@ -142,18 +122,11 @@ namespace Robust.Client.UserInterface [ViewVariables] public float AnchorLeft { - get => GameController.OnGodot ? SceneControl.AnchorLeft : _anchorLeft; + get => _anchorLeft; set { - if (GameController.OnGodot) - { - SceneControl.AnchorLeft = value; - } - else - { - _anchorLeft = value; - _updateLayout(); - } + _anchorLeft = value; + _updateLayout(); } } @@ -162,18 +135,11 @@ namespace Robust.Client.UserInterface [ViewVariables] public float AnchorRight { - get => GameController.OnGodot ? SceneControl.AnchorRight : _anchorRight; + get => _anchorRight; set { - if (GameController.OnGodot) - { - SceneControl.AnchorRight = value; - } - else - { - _anchorRight = value; - _updateLayout(); - } + _anchorRight = value; + _updateLayout(); } } @@ -182,18 +148,11 @@ namespace Robust.Client.UserInterface [ViewVariables] public float AnchorTop { - get => GameController.OnGodot ? SceneControl.AnchorTop : _anchorTop; + get => _anchorTop; set { - if (GameController.OnGodot) - { - SceneControl.AnchorTop = value; - } - else - { - _anchorTop = value; - _updateLayout(); - } + _anchorTop = value; + _updateLayout(); } } @@ -202,18 +161,11 @@ namespace Robust.Client.UserInterface [ViewVariables] public float MarginRight { - get => GameController.OnGodot ? SceneControl.MarginRight : _marginRight; + get => _marginRight; set { - if (GameController.OnGodot) - { - SceneControl.MarginRight = value; - } - else - { - _marginRight = value; - _updateLayout(); - } + _marginRight = value; + _updateLayout(); } } @@ -222,18 +174,11 @@ namespace Robust.Client.UserInterface [ViewVariables] public float MarginLeft { - get => GameController.OnGodot ? SceneControl.MarginLeft : _marginLeft; + get => _marginLeft; set { - if (GameController.OnGodot) - { - SceneControl.MarginLeft = value; - } - else - { - _marginLeft = value; - _updateLayout(); - } + _marginLeft = value; + _updateLayout(); } } @@ -242,18 +187,11 @@ namespace Robust.Client.UserInterface [ViewVariables] public float MarginTop { - get => GameController.OnGodot ? SceneControl.MarginTop : _marginTop; + get => _marginTop; set { - if (GameController.OnGodot) - { - SceneControl.MarginTop = value; - } - else - { - _marginTop = value; - _updateLayout(); - } + _marginTop = value; + _updateLayout(); } } @@ -262,18 +200,11 @@ namespace Robust.Client.UserInterface [ViewVariables] public float MarginBottom { - get => GameController.OnGodot ? SceneControl.MarginBottom : _marginBottom; + get => _marginBottom; set { - if (GameController.OnGodot) - { - SceneControl.MarginBottom = value; - } - else - { - _marginBottom = value; - _updateLayout(); - } + _marginBottom = value; + _updateLayout(); } } @@ -304,23 +235,16 @@ namespace Robust.Client.UserInterface [ViewVariables] public bool Visible { - get => GameController.OnGodot ? SceneControl.Visible : _visible; + get => _visible; set { - if (GameController.OnGodot) + if (_visible == value) { - SceneControl.Visible = value; + return; } - else - { - if (_visible == value) - { - return; - } - _visible = value; + _visible = value; - _propagateVisibilityChanged(value); - } + _propagateVisibilityChanged(value); } } @@ -394,20 +318,13 @@ namespace Robust.Client.UserInterface [ViewVariables] public Vector2 Size { - get => GameController.OnGodot ? SceneControl.GetSize().Convert() : _size; + get => _size; set { - if (GameController.OnGodot) - { - SceneControl.SetSize(value.Convert()); - } - else - { - var (diffX, diffY) = value - _sizeByMargins; - _marginRight += diffX; - _marginBottom += diffY; - _updateLayout(); - } + var (diffX, diffY) = value - _sizeByMargins; + _marginRight += diffX; + _marginBottom += diffY; + _updateLayout(); } } @@ -420,22 +337,15 @@ namespace Robust.Client.UserInterface [ViewVariables] public Vector2 Position { - get => GameController.OnGodot ? SceneControl.GetPosition().Convert() : _position; + get => _position; set { - if (GameController.OnGodot) - { - SceneControl.SetPosition(value.Convert()); - } - else - { - var (diffX, diffY) = value - _position; - _marginTop += diffY; - _marginBottom += diffY; - _marginLeft += diffX; - _marginRight += diffX; - _updateLayout(); - } + var (diffX, diffY) = value - _position; + _marginTop += diffY; + _marginBottom += diffY; + _marginLeft += diffX; + _marginRight += diffX; + _updateLayout(); } } @@ -444,11 +354,6 @@ namespace Robust.Client.UserInterface { get { - if (GameController.OnGodot) - { - return SceneControl.GetPosition().Convert(); - } - var offset = Position; var parent = Parent; while (parent != null) @@ -465,13 +370,9 @@ namespace Robust.Client.UserInterface public Vector2 Scale { - get => GameController.OnGodot ? SceneControl.RectScale.Convert() : default; + get => default; set { - if (GameController.OnGodot) - { - SceneControl.RectScale = value.Convert(); - } } } @@ -479,38 +380,15 @@ namespace Robust.Client.UserInterface public string ToolTip { - get => GameController.OnGodot ? SceneControl.GetTooltip() : _tooltip; + get => _tooltip; set { - if (GameController.OnGodot) - { - SceneControl.SetTooltip(value); - } - else - { - _tooltip = value; - } + _tooltip = value; } } - private MouseFilterMode _mouseFilter = MouseFilterMode.Stop; - [ViewVariables] - public MouseFilterMode MouseFilter - { - get => GameController.OnGodot ? (MouseFilterMode) SceneControl.MouseFilter : _mouseFilter; - set - { - if (GameController.OnGodot) - { - SceneControl.MouseFilter = (Godot.Control.MouseFilterEnum) value; - } - else - { - _mouseFilter = value; - } - } - } + public MouseFilterMode MouseFilter { get; set; } = MouseFilterMode.Stop; private bool _canKeyboardFocus; @@ -536,88 +414,32 @@ namespace Robust.Client.UserInterface public bool KeyboardFocusOnClick { get; set; } - private SizeFlags _sizeFlagsH = SizeFlags.Fill; - [ViewVariables] - public SizeFlags SizeFlagsHorizontal - { - get => GameController.OnGodot ? (SizeFlags) SceneControl.SizeFlagsHorizontal : _sizeFlagsH; - set - { - if (GameController.OnGodot) - { - SceneControl.SizeFlagsHorizontal = (int) value; - } - else - { - // TODO: Notify parent container. - _sizeFlagsH = value; - } - } - } + public SizeFlags SizeFlagsHorizontal { get; set; } = SizeFlags.Fill; private float _sizeFlagsStretchRatio = 1; [ViewVariables] public float SizeFlagsStretchRatio { - get => GameController.OnGodot ? SceneControl.SizeFlagsStretchRatio : _sizeFlagsStretchRatio; + get => _sizeFlagsStretchRatio; set { - if (GameController.OnGodot) + if (value <= 0) { - SceneControl.SizeFlagsStretchRatio = value; + throw new ArgumentOutOfRangeException(nameof(value), value, "Value must be greater than zero."); } - else - { - if (value <= 0) - { - throw new ArgumentOutOfRangeException(nameof(value), value, "Value must be greater than zero."); - } - // TODO: Notify parent container. - _sizeFlagsStretchRatio = value; - } + // TODO: Notify parent container. + _sizeFlagsStretchRatio = value; } } - private SizeFlags _sizeFlagsV = SizeFlags.Fill; - [ViewVariables] - public SizeFlags SizeFlagsVertical - { - get => GameController.OnGodot ? (SizeFlags) SceneControl.SizeFlagsVertical : _sizeFlagsV; - set - { - if (GameController.OnGodot) - { - SceneControl.SizeFlagsVertical = (int) value; - } - else - { - // TODO: Notify parent container. - _sizeFlagsV = value; - } - } - } + public SizeFlags SizeFlagsVertical { get; set; } = SizeFlags.Fill; - private bool _rectClipContent = false; [ViewVariables] - public bool RectClipContent - { - get => GameController.OnGodot ? SceneControl.RectClipContent : _rectClipContent; - set - { - if (GameController.OnGodot) - { - SceneControl.RectClipContent = _rectClipContent; - } - else - { - _rectClipContent = value; - } - } - } + public bool RectClipContent { get; set; } = false; /// /// A margin around this control. If this control + this margin is outside its parent's , @@ -631,23 +453,7 @@ namespace Robust.Client.UserInterface public Color? ModulateSelfOverride { get; set; } - private Color _modulate = Color.White; - - public Color Modulate - { - get => GameController.OnGodot ? SceneControl.Modulate.Convert() : _modulate; - set - { - if (GameController.OnGodot) - { - SceneControl.Modulate = value.Convert(); - } - else - { - _modulate = value; - } - } - } + public Color Modulate { get; set; } = Color.White; public Color ActualModulateSelf { @@ -677,20 +483,13 @@ namespace Robust.Client.UserInterface { get { - if (GameController.OnGodot) + if (!_calculatedMinimumSize.HasValue) { - return SceneControl.GetCombinedMinimumSize().Convert(); + _updateMinimumSize(); + DebugTools.Assert(_calculatedMinimumSize.HasValue); } - else - { - if (!_calculatedMinimumSize.HasValue) - { - _updateMinimumSize(); - DebugTools.Assert(_calculatedMinimumSize.HasValue); - } - return Vector2.ComponentMax(CustomMinimumSize, _calculatedMinimumSize.Value); - } + return Vector2.ComponentMax(CustomMinimumSize, _calculatedMinimumSize.Value); } } @@ -705,18 +504,11 @@ namespace Robust.Client.UserInterface [ViewVariables] public Vector2 CustomMinimumSize { - get => GameController.OnGodot ? SceneControl.RectMinSize.Convert() : _customMinimumSize; + get => _customMinimumSize; set { - if (GameController.OnGodot) - { - SceneControl.RectMinSize = value.Convert(); - } - else - { - _customMinimumSize = Vector2.ComponentMax(Vector2.Zero, value); - MinimumSizeChanged(); - } + _customMinimumSize = Vector2.ComponentMax(Vector2.Zero, value); + MinimumSizeChanged(); } } @@ -728,9 +520,7 @@ namespace Robust.Client.UserInterface } public Vector2 GlobalMousePosition => - GameController.OnGodot - ? SceneControl.GetGlobalMousePosition().Convert() - : IoCManager.Resolve().MouseScreenPosition; + IoCManager.Resolve().MouseScreenPosition; private readonly Dictionary _children = new Dictionary(); @@ -748,18 +538,10 @@ namespace Robust.Client.UserInterface { UserInterfaceManagerInternal = IoCManager.Resolve(); - if (GameController.OnGodot) + SetDefaults(); + if (ScenePath != null) { - SetupSceneControl(); - } - - else - { - SetDefaults(); - if (ScenePath != null) - { - _manualNodeSetup(); - } + _manualNodeSetup(); } Name = GetType().Name; @@ -778,17 +560,10 @@ namespace Robust.Client.UserInterface UserInterfaceManagerInternal = IoCManager.Resolve(); - if (GameController.OnGodot) + SetDefaults(); + if (ScenePath != null) { - SetupSceneControl(); - } - else - { - SetDefaults(); - if (ScenePath != null) - { - _manualNodeSetup(); - } + _manualNodeSetup(); } Name = name; @@ -797,22 +572,6 @@ namespace Robust.Client.UserInterface Restyle(); } - - /// - /// Wrap the provided Godot control with this one. - /// This does NOT set up parenting correctly! - /// - internal Control(Godot.Control control) - { - UserInterfaceManagerInternal = IoCManager.Resolve(); - _name = control.GetName(); - InjectControlWrap(control); - SetupSignalHooks(); - //Logger.Debug($"Wrapping control {Name} ({GetType()} -> {control.GetType()})"); - Initialize(); - Restyle(); - } - /// /// Use this to do various initialization of the control. /// Ranging from spawning children to prefetching them for later referencing. @@ -1053,85 +812,9 @@ namespace Robust.Client.UserInterface { _manualNodeTypeTranslations[attr.InstanceString] = type; } - - if (attr.ConcreteType != null) - { - _manualNodeTypeTranslations[attr.ConcreteType.Name] = type; - } } } - - private void SetupSceneControl() - { - Godot.Control newSceneControl; - if (ScenePath == null) - { - newSceneControl = SpawnSceneControl(); - } - else - { - // Get disk path with VFS. - var cache = IoCManager.Resolve(); - if (!cache.TryGetDiskFilePath(ScenePath, out var diskPath)) - { - throw new FileNotFoundException("Scene path must exist on disk."); - } - - newSceneControl = LoadScene(diskPath); - } - - InjectControlWrap(newSceneControl); - SetupSignalHooks(); - // Certain controls (LineEdit, WindowDialog, etc...) create sub controls automatically, - // handle these. - WrapChildControls(); - } - - // ASSUMING DIRECT CONTROL. - private void InjectControlWrap(Godot.Control control) - { - // Inject wrapper script to hook virtual functions. - // IMPORTANT: Because of how Scripts work in Godot, - // it has to effectively "replace" the type of the control. - // It... obviously cannot do this because this is [insert statically typed language]. - // As such: getting an instance to the control AFTER this point will yield a control of type ControlWrap. - // UPDATE: As of 3.1 alpha 3, the following does not work: - // Luckily, the old instance seems to still work flawlessy for everything, including signals!\ - // /UPDATE: so yes we need to use _Set and such now. Oh well. - var script = Godot.GD.Load("res://ControlWrap.cs"); - - // So... getting a new reference to ourselves is surprisingly difficult! - if (control.GetChildCount() > 0) - { - // Potentially easiest: if we have a child, get the parent of our child (us). - var child = control.GetChild(0); - control.SetScript(script); - WrappedSceneControl = (ControlWrap) child.GetParent(); - } - else if (control.GetParent() != null) - { - // If not but we have a parent use that. - var index = control.GetIndex(); - var parent = control.GetParent(); - control.SetScript(script); - WrappedSceneControl = (ControlWrap) parent.GetChild(index); - } - else - { - // Ok so we're literally a lone node guess making a temporary child'll be fine. - var node = new Godot.Node(); - control.AddChild(node); - control.SetScript(script); - WrappedSceneControl = (ControlWrap) node.GetParent(); - node.QueueFree(); - } - - WrappedSceneControl.GetMinimumSizeOverride = () => CalculateMinimumSize().Convert(); - WrappedSceneControl.HasPointOverride = point => HasPoint(point.Convert()); - WrappedSceneControl.DrawOverride = DoDraw; - } - private protected virtual void SetGodotProperty(string property, object value, GodotAssetScene context) { switch (property) @@ -1238,40 +921,18 @@ namespace Robust.Client.UserInterface return (T) result; } - private void DoDraw() - { - using (var handle = new DrawingHandleScreen(SceneControl.GetCanvasItem())) - { - Draw(handle); - } - } - protected internal virtual void Draw(DrawingHandleScreen handle) { } public void UpdateDraw() { - if (GameController.OnGodot) - { - SceneControl.Update(); - } } protected internal virtual void ModalRemoved() { } - /// - /// Overriden by child classes to change the Godot control type. - /// ONLY spawn the control in here. Use for holding references to it. - /// This is to allow children to override it without breaking the setting. - /// - private protected virtual Godot.Control SpawnSceneControl() - { - return new Godot.Control(); - } - public bool Disposed { get; private set; } = false; /// @@ -1292,26 +953,15 @@ namespace Robust.Client.UserInterface protected virtual void Dispose(bool disposing) { - if (disposing) + if (!disposing) { - DisposeAllChildren(); - Parent?.RemoveChild(this); - - OnKeyDown = null; + return; } + DisposeAllChildren(); + Parent?.RemoveChild(this); - if (GameController.OnGodot) - { - DisposeSignalHooks(); - } - - if (GameController.OnGodot && !GameController.ShuttingDownHard) - { - WrappedSceneControl?.QueueFree(); - WrappedSceneControl?.Dispose(); - WrappedSceneControl = null; - } + OnKeyDown = null; } ~Control() @@ -1382,13 +1032,6 @@ namespace Robust.Client.UserInterface child.Name = childName; } - if (GameController.OnGodot) - { - SceneControl.AddChild(child.SceneControl, LegibleUniqueName); - // Godot changes the name automatically if you would cause a naming conflict. - child._name = child.SceneControl.GetName(); - } - child.Parent = this; _children[child.Name] = (child, _orderedChildren.Count); _orderedChildren.Add(child); @@ -1435,10 +1078,6 @@ namespace Robust.Client.UserInterface _updateChildIndices(); child.Parent = null; - if (GameController.OnGodot) - { - SceneControl.RemoveChild(child.SceneControl); - } child.Deparented(); if (IsInsideTree) @@ -1482,12 +1121,6 @@ namespace Robust.Client.UserInterface /// public void MinimumSizeChanged() { - if (GameController.OnGodot) - { - SceneControl.MinimumSizeChanged(); - return; - } - _calculatedMinimumSize = null; _updateLayout(); OnMinimumSizeChanged?.Invoke(this); @@ -1592,30 +1225,6 @@ namespace Robust.Client.UserInterface return; } - if (GameController.OnGodot) - { - // Because some controls spawn other sub nodes like timers, - // This position doesn't map to the scene tree. - var parentScene = Parent.SceneControl; - var siblingCount = parentScene.GetChildCount(); - var counter = 0; - for (var i = 0; i < siblingCount; i++) - { - var sibling = parentScene.GetChild(i); - // Use a counter that counts the controls to figure out the position to move to. - if (sibling is Godot.Control) - { - if (counter == position) - { - parentScene.MoveChild(SceneControl, counter); - break; - } - - counter += 1; - } - } - } - Parent._orderedChildren.RemoveAt(posInParent); Parent._orderedChildren.Insert(position, this); Parent._updateChildIndices(); @@ -1658,164 +1267,23 @@ namespace Robust.Client.UserInterface public bool HasKeyboardFocus() { - return GameController.OnGodot ? SceneControl.HasFocus() : UserInterfaceManager.KeyboardFocused == this; + return UserInterfaceManager.KeyboardFocused == this; } public void GrabKeyboardFocus() { - if (GameController.OnGodot) - { - SceneControl.GrabFocus(); - } - else - { - UserInterfaceManager.GrabKeyboardFocus(this); - } + UserInterfaceManager.GrabKeyboardFocus(this); } public void ReleaseKeyboardFocus() { - if (GameController.OnGodot) - { - SceneControl?.ReleaseFocus(); - } - else - { - UserInterfaceManager.ReleaseKeyboardFocus(this); - } + UserInterfaceManager.ReleaseKeyboardFocus(this); } protected virtual void Resized() { } - internal static Control InstanceScene(string resourcePath) - { - var res = (Godot.PackedScene) Godot.ResourceLoader.Load(resourcePath); - return InstanceScene(res); - } - - /// - /// Instance a packed Godot scene as a child of this one, wrapping all the nodes in SS14 controls. - /// This makes it possible to use Godot's GUI editor relatively comfortably, - /// while still being able to use the better SS14 API. - /// - /// - /// - // TODO: Handle instances inside the provided scene in some way. - // Shouldn't need more than support for populating the GodotTranslationCache - // from Robust.Client.Godot I *think*? - internal static Control InstanceScene(Godot.PackedScene scene) - { - var root = (Godot.Control) scene.Instance(); - return WrapGodotControl(null, root); - } - - private static Control WrapGodotControl(Control parent, Godot.Control control) - { - var type = FindGodotTranslationType(control); - var newControl = (Control) Activator.CreateInstance(type, - BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance | BindingFlags.NonPublic, - null, new object[] {control}, null, null); - - if (parent != null) - { - newControl.Parent = parent; - parent._children[newControl.Name] = (newControl, parent._orderedChildren.Count); - parent._orderedChildren.Add(newControl); - } - - newControl.WrapChildControls(); - - return newControl; - } - - private void WrapChildControls() - { - foreach (var child in SceneControl.GetChildren()) - { - // Some Godot nodes have subnodes. - // great example being the LineEdit. - // These subnodes may be other stuff like timers, - // so don't blow up on it! - if (child is Godot.Control childControl) - { - WrapGodotControl(this, childControl); - } - } - } - - private static Dictionary GodotTranslationCache; - - // Because the translation cache may not include every control, - // for example controls we don't have SS14 counterparts to, - // this method will look up the inheritance tree until (last resort) it hits Godot.Control. - // Filling in the blanks later. - private static Type FindGodotTranslationType(Godot.Control control) - { - if (GodotTranslationCache == null) - { - SetupGodotTranslationCache(); - } - - var original = control.GetType(); - var tmp = original; - // CanvasItem is the parent of Godot.Control so reaching it means we passed Godot.Control. - while (tmp != typeof(Godot.CanvasItem)) - { - if (GodotTranslationCache.TryGetValue(tmp, out var info)) - { - if (original != tmp) - { - GodotTranslationCache[original] = info; - } - - return info; - } - - tmp = tmp.BaseType; - } - - throw new InvalidOperationException( - "Managed to pass Godot.Control when finding translations. This should be impossible!"); - } - - private static void SetupGodotTranslationCache() - { - GodotTranslationCache = new Dictionary(); - var refl = IoCManager.Resolve(); - foreach (var childType in refl.GetAllChildren(inclusive: true)) - { - var attr = childType.GetCustomAttribute(); - if (attr == null) - { - continue; - } - - var godotType = attr.ConcreteType; - if (godotType == null) - { - continue; - } - - if (GodotTranslationCache.TryGetValue(godotType, out var dupe)) - { - Logger.Error( - $"Found multiple SS14 Control types pointing to a single Godot Control type. Godot: {godotType}, first: {dupe}, second: {childType}"); - continue; - } - - GodotTranslationCache[godotType] = childType; - } - - if (!GodotTranslationCache.ContainsKey(typeof(Godot.Control))) - { - GodotTranslationCache = null; - throw new InvalidOperationException( - "We don't even have the base Godot Control in the translation cache. We can't use scene instancing like this!"); - } - } - public void SetAnchorAndMarginPreset(LayoutPreset preset, LayoutPresetMode mode = LayoutPresetMode.MinSize, int margin = 0) { @@ -1839,12 +1307,6 @@ namespace Robust.Client.UserInterface /// public void SetAnchorPreset(LayoutPreset preset, bool keepMargin = false) { - if (GameController.OnGodot) - { - SceneControl.SetAnchorsPreset((Godot.Control.LayoutPreset) preset, keepMargin); - return; - } - // Left Anchor. switch (preset) { @@ -1968,13 +1430,6 @@ namespace Robust.Client.UserInterface public void SetMarginsPreset(LayoutPreset preset, LayoutPresetMode resizeMode = LayoutPresetMode.MinSize, int margin = 0) { - if (GameController.OnGodot) - { - SceneControl.SetMarginsPreset((Godot.Control.LayoutPreset) preset, - (Godot.Control.LayoutPresetMode) resizeMode, margin); - return; - } - var newSize = Size; var minSize = CombinedMinimumSize; if ((resizeMode & LayoutPresetMode.KeepWidth) == 0) @@ -2195,106 +1650,6 @@ namespace Robust.Client.UserInterface ShrinkEnd = 8, } - protected void SetColorOverride(string name, Color? color) - { - if (!GameController.OnGodot) - { - return; - } - - // So here's an interesting one. - // Godot's AddColorOverride and such API on controls - // Doesn't actually have a way to REMOVE the override. - // Passing null via Set() does though. - if (color != null) - { - SceneControl.AddColorOverride(name, color.Value.Convert()); - } - else - { - SceneControl.Set($"custom_colors/{name}", null); - } - } - - protected Color? GetColorOverride(string name) - { - if (!GameController.OnGodot) - { - return default; - } - - return SceneControl.HasColorOverride(name) ? SceneControl.GetColor(name).Convert() : (Color?) null; - } - - protected void SetConstantOverride(string name, int? constant) - { - if (!GameController.OnGodot) - { - return; - } - - if (constant != null) - { - SceneControl.AddConstantOverride(name, constant.Value); - } - else - { - SceneControl.Set($"custom_constants/{name}", null); - } - } - - protected int? GetConstantOverride(string name) - { - if (!GameController.OnGodot) - { - return default; - } - - return SceneControl.HasConstantOverride(name) ? SceneControl.GetConstant(name) : (int?) null; - } - - protected void SetStyleBoxOverride(string name, StyleBox styleBox) - { - if (!GameController.OnGodot) - { - return; - } - - SceneControl.AddStyleboxOverride(name, styleBox.GodotStyleBox); - } - - protected StyleBox GetStyleBoxOverride(string name) - { - if (!GameController.OnGodot) - { - return default; - } - - var box = SceneControl.HasStyleboxOverride(name) ? SceneControl.GetStylebox(name) : null; - return box == null ? null : new GodotStyleBoxWrap(box); - } - - protected void SetFontOverride(string name, Font font) - { - if (!GameController.OnGodot) - { - return; - } - - SceneControl.AddFontOverride(name, font); - } - - protected Font GetFontOverride(string name) - { - if (!GameController.OnGodot) - { - return default; - } - - var font = SceneControl.HasFontOverride(name) ? SceneControl.GetFont(name) : null; - return font == null ? null : new GodotWrapFont(font); - } - internal void DoUpdate(ProcessFrameEventArgs args) { Update(args); @@ -2335,11 +1690,6 @@ namespace Robust.Client.UserInterface private void _doUpdateLayout() { - if (GameController.OnGodot) - { - return; - } - var (pSizeX, pSizeY) = Parent?._size ?? Vector2.Zero; var top = _anchorTop * pSizeY + _marginTop; @@ -2398,13 +1748,9 @@ namespace Robust.Client.UserInterface public CursorShape DefaultCursorShape { - get => GameController.OnGodot ? (CursorShape) SceneControl.GetDefaultCursorShape() : default; + get => default; set { - if (GameController.OnGodot) - { - SceneControl.SetDefaultCursorShape((Godot.Control.CursorShape) value); - } } } @@ -2437,17 +1783,6 @@ namespace Robust.Client.UserInterface Ignore = 2, } - /// - /// Convenient helper to load a Godot scene without all the casting. Does NOT wrap the nodes (duh!). - /// - /// The resource path to the scene file to load. - /// The root of the loaded scene. - private protected static Godot.Control LoadScene(string path) - { - var scene2 = (Godot.PackedScene) Godot.ResourceLoader.Load(path); - return (Godot.Control) scene2.Instance(); - } - public readonly struct OrderedChildEnumerable : IEnumerable { private readonly Control Owner; @@ -2478,18 +1813,6 @@ namespace Robust.Client.UserInterface internal class ControlWrapAttribute : Attribute { public readonly string InstanceString; - public readonly Type ConcreteType; - - public ControlWrapAttribute(Type concreteType) - { - ConcreteType = concreteType; - } - - public ControlWrapAttribute(Type concreteType, string instanceString) - { - ConcreteType = concreteType; - InstanceString = instanceString; - } public ControlWrapAttribute(string instanceString) { diff --git a/Robust.Client/UserInterface/Controls/BaseButton.cs b/Robust.Client/UserInterface/Controls/BaseButton.cs index 785cffc48..7ace296bd 100644 --- a/Robust.Client/UserInterface/Controls/BaseButton.cs +++ b/Robust.Client/UserInterface/Controls/BaseButton.cs @@ -1,5 +1,4 @@ -using Robust.Client.GodotGlue; -using System; +using System; using JetBrains.Annotations; using Robust.Client.Utility; using Robust.Shared.Log; @@ -8,7 +7,7 @@ using Robust.Shared.ViewVariables; namespace Robust.Client.UserInterface.Controls { [PublicAPI] - [ControlWrap(typeof(Godot.BaseButton))] + [ControlWrap("BaseButton")] public abstract class BaseButton : Control { private bool _attemptingPress; @@ -22,50 +21,23 @@ namespace Robust.Client.UserInterface.Controls { } - internal BaseButton(Godot.BaseButton button) : base(button) - { - } - - private ActionMode _mode = ActionMode.Release; - [ViewVariables] - public ActionMode Mode - { - get => GameController.OnGodot ? (ActionMode) SceneControl.Get("action_mode") : _mode; - set - { - if (GameController.OnGodot) - { - SceneControl.Set("action_mode", (Godot.BaseButton.ActionModeEnum) value); - } - else - { - _mode = value; - } - } - } + public ActionMode Mode { get; set; } = ActionMode.Release; private bool _disabled; [ViewVariables] public bool Disabled { - get => GameController.OnGodot ? (bool) SceneControl.Get("disabled") : _disabled; + get => _disabled; set { - if (GameController.OnGodot) - { - SceneControl.Set("disabled", value); - } - else - { - var old = _disabled; - _disabled = value; + var old = _disabled; + _disabled = value; - if (old != value) - { - DrawModeChanged(); - } + if (old != value) + { + DrawModeChanged(); } } } @@ -78,43 +50,21 @@ namespace Robust.Client.UserInterface.Controls [ViewVariables] public bool Pressed { - get => GameController.OnGodot ? (bool) SceneControl.Get("pressed") : _pressed; + get => _pressed; set { - if (GameController.OnGodot) + if (_pressed == value) { - SceneControl.Set("pressed", value); + return; } - else - { - if (_pressed != value) - { - _pressed = value; + _pressed = value; - DrawModeChanged(); - } - } + DrawModeChanged(); } } - private bool _toggleMode; - [ViewVariables] - public bool ToggleMode - { - get => GameController.OnGodot ? (bool) SceneControl.Get("toggle_mode") : _toggleMode; - set - { - if (GameController.OnGodot) - { - SceneControl.Set("toggle_mode", value); - } - else - { - _toggleMode = value; - } - } - } + public bool ToggleMode { get; set; } public enum ActionMode { @@ -123,18 +73,13 @@ namespace Robust.Client.UserInterface.Controls } [ViewVariables] - public bool IsHovered => GameController.OnGodot ? (bool) SceneControl.Call("is_hovered") : _beingHovered; + public bool IsHovered => _beingHovered; [ViewVariables] public DrawModeEnum DrawMode { get { - if (GameController.OnGodot) - { - return (DrawModeEnum) SceneControl.Call("get_draw_mode"); - } - if (Disabled) { return DrawModeEnum.Disabled; @@ -154,21 +99,7 @@ namespace Robust.Client.UserInterface.Controls } } - private ButtonGroup _buttonGroup; - - public ButtonGroup ButtonGroup - { - get => _buttonGroup ?? (GameController.OnGodot - ? new ButtonGroup((Godot.ButtonGroup) SceneControl.Call("get_button_group")) - : null); - set - { - if (GameController.OnGodot) - { - SceneControl.Call("set_button_group", value?.GodotGroup); - } - } - } + public ButtonGroup ButtonGroup { get; set; } public event Action OnButtonDown; public event Action OnButtonUp; @@ -183,7 +114,7 @@ namespace Robust.Client.UserInterface.Controls { base.MouseDown(args); - if (GameController.OnGodot || Disabled) + if (Disabled) { return; } @@ -221,7 +152,7 @@ namespace Robust.Client.UserInterface.Controls { base.MouseUp(args); - if (GameController.OnGodot || Disabled) + if (Disabled) { return; } @@ -255,11 +186,6 @@ namespace Robust.Client.UserInterface.Controls { base.MouseEntered(); - if (GameController.OnGodot) - { - return; - } - var drawMode = DrawMode; _beingHovered = true; if (drawMode != DrawMode) @@ -272,11 +198,6 @@ namespace Robust.Client.UserInterface.Controls { base.MouseExited(); - if (GameController.OnGodot) - { - return; - } - var drawMode = DrawMode; _beingHovered = false; if (drawMode != DrawMode) @@ -319,85 +240,6 @@ namespace Robust.Client.UserInterface.Controls } } - private GodotSignalSubscriber0 __buttonDownSubscriber; - private GodotSignalSubscriber0 __buttonUpSubscriber; - private GodotSignalSubscriber1 __toggledSubscriber; - private GodotSignalSubscriber0 __pressedSubscriber; - - protected override void SetupSignalHooks() - { - base.SetupSignalHooks(); - - __buttonDownSubscriber = new GodotSignalSubscriber0(); - __buttonDownSubscriber.Connect(SceneControl, "button_down"); - __buttonDownSubscriber.Signal += __buttonDownHook; - - __buttonUpSubscriber = new GodotSignalSubscriber0(); - __buttonUpSubscriber.Connect(SceneControl, "button_up"); - __buttonUpSubscriber.Signal += __buttonUpHook; - - __toggledSubscriber = new GodotSignalSubscriber1(); - __toggledSubscriber.Connect(SceneControl, "toggled"); - __toggledSubscriber.Signal += __toggledHook; - - __pressedSubscriber = new GodotSignalSubscriber0(); - __pressedSubscriber.Connect(SceneControl, "pressed"); - __pressedSubscriber.Signal += __pressedHook; - } - - protected override void DisposeSignalHooks() - { - base.DisposeSignalHooks(); - - if (__buttonDownSubscriber != null) - { - __buttonDownSubscriber.Disconnect(SceneControl, "button_down"); - __buttonDownSubscriber.Dispose(); - __buttonDownSubscriber = null; - } - - if (__buttonUpSubscriber != null) - { - __buttonUpSubscriber.Disconnect(SceneControl, "button_up"); - __buttonUpSubscriber.Dispose(); - __buttonUpSubscriber = null; - } - - if (__toggledSubscriber != null) - { - __toggledSubscriber.Disconnect(SceneControl, "toggled"); - __toggledSubscriber.Dispose(); - __toggledSubscriber = null; - } - - if (__pressedSubscriber != null) - { - __pressedSubscriber.Disconnect(SceneControl, "pressed"); - __pressedSubscriber.Dispose(); - __pressedSubscriber = null; - } - } - - private void __buttonDownHook() - { - OnButtonDown?.Invoke(new ButtonEventArgs(this)); - } - - private void __buttonUpHook() - { - OnButtonUp?.Invoke(new ButtonEventArgs(this)); - } - - private void __pressedHook() - { - OnPressed?.Invoke(new ButtonEventArgs(this)); - } - - private void __toggledHook(object state) - { - OnToggled?.Invoke(new ButtonToggledEventArgs((bool) state, this)); - } - private protected override void SetGodotProperty(string property, object value, GodotAssetScene context) { base.SetGodotProperty(property, value, context); @@ -416,56 +258,5 @@ namespace Robust.Client.UserInterface.Controls public sealed class ButtonGroup { - public Godot.ButtonGroup GodotGroup { get; } - - public ButtonGroup() - { - if (GameController.OnGodot) - { - GodotGroup = new Godot.ButtonGroup(); - } - } - - public ButtonGroup(Godot.ButtonGroup group) - { - GodotGroup = group; - } - - private bool Equals(ButtonGroup other) - { - if (ReferenceEquals(this, other)) - { - return true; - } - - if (GameController.OnGodot) - { - return Equals(GodotGroup, other.GodotGroup); - } - - return false; - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is ButtonGroup grp && Equals(grp); - } - - public override int GetHashCode() - { - return GodotGroup != null ? GodotGroup.GetHashCode() : 0; - } - - public static bool operator ==(ButtonGroup left, ButtonGroup right) - { - return Equals(left, right); - } - - public static bool operator !=(ButtonGroup left, ButtonGroup right) - { - return !Equals(left, right); - } } } diff --git a/Robust.Client/UserInterface/Controls/BoxContainer.cs b/Robust.Client/UserInterface/Controls/BoxContainer.cs index 82577e7a1..77ce81cb2 100644 --- a/Robust.Client/UserInterface/Controls/BoxContainer.cs +++ b/Robust.Client/UserInterface/Controls/BoxContainer.cs @@ -4,7 +4,7 @@ using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(BoxContainer))] + [ControlWrap("BoxContainer")] public abstract class BoxContainer : Container { public const string StylePropertySeparation = "separation"; @@ -20,27 +20,7 @@ namespace Robust.Client.UserInterface.Controls { } - internal BoxContainer(Godot.BoxContainer sceneControl) : base(sceneControl) - { - } - - private AlignMode _align; - - public AlignMode Align - { - get => GameController.OnGodot ? (AlignMode) SceneControl.Get("align_mode") : _align; - set - { - if (GameController.OnGodot) - { - SceneControl.Set("align_mode", (int) value); - } - else - { - _align = value; - } - } - } + public AlignMode Align { get; set; } private int ActualSeparation { @@ -51,17 +31,11 @@ namespace Robust.Client.UserInterface.Controls return separation; } - return _separationOverride ?? 1; + return SeparationOverride ?? 1; } } - private int? _separationOverride; - - public int? SeparationOverride - { - get => _separationOverride ?? GetConstantOverride("separation"); - set => SetConstantOverride("separation", _separationOverride = value); - } + public int? SeparationOverride { get; set; } protected override void SortChildren() { @@ -160,7 +134,7 @@ namespace Robust.Client.UserInterface.Controls var offset = 0; if (!stretchingAtAll) { - switch (_align) + switch (Align) { case AlignMode.Begin: break; @@ -203,10 +177,6 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return base.CalculateMinimumSize(); - } var separation = ActualSeparation; var minWidth = 0f; diff --git a/Robust.Client/UserInterface/Controls/Button.cs b/Robust.Client/UserInterface/Controls/Button.cs index e1770afe7..00a815721 100644 --- a/Robust.Client/UserInterface/Controls/Button.cs +++ b/Robust.Client/UserInterface/Controls/Button.cs @@ -7,7 +7,7 @@ using Robust.Shared.ViewVariables; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.Button))] + [ControlWrap("Button")] public class Button : BaseButton { public const string StylePropertyStyleBox = "stylebox"; @@ -25,71 +25,23 @@ namespace Robust.Client.UserInterface.Controls { } - internal Button(Godot.Button button) : base(button) - { - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.Button(); - } - - private AlignMode _textAlign = AlignMode.Center; + [ViewVariables] + public AlignMode TextAlign { get; set; } = AlignMode.Center; [ViewVariables] - public AlignMode TextAlign - { - get => GameController.OnGodot ? (AlignMode) SceneControl.Get("align") : _textAlign; - set - { - if (GameController.OnGodot) - { - SceneControl.Set("align", (Godot.Button.TextAlign) value); - } - else - { - _textAlign = value; - } - } - } - - private bool _clipText; - - [ViewVariables] - public bool ClipText - { - get => GameController.OnGodot ? (bool) SceneControl.Get("clip_text") : _clipText; - set - { - if (GameController.OnGodot) - { - SceneControl.Set("clip_text", value); - } - else - { - _clipText = value; - } - } - } + public bool ClipText { get; set; } private string _text; [ViewVariables] public string Text { - get => GameController.OnGodot ? (string) SceneControl.Get("text") : _text; + get => _text; set { - if (GameController.OnGodot) - { - SceneControl.Set("text", value); - } - else - { - _text = value; - _textWidthCache = null; - MinimumSizeChanged(); - } + _text = value; + _textWidthCache = null; + MinimumSizeChanged(); } } @@ -128,41 +80,14 @@ namespace Robust.Client.UserInterface.Controls return fontColor; } - return _fontColorOverride ?? Color.White; + return FontColorOverride ?? Color.White; } } - private Color? _fontColorOverride; - - public Color? FontColorOverride - { - get => _fontColorOverride ?? GetColorOverride("font_color"); - set => SetColorOverride("font_color", _fontColorOverride = value); - } - - private Color? _fontColorDisabledOverride; - - public Color? FontColorDisabledOverride - { - get => _fontColorDisabledOverride ?? GetColorOverride("font_color_disabled"); - set => SetColorOverride("font_color_disabled", _fontColorDisabledOverride = value); - } - - private Color? _fontColorHoverOverride; - - public Color? FontColorHoverOverride - { - get => _fontColorHoverOverride ?? GetColorOverride("font_color_hover"); - set => SetColorOverride("font_color_hover", _fontColorHoverOverride = value); - } - - private Color? _fontColorPressedOverride; - - public Color? FontColorPressedOverride - { - get => _fontColorPressedOverride ?? GetColorOverride("font_color_pressed"); - set => SetColorOverride("font_color_pressed", _fontColorPressedOverride = value); - } + public Color? FontColorOverride { get; set; } + public Color? FontColorDisabledOverride { get; set; } + public Color? FontColorHoverOverride { get; set; } + public Color? FontColorPressedOverride { get; set; } public enum AlignMode { @@ -175,11 +100,6 @@ namespace Robust.Client.UserInterface.Controls { base.Draw(handle); - if (GameController.OnGodot) - { - return; - } - var style = ActualStyleBox; var drawBox = SizeBox; style.Draw(handle, drawBox); @@ -243,12 +163,6 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return base.CalculateMinimumSize(); - } - - var uiTheme = UserInterfaceManager.ThemeDefaults; var style = ActualStyleBox; var font = ActualFont; diff --git a/Robust.Client/UserInterface/Controls/CenterContainer.cs b/Robust.Client/UserInterface/Controls/CenterContainer.cs index 83b809251..4045e35a2 100644 --- a/Robust.Client/UserInterface/Controls/CenterContainer.cs +++ b/Robust.Client/UserInterface/Controls/CenterContainer.cs @@ -2,17 +2,9 @@ using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.CenterContainer))] + [ControlWrap("CenterContainer")] public class CenterContainer : Container { - public CenterContainer() {} - public CenterContainer(Godot.CenterContainer control) : base(control) {} - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.CenterContainer(); - } - protected override void SortChildren() { foreach (var child in Children) @@ -26,11 +18,6 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return Vector2.Zero; - } - var min = Vector2.Zero; foreach (var child in Children) diff --git a/Robust.Client/UserInterface/Controls/CheckBox.cs b/Robust.Client/UserInterface/Controls/CheckBox.cs index 0b632c96f..063dd5d3b 100644 --- a/Robust.Client/UserInterface/Controls/CheckBox.cs +++ b/Robust.Client/UserInterface/Controls/CheckBox.cs @@ -4,7 +4,7 @@ using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.CheckBox))] + [ControlWrap("CheckBox")] public class CheckBox : Button { public const string StylePropertyIcon = "icon"; @@ -18,17 +18,8 @@ namespace Robust.Client.UserInterface.Controls { } - internal CheckBox(Godot.CheckBox box) : base(box) - { - } - protected internal override void Draw(DrawingHandleScreen handle) { - if (GameController.OnGodot) - { - return; - } - var offset = 0; var icon = _getIcon(); if (icon != null) @@ -43,11 +34,6 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return Vector2.Zero; - } - var minSize = _getIcon()?.Size ?? Vector2i.Zero; var font = ActualFont; @@ -80,11 +66,6 @@ namespace Robust.Client.UserInterface.Controls return 0; } - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.CheckBox(); - } - protected override void SetDefaults() { base.SetDefaults(); diff --git a/Robust.Client/UserInterface/Controls/CheckButton.cs b/Robust.Client/UserInterface/Controls/CheckButton.cs index 4ff2c3d01..779792ad2 100644 --- a/Robust.Client/UserInterface/Controls/CheckButton.cs +++ b/Robust.Client/UserInterface/Controls/CheckButton.cs @@ -1,14 +1,10 @@ namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.CheckButton))] + [ControlWrap("CheckButton")] public class CheckButton : Button { public CheckButton() { } - - public CheckButton(Godot.CheckButton button) : base(button) - { - } } } diff --git a/Robust.Client/UserInterface/Controls/Container.cs b/Robust.Client/UserInterface/Controls/Container.cs index ee0ed7174..6e3e95040 100644 --- a/Robust.Client/UserInterface/Controls/Container.cs +++ b/Robust.Client/UserInterface/Controls/Container.cs @@ -3,7 +3,7 @@ using Robust.Shared.Utility; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.Container))] + [ControlWrap("Container")] public class Container : Control { public Container() : base() @@ -14,17 +14,6 @@ namespace Robust.Client.UserInterface.Controls { } - // So for SOME REASON Godot.TabContainer wasn't a Container until 3.1. - // ??? - internal Container(Godot.Control sceneControl) : base(sceneControl) - { - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.Container(); - } - protected virtual void SortChildren() { @@ -34,26 +23,20 @@ namespace Robust.Client.UserInterface.Controls { base.ChildAdded(newChild); - if (!GameController.OnGodot) - { - newChild.OnMinimumSizeChanged += _childChanged; - newChild.OnVisibilityChanged += _childChanged; - MinimumSizeChanged(); - SortChildren(); - } + newChild.OnMinimumSizeChanged += _childChanged; + newChild.OnVisibilityChanged += _childChanged; + MinimumSizeChanged(); + SortChildren(); } protected override void ChildRemoved(Control child) { base.ChildRemoved(child); - if (!GameController.OnGodot) - { - child.OnMinimumSizeChanged -= _childChanged; - child.OnVisibilityChanged -= _childChanged; - MinimumSizeChanged(); - SortChildren(); - } + child.OnMinimumSizeChanged -= _childChanged; + child.OnVisibilityChanged -= _childChanged; + MinimumSizeChanged(); + SortChildren(); } protected void FitChildInBox(Control child, UIBox2 box) @@ -109,11 +92,6 @@ namespace Robust.Client.UserInterface.Controls { base.Resized(); - if (GameController.OnGodot) - { - return; - } - SortChildren(); } } diff --git a/Robust.Client/UserInterface/Controls/GridContainer.cs b/Robust.Client/UserInterface/Controls/GridContainer.cs index 508fd8c7c..d4b5b4319 100644 --- a/Robust.Client/UserInterface/Controls/GridContainer.cs +++ b/Robust.Client/UserInterface/Controls/GridContainer.cs @@ -4,7 +4,7 @@ using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.GridContainer))] + [ControlWrap("GridContainer")] public class GridContainer : Container { private int _columns = 1; @@ -17,35 +17,19 @@ namespace Robust.Client.UserInterface.Controls { } - internal GridContainer(Godot.GridContainer sceneControl) : base(sceneControl) - { - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.GridContainer(); - } - public int Columns { - get => GameController.OnGodot ? (int) SceneControl.Get("columns") : _columns; + get => _columns; set { - if (GameController.OnGodot) + if (value <= 0) { - SceneControl.Set("columns", value); + throw new ArgumentOutOfRangeException(nameof(value), value, "Value must be greater than zero."); } - else - { - if (value <= 0) - { - throw new ArgumentOutOfRangeException(nameof(value), value, "Value must be greater than zero."); - } - _columns = value; - MinimumSizeChanged(); - SortChildren(); - } + _columns = value; + MinimumSizeChanged(); + SortChildren(); } } @@ -73,8 +57,8 @@ namespace Robust.Client.UserInterface.Controls [SuppressMessage("ReSharper", "StringLiteralTypo")] public int? VSeparationOverride { - get => _vSeparationOverride ?? GetConstantOverride("vseparation"); - set => SetConstantOverride("vseparation", _vSeparationOverride = value); + get => _vSeparationOverride; + set => _vSeparationOverride = value; } private int? _hSeparationOverride; @@ -82,19 +66,14 @@ namespace Robust.Client.UserInterface.Controls [SuppressMessage("ReSharper", "StringLiteralTypo")] public int? HSeparationOverride { - get => _hSeparationOverride ?? GetConstantOverride("hseparation"); - set => SetConstantOverride("hseparation", _hSeparationOverride = value); + get => _hSeparationOverride; + set => _hSeparationOverride = value; } private (int h, int v) Separations => (_hSeparationOverride ?? 4, _vSeparationOverride ?? 4); protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return Vector2.Zero; - } - var firstRow = true; var totalMinSize = Vector2.Zero; var thisRowSize = Vector2.Zero; diff --git a/Robust.Client/UserInterface/Controls/HBoxContainer.cs b/Robust.Client/UserInterface/Controls/HBoxContainer.cs index f1c468cb7..53f08256d 100644 --- a/Robust.Client/UserInterface/Controls/HBoxContainer.cs +++ b/Robust.Client/UserInterface/Controls/HBoxContainer.cs @@ -1,6 +1,6 @@ namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.HBoxContainer))] + [ControlWrap("HBoxContainer")] public class HBoxContainer : BoxContainer { public HBoxContainer() : base() @@ -11,15 +11,6 @@ { } - internal HBoxContainer(Godot.HBoxContainer sceneControl) : base(sceneControl) - { - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.HBoxContainer(); - } - private protected override bool Vertical => false; } } diff --git a/Robust.Client/UserInterface/Controls/HScrollBar.cs b/Robust.Client/UserInterface/Controls/HScrollBar.cs index 81374038e..e802c5edd 100644 --- a/Robust.Client/UserInterface/Controls/HScrollBar.cs +++ b/Robust.Client/UserInterface/Controls/HScrollBar.cs @@ -1,19 +1,10 @@ namespace Robust.Client.UserInterface.Controls { - [Control.ControlWrapAttribute(typeof(Godot.HScrollBar))] + [Control.ControlWrapAttribute("HScrollBar")] public class HScrollBar : ScrollBar { public HScrollBar() : base(OrientationMode.Horizontal) { } - - internal HScrollBar(Godot.HScrollBar control) : base(control) - { - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.HScrollBar(); - } } } diff --git a/Robust.Client/UserInterface/Controls/HSplitContainer.cs b/Robust.Client/UserInterface/Controls/HSplitContainer.cs index e75e765ff..d2da585c3 100644 --- a/Robust.Client/UserInterface/Controls/HSplitContainer.cs +++ b/Robust.Client/UserInterface/Controls/HSplitContainer.cs @@ -1,11 +1,10 @@ namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.HSplitContainer))] + [ControlWrap("HSplitContainer")] public class HSplitContainer : SplitContainer { private protected sealed override bool Vertical => false; public HSplitContainer() {} - public HSplitContainer(Godot.HSplitContainer control) : base(control) {} } } diff --git a/Robust.Client/UserInterface/Controls/ItemList.cs b/Robust.Client/UserInterface/Controls/ItemList.cs index 06396383e..66dc6d1fa 100644 --- a/Robust.Client/UserInterface/Controls/ItemList.cs +++ b/Robust.Client/UserInterface/Controls/ItemList.cs @@ -11,7 +11,7 @@ using Font = Robust.Client.Graphics.Font; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.ItemList))] + [ControlWrap("ItemList")] public class ItemList : Control { private bool _isAtBottom = true; @@ -29,7 +29,7 @@ namespace Robust.Client.UserInterface.Controls public const string StylePropertySelectedItemBackground = "selected-item-background"; public const string StylePropertyDisabledItemBackground = "disabled-item-background"; - public int ItemCount => GameController.OnGodot ? (int)SceneControl.Call("get_item_count") : _itemList.Count; + public int ItemCount => _itemList.Count; public bool ScrollFollowing { get; set; } = true; @@ -45,20 +45,11 @@ namespace Robust.Client.UserInterface.Controls { } - internal ItemList(Godot.ItemList control) : base(control) - { - } - protected override void SetDefaults() { RectClipContent = true; } - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.ItemList(); - } - private void RecalculateContentHeight() { _totalContentHeight = 0; @@ -74,236 +65,118 @@ namespace Robust.Client.UserInterface.Controls public void AddItem(string text, Texture icon = null, bool selectable = true) { - if (GameController.OnGodot) + var item = new Item {Text = text, Icon = icon, Selectable = selectable}; + _itemList.Add(item); + RecalculateContentHeight(); + if (_isAtBottom && ScrollFollowing) { - SceneControl.Call("add_item", text, icon, selectable); - } - else - { - var item = new Item() {Text = text, Icon = icon, Selectable = selectable}; - _itemList.Add(item); - RecalculateContentHeight(); - if (_isAtBottom && ScrollFollowing) - { - _scrollBar.Value = ScrollLimit; + _scrollBar.Value = ScrollLimit; - } } } public void AddIconItem(Texture icon, bool selectable = true) { - if (GameController.OnGodot) - { - SceneControl.Call("add_icon_item", icon, selectable); - } - else - { - AddItem(null, icon, selectable); - } + AddItem(null, icon, selectable); } public void Clear() { - if (GameController.OnGodot) - { - SceneControl.Call("clear"); - } - else - { - _itemList.Clear(); - _totalContentHeight = 0; - } + _itemList.Clear(); + _totalContentHeight = 0; } public void EnsureCurrentIsVisible() { - if (GameController.OnGodot) - { - SceneControl.Call("ensure_current_is_visible"); - } + // TODO: Implement this. } public int GetItemAtPosition(Vector2 position, bool exact = false) { - return GameController.OnGodot ? (int)SceneControl.Call("get_item_at_position", position.Convert(), exact) : default; + throw new NotImplementedException(); } public bool IsSelected(int idx) { - return GameController.OnGodot ? (bool)SceneControl.Call("is_selected", idx) : _itemList[idx].Selected; + return _itemList[idx].Selected; } public void RemoveItem(int idx) { - if (GameController.OnGodot) - { - SceneControl.Call("remove_item", idx); - } - else - { - _itemList.RemoveAt(idx); - RecalculateContentHeight(); - } + _itemList.RemoveAt(idx); + RecalculateContentHeight(); } public void Select(int idx, bool single = true) { - if (GameController.OnGodot) + if (single) { - SceneControl.Call("select", idx, single); + for (var jdx = 0; jdx < _itemList.Count; jdx++) + { + Unselect(jdx); + } } - else + + var i = _itemList[idx]; + + if (i.Selectable) { - if (single) - { - for (var jdx = 0; jdx < _itemList.Count; jdx++) - { - Unselect(jdx); - } - } - - var i = _itemList[idx]; - - if (i.Selectable) - { - i.Selected = true; - OnItemSelected?.Invoke(new ItemListSelectedEventArgs(idx, this)); - } + i.Selected = true; + OnItemSelected?.Invoke(new ItemListSelectedEventArgs(idx, this)); } } public void Select(Item item, bool single = true) { - if (GameController.OnGodot) - { - return; - } - else - { - var idx = _itemList.IndexOf(item); - if (idx != -1) - Select(idx, single); - } - } - - public void SetItemCustomBgColor(int idx, Color color) - { - if (GameController.OnGodot) - { - SceneControl.Call("set_icon_custom_bg_color", idx, color.Convert()); - } - else - { - //_itemList[idx].CustomBg = color; - } + var idx = _itemList.IndexOf(item); + if (idx != -1) + Select(idx, single); } public void SetItemDisabled(int idx, bool disabled) { - if (GameController.OnGodot) - { - SceneControl.Call("set_item_disabled", idx, disabled); - } - else - { - Unselect(idx); - var i = _itemList[idx]; - i.Disabled = disabled; - } + Unselect(idx); + var i = _itemList[idx]; + i.Disabled = disabled; } public void SetItemIcon(int idx, Texture icon) { - if (GameController.OnGodot) - { - SceneControl.Call("set_item_icon", idx, icon); - } - else - { - _itemList[idx].Icon = icon; - } + _itemList[idx].Icon = icon; } public void SetItemIconRegion(int idx, UIBox2 region) { - if (GameController.OnGodot) - { - SceneControl.Call("set_item_icon_region", idx, region.Convert()); - } - else - { - _itemList[idx].IconRegion = region; - } + _itemList[idx].IconRegion = region; } public void SetItemSelectable(int idx, bool selectable) { - if (GameController.OnGodot) - { - SceneControl.Call("set_item_selectable", idx, selectable); - } - else - { - _itemList[idx].Selectable = selectable; - } + _itemList[idx].Selectable = selectable; } public void SetItemText(int idx, string text) { - if (GameController.OnGodot) - { - SceneControl.Call("set_item_text", idx, text); - } - else - { - _itemList[idx].Text = text; - } + _itemList[idx].Text = text; } public void SetItemTooltip(int idx, string tooltip) { - if (GameController.OnGodot) - { - SceneControl.Call("set_item_tooltip", idx, tooltip); - } - else - { - _itemList[idx].TooltipText = tooltip; - } + _itemList[idx].TooltipText = tooltip; } public void SetItemTooltipEnabled(int idx, bool enabled) { - if (GameController.OnGodot) - { - SceneControl.Call("set_item_tooltip_enabled", idx, enabled); - } - else - { - _itemList[idx].TooltipEnabled = true; - } + _itemList[idx].TooltipEnabled = true; } public void SortItemsByText() { - if (GameController.OnGodot) - { - SceneControl.Call("sort_items_by_text"); - } - else - { - _itemList.Sort((p, q) => string.Compare(p.Text, q.Text, StringComparison.Ordinal)); - } + _itemList.Sort((p, q) => string.Compare(p.Text, q.Text, StringComparison.Ordinal)); } public void Unselect(int idx) { - if (GameController.OnGodot) - { - SceneControl.Call("unselect", idx); - } - else { var i = _itemList[idx]; if (!i.Selected) return; @@ -314,16 +187,9 @@ namespace Robust.Client.UserInterface.Controls public void Unselect(Item item) { - if (GameController.OnGodot) - { - return; - } - else - { - var idx = _itemList.IndexOf(item); - if (idx == -1) return; - Unselect(idx); - } + var idx = _itemList.IndexOf(item); + if (idx == -1) return; + Unselect(idx); } public Font ActualFont @@ -413,11 +279,6 @@ namespace Robust.Client.UserInterface.Controls { base.Draw(handle); - if (GameController.OnGodot) - { - return; - } - var font = ActualFont; var listBg = ActualBackground; var iconBg = ActualItemBackground; @@ -516,11 +377,6 @@ namespace Robust.Client.UserInterface.Controls { base.MouseMove(args); - if (GameController.OnGodot) - { - return; - } - for (var idx = 0; idx < _itemList.Count; idx++) { var item = _itemList[idx]; @@ -535,11 +391,6 @@ namespace Robust.Client.UserInterface.Controls { base.MouseWheel(args); - if (GameController.OnGodot) - { - return; - } - if (args.WheelDirection == Mouse.Wheel.Up) { _scrollBar.Value = _scrollBar.Value - _getScrollSpeed(); @@ -563,7 +414,7 @@ namespace Robust.Client.UserInterface.Controls { base.MouseDown(args); - if (GameController.OnGodot || SelectMode == ItemListSelectMode.None || args.Button != Mouse.Button.Left) + if (SelectMode == ItemListSelectMode.None || args.Button != Mouse.Button.Left) { return; } @@ -584,8 +435,6 @@ namespace Robust.Client.UserInterface.Controls protected override void Initialize() { base.Initialize(); - if (GameController.OnGodot) - return; _scrollBar = new VScrollBar {Name = "_v_scroll"}; AddChild(_scrollBar); diff --git a/Robust.Client/UserInterface/Controls/Label.cs b/Robust.Client/UserInterface/Controls/Label.cs index 0a53da2df..884a914ac 100644 --- a/Robust.Client/UserInterface/Controls/Label.cs +++ b/Robust.Client/UserInterface/Controls/Label.cs @@ -11,7 +11,7 @@ namespace Robust.Client.UserInterface.Controls /// /// A label is a GUI control that displays simple text. /// - [ControlWrap(typeof(Godot.Label))] + [ControlWrap("Label")] public class Label : Control { public const string StylePropertyFontColor = "font-color"; @@ -23,11 +23,7 @@ namespace Robust.Client.UserInterface.Controls { } - public Label() : base() - { - } - - internal Label(Godot.Label control) : base(control) + public Label() { } @@ -36,90 +32,39 @@ namespace Robust.Client.UserInterface.Controls [ViewVariables] public string Text { - get => GameController.OnGodot ? (string) SceneControl.Get("text") : _text; + get => _text; set { - if (GameController.OnGodot) - { - SceneControl.Set("text", value); - } - else - { - _text = value; - _textDimensionCache = null; - MinimumSizeChanged(); - } + _text = value; + _textDimensionCache = null; + MinimumSizeChanged(); } } [ViewVariables] public bool AutoWrap { - get => GameController.OnGodot ? (bool) SceneControl.Get("autowrap") : default; + get => default; set { - if (GameController.OnGodot) - { - SceneControl.Set("autowrap", value); - } } } - private AlignMode _align; - [ViewVariables] - public AlignMode Align - { - get => GameController.OnGodot ? (AlignMode) SceneControl.Get("align") : _align; - set - { - if (GameController.OnGodot) - { - SceneControl.Set("align", (Godot.Label.AlignEnum) value); - } - else - { - _align = value; - } - } - } - - private VAlignMode _vAlign; + public AlignMode Align { get; set; } [ViewVariables] - public VAlignMode VAlign - { - // ReSharper disable once StringLiteralTypo - get => GameController.OnGodot ? (VAlignMode) SceneControl.Get("valign") : _vAlign; - set - { - if (GameController.OnGodot) - { - // ReSharper disable once StringLiteralTypo - SceneControl.Set("valign", (Godot.Label.VAlign) value); - } - else - { - _vAlign = value; - } - } - } + public VAlignMode VAlign { get; set; } - private Font _fontOverride; - - public Font FontOverride - { - get => _fontOverride ?? GetFontOverride("font"); - set => SetFontOverride("font", _fontOverride = value); - } + public Font FontOverride { get; set; } private Font ActualFont { get { - if (_fontOverride != null) + if (FontOverride != null) { - return _fontOverride; + return FontOverride; } if (TryGetStyleProperty(StylePropertyFont, out var font)) @@ -131,21 +76,15 @@ namespace Robust.Client.UserInterface.Controls } } - private Color? _fontColorShadowOverride; - - public Color? FontColorShadowOverride - { - get => _fontColorShadowOverride ?? GetColorOverride("font_color_shadow"); - set => SetColorOverride("font_color_shadow", _fontColorShadowOverride = value); - } + public Color? FontColorShadowOverride { get; set; } private Color ActualFontColor { get { - if (_fontColorOverride.HasValue) + if (FontColorOverride.HasValue) { - return _fontColorOverride.Value; + return FontColorOverride.Value; } if (TryGetStyleProperty(StylePropertyFontColor, out var color)) @@ -157,42 +96,15 @@ namespace Robust.Client.UserInterface.Controls } } - private Color? _fontColorOverride; + public Color? FontColorOverride { get; set; } - public Color? FontColorOverride - { - get => _fontColorOverride ?? GetColorOverride("font_color"); - set => SetColorOverride("font_color", _fontColorOverride = value); - } + public int? ShadowOffsetXOverride { get; set; } - private int? _shadowOffsetXOverride; + public int? ShadowOffsetYOverride { get; set; } - public int? ShadowOffsetXOverride - { - get => _shadowOffsetXOverride ?? GetConstantOverride("shadow_offset_x"); - set => SetConstantOverride("shadow_offset_x", _shadowOffsetXOverride = value); - } - - private int? _shadowOffsetYOverride; - - public int? ShadowOffsetYOverride - { - get => _shadowOffsetYOverride ?? GetConstantOverride("shadow_offset_y"); - set => SetConstantOverride("shadow_offset_y", _shadowOffsetYOverride = value); - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.Label(); - } protected internal override void Draw(DrawingHandleScreen handle) { - if (GameController.OnGodot) - { - return; - } - if (_text == null) { return; @@ -273,11 +185,6 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return base.CalculateMinimumSize(); - } - if (!_textDimensionCache.HasValue) { _calculateTextDimension(); diff --git a/Robust.Client/UserInterface/Controls/LineEdit.cs b/Robust.Client/UserInterface/Controls/LineEdit.cs index caa71deab..50aa93a4b 100644 --- a/Robust.Client/UserInterface/Controls/LineEdit.cs +++ b/Robust.Client/UserInterface/Controls/LineEdit.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using JetBrains.Annotations; -using Robust.Client.GodotGlue; using Robust.Client.Graphics; using Robust.Client.Graphics.Drawing; using Robust.Client.Input; @@ -12,7 +11,7 @@ using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.LineEdit))] + [ControlWrap("LineEdit")] public class LineEdit : Control { public const string StylePropertyStyleBox = "stylebox"; @@ -20,7 +19,6 @@ namespace Robust.Client.UserInterface.Controls public const string StylePseudoClassPlaceholder = "placeholder"; [NotNull] private string _text = ""; - private AlignMode _textAlign; private bool _editable = true; [CanBeNull] private string _placeHolder; private int _cursorPosition; @@ -38,92 +36,48 @@ namespace Robust.Client.UserInterface.Controls { } - internal LineEdit(Godot.LineEdit control) : base(control) - { - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.LineEdit(); - } - - public AlignMode TextAlign - { - get => GameController.OnGodot ? (AlignMode) SceneControl.Get("align") : _textAlign; - set - { - if (GameController.OnGodot) - { - SceneControl.Set("align", (Godot.LineEdit.AlignEnum) value); - } - else - { - _textAlign = value; - } - } - } + public AlignMode TextAlign { get; set; } public string Text { - get => GameController.OnGodot ? (string) SceneControl.Get("text") : _text; + get => _text; set { - if (GameController.OnGodot) + if (value == null) { - SceneControl.Set("text", value); + value = ""; } - else - { - if (value == null) - { - value = ""; - } - _text = value; - _cursorPosition = 0; - _updatePseudoClass(); - } + _text = value; + _cursorPosition = 0; + _updatePseudoClass(); } } public bool Editable { - get => GameController.OnGodot ? (bool) SceneControl.Get("editable") : _editable; + get => _editable; set { - if (GameController.OnGodot) + _editable = value; + if (!_editable) { - SceneControl.Set("editable", value); + AddStyleClass(StyleClassLineEditNotEditable); } else { - _editable = value; - if (!_editable) - { - AddStyleClass(StyleClassLineEditNotEditable); - } - else - { - RemoveStyleClass(StyleClassLineEditNotEditable); - } + RemoveStyleClass(StyleClassLineEditNotEditable); } } } public string PlaceHolder { - get => GameController.OnGodot ? (string) SceneControl.Get("placeholder_text") : _placeHolder; + get => _placeHolder; set { - if (GameController.OnGodot) - { - SceneControl.Set("placeholder_text", value); - } - else - { - _placeHolder = value; - _updatePseudoClass(); - } + _placeHolder = value; + _updatePseudoClass(); } } @@ -136,51 +90,19 @@ namespace Robust.Client.UserInterface.Controls // Future me reporting, thanks past me. // Second future me reporting, thanks again. // Third future me is here to say thanks. - - public void AppendAtCursor(string text) - { - if (GameController.OnGodot) - { - SceneControl.Call("append_at_cursor", text); - } - } + // Fourth future me is here to continue the tradition. public void Clear() { - if (GameController.OnGodot) - { - SceneControl.Call("clear"); - } - Text = ""; } - public int CursorPosition - { - get => GameController.OnGodot ? (int) SceneControl.Get("caret_position") : default; - set - { - if (GameController.OnGodot) - { - SceneControl.Set("caret_position", value); - } - } - } - public void Select(int from = 0, int to = -1) { - if (GameController.OnGodot) - { - SceneControl.Call("select", from, to); - } } public void SelectAll() { - if (GameController.OnGodot) - { - SceneControl.Call("select_all"); - } } public event Action OnTextChanged; @@ -188,12 +110,6 @@ namespace Robust.Client.UserInterface.Controls public void InsertAtCursor(string text) { - if (GameController.OnGodot) - { - SceneControl.Call("append_at_cursor", text); - return; - } - // Strip newlines. var chars = new List(text.Length); foreach (var chr in text) @@ -218,11 +134,6 @@ namespace Robust.Client.UserInterface.Controls protected internal override void Draw(DrawingHandleScreen handle) { - if (GameController.OnGodot) - { - return; - } - var styleBox = _getStyleBox(); var drawBox = SizeBox; var contentBox = styleBox.GetContentBox(drawBox); @@ -287,11 +198,6 @@ namespace Robust.Client.UserInterface.Controls { base.FrameUpdate(args); - if (GameController.OnGodot) - { - return; - } - _cursorBlinkTimer -= args.Elapsed; if (_cursorBlinkTimer <= 0) { @@ -302,11 +208,6 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return Vector2.Zero; - } - var font = _getFont(); var style = _getStyleBox(); return new Vector2(0, font.Height) + style.MinimumSize; @@ -316,7 +217,7 @@ namespace Robust.Client.UserInterface.Controls { base.TextEntered(args); - if (GameController.OnGodot || !Editable) + if (!Editable) { return; } @@ -337,11 +238,6 @@ namespace Robust.Client.UserInterface.Controls { base.KeyDown(args); - if (GameController.OnGodot) - { - return; - } - // Just eat all keyboard input. args.Handle(); @@ -407,11 +303,6 @@ namespace Robust.Client.UserInterface.Controls { base.MouseDown(args); - if (GameController.OnGodot) - { - return; - } - // Find closest cursor position under mouse. var style = _getStyleBox(); var contentBox = style.GetContentBox(SizeBox); @@ -466,12 +357,6 @@ namespace Robust.Client.UserInterface.Controls { base.FocusEntered(); - - if (GameController.OnGodot) - { - return; - } - // Reset this so the cursor is always visible immediately after gaining focus.. _cursorCurrentlyLit = true; _cursorBlinkTimer = BlinkTime; @@ -543,51 +428,6 @@ namespace Robust.Client.UserInterface.Controls } } - private GodotSignalSubscriber1 __textChangedSubscriber; - private GodotSignalSubscriber1 __textEnteredSubscriber; - - protected override void SetupSignalHooks() - { - base.SetupSignalHooks(); - - __textChangedSubscriber = new GodotSignalSubscriber1(); - __textChangedSubscriber.Connect(SceneControl, "text_changed"); - __textChangedSubscriber.Signal += __textChangedHook; - - __textEnteredSubscriber = new GodotSignalSubscriber1(); - __textEnteredSubscriber.Connect(SceneControl, "text_entered"); - __textEnteredSubscriber.Signal += __textEnteredHook; - } - - protected override void DisposeSignalHooks() - { - base.DisposeSignalHooks(); - - if (__textChangedSubscriber != null) - { - __textChangedSubscriber.Disconnect(SceneControl, "text_changed"); - __textChangedSubscriber.Dispose(); - __textChangedSubscriber = null; - } - - if (__textEnteredSubscriber != null) - { - __textEnteredSubscriber.Disconnect(SceneControl, "text_entered"); - __textEnteredSubscriber.Dispose(); - __textEnteredSubscriber = null; - } - } - - private void __textChangedHook(object text) - { - OnTextChanged?.Invoke(new LineEditEventArgs(this, (string) text)); - } - - private void __textEnteredHook(object text) - { - OnTextEntered?.Invoke(new LineEditEventArgs(this, (string) text)); - } - private protected override void SetGodotProperty(string property, object value, GodotAssetScene context) { base.SetGodotProperty(property, value, context); diff --git a/Robust.Client/UserInterface/Controls/MarginContainer.cs b/Robust.Client/UserInterface/Controls/MarginContainer.cs index e45435b5a..8ca3e98b7 100644 --- a/Robust.Client/UserInterface/Controls/MarginContainer.cs +++ b/Robust.Client/UserInterface/Controls/MarginContainer.cs @@ -3,7 +3,7 @@ using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.MarginContainer))] + [ControlWrap("MarginContainer")] public class MarginContainer : Container { public MarginContainer() @@ -14,53 +14,17 @@ namespace Robust.Client.UserInterface.Controls { } - internal MarginContainer(Godot.MarginContainer sceneControl) : base(sceneControl) - { - } - - private int? _marginBottomOverride; - - public int? MarginBottomOverride - { - get => _marginBottomOverride ?? GetConstantOverride("margin_bottom"); - set => SetConstantOverride("margin_bottom", _marginBottomOverride = value); - } - - private int? _marginTopOverride; - - public int? MarginTopOverride - { - get => _marginTopOverride ?? GetConstantOverride("margin_top"); - set => SetConstantOverride("margin_top", _marginTopOverride = value); - } - - private int? _marginRightOverride; - - public int? MarginRightOverride - { - get => _marginRightOverride ?? GetConstantOverride("margin_right"); - set => SetConstantOverride("margin_right", _marginRightOverride = value); - } - - private int? _marginLeftOverride; - - public int? MarginLeftOverride - { - get => _marginLeftOverride ?? GetConstantOverride("margin_left"); - set => SetConstantOverride("margin_left", _marginLeftOverride = value); - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.MarginContainer(); - } + public int? MarginBottomOverride { get; set; } + public int? MarginTopOverride { get; set; } + public int? MarginRightOverride { get; set; } + public int? MarginLeftOverride { get; set; } protected override void SortChildren() { - var top = _marginTopOverride ?? 0; - var bottom = _marginBottomOverride ?? 0; - var left = _marginLeftOverride ?? 0; - var right = _marginRightOverride ?? 0; + var top = MarginTopOverride ?? 0; + var bottom = MarginBottomOverride ?? 0; + var left = MarginLeftOverride ?? 0; + var right = MarginRightOverride ?? 0; var box = new UIBox2(left, top, Width - right - left, Height - bottom - top); @@ -72,15 +36,10 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return Vector2.Zero; - } - - var top = _marginTopOverride ?? 0; - var bottom = _marginBottomOverride ?? 0; - var left = _marginLeftOverride ?? 0; - var right = _marginRightOverride ?? 0; + var top = MarginTopOverride ?? 0; + var bottom = MarginBottomOverride ?? 0; + var left = MarginLeftOverride ?? 0; + var right = MarginRightOverride ?? 0; var childMinSize = Vector2.Zero; @@ -96,24 +55,20 @@ namespace Robust.Client.UserInterface.Controls { base.SetGodotProperty(property, value, context); - if (property == "custom_constants/margin_right") + switch (property) { - MarginRightOverride = (int)(long)value; - } - - if (property == "custom_constants/margin_left") - { - MarginLeftOverride = (int)(long)value; - } - - if (property == "custom_constants/margin_bottom") - { - MarginBottomOverride = (int)(long)value; - } - - if (property == "custom_constants/margin_top") - { - MarginTopOverride = (int)(long)value; + case "custom_constants/margin_right": + MarginRightOverride = (int)(long)value; + break; + case "custom_constants/margin_left": + MarginLeftOverride = (int)(long)value; + break; + case "custom_constants/margin_bottom": + MarginBottomOverride = (int)(long)value; + break; + case "custom_constants/margin_top": + MarginTopOverride = (int)(long)value; + break; } } } diff --git a/Robust.Client/UserInterface/Controls/OptionButton.cs b/Robust.Client/UserInterface/Controls/OptionButton.cs index 54b07d8b1..4ca82d5d6 100644 --- a/Robust.Client/UserInterface/Controls/OptionButton.cs +++ b/Robust.Client/UserInterface/Controls/OptionButton.cs @@ -1,83 +1,55 @@ using System; using System.Collections.Generic; -using Robust.Client.GodotGlue; using Robust.Client.Graphics; using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.OptionButton))] + [ControlWrap("OptionButton")] public class OptionButton : Button { private List _buttonData = new List(); private Dictionary _idMap = new Dictionary(); private Popup _popup; private VBoxContainer _popupVBox; - private int _selectedId; public event Action OnItemSelected; - public int Selected - { - get => GameController.OnGodot ? (int) SceneControl.Get("selected") : default; - set - { - if (GameController.OnGodot) - { - SceneControl.Set("selected", value); - } - } - } - public void AddItem(Texture icon, string label, int? id = null) { - if (GameController.OnGodot) - { - SceneControl.Call("add_icon_item", icon.GodotTexture, label, id ?? -1); - } - else - { - AddItem(label, id); - } + AddItem(label, id); } public void AddItem(string label, int? id = null) { - if (GameController.OnGodot) + if (id == null) { - SceneControl.Call("add_item", label, id ?? -1); + id = _buttonData.Count; } - else + + if (_idMap.ContainsKey(id.Value)) { - if (id == null) - { - id = _buttonData.Count; - } + throw new ArgumentException("An item with the same ID already exists."); + } - if (_idMap.ContainsKey(id.Value)) - { - throw new ArgumentException("An item with the same ID already exists."); - } - - var button = new Button - { - Text = label, - ToggleMode = true - }; - button.OnPressed += ButtonOnPressed; - var data = new ButtonData - { - Text = label, - Id = id.Value, - Button = button - }; - _idMap.Add(id.Value, _buttonData.Count); - _buttonData.Add(data); - _popupVBox.AddChild(button); - if (_buttonData.Count == 1) - { - Select(0); - } + var button = new Button + { + Text = label, + ToggleMode = true + }; + button.OnPressed += ButtonOnPressed; + var data = new ButtonData + { + Text = label, + Id = id.Value, + Button = button + }; + _idMap.Add(id.Value, _buttonData.Count); + _buttonData.Add(data); + _popupVBox.AddChild(button); + if (_buttonData.Count == 1) + { + Select(0); } } @@ -100,75 +72,49 @@ namespace Robust.Client.UserInterface.Controls public void Clear() { - if (GameController.OnGodot) - { - SceneControl.Call("clear"); - } - else - { - _idMap.Clear(); - _buttonData.Clear(); - _popupVBox.DisposeAllChildren(); - _selectedId = 0; - } + _idMap.Clear(); + _buttonData.Clear(); + _popupVBox.DisposeAllChildren(); + SelectedId = 0; } - public int ItemCount => GameController.OnGodot ? (int) SceneControl.Call("get_item_count") : _buttonData.Count; + public int ItemCount => _buttonData.Count; public int GetItemId(int idx) { - return GameController.OnGodot ? (int) SceneControl.Call("get_item_id", idx) : _buttonData[idx].Id; + return _buttonData[idx].Id; } public object GetItemMetadata(int idx) { - return GameController.OnGodot ? SceneControl.Call("get_item_metadata", idx) : _buttonData[idx].Metadata; + return _buttonData[idx].Metadata; } - public int SelectedId => GameController.OnGodot ? (int) SceneControl.Call("get_selected_id") : _selectedId; + public int SelectedId { get; private set; } - public object SelectedMetadata => - GameController.OnGodot - ? SceneControl.GetSceneInstanceLoadPlaceholder() - : _buttonData[_idMap[_selectedId]].Metadata; + public object SelectedMetadata => _buttonData[_idMap[SelectedId]].Metadata; public bool IsItemDisabled(int idx) { - return GameController.OnGodot - ? (bool) SceneControl.Call("is_item_disabled", idx) - : _buttonData[idx].Disabled; + return _buttonData[idx].Disabled; } public void RemoveItem(int idx) { - if (GameController.OnGodot) - { - SceneControl.Call("remove_item", idx); - } - else - { - var data = _buttonData[idx]; - _idMap.Remove(data.Id); - _popupVBox.RemoveChild(data.Button); - _buttonData.RemoveAt(idx); - } + var data = _buttonData[idx]; + _idMap.Remove(data.Id); + _popupVBox.RemoveChild(data.Button); + _buttonData.RemoveAt(idx); } public void Select(int idx) { - if (GameController.OnGodot) - { - SceneControl.Call("select", idx); - } - else - { - var prev = _buttonData[_idMap[_selectedId]]; - prev.Button.Pressed = false; - var data = _buttonData[idx]; - _selectedId = data.Id; - Text = data.Text; - data.Button.Pressed = true; - } + var prev = _buttonData[_idMap[SelectedId]]; + prev.Button.Pressed = false; + var data = _buttonData[idx]; + SelectedId = data.Id; + Text = data.Text; + data.Button.Pressed = true; } public void SelectId(int id) @@ -178,93 +124,48 @@ namespace Robust.Client.UserInterface.Controls public int GetIdx(int id) { - if (!GameController.OnGodot) - { - return _idMap[id]; - } - - for (var i = 0; i < ItemCount; i++) - { - if (id == GetItemId(i)) - { - return i; - } - } - - throw new ArgumentException("ID does not exist."); + return _idMap[id]; } public void SetItemDisabled(int idx, bool disabled) { - if (GameController.OnGodot) - { - SceneControl.Call("set_item_disabled", idx, disabled); - } - else - { - var data = _buttonData[idx]; - data.Disabled = disabled; - data.Button.Disabled = disabled; - } + var data = _buttonData[idx]; + data.Disabled = disabled; + data.Button.Disabled = disabled; } public void SetItemIcon(int idx, Texture texture) { - if (GameController.OnGodot) - { - SceneControl.Call("set_item_icon", idx, texture); - } } public void SetItemId(int idx, int id) { - if (GameController.OnGodot) + if (_idMap.TryGetValue(id, out var existIdx) && existIdx != id) { - SceneControl.Call("set_item_id", idx, id); + throw new InvalidOperationException("An item with said ID already exists."); } - else - { - if (_idMap.TryGetValue(id, out var existIdx) && existIdx != id) - { - throw new InvalidOperationException("An item with said ID already exists."); - } - var data = _buttonData[idx]; - _idMap.Remove(data.Id); - _idMap.Add(id, idx); - data.Id = id; - } + var data = _buttonData[idx]; + _idMap.Remove(data.Id); + _idMap.Add(id, idx); + data.Id = id; } public void SetItemMetadata(int idx, object metadata) { - if (GameController.OnGodot) - { - SceneControl.Call("set_item_metadata", idx, metadata); - } - else - { - _buttonData[idx].Metadata = metadata; - } + _buttonData[idx].Metadata = metadata; } public void SetItemText(int idx, string text) { - if (GameController.OnGodot) + var data = _buttonData[idx]; + data.Text = text; + if (SelectedId == data.Id) { - SceneControl.Call("set_item_text", idx, text); + Text = text; } - else - { - var data = _buttonData[idx]; - data.Text = text; - if (_selectedId == data.Id) - { - Text = text; - } - data.Button.Text = text; - } + data.Button.Text = text; } private void _onPressed(ButtonEventArgs args) @@ -274,7 +175,7 @@ namespace Robust.Client.UserInterface.Controls _popup.Open(box); } - public OptionButton() : base() + public OptionButton() { } @@ -282,28 +183,16 @@ namespace Robust.Client.UserInterface.Controls { } - internal OptionButton(Godot.OptionButton button) : base(button) - { - } - protected override void Initialize() { base.Initialize(); - if (!GameController.OnGodot) - { - OnPressed += _onPressed; - _popup = new Popup(); - AddChild(_popup); - _popupVBox = new VBoxContainer(); - _popup.AddChild(_popupVBox); - _popupVBox.SetAnchorAndMarginPreset(LayoutPreset.Wide); - } - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.OptionButton(); + OnPressed += _onPressed; + _popup = new Popup(); + AddChild(_popup); + _popupVBox = new VBoxContainer(); + _popup.AddChild(_popupVBox); + _popupVBox.SetAnchorAndMarginPreset(LayoutPreset.Wide); } public class ItemSelectedEventArgs : EventArgs @@ -322,34 +211,6 @@ namespace Robust.Client.UserInterface.Controls } } - private GodotSignalSubscriber1 __itemSelectedSubscriber; - - protected override void SetupSignalHooks() - { - base.SetupSignalHooks(); - - __itemSelectedSubscriber = new GodotSignalSubscriber1(); - __itemSelectedSubscriber.Connect(SceneControl, "item_selected"); - __itemSelectedSubscriber.Signal += __itemSelectedHook; - } - - protected override void DisposeSignalHooks() - { - base.DisposeSignalHooks(); - - if (__itemSelectedSubscriber != null) - { - __itemSelectedSubscriber.Disconnect(SceneControl, "item_selected"); - __itemSelectedSubscriber.Dispose(); - __itemSelectedSubscriber = null; - } - } - - private void __itemSelectedHook(object id) - { - OnItemSelected?.Invoke(new ItemSelectedEventArgs((int) id, this)); - } - private sealed class ButtonData { public string Text; diff --git a/Robust.Client/UserInterface/Controls/OutputPanel.cs b/Robust.Client/UserInterface/Controls/OutputPanel.cs index 07682ac19..b96bea8a1 100644 --- a/Robust.Client/UserInterface/Controls/OutputPanel.cs +++ b/Robust.Client/UserInterface/Controls/OutputPanel.cs @@ -21,9 +21,6 @@ namespace Robust.Client.UserInterface.Controls private readonly List _entries = new List(); private bool _isAtBottom = true; - // These two are used to implement this on Godot. - private PanelContainer _godotPanelContainer; - private Godot.RichTextLabel _godotRichTextLabel; private int _totalContentHeight; private bool _firstLine = true; private StyleBox _styleBoxOverride; @@ -39,43 +36,22 @@ namespace Robust.Client.UserInterface.Controls set { _styleBoxOverride = value; - if (GameController.OnGodot) - { - // Have to set this to empty so Godot doesn't set it to that ugly default one. - _godotPanelContainer.PanelOverride = value ?? new StyleBoxEmpty(); - } - else - { - MinimumSizeChanged(); - _invalidateEntries(); - } + MinimumSizeChanged(); + _invalidateEntries(); } } public void Clear() { _firstLine = true; - if (GameController.OnGodot) - { - _godotRichTextLabel.Clear(); - } - else - { - _entries.Clear(); - _totalContentHeight = 0; - _scrollBar.MaxValue = Math.Max(_scrollBar.Page, _totalContentHeight); - _scrollBar.Value = 0; - } + _entries.Clear(); + _totalContentHeight = 0; + _scrollBar.MaxValue = Math.Max(_scrollBar.Page, _totalContentHeight); + _scrollBar.Value = 0; } public void RemoveLine(int line) { - if (GameController.OnGodot) - { - _godotRichTextLabel.RemoveLine(line); - return; - } - var entry = _entries[line]; _entries.RemoveAt(line); @@ -90,12 +66,6 @@ namespace Robust.Client.UserInterface.Controls public void AddMessage(FormattedMessage message) { - if (GameController.OnGodot) - { - _addMessageGodot(message); - return; - } - var entry = new RichTextEntry(message); entry.Update(_getFont(), _getContentBox().Width); @@ -129,32 +99,16 @@ namespace Robust.Client.UserInterface.Controls { base.Initialize(); - if (GameController.OnGodot) - { - _godotPanelContainer = new PanelContainer {PanelOverride = new StyleBoxEmpty()}; - _godotPanelContainer.SetAnchorPreset(LayoutPreset.Wide); - AddChild(_godotPanelContainer); - _godotRichTextLabel = new Godot.RichTextLabel {ScrollFollowing = true}; - _godotPanelContainer.SceneControl.AddChild(_godotRichTextLabel); - } - else - { - _scrollBar = new VScrollBar {Name = "_v_scroll"}; - AddChild(_scrollBar); - _scrollBar.SetAnchorAndMarginPreset(LayoutPreset.RightWide); - _scrollBar.OnValueChanged += _ => _isAtBottom = _scrollBar.IsAtEnd; - } + _scrollBar = new VScrollBar {Name = "_v_scroll"}; + AddChild(_scrollBar); + _scrollBar.SetAnchorAndMarginPreset(LayoutPreset.RightWide); + _scrollBar.OnValueChanged += _ => _isAtBottom = _scrollBar.IsAtEnd; } protected internal override void Draw(DrawingHandleScreen handle) { base.Draw(handle); - if (GameController.OnGodot) - { - return; - } - var style = _getStyleBox(); var font = _getFont(); style?.Draw(handle, SizeBox); @@ -190,11 +144,6 @@ namespace Robust.Client.UserInterface.Controls { base.MouseWheel(args); - if (GameController.OnGodot) - { - return; - } - if (args.WheelDirection == Mouse.Wheel.Up) { _scrollBar.Value = _scrollBar.Value - _getScrollSpeed(); @@ -202,7 +151,6 @@ namespace Robust.Client.UserInterface.Controls } else if (args.WheelDirection == Mouse.Wheel.Down) { - var limit = ScrollLimit; _scrollBar.Value = _scrollBar.Value + _getScrollSpeed(); if (_scrollBar.IsAtEnd) { @@ -211,44 +159,6 @@ namespace Robust.Client.UserInterface.Controls } } - private void _addMessageGodot(FormattedMessage message) - { - DebugTools.Assert(GameController.OnGodot); - - if (!_firstLine) - { - _godotRichTextLabel.Newline(); - } - else - { - _firstLine = false; - } - - var pushCount = 0; - foreach (var tag in message.Tags) - switch (tag) - { - case FormattedMessage.TagText text: - _godotRichTextLabel.AddText(text.Text); - break; - case FormattedMessage.TagColor color: - _godotRichTextLabel.PushColor(color.Color.Convert()); - pushCount++; - break; - case FormattedMessage.TagPop _: - if (pushCount <= 0) throw new InvalidOperationException(); - - _godotRichTextLabel.Pop(); - pushCount--; - break; - } - - for (; pushCount > 0; pushCount--) - { - _godotRichTextLabel.Pop(); - } - } - protected override void SetDefaults() { base.SetDefaults(); @@ -260,11 +170,6 @@ namespace Robust.Client.UserInterface.Controls { base.Resized(); - if (GameController.OnGodot) - { - return; - } - var styleBoxSize = _getStyleBox()?.MinimumSize.Y ?? 0; _scrollBar.Page = Size.Y - styleBoxSize; diff --git a/Robust.Client/UserInterface/Controls/Panel.cs b/Robust.Client/UserInterface/Controls/Panel.cs index 557b5741d..23a3a07f5 100644 --- a/Robust.Client/UserInterface/Controls/Panel.cs +++ b/Robust.Client/UserInterface/Controls/Panel.cs @@ -4,7 +4,7 @@ using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.Panel))] + [ControlWrap("Panel")] public class Panel : Control { public const string StylePropertyPanel = "panel"; @@ -13,25 +13,16 @@ namespace Robust.Client.UserInterface.Controls { } - public Panel() : base() + public Panel() { } - internal Panel(Godot.Panel panel) : base(panel) - { - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.Panel(); - } - private StyleBox _panelOverride; public StyleBox PanelOverride { - get => _panelOverride ?? GetStyleBoxOverride("panel"); - set => SetStyleBoxOverride("panel", _panelOverride = value); + get => _panelOverride; + set => _panelOverride = value; } private StyleBox ActualPanel @@ -56,11 +47,8 @@ namespace Robust.Client.UserInterface.Controls { base.Draw(handle); - if (!GameController.OnGodot) - { - var panel = ActualPanel; - panel.Draw(handle, SizeBox); - } + var panel = ActualPanel; + panel.Draw(handle, SizeBox); } private protected override void SetGodotProperty(string property, object value, GodotAssetScene context) @@ -75,11 +63,6 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return Vector2.Zero; - } - return ActualPanel.MinimumSize; } } diff --git a/Robust.Client/UserInterface/Controls/PanelContainer.cs b/Robust.Client/UserInterface/Controls/PanelContainer.cs index 25f77260c..698964cb9 100644 --- a/Robust.Client/UserInterface/Controls/PanelContainer.cs +++ b/Robust.Client/UserInterface/Controls/PanelContainer.cs @@ -4,7 +4,7 @@ using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.PanelContainer))] + [ControlWrap("PanelContainer")] public class PanelContainer : Container { public const string StylePropertyPanel = "panel"; @@ -17,32 +17,19 @@ namespace Robust.Client.UserInterface.Controls { } - internal PanelContainer(Godot.PanelContainer container) : base(container) - { - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.PanelContainer(); - } private StyleBox _panelOverride; public StyleBox PanelOverride { - get => _panelOverride ?? GetStyleBoxOverride("panel"); - set => SetStyleBoxOverride("panel", _panelOverride = value); + get => _panelOverride; + set => _panelOverride = value; } protected internal override void Draw(DrawingHandleScreen handle) { base.Draw(handle); - if (GameController.OnGodot) - { - return; - } - var style = _getStyleBox(); style?.Draw(handle, SizeBox); } @@ -61,11 +48,6 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return Vector2.Zero; - } - var styleSize = _getStyleBox()?.MinimumSize ?? Vector2.Zero; var childSize = Vector2.Zero; foreach (var child in Children) diff --git a/Robust.Client/UserInterface/Controls/Popup.cs b/Robust.Client/UserInterface/Controls/Popup.cs index a34e46fc6..1e4cad6ac 100644 --- a/Robust.Client/UserInterface/Controls/Popup.cs +++ b/Robust.Client/UserInterface/Controls/Popup.cs @@ -1,14 +1,12 @@ using System; -using Robust.Client.GodotGlue; -using Robust.Client.Utility; using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.Popup))] + [ControlWrap("Popup")] public class Popup : Control { - public Popup() : base() + public Popup() { } @@ -16,34 +14,18 @@ namespace Robust.Client.UserInterface.Controls { } - internal Popup(Godot.Popup control) : base(control) - { - } - public event Action OnPopupHide; - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.Popup(); - } - public void Open(UIBox2? box = null) { - if (GameController.OnGodot) + if (box != null) { - SceneControl.Call("popup", box?.Convert()); + Position = box.Value.TopLeft; + Size = box.Value.Size; } - else - { - if (box != null) - { - Position = box.Value.TopLeft; - Size = box.Value.Size; - } - Visible = true; - UserInterfaceManagerInternal.PushModal(this); - } + Visible = true; + UserInterfaceManagerInternal.PushModal(this); } protected internal override void ModalRemoved() @@ -54,31 +36,6 @@ namespace Robust.Client.UserInterface.Controls OnPopupHide?.Invoke(); } - private GodotSignalSubscriber0 __popupHideSubscriber; - - protected override void SetupSignalHooks() - { - base.SetupSignalHooks(); - - __popupHideSubscriber = new GodotSignalSubscriber0(); - __popupHideSubscriber.Connect(SceneControl, "popup_hide"); - __popupHideSubscriber.Signal += __popupHideHook; - } - - protected override void DisposeSignalHooks() - { - base.DisposeSignalHooks(); - - __popupHideSubscriber.Disconnect(SceneControl, "popup_hide"); - __popupHideSubscriber.Dispose(); - __popupHideSubscriber = null; - } - - private void __popupHideHook() - { - OnPopupHide?.Invoke(); - } - protected override void SetDefaults() { base.SetDefaults(); diff --git a/Robust.Client/UserInterface/Controls/ProgressBar.cs b/Robust.Client/UserInterface/Controls/ProgressBar.cs index efbb4430a..158aaf68c 100644 --- a/Robust.Client/UserInterface/Controls/ProgressBar.cs +++ b/Robust.Client/UserInterface/Controls/ProgressBar.cs @@ -5,7 +5,7 @@ using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.ProgressBar))] + [ControlWrap("ProgressBar")] public class ProgressBar : Range { public const string StylePropertyBackground = "background"; @@ -19,22 +19,6 @@ namespace Robust.Client.UserInterface.Controls { } - internal ProgressBar(Godot.ProgressBar control) : base(control) - { - } - - /// - /// True if the percentage label on top of the progress bar is visible. - /// - public bool PercentVisible - { - get => GameController.OnGodot ? (bool)SceneControl.Get("percent_visible") : default; - set - { - if (GameController.OnGodot) SceneControl.Set("percent_visible", value); - } - } - [Pure] private StyleBox _getBackground() { @@ -53,11 +37,6 @@ namespace Robust.Client.UserInterface.Controls { base.Draw(handle); - if (GameController.OnGodot) - { - return; - } - var bg = _getBackground(); bg?.Draw(handle, SizeBox); @@ -76,20 +55,10 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return Vector2.Zero; - } - var bgSize = _getBackground()?.MinimumSize ?? Vector2.Zero; var fgSize = _getForeground()?.MinimumSize ?? Vector2.Zero; return Vector2.ComponentMax(bgSize, fgSize); } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.ProgressBar(); - } } } diff --git a/Robust.Client/UserInterface/Controls/Range.cs b/Robust.Client/UserInterface/Controls/Range.cs index 43bcfd31e..42ee01b46 100644 --- a/Robust.Client/UserInterface/Controls/Range.cs +++ b/Robust.Client/UserInterface/Controls/Range.cs @@ -6,7 +6,7 @@ using Robust.Shared.ViewVariables; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.Range))] + [ControlWrap("Range")] public abstract class Range : Control { private float _maxValue = 100; @@ -22,94 +22,57 @@ namespace Robust.Client.UserInterface.Controls { } - internal Range(Godot.Range control) : base(control) - { - } - public event Action OnValueChanged; public float GetAsRatio() { - if (GameController.OnGodot) - { - return (float)SceneControl.Call("get_as_ratio"); - } - return (_value - _minValue) / (_maxValue - _minValue); } [ViewVariables] public float Page { - get => GameController.OnGodot ? (float)SceneControl.Get("page") : _page; + get => _page; set { - if (GameController.OnGodot) - { - SceneControl.Set("page", value); - } - else - { - _page = value; - _ensureValueClamped(); - } + _page = value; + _ensureValueClamped(); } } [ViewVariables] public float MaxValue { - get => GameController.OnGodot ? (float)SceneControl.Get("max_value") : _maxValue; + get => _maxValue; set { - if (GameController.OnGodot) - { - SceneControl.Set("max_value", value); - } - else - { - _maxValue = value; - _ensureValueClamped(); - } + _maxValue = value; + _ensureValueClamped(); } } [ViewVariables] public float MinValue { - get => GameController.OnGodot ? (float)SceneControl.Get("min_value") : _minValue; + get => _minValue; set { - if (GameController.OnGodot) - { - SceneControl.Set("min_value", value); - } - else - { - _minValue = value; - _ensureValueClamped(); - } + _minValue = value; + _ensureValueClamped(); } } [ViewVariables] public float Value { - get => GameController.OnGodot ? (float) SceneControl.Get("value") : _value; + get => _value; set { - if (GameController.OnGodot) + var newValue = ClampValue(value); + if (!FloatMath.CloseTo(newValue, _value)) { - SceneControl.Set("value", value); - } - else - { - var newValue = ClampValue(value); - if (!FloatMath.CloseTo(newValue, _value)) - { - _value = newValue; - OnValueChanged?.Invoke(this); - } + _value = newValue; + OnValueChanged?.Invoke(this); } } } diff --git a/Robust.Client/UserInterface/Controls/RichTextLabel.cs b/Robust.Client/UserInterface/Controls/RichTextLabel.cs index d0a6a4533..f915b83f5 100644 --- a/Robust.Client/UserInterface/Controls/RichTextLabel.cs +++ b/Robust.Client/UserInterface/Controls/RichTextLabel.cs @@ -57,7 +57,7 @@ namespace Robust.Client.UserInterface.Controls { base.Draw(handle); - if (GameController.OnGodot || _message == null) + if (_message == null) { return; } diff --git a/Robust.Client/UserInterface/Controls/ScrollBar.cs b/Robust.Client/UserInterface/Controls/ScrollBar.cs index 2fb3f98b3..8bc31a59d 100644 --- a/Robust.Client/UserInterface/Controls/ScrollBar.cs +++ b/Robust.Client/UserInterface/Controls/ScrollBar.cs @@ -6,7 +6,7 @@ using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.ScrollBar))] + [ControlWrap("ScrollBar")] public abstract class ScrollBar : Range { public const string StylePropertyGrabber = "grabber"; @@ -22,10 +22,6 @@ namespace Robust.Client.UserInterface.Controls _orientation = orientation; } - private protected ScrollBar(Godot.ScrollBar control) : base(control) - { - } - public bool IsAtEnd { get @@ -37,11 +33,6 @@ namespace Robust.Client.UserInterface.Controls protected internal override void Draw(DrawingHandleScreen handle) { - if (GameController.OnGodot) - { - return; - } - var styleBox = _getGrabberStyleBox(); styleBox?.Draw(handle, _getGrabberBox()); @@ -58,22 +49,12 @@ namespace Robust.Client.UserInterface.Controls { base.MouseExited(); - if (GameController.OnGodot) - { - return; - } - _isHovered = false; _updatePseudoClass(); } protected internal override void MouseMove(GUIMouseMoveEventArgs args) { - if (GameController.OnGodot) - { - return; - } - if (_grabData == null) { var box = _getGrabberBox(); @@ -103,7 +84,7 @@ namespace Robust.Client.UserInterface.Controls protected internal override void MouseDown(GUIMouseButtonEventArgs args) { - if (GameController.OnGodot || args.Button != Mouse.Button.Left) + if (args.Button != Mouse.Button.Left) { return; } @@ -120,7 +101,7 @@ namespace Robust.Client.UserInterface.Controls protected internal override void MouseUp(GUIMouseButtonEventArgs args) { - if (GameController.OnGodot || args.Button != Mouse.Button.Left) + if (args.Button != Mouse.Button.Left) { return; } diff --git a/Robust.Client/UserInterface/Controls/ScrollContainer.cs b/Robust.Client/UserInterface/Controls/ScrollContainer.cs index 161705ad1..7f901096f 100644 --- a/Robust.Client/UserInterface/Controls/ScrollContainer.cs +++ b/Robust.Client/UserInterface/Controls/ScrollContainer.cs @@ -5,7 +5,7 @@ using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.ScrollContainer))] + [ControlWrap("ScrollContainer")] public class ScrollContainer : Container { private bool _vScrollEnabled = true; @@ -27,10 +27,6 @@ namespace Robust.Client.UserInterface.Controls { } - internal ScrollContainer(Godot.ScrollContainer container) : base(container) - { - } - public bool VScrollEnabled { get => _vScrollEnabled; @@ -51,20 +47,10 @@ namespace Robust.Client.UserInterface.Controls } } - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.ScrollContainer(); - } - protected override void Initialize() { base.Initialize(); - if (GameController.OnGodot) - { - return; - } - Action ev = _scrollValueChanged; _hScrollBar = new HScrollBar {Visible = false}; _vScrollBar = new VScrollBar {Visible = false}; @@ -149,11 +135,6 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return Vector2.Zero; - } - var totalX = 0f; var totalY = 0f; diff --git a/Robust.Client/UserInterface/Controls/SplitContainer.cs b/Robust.Client/UserInterface/Controls/SplitContainer.cs index 2bbef0890..d818562e5 100644 --- a/Robust.Client/UserInterface/Controls/SplitContainer.cs +++ b/Robust.Client/UserInterface/Controls/SplitContainer.cs @@ -3,7 +3,7 @@ using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.SplitContainer))] + [ControlWrap("SplitContainer")] public abstract class SplitContainer : Container { // TODO: Implement the grabber. @@ -11,14 +11,6 @@ namespace Robust.Client.UserInterface.Controls private protected abstract bool Vertical { get; } - protected SplitContainer() - { - } - - protected SplitContainer(Godot.SplitContainer control) : base(control) - { - } - protected override void SortChildren() { base.SortChildren(); @@ -75,11 +67,6 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return Vector2.Zero; - } - if (ChildCount != 2) { return Vector2.Zero; diff --git a/Robust.Client/UserInterface/Controls/SpriteView.cs b/Robust.Client/UserInterface/Controls/SpriteView.cs index 22239691b..d6a930c9c 100644 --- a/Robust.Client/UserInterface/Controls/SpriteView.cs +++ b/Robust.Client/UserInterface/Controls/SpriteView.cs @@ -10,7 +10,7 @@ using Robust.Shared.Maths; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(GodotGlue.SpriteView), "res://Engine/Scenes/SpriteMirror/SpriteView.tscn")] + [ControlWrap("res://Engine/Scenes/SpriteMirror/SpriteView.tscn")] public class SpriteView : Control { ISpriteProxy Mirror; @@ -31,7 +31,6 @@ namespace Robust.Client.UserInterface.Controls if (value != null) { Mirror = value.CreateProxy(); - Mirror.AttachToControl(this); UpdateMirrorPosition(); } } @@ -45,10 +44,6 @@ namespace Robust.Client.UserInterface.Controls { } - public SpriteView(Godot.Control control) : base(control) - { - } - protected override void Initialize() { base.Initialize(); @@ -88,7 +83,7 @@ namespace Robust.Client.UserInterface.Controls protected internal override void Draw(DrawingHandleScreen handle) { - if (GameController.OnGodot || _sprite == null) + if (_sprite == null) { return; } diff --git a/Robust.Client/UserInterface/Controls/TabContainer.cs b/Robust.Client/UserInterface/Controls/TabContainer.cs index 10fae38e5..357a04296 100644 --- a/Robust.Client/UserInterface/Controls/TabContainer.cs +++ b/Robust.Client/UserInterface/Controls/TabContainer.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using JetBrains.Annotations; -using Robust.Client.GodotGlue; using Robust.Client.Graphics; using Robust.Client.Graphics.Drawing; using Robust.Shared.Maths; @@ -10,7 +9,7 @@ using PureAttribute = System.Diagnostics.Contracts.PureAttribute; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.TabContainer))] + [ControlWrap("TabContainer")] public class TabContainer : Container { public const string StylePropertyTabStyleBox = "tab-stylebox"; @@ -19,9 +18,6 @@ namespace Robust.Client.UserInterface.Controls public const string StylePropertyTabFontColorInactive = "tab-font-color-inactive"; public const string StylePropertyPanelStyleBox = "panel-stylebox"; - private GodotSignalSubscriber1 _onTabSelectedSubscriber; - private GodotSignalSubscriber1 _onTabChangedSubscriber; - private int _currentTab; private bool _tabsVisible = true; private readonly List _tabData = new List(); @@ -34,100 +30,58 @@ namespace Robust.Client.UserInterface.Controls { } - internal TabContainer(Godot.TabContainer control) : base(control) - { - } - public int CurrentTab { - get => GameController.OnGodot ? (int) SceneControl.Call("get_current_tab") : _currentTab; + get => _currentTab; set { - if (GameController.OnGodot) + if (_currentTab < 0) { - SceneControl.Call("set_current_tab", value); + throw new ArgumentOutOfRangeException(nameof(value), value, "Current tab must be positive."); } - else + + if (_currentTab >= ChildCount) { - if (_currentTab < 0) - { - throw new ArgumentOutOfRangeException(nameof(value), value, "Current tab must be positive."); - } - - if (_currentTab >= ChildCount) - { - throw new ArgumentOutOfRangeException(nameof(value), value, - "Current tab must less than the amount of tabs."); - } - - if (_currentTab == value) - { - return; - } - - var old = _currentTab; - _currentTab = value; - - GetChild(old).Visible = false; - var newSelected = GetChild(value); - newSelected.Visible = true; - _fixChildMargins(newSelected); - - OnTabChanged?.Invoke(value); + throw new ArgumentOutOfRangeException(nameof(value), value, + "Current tab must less than the amount of tabs."); } - } - } - public TabAlignMode TabAlign - { - get => GameController.OnGodot ? (TabAlignMode) SceneControl.Call("get_tab_align") : default; - set - { - if (GameController.OnGodot) + if (_currentTab == value) { - SceneControl.Call("set_tab_align", (Godot.TabContainer.TabAlignEnum) value); + return; } + + var old = _currentTab; + _currentTab = value; + + GetChild(old).Visible = false; + var newSelected = GetChild(value); + newSelected.Visible = true; + _fixChildMargins(newSelected); + + OnTabChanged?.Invoke(value); } } public bool TabsVisible { - get => GameController.OnGodot ? (bool) SceneControl.Get("tabs_visible") : _tabsVisible; + get => _tabsVisible; set { - if (GameController.OnGodot) - { - SceneControl.Set("tabs_visible", value); - } - else - { - _tabsVisible = value; - MinimumSizeChanged(); - } + _tabsVisible = value; + MinimumSizeChanged(); } } - public event Action OnTabSelected; public event Action OnTabChanged; public string GetTabTitle(int tab) { - if (GameController.OnGodot) - { - return (string) SceneControl.Call("get_tab_title", tab); - } - return _tabData[tab].Name ?? GetChild(tab).Name; } public void SetTabTitle(int tab, string title) { - if (GameController.OnGodot) - { - SceneControl.Call("set_tab_title", tab, title); - return; - } - _tabData[tab].Name = title; } @@ -135,11 +89,6 @@ namespace Robust.Client.UserInterface.Controls { base.ChildAdded(newChild); - if (GameController.OnGodot) - { - return; - } - _tabData.Add(new TabData(newChild)); if (ChildCount == 1) @@ -159,11 +108,6 @@ namespace Robust.Client.UserInterface.Controls { base.ChildRemoved(child); - if (GameController.OnGodot) - { - return; - } - for (var i = 0; i < _tabData.Count; i++) { if (_tabData[i].Control == child) @@ -178,11 +122,6 @@ namespace Robust.Client.UserInterface.Controls { base.ChildMoved(child, oldIndex, newIndex); - if (GameController.OnGodot) - { - return; - } - var data = _tabData[oldIndex]; DebugTools.Assert(data.Control == child); _tabData.RemoveAt(oldIndex); @@ -193,11 +132,6 @@ namespace Robust.Client.UserInterface.Controls { base.Draw(handle); - if (GameController.OnGodot) - { - return; - } - // First, draw panel. var headerSize = _getHeaderSize(); var panel = _getPanel(); @@ -270,11 +204,6 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot) - { - return Vector2.Zero; - } - var total = new Vector2(); foreach (var child in Children) @@ -319,7 +248,7 @@ namespace Robust.Client.UserInterface.Controls { base.MouseDown(args); - if (GameController.OnGodot || !TabsVisible) + if (!TabsVisible) { return; } @@ -457,50 +386,6 @@ namespace Robust.Client.UserInterface.Controls return UserInterfaceManager.ThemeDefaults.DefaultFont; } - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.TabContainer(); - } - - protected override void SetupSignalHooks() - { - base.SetupSignalHooks(); - - _onTabSelectedSubscriber = new GodotSignalSubscriber1(); - _onTabSelectedSubscriber.Connect(SceneControl, "tab_selected"); - _onTabSelectedSubscriber.Signal += tab => OnTabSelected?.Invoke((int) tab); - - _onTabChangedSubscriber = new GodotSignalSubscriber1(); - _onTabChangedSubscriber.Connect(SceneControl, "tab_changed"); - _onTabChangedSubscriber.Signal += tab => OnTabChanged?.Invoke((int) tab); - } - - protected override void DisposeSignalHooks() - { - base.DisposeSignalHooks(); - - if (_onTabSelectedSubscriber != null) - { - _onTabSelectedSubscriber.Disconnect(SceneControl, "tab_selected"); - _onTabSelectedSubscriber.Dispose(); - _onTabSelectedSubscriber = null; - } - - if (_onTabChangedSubscriber != null) - { - _onTabChangedSubscriber.Disconnect(SceneControl, "tab_changed"); - _onTabChangedSubscriber.Dispose(); - _onTabChangedSubscriber = null; - } - } - - public enum TabAlignMode - { - Left = 0, - Center = 1, - Right = 2 - } - private class TabData { public string Name; diff --git a/Robust.Client/UserInterface/Controls/TextureButton.cs b/Robust.Client/UserInterface/Controls/TextureButton.cs index b0518f261..c67d1ffd9 100644 --- a/Robust.Client/UserInterface/Controls/TextureButton.cs +++ b/Robust.Client/UserInterface/Controls/TextureButton.cs @@ -11,7 +11,7 @@ using Robust.Shared.Utility; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.TextureButton))] + [ControlWrap("TextureButton")] public class TextureButton : BaseButton { public const string StylePropertyTexture = "texture"; @@ -20,9 +20,6 @@ namespace Robust.Client.UserInterface.Controls public const string StylePseudoClassDisabled = "disabled"; public const string StylePseudoClassPressed = "pressed"; - private Texture _textureNormal; - private Texture _textureHover; - public TextureButton() { } @@ -31,41 +28,8 @@ namespace Robust.Client.UserInterface.Controls { } - internal TextureButton(Godot.TextureButton button) : base(button) - { - } - - public Texture TextureNormal - { - get => _textureNormal ?? (GameController.OnGodot - ? new GodotTextureSource((Godot.Texture) SceneControl.Get("texture_normal")) - : null); - set - { - if (GameController.OnGodot) - { - SceneControl.Set("texture_normal", value.GodotTexture); - } - - _textureNormal = value; - } - } - - public Texture TextureHover - { - get => _textureHover ?? (GameController.OnGodot - ? new GodotTextureSource((Godot.Texture) SceneControl.Get("texture_hover")) - : null); - set - { - if (GameController.OnGodot) - { - SceneControl.Set("texture_hover", value.GodotTexture); - } - - _textureHover = value; - } - } + public Texture TextureNormal { get; set; } + public Texture TextureHover { get; set; } protected override void Initialize() { @@ -95,18 +59,8 @@ namespace Robust.Client.UserInterface.Controls } } - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.TextureButton(); - } - protected internal override void Draw(DrawingHandleScreen handle) { - if (GameController.OnGodot) - { - return; - } - var texture = TextureNormal; if (IsHovered && TextureHover != null) diff --git a/Robust.Client/UserInterface/Controls/TextureRect.cs b/Robust.Client/UserInterface/Controls/TextureRect.cs index e5a12e2b8..13fdd4a9c 100644 --- a/Robust.Client/UserInterface/Controls/TextureRect.cs +++ b/Robust.Client/UserInterface/Controls/TextureRect.cs @@ -11,13 +11,13 @@ using Robust.Shared.Utility; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.TextureRect))] + [ControlWrap("TextureRect")] public class TextureRect : Control { - private bool _canShrink = false; + private bool _canShrink; private StretchMode _stretch = StretchMode.Keep; - public TextureRect() : base() + public TextureRect() { } @@ -25,60 +25,23 @@ namespace Robust.Client.UserInterface.Controls { } - public TextureRect(Godot.TextureRect button) : base(button) - { - } - private Texture _texture; public Texture Texture { - // TODO: Maybe store the texture passed in in case it's like a TextureResource or whatever. - get => _texture ?? (GameController.OnGodot - ? new GodotTextureSource((Godot.Texture) SceneControl.Get("texture")) - : null); + get => _texture; set { - if (GameController.OnGodot) - { - SceneControl.Set("texture", value?.GodotTexture); - } - _texture = value; MinimumSizeChanged(); } } - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.TextureRect(); - } - - protected override void Initialize() - { - base.Initialize(); - -#pragma warning disable 618 - if (GameController.OnGodot && Stretch == StretchMode.ScaleOnExpand) -#pragma warning restore 618 - { - // Turn the old compat mode into the non deprecated mode. - if (CanShrink) - { - Stretch = StretchMode.Scale; - } - else - { - Stretch = StretchMode.Keep; - } - } - } - protected internal override void Draw(DrawingHandleScreen handle) { base.Draw(handle); - if (_texture == null || GameController.OnGodot) + if (_texture == null) { return; } @@ -125,7 +88,6 @@ namespace Robust.Client.UserInterface.Controls var (scaleX, scaleY) = Size / _texture.Size; // Use whichever scale is greater. var scale = Math.Max(scaleX, scaleY); - var texSize = _texture.Size * scale; // Offset inside the actual texture. var offset = (_texture.Size - Size) / scale / 2f; handle.DrawTextureRectRegion(_texture, SizeBox, UIBox2.FromDimensions(offset, Size / scale)); @@ -161,42 +123,28 @@ namespace Robust.Client.UserInterface.Controls public bool CanShrink { - get => GameController.OnGodot ? (bool) SceneControl.Get("expand") : _canShrink; + get => _canShrink; set { - if (GameController.OnGodot) - { - SceneControl.Set("expand", value); - } - else - { - _canShrink = value; - MinimumSizeChanged(); - } + _canShrink = value; + MinimumSizeChanged(); } } public StretchMode Stretch { - get => GameController.OnGodot ? (StretchMode) SceneControl.Get("stretch_mode") : _stretch; + get => _stretch; set { - if (GameController.OnGodot) - { - SceneControl.Set("stretch_mode", (Godot.TextureRect.StretchModeEnum) value); - } - else - { #pragma warning disable 618 - if (value == StretchMode.ScaleOnExpand) + if (value == StretchMode.ScaleOnExpand) #pragma warning restore 618 - { - throw new ArgumentException("ScaleOnExpand is a deprecated holdover from Godot, do not use it.", - nameof(value)); - } - - _stretch = value; + { + throw new ArgumentException("ScaleOnExpand is a deprecated holdover from Godot, do not use it.", + nameof(value)); } + + _stretch = value; } } @@ -216,7 +164,7 @@ namespace Robust.Client.UserInterface.Controls protected override Vector2 CalculateMinimumSize() { - if (GameController.OnGodot || _texture == null || CanShrink) + if (_texture == null || CanShrink) { return Vector2.Zero; } diff --git a/Robust.Client/UserInterface/Controls/Tree.cs b/Robust.Client/UserInterface/Controls/Tree.cs index b9101f4c2..d09150c45 100644 --- a/Robust.Client/UserInterface/Controls/Tree.cs +++ b/Robust.Client/UserInterface/Controls/Tree.cs @@ -8,52 +8,24 @@ using Robust.Shared.Utility; namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.Tree))] + [ControlWrap("Tree")] public class Tree : Control { public const string StylePropertyItemBoxSelected = "item-selected"; public const string StylePropertyBackground = "background"; - readonly Dictionary ItemMap = new Dictionary(); private readonly List _itemList = new List(); - private bool _hideRoot; - private Item _root; private int? _selectedIndex; private VScrollBar _scrollBar; - public bool HideRoot - { - get => GameController.OnGodot ? (bool) SceneControl.Get("hide_root") : _hideRoot; - set - { - if (GameController.OnGodot) - { - SceneControl.Set("hide_root", value); - } - else - { - _hideRoot = value; - } - } - } + public bool HideRoot { get; set; } - public Item Root => GameController.OnGodot ? GetItem((Godot.TreeItem) SceneControl.Call("get_root")) : _root; + public Item Root => _root; - public Item Selected - { - get - { - if (GameController.OnGodot) - { - return GetItem((Godot.TreeItem) SceneControl.Call("get_selected")); - } - - return _selectedIndex == null ? null : _itemList[_selectedIndex.Value]; - } - } + public Item Selected => _selectedIndex == null ? null : _itemList[_selectedIndex.Value]; public event Action OnItemSelected; @@ -67,30 +39,10 @@ namespace Robust.Client.UserInterface.Controls { } - internal Tree(Godot.Tree panel) : base(panel) - { - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.Tree(); - } - #endregion Construction public void Clear() { - foreach (var item in ItemMap.Values) - { - item.Dispose(); - } - - ItemMap.Clear(); - if (GameController.OnGodot) - { - SceneControl.Call("clear"); - } - foreach (var item in _itemList) { item.Dispose(); @@ -117,54 +69,21 @@ namespace Robust.Client.UserInterface.Controls } } - if (GameController.OnGodot) + var item = new Item(this, _itemList.Count); + _itemList.Add(item); + + if (_root == null) { - var nativeItem = (Godot.TreeItem) SceneControl.Call("create_item", parent?.NativeItem); - var item = new Item(nativeItem, this, ItemMap.Count); - ItemMap[nativeItem] = item; - return item; + _root = item; } else { - var item = new Item(this, _itemList.Count); - _itemList.Add(item); - - if (_root == null) - { - _root = item; - } - else - { - parent = parent ?? _root; - parent.Children.Add(item); - } - - _updateScrollbar(); - return item; - } - } - - public void EnsureCursorIsVisible() - { - if (GameController.OnGodot) - { - SceneControl.Call("ensure_cursor_is_visible"); - } - } - - public Vector2 GetScroll() - { - return GameController.OnGodot ? ((Godot.Vector2) SceneControl.Call("get_scroll")).Convert() : default; - } - - private Item GetItem(Godot.TreeItem item) - { - if (ItemMap.TryGetValue(item, out var ret)) - { - return ret; + parent = parent ?? _root; + parent.Children.Add(item); } - return null; + _updateScrollbar(); + return item; } protected override void SetDefaults() @@ -178,11 +97,6 @@ namespace Robust.Client.UserInterface.Controls { base.Initialize(); - if (GameController.OnGodot) - { - return; - } - _scrollBar = new VScrollBar {Name = "_v_scroll"}; AddChild(_scrollBar); _scrollBar.SetAnchorAndMarginPreset(LayoutPreset.RightWide); @@ -192,11 +106,6 @@ namespace Robust.Client.UserInterface.Controls { base.MouseDown(args); - if (GameController.OnGodot) - { - return; - } - var item = _tryFindItemAtPosition(args.RelativePosition); if (item != null && item.Selectable) @@ -208,8 +117,6 @@ namespace Robust.Client.UserInterface.Controls private Item _tryFindItemAtPosition(Vector2 position) { - DebugTools.Assert(!GameController.OnGodot); - var font = _getFont(); if (font == null || _root == null) { @@ -271,11 +178,6 @@ namespace Robust.Client.UserInterface.Controls { base.Draw(handle); - if (GameController.OnGodot) - { - return; - } - var font = _getFont(); if (font == null || _root == null) { @@ -374,11 +276,6 @@ namespace Robust.Client.UserInterface.Controls private void _updateScrollbar() { - if (GameController.OnGodot) - { - return; - } - var internalHeight = _getInternalHeight(); _scrollBar.MaxValue = internalHeight; _scrollBar.Page = Height; @@ -432,88 +329,17 @@ namespace Robust.Client.UserInterface.Controls } } - #region Signals - - private GodotGlue.GodotSignalSubscriber0 __itemSelectedSubscriber; - - protected override void SetupSignalHooks() - { - base.SetupSignalHooks(); - - __itemSelectedSubscriber = new GodotGlue.GodotSignalSubscriber0(); - __itemSelectedSubscriber.Connect(SceneControl, "item_selected"); - __itemSelectedSubscriber.Signal += () => OnItemSelected?.Invoke(); - } - - protected override void DisposeSignalHooks() - { - base.DisposeSignalHooks(); - - if (__itemSelectedSubscriber != null) - { - __itemSelectedSubscriber?.Disconnect(SceneControl, "item_selected"); - __itemSelectedSubscriber?.Dispose(); - __itemSelectedSubscriber = null; - } - } - - #endregion Signals - public sealed class Item : IDisposable { - internal readonly Godot.TreeItem NativeItem; internal readonly List Children = new List(); internal readonly int Index; public readonly Tree Parent; public object Metadata { get; set; } public bool Disposed { get; private set; } - private string _text; - private bool _selectable = true; + public string Text { get; set; } - public string Text - { - get => GameController.OnGodot ? NativeItem.GetText(0) : _text; - set - { - if (GameController.OnGodot) - { - NativeItem.SetText(0, value); - } - else - { - _text = value; - } - } - } - - [Obsolete("Use Text")] - public void SetText(int column, string text) - { - Text = text; - } - - public bool Selectable - { - get => GameController.OnGodot ? NativeItem.IsSelectable(0) : _selectable; - set - { - if (GameController.OnGodot) - { - NativeItem.SetSelectable(0, value); - } - else - { - _selectable = value; - } - } - } - - [Obsolete("Use Selectable")] - public void SetSelectable(int column, bool selectable) - { - Selectable = selectable; - } + public bool Selectable { get; set; } = true; internal Item(Tree parent, int index) { @@ -521,20 +347,8 @@ namespace Robust.Client.UserInterface.Controls Index = index; } - internal Item(Godot.TreeItem native, Tree parent, int index) - { - NativeItem = native; - Parent = parent; - Index = index; - } - public void Dispose() { - if (GameController.OnGodot) - { - NativeItem?.Dispose(); - } - Disposed = true; } } diff --git a/Robust.Client/UserInterface/Controls/VBoxContainer.cs b/Robust.Client/UserInterface/Controls/VBoxContainer.cs index 31d7e9d27..fb5bc8f66 100644 --- a/Robust.Client/UserInterface/Controls/VBoxContainer.cs +++ b/Robust.Client/UserInterface/Controls/VBoxContainer.cs @@ -1,9 +1,9 @@ namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.VBoxContainer))] + [ControlWrap("VBoxContainer")] public class VBoxContainer : BoxContainer { - public VBoxContainer() : base() + public VBoxContainer() { } @@ -11,15 +11,6 @@ { } - internal VBoxContainer(Godot.VBoxContainer sceneControl) : base(sceneControl) - { - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.VBoxContainer(); - } - private protected override bool Vertical => true; } } diff --git a/Robust.Client/UserInterface/Controls/VScrollBar.cs b/Robust.Client/UserInterface/Controls/VScrollBar.cs index 1fed8907c..731ddbd36 100644 --- a/Robust.Client/UserInterface/Controls/VScrollBar.cs +++ b/Robust.Client/UserInterface/Controls/VScrollBar.cs @@ -1,19 +1,10 @@ namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.VScrollBar))] + [ControlWrap("VScrollBar")] public class VScrollBar : ScrollBar { public VScrollBar() : base(OrientationMode.Vertical) { } - - internal VScrollBar(Godot.ScrollBar control) : base(control) - { - } - - private protected override Godot.Control SpawnSceneControl() - { - return new Godot.VScrollBar(); - } } } diff --git a/Robust.Client/UserInterface/Controls/VSplitContainer.cs b/Robust.Client/UserInterface/Controls/VSplitContainer.cs index 7ab0809a9..0a7b9cffc 100644 --- a/Robust.Client/UserInterface/Controls/VSplitContainer.cs +++ b/Robust.Client/UserInterface/Controls/VSplitContainer.cs @@ -1,11 +1,10 @@ namespace Robust.Client.UserInterface.Controls { - [ControlWrap(typeof(Godot.VSplitContainer))] + [ControlWrap("VSplitContainer")] public class VSplitContainer : SplitContainer { private protected sealed override bool Vertical => true; public VSplitContainer() {} - public VSplitContainer(Godot.VSplitContainer control) : base(control) {} } } diff --git a/Robust.Client/UserInterface/CustomControls/SS14Window.cs b/Robust.Client/UserInterface/CustomControls/SS14Window.cs index 06004839a..23efcb009 100644 --- a/Robust.Client/UserInterface/CustomControls/SS14Window.cs +++ b/Robust.Client/UserInterface/CustomControls/SS14Window.cs @@ -97,13 +97,10 @@ namespace Robust.Client.UserInterface.CustomControls TitleLabel.AddStyleClass(StyleClassWindowTitle); AddStyleClass(StyleClassWindowPanel); header.AddStyleClass(StyleClassWindowHeader); - // TODO: Remove this check by making UI in Godot also use CSS. - if (!GameController.OnGodot) - { - header.PanelOverride = null; - CloseButton.TextureNormal = null; - CloseButton.AddStyleClass(StyleClassWindowCloseButton); - } + + header.PanelOverride = null; + CloseButton.TextureNormal = null; + CloseButton.AddStyleClass(StyleClassWindowCloseButton); if (CustomSize != null) { diff --git a/Robust.Client/UserInterface/RichTextEntry.cs b/Robust.Client/UserInterface/RichTextEntry.cs index 6d87c25c2..d2f7b656b 100644 --- a/Robust.Client/UserInterface/RichTextEntry.cs +++ b/Robust.Client/UserInterface/RichTextEntry.cs @@ -43,7 +43,6 @@ namespace Robust.Client.UserInterface /// The horizontal size of the container of this entry. public void Update(Font font, float sizeX) { - DebugTools.Assert(!GameController.OnGodot); // This method is gonna suck due to complexity. // Bear with me here. // I am so deeply sorry for the person adding stuff to this in the future. diff --git a/Robust.Client/UserInterface/UserInterfaceManager.cs b/Robust.Client/UserInterface/UserInterfaceManager.cs index f4ee16c6e..2d1c3d070 100644 --- a/Robust.Client/UserInterface/UserInterfaceManager.cs +++ b/Robust.Client/UserInterface/UserInterfaceManager.cs @@ -29,7 +29,6 @@ namespace Robust.Client.UserInterface { internal sealed class UserInterfaceManager : IDisposable, IUserInterfaceManagerInternal { - [Dependency] private readonly ISceneTreeHolder _sceneTreeHolder; [Dependency] private readonly IInputManager _inputManager; [Dependency] private readonly IDisplayManager _displayManager; [Dependency] private readonly IClientConsole _console; @@ -50,7 +49,6 @@ namespace Robust.Client.UserInterface // So we keep track of which control is "focused" by the mouse. private Control _mouseFocused; - private Godot.CanvasLayer CanvasLayer; public Control StateRoot { get; private set; } public Control CurrentlyHovered { get; private set; } public Control RootControl { get; private set; } @@ -94,33 +92,14 @@ namespace Robust.Client.UserInterface private void _initializeCommon() { - if (GameController.OnGodot) - { - CanvasLayer = new Godot.CanvasLayer - { - Name = "UILayer", - Layer = CanvasLayers.LAYER_GUI - }; - - _sceneTreeHolder.SceneTree.GetRoot().AddChild(CanvasLayer); - } - RootControl = new Control("UIRoot") { MouseFilter = Control.MouseFilterMode.Ignore, IsInsideTree = true }; RootControl.SetAnchorPreset(Control.LayoutPreset.Wide); - if (!GameController.OnGodot) - { - RootControl.Size = _displayManager.ScreenSize; - _displayManager.OnWindowResized += args => RootControl.Size = args.NewSize; - } - - if (GameController.OnGodot) - { - CanvasLayer.AddChild(RootControl.SceneControl); - } + RootControl.Size = _displayManager.ScreenSize; + _displayManager.OnWindowResized += args => RootControl.Size = args.NewSize; StateRoot = new Control("StateRoot") { diff --git a/Robust.Client/Utility/GodotConversions.cs b/Robust.Client/Utility/GodotConversions.cs deleted file mode 100644 index 373287482..000000000 --- a/Robust.Client/Utility/GodotConversions.cs +++ /dev/null @@ -1,75 +0,0 @@ -using Robust.Shared.Maths; - -namespace Robust.Client.Utility -{ - internal static class GodotConversions - { - public static Vector2 Convert(this Godot.Vector2 vector2) - { - return new Vector2(vector2.x, vector2.y); - } - - public static Godot.Vector2 Convert(this Vector2 vector2) - { - return new Godot.Vector2(vector2.X, vector2.Y); - } - - public static Vector3 Convert(this Godot.Vector3 vector3) - { - return new Vector3(vector3.x, vector3.y, vector3.z); - } - - public static Godot.Vector3 Convert(this Vector3 vector3) - { - return new Godot.Vector3(vector3.X, vector3.Y, vector3.Z); - } - - public static Color Convert(this Godot.Color color) - { - return new Color(color.r, color.g, color.b, color.a); - } - - public static Godot.Color Convert(this Color color) - { - return new Godot.Color(color.R, color.G, color.B, color.A); - } - - public static Godot.Rect2 Convert(this UIBox2 box) - { - return new Godot.Rect2(box.Left, box.Top, box.Width, box.Height); - } - - public static UIBox2 Convert(this Godot.Rect2 rect) - { - return new UIBox2(rect.Position.x, rect.Position.y, rect.End.x, rect.End.y); - } - - /// - /// Loosely convert a 3x3 matrix into a Godot 2D transform. - /// This does not copy over the third row, as Godot's 2D transforms don't have it. - /// - public static Godot.Transform2D Convert(in this Matrix3 matrix) - { - return new Godot.Transform2D - { - origin = new Godot.Vector2(matrix.R0C2, matrix.R1C2), - x = new Godot.Vector2(matrix.R0C0, matrix.R1C0), - y = new Godot.Vector2(matrix.R0C1, matrix.R1C1), - }; - } - - /// - /// Loosely convert a 2D Godot transform into a 3x3 matrix. - /// The third row will be initialized to 0, 0, 1 as does not carry it. - /// - public static Matrix3 Convert(in this Godot.Transform2D transform) - { - return new Matrix3 - { - R0C0 = transform.x.x, R0C1 = transform.y.x, R0C2 = transform.origin.x, - R1C0 = transform.x.y, R1C1 = transform.y.y, R1C2 = transform.origin.y, - R2C0 = 0, R2C1 = 0, R2C2 = 1 - }; - } - } -} diff --git a/Robust.Client/Utility/GodotResourceCopy.cs b/Robust.Client/Utility/GodotResourceCopy.cs deleted file mode 100644 index 2a034b115..000000000 --- a/Robust.Client/Utility/GodotResourceCopy.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using Robust.Shared.ContentPack; -using Robust.Shared.Utility; - -namespace Robust.Client.Utility -{ - // Don't use this outside debug builds. - // Seriously. - // For release builds, this should be handled by the release packaging script. -#if DEBUG - /// - /// Handles the automatic copying of resources that need to be accessible to Godot's res://. - /// That's .tscn files, font files and GUI image files. - /// I say copy but if you're on Unix, it'll use symlinks. Like a sane person. - /// - public static class GodotResourceCopy - { - /// - /// Ensure that the directory is a mirror of . - /// On Windows this does a recursive copy. - /// On Unix it uses a symlink. - /// - public static void DoDirCopy(string sourcePath, string targetPath) - { - if (!GameController.OnGodot) - { - return; - } -#if UNIX - if (Directory.Exists(targetPath)) - { - return; - } - var process = Process.Start("ln", $"-s \"{sourcePath}\" \"{targetPath}\""); - if (process == null) - { - throw new IOException(); - } - - process.WaitForExit(); - DebugTools.Assert(process.ExitCode == 0); -#else - if (File.Exists(Path.Combine(targetPath, "I_MADE_THE_SYMLINK"))) - { - return; - } - - var dirQueue = new Queue(); - dirQueue.Enqueue("."); - - while (dirQueue.Count > 0) - { - var relative = dirQueue.Dequeue(); - var sourceRelative = Path.Combine(sourcePath, relative); - var targetRelative = Path.Combine(targetPath, relative); - - Directory.CreateDirectory(targetRelative); - - foreach (var dirChild in Directory.EnumerateDirectories(sourceRelative).Select(Path.GetFileName)) - { - dirQueue.Enqueue(Path.Combine(relative, dirChild)); - } - - foreach (var fileChild in Directory.EnumerateFiles(sourceRelative).Select(Path.GetFileName)) - { - var sourceFile = Path.Combine(sourceRelative, fileChild); - var targetFile = Path.Combine(targetRelative, fileChild); - - if (!File.Exists(targetFile) || File.GetLastWriteTime(targetFile) < File.GetLastWriteTime(sourceFile)) - { - File.Copy(sourceFile, targetFile, true); - } - } - } -#endif - } - } -#endif // DEBUG -} diff --git a/Robust.UnitTesting/Client/Utility/GodotConversionsTest.cs b/Robust.UnitTesting/Client/Utility/GodotConversionsTest.cs deleted file mode 100644 index 95f710373..000000000 --- a/Robust.UnitTesting/Client/Utility/GodotConversionsTest.cs +++ /dev/null @@ -1,44 +0,0 @@ -using NUnit.Framework; -using Robust.Client.Utility; -using Robust.Shared.Maths; - -namespace Robust.UnitTesting.Client.Utility -{ - [Parallelizable(ParallelScope.All | ParallelScope.Fixtures)] - [TestFixture] - [TestOf(typeof(GodotConversions))] - class GodotConversionsTest - { - [Test] - public void TestTransform2DConversion() - { - var matrix = Matrix3.Identity; - var xform = matrix.Convert(); - var vec = new Vector2(5, 7); - - Assert.That(Xform(vec, xform), Is.EqualTo(matrix.Transform(vec))); - - matrix = new Matrix3(0.75f, 0.20f, 5, - 0.66f, 0.15f, 5, - 0, 0, 1); - xform = matrix.Convert(); - Assert.That(Xform(vec, xform), Is.EqualTo(matrix.Transform(vec))); - Assert.That(Xform(vec, xform.Convert()), Is.EqualTo(matrix.Transform(vec))); - vec = Vector2.Zero; - Assert.That(Xform(vec, xform), Is.EqualTo(matrix.Transform(vec))); - Assert.That(Xform(vec, xform.Convert()), Is.EqualTo(matrix.Transform(vec))); - } - - private static Vector2 Xform(Vector2 vector, Matrix3 matrix) - { - var vec3 = new Vector3(vector.X, vector.Y, 1); - matrix.Transform(ref vec3); - return new Vector2(vec3.X, vec3.Y); - } - - private static Vector2 Xform(Vector2 vector, Godot.Transform2D transform) - { - return transform.Xform(vector.Convert()).Convert(); - } - } -} diff --git a/Robust.UnitTesting/Robust.UnitTesting.csproj b/Robust.UnitTesting/Robust.UnitTesting.csproj index 48376405f..48075418f 100644 --- a/Robust.UnitTesting/Robust.UnitTesting.csproj +++ b/Robust.UnitTesting/Robust.UnitTesting.csproj @@ -30,7 +30,6 @@ 7.2 - true true @@ -73,12 +72,6 @@ - - ..\Robust.Client.Godot\.mono\assemblies\GodotSharp.dll - - - ..\Dependencies\godot\GodotSharp.dll - @@ -101,7 +94,6 @@ - diff --git a/Robust.UnitTesting/RobustUnitTest.cs b/Robust.UnitTesting/RobustUnitTest.cs index 9c851ab32..7c1bb248a 100644 --- a/Robust.UnitTesting/RobustUnitTest.cs +++ b/Robust.UnitTesting/RobustUnitTest.cs @@ -231,7 +231,6 @@ namespace Robust.UnitTesting //IoCManager.Register(); IoCManager.Register(); IoCManager.Register(); - IoCManager.Register(); IoCManager.Register(); IoCManager.Register(); IoCManager.Register(); diff --git a/RobustToolbox.sln b/RobustToolbox.sln index 0d71d0c72..c394ce878 100644 --- a/RobustToolbox.sln +++ b/RobustToolbox.sln @@ -16,8 +16,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{795D76AB EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Client", "Robust.Client\Robust.Client.csproj", "{83429BD6-6358-4B18-BE51-401DF8EA2673}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Client.Godot", "Robust.Client.Godot\Robust.Client.Godot.csproj", "{8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Shared.Maths", "Robust.Shared.Maths\Robust.Shared.Maths.csproj", "{93F23A82-00C5-4572-964E-E7C9457726D4}" EndProject Global @@ -141,24 +139,6 @@ Global {83429BD6-6358-4B18-BE51-401DF8EA2673}.Tools|x64.Build.0 = Debug|x64 {83429BD6-6358-4B18-BE51-401DF8EA2673}.Tools|x86.ActiveCfg = Debug|x86 {83429BD6-6358-4B18-BE51-401DF8EA2673}.Tools|x86.Build.0 = Debug|x86 - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Debug|x64.ActiveCfg = Debug|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Debug|x64.Build.0 = Debug|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Debug|x86.ActiveCfg = Debug|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Debug|x86.Build.0 = Debug|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Release|Any CPU.Build.0 = Release|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Release|x64.ActiveCfg = Release|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Release|x64.Build.0 = Release|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Release|x86.ActiveCfg = Release|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Release|x86.Build.0 = Release|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|Any CPU.ActiveCfg = Tools|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|Any CPU.Build.0 = Tools|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|x64.ActiveCfg = Tools|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|x64.Build.0 = Tools|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|x86.ActiveCfg = Tools|Any CPU - {8AF31169-49B1-4A12-B8F4-2A0674A9E7CB}.Tools|x86.Build.0 = Tools|Any CPU {93F23A82-00C5-4572-964E-E7C9457726D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {93F23A82-00C5-4572-964E-E7C9457726D4}.Debug|Any CPU.Build.0 = Debug|Any CPU {93F23A82-00C5-4572-964E-E7C9457726D4}.Debug|x64.ActiveCfg = Debug|x64