Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"chat.tools.terminal.autoApprove": {
"ForEach-Object": true
"ForEach-Object": true,
"dotnet restore": true,
"Set-Content": true
}
}
2 changes: 1 addition & 1 deletion AssetEditor/AssetEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<PackageProjectUrl>https://github.com/donkeyProgramming/TheAssetEditor</PackageProjectUrl>
<RepositoryUrl>https://github.com/donkeyProgramming/TheAssetEditor</RepositoryUrl>
<PackageId>AssetEditor</PackageId>
<Version>0.71.0</Version>
<Version>0.72.0</Version>
<AnalysisLevel>6.0</AnalysisLevel>
</PropertyGroup>

Expand Down
12 changes: 11 additions & 1 deletion AssetEditor/Language_Cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"SettingsWindow.RenderBackground": "渲染引擎背景颜色",
"SettingsWindow.OnlyLoadLod0": "仅为参考 Mesh 加载 Lod0",
"SettingsWindow.GridSize": "网格大小",
"SettingsWindow.VertexSelectionColour": "顶点选择颜色",
"SettingsWindow.AudioModding": "音频 Mod",
"SettingsWindow.SaveButton": "保存",

Expand Down Expand Up @@ -97,6 +98,7 @@
"SettingsWindow.Title": "设置",
"SettingsWindow.OnlyLoadLod0Tooltip": "在 Kitbash 工具中导入参考 Mesh 时,仅导入 Lod0 以节省内存。",
"SettingsWindow.GridSizeTooltip": "可视化编辑器中网格的大小",
"SettingsWindow.VertexSelectionColourTooltip": "选中顶点的十六进制颜色(例如 #FF7800)",
"SettingsWindow.GameFiles": "游戏文件",
"SettingsWindow.GameDataPathHint": "浏览游戏数据位置,例如 \"C:\\SteamLibrary\\steamapps\\common\\Total War WARHAMMER III\\data\"",
"SettingsWindow.WwiseCLI": "Wwise CLI",
Expand Down Expand Up @@ -881,5 +883,13 @@

"AnimationReTarget.BoneSettings.Title": "骨骼设置:",
"FbxSettingsDialog.Import": "导入",
"FbxSettingsDialog.Cancel": "取消"
"FbxSettingsDialog.Cancel": "取消",

"PackFileCache.InvalidReason.Title": "Cache Rebuild Required",
"PackFileCache.InvalidReason.NotFound": "No cache found for {0}. Building cache for the first time - this may take a moment.",
"PackFileCache.InvalidReason.DataChanged": "Game files for {0} have changed since the cache was built. Rebuilding cache.",
"PackFileCache.InvalidReason.Corrupted": "Cache for {0} is corrupted and will be rebuilt.",
"PackFileCache.BuildingCache": "Building pack file cache for {0}. This may take some time, please wait...",
"PackFileCache.BuildingCache.Title": "Building Cache",
"PackFileCache.Description": "The cache allows faster startup times and reduces memory usage by storing pre-processed game file data on disk."
}
12 changes: 11 additions & 1 deletion AssetEditor/Language_En.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"SettingsWindow.RenderBackground": "Render engine background colour",
"SettingsWindow.OnlyLoadLod0": "Only load Lod0 for reference meshes",
"SettingsWindow.GridSize": "Grid Size",
"SettingsWindow.VertexSelectionColour": "Vertex Selection Colour",
"SettingsWindow.AudioModding": "Audio Modding",
"SettingsWindow.SaveButton": "Save",

Expand Down Expand Up @@ -97,6 +98,7 @@
"SettingsWindow.Title": "Settings",
"SettingsWindow.OnlyLoadLod0Tooltip": "When importing a reference mesh in the Kitbash tool, only import Lod0 in order to save memory.",
"SettingsWindow.GridSizeTooltip": "Size of the grid in visual editors",
"SettingsWindow.VertexSelectionColourTooltip": "Hex colour for selected vertices (e.g. #FF7800)",
"SettingsWindow.GameFiles": "Game Files",
"SettingsWindow.GameDataPathHint": "Browse for game data location e.g. \"C:\\SteamLibrary\\steamapps\\common\\Total War WARHAMMER III\\data\"",
"SettingsWindow.WwiseCLI": "Wwise CLI",
Expand Down Expand Up @@ -881,6 +883,14 @@

"AnimationReTarget.BoneSettings.Title": "Bone settings:",
"FbxSettingsDialog.Import": "Import",
"FbxSettingsDialog.Cancel": "Cancel"
"FbxSettingsDialog.Cancel": "Cancel",

"PackFileCache.InvalidReason.Title": "Cache Rebuild Required",
"PackFileCache.InvalidReason.NotFound": "No cache found for {0}. Building cache for the first time - this may take a moment.",
"PackFileCache.InvalidReason.DataChanged": "Game files for {0} have changed since the cache was built. Rebuilding cache.",
"PackFileCache.InvalidReason.Corrupted": "Cache for {0} is corrupted and will be rebuilt.",
"PackFileCache.BuildingCache": "Building pack file cache for {0}. This may take some time, please wait...",
"PackFileCache.BuildingCache.Title": "Building Cache",
"PackFileCache.Description": "The cache allows faster startup times and reduces memory usage by storing pre-processed game file data on disk."
}

11 changes: 10 additions & 1 deletion AssetEditor/Language_Fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"SettingsWindow.RenderBackground": "Couleur d’arrière-plan du moteur de rendu",
"SettingsWindow.OnlyLoadLod0": "Charger uniquement le Lod0 pour les maillages de référence",
"SettingsWindow.GridSize": "Taille de la grille",
"SettingsWindow.VertexSelectionColour": "Couleur de sélection des sommets",
"SettingsWindow.AudioModding": "Modding audio",
"SettingsWindow.SaveButton": "Enregistrer",

Expand All @@ -27,5 +28,13 @@
"KitbashTool.Debug.Geometry.CreatePlane.Tooltip": "Creer un plan subdivise",
"KitbashTool.Debug.Geometry.CreateSphere.Tooltip": "Creer une sphere subdivisee",

"KitbashTool.SaveDialog.DisplayDialogOnNextSave": "Afficher la boîte de dialogue à la prochaine sauvegarde"
"KitbashTool.SaveDialog.DisplayDialogOnNextSave": "Afficher la boîte de dialogue à la prochaine sauvegarde",

"PackFileCache.InvalidReason.Title": "Cache Rebuild Required",
"PackFileCache.InvalidReason.NotFound": "No cache found for {0}. Building cache for the first time - this may take a moment.",
"PackFileCache.InvalidReason.DataChanged": "Game files for {0} have changed since the cache was built. Rebuilding cache.",
"PackFileCache.InvalidReason.Corrupted": "Cache for {0} is corrupted and will be rebuilt.",
"PackFileCache.BuildingCache": "Building pack file cache for {0}. This may take some time, please wait...",
"PackFileCache.BuildingCache.Title": "Building Cache",
"PackFileCache.Description": "The cache allows faster startup times and reduces memory usage by storing pre-processed game file data on disk."
}
5 changes: 5 additions & 0 deletions AssetEditor/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
using System.Windows.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Xna.Framework;
using Shared.Core.Misc;
using Shared.Core.Services;
using Shared.Core.Settings;
using Shared.Ui.BaseDialogs.ColourPickerButton;

namespace AssetEditor.ViewModels
{
Expand All @@ -28,6 +30,7 @@ partial class SettingsViewModel : ObservableObject
[ObservableProperty] private ThemeType _currentTheme;
[ObservableProperty] private BackgroundColour _currentRenderEngineBackgroundColour;
[ObservableProperty] private int _visualEditorsGridSize;
[ObservableProperty] private ColourPickerViewModel _vertexSelectionColour;
[ObservableProperty] private bool _startMaximised;
[ObservableProperty] private GameTypeEnum _currentGame;
[ObservableProperty] private bool _loadCaPacksByDefault;
Expand All @@ -49,6 +52,7 @@ public SettingsViewModel(ApplicationSettingsService settingsService, Localizatio
RenderEngineBackgroundColours = new ObservableCollection<BackgroundColour>((BackgroundColour[])Enum.GetValues(typeof(BackgroundColour)));
CurrentRenderEngineBackgroundColour = _settingsService.CurrentSettings.RenderEngineBackgroundColour;
VisualEditorsGridSize = _settingsService.CurrentSettings.VisualEditorsGridSize;
VertexSelectionColour = new ColourPickerViewModel(_settingsService.CurrentSettings.VertexSelectionColour);
CameraModes = new ObservableCollection<CameraControlMode>((CameraControlMode[])Enum.GetValues(typeof(CameraControlMode)));

StartMaximised = _settingsService.CurrentSettings.StartMaximised;
Expand Down Expand Up @@ -79,6 +83,7 @@ private void Save()
_settingsService.CurrentSettings.Theme = CurrentTheme;
_settingsService.CurrentSettings.RenderEngineBackgroundColour = CurrentRenderEngineBackgroundColour;
_settingsService.CurrentSettings.VisualEditorsGridSize = VisualEditorsGridSize;
_settingsService.CurrentSettings.VertexSelectionColour = VertexSelectionColour.SelectedColour;
_settingsService.CurrentSettings.StartMaximised = StartMaximised;
_settingsService.CurrentSettings.CurrentGame = CurrentGame;
_settingsService.CurrentSettings.LoadCaPacksByDefault = LoadCaPacksByDefault;
Expand Down
7 changes: 6 additions & 1 deletion AssetEditor/Views/Settings/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
xmlns:gameinfo="clr-namespace:Shared.Core.Services;assembly=Shared.Core"
xmlns:behaviors="clr-namespace:Shared.Ui.Common.Behaviors;assembly=Shared.Ui"
xmlns:loc="clr-namespace:Shared.Ui.Common;assembly=Shared.Ui"
xmlns:local="clr-namespace:AssetEditor.Views.Settings" xmlns:viewmodels="clr-namespace:AssetEditor.ViewModels"
xmlns:local="clr-namespace:AssetEditor.Views.Settings" xmlns:viewmodels="clr-namespace:AssetEditor.ViewModels"
xmlns:colourpickerbutton="clr-namespace:Shared.Ui.BaseDialogs.ColourPickerButton;assembly=Shared.Ui"
d:DataContext="{d:DesignInstance Type=viewmodels:SettingsViewModel}"
mc:Ignorable="d" >

Expand Down Expand Up @@ -98,6 +99,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<TextBlock Grid.Row="0" Text="{loc:Loc SettingsWindow.Rendering}" Margin="5, 10, 0, 0" FontSize="15"/>
Expand All @@ -113,6 +115,9 @@
<TextBlock Grid.Row="4" Grid.Column="0" Text="{loc:Loc SettingsWindow.GridSize}" Margin="5, 0, 0, 0" ToolTip="{loc:Loc SettingsWindow.GridSizeTooltip}"/>
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding VisualEditorsGridSize, UpdateSourceTrigger=LostFocus}" MaxLength="4" Width="150" Margin="0, 0, 0, 5" HorizontalAlignment="Left" HorizontalContentAlignment="Right"/>

<TextBlock Grid.Row="5" Grid.Column="0" Text="{loc:Loc SettingsWindow.VertexSelectionColour}" Margin="5, 0, 0, 0" ToolTip="{loc:Loc SettingsWindow.VertexSelectionColourTooltip}"/>
<colourpickerbutton:ColourPickerButtonView Grid.Row="5" Grid.Column="1" DataContext="{Binding VertexSelectionColour}" Width="25" Height="25" Margin="0, 0, 0, 5" HorizontalAlignment="Left"/>



</Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Editors.KitbasherEditor.ChildEditors.MeshFitter;
using Editors.KitbasherEditor.ChildEditors.PhotoStudio;
Expand Down Expand Up @@ -30,16 +29,14 @@ public class MenuBarViewModel : IKeyboardHandler
private readonly CommandExecutor _commandExecutor;
private readonly MenuItemVisibilityRuleEngine _menuItemVisibilityRuleEngine;
private readonly ActionHotkeyHandler _hotKeyHandler = new ActionHotkeyHandler();
private readonly IWindowsKeyboard _keyboard;
private readonly LocalizationManager _localizationManager;
private readonly Dictionary<Type, MenuAction> _uiCommands = new();

public MenuBarViewModel(CommandExecutor commandExecutor, IEventHub eventHub, MenuItemVisibilityRuleEngine menuItemVisibilityRuleEngine, TransformToolViewModel transformToolViewModel, IUiCommandFactory uiCommandFactory, IWindowsKeyboard windowKeyboard, LocalizationManager localizationManager)
public MenuBarViewModel(CommandExecutor commandExecutor, IEventHub eventHub, MenuItemVisibilityRuleEngine menuItemVisibilityRuleEngine, TransformToolViewModel transformToolViewModel, IUiCommandFactory uiCommandFactory, LocalizationManager localizationManager)
{
_commandExecutor = commandExecutor;
_menuItemVisibilityRuleEngine = menuItemVisibilityRuleEngine;
_uiCommandFactory = uiCommandFactory;
_keyboard = windowKeyboard;
_localizationManager = localizationManager;
TransformTool = transformToolViewModel;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void Setup()
// SelectionManager has complex constructor and non-virtual methods;
// use reflection to set _currentState so GetStateCopy() works.
_selectionManagerMock = new Mock<SelectionManager>(MockBehavior.Loose,
null!, null!, null!, null!, null!);
null!, null!, null!, null!, null!, null!);

var selectionState = Mock.Of<ISelectionState>(s => s.Clone() == Mock.Of<ISelectionState>());
var stateField = typeof(SelectionManager).GetField("_currentState", BindingFlags.NonPublic | BindingFlags.Instance)!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using GameWorld.Core.Utility;
using Microsoft.Xna.Framework;
using Shared.Core.Events;
using Shared.Core.Settings;

namespace GameWorld.Core.Components.Selection
{
Expand All @@ -31,6 +32,7 @@ public class SelectionManager : BaseComponent, IDisposable
private readonly IScopedResourceLibrary _resourceLib;
private readonly IDeviceResolver _deviceResolverComponent;
private readonly IGraphicsResourceCreator _graphicsResourceCreator;
private readonly ApplicationSettingsService _settingsService;

private (int v0, int v1)[] _cachedEdgeIndices;
private Rmv2MeshNode _cachedEdgeMesh;
Expand All @@ -43,13 +45,14 @@ public class SelectionManager : BaseComponent, IDisposable
const int MaxRenderEdges = 50000;
private readonly EdgeData[] _edgeDataCache = new EdgeData[MaxRenderEdges];

public SelectionManager(IEventHub eventHub, RenderEngineComponent renderEngine, IScopedResourceLibrary resourceLib, IDeviceResolver deviceResolverComponent, IGraphicsResourceCreator graphicsResourceCreator)
public SelectionManager(IEventHub eventHub, RenderEngineComponent renderEngine, IScopedResourceLibrary resourceLib, IDeviceResolver deviceResolverComponent, IGraphicsResourceCreator graphicsResourceCreator, ApplicationSettingsService settingsService)
{
_eventHub = eventHub;
_renderEngine = renderEngine;
_resourceLib = resourceLib;
_deviceResolverComponent = deviceResolverComponent;
_graphicsResourceCreator = graphicsResourceCreator;
_settingsService = settingsService;
}

public override void Initialize()
Expand All @@ -72,7 +75,6 @@ public override void Initialize()
base.Initialize();
}


public ISelectionState CreateSelectionSate(GeometrySelectionMode mode, ISelectable selectedObj, bool sendEvent = true)
{
if (_currentState != null)
Expand Down Expand Up @@ -120,6 +122,9 @@ private void SelectionManager_SelectionChanged(ISelectionState state, bool sendE

public override void Draw(GameTime gameTime)
{
if (_vertexRenderer != null)
_vertexRenderer.SelectionColour = _settingsService.CurrentSettings.VertexSelectionColour;

var selectionState = GetState();

if (selectionState is ObjectSelectionState objectSelectionState)
Expand Down Expand Up @@ -147,6 +152,8 @@ public override void Draw(GameTime gameTime)
_cachedEdgeMesh = vertexObject;
_cachedEdgeIndices = BuildEdgeIndexCache(geo);
_edgeDataDirty = true;
_sampleIdx0 = 0;
_sampleIdx1 = geo.VertexCount() > 1 ? 1 : 0;
}

if (selectionVertexState.SelectedVertices.Count >= 2)
Expand All @@ -160,7 +167,14 @@ public override void Draw(GameTime gameTime)
_sampleIdx1 = _sampleIdx0 < geo.VertexCount() - 1 ? _sampleIdx0 + 1 : 0;
}

if (!_edgeDataDirty && geo.VertexCount() >= 2)
var vertexCount = geo.VertexCount();
if (vertexCount > 0)
{
_sampleIdx0 = Math.Clamp(_sampleIdx0, 0, vertexCount - 1);
_sampleIdx1 = Math.Clamp(_sampleIdx1, 0, vertexCount - 1);
}

if (!_edgeDataDirty && vertexCount >= 2)
{
var p0 = geo.GetVertexById(_sampleIdx0);
var p1 = geo.GetVertexById(_sampleIdx1);
Expand All @@ -173,7 +187,7 @@ public override void Draw(GameTime gameTime)
UpdateEdgeQuadData(vertexObject, selectionVertexState);
_edgeDataDirty = false;

if (geo.VertexCount() >= 2)
if (vertexCount >= 2)
{
_samplePos0 = geo.GetVertexById(_sampleIdx0);
_samplePos1 = geo.GetVertexById(_sampleIdx1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public class VertexInstanceMesh : IDisposable
readonly int _maxInstanceCount = 50000;
int _currentInstanceCount;

Vector3 _selectedColour = new(1.0f, 0.47f, 0.0f);
Vector3 _deselectedColour = new(0.0f, 0.0f, 0.0f);

public Vector3 SelectionColour { get; set; } = new Vector3(1.0f, 0.47f, 0.0f);
public float VertexPixelSize { get; set; } = 5.5f;
public float SelectedSizeBoost { get; set; } = 2.0f;
public float SelectionThresholdMultiplier { get; set; } = 2.0f;
Expand Down Expand Up @@ -108,7 +108,7 @@ public void Update(MeshObject geo, Matrix modelMatrix, Vector3 cameraPos,
var distance = (cameraPos - vertPos).Length();

var weight = selectedVertexes.VertexWeights[i];
var color = Vector3.Lerp(_deselectedColour, _selectedColour, weight);
var color = Vector3.Lerp(_deselectedColour, SelectionColour, weight);

var effectivePixelSize = VertexPixelSize + weight * SelectedSizeBoost;
var worldScale = effectivePixelSize * distance * fovScale;
Expand Down
Loading
Loading