Skip to content

Commit 24c8cf6

Browse files
committed
Content bundle load dialog fixes
Change title to say "Loading". Fix "not a content bundle" error state. Fixes #146
1 parent 366d35f commit 24c8cf6

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

SS14.Launcher/ViewModels/ConnectingViewModel.cs

+21-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class ConnectingViewModel : ViewModelBase
1313
private readonly Connector _connector;
1414
private readonly Updater _updater;
1515
private readonly MainWindowViewModel _windowVm;
16+
private readonly ConnectionType _connectionType;
1617

1718
private readonly CancellationTokenSource _cancelSource = new CancellationTokenSource();
1819

@@ -25,16 +26,18 @@ public class ConnectingViewModel : ViewModelBase
2526

2627
public bool IsErrored => _connectorStatus == Connector.ConnectionStatus.ConnectionFailed ||
2728
_connectorStatus == Connector.ConnectionStatus.UpdateError ||
29+
_connectorStatus == Connector.ConnectionStatus.NotAContentBundle ||
2830
_connectorStatus == Connector.ConnectionStatus.ClientExited &&
2931
_connector.ClientExitedBadly;
3032

3133
public static event Action? StartedConnecting;
3234

33-
public ConnectingViewModel(Connector connector, MainWindowViewModel windowVm, string? givenReason)
35+
public ConnectingViewModel(Connector connector, MainWindowViewModel windowVm, string? givenReason, ConnectionType connectionType)
3436
{
3537
_updater = Locator.Current.GetRequiredService<Updater>();
3638
_connector = connector;
3739
_windowVm = windowVm;
40+
_connectionType = connectionType;
3841
_reasonSuffix = (givenReason != null) ? ("\n" + givenReason) : "";
3942

4043
this.WhenAnyValue(x => x._updater.Progress)
@@ -134,7 +137,8 @@ public string ProgressText
134137
public bool ProgressBarVisible => _connectorStatus != Connector.ConnectionStatus.ClientExited &&
135138
_connectorStatus != Connector.ConnectionStatus.ClientRunning &&
136139
_connectorStatus != Connector.ConnectionStatus.ConnectionFailed &&
137-
_connectorStatus != Connector.ConnectionStatus.UpdateError;
140+
_connectorStatus != Connector.ConnectionStatus.UpdateError &&
141+
_connectorStatus != Connector.ConnectionStatus.NotAContentBundle;
138142

139143
public bool SpeedIndeterminate => _connectorStatus != Connector.ConnectionStatus.Updating || _updaterSpeed == null;
140144

@@ -182,10 +186,17 @@ public string SpeedText
182186
_ => ""
183187
};
184188

189+
public string TitleText => _connectionType switch
190+
{
191+
ConnectionType.Server => "Connecting...",
192+
ConnectionType.ContentBundle => "Loading...",
193+
_ => ""
194+
};
195+
185196
public static void StartConnect(MainWindowViewModel windowVm, string address, string? givenReason = null)
186197
{
187198
var connector = new Connector();
188-
var vm = new ConnectingViewModel(connector, windowVm, givenReason);
199+
var vm = new ConnectingViewModel(connector, windowVm, givenReason, ConnectionType.Server);
189200
windowVm.ConnectingVM = vm;
190201
vm.Start(address);
191202
StartedConnecting?.Invoke();
@@ -194,7 +205,7 @@ public static void StartConnect(MainWindowViewModel windowVm, string address, st
194205
public static void StartContentBundle(MainWindowViewModel windowVm, string fileName)
195206
{
196207
var connector = new Connector();
197-
var vm = new ConnectingViewModel(connector, windowVm, null);
208+
var vm = new ConnectingViewModel(connector, windowVm, null, ConnectionType.ContentBundle);
198209
windowVm.ConnectingVM = vm;
199210
vm.StartContentBundle(fileName);
200211
StartedConnecting?.Invoke();
@@ -224,4 +235,10 @@ public void Cancel()
224235
{
225236
_cancelSource.Cancel();
226237
}
238+
239+
public enum ConnectionType
240+
{
241+
Server,
242+
ContentBundle
243+
}
227244
}

SS14.Launcher/Views/ConnectingOverlay.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</Design.DataContext>
1212
<ContentControl Classes="OverlayBox">
1313
<StackPanel Orientation="Vertical">
14-
<TextBlock HorizontalAlignment="Center" Classes="NanoHeadingMedium" Text="Connecting..." />
14+
<TextBlock HorizontalAlignment="Center" Classes="NanoHeadingMedium" Text="{Binding TitleText}" />
1515
<TextBlock HorizontalAlignment="Center" Margin="0 10" DockPanel.Dock="Top" Text="{Binding StatusText}"
1616
TextWrapping="Wrap" MaxWidth="400" />
1717
<ProgressBar DockPanel.Dock="Bottom" Maximum="1" Value="{Binding Progress}"

0 commit comments

Comments
 (0)