Skip to content

Commit c880fc8

Browse files
TWUI stuff and close console on exit
1 parent cce9161 commit c880fc8

File tree

5 files changed

+73
-31
lines changed

5 files changed

+73
-31
lines changed

AssetEditor/App.xaml.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ void ShowMainWindow()
8484

8585
var mainWindow = _serviceProvider.GetRequiredService<MainWindow>();
8686
mainWindow.DataContext = _serviceProvider.GetRequiredService<MainViewModel>();
87+
mainWindow.Closed += OnMainWindowClosed;
8788
mainWindow.Show();
8889

8990
// Ensure the window doesn't cover up the windows bar.
@@ -94,6 +95,13 @@ void ShowMainWindow()
9495
SystemCommands.MaximizeWindow(mainWindow);
9596
}
9697

98+
private void OnMainWindowClosed(object sender, EventArgs e)
99+
{
100+
foreach (Window window in Current.Windows)
101+
window.Close();
102+
Shutdown();
103+
}
104+
97105
void DispatcherUnhandledExceptionHandler(object sender, DispatcherUnhandledExceptionEventArgs args)
98106
{
99107
Logging.Create<App>().Here().Fatal(args.Exception.ToString());

Editors/TwuiEditor/Editor.Twui/DependencyInjectionContainer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public override void Register(IServiceCollection serviceCollection)
2525

2626
public override void RegisterTools(IEditorDatabase editorDatabase)
2727
{
28-
//EditorInfoBuilder
29-
// .Create<TwuiEditor, TwuiMainView>(EditorEnums.Twui_Editor)
30-
// .AddExtention(".twui.xml", EditorPriorites.High)
31-
// .Build(editorDatabase);
28+
EditorInfoBuilder
29+
.Create<TwuiEditor, TwuiMainView>(EditorEnums.Twui_Editor)
30+
.AddExtention(".twui.xml", EditorPriorites.High)
31+
.Build(editorDatabase);
3232
}
3333
}
3434
}

Editors/TwuiEditor/Editor.Twui/Editor/Rendering/ComponentCoordinateHelper.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Editors.Twui.Editor.Rendering
1010
{
1111
public static class ComponentCoordinateHelper
1212
{
13-
public static Rectangle GetLocalCoordinateSpace(Component component, Rectangle parentComponentRect)
13+
public static Rectangle GetLocalCoordinateSpace(Component component, Rectangle parentComponentRect, int depth)
1414
{
1515
var currentStateId = component.Currentstate;
1616
var currentState = component.States.FirstOrDefault(x => x.UniqueGuid == currentStateId);
@@ -20,10 +20,18 @@ public static Rectangle GetLocalCoordinateSpace(Component component, Rectangle p
2020
//throw new Exception($"Current state {currentStateId} not found in {component.Name}[{component.Id}]");
2121
}
2222

23-
var localSpace = component.Offset;
23+
if (component.Name == "holder_grudge_cycles")
24+
{
25+
}
26+
27+
var localSpace = new Vector2(parentComponentRect.X, parentComponentRect.Y);
2428
var width = (int)currentState.Width;
2529
var height = (int)currentState.Height;
2630

31+
32+
33+
34+
2735
if (component.DockingHorizontal != DockingHorizontal.None || component.DockingVertical != DockingVertical.None)
2836
{
2937
switch (component.DockingHorizontal)
@@ -56,7 +64,12 @@ public static Rectangle GetLocalCoordinateSpace(Component component, Rectangle p
5664
break;
5765
}
5866

59-
//localSpace += component.Dock_offset;
67+
68+
localSpace += component.Dock_offset;
69+
70+
71+
var anchorOffset = new Vector2(width, height) * component.Component_anchor_point;
72+
localSpace -= anchorOffset;
6073
}
6174

6275

Editors/TwuiEditor/Editor.Twui/Editor/Rendering/TwuiPreviewBuilder.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,36 +60,51 @@ public RenderTarget2D UpdateTexture(TwuiFile twuiFile, Component? selectedCompon
6060
device.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true };
6161

6262
_spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend);//, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
63-
DrawHierarchy(Rectangle.Empty, twuiFile.Hierarchy.RootItems, twuiFile.Components, selectedComponent);
63+
64+
DrawHierarchy(Rectangle.Empty, twuiFile.Hierarchy.RootItems, twuiFile.Components, selectedComponent, 0);
6465
_spriteBatch.End();
6566

6667
device.SetRenderTarget(null);
6768

6869
return _renderTarget;
6970
}
7071

71-
void DrawHierarchy(Rectangle localSpace, IEnumerable<HierarchyItem> hierarchyItems, List<Component> componentList, Component? selectedComponent)
72+
void DrawHierarchy(Rectangle localSpace, IEnumerable<HierarchyItem> hierarchyItems, List<Component> componentList, Component? selectedComponent, int depth)
7273
{
7374
foreach (var hierarchyItem in hierarchyItems)
7475
{
7576
var component = componentList.FirstOrDefault(x => hierarchyItem.Id == x.This);
7677
if (component == null)
7778
continue;
7879

79-
var componentLocalSpace = DrawComponent(localSpace, component, selectedComponent);
80-
DrawHierarchy(componentLocalSpace, hierarchyItem.Children, componentList, selectedComponent);
80+
var componentLocalSpace = DrawComponent(localSpace, component, selectedComponent, depth);
81+
82+
83+
int width = 0; int height = 0;
84+
var currentStateId = component.Currentstate;
85+
var currentState = component.States.FirstOrDefault(x => x.UniqueGuid == currentStateId);
86+
if (currentState != null)
87+
{
88+
width = (int)currentState.Width;
89+
height = (int)currentState.Height;
90+
}
91+
var spacing = new string('\t', depth);
92+
Console.WriteLine($"{spacing}{component.Name}: Offset:{component.Offset}, Width:{width}, Height:{height}, Rect:{componentLocalSpace} -- DockingX:{component.DockingHorizontal}, DockingY:{component.DockingVertical}, DockOffset:{component.Dock_offset}, Acor:{component.Component_anchor_point}");
93+
94+
95+
DrawHierarchy(componentLocalSpace, hierarchyItem.Children, componentList, selectedComponent, depth+1);
8196
}
8297
}
8398

84-
Rectangle DrawComponent(Rectangle localSpace, Component currentComponent, Component? selectedComponent)
99+
Rectangle DrawComponent(Rectangle localSpace, Component currentComponent, Component? selectedComponent, int depth)
85100
{
86101
var invMaxLayerDepth = 1f/999999f;
87102

88103
// Take into account docking
89104
// Take into account colour
90105
// Take into account state
91106

92-
var compnentLocalSpace = ComponentCoordinateHelper.GetLocalCoordinateSpace(currentComponent, Rectangle.Empty);
107+
var compnentLocalSpace = ComponentCoordinateHelper.GetLocalCoordinateSpace(currentComponent, localSpace, depth);
93108

94109
foreach (var image in currentComponent.ComponentImages)
95110
{

Notes.txt

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
1-
FIX GameDb => SQL DB convrter v0.1
21

3-
RenderEngineComponent=> Draw
4-
inside _drawGlow, crash if device.Viewport.Width == 1 as bloomRenderTarget == null
52

63

7-
Finished for v059
8-
asd888
4+
5+
6+
Fixes for v060
7+
98
[Feature] twui editor v0.1
10-
[Feature] Support for reading encrypted packfiles
11-
12-
[Bugfix] General: Fixed common crash when opening 3d models, that caused soft lock. Thanks to Cemmen and timbabwiani for debugging help
13-
[Bugfix] Audiostuff: Ask pear for a description
14-
[Bugfix] General: Fixed bug which caused deleted files to not be removed
15-
[Bugfix] Kitbash: Error message if there is an error in wsmodel, reverts to using rmv2 material
16-
[Bugfix] Kitbash: Fixed potential softlock when loading wsmodels with errors
17-
[Bugfix] AnimationBins: Most warnings turned into errors, as CA has terrible QA.
18-
19-
X GameWorld: Complex scene loader, make it work without needed Animation players, and graphics card. For unit testing. Make a input setting struct
20-
X General: Convert GameinformationFactory to a static!
9+
FIX GameDb => SQL DB convrter v0.1
2110

22-
Fixes for v059
2311
Finish game settings and make stuff hide behind interface.
2412
Consider movving all of material stuff out of rendering, as it would then make more sene to move wsmodel parsing and generations in there
2513
Hide basic shader behind material factory as well. It can also be a capability shader.
@@ -67,7 +55,11 @@ Bugs:
6755
Save
6856
Add
6957
Search
70-
58+
59+
Important tests:
60+
WsModel for only visible nodes
61+
AnimationBin saving/parsing
62+
7163

7264
Improvements:
7365
General: Print scope - special handling for eventhub. Include registred callbacks
@@ -133,6 +125,20 @@ New features:
133125
Interesting links:
134126
https://github.com/kikipoulet/SukiUI/blob/main/SukiUI/Controls/PropertyGrid/InstanceViewModel.cs -> Auto generate views for property gird. Also good docking in same lib
135127

128+
129+
130+
Finished for v058
131+
[Feature] Support for reading encrypted packfiles
132+
133+
[Bugfix] Kitbash: Fixed issue when generating WsModel for only visible meshes
134+
[Bugfix] General: Fixed common crash when opening 3d models, that caused soft lock. Thanks to Cemmen and timbabwiani for debugging help
135+
[Bugfix] Audio: General bugfixes and Improvements
136+
[Bugfix] General: Fixed bug which caused deleted files to not be removed
137+
[Bugfix] Kitbash: Error message if there is an error in wsmodel, reverts to using rmv2 material
138+
[Bugfix] Kitbash: Fixed potential softlock when loading wsmodels with errors
139+
[Bugfix] AnimationBins: Most warnings turned into errors, as CA has terrible QA.
140+
[Bugfix] AnimationBins: Fixed crash when validating bin, due to missing file. Is now a warrning #243
141+
136142
Fixes for v058:
137143
[Feature] General: Force close current editor option added to the error window to avoid softlocks. https://github.com/donkeyProgramming/TheAssetEditor/issues/232
138144
[Feature] AnimationReTarget: The tool is enabled again - probably pretty buggy in its first iterations. Improvements will come.

0 commit comments

Comments
 (0)