forked from FakeFishGames/Barotrauma
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97d53fe
commit ef52691
Showing
93 changed files
with
3,005 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Barotrauma/BarotraumaClient/ClientSource/Characters/Jobs/JobPrefab.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using Microsoft.Xna.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
|
16 changes: 16 additions & 0 deletions
16
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Configuration/DisplayableData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Microsoft.Xna.Framework; | ||
|
||
namespace Barotrauma.LuaCs.Configuration; | ||
|
||
public class DisplayableData : IDisplayableData | ||
{ | ||
public string Name { get; private set; } | ||
public string ModName { get; private set; } | ||
public string DisplayName { get; private set; } | ||
public string DisplayModName { get; private set; } | ||
public string DisplayCategory { get; private set; } | ||
public string Tooltip { get; private set; } | ||
public string ImageIcon { get; private set; } | ||
public Point IconResolution { get; private set; } | ||
public bool ShowWhenNotLoaded { get; private set; } | ||
} |
6 changes: 6 additions & 0 deletions
6
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Configuration/IConfigDisplayDefinitions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using Barotrauma.LuaCs.Configuration; | ||
using Barotrauma.LuaCs.Data; | ||
|
||
namespace Barotrauma.LuaCs.Configuration; | ||
|
||
public partial interface IConfigBase : IDisplayableData, IDisplayableInitialize { } |
66 changes: 66 additions & 0 deletions
66
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Configuration/IDisplayableConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System.Numerics; | ||
using Microsoft.Xna.Framework; | ||
|
||
namespace Barotrauma.LuaCs.Configuration; | ||
|
||
/// <summary> | ||
/// Contains the Display Data for use with Menus. | ||
/// </summary> | ||
public interface IDisplayableData | ||
{ | ||
/// <summary> | ||
/// Internal name of the instance. | ||
/// </summary> | ||
string Name { get; } | ||
/// <summary> | ||
/// Internal mod name of the instance. ContentPackage name will be used by default. | ||
/// </summary> | ||
string ModName { get; } | ||
/// <summary> | ||
/// The name to display in GUIs and Menus. | ||
/// </summary> | ||
string DisplayName { get; } | ||
/// <summary> | ||
/// The mod name to display in GUIs and Menus. | ||
/// </summary> | ||
string DisplayModName { get; } | ||
/// <summary> | ||
/// Category this instance falls under. Used by menus when filtering by category. | ||
/// </summary> | ||
string DisplayCategory { get; } | ||
/// <summary> | ||
/// The tooltip shown on hover. | ||
/// </summary> | ||
string Tooltip { get; } | ||
/// <summary> | ||
/// The fully qualified filepath to the image icon for this config. | ||
/// </summary> | ||
string ImageIcon { get; } | ||
/// <summary> | ||
/// Required if ImageIcon is set. X,Y resolution of the image. | ||
/// </summary> | ||
Point IconResolution { get; } | ||
/// <summary> | ||
/// Whether to show the entry in the menu when not loaded. | ||
/// </summary> | ||
bool ShowWhenNotLoaded { get; } | ||
} | ||
|
||
public interface IDisplayableInitialize | ||
{ | ||
void Initialize(IDisplayableData values); | ||
|
||
// copy this as needed | ||
/*public void Initialize(IDisplayableData values) | ||
{ | ||
this.Name = values.Name; | ||
this.ModName = values.ModName; | ||
this.DisplayName = values.DisplayName; | ||
this.DisplayModName = values.DisplayModName; | ||
this.DisplayCategory = values.DisplayCategory; | ||
this.Tooltip = values.Tooltip; | ||
this.ImageIcon = values.ImageIcon; | ||
this.IconResolution = values.IconResolution; | ||
this.ShowWhenNotLoaded = values.ShowWhenNotLoaded; | ||
}*/ | ||
} |
21 changes: 21 additions & 0 deletions
21
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/DataInterfaceDefinitions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Collections.Immutable; | ||
using System.Globalization; | ||
|
||
namespace Barotrauma.LuaCs.Data; | ||
|
||
public partial record ModConfigInfo : IModConfigInfo | ||
{ | ||
public ImmutableArray<IStylesResourceInfo> StylesResourceInfos { get; init; } | ||
} | ||
|
||
public record StylesResourceInfo : IStylesResourceInfo | ||
{ | ||
public Platform SupportedPlatforms { get; init; } | ||
public Target SupportedTargets { get; init; } | ||
public int LoadPriority { get; init; } | ||
public ImmutableArray<string> FilePaths { get; init; } | ||
public bool Optional { get; init; } | ||
public ImmutableArray<CultureInfo> SupportedCultures { get; init; } | ||
public string InternalName { get; init; } | ||
public ImmutableArray<IPackageDependencyInfo> Dependencies { get; init; } | ||
} |
5 changes: 5 additions & 0 deletions
5
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/IConfigInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using Barotrauma.LuaCs.Configuration; | ||
|
||
namespace Barotrauma.LuaCs.Data; | ||
|
||
public partial interface IConfigInfo : IDisplayableData { } |
15 changes: 15 additions & 0 deletions
15
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/IResourceInfoDeclarations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Collections.Immutable; | ||
|
||
namespace Barotrauma.LuaCs.Data; | ||
|
||
public partial interface IModConfigInfo : IStylesResourcesInfo { } | ||
|
||
public interface IStylesResourceInfo : IResourceInfo, IResourceCultureInfo, ILoadableResourceInfo, IPackageDependenciesInfo { } | ||
|
||
public interface IStylesResourcesInfo | ||
{ | ||
/// <summary> | ||
/// Collection of loadable styles data. | ||
/// </summary> | ||
ImmutableArray<IStylesResourceInfo> StylesResourceInfos { get; } | ||
} |
6 changes: 6 additions & 0 deletions
6
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Data/IStylesInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Barotrauma.LuaCs.Data; | ||
|
||
public interface IStylesInfo | ||
{ | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Services/IClientLoggerService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Barotrauma.LuaCs.Services; | ||
|
||
public interface IClientLoggerService : IService | ||
{ | ||
void AddToGUIUpdateList(); | ||
void ShowErrorOverlay(string message, float time = 5f, float duration = 1.5f); | ||
} |
51 changes: 51 additions & 0 deletions
51
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Services/IStylesService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
namespace Barotrauma.LuaCs.Services; | ||
|
||
// TODO: Rework interface to support resource infos. | ||
/// <summary> | ||
/// Loads XML Style assets from the given content package. | ||
/// </summary> | ||
public interface IStylesService : IService | ||
{ | ||
/// <summary> | ||
/// Tries to load the styles file for the given contentpackage and path into a new UIStylesProcessor instance. | ||
/// </summary> | ||
/// <param name="package"></param> | ||
/// <param name="path"></param> | ||
/// <returns></returns> | ||
bool TryLoadStylesFile(ContentPackage package, ContentPath path); | ||
/// <summary> | ||
/// Unloads all styles assets and UIStyleProcessor instances. | ||
/// </summary> | ||
void UnloadAllStyles(); | ||
|
||
/// <summary> | ||
/// Tries to the get the font asset by xml asset name, returns null on failure. | ||
/// </summary> | ||
/// <param name="fontName">XML Name of the asset.</param> | ||
/// <returns>The asset or null if none are found.</returns> | ||
GUIFont GetFont(string fontName); | ||
/// <summary> | ||
/// Tries to the get the sprite asset by xml asset name, returns null on failure. | ||
/// </summary> | ||
/// <param name="spriteName">XML Name of the asset.</param> | ||
/// <returns>The asset or null if none are found.</returns> | ||
GUISprite GetSprite(string spriteName); | ||
/// <summary> | ||
/// Tries to the get the sprite sheet asset by xml asset name, returns null on failure. | ||
/// </summary> | ||
/// <param name="spriteSheetName">XML Name of the asset.</param> | ||
/// <returns>The asset or null if none are found.</returns> | ||
GUISpriteSheet GetSpriteSheet(string spriteSheetName); | ||
/// <summary> | ||
/// Tries to the get the cursor asset by xml asset name, returns null on failure. | ||
/// </summary> | ||
/// <param name="cursorName">XML Name of the asset.</param> | ||
/// <returns>The asset or null if none are found.</returns> | ||
GUICursor GetCursor(string cursorName); | ||
/// <summary> | ||
/// Tries to the get the color asset by xml asset name, returns null on failure. | ||
/// </summary> | ||
/// <param name="colorName">XML Name of the asset.</param> | ||
/// <returns>The asset or null if none are found.</returns> | ||
GUIColor GetColor(string colorName); | ||
} |
50 changes: 50 additions & 0 deletions
50
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Services/LoggerService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Microsoft.Xna.Framework; | ||
|
||
namespace Barotrauma.LuaCs.Services; | ||
|
||
public partial class LoggerService : ILoggerService, IClientLoggerService | ||
{ | ||
private GUIFrame _overlayFrame; | ||
private GUITextBlock _textBlock; | ||
private double _showTimer = 0; | ||
|
||
|
||
private void CreateOverlay(string message) | ||
{ | ||
_overlayFrame = new GUIFrame(new RectTransform(new Vector2(0.4f, 0.03f), null), null, new Color(50, 50, 50, 100)) | ||
{ | ||
CanBeFocused = false | ||
}; | ||
|
||
GUILayoutGroup layout = | ||
new GUILayoutGroup( | ||
new RectTransform(new Vector2(0.8f, 0.8f), _overlayFrame.RectTransform, Anchor.CenterLeft), false, | ||
Anchor.Center); | ||
|
||
_textBlock = new GUITextBlock(new RectTransform(new Vector2(1f, 0f), layout.RectTransform), message); | ||
_overlayFrame.RectTransform.MinSize = new Point((int)(_textBlock.TextSize.X * 1.2), 0); | ||
|
||
layout.Recalculate(); | ||
} | ||
|
||
public void AddToGUIUpdateList() | ||
{ | ||
if (_overlayFrame != null && Timing.TotalTime <= _showTimer) | ||
{ | ||
_overlayFrame.AddToGUIUpdateList(); | ||
} | ||
} | ||
|
||
public void ShowErrorOverlay(string message, float time = 5f, float duration = 1.5f) | ||
{ | ||
if (Timing.TotalTime <= _showTimer) | ||
{ | ||
return; | ||
} | ||
|
||
CreateOverlay(message); | ||
|
||
_overlayFrame.Flash(Color.Red, duration, true); | ||
_showTimer = Timing.TotalTime + time; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
Barotrauma/BarotraumaClient/ClientSource/LuaCs/Services/PackageService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Immutable; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Barotrauma.LuaCs.Data; | ||
using Barotrauma.LuaCs.Services.Processing; | ||
|
||
namespace Barotrauma.LuaCs.Services; | ||
|
||
public partial class PackageService : IStylesResourcesInfo | ||
{ | ||
private readonly Lazy<IStylesService> _stylesService; | ||
|
||
public PackageService( | ||
Lazy<IXmlModConfigConverterService> converterService, | ||
Lazy<ILegacyConfigService> legacyConfigService, | ||
Lazy<ILuaScriptService> luaScriptService, | ||
Lazy<ILocalizationService> localizationService, | ||
Lazy<IPluginService> pluginService, | ||
Lazy<IStylesService> stylesService, | ||
Lazy<IConfigService> configService, | ||
IPackageManagementService packageManagementService, | ||
IStorageService storageService, | ||
ILoggerService loggerService) | ||
{ | ||
_modConfigConverterService = converterService; | ||
_legacyConfigService = legacyConfigService; | ||
_luaScriptService = luaScriptService; | ||
_localizationService = localizationService; | ||
_pluginService = pluginService; | ||
_stylesService = stylesService; | ||
_configService = configService; | ||
_packageManagementService = packageManagementService; | ||
_storageService = storageService; | ||
_loggerService = loggerService; | ||
} | ||
|
||
public ImmutableArray<IStylesResourceInfo> StylesResourceInfos => ModConfigInfo?.StylesResourceInfos ?? ImmutableArray<IStylesResourceInfo>.Empty; | ||
|
||
public void LoadStyles([NotNull]IStylesResourcesInfo stylesInfo) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...rauma/BarotraumaClient/ClientSource/LuaCs/Services/Processing/IClientParserDefinitions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Xml.Linq; | ||
using Barotrauma.LuaCs.Data; | ||
|
||
namespace Barotrauma.LuaCs.Services.Processing; | ||
|
||
#region XmlToResourceParsers | ||
public interface IXmlStylesToResConverterService : IXmlResourceConverterService<IStylesResourceInfo> { } | ||
|
||
#endregion |
Oops, something went wrong.