Skip to content

Commit eafc54c

Browse files
committed
edit: files
1 parent 952221c commit eafc54c

File tree

13 files changed

+76
-116
lines changed

13 files changed

+76
-116
lines changed

.idea/.idea.Grid_Level_Editor/.idea/indexLayout.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Code/LevelEditor/BlockDataEditor.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,17 @@ public void SetPrefab(GameObject newPrefab)
4141
prefab = newPrefab;
4242
}
4343

44-
public override string ToString()
45-
{
46-
return string.IsNullOrEmpty(id) ? "Unnamed Block" : id;
47-
}
44+
public override string ToString() => string.IsNullOrEmpty(id) ? "Unnamed Block" : id;
4845

49-
public override bool Equals(object obj)
50-
{
51-
return obj is BlockDataEditor other && id == other.id;
52-
}
46+
public override bool Equals(object obj) => obj is BlockDataEditor other && id == other.id;
5347

54-
public override int GetHashCode()
55-
{
56-
return id != null ? id.GetHashCode() : 0;
57-
}
48+
public override int GetHashCode() => id != null ? id.GetHashCode() : 0;
5849

5950
#if UNITY_EDITOR
6051
private void OnValidate()
6152
{
6253
if (!string.IsNullOrEmpty(id))
63-
{
6454
SetID(id);
65-
}
6655
}
6756
#endif
6857
}

Assets/Code/LevelEditor/BlockLibraryWindow.cs

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@ private enum SortMode
1717
ByIconName
1818
}
1919

20-
[MenuItem("Tools/Block Library 🧱")]
20+
[MenuItem("Tools/Gid Level Editor/Block Window")]
2121
public static void ShowWindow()
2222
{
2323
var window = GetWindow<BlockLibraryWindow>(false, "Block Library", true);
2424
window.minSize = new Vector2(400, 500);
2525
}
2626

27-
[BoxGroup("📦 Block Library", centerLabel: true)] [ReadOnly, ShowInInspector, HideLabel]
27+
[BoxGroup("Block Library", centerLabel: true)] [ReadOnly, ShowInInspector, HideLabel]
2828
private BlockLibrary _blockLibrary;
2929

30-
[BoxGroup("🧱 Create Block", centerLabel: true)] [ShowInInspector, LabelText("Block ID")]
30+
[BoxGroup("Create Block", centerLabel: true)] [ShowInInspector, LabelText("Block ID")]
3131
[GUIColor(0.2f, 0.8f, 0.2f)]
3232
private string _newBlockId = "";
33-
[BoxGroup("🧱 Create Block")] [ShowInInspector, LabelText("Icon")]
33+
[BoxGroup("Create Block")] [ShowInInspector, LabelText("Icon")]
3434
[GUIColor(0.2f, 0.8f, 0.2f)]
3535
private Sprite _newBlockSprite;
36-
[BoxGroup("🧱 Create Block")] [ShowInInspector, LabelText("Prefab")]
36+
[BoxGroup("Create Block")] [ShowInInspector, LabelText("Prefab")]
3737
[GUIColor(0.2f, 0.8f, 0.2f)]
3838
private GameObject _newBlockPrefab;
3939

40-
[BoxGroup("🔍 Search & Sort", centerLabel: true)] [ShowInInspector, LabelText("Filter")]
40+
[BoxGroup("Search & Sort", centerLabel: true)] [ShowInInspector, LabelText("Filter")]
4141
private string _searchFilter = "";
42-
[BoxGroup("🔍 Search & Sort")]
43-
[HorizontalGroup("🔍 Search & Sort/SortRow")]
42+
[BoxGroup("Search & Sort")]
43+
[HorizontalGroup("Search & Sort/SortRow")]
4444
[EnumToggleButtons, HideLabel, PropertyOrder(0)]
4545
[SerializeField]
4646
private SortMode _sortMode = SortMode.ByID;
@@ -64,10 +64,7 @@ protected override void DrawEditor(int index)
6464
{
6565
SirenixEditorGUI.ErrorMessageBox("No BlockLibrary asset found.");
6666
if (GUILayout.Button("Create BlockLibrary"))
67-
{
6867
CreateLibrary();
69-
}
70-
7168
return;
7269
}
7370

@@ -108,14 +105,14 @@ private void CreateLibrary()
108105
AssetDatabase.Refresh();
109106

110107
_blockLibrary = asset;
111-
Debug.Log("BlockLibrary created at " + path);
108+
Debug.Log("BlockLibrary created at " + path);
112109
}
113110

114111
private void DrawSelectedBlockSection()
115112
{
116113
SirenixEditorGUI.BeginBox();
117114
SirenixEditorGUI.BeginBoxHeader();
118-
SirenixEditorGUI.Title("🎯 Selected Block", null, TextAlignment.Center, true);
115+
SirenixEditorGUI.Title("Selected Block", null, TextAlignment.Center, true);
119116
SirenixEditorGUI.EndBoxHeader();
120117

121118
if (_selectedBlock == null)
@@ -132,16 +129,15 @@ private void DrawSelectedBlockSection()
132129
EditorGUILayout.EndHorizontal();
133130

134131
GUILayout.Space(8);
135-
136-
// Поля редактирования DTO
132+
137133
_blockDraft.Id = EditorGUILayout.TextField("ID", _blockDraft.Id);
138134
_blockDraft.Icon = (Sprite)EditorGUILayout.ObjectField("Icon", _blockDraft.Icon, typeof(Sprite), false);
139135
_blockDraft.Prefab =
140136
(GameObject)EditorGUILayout.ObjectField("Prefab", _blockDraft.Prefab, typeof(GameObject), false);
141137

142138
GUILayout.Space(4);
143139

144-
if (GUILayout.Button("💾 Apply Changes", GUILayout.Height(25)))
140+
if (GUILayout.Button("Apply Changes", GUILayout.Height(25)))
145141
{
146142
_blockDraft.ApplyTo(_selectedBlock);
147143
}
@@ -150,7 +146,7 @@ private void DrawSelectedBlockSection()
150146
SirenixEditorGUI.EndBox();
151147
}
152148

153-
[HorizontalGroup("🔍 Search & Sort/SortRow", width: 25)]
149+
[HorizontalGroup("Search & Sort/SortRow", width: 25)]
154150
[Button("@_sortAscending ? \"\" : \"\"", ButtonSizes.Medium)]
155151
[PropertyOrder(1)]
156152
private void ToggleSortDirection() => _sortAscending = !_sortAscending;
@@ -159,7 +155,7 @@ private void DrawExistingBlocks()
159155
{
160156
SirenixEditorGUI.BeginBox();
161157
SirenixEditorGUI.BeginBoxHeader();
162-
SirenixEditorGUI.Title("📦 Existing Blocks", null, TextAlignment.Center, true);
158+
SirenixEditorGUI.Title("Existing Blocks", null, TextAlignment.Center, true);
163159
SirenixEditorGUI.EndBoxHeader();
164160

165161
if (_blockLibrary.AllBlocks == null || _blockLibrary.AllBlocks.Count == 0)
@@ -172,9 +168,7 @@ private void DrawExistingBlocks()
172168
var blocks = new List<BlockDataEditor>(_blockLibrary.AllBlocks);
173169

174170
if (!string.IsNullOrEmpty(_searchFilter))
175-
{
176171
blocks = blocks.FindAll(b => b != null && b.ID.ToLower().Contains(_searchFilter.ToLower()));
177-
}
178172

179173
blocks.Sort((a, b) =>
180174
{
@@ -193,7 +187,8 @@ private void DrawExistingBlocks()
193187

194188
foreach (var block in blocks)
195189
{
196-
if (block == null) continue;
190+
if (block == null)
191+
continue;
197192

198193
SirenixEditorGUI.BeginBox();
199194
SirenixEditorGUI.BeginBoxHeader();
@@ -248,9 +243,9 @@ private void DrawExistingBlocks()
248243
SirenixEditorGUI.EndBox();
249244
}
250245

251-
[BoxGroup("🧱 Create Block")]
246+
[BoxGroup("Create Block")]
252247
[GUIColor(0.2f, 0.8f, 0.2f)]
253-
[Button("🚀 Create New Block", ButtonSizes.Large)]
248+
[Button("Create New Block", ButtonSizes.Large)]
254249
[EnableIf("@!string.IsNullOrEmpty(_newBlockId) && _newBlockSprite != null")]
255250
private void CreateNewBlock()
256251
{
@@ -273,7 +268,7 @@ private void CreateNewBlock()
273268
EditorUtility.SetDirty(_blockLibrary);
274269
AssetDatabase.SaveAssets();
275270

276-
Debug.Log($"Created new block: {_newBlockId}");
271+
Debug.Log($"Created new block: {_newBlockId}");
277272
}
278273

279274
private int SafeCompare(UnityEngine.Object a, UnityEngine.Object b)

Assets/Code/LevelEditor/BlockPopupWindow.cs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#if UNITY_EDITOR
2-
using UnityEditor;
3-
using UnityEngine;
42
using System;
53
using System.Collections.Generic;
64
using System.Linq;
5+
using UnityEditor;
6+
using UnityEngine;
77

88
namespace Code.LevelEditor
99
{
@@ -160,7 +160,8 @@ private void DrawBlockList()
160160
private void DrawSelectedCellsList()
161161
{
162162
_showSelectionList = EditorGUILayout.Foldout(_showSelectionList, "\U0001f7e9 Selected Cells Details", true);
163-
if (!_showSelectionList) return;
163+
if (!_showSelectionList)
164+
return;
164165

165166
_searchFilter = EditorGUILayout.TextField("Search", _searchFilter);
166167

@@ -184,7 +185,7 @@ private void DrawSelectedCellsList()
184185
if (cell.Block?.Icon != null)
185186
GUILayout.Label(cell.Block.Icon.texture, GUILayout.Width(32), GUILayout.Height(32));
186187
else
187-
GUILayout.Label("", GUILayout.Width(32), GUILayout.Height(32));
188+
GUILayout.Label("-", GUILayout.Width(32), GUILayout.Height(32));
188189

189190
EditorGUILayout.LabelField(label);
190191
EditorGUILayout.EndHorizontal();
@@ -199,20 +200,23 @@ private void DrawSelectedCellsList()
199200
private void DrawRotationButtons()
200201
{
201202
GUILayout.BeginHorizontal();
202-
if (GUILayout.Button("↑\n0°")) _onRotationSelected?.Invoke(0);
203-
if (GUILayout.Button("→\n90°")) _onRotationSelected?.Invoke(90);
204-
if (GUILayout.Button("↓\n180°")) _onRotationSelected?.Invoke(180);
205-
if (GUILayout.Button("←\n270°")) _onRotationSelected?.Invoke(270);
203+
if (GUILayout.Button("↑\n0°"))
204+
_onRotationSelected?.Invoke(0);
205+
if (GUILayout.Button("→\n90°"))
206+
_onRotationSelected?.Invoke(90);
207+
if (GUILayout.Button("↓\n180°"))
208+
_onRotationSelected?.Invoke(180);
209+
if (GUILayout.Button("←\n270°"))
210+
_onRotationSelected?.Invoke(270);
206211
GUILayout.EndHorizontal();
207212
}
208213

209214
private void DrawCopyPasteButtons()
210215
{
211216
GUILayout.BeginHorizontal();
212-
213-
// КНОПКА КОПИРОВАНИЯ
217+
214218
GUI.backgroundColor = new Color(0.8f, 0.8f, 1f);
215-
if (GUILayout.Button("📋 Copy", GUILayout.Height(25)))
219+
if (GUILayout.Button("Copy", GUILayout.Height(25)))
216220
{
217221
_copiedCells.Clear();
218222

@@ -231,25 +235,24 @@ private void DrawCopyPasteButtons()
231235
}
232236
}
233237

234-
Debug.Log($"📋 Copied {_copiedCells.Count} cells");
238+
Debug.Log($"Copied {_copiedCells.Count} cells");
235239
}
236240
else
237241
{
238-
Debug.LogWarning("No cells selected to copy.");
242+
Debug.LogWarning("No cells selected to copy.");
239243
}
240244
}
241-
242-
// КНОПКА ВСТАВКИ
245+
243246
GUI.backgroundColor = new Color(0.7f, 1f, 0.7f);
244-
if (GUILayout.Button("📌 Paste", GUILayout.Height(25)))
247+
if (GUILayout.Button("Paste", GUILayout.Height(25)))
245248
{
246249
if (_copiedCells == null || _copiedCells.Count == 0)
247250
{
248-
Debug.LogWarning("Nothing copied to paste.");
251+
Debug.LogWarning("Nothing copied to paste.");
249252
}
250253
else if (_currentSelection == null || _currentSelection.Count == 0)
251254
{
252-
Debug.LogWarning("No cells selected to paste into.");
255+
Debug.LogWarning("No cells selected to paste into.");
253256
}
254257
else
255258
{
@@ -272,7 +275,7 @@ private void DrawCopyPasteButtons()
272275
}
273276
}
274277

275-
Debug.Log($"📌 Pasted {pasteCount} cells starting from [{firstTarget.x},{firstTarget.y}]");
278+
Debug.Log($"Pasted {pasteCount} cells starting from [{firstTarget.x},{firstTarget.y}]");
276279
}
277280
}
278281

@@ -284,9 +287,7 @@ private void DrawClearButton()
284287
{
285288
GUI.backgroundColor = new Color(1f, 0.3f, 0.3f);
286289
if (GUILayout.Button("🗑 Clear Block(s)", GUILayout.Height(30)))
287-
{
288290
_onClear?.Invoke();
289-
}
290291

291292
GUI.backgroundColor = Color.white;
292293
}

Assets/Code/LevelEditor/LevelCell.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ namespace Code.LevelEditor
77
public class LevelCell
88
{
99
public BlockDataEditor Block;
10-
[SerializeField] public Quaternion Rotation = Quaternion.identity;
10+
public Quaternion Rotation = Quaternion.identity;
1111
}
1212
}

Assets/Code/LevelEditor/LevelHegsagonEditor.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ private void DrawRotationArrow(Rect rect, Quaternion rotation)
149149
private void DrawSelectionOverlay(Rect rect, int x, int y)
150150
{
151151
if (_currentSelection.Contains(new Vector2Int(x, y)))
152-
{
153152
EditorGUI.DrawRect(rect, new Color(0f, 1f, 0f, 0.25f));
154-
}
155153
}
156154

157155
private void HandleCellInteraction(Rect rect, int x, int y)
@@ -273,7 +271,7 @@ private void ClearBlock(LevelCell fallbackCell)
273271
private void MarkDirty()
274272
{
275273
GUI.changed = true;
276-
UnityEditor.EditorUtility.SetDirty(this);
274+
EditorUtility.SetDirty(this);
277275
UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
278276
}
279277

Assets/Code/LevelEditor/LevelMatrixEditor.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ private LevelCell DrawLevelCell(Rect rect, LevelCell cell, int x, int y)
4848

4949
private void LoadLibrary()
5050
{
51-
if (cachedLibrary != null) return;
51+
if (cachedLibrary != null)
52+
return;
5253

5354
string[] guids = UnityEditor.AssetDatabase.FindAssets("t:BlockLibrary");
54-
if (guids.Length == 0) return;
55+
if (guids.Length == 0)
56+
return;
5557

5658
string path = UnityEditor.AssetDatabase.GUIDToAssetPath(guids[0]);
5759
cachedLibrary = UnityEditor.AssetDatabase.LoadAssetAtPath<BlockLibrary>(path);
@@ -158,17 +160,16 @@ private void HandleCellInteraction(Rect rect, int x, int y)
158160

159161
private void ShowContextMenu(LevelCell cell, int x, int y)
160162
{
161-
if (cachedLibrary == null) return;
163+
if (cachedLibrary == null)
164+
return;
162165

163166
Vector2 screenPos = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);
164167
Vector2 windowSize = new Vector2(350, 550);
165168
Rect rect = new Rect(screenPos, windowSize);
166169

167170
Vector2Int clickedPos = new Vector2Int(x, y);
168171
if (currentSelection == null || !currentSelection.Contains(clickedPos))
169-
{
170172
currentSelection = new List<Vector2Int> { clickedPos };
171-
}
172173

173174
BlockPopupWindow.LevelEditorHelpers.TryGetCell = pos => GetCell(pos);
174175

@@ -262,8 +263,10 @@ public IEnumerable<Vector2Int> GetAllOfType(BlockDataEditor type)
262263

263264
private void ResizeGrid()
264265
{
265-
if (width <= 0) width = 1;
266-
if (height <= 0) height = 1;
266+
if (width <= 0)
267+
width = 1;
268+
if (height <= 0)
269+
height = 1;
267270

268271
var newGrid = new LevelCell[width, height];
269272

0 commit comments

Comments
 (0)