Skip to content

Commit

Permalink
Initial pre release
Browse files Browse the repository at this point in the history
  • Loading branch information
sjdawson committed Jan 18, 2021
1 parent ad86f7d commit d4b2a8b
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 34 deletions.
15 changes: 9 additions & 6 deletions GentlemanDriverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ namespace sjdawson.GentlemanDriverPlugin
{
[PluginDescription("Additional properties, actions and events for use in various racing games.")]
[PluginAuthor("sjdawson")]
[PluginName("GentlemanDriverPlugin")]
[PluginName("Gentleman Driver Plugin")]

public class GentlemanDriverPlugin: IPlugin, IDataPlugin, IWPFSettings
{
public GentlemanDriverPluginSettings Settings;
public PluginManager PluginManager { get; set; }

// public Sections.Flags Flags;
public Sections.Laps Laps;

/// <summary>
/// Initialise the plugin preparing all settings, properties, events and triggers.
Expand All @@ -23,16 +23,19 @@ public void Init(PluginManager pluginManager)
{
Settings = this.ReadCommonSettings<GentlemanDriverPluginSettings>("GentlemanDriverPluginSettings", () => new GentlemanDriverPluginSettings());

// Flags = new Sections.Flags(this);
Laps = new Sections.Laps(this);
}

/// <param name="pluginManager"></param>
/// <param name="data"></param>
public void DataUpdate(PluginManager pluginManager, ref GameData data)
{
if (data.OldData != null && data.NewData != null)
{
// Lights.DataUpdate();
if (data.GameRunning)
{
if (data.OldData != null && data.NewData != null)
{
Laps.DataUpdate(ref data);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions GentlemanDriverPluginSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
{
public class GentlemanDriverPluginSettings
{
public int OptimalTyreTemperature = 85;
}
}
6 changes: 5 additions & 1 deletion GentlemanDriverPluginSettingsControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<ColumnDefinition/>
</Grid.ColumnDefinitions>

<TextBlock Text="NO SETTINGS" FontSize="16" FontWeight="Bold" Grid.ColumnSpan="2" Margin="20,20,0,0"/>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="30,0,0,0" Text="Optimal tyre temperature" Grid.Row="0" />
<Custom:NumericUpDown x:Name="OptimalTyreTemperature" HasDecimals="False" Margin="5" ValueChanged="OptimalTyreTemperatureChanged" Grid.Row="0"
ToolTip="The value at which your tyres are at their optimal temperature"
Width="300" HorizontalAlignment="Right"
Grid.Column="1" Minimum="0" Maximum="200"/>
</Grid>
</UserControl>
7 changes: 7 additions & 0 deletions GentlemanDriverPluginSettingsControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@ public partial class GentlemanDriverPluginSettingsControl : UserControl

public GentlemanDriverPluginSettingsControl()
{
InitializeComponent();
}

public GentlemanDriverPluginSettingsControl(GentlemanDriverPlugin plugin) : this()
{
this.Plugin = plugin;
}

public void OptimalTyreTemperatureChanged(object sender, RoutedPropertyChangedEventArgs<double?> e)
{
Plugin.Settings.OptimalTyreTemperature = (int)OptimalTyreTemperature.Value;
}

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
OptimalTyreTemperature.Value = Plugin.Settings.OptimalTyreTemperature;
}
}
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ This plugin for [SimHub](https://www.simhubdash.com/) adds properties, events an

### 0.0.1

Initial release
Initial pre-release
- Adds `GentlemanDriver.Laps.StintTotal` property, showing the number of laps in your current stint

---

Expand Down
22 changes: 0 additions & 22 deletions Sections/Flags.cs

This file was deleted.

33 changes: 33 additions & 0 deletions Sections/Laps.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using GameReaderCommon;

namespace sjdawson.GentlemanDriverPlugin.Sections
{
public class Laps
{
private readonly GentlemanDriverPlugin Base;

private int LastOutLap = 0;

public Laps(GentlemanDriverPlugin gentlemanDriverPlugin)
{
Base = gentlemanDriverPlugin;

Base.AddProp("Laps.StintTotal", 0);
}

public void DataUpdate(ref GameData data)
{
Base.SetProp("Laps.StintTotal", LapsStintTotal(data));
}

private int LapsStintTotal(GameData data)
{
if (data.NewData.IsInPitLane > 0)
{
this.LastOutLap = data.NewData.CurrentLap;
}

return data.NewData.CurrentLap - this.LastOutLap;
}
}
}
8 changes: 4 additions & 4 deletions sjdawson.GentlemanDriverPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ProjectGuid>{833040C9-FE5E-4CCF-B21D-71979E049B6B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>sjdawson.BeamNGPlugin</RootNamespace>
<AssemblyName>sjdawson.BeamNGPlugin</AssemblyName>
<RootNamespace>sjdawson.GentlemanDriverPlugin</RootNamespace>
<AssemblyName>sjdawson.GentlemanDriverPlugin</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
Expand Down Expand Up @@ -82,7 +82,7 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Sections\Flags.cs" />
<Compile Include="Sections\Laps.cs" />
<Compile Include="GentlemanDriverPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="GentlemanDriverPluginSettings.cs" />
Expand Down Expand Up @@ -112,4 +112,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

0 comments on commit d4b2a8b

Please sign in to comment.