From 8e596cc77ee1972b0034be50dc3a39d8aeab36bc Mon Sep 17 00:00:00 2001 From: HenryMarkle Date: Sun, 8 Sep 2024 11:06:50 +0300 Subject: [PATCH] fix --- Leditor.Renderer/Partial/Engine.Materials.cs | 146 ++++++++++++++++++- Leditor.Renderer/Partial/Engine.cs | 19 +++ Leditor/Pages/NewLevelPage.cs | 14 ++ Leditor/imgui.ini | 66 +++++---- 4 files changed, 211 insertions(+), 34 deletions(-) diff --git a/Leditor.Renderer/Partial/Engine.Materials.cs b/Leditor.Renderer/Partial/Engine.Materials.cs index b23c371..650ec47 100644 --- a/Leditor.Renderer/Partial/Engine.Materials.cs +++ b/Leditor.Renderer/Partial/Engine.Materials.cs @@ -3577,7 +3577,7 @@ in RenderTexture2D rt } else { SDraw.Draw_NoWhite_NoColor( _layers[q], - State.densePipesImages[$"{mat.Name}image"], + State.densePipesImages[mat.Name], Shaders.WhiteRemover, new Rectangle((variable - 1) * 40, 1, 40, 40), new Rectangle(pos - Vector2.One * 20, Vector2.One * 40) @@ -3677,7 +3677,7 @@ in RenderTexture2D rt } else { SDraw.Draw_NoWhite_NoColor( _layers[q], - State.densePipesImages[$"{mat.Name}image"], + State.densePipesImages[mat.Name], Shaders.WhiteRemover, new Rectangle(variable*40, 1 + (rand - 1)*40, 40, 40), new Rectangle(pos - Vector2.One * 20, Vector2.One * 40) @@ -3686,4 +3686,146 @@ in RenderTexture2D rt } } } + + protected virtual void DrawRandomPipesMaterial_MTX( + in MaterialDefinition mat, + int x, + int y, + int layer, + in RenderCamera camera, + in RenderTexture2D rt + ) { + var pos = (new Vector2(x, y) - camera.Coords/20f) * 20 - Vector2.One * 10; + + var cellType = Utils.GetGeoCellType(Level!.GeoMatrix, x, y, layer); + + if (cellType is not GeoType.Air or GeoType.Solid) { + var variable = 16; + + variable = cellType switch { + GeoType.SlopeNE => 20, + GeoType.SlopeNW => 19, + GeoType.SlopeES => 17, + GeoType.SlopeSW => 18, + GeoType.Platform => Random.Generate(2) - 1 == 1 ? 25 : 21, + GeoType.Glass => 22, + + _ => variable + }; + + var sublayer = layer * 10; + + if (cellType is GeoType.Platform) { + for (var d = 0; d <= 9; d++) { + SDraw.Draw_NoWhite_NoColor( + _layers[sublayer + d], + State.densePipesImages2[mat.Name], + Shaders.WhiteRemover, + new Rectangle((variable - 1)*20, d * 20, 20, 20), + new Rectangle(pos - Vector2.One * 10, Vector2.One * 20) + ); + } + } + else { + for (var d = 0; d <= 2; d++) { + SDraw.Draw_NoWhite_NoColor( + _layers[sublayer + d], + State.densePipesImages2[mat.Name], + Shaders.WhiteRemover, + new Rectangle((variable - 1)*20, d * 20, 20, 20), + new Rectangle(pos - Vector2.One * 10, Vector2.One * 20) + ); + } + + for (var d = 3; d <= 6; d++) { + SDraw.Draw_NoWhite_NoColor( + _layers[sublayer + d], + State.densePipesImages2[mat.Name], + Shaders.WhiteRemover, + new Rectangle((variable - 1)*20, 3 * 20, 20, 20), + new Rectangle(pos - Vector2.One * 10, Vector2.One * 20) + ); + } + + var tf = 7; + + for (var d = 4; d <= 6; d++) { + SDraw.Draw_NoWhite_NoColor( + _layers[sublayer + tf], + State.densePipesImages2[mat.Name], + Shaders.WhiteRemover, + new Rectangle((variable - 1)*20, d * 20, 20, 20), + new Rectangle(pos - Vector2.One * 10, Vector2.One * 20) + ); + + tf++; + } + } + } + else { + ReadOnlySpan list = [ + "0000", "1111", "0101", "1010", + "0001", "1000", "0100", "0010", + "1001", "1100", "0110", "0011", + "1011", "1101", "1110", "0111" + ]; + + var sublayer = layer * 10; + + var left = Utils.BoolInt(Utils.IsGeoCellSolid(Level!.GeoMatrix, x - 1, y, layer)) * DPCircuitConnection().x; + var right = Utils.BoolInt(Utils.IsGeoCellSolid(Level!.GeoMatrix, x + 1, y, layer)) * DPCircuitConnection().x; + var top = Utils.BoolInt(Utils.IsGeoCellSolid(Level!.GeoMatrix, x, y - 1, layer)) * DPCircuitConnection().y; + var bottom = Utils.BoolInt(Utils.IsGeoCellSolid(Level!.GeoMatrix, x, y + 1, layer)) * DPCircuitConnection().y; + + if ( + Utils.GetGeoCellType(Level!.GeoMatrix, x - 1, y, layer) is not GeoType.Air && + ( + !Configuration.MaterialFixes || + Utils.GetGeoCellType(Level!.GeoMatrix, x - 1, y, layer) is not GeoType.Glass + ) + ) { + left = 1; + } + + if ( + Utils.GetGeoCellType(Level!.GeoMatrix, x + 1, y, layer) is not GeoType.Air && + ( + !Configuration.MaterialFixes || + Utils.GetGeoCellType(Level!.GeoMatrix, x + 1, y, layer) is not GeoType.Glass + ) + ) { + right = 1; + } + + if ( + Utils.GetGeoCellType(Level!.GeoMatrix, x, y - 1, layer) is not GeoType.Air && + ( + !Configuration.MaterialFixes || + Utils.GetGeoCellType(Level!.GeoMatrix, x, y - 1, layer) is not GeoType.Glass + ) + ) { + top = 1; + } + + if ( + Utils.GetGeoCellType(Level!.GeoMatrix, x, y + 1, layer) is not GeoType.Air && + ( + !Configuration.MaterialFixes || + Utils.GetGeoCellType(Level!.GeoMatrix, x, y + 1, layer) is not GeoType.Glass + ) + ) { + bottom = 1; + } + + var variable = list.IndexOf($"{left}{top}{right}{bottom}") + 1; + + variable = variable switch { + 3 => Random.Generate(2) == 2 ? 23 : 3, + 4 => Random.Generate(2) == 2 ? 24 : 4, + _ => Random.Generate(3) switch { 1 => 1, 2 => 26, _ => 27 }, + }; + + + } + } } \ No newline at end of file diff --git a/Leditor.Renderer/Partial/Engine.cs b/Leditor.Renderer/Partial/Engine.cs index 47dee26..352aed2 100644 --- a/Leditor.Renderer/Partial/Engine.cs +++ b/Leditor.Renderer/Partial/Engine.cs @@ -86,6 +86,7 @@ protected class RenderState public Dictionary tileSets = []; public Dictionary wvTiles = []; public Dictionary densePipesImages = []; + public Dictionary densePipesImages2 = []; /// /// Used for rendering `Random Metal` material @@ -302,6 +303,17 @@ public virtual void Initialize(Registry registry) }) .ToDictionary(m => m.Item1, m => m.Item2, StringComparer.OrdinalIgnoreCase); }); + + var desnsePipesImages2Task = Task.Run(() => { + densePipesImages2 = registry.Materials!.Names.Values + .Where(m => m.RenderType == MaterialRenderType.DensePipe) + .Select(m => { + var texture = registry.CastLibraries.Values.Where(c => c.Members.ContainsKey($"{m.Name}Image2")).Select(c => c[$"{m.Name}WVTiles"]).First().Texture; + + return (m.Name, texture); + }) + .ToDictionary(m => m.Item1, m => m.Item2, StringComparer.OrdinalIgnoreCase); + }); var memberTask = Task.Run(() => { registry.Tiles?.Names.TryGetValue("Temple Stone Wedge", out TempleStoneWedge); @@ -433,6 +445,7 @@ public virtual void Initialize(Registry registry) megaTrashPoolTask.Wait(); wvTilesTask.Wait(); desnsePipesImagesTask.Wait(); + desnsePipesImages2Task.Wait(); Initialized = true; } @@ -1218,6 +1231,12 @@ public virtual void Render() DrawDensePipeMaterial_MTX(material, q.x, q.y, layer, camera, _frontImage); } break; + + case MaterialRenderType.RandomPipes: + { + + } + break; } } } diff --git a/Leditor/Pages/NewLevelPage.cs b/Leditor/Pages/NewLevelPage.cs index 95e722d..8d45861 100644 --- a/Leditor/Pages/NewLevelPage.cs +++ b/Leditor/Pages/NewLevelPage.cs @@ -37,9 +37,14 @@ public override void Dispose() private bool _isBufferControlActive; + private bool _isInputBusy; + public override void Draw() { // BeginDrawing(); + + GLOBALS.LockNavigation = _isInputBusy; + _isInputBusy = false; ClearBackground(GLOBALS.Settings.GeneralSettings.DarkTheme ? new Color(100, 100, 100, 255) @@ -124,11 +129,13 @@ public override void Draw() ImGui.SetNextItemWidth(200); ImGui.InputInt("Width", ref _matrixWidthValue); + _isInputBusy = _isInputBusy || ImGui.IsItemActive(); _isBufferControlActive = _isBufferControlActive || ImGui.IsItemActive(); ImGui.SetNextItemWidth(200); ImGui.InputInt("Height", ref _matrixHeightValue); + _isInputBusy = _isInputBusy || ImGui.IsItemActive(); _isBufferControlActive = _isBufferControlActive || ImGui.IsItemActive(); Utils.Restrict(ref _matrixWidthValue, 1); @@ -139,21 +146,25 @@ public override void Draw() ImGui.SetNextItemWidth(200); ImGui.InputInt("Left", ref _leftPadding); + _isInputBusy = _isInputBusy || ImGui.IsItemActive(); _isBufferControlActive = _isBufferControlActive || ImGui.IsItemActive(); ImGui.SetNextItemWidth(200); ImGui.InputInt("Top", ref _topPadding); + _isInputBusy = _isInputBusy || ImGui.IsItemActive(); _isBufferControlActive = _isBufferControlActive || ImGui.IsItemActive(); ImGui.SetNextItemWidth(200); ImGui.InputInt("Right", ref _rightPadding); + _isInputBusy = _isInputBusy || ImGui.IsItemActive(); _isBufferControlActive = _isBufferControlActive || ImGui.IsItemActive(); ImGui.SetNextItemWidth(200); ImGui.InputInt("Bottom", ref _bottomPadding); + _isInputBusy = _isInputBusy || ImGui.IsItemActive(); _isBufferControlActive = _isBufferControlActive || ImGui.IsItemActive(); Utils.Restrict(ref _leftPadding, 0); @@ -225,13 +236,16 @@ public override void Draw() var col1Space = ImGui.GetContentRegionAvail(); ImGui.SetNextItemWidth(100); + ImGui.InputInt("Rows", ref _rows); + _isInputBusy = _isInputBusy || ImGui.IsItemActive(); _isBufferControlActive = _isBufferControlActive || ImGui.IsItemActive(); ImGui.SetNextItemWidth(100); ImGui.InputInt("Columns", ref _columns); + _isInputBusy = _isInputBusy || ImGui.IsItemActive(); _isBufferControlActive = _isBufferControlActive || ImGui.IsItemActive(); Utils.Restrict(ref _rows, 1); diff --git a/Leditor/imgui.ini b/Leditor/imgui.ini index d1b049d..acde668 100644 --- a/Leditor/imgui.ini +++ b/Leditor/imgui.ini @@ -34,32 +34,29 @@ Size=170,187 Collapsed=0 [Window][Blocks##GeoBlocks] -Pos=942,19 +Pos=1557,39 Size=338,252 Collapsed=0 [Window][Settings##NewGeoSettings] -Pos=942,273 +Pos=1424,397 Size=338,527 Collapsed=0 [Window][Tiles & Materials] -Pos=935,19 +Pos=1460,78 Size=345,403 Collapsed=0 -DockId=0x00000017,0 [Window][Specs] -Pos=935,424 +Pos=1470,489 Size=345,187 Collapsed=0 -DockId=0x00000018,0 [Window][Settings##TilesSettings] -Pos=935,613 +Pos=1460,688 Size=345,187 Collapsed=0 -DockId=0x00000016,0 [Window][Settings##CameraEditorSettings] Pos=994,30 @@ -129,7 +126,7 @@ DockId=0x0000000B,0 [Window][Create New Level##NewLevelWindow] Pos=40,40 -Size=1220,770 +Size=1840,911 Collapsed=0 [Window][About##AboutLeditor] @@ -175,11 +172,11 @@ Collapsed=0 [Window][WindowOverViewport_11111111] Pos=0,19 -Size=1300,831 +Size=1920,972 Collapsed=0 [Window][Shortcuts##EditorShortcuts] -Pos=60,60 +Pos=39,597 Size=304,341 Collapsed=0 @@ -188,26 +185,31 @@ Pos=312,389 Size=675,71 Collapsed=0 +[Window][Textures##TileEditorTileTexturesWin] +Pos=60,60 +Size=46,966 +Collapsed=0 + +[Window][Visuals##TilesEditorVisualsWindow] +Pos=60,60 +Size=256,477 +Collapsed=0 + [Docking][Data] -DockSpace ID=0x8B93E3BD Pos=0,19 Size=1280,781 Split=X - DockNode ID=0x0000001B Parent=0x8B93E3BD SizeRef=939,800 Split=X - DockNode ID=0x00000013 Parent=0x0000001B SizeRef=933,991 Split=X - DockNode ID=0x00000011 Parent=0x00000013 SizeRef=887,991 Split=X - DockNode ID=0x0000000A Parent=0x00000011 SizeRef=1515,991 CentralNode=1 - DockNode ID=0x0000000C Parent=0x00000011 SizeRef=403,991 Split=Y Selected=0x7D1DA4A6 - DockNode ID=0x0000000D Parent=0x0000000C SizeRef=241,401 Selected=0x7D1DA4A6 - DockNode ID=0x0000000E Parent=0x0000000C SizeRef=241,378 Split=Y Selected=0xE365E069 - DockNode ID=0x0000000F Parent=0x0000000E SizeRef=241,131 Selected=0xE365E069 - DockNode ID=0x00000010 Parent=0x0000000E SizeRef=241,245 Selected=0xAF2658BC - DockNode ID=0x00000012 Parent=0x00000013 SizeRef=391,991 Selected=0xD7CDB64E - DockNode ID=0x00000014 Parent=0x0000001B SizeRef=345,991 Split=Y Selected=0x91EB7909 - DockNode ID=0x00000015 Parent=0x00000014 SizeRef=354,592 Split=Y Selected=0x91EB7909 - DockNode ID=0x00000017 Parent=0x00000015 SizeRef=354,403 Selected=0x91EB7909 - DockNode ID=0x00000018 Parent=0x00000015 SizeRef=354,187 Selected=0x4098A460 - DockNode ID=0x00000016 Parent=0x00000014 SizeRef=354,187 Selected=0x0249687E - DockNode ID=0x0000001C Parent=0x8B93E3BD SizeRef=339,800 Split=Y Selected=0x56CE8506 - DockNode ID=0x00000009 Parent=0x0000001C SizeRef=264,573 Split=Y Selected=0x56CE8506 - DockNode ID=0x0000001D Parent=0x00000009 SizeRef=339,468 Selected=0x56CE8506 - DockNode ID=0x0000001E Parent=0x00000009 SizeRef=339,103 Selected=0x923F9C39 - DockNode ID=0x0000000B Parent=0x0000001C SizeRef=264,206 Selected=0xE7756E60 +DockSpace ID=0x7C6B3D9B Window=0xA87D555D Pos=0,19 Size=1920,972 CentralNode=1 +DockSpace ID=0x8B93E3BD Pos=0,19 Size=1280,781 Split=X + DockNode ID=0x0000001B Parent=0x8B93E3BD SizeRef=939,800 Split=X + DockNode ID=0x00000011 Parent=0x0000001B SizeRef=887,991 Split=X + DockNode ID=0x0000000A Parent=0x00000011 SizeRef=1515,991 CentralNode=1 + DockNode ID=0x0000000C Parent=0x00000011 SizeRef=403,991 Split=Y Selected=0x7D1DA4A6 + DockNode ID=0x0000000D Parent=0x0000000C SizeRef=241,401 Selected=0x7D1DA4A6 + DockNode ID=0x0000000E Parent=0x0000000C SizeRef=241,378 Split=Y Selected=0xE365E069 + DockNode ID=0x0000000F Parent=0x0000000E SizeRef=241,131 Selected=0xE365E069 + DockNode ID=0x00000010 Parent=0x0000000E SizeRef=241,245 Selected=0xAF2658BC + DockNode ID=0x00000012 Parent=0x0000001B SizeRef=391,991 Selected=0xD7CDB64E + DockNode ID=0x0000001C Parent=0x8B93E3BD SizeRef=339,800 Split=Y Selected=0x56CE8506 + DockNode ID=0x00000009 Parent=0x0000001C SizeRef=264,573 Split=Y Selected=0x56CE8506 + DockNode ID=0x0000001D Parent=0x00000009 SizeRef=339,468 Selected=0x56CE8506 + DockNode ID=0x0000001E Parent=0x00000009 SizeRef=339,103 Selected=0x923F9C39 + DockNode ID=0x0000000B Parent=0x0000001C SizeRef=264,206 Selected=0xE7756E60