Compare commits

...

14 Commits

Author SHA1 Message Date
7a9359ec7d Merge pull request #11 from rmroc451/3-tags-now-overlap-with-icons-when-titles-are-long
fix #3 tags now overlap with icons when titles are long
2024-06-18 00:27:53 -05:00
9d9cc96283 resolve #3 overlapping callout titles with the right floating icons. Switching from SHIFT to LEFT ALT key for hiding car callouts that have no issues. 2024-06-18 00:26:20 -05:00
d7b846a8b2 Merge remote-tracking branch 'origin/main' into 3-tags-now-overlap-with-icons-when-titles-are-long 2024-06-17 23:06:46 -05:00
9cf5998a13 Merge pull request #10 from rmroc451/2-investigate-settings-instantiation-issues
fix #2
2024-06-17 23:01:09 -05:00
ffe6d344d7 Merge pull request #9 from rmroc451/1-hstackrebuildoninterval-misses-button-clicks
fix #1
2024-06-17 22:57:37 -05:00
7a21c6472e removed hStack.RebuildOnInterval in favor of builder.AddObserver for each car in inspector car's consist. 2024-06-17 22:55:51 -05:00
a9e6580258 work in progress attempts to resolve text overlapping on car tag titles. 2024-06-17 20:54:05 -05:00
b12f3b07c4 initial fixes for settings instantiation issue 2024-06-17 20:52:31 -05:00
371cfc41c8 #2 remove ex.tostring from appending to entry.text and spamming console. 2024-06-17 18:50:01 -05:00
180b63a41d Update README.md
moved todo list to issues labeled as enhancements.
2024-06-17 10:19:26 -05:00
b3546f433d Patch inspector button recalc based on consist brake || air system changes 2024-06-16 22:13:03 -05:00
ced72acf7c Update README.md 2024-06-16 16:29:54 -05:00
3d1fa908b9 Delete LICENSE.txt 2024-06-16 16:28:50 -05:00
1de82c130b super awkward grammar issue :D 2024-06-16 15:27:25 -05:00
10 changed files with 102 additions and 118 deletions

View File

@@ -12,7 +12,7 @@
<PropertyGroup Condition="'$(AssemblyVersion)' == '' OR '$(MajorVersion)' != '' OR '$(MinorVersion)' != ''">
<MajorVersion Condition="'$(MajorVersion)' == ''">0</MajorVersion>
<MinorVersion Condition="'$(MinorVersion)' == ''">1</MinorVersion>
<PatchVersion Condition="'$(PatchVersion)' == ''">0</PatchVersion>
<PatchVersion Condition="'$(PatchVersion)' == ''">2</PatchVersion>
<AssemblyVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<ProductVersion>$(AssemblyVersion)</ProductVersion>

View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) [year] [fullname]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,5 +1,5 @@
[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/) [![Buymeacoffee](https://badgen.net/badge/icon/buymeacoffee?icon=buymeacoffee&label)](https://ko-fi.com/rmroc451)
# RMROC451's Tweaks and Thinks
# RMROC451's Tweaks and Things
Please Read this **ENTIRE** README before continuing.
This is a mod for Railroader which is available on Steam.
@@ -17,7 +17,7 @@ This mod requires Railloader by Zamu.
2. Drag the zip file onto Railloader.exe and have Railloader install the mod.
* as with option 1, this will put a `RMROC451.TweaksAndThings` folder into the Mods folder created in step 1
* If you DO NOT have the `RMROC451.TweaksAndThings` folder in the Mods folder after completing ONE of the above steps, you didn't complete the step successfully.
3. Run the game and enjoy all of you interchange tracks being used.
3. Run the game and enjoy all of the tweaks and things!
## Notes
1. This mod currently supports Railroader verison 2024.4.4. This mod may break in future updates. I will do my best to continue to update this mod.
@@ -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?
2024.4.4
### RMROC451 TaDo
- ![Work In Progress](https://img.shields.io/badge/Status%3F-Work%20In%20Progress-green.svg)
- [ ] 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?
- ![Pending](https://img.shields.io/badge/Status%3F-Pending-yellow.svg)
- [ ] 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.*

View File

@@ -8,6 +8,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
Paths.user = Paths.user
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RMROC451.TweaksAndThings", "TweaksAndThings\RMROC451.TweaksAndThings.csproj", "{59BB5A3F-C26B-4E2D-A657-94C562449365}"

View File

@@ -1,27 +1,16 @@
using GalaSoft.MvvmLight.Messaging;
using Game;
using Game.Events;
using Game.Messages;
using Game.Messages;
using Game.State;
using HarmonyLib;
using KeyValue.Runtime;
using Network;
using Network.Messages;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Railloader;
using Serilog;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using TweaksAndThings.Enums;
using UI.Builder;
using UI.CarInspector;
using WorldStreamer2;
using static Model.Car;
using static Unity.IO.LowLevel.Unsafe.AsyncReadManagerMetrics;
namespace TweaksAndThings.Patches;
@@ -44,17 +33,24 @@ public class CarInspector_PopulateCarPanel_Patch
TweaksAndThings tweaksAndThings = SingletonPluginBase<TweaksAndThings>.Shared;
if (!tweaksAndThings.IsEnabled) return true;
var consist = __instance._car.EnumerateCoupled(LogicalEnd.A);
builder = AddCarConsistRebuildObservers(builder, consist);
builder.HStack(delegate (UIPanelBuilder hstack)
{
hstack.AddButtonCompact("Handbrakes", delegate
var buttonName = $"{(consist.Any(c => c.HandbrakeApplied()) ? "Release " : "Set ")} {TextSprites.HandbrakeWheel}";
hstack.AddButtonCompact(buttonName, delegate
{
MrocConsistHelper(__instance._car, MrocHelperType.Handbrake);
}).Tooltip("Release Consist Handbrakes", "Iterates over each car in this consist and releases handbrakes.");
if (StateManager.IsHost || true)
hstack.Rebuild();
}).Tooltip(buttonName, $"Iterates over cars in this consist and {(consist.Any(c => c.HandbrakeApplied()) ? "releases" : "sets")} {TextSprites.HandbrakeWheel}.");
if (consist.Any(c => c.EndAirSystemIssue()))
{
hstack.AddButtonCompact("Air Lines", delegate
hstack.AddButtonCompact("Connect Air Lines", delegate
{
MrocConsistHelper(__instance._car, MrocHelperType.GladhandAndAnglecock);
hstack.Rebuild();
}).Tooltip("Connect Consist Air Lines", "Iterates over each car in this consist and connects gladhands and opens anglecocks.");
}
});
@@ -62,6 +58,38 @@ public class CarInspector_PopulateCarPanel_Patch
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)
{
IEnumerable<Model.Car> consist = car.EnumerateCoupled(LogicalEnd.A);
@@ -70,7 +98,14 @@ public class CarInspector_PopulateCarPanel_Patch
switch (mrocHelperType)
{
case MrocHelperType.Handbrake:
consist.Do(c => c.SetHandbrake(false));
if (consist.Any(c => c.HandbrakeApplied()))
{
consist.Do(c => c.SetHandbrake(false));
} else
{
TrainController tc = UnityEngine.Object.FindObjectOfType<TrainController>();
tc.ApplyHandbrakesAsNeeded(consist.ToList(), PlaceTrainHandbrakes.Automatic);
}
break;
case MrocHelperType.GladhandAndAnglecock:

View File

@@ -102,7 +102,6 @@ public class ExpandedConsole_Add_Patch
catch (Exception ex)
{
Log.Error(ex, ex.Message);
entry.Text += ex.ToString();
}
}

View File

@@ -1,67 +1,58 @@
using HarmonyLib;
using JetBrains.Annotations;
using Model;
using Model.AI;
using Model.OpsNew;
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.Builder;
using UI.CarInspector;
using UI.Tags;
using UnityEngine;
using static Model.Car;
using tat = TweaksAndThings.TweaksAndThings;
namespace TweaksAndThings.Patches;
[HarmonyPatch(typeof(TagController))]
[HarmonyPatch(nameof(TagController.UpdateTag), typeof(Car), typeof(TagCallout), typeof(OpsController))]
[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)
{
TagController tagController = UnityEngine.Object.FindObjectOfType<TagController>();
TweaksAndThings tweaksAndThings = SingletonPluginBase<TweaksAndThings>.Shared;
tagCallout.callout.Title = $"<align=left>{car.DisplayName}<line-height=0>";
if (!tweaksAndThings.IsEnabled || !tweaksAndThings.settings.HandBrakeAndAirTagModifiers)
{
return;
}
tagCallout.gameObject.SetActive(
tagCallout.gameObject.activeSelf &&
(!GameInput.IsShiftDown || (GameInput.IsShiftDown && car.CarOrEndGearIssue()))
);
if (tagCallout.gameObject.activeSelf && GameInput.IsShiftDown && car.CarOrEndGearIssue()) {
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.activeSelf &&
(!GameInput.IsAltDown || isAltDownWithCarIssue)
);
if (tagCallout.gameObject.activeSelf && isAltDownWithCarIssue)
{
tagController.ApplyImageColor(tagCallout, Color.black);
}
if (car.CarAndEndGearIssue())
{
tagCallout.callout.Title =
$"{tagCallout.callout.Title}\n<align=\"right\">{TextSprites.CycleWaybills}{TextSprites.HandbrakeWheel}";
}
else if (car.EndAirSystemIssue())
tagCallout.callout.Title =
$"{tagCallout.callout.Title}\n<align=\"right\">{TextSprites.CycleWaybills}";
else if (car.HandbrakeApplied())
tagCallout.callout.Title =
$"{tagCallout.callout.Title}\n<align=\"right\">{TextSprites.HandbrakeWheel}";
return;
tagCallout.callout.Title =
(car.CarAndEndGearIssue(), car.EndAirSystemIssue(), car.HandbrakeApplied()) switch
{
(true, _, _) => $"{tagCallout.callout.Title}{tagTitleAndIconDelimeter}{TextSprites.CycleWaybills}{TextSprites.HandbrakeWheel}".Replace("{0}", "2"),
(_, true, _) => $"{tagCallout.callout.Title}{tagTitleAndIconDelimeter}{TextSprites.CycleWaybills}".Replace("{0}", "1"),
(_, _, true) => $"{tagCallout.callout.Title}{tagTitleAndIconDelimeter}{TextSprites.HandbrakeWheel}".Replace("{0}", "1"),
_ => car.DisplayName
};
}
}
@@ -80,6 +71,7 @@ public static class ModelCarExtensions
public static bool CarOrEndGearIssue(this Model.Car car) =>
car.EndAirSystemIssue() || car.HandbrakeApplied();
public static bool CarAndEndGearIssue(this Model.Car car) =>
car.EndAirSystemIssue() && car.HandbrakeApplied();
}

View File

@@ -13,6 +13,8 @@
<GameAssembly Include="Definition" />
<GameAssembly Include="UnityEngine.CoreModule" />
<GameAssembly Include="UnityEngine.UI" />
<GameAssembly Include="Unity.TextMeshPro" />
<GameAssembly Include="System.Net.Http" />
</ItemGroup>
@@ -27,10 +29,4 @@
<ItemGroup>
<Publicize Include="Assembly-CSharp" />
</ItemGroup>
<ItemGroup>
<Reference Include="ForYourConvenience">
<HintPath>D:\SteamLibrary\steamapps\common\Railroader\Mods\ForYourConvenience\ForYourConvenience.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@@ -12,10 +12,11 @@ public class Settings
{
public Settings()
{}
{
WebhookSettingsList = new[] { new WebhookSettings() }.ToList();
}
public Settings(
WebhookSettings webhookSettings,
public Settings(
List<WebhookSettings> webhookSettingsList,
bool handBrakeAndAirTagModifiers
)
@@ -29,7 +30,11 @@ public class Settings
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");
}
}
}

View File

@@ -1,16 +1,11 @@
using GalaSoft.MvvmLight.Messaging;
using Game.Messages;
using Game.State;
using HarmonyLib;
using Newtonsoft.Json.Linq;
using Railloader;
using Serilog;
using Serilog.Debugging;
using System.Linq;
using System.Net.Http;
using TweaksAndThings.Commands;
using UI.Builder;
using UI.CarInspector;
namespace TweaksAndThings
{
@@ -48,6 +43,11 @@ namespace TweaksAndThings
//moddingContext.RegisterConsoleCommand(new EchoCommand());
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()
@@ -94,7 +94,7 @@ namespace TweaksAndThings
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.");
});
}