Skip to content

Commit

Permalink
Introduce defines
Browse files Browse the repository at this point in the history
  • Loading branch information
sailro committed Feb 2, 2025
1 parent 7017b2a commit 77e9c61
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 9 deletions.
4 changes: 2 additions & 2 deletions BepInExPlugin/BepInExPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
Expand All @@ -42,7 +42,7 @@
<Reference Include="System.Core" />
<Reference Include="netstandard">
<HintPath>$(EFTManagedPath)\netstandard.dll</HintPath>
</Reference>
</Reference>
<!-- Unity -->
<Reference Include="UnityEngine">
<HintPath>$(EFTManagedPath)\UnityEngine.dll</HintPath>
Expand Down
21 changes: 18 additions & 3 deletions Features/Feature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,31 @@ protected void AddConsoleLog(string log)
ConsoleScreen.Log(log);
}

public override ETranslateResult TranslateCommand(ECommand command)
#if EFT_LIVE
protected
#else
public
#endif
override ETranslateResult TranslateCommand(ECommand command)
{
return ETranslateResult.Ignore;
}

public override void TranslateAxes(ref float[] axes)
#if EFT_LIVE
protected
#else
public
#endif
override void TranslateAxes(ref float[] axes)
{
}

public override ECursorResult ShouldLockCursor()
#if EFT_LIVE
protected
#else
public
#endif
override ECursorResult ShouldLockCursor()
{
return ECursorResult.Ignore;
}
Expand Down
21 changes: 18 additions & 3 deletions Features/FeatureRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,12 @@ private object RenderBooleanProperty(object currentValue, GUILayoutOption option
return newValue;
}

public override ETranslateResult TranslateCommand(ECommand command)
#if EFT_LIVE
protected
#else
public
#endif
override ETranslateResult TranslateCommand(ECommand command)
{
return command switch
{
Expand All @@ -407,14 +412,24 @@ public override ETranslateResult TranslateCommand(ECommand command)
};
}

public override void TranslateAxes(ref float[] axes)
#if EFT_LIVE
protected
#else
public
#endif
override void TranslateAxes(ref float[] axes)
{
// this will disable the axes for player movement
if (Enabled)
axes = null!;
}

public override ECursorResult ShouldLockCursor()
#if EFT_LIVE
protected
#else
public
#endif
override ECursorResult ShouldLockCursor()
{
return Enabled ? ECursorResult.ShowCursor : ECursorResult.Ignore;
}
Expand Down
2 changes: 2 additions & 0 deletions Features/TemplateHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ internal class TemplateHelper

private static void UpdateTemplates()
{
#if !EFT_LIVE
if (!Singleton<ItemFactoryClass>.Instantiated)
return;

Expand All @@ -30,6 +31,7 @@ private static void UpdateTemplates()
{
_templates.Add(kv.Key.ToString(), kv.Value);
}
#endif
}

internal static ItemTemplate[] FindTemplates(string searchShortNameOrTemplateId)
Expand Down
1 change: 1 addition & 0 deletions Installer/CompilationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal class CompilationContext(Installation installation, string projectTitle
public string Project { get; set; } = project;
public string Branch { get; set; } = DefaultBranch;
public string[] Exclude { get; set; } = [];
public string[] Defines { get; set; } = [];
public ZipArchive? Archive { get; set; }
public bool IsFatalFailure { get; set; } = false;
public string Language { get; set; } = "";
Expand Down
1 change: 1 addition & 0 deletions Installer/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public Compiler(ZipArchive projectArchive, CompilationContext context)
ProjectArchive = projectArchive;
Installation = context.Installation;
Exclude = context.Exclude;
Defines = context.Defines;
ProjectContent = string.Empty;

var entry = projectArchive.Entries.FirstOrDefault(e => e.Name == context.Project) ?? throw new ArgumentException($"Project {context.Project} not found!");
Expand Down
1 change: 1 addition & 0 deletions Installer/InstallCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ private static async Task<CompilationResult> BuildTrainerAsync(Settings settings
{
Exclude = [.. settings.DisabledFeatures!, .. settings.DisabledCommands!],
Branch = GetInitialBranch(settings),
Defines = installation.UsingSptAki ? [] : ["EFT_LIVE"],
Language = settings.Language
};

Expand Down
2 changes: 1 addition & 1 deletion NLog.EFT.Trainer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
Expand Down

0 comments on commit 77e9c61

Please sign in to comment.