1
- using Prowl . Editor . Preferences ;
1
+ using Prowl . Editor . Assets ;
2
+ using Prowl . Editor . Preferences ;
2
3
using Prowl . Icons ;
3
4
using Prowl . Runtime ;
4
5
using Prowl . Runtime . GUI ;
5
6
using Prowl . Runtime . GUI . Graphics ;
7
+ using Prowl . Runtime . GUI . Layout ;
6
8
7
9
namespace Prowl . Editor
8
10
{
@@ -73,9 +75,16 @@ private void DrawProjectsTab()
73
75
var folders = new DirectoryInfo ( Project . Projects_Directory ) . EnumerateDirectories ( ) ;
74
76
folders = folders . OrderByDescending ( ( x ) => x . LastWriteTimeUtc ) ;
75
77
76
- foreach ( var projectFolder in folders )
77
- if ( string . IsNullOrEmpty ( _searchText ) || projectFolder . Name . Contains ( _searchText , StringComparison . OrdinalIgnoreCase ) )
78
- DisplayProject ( projectFolder . Name ) ;
78
+ if ( folders . Count ( ) == 0 )
79
+ {
80
+ gui . Draw2D . DrawText ( "No projects found! Navigate to the 'Create' tab to start a new project" , rect ) ;
81
+ }
82
+ else
83
+ {
84
+ foreach ( var projectFolder in folders )
85
+ if ( string . IsNullOrEmpty ( _searchText ) || projectFolder . Name . Contains ( _searchText , StringComparison . OrdinalIgnoreCase ) )
86
+ DisplayProject ( projectFolder . Name ) ;
87
+ }
79
88
}
80
89
81
90
using ( gui . Node ( "OpenBtn" ) . TopLeft ( Offset . Percentage ( 1f , - 162 ) , Offset . Percentage ( 1f , - 60 ) ) . Scale ( 162 , 60 ) . Enter ( ) )
@@ -101,6 +110,8 @@ private void DrawProjectsTab()
101
110
}
102
111
}
103
112
}
113
+
114
+ string ? contextMenuProject = null ;
104
115
private void DisplayProject ( string name )
105
116
{
106
117
var proj = Project . GetPath ( name ) ;
@@ -123,14 +134,63 @@ private void DisplayProject(string name)
123
134
gui . Draw2D . DrawRect ( gui . CurrentNode . LayoutData . Rect , new ( 0.7f , 0.7f , 0.7f , 1f ) , 1 , 2 ) ;
124
135
}
125
136
else if ( interact . IsHovered ( ) )
137
+ {
126
138
gui . Draw2D . DrawRectFilled ( gui . CurrentNode . LayoutData . Rect , new ( 0.1f , 0.1f , 0.1f , 0.4f ) , 2 ) ;
139
+ }
140
+
141
+ using ( gui . Node ( "ProjectOptionsBtn" ) . Top ( new Offset ( 8 , LayoutValueType . Pixel ) ) . Left ( new Offset ( rect . width - 32 , LayoutValueType . Pixel ) ) . Height ( 24 ) . Width ( 24 ) . Enter ( ) )
142
+ {
143
+ rect = gui . CurrentNode . LayoutData . Rect ;
144
+ if ( gui . IsNodePressed ( ) )
145
+ {
146
+ // Got to be a better way than doing this
147
+ contextMenuProject = name ;
148
+ gui . OpenPopup ( "ProjectOptionsContextMenu" , null , gui . CurrentNode . Parent ) ;
149
+ }
150
+ else if ( gui . IsNodeHovered ( ) )
151
+ {
152
+ gui . Draw2D . DrawRectFilled ( rect , new ( 0.1f , 0.1f , 0.1f , 1f ) , 2 ) ;
153
+ }
154
+
155
+ // Text centering/alignment functions?
156
+ UIDrawList . DefaultFont . CalcTextSizeA ( out Vector2 textSize , 20 , rect . width , rect . width , "..." , 0 ) ;
157
+ gui . Draw2D . DrawText ( UIDrawList . DefaultFont , "..." , 20 , rect . Position + new Vector2 ( textSize . x * 0.5f , 0 ) , Color . white ) ;
158
+ }
159
+
160
+ // Outside ProjectOptionsBtn node as it wouldn't render (or too small in size?)
161
+ if ( contextMenuProject != null && contextMenuProject . Equals ( name ) )
162
+ {
163
+ DrawProjectContextMenu ( proj ) ;
164
+ }
127
165
//else if (interact.IsDoubleClicked())
128
166
//{
129
167
// Project.Open(name);
130
168
// isOpened = false;
131
169
//}
132
170
}
171
+ }
133
172
173
+ private void DrawProjectContextMenu ( DirectoryInfo proj )
174
+ {
175
+ bool closePopup = false ;
176
+ if ( gui . BeginPopup ( "ProjectOptionsContextMenu" , out var popupHolder ) && popupHolder != null )
177
+ {
178
+ using ( popupHolder . Width ( 180 ) . Padding ( 5 ) . Layout ( LayoutType . Column ) . Spacing ( 5 ) . FitContentHeight ( ) . Enter ( ) )
179
+ {
180
+ // Add options
181
+ // - Delete project (with popup confirmation)
182
+ if ( EditorGUI . StyledButton ( "Show In Explorer" ) )
183
+ {
184
+ AssetDatabase . OpenPath ( proj ) ;
185
+ closePopup = true ;
186
+ }
187
+ }
188
+ }
189
+ if ( closePopup )
190
+ {
191
+ contextMenuProject = null ;
192
+ gui . ClosePopup ( popupHolder ) ;
193
+ }
134
194
}
135
195
136
196
private string GetFormattedLastModifiedTime ( DateTime lastModified )
0 commit comments