Skip to content

Commit 15af769

Browse files
committed
Fix DS loading, add NLog for logging
1 parent a3e29ff commit 15af769

25 files changed

Lines changed: 144 additions & 149 deletions

‎TestPlugin/Class1.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ public class Plugin : TorchPluginBase
1515
public override void Init(ITorchBase torch)
1616
{
1717
base.Init(torch);
18-
Torch.Log.Write($"Plugin init {Name}");
18+
//Torch.Log.Write($"Plugin init {Name}");
1919
}
2020

2121
/// <inheritdoc />
2222
public override void Update()
2323
{
24-
Torch.Log.Write($"Plugin update {Name}");
24+
//Torch.Log.Write($"Plugin update {Name}");
2525
}
2626

2727
/// <inheritdoc />
2828
public override void Unload()
2929
{
30-
Torch.Log.Write($"Plugin unload {Name}");
30+
//Torch.Log.Write($"Plugin unload {Name}");
3131
}
3232
}
3333
}

‎Torch.API/ILogger.cs‎

Lines changed: 0 additions & 14 deletions
This file was deleted.

‎Torch.API/IPluginManager.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ public interface IPluginManager : IEnumerable<ITorchPlugin>
99
{
1010
void UpdatePlugins();
1111
void LoadPlugins();
12+
void UnloadPlugins();
1213
}
1314
}

‎Torch.API/ITorchBase.cs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public interface ITorchBase
1111
event Action SessionLoaded;
1212
IMultiplayer Multiplayer { get; }
1313
IPluginManager Plugins { get; }
14-
ILogger Log { get; set; }
1514
void Invoke(Action action);
1615
void InvokeBlocking(Action action);
1716
Task InvokeAsync(Action action);

‎Torch.API/ITorchPlugin.cs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,20 @@ public interface ITorchPlugin
1313
Version Version { get; }
1414
string Name { get; }
1515

16+
/// <summary>
17+
/// Called when the game is initialized.
18+
/// </summary>
19+
/// <param name="torchBase"></param>
1620
void Init(ITorchBase torchBase);
21+
22+
/// <summary>
23+
/// Called after each game tick. Not thread safe, use invocation methods in <see cref="ITorchBase"/>.
24+
/// </summary>
1725
void Update();
26+
27+
/// <summary>
28+
/// Called when the game exits.
29+
/// </summary>
1830
void Unload();
1931
}
2032
}

‎Torch.API/Torch.API.csproj‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,18 @@
3232
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
3333
</PropertyGroup>
3434
<ItemGroup>
35+
<Reference Include="NLog">
36+
<HintPath>..\packages\NLog.4.4.1\lib\net45\NLog.dll</HintPath>
37+
</Reference>
3538
<Reference Include="PresentationCore" />
3639
<Reference Include="PresentationFramework" />
3740
<Reference Include="System" />
41+
<Reference Include="System.Configuration" />
3842
<Reference Include="System.Core" />
43+
<Reference Include="System.IO.Compression" />
44+
<Reference Include="System.Runtime.Serialization" />
45+
<Reference Include="System.ServiceModel" />
46+
<Reference Include="System.Transactions" />
3947
<Reference Include="System.Xml.Linq" />
4048
<Reference Include="System.Data.DataSetExtensions" />
4149
<Reference Include="Microsoft.CSharp" />
@@ -53,7 +61,6 @@
5361
<ItemGroup>
5462
<Compile Include="ConnectionState.cs" />
5563
<Compile Include="IChatItem.cs" />
56-
<Compile Include="ILogger.cs" />
5764
<Compile Include="IMultiplayer.cs" />
5865
<Compile Include="IPlayer.cs" />
5966
<Compile Include="IPluginManager.cs" />
@@ -63,6 +70,9 @@
6370
<Compile Include="PluginAttribute.cs" />
6471
<Compile Include="Properties\AssemblyInfo.cs" />
6572
</ItemGroup>
73+
<ItemGroup>
74+
<None Include="packages.config" />
75+
</ItemGroup>
6676
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6777
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
6878
Other similar extension points exist, see Microsoft.Common.targets.

‎Torch.API/packages.config‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="NLog" version="4.4.1" targetFramework="net461" />
4+
</packages>

‎Torch.Client/Torch.Client.csproj‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
<Prefer32Bit>true</Prefer32Bit>
3838
</PropertyGroup>
3939
<ItemGroup>
40+
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
41+
<HintPath>..\packages\NLog.4.4.1\lib\net45\NLog.dll</HintPath>
42+
<Private>True</Private>
43+
</Reference>
4044
<Reference Include="Sandbox.Game">
4145
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Bin64\Sandbox.Game.dll</HintPath>
4246
</Reference>
@@ -108,6 +112,7 @@
108112
<Generator>ResXFileCodeGenerator</Generator>
109113
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
110114
</EmbeddedResource>
115+
<None Include="packages.config" />
111116
<None Include="Properties\Settings.settings">
112117
<Generator>SettingsSingleFileGenerator</Generator>
113118
<LastGenOutput>Settings.Designer.cs</LastGenOutput>

‎Torch.Client/TorchClient.cs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,14 @@ public override void Start()
8585
{
8686
using (var spaceEngineersGame = new SpaceEngineersGame(_services, RunArgs))
8787
{
88-
Log.Write("Starting client...");
88+
Log.Info("Starting client");
8989
spaceEngineersGame.OnGameLoaded += SpaceEngineersGame_OnGameLoaded;
9090
spaceEngineersGame.Run();
9191
}
9292
}
9393

9494
private void SpaceEngineersGame_OnGameLoaded(object sender, EventArgs e)
9595
{
96-
Log.Write("Loading plugins");
97-
Plugins.LoadAllPlugins();
9896
}
9997

10098
public override void Stop()

‎Torch.Client/TorchSettingsScreen.cs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ public sealed override void RecreateControls(bool constructor)
2828
VisibleRowsCount = 10,
2929
};
3030

31-
foreach (var plugin in TorchBase.Instance.Plugins.Plugins)
31+
foreach (var plugin in TorchBase.Instance.Plugins)
3232
{
33-
var name = TorchBase.Instance.Plugins.GetPluginName(plugin.GetType());
34-
pluginList.Items.Add(new MyGuiControlListbox.Item(new StringBuilder(name)));
33+
pluginList.Items.Add(new MyGuiControlListbox.Item(new StringBuilder(plugin.Name)));
3534
}
3635
Controls.Add(pluginList);
3736
}

0 commit comments

Comments
 (0)