Skip to content

Commit

Permalink
Merge pull request #44 from Craxy/csproj
Browse files Browse the repository at this point in the history
Update csproj file
  • Loading branch information
Craxy authored Oct 2, 2018
2 parents 41280e5 + 846ee27 commit 716c689
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 48 deletions.
74 changes: 41 additions & 33 deletions src/ToggleTrafficLights/Mod.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using Craxy.CitiesSkylines.ToggleTrafficLights.Game;
Expand All @@ -12,48 +13,55 @@ namespace Craxy.CitiesSkylines.ToggleTrafficLights
// Strange behaviour of IUserMod with other interfaces:
// For every class with C:S mod interface a new instance is created, even if same class implements multiple interfaces.
// Except: for IUserMod: if class with IUserMod implements other C:S mod interfaces, IUserMod instance is reused
public sealed class Mod

public sealed class Mod
: IUserMod
, ISerializableDataExtension, ILoadingExtension
#if DEBUG
, IThreadingExtension
#endif
{
public Simulation Simulation => Simulation.Instance;

#region IUserMod
private static Version Version
=> Assembly.GetExecutingAssembly().GetName().Version;

static Mod()
=> Log.Info($"Loaded: {Assembly.GetExecutingAssembly().GetName()})");

public string Name
=> "Toggle Traffic Lights"
#if DEBUG
+ " (DEBUG)"
#endif
;
public string Description
=> "Remove or add traffic lights at junctions.";

public void OnEnabled()
public static readonly Version Version;
private static string _name, _description;
static Mod()
{
var assembly = Assembly.GetExecutingAssembly();

Version = assembly.GetName().Version;

T GetAssemblyAttribute<T>() where T : Attribute => (T) assembly.GetCustomAttributes(typeof(T), false).Single();

_name = GetAssemblyAttribute<AssemblyTitleAttribute>().Title;
#if DEBUG
_name += " (DEBUG)";
#endif
_description = GetAssemblyAttribute<AssemblyDescriptionAttribute>().Description;

Log.Info($"Loaded: {Assembly.GetExecutingAssembly().GetName()}) at {DateTime.Now}");
}

public string Name => _name;
public string Description => _description;

public void OnEnabled()
=> Log.Message($"Mod {Name} v.{Version} enabled at {DateTime.Now}");
public void OnDisabled()
public void OnDisabled()
=> Log.Message($"Mod {Name} v.{Version} disabled at {DateTime.Now}");

public void OnSettingsUI(UIHelperBase helper)
public void OnSettingsUI(UIHelperBase helper)
=> SettingsBuilder.MakeSettings((UIHelper) helper, Simulation.Options);

#endregion IUserMode

#region ISerializableDataExtension
void ISerializableDataExtension.OnCreated(ISerializableData serializedData)
void ISerializableDataExtension.OnCreated(ISerializableData serializedData)
=> Trace(nameof(ISerializableDataExtension));
void ILoadingExtension.OnReleased()
void ILoadingExtension.OnReleased()
=> Trace(nameof(ILoadingExtension));

void ILoadingExtension.OnLevelLoaded(LoadMode mode)
{
Trace(nameof(ILoadingExtension));
Expand All @@ -65,13 +73,13 @@ void ILoadingExtension.OnLevelUnloading()
Simulation.Process(Simulation.Step.LevelUnloaded);
}
#endregion ISerializableDataExtension

#region ILoadingExtension
void ILoadingExtension.OnCreated(ILoading loading)
void ILoadingExtension.OnCreated(ILoading loading)
=> Trace(nameof(ILoadingExtension));
void ISerializableDataExtension.OnReleased()
void ISerializableDataExtension.OnReleased()
=> Trace(nameof(ISerializableDataExtension));

void ISerializableDataExtension.OnLoadData()
{
Trace(nameof(ISerializableDataExtension));
Expand All @@ -83,14 +91,14 @@ void ISerializableDataExtension.OnSaveData()
Simulation.Process(Simulation.Step.SaveData);
}
#endregion ILoadingExtension

#region IThreadingExtension
#if DEBUG
void IThreadingExtension.OnCreated(IThreading threading)
void IThreadingExtension.OnCreated(IThreading threading)
=> Trace(nameof(IThreadingExtension));
void IThreadingExtension.OnReleased()
void IThreadingExtension.OnReleased()
=> Trace(nameof(IThreadingExtension));

void IThreadingExtension.OnUpdate(float realTimeDelta, float simulationTimeDelta)
{
Simulation.OnUpdate(realTimeDelta, simulationTimeDelta);
Expand Down
63 changes: 48 additions & 15 deletions src/ToggleTrafficLights/ToggleTrafficLights.csproj
Original file line number Diff line number Diff line change
@@ -1,48 +1,81 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<!-- dotnet cli msbuild can't compile to net35 and lower -> use separately installed net35 components -->
<!-- https://github.com/Microsoft/msbuild/issues/1333#issuecomment-296346352 -->
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35'">C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
<LangVersion>7</LangVersion>
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<RootNamespace>Craxy.CitiesSkylines.ToggleTrafficLights</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup>
<Version>0.12.0</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>$(Version)</FileVersion>
<Product>Toggle Traffic Lights</Product>
<Name>Toggle Traffic Lights</Name>
<Description>Mod for Cities:Skylines. Tool to remove or add traffic lights at intersections.</Description>
<Authors>Craxy</Authors>
<Copyright>Copyright © Craxy 2015 - 2017</Copyright>
<RepositoryUrl>https://github.com/Craxy/ToggleTrafficLights/</RepositoryUrl>

<!-- If true: execute Cities.exe after build. For single build: dotnet build /p:StartCS=true -->
<StartCS>false</StartCS>
<!-- Starts CS via steam. $(SteamExe) must be specified! -->
<!-- Launching CS without steam is a bit clunky: Cities.exe starts, exits and starts again with steam. So for CS there's no reason to not use $(UseSteam). -->
<UseSteam>true</UseSteam>
</PropertyGroup>

<PropertyGroup>
<!-- Different on each system -->
<CitiesSkylinesPath>D:\Games\Steam\steamapps\common\Cities_Skylines</CitiesSkylinesPath>
<SteamExe>D:\Games\Steam\Steam.exe</SteamExe>
</PropertyGroup>

<PropertyGroup>
<CitiesSkylinesSteamId>255710</CitiesSkylinesSteamId>
</PropertyGroup>

<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\libs\Assembly-CSharp.dll</HintPath>
<Reference Include="Assembly-CSharp">
<HintPath>$(CitiesSkylinesPath)\Cities_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="ColossalManaged, Version=0.3.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\libs\ColossalManaged.dll</HintPath>
<Reference Include="ColossalManaged">
<HintPath>$(CitiesSkylinesPath)\Cities_Data\Managed\ColossalManaged.dll</HintPath>
</Reference>
<Reference Include="ICities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\libs\ICities.dll</HintPath>
<Reference Include="ICities">
<HintPath>$(CitiesSkylinesPath)\Cities_Data\Managed\ICities.dll</HintPath>
</Reference>
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\libs\UnityEngine.dll</HintPath>
<Reference Include="UnityEngine">
<HintPath>$(CitiesSkylinesPath)\Cities_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\libs\UnityEngine.UI.dll</HintPath>
<Reference Include="UnityEngine.UI">
<HintPath>$(CitiesSkylinesPath)\Cities_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Assets\icons.png" />
<None Include="Assets\orig\*" />
</ItemGroup>

<PropertyGroup>
<!-- $(ProjectName) isn't available when $(ModDir) is set -> add $(ProjectName) in Target -->
<ModDir>$(LOCALAPPDATA)\Colossal Order\Cities_Skylines\Addons\Mods</ModDir>
<AssemblyTitle>$(Name)</AssemblyTitle>
<Title>$(Name)</Title>
<Product>$(Name)</Product>
</PropertyGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<RemoveDir Directories="$(LOCALAPPDATA)\Colossal Order\Cities_Skylines\Addons\Mods\$(ProjectName)" />
<MakeDir Directories="$(LOCALAPPDATA)\Colossal Order\Cities_Skylines\Addons\Mods\$(ProjectName)" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(LOCALAPPDATA)\Colossal Order\Cities_Skylines\Addons\Mods\$(ProjectName)" />
<RemoveDir Directories="$(ModDir)\$(ProjectName)" />
<MakeDir Directories="$(ModDir)\$(ProjectName)" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(ModDir)\$(ProjectName)" />
</Target>
<Target Name="StartCitiesSkylines" AfterTargets="PostBuild" Condition="'$(StartCS)' == 'true'">
<Exec Condition="'$(UseSteam)' != 'true'" Command='"$(CitiesSkylinesPath)/Cities"' />
<Exec Condition="'$(UseSteam)' == 'true'" Command='"$(SteamExe)" -applaunch $(CitiesSkylinesSteamId)' />
</Target>
</Project>

0 comments on commit 716c689

Please sign in to comment.