@@ -17,6 +17,7 @@ public partial class Form1 : Form
17
17
public static Dictionary < string , string > unityList = new Dictionary < string , string > ( ) ;
18
18
const string contextRegRoot = "Software\\ Classes\\ Directory\\ Background\\ shell" ;
19
19
bool isDownloadUnityList = false ;
20
+ const string launcherArgumentsFile = "LauncherArguments.txt" ;
20
21
21
22
22
23
public Form1 ( )
@@ -286,9 +287,14 @@ void FilterRecentProject(object sender, EventArgs e)
286
287
SetStatus ( "Filtering recent projects list.." ) ;
287
288
foreach ( DataGridViewRow recentProject in gridRecent . Rows )
288
289
{
289
- if ( recentProject . Cells [ "_project" ] . Value . ToString ( ) . ToLower ( ) . Contains ( tbSearchBar . Text . ToLower ( ) ) )
290
+ if ( recentProject . Cells [ "_project" ] . Value . ToString ( ) . IndexOf ( tbSearchBar . Text , StringComparison . OrdinalIgnoreCase ) > - 1 )
291
+ {
290
292
recentProject . Visible = true ;
291
- else recentProject . Visible = false ;
293
+ }
294
+ else
295
+ {
296
+ recentProject . Visible = false ;
297
+ }
292
298
}
293
299
}
294
300
@@ -365,7 +371,13 @@ void UpdateRecentProjectsList()
365
371
// get project version
366
372
string projectVersion = GetProjectVersion ( projectPath ) ;
367
373
368
- gridRecent . Rows . Add ( projectName , projectVersion , projectPath , lastUpdated ) ;
374
+ // get custom launch arguments,TODO if enabled
375
+ string customArgs = ReadCustomLaunchArguments ( projectPath ) ;
376
+
377
+ // get git branchinfo,TODO if enabled
378
+ string gitBranch = ReadGitBranchInfo ( projectPath ) ;
379
+
380
+ gridRecent . Rows . Add ( projectName , projectVersion , projectPath , lastUpdated , customArgs , gitBranch ) ;
369
381
gridRecent . Rows [ gridRecent . Rows . Count - 1 ] . Cells [ 1 ] . Style . ForeColor = HaveExactVersionInstalled ( projectVersion ) ? Color . Green : Color . Red ;
370
382
}
371
383
}
@@ -420,6 +432,14 @@ void LaunchProject(string projectPath, string version, bool openProject = true)
420
432
if ( openProject == true )
421
433
{
422
434
var pars = " -projectPath " + "\" " + projectPath + "\" " ;
435
+
436
+ // check for custom launch parameters and append them
437
+ string customArguments = GetSelectedRowData ( "_launchArguments" ) ;
438
+ if ( string . IsNullOrEmpty ( customArguments ) == false )
439
+ {
440
+ pars += " " + customArguments ;
441
+ }
442
+
423
443
myProcess . StartInfo . Arguments = pars ;
424
444
}
425
445
myProcess . Start ( ) ;
@@ -627,6 +647,8 @@ void LaunchSelectedProject(bool openProject = true)
627
647
}
628
648
}
629
649
650
+
651
+
630
652
void LaunchSelectedUnity ( )
631
653
{
632
654
var selected = gridUnityList . CurrentCell . RowIndex ;
@@ -827,7 +849,9 @@ private void unityGridView_KeyDown(object sender, KeyEventArgs e)
827
849
/// <param name="e"></param>
828
850
private void Form1_KeyPress ( object sender , KeyPressEventArgs e )
829
851
{
830
- //Console.WriteLine((int)e.KeyChar);
852
+ // if editing cells, dont focus on search
853
+ if ( gridRecent . IsCurrentCellInEditMode == true ) return ;
854
+
831
855
switch ( ( int ) e . KeyChar )
832
856
{
833
857
case 27 : // ESC - clear search
@@ -860,7 +884,9 @@ private void Form1_KeyPress(object sender, KeyPressEventArgs e)
860
884
/// <param name="e"></param>
861
885
private void gridRecent_KeyDown ( object sender , KeyEventArgs e )
862
886
{
863
- //Console.WriteLine(e.KeyValue);
887
+ // if editing cells, dont search or launch
888
+ if ( gridRecent . IsCurrentCellInEditMode == true ) return ;
889
+
864
890
switch ( e . KeyCode )
865
891
{
866
892
case Keys . Return : // launch selected project
@@ -1197,5 +1223,67 @@ private void UnityVersionsListDownloaded(object sender, DownloadStringCompletedE
1197
1223
gridUnityUpdates . Rows . Add ( row [ 3 ] , row [ 6 ] . Trim ( '"' ) ) ;
1198
1224
}
1199
1225
}
1226
+
1227
+ // after editing launch arguments cell
1228
+ private void gridRecent_CellEndEdit ( object sender , DataGridViewCellEventArgs e )
1229
+ {
1230
+ string path = GetSelectedRowData ( "_path" ) ;
1231
+ if ( string . IsNullOrEmpty ( path ) ) return ;
1232
+
1233
+
1234
+ string arguments = GetSelectedRowData ( "_launchArguments" ) ;
1235
+
1236
+ // save arguments to projectsettings folder
1237
+ string outputFile = Path . Combine ( path , "ProjectSettings" , launcherArgumentsFile ) ;
1238
+
1239
+ try
1240
+ {
1241
+ StreamWriter sw = new StreamWriter ( outputFile ) ;
1242
+ sw . WriteLine ( arguments ) ;
1243
+ sw . Close ( ) ;
1244
+ }
1245
+ catch ( Exception exception )
1246
+ {
1247
+ SetStatus ( "File error: " + exception . Message ) ;
1248
+ }
1249
+ // TODO: keep current row selected
1250
+ }
1251
+
1252
+ // returns currently selected rows path string
1253
+ string GetSelectedRowData ( string key )
1254
+ {
1255
+ string path = null ;
1256
+ var selected = gridRecent . CurrentCell . RowIndex ;
1257
+ if ( selected > - 1 )
1258
+ {
1259
+ path = gridRecent . Rows [ selected ] . Cells [ key ] . Value ? . ToString ( ) ;
1260
+ }
1261
+ return path ;
1262
+ }
1263
+
1264
+ string ReadCustomLaunchArguments ( string projectPath )
1265
+ {
1266
+ string results = null ;
1267
+ string argumentsFile = Path . Combine ( projectPath , "ProjectSettings" , launcherArgumentsFile ) ;
1268
+ if ( File . Exists ( argumentsFile ) == true )
1269
+ {
1270
+ results = File . ReadAllText ( argumentsFile ) ;
1271
+ }
1272
+ return results ;
1273
+ }
1274
+
1275
+ string ReadGitBranchInfo ( string projectPath )
1276
+ {
1277
+ string results = null ;
1278
+ string branchFile = Path . Combine ( projectPath , ".git" , "HEAD" ) ;
1279
+ if ( File . Exists ( branchFile ) == true )
1280
+ {
1281
+ results = File . ReadAllText ( branchFile ) ;
1282
+ // get branch only
1283
+ int pos = results . LastIndexOf ( "/" ) + 1 ;
1284
+ results = results . Substring ( pos , results . Length - pos ) ;
1285
+ }
1286
+ return results ;
1287
+ }
1200
1288
}
1201
1289
}
0 commit comments