Skip to content

Commit

Permalink
Added icons to show whether the game is connected or disconnected
Browse files Browse the repository at this point in the history
Added better output when attempting to launch the game in edit mode but failing.
  • Loading branch information
vchelaru committed Sep 17, 2023
1 parent 2cc32f9 commit f85c5fb
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 52 deletions.
56 changes: 14 additions & 42 deletions FRBDK/Glue/CompilerLibrary/ViewModels/CompilerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ public bool IsCompiling
set => Set(value);
}

public bool IsConnectedToGame
{
get => Get<bool>();
set => Set(value);
}

[DependsOn(nameof(IsRunning))]
[DependsOn(nameof(IsConnectedToGame))]
public Visibility ConnectedButtonVisibility => (IsRunning && IsConnectedToGame).ToVisibility();

[DependsOn(nameof(IsRunning))]
[DependsOn(nameof(IsConnectedToGame))]
public Visibility CancelButtonVisibility => (IsRunning && !IsConnectedToGame).ToVisibility();

[DependsOn(nameof(IsCompiling))]
public Visibility BuildingActivitySpinnerVisibility => IsCompiling.ToVisibility();

Expand Down Expand Up @@ -337,55 +351,13 @@ public bool IsEditChecked
[DependsOn(nameof(PlayOrEdit))]
public Visibility FocusButtonVisibility => (PlayOrEdit == PlayOrEdit.Edit).ToVisibility();

public double LastWaitTimeInSeconds
{
get => Get<double>();
set => Set(value);
}

[DependsOn(nameof(PlayOrEdit))]
[DependsOn(nameof(IsRunning))]
public Visibility ConnectedFrameVisibility
{
get => (PlayOrEdit == PlayOrEdit.Edit && IsRunning).ToVisibility();
}

[DependsOn(nameof(LastWaitTimeInSeconds))]
public string ConnectedString
{
get
{
if(LastWaitTimeInSeconds < 1)
{
return $"Connected {LastWaitTimeInSeconds:0.0}";
}
else
{
return $"Waiting for game {LastWaitTimeInSeconds:0.0}";
}
}
}

[DependsOn(nameof(LastWaitTimeInSeconds))]
public Brush ConnectedFrameBackgroundColor
{
get
{
if(LastWaitTimeInSeconds < 1)
{
return Brushes.Green;
}
else if(LastWaitTimeInSeconds < 3)
{
return Brushes.Yellow;
}
else
{
return Brushes.Red;
}
}
}

public bool HasDraggedTreeNodeOverView
{
get => Get<bool>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
<ItemGroup>
<None Remove="GlueControl\Icons\AdvanceOneFrame.png" />
<None Remove="GlueControl\Icons\build.png" />
<None Remove="GlueControl\Icons\Connected.png" />
<None Remove="GlueControl\Icons\Disconnected.png" />
<None Remove="GlueControl\Icons\Edit.png" />
<None Remove="GlueControl\Icons\EditDeselected.png" />
<None Remove="GlueControl\Icons\FirewallEnablePopup.png" />
Expand Down Expand Up @@ -151,6 +153,8 @@
<ItemGroup>
<Resource Include="GlueControl\Icons\AdvanceOneFrame.png" />
<Resource Include="GlueControl\Icons\build.png" />
<Resource Include="GlueControl\Icons\Connected.png" />
<Resource Include="GlueControl\Icons\Disconnected.png" />
<Resource Include="GlueControl\Icons\Edit.png" />
<Resource Include="GlueControl\Icons\EditDeselected.png" />
<Resource Include="GlueControl\Icons\FirewallEnablePopup.png" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,21 @@ public class CommandSender

public GlueViewSettingsViewModel GlueViewSettingsViewModel { get; set; }
public CompilerViewModel CompilerViewModel { get; set; }
public bool IsConnected { get; internal set; }

bool isConnected;
public bool IsConnected
{
get => isConnected;
internal set
{
isConnected = value;

if (CompilerViewModel != null)
{
CompilerViewModel.IsConnectedToGame = value;
}
}
}

public static CommandSender Self { get; private set; }

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ private async Task ReactToPlayOrEditSet()

if (response?.Succeeded != true)
{
var message = "Failed to change game/edit mode. ";
var message = $"Failed to set game/edit mode to {CompilerViewModel.PlayOrEdit}.";
if (response == null)
{
message += "Game sent no response back.";
Expand All @@ -763,10 +763,11 @@ private async Task ReactToPlayOrEditSet()
message += response.Message;
}
ReactToPluginEvent("Compiler_Output_Standard", message);
GlueCommands.Self.PrintOutput(message);
}
else if (CommandSender.Self.IsConnected == false)
{

var message = $"Failed to set game/edit mode to {CompilerViewModel.PlayOrEdit} because the game is not connected.";
}
else if (inEditMode)
{
Expand Down Expand Up @@ -827,8 +828,8 @@ private async Task ReactToPlayOrEditSet()
{
if(displaySettings != null &&
displaySettings.AspectRatioHeight > 0 &&
displaySettings.FixedAspectRatio == true
)
// need to reearch at some time - do we want to worry about variable aspect ratio?
displaySettings.AspectRatioBehavior == AspectRatioBehavior.FixedAspectRatio)
{
setCameraAspectRatioDto.AspectRatio = GlueState.Self.CurrentGlueProject.DisplaySettings.AspectRatioWidth /
GlueState.Self.CurrentGlueProject.DisplaySettings.AspectRatioHeight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ class FileChangeManager
private RefreshManager _refreshManager;
CompilerViewModel viewModel;

string[] ignoredFilesForCopying = new[]
{
"gum_events.json",
"GumLastChangeFilePath.txt"
};


public FileChangeManager(Action<string> output, CompilerViewModel viewModel, RefreshManager refreshManager)
{
this._output = output;
Expand Down Expand Up @@ -68,7 +75,15 @@ private bool IsFileIgnored(FilePath fileName)
{
var settingsFolder = GlueState.Self.ProjectSpecificSettingsPath;

return settingsFolder.IsRootOf(fileName);
if(settingsFolder.IsRootOf(fileName))
{
return true;
}


var strippedFileName = fileName.NoPath;

return ignoredFilesForCopying.Contains(strippedFileName);
}

private void OutputSuccessOrFailure(bool succeeded)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,27 @@
</WrapPanel>

<StackPanel x:Name="AlwaysVisibleStack" HorizontalAlignment="Right" Orientation="Horizontal" Margin="2" Grid.Column="1">

<Image Height="24"
Source="/GameCommunicationPlugin;component/GlueControl/Icons/Connected.png"
Visibility="{Binding ConnectedButtonVisibility}">
<Image.ToolTip>
<TextBlock>Connected to game</TextBlock>
</Image.ToolTip>
</Image>
<Image Height="24"
Source="/GameCommunicationPlugin;component/GlueControl/Icons/Disconnected.png"
Visibility="{Binding CancelButtonVisibility}">
<Image.ToolTip>
<TextBlock>Disconnected from game</TextBlock>
</Image.ToolTip>
</Image>

<Grid Visibility="{Binding MessageAboutEditModeDisabledVisibility}">
<Frame Background="Yellow" BorderBrush="DarkGray" BorderThickness="1"/>
<Frame Margin="0,3,0,3" Background="Yellow" BorderBrush="DarkGray" BorderThickness="1"/>
<TextBlock Margin="3" VerticalAlignment="Center">Enable Game Embed and Edit in Settings</TextBlock>
</Grid>
<Button VerticalAlignment="Top" Width="24" Click="GlueViewSettingsButtonClicked">
<Button VerticalAlignment="Center" Width="24" Click="GlueViewSettingsButtonClicked" Margin="2,0,0,0">
<Image IsHitTestVisible="False" Source="/GameCommunicationPlugin;component/GlueControl/Icons/Settings.png"></Image>
</Button>
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,9 @@ public void CopyToBuildFolder(FilePath absoluteSource)
}, $"{nameof(CopyToBuildFolder)} {absoluteSource}");
}

private static void CopyToBuildFolder(FilePath absoluteSource, string debugPath)
private static void CopyToBuildFolder(FilePath absoluteSource, string outputPathRelativeToCsProj)
{
string buildFolder = FileManager.GetDirectory(GlueState.Self.CurrentCodeProjectFileName.FullPath) + debugPath + "Content/";
string buildFolder = FileManager.GetDirectory(GlueState.Self.CurrentCodeProjectFileName.FullPath) + outputPathRelativeToCsProj + "Content/";
string destination = buildFolder + FileManager.MakeRelative(absoluteSource.FullPath, GlueState.Self.ContentDirectory);

string destinationFolder = FileManager.GetDirectory(destination);
Expand Down

0 comments on commit f85c5fb

Please sign in to comment.