mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-04 05:11:50 +01:00
Move rolling stock and physics into the domain
VehicleDatabase becomes VehicleCatalog, Physics becomes VehiclePhysics, and the textures.txt and .fiz parsers move to Infrastructure. GameLibrary replaces the GameData singleton.
This commit is contained in:
@@ -19,14 +19,16 @@ using Avalonia.VisualTree;
|
||||
using StarterNG.Classes;
|
||||
using StarterNG.Domain;
|
||||
using StarterNG.Domain.Sceneries;
|
||||
using StarterNG.Domain.Vehicles;
|
||||
using StarterNG.Application;
|
||||
|
||||
namespace StarterNG.Views;
|
||||
|
||||
public partial class Depot : UserControl
|
||||
{
|
||||
|
||||
private readonly VehicleDatabase _db = GameData.Instance.Vehicles;
|
||||
private readonly List<Scenery> _sceneries = GameData.Instance.Sceneries;
|
||||
private readonly VehicleCatalog _db = AppServices.Current.Library.Vehicles;
|
||||
private readonly List<Scenery> _sceneries = AppServices.Current.Library.Sceneries;
|
||||
|
||||
private readonly VehicleInfo _info;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ using Avalonia.Media.Imaging;
|
||||
using StarterNG.Classes;
|
||||
using StarterNG.Domain;
|
||||
using StarterNG.Infrastructure;
|
||||
using StarterNG.Domain.Vehicles;
|
||||
|
||||
namespace StarterNG.Views;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using Avalonia.Media;
|
||||
using Avalonia.Media.Imaging;
|
||||
|
||||
using StarterNG.Classes;
|
||||
using StarterNG.Application;
|
||||
|
||||
namespace StarterNG.Views;
|
||||
|
||||
@@ -28,7 +29,7 @@ public sealed class MiniTextures
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
return null;
|
||||
if (strict && !VehicleDatabase.HasMini(name))
|
||||
if (strict && !AppServices.Current.MiniTextures.Has(name))
|
||||
return null;
|
||||
|
||||
string key = $"{(strict ? "!" : "")}{name}@{height}";
|
||||
@@ -36,7 +37,7 @@ public sealed class MiniTextures
|
||||
return cached;
|
||||
|
||||
Bitmap? bmp = null;
|
||||
string? path = VehicleDatabase.MiniPath(name);
|
||||
string? path = AppServices.Current.MiniTextures.PathFor(name);
|
||||
if (path != null)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -15,6 +15,7 @@ using Avalonia.Threading;
|
||||
using StarterNG.Classes;
|
||||
using StarterNG.Domain;
|
||||
using StarterNG.Domain.Sceneries;
|
||||
using StarterNG.Domain.Vehicles;
|
||||
|
||||
namespace StarterNG.Views;
|
||||
|
||||
@@ -28,7 +29,7 @@ public sealed class VehicleBrowser
|
||||
private readonly Image miniPreview;
|
||||
private readonly Button addVehicleButton;
|
||||
|
||||
private readonly VehicleDatabase _db;
|
||||
private readonly VehicleCatalog _db;
|
||||
private readonly MiniTextures _minis;
|
||||
private readonly Action _openTextureBase;
|
||||
|
||||
@@ -57,7 +58,7 @@ public sealed class VehicleBrowser
|
||||
public VehicleBrowser(
|
||||
ComboBox categoryCombo, ComboBox classCombo, ListBox vehicleListBox, TextBox searchBox,
|
||||
CheckBox hideArchivalCheck, Image miniPreview, Button addVehicleButton,
|
||||
VehicleDatabase db, MiniTextures minis, Action openTextureBase)
|
||||
VehicleCatalog db, MiniTextures minis, Action openTextureBase)
|
||||
{
|
||||
this.categoryCombo = categoryCombo;
|
||||
this.classCombo = classCombo;
|
||||
|
||||
@@ -12,6 +12,7 @@ using Material.Icons.Avalonia;
|
||||
|
||||
using StarterNG.Classes;
|
||||
using StarterNG.Domain;
|
||||
using StarterNG.Domain.Vehicles;
|
||||
|
||||
namespace StarterNG.Views;
|
||||
|
||||
@@ -19,7 +20,7 @@ public sealed class VehicleCards
|
||||
{
|
||||
private readonly Panel consistStack;
|
||||
|
||||
private readonly VehicleDatabase _db;
|
||||
private readonly VehicleCatalog _db;
|
||||
private readonly Consist _consist;
|
||||
private readonly Cargo _cargo;
|
||||
private readonly MiniTextures _minis;
|
||||
@@ -36,7 +37,7 @@ public sealed class VehicleCards
|
||||
|
||||
public Dynamic? PressedCar { get; set; }
|
||||
|
||||
public VehicleCards(Panel consistStack, VehicleDatabase db, Consist consist,
|
||||
public VehicleCards(Panel consistStack, VehicleCatalog db, Consist consist,
|
||||
Cargo cargo, MiniTextures minis, Cursor hand,
|
||||
Action redraw, Action refreshDetails, Action<Dynamic> selectInBrowser,
|
||||
Action<int, PointerPressedEventArgs> armDrag)
|
||||
|
||||
@@ -12,6 +12,7 @@ using Avalonia.Media;
|
||||
using StarterNG.Classes;
|
||||
using StarterNG.Controls;
|
||||
using StarterNG.Domain;
|
||||
using StarterNG.Domain.Vehicles;
|
||||
|
||||
namespace StarterNG.Views;
|
||||
|
||||
@@ -26,7 +27,7 @@ public sealed class VehicleDetails
|
||||
private readonly StackPanel damagePanel;
|
||||
private readonly Button removeVehicleButton;
|
||||
|
||||
private readonly VehicleDatabase _db;
|
||||
private readonly VehicleCatalog _db;
|
||||
private readonly VehicleInfo _info;
|
||||
private readonly Consist _consist;
|
||||
private readonly Cargo _cargo;
|
||||
@@ -41,7 +42,7 @@ public sealed class VehicleDetails
|
||||
Panel couplerActions,
|
||||
StackPanel brakesPanel, StackPanel loadsPanel, StackPanel damagePanel,
|
||||
Button removeVehicleButton,
|
||||
VehicleDatabase db, VehicleInfo info, Consist consist, Cargo cargo, Cursor hand,
|
||||
VehicleCatalog db, VehicleInfo info, Consist consist, Cargo cargo, Cursor hand,
|
||||
Action redraw, Action refreshChrome, Action<VehicleTexture, StackPanel> showTextureInfo)
|
||||
{
|
||||
this.generalPanel = generalPanel;
|
||||
|
||||
@@ -9,6 +9,8 @@ using Avalonia.Media;
|
||||
using StarterNG.Classes;
|
||||
using StarterNG.Domain;
|
||||
using StarterNG.Infrastructure;
|
||||
using StarterNG.Domain.Vehicles;
|
||||
using StarterNG.Application;
|
||||
|
||||
namespace StarterNG.Views;
|
||||
|
||||
@@ -19,7 +21,7 @@ public sealed class RulesWindow : Window
|
||||
private readonly WrapPanel _members = new() { Orientation = Orientation.Horizontal };
|
||||
private readonly ComboBox _category = new();
|
||||
private readonly ComboBox _model = new();
|
||||
private readonly VehicleDatabase _db = GameData.Instance.Vehicles;
|
||||
private readonly VehicleCatalog _db = AppServices.Current.Library.Vehicles;
|
||||
|
||||
public RulesWindow()
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ public partial class Scenarios : UserControl
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Sceneries = GameData.Instance.Sceneries;
|
||||
Sceneries = AppServices.Current.Library.Sceneries;
|
||||
|
||||
_loadingFilters = true;
|
||||
archivalSwitch.IsChecked = !StarterNG.Classes.Settings.Instance.ShowArchivalSceneries;
|
||||
@@ -339,7 +339,7 @@ public partial class Scenarios : UserControl
|
||||
var lines = new List<string>();
|
||||
lines.AddRange(scenery.Faults);
|
||||
|
||||
var db = GameData.Instance.Vehicles;
|
||||
var db = AppServices.Current.Library.Vehicles;
|
||||
foreach (var ts in scenery.Trainsets)
|
||||
{
|
||||
if (!ts.Parsed)
|
||||
@@ -423,8 +423,8 @@ public partial class Scenarios : UserControl
|
||||
try
|
||||
{
|
||||
string? selected = AppState.Instance.CurrentScenery?.Path;
|
||||
await Task.Run(() => GameData.Instance.ReloadSceneries());
|
||||
Sceneries = GameData.Instance.Sceneries;
|
||||
await Task.Run(() => AppServices.Current.Library.ReloadSceneries());
|
||||
Sceneries = AppServices.Current.Library.Sceneries;
|
||||
BuildSceneryTree();
|
||||
if (!string.IsNullOrEmpty(selected))
|
||||
{
|
||||
@@ -486,7 +486,7 @@ public partial class Scenarios : UserControl
|
||||
return cached;
|
||||
|
||||
Bitmap? bmp = null;
|
||||
string? path = VehicleDatabase.MiniPath(name);
|
||||
string? path = AppServices.Current.MiniTextures.PathFor(name);
|
||||
if (path != null)
|
||||
{
|
||||
try
|
||||
@@ -888,12 +888,12 @@ public partial class Scenarios : UserControl
|
||||
UpdateTrainStats(trainset);
|
||||
});
|
||||
|
||||
var db = GameData.Instance.Vehicles;
|
||||
var db = AppServices.Current.Library.Vehicles;
|
||||
foreach (var train in trainset.Vehicles)
|
||||
{
|
||||
|
||||
string miniName = db.MiniForSkin(train.SkinFile) ?? train.SkinFile;
|
||||
if (!VehicleDatabase.HasMini(miniName) && VehicleDatabase.HasMini(train.SkinFile))
|
||||
if (!AppServices.Current.MiniTextures.Has(miniName) && AppServices.Current.MiniTextures.Has(train.SkinFile))
|
||||
miniName = train.SkinFile;
|
||||
int thumbH = StarterNG.Classes.Settings.Instance.LargeThumbnails ? 64 : 32;
|
||||
|
||||
@@ -1193,12 +1193,12 @@ public partial class Scenarios : UserControl
|
||||
return;
|
||||
}
|
||||
|
||||
var db = GameData.Instance.Vehicles;
|
||||
var db = AppServices.Current.Library.Vehicles;
|
||||
StarterNG.Infrastructure.StatsBar.Fill(trainStats, TrainsetDisplay.StatsFields(
|
||||
trainset,
|
||||
car => Physics.For(car.DataFolder, db.TextureForSkin(car.SkinFile)?.Model)
|
||||
?? Physics.For(car.DataFolder, car.MmdFile)
|
||||
?? Physics.For(car.DataFolder, car.SkinFile),
|
||||
car => AppServices.Current.Physics.For(car.DataFolder, db.TextureForSkin(car.SkinFile)?.Model)
|
||||
?? AppServices.Current.Physics.For(car.DataFolder, car.MmdFile)
|
||||
?? AppServices.Current.Physics.For(car.DataFolder, car.SkinFile),
|
||||
car => db.TextureForSkin(car.SkinFile)?.ResolvedCategory));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,14 @@ using Avalonia.Input;
|
||||
using Avalonia.Input.Platform;
|
||||
using Avalonia.Interactivity;
|
||||
using StarterNG.Classes;
|
||||
using StarterNG.Domain.Vehicles;
|
||||
using StarterNG.Application;
|
||||
|
||||
namespace StarterNG.Views;
|
||||
|
||||
public partial class TextureBaseWindow : Window
|
||||
{
|
||||
private readonly VehicleDatabase _db = GameData.Instance.Vehicles;
|
||||
private readonly VehicleCatalog _db = AppServices.Current.Library.Vehicles;
|
||||
private readonly List<TextureRow> _all = new();
|
||||
|
||||
public VehicleTexture? Picked { get; private set; }
|
||||
@@ -193,7 +195,7 @@ internal sealed class TextureRow
|
||||
public string Directory { get; }
|
||||
public DateTime? RevisionDate { get; }
|
||||
|
||||
public TextureRow(VehicleTexture t, VehicleDatabase db)
|
||||
public TextureRow(VehicleTexture t, VehicleCatalog db)
|
||||
{
|
||||
Texture = t;
|
||||
Skin = Path.GetFileNameWithoutExtension(t.Skinfile);
|
||||
|
||||
Reference in New Issue
Block a user