Skip to content

Commit d91f9a8

Browse files
committed
add initial build status icon, add output log to context menu builds (into parent of build folder), add SetStatus and SetBuildStatus methods to Tools.cs (using mainwindow reference)
1 parent f1ed815 commit d91f9a8

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

UnityLauncherPro/MainWindow.xaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,8 +715,13 @@
715715
</TabControl>
716716

717717
<Grid Grid.Row="2" UseLayoutRounding="False">
718-
<StatusBar VerticalAlignment="Bottom" Margin="3,1,20,1" Background="{x:Null}" Foreground="{DynamicResource ThemeStatusText}">
719-
<TextBlock x:Name="txtStatus" Margin="6,1,3,0" VerticalAlignment="Center" Text="Ready"/>
718+
<StatusBar VerticalAlignment="Center" Margin="3,0,15,0" Background="{x:Null}" Foreground="{DynamicResource ThemeStatusText}">
719+
<StatusBarItem>
720+
<TextBlock x:Name="txtStatus" Margin="6,0,3,0" VerticalAlignment="Center" Text="Ready"/>
721+
</StatusBarItem>
722+
<StatusBarItem HorizontalAlignment="Right">
723+
<Label x:Name="btnBuildStatus" Content="" ToolTip="Builds" Foreground="{DynamicResource ThemeButtonForegroundDisabled}" Padding="0,0,0,0"/>
724+
</StatusBarItem>
720725
</StatusBar>
721726
</Grid>
722727
</Grid>

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ void Init()
8686
Resizable_BorderLess_Chrome.CaptionHeight = 1.0;
8787
WindowChrome.SetWindowChrome(this, Resizable_BorderLess_Chrome);
8888

89+
Tools.mainWindow = this;
90+
8991
// need to load here to get correct window size early
9092
LoadSettings();
9193
}
@@ -3033,11 +3035,16 @@ private void Window_MouseDown(object sender, MouseButtonEventArgs e)
30333035
gridSettingsBg.Focus();
30343036
}
30353037

3036-
void SetStatus(string msg)
3038+
public void SetStatus(string msg)
30373039
{
30383040
txtStatus.Text = msg;
30393041
}
30403042

3043+
public void SetBuildStatus(System.Windows.Media.Color color)
3044+
{
3045+
btnBuildStatus.Foreground = new SolidColorBrush(color);
3046+
}
3047+
30413048
private void btnPatchHubConfig_Click(object sender, RoutedEventArgs e)
30423049
{
30433050
// read the config file from %APPDATA%

UnityLauncherPro/Tools.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Windows;
1313
using System.Windows.Controls;
1414
using System.Windows.Input;
15+
using System.Windows.Media;
1516
using UnityLauncherPro.Helpers;
1617

1718
namespace UnityLauncherPro
@@ -1378,6 +1379,11 @@ public static void OpenAppdataSpecialFolder(string subfolder)
13781379
public static void BuildProject(Project proj, Platform platform)
13791380
{
13801381
Console.WriteLine("Building " + proj.Title + " for " + platform);
1382+
SetStatus("Build process started: " + DateTime.Now.ToString("HH:mm:ss"));
1383+
1384+
// TODO use theme colors, keep list of multiple builds, if click status button show list of builds, if click for single build (show output folder)
1385+
SetBuildStatus(Colors.Red);
1386+
13811387
if (string.IsNullOrEmpty(proj.Path)) return;
13821388

13831389
// create builder script template (with template string, that can be replaced with project related paths or names?)
@@ -1454,7 +1460,7 @@ static string[] GetScenes()
14541460

14551461
// create commandline string for building and launch it
14561462
//var buildcmd = $"\"{unityExePath}\" -quit -batchmode -nographics -projectPath \"{proj.Path}\" -executeMethod \"Builder.BuildAndroid\" -buildTarget android -logFile -";
1457-
var buildParams = $" -quit -batchmode -nographics -projectPath \"{proj.Path}\" -executeMethod \"UnityLauncherProTools.Build{platform}\" -buildTarget {platform} -logFile -";
1463+
var buildParams = $" -quit -batchmode -nographics -projectPath \"{proj.Path}\" -executeMethod \"UnityLauncherProTools.Build{platform}\" -buildTarget {platform} -logFile \"{outputFolder}/../build.log\"";
14581464
Console.WriteLine("buildcmd= " + buildParams);
14591465

14601466
// launch build
@@ -1465,6 +1471,9 @@ static string[] GetScenes()
14651471
{
14661472
Console.WriteLine("Build process exited: " + outputFolder);
14671473
Tools.ExploreFolder(outputFolder);
1474+
SetStatus("Build process finished: " + DateTime.Now.ToString("HH:mm:ss"));
1475+
// TODO set color based on results
1476+
SetBuildStatus(Colors.Green);
14681477
};
14691478

14701479
}
@@ -1754,6 +1763,19 @@ internal static string GetBytesReadable(long i)
17541763
return readable.ToString("0.### ") + suffix;
17551764
}
17561765

1766+
public static MainWindow mainWindow;
1767+
1768+
// set status bar in main thread
1769+
public static void SetStatus(string text)
1770+
{
1771+
mainWindow.Dispatcher.Invoke(() => { mainWindow.SetStatus(text); });
1772+
}
1773+
1774+
public static void SetBuildStatus(Color color)
1775+
{
1776+
mainWindow.Dispatcher.Invoke(() => { mainWindow.SetBuildStatus(color); });
1777+
}
1778+
17571779
} // class
17581780

17591781
} // namespace

0 commit comments

Comments
 (0)