mirror of
https://github.com/rmroc451/TweaksAndThings.git
synced 2025-12-17 09:49:39 -06:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a9359ec7d | |||
| 9d9cc96283 | |||
| d7b846a8b2 | |||
| 9cf5998a13 | |||
| ffe6d344d7 | |||
| 7a21c6472e | |||
| a9e6580258 | |||
| b12f3b07c4 | |||
| 371cfc41c8 | |||
| 180b63a41d |
@@ -12,7 +12,7 @@
|
|||||||
<PropertyGroup Condition="'$(AssemblyVersion)' == '' OR '$(MajorVersion)' != '' OR '$(MinorVersion)' != ''">
|
<PropertyGroup Condition="'$(AssemblyVersion)' == '' OR '$(MajorVersion)' != '' OR '$(MinorVersion)' != ''">
|
||||||
<MajorVersion Condition="'$(MajorVersion)' == ''">0</MajorVersion>
|
<MajorVersion Condition="'$(MajorVersion)' == ''">0</MajorVersion>
|
||||||
<MinorVersion Condition="'$(MinorVersion)' == ''">1</MinorVersion>
|
<MinorVersion Condition="'$(MinorVersion)' == ''">1</MinorVersion>
|
||||||
<PatchVersion Condition="'$(PatchVersion)' == ''">1</PatchVersion>
|
<PatchVersion Condition="'$(PatchVersion)' == ''">2</PatchVersion>
|
||||||
<AssemblyVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</AssemblyVersion>
|
<AssemblyVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</AssemblyVersion>
|
||||||
<FileVersion>$(AssemblyVersion)</FileVersion>
|
<FileVersion>$(AssemblyVersion)</FileVersion>
|
||||||
<ProductVersion>$(AssemblyVersion)</ProductVersion>
|
<ProductVersion>$(AssemblyVersion)</ProductVersion>
|
||||||
|
|||||||
23
README.md
23
README.md
@@ -46,27 +46,4 @@ Yes, these are client side mods. Host doesn't need to have them.
|
|||||||
### What version of Railroader does this mod work with?
|
### What version of Railroader does this mod work with?
|
||||||
2024.4.4
|
2024.4.4
|
||||||
|
|
||||||
### RMROC451 TaDo
|
|
||||||
- 
|
|
||||||
- [ ] WebhookNotifier
|
|
||||||
- [X] Move base webclient calling to new WebhookNotifier
|
|
||||||
- [X] Extend WebhookNotifier in DiscordNotifier, to do formating of payload only.
|
|
||||||
- [X] Add Settings UI Elements for webhook url
|
|
||||||
- [ ] create thread per host || save game name || nearest city || locomotive??
|
|
||||||
- [X] store in a settings file per host & save game name?
|
|
||||||
- [ ] inspector button(s)
|
|
||||||
- [X] auto connect glad hands/angle cocks
|
|
||||||
- [X] release/set car brake?
|
|
||||||
- [ ] Cost Ideas
|
|
||||||
- [ ] $$$ based on usage per day? or flat $5 per use?
|
|
||||||
- [ ] Caboose only?
|
|
||||||
- [ ] detect car having a nearby caboose to use? `UpdateCarsNearbyPlayer` but for car.
|
|
||||||
- [ ] add crew to caboose (similar to engine service), $25/day to fill up, must have crew to use and caboose near cars.
|
|
||||||
- [ ] crew number modifier for how many cars away from caboose it can effectively work?
|
|
||||||
- [ ] crew need to refill at a station?
|
|
||||||
- 
|
|
||||||
- [ ] Camera offset to coupler
|
|
||||||
- [ ] shift + 9/0
|
|
||||||
- [ ] finance exporter/discord report at end of day for Game.State.Ledger
|
|
||||||
|
|
||||||
*Special thanks and credit to Zamu for creating Railloader and for help with making the mod a bit more robust.*
|
*Special thanks and credit to Zamu for creating Railloader and for help with making the mod a bit more robust.*
|
||||||
|
|||||||
@@ -1,27 +1,16 @@
|
|||||||
using GalaSoft.MvvmLight.Messaging;
|
using Game.Messages;
|
||||||
using Game;
|
|
||||||
using Game.Events;
|
|
||||||
using Game.Messages;
|
|
||||||
using Game.State;
|
using Game.State;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using KeyValue.Runtime;
|
using KeyValue.Runtime;
|
||||||
using Network;
|
|
||||||
using Network.Messages;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Railloader;
|
using Railloader;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Remoting.Messaging;
|
|
||||||
using TweaksAndThings.Enums;
|
using TweaksAndThings.Enums;
|
||||||
using UI.Builder;
|
using UI.Builder;
|
||||||
using UI.CarInspector;
|
using UI.CarInspector;
|
||||||
using WorldStreamer2;
|
|
||||||
using static Model.Car;
|
using static Model.Car;
|
||||||
using static Unity.IO.LowLevel.Unsafe.AsyncReadManagerMetrics;
|
|
||||||
|
|
||||||
namespace TweaksAndThings.Patches;
|
namespace TweaksAndThings.Patches;
|
||||||
|
|
||||||
@@ -44,10 +33,11 @@ public class CarInspector_PopulateCarPanel_Patch
|
|||||||
TweaksAndThings tweaksAndThings = SingletonPluginBase<TweaksAndThings>.Shared;
|
TweaksAndThings tweaksAndThings = SingletonPluginBase<TweaksAndThings>.Shared;
|
||||||
if (!tweaksAndThings.IsEnabled) return true;
|
if (!tweaksAndThings.IsEnabled) return true;
|
||||||
|
|
||||||
|
var consist = __instance._car.EnumerateCoupled(LogicalEnd.A);
|
||||||
|
builder = AddCarConsistRebuildObservers(builder, consist);
|
||||||
|
|
||||||
builder.HStack(delegate (UIPanelBuilder hstack)
|
builder.HStack(delegate (UIPanelBuilder hstack)
|
||||||
{
|
{
|
||||||
var consist = __instance._car.EnumerateCoupled(LogicalEnd.A);
|
|
||||||
|
|
||||||
var buttonName = $"{(consist.Any(c => c.HandbrakeApplied()) ? "Release " : "Set ")} {TextSprites.HandbrakeWheel}";
|
var buttonName = $"{(consist.Any(c => c.HandbrakeApplied()) ? "Release " : "Set ")} {TextSprites.HandbrakeWheel}";
|
||||||
hstack.AddButtonCompact(buttonName, delegate
|
hstack.AddButtonCompact(buttonName, delegate
|
||||||
{
|
{
|
||||||
@@ -63,12 +53,43 @@ public class CarInspector_PopulateCarPanel_Patch
|
|||||||
hstack.Rebuild();
|
hstack.Rebuild();
|
||||||
}).Tooltip("Connect Consist Air Lines", "Iterates over each car in this consist and connects gladhands and opens anglecocks.");
|
}).Tooltip("Connect Consist Air Lines", "Iterates over each car in this consist and connects gladhands and opens anglecocks.");
|
||||||
}
|
}
|
||||||
hstack.RebuildOnInterval(1f);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static UIPanelBuilder AddCarConsistRebuildObservers(UIPanelBuilder builder, IEnumerable<Model.Car> consist)
|
||||||
|
{
|
||||||
|
foreach (Model.Car car in consist)
|
||||||
|
{
|
||||||
|
builder = AddObserver(builder, car, PropertyChange.KeyForControl(PropertyChange.Control.Handbrake));
|
||||||
|
foreach (LogicalEnd logicalEnd in ends)
|
||||||
|
{
|
||||||
|
builder = AddObserver(builder, car, KeyValueKeyFor(EndGearStateKey.IsCoupled, car.LogicalToEnd(logicalEnd)));
|
||||||
|
builder = AddObserver(builder, car, KeyValueKeyFor(EndGearStateKey.IsAirConnected, car.LogicalToEnd(logicalEnd)));
|
||||||
|
builder = AddObserver(builder, car, KeyValueKeyFor(EndGearStateKey.Anglecock, car.LogicalToEnd(logicalEnd)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static UIPanelBuilder AddObserver(UIPanelBuilder builder, Model.Car car, string key)
|
||||||
|
{
|
||||||
|
builder.AddObserver(
|
||||||
|
car.KeyValueObject.Observe(
|
||||||
|
key,
|
||||||
|
delegate (Value value)
|
||||||
|
{
|
||||||
|
builder.Rebuild();
|
||||||
|
},
|
||||||
|
false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
public static void MrocConsistHelper(Model.Car car, MrocHelperType mrocHelperType)
|
public static void MrocConsistHelper(Model.Car car, MrocHelperType mrocHelperType)
|
||||||
{
|
{
|
||||||
IEnumerable<Model.Car> consist = car.EnumerateCoupled(LogicalEnd.A);
|
IEnumerable<Model.Car> consist = car.EnumerateCoupled(LogicalEnd.A);
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ public class ExpandedConsole_Add_Patch
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Error(ex, ex.Message);
|
Log.Error(ex, ex.Message);
|
||||||
entry.Text += ex.ToString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,67 +1,58 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Model;
|
using Model;
|
||||||
using Model.AI;
|
|
||||||
using Model.OpsNew;
|
using Model.OpsNew;
|
||||||
using Railloader;
|
using Railloader;
|
||||||
using Serilog;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Track;
|
|
||||||
using TweaksAndThings;
|
|
||||||
using UI;
|
using UI;
|
||||||
using UI.Builder;
|
|
||||||
using UI.CarInspector;
|
|
||||||
using UI.Tags;
|
using UI.Tags;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using static Model.Car;
|
|
||||||
using tat = TweaksAndThings.TweaksAndThings;
|
|
||||||
|
|
||||||
namespace TweaksAndThings.Patches;
|
namespace TweaksAndThings.Patches;
|
||||||
|
|
||||||
[HarmonyPatch(typeof(TagController))]
|
[HarmonyPatch(typeof(TagController))]
|
||||||
[HarmonyPatch(nameof(TagController.UpdateTag), typeof(Car), typeof(TagCallout), typeof(OpsController))]
|
[HarmonyPatch(nameof(TagController.UpdateTag), typeof(Car), typeof(TagCallout), typeof(OpsController))]
|
||||||
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
[HarmonyPatchCategory("RMROC451TweaksAndThings")]
|
||||||
public class TagConroller_UpdateTag_Patch
|
public class TagController_UpdateTag_Patch
|
||||||
{
|
{
|
||||||
|
private const string tagTitleAndIconDelimeter = "\n<width=100%><align=\"right\">";
|
||||||
|
private const string tagTitleFormat = "<align=left><margin-right={0}.5em>{1}</margin><line-height=0>";
|
||||||
|
|
||||||
private static void Postfix(Car car, TagCallout tagCallout)
|
private static void Postfix(Car car, TagCallout tagCallout)
|
||||||
{
|
{
|
||||||
TagController tagController = UnityEngine.Object.FindObjectOfType<TagController>();
|
TagController tagController = UnityEngine.Object.FindObjectOfType<TagController>();
|
||||||
TweaksAndThings tweaksAndThings = SingletonPluginBase<TweaksAndThings>.Shared;
|
TweaksAndThings tweaksAndThings = SingletonPluginBase<TweaksAndThings>.Shared;
|
||||||
tagCallout.callout.Title = $"<align=left>{car.DisplayName}<line-height=0>";
|
|
||||||
|
|
||||||
if (!tweaksAndThings.IsEnabled || !tweaksAndThings.settings.HandBrakeAndAirTagModifiers)
|
if (!tweaksAndThings.IsEnabled || !tweaksAndThings.settings.HandBrakeAndAirTagModifiers)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProceedWithPostFix(car, tagCallout, tagController);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ProceedWithPostFix(Car car, TagCallout tagCallout, TagController tagController)
|
||||||
|
{
|
||||||
|
bool isAltDownWithCarIssue = GameInput.IsAltDown && car.CarOrEndGearIssue();
|
||||||
|
tagCallout.callout.Title = string.Format(tagTitleFormat, "{0}", car.DisplayName);
|
||||||
tagCallout.gameObject.SetActive(
|
tagCallout.gameObject.SetActive(
|
||||||
tagCallout.gameObject.activeSelf &&
|
tagCallout.gameObject.activeSelf &&
|
||||||
(!GameInput.IsShiftDown || (GameInput.IsShiftDown && car.CarOrEndGearIssue()))
|
(!GameInput.IsAltDown || isAltDownWithCarIssue)
|
||||||
);
|
);
|
||||||
if (tagCallout.gameObject.activeSelf && GameInput.IsShiftDown && car.CarOrEndGearIssue()) {
|
|
||||||
|
|
||||||
|
if (tagCallout.gameObject.activeSelf && isAltDownWithCarIssue)
|
||||||
|
{
|
||||||
tagController.ApplyImageColor(tagCallout, Color.black);
|
tagController.ApplyImageColor(tagCallout, Color.black);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (car.CarAndEndGearIssue())
|
tagCallout.callout.Title =
|
||||||
{
|
(car.CarAndEndGearIssue(), car.EndAirSystemIssue(), car.HandbrakeApplied()) switch
|
||||||
tagCallout.callout.Title =
|
{
|
||||||
$"{tagCallout.callout.Title}\n<align=\"right\">{TextSprites.CycleWaybills}{TextSprites.HandbrakeWheel}";
|
(true, _, _) => $"{tagCallout.callout.Title}{tagTitleAndIconDelimeter}{TextSprites.CycleWaybills}{TextSprites.HandbrakeWheel}".Replace("{0}", "2"),
|
||||||
}
|
(_, true, _) => $"{tagCallout.callout.Title}{tagTitleAndIconDelimeter}{TextSprites.CycleWaybills}".Replace("{0}", "1"),
|
||||||
else if (car.EndAirSystemIssue())
|
(_, _, true) => $"{tagCallout.callout.Title}{tagTitleAndIconDelimeter}{TextSprites.HandbrakeWheel}".Replace("{0}", "1"),
|
||||||
tagCallout.callout.Title =
|
_ => car.DisplayName
|
||||||
$"{tagCallout.callout.Title}\n<align=\"right\">{TextSprites.CycleWaybills}";
|
};
|
||||||
else if (car.HandbrakeApplied())
|
|
||||||
tagCallout.callout.Title =
|
|
||||||
$"{tagCallout.callout.Title}\n<align=\"right\">{TextSprites.HandbrakeWheel}";
|
|
||||||
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +71,7 @@ public static class ModelCarExtensions
|
|||||||
|
|
||||||
public static bool CarOrEndGearIssue(this Model.Car car) =>
|
public static bool CarOrEndGearIssue(this Model.Car car) =>
|
||||||
car.EndAirSystemIssue() || car.HandbrakeApplied();
|
car.EndAirSystemIssue() || car.HandbrakeApplied();
|
||||||
|
|
||||||
public static bool CarAndEndGearIssue(this Model.Car car) =>
|
public static bool CarAndEndGearIssue(this Model.Car car) =>
|
||||||
car.EndAirSystemIssue() && car.HandbrakeApplied();
|
car.EndAirSystemIssue() && car.HandbrakeApplied();
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
<GameAssembly Include="Definition" />
|
<GameAssembly Include="Definition" />
|
||||||
|
|
||||||
<GameAssembly Include="UnityEngine.CoreModule" />
|
<GameAssembly Include="UnityEngine.CoreModule" />
|
||||||
|
<GameAssembly Include="UnityEngine.UI" />
|
||||||
|
<GameAssembly Include="Unity.TextMeshPro" />
|
||||||
|
|
||||||
<GameAssembly Include="System.Net.Http" />
|
<GameAssembly Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -27,10 +29,4 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Publicize Include="Assembly-CSharp" />
|
<Publicize Include="Assembly-CSharp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="ForYourConvenience">
|
|
||||||
<HintPath>D:\SteamLibrary\steamapps\common\Railroader\Mods\ForYourConvenience\ForYourConvenience.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ public class Settings
|
|||||||
{
|
{
|
||||||
|
|
||||||
public Settings()
|
public Settings()
|
||||||
{}
|
{
|
||||||
|
WebhookSettingsList = new[] { new WebhookSettings() }.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
public Settings(
|
public Settings(
|
||||||
WebhookSettings webhookSettings,
|
|
||||||
List<WebhookSettings> webhookSettingsList,
|
List<WebhookSettings> webhookSettingsList,
|
||||||
bool handBrakeAndAirTagModifiers
|
bool handBrakeAndAirTagModifiers
|
||||||
)
|
)
|
||||||
@@ -29,7 +30,11 @@ public class Settings
|
|||||||
|
|
||||||
internal void AddAnotherRow()
|
internal void AddAnotherRow()
|
||||||
{
|
{
|
||||||
//if (!string.IsNullOrEmpty(WebhookSettingsList.Last().WebhookUrl)) WebhookSettingsList.Add(new());
|
if (!string.IsNullOrEmpty(WebhookSettingsList.Last().WebhookUrl))
|
||||||
|
{
|
||||||
|
WebhookSettingsList.Add(new());
|
||||||
|
Log.Information($"Adding another {nameof(WebhookSettings)} list entry, last one was filled in");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
using GalaSoft.MvvmLight.Messaging;
|
using GalaSoft.MvvmLight.Messaging;
|
||||||
using Game.Messages;
|
|
||||||
using Game.State;
|
using Game.State;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Railloader;
|
using Railloader;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Debugging;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using TweaksAndThings.Commands;
|
|
||||||
using UI.Builder;
|
using UI.Builder;
|
||||||
using UI.CarInspector;
|
|
||||||
|
|
||||||
namespace TweaksAndThings
|
namespace TweaksAndThings
|
||||||
{
|
{
|
||||||
@@ -48,6 +43,11 @@ namespace TweaksAndThings
|
|||||||
//moddingContext.RegisterConsoleCommand(new EchoCommand());
|
//moddingContext.RegisterConsoleCommand(new EchoCommand());
|
||||||
|
|
||||||
settings = moddingContext.LoadSettingsData<Settings>(self.Id);
|
settings = moddingContext.LoadSettingsData<Settings>(self.Id);
|
||||||
|
if (settings.WebhookSettingsList?.Any() ?? false)
|
||||||
|
{
|
||||||
|
settings.WebhookSettingsList = new[] { new WebhookSettings() }.ToList();
|
||||||
|
this.moddingContext.SaveSettingsData(this.modDefinition.Id, settings ?? new());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnEnable()
|
public override void OnEnable()
|
||||||
@@ -94,7 +94,7 @@ namespace TweaksAndThings
|
|||||||
builder.Rebuild();
|
builder.Rebuild();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
).Tooltip("Enable Tag Updates", $"Will add {TextSprites.CycleWaybills} to the car tag title having Air System issues. Also prepends {TextSprites.HandbrakeWheel} if there is a handbrake set.\n\nHolding Shift while tags are displayed only shows tag titles that have issues.");
|
).Tooltip("Enable Tag Updates", $"Will add {TextSprites.CycleWaybills} to the car tag title having Air System issues. Also prepends {TextSprites.HandbrakeWheel} if there is a handbrake set.\n\nHolding Left Alt while tags are displayed only shows tag titles that have issues.");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user