Skip to content

Commit

Permalink
Added a Force option to transfers
Browse files Browse the repository at this point in the history
Now, if a transfer is blocked by it's app state, you can force it, which
will allow additional appState flags, or ignore app state entirely if
steam isn't running.
Also, added logic to CanCopy to be more permissive if Steam isn't
running.
  • Loading branch information
DjScribbles committed Mar 21, 2016
1 parent 6be1039 commit a6b1604
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 6 deletions.
18 changes: 15 additions & 3 deletions GamePipe/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,21 @@
</Button>
</Grid>
<ci:Image Grid.Column="1" Grid.RowSpan="5" ImageUrl="{Binding ImageUrl}" Height="61" Width="162"/>
<TextBlock Grid.Row="0" Grid.Column="2" Text="{Binding TransferType}" Style="{StaticResource Detail}" VerticalAlignment="Top" Margin="4,-4,4,-8"/>
<TextBlock Grid.Row="0" Grid.Column="3" Text="This game cannot be moved right now, it is currently locked by Steam"
Visibility="{Binding IsBlocked, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource Detail}" VerticalAlignment="Top" Margin="4,-4,4,-8"/>
<TextBlock Grid.Row="0" Grid.Column="2" Text="{Binding TransferType}" Style="{StaticResource Detail}" VerticalAlignment="Center" Margin="4,-4"/>
<StackPanel Grid.Row="0" Grid.Column="3" Orientation="Horizontal" Visibility="{Binding IsBlocked, Converter={StaticResource BooleanToVisibilityConverter}}" >
<TextBlock Text="This game cannot be moved right now, it is currently locked by Steam."
Style="{StaticResource Detail}" VerticalAlignment="Center" Margin="4,-4"/>
<TextBlock Text="Unable to Force. You must close Steam to proceed."
Style="{StaticResource Detail}" VerticalAlignment="Center" Margin="4,-4" Visibility="{Binding IsForced, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<TextBlock Text="If this application is not running or being updated by Steam, you can..."
Style="{StaticResource Detail}" VerticalAlignment="Center" Margin="4,-4" Visibility="{Binding IsNotForced, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<Button Command="{Binding ForceTransferCommand}" Visibility="{Binding IsNotForced, Converter={StaticResource BooleanToVisibilityConverter}}" Margin="4,0" >
<Button.Content>
<TextBlock Text="Try to Force This Transfer"
Style="{StaticResource Detail}" VerticalAlignment="Center" Margin="4,-8" />
</Button.Content>
</Button>
</StackPanel>
<TextBlock Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="3" Text="{Binding GameName}" Style="{StaticResource Title}" Margin="4,-4,4,4" HorizontalAlignment="Left"/>

<Button Grid.Row="0" Grid.Column="5" Grid.RowSpan="2" Command="{Binding AbortCommand}">
Expand Down
24 changes: 24 additions & 0 deletions GamePipe/ViewModel/TransferViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ private void _model_PropertyChanged(object sender, System.ComponentModel.Propert

public TransferStatus Status { get { return _model.Status; } }
public bool IsBlocked { get { return _model.Status == TransferStatus.Blocked; } }
public bool IsForced { get { return _model.ForceTransfer; } }
public bool IsNotForced { get { return !_model.ForceTransfer; } }//TODO This is really lazy...
public double Progress { get { return _model.Progress; } }
public string TransferType { get { return _model.TransferType; } }
public string ImageUrl { get { return _model.Application?.ImageUrl; } }
Expand Down Expand Up @@ -123,6 +125,28 @@ public void MoveDown()
Manager.ShuffleTransfers(transfers);
}
#endregion //MoveDownCommand
#region "ForceTransferCommand"
private RelayCommand _ForceTransferCommand = null;
public RelayCommand ForceTransferCommand
{
get
{
if (_ForceTransferCommand == null)
{
_ForceTransferCommand = new RelayCommand(x => ForceTransfer());

}
return _ForceTransferCommand;
}
}

public void ForceTransfer()
{
Model.ForceTransfer = true;
NotifyPropertyChanged("IsNotForced");
NotifyPropertyChanged("IsForced");
}
#endregion //ForceTransferCommand
#endregion //Commands
}
}
2 changes: 2 additions & 0 deletions GamePipeLib/Interfaces/IAppProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public interface IAppProvider
IEnumerable<string> GetDirectoriesForApp(string appId);
[OperationContract]
bool CanCopy(string appId);
[OperationContract]
bool CanCopyIfForced(string appId);


[OperationContract]
Expand Down
1 change: 1 addition & 0 deletions GamePipeLib/Interfaces/ILocalSteamApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public interface ILocalSteamApplication : ISteamApplication
void MeasureDiskSize();
void DeleteGameData();
bool CanCopy();
bool CanCopyIfForced();
void RefreshFromAcf();
}
}
17 changes: 16 additions & 1 deletion GamePipeLib/Model/Steam/SteamApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,22 @@ private set

public bool CanCopy()
{
return (0 == (AppState & ~(AppStateFlags.StateFullyInstalled | AppStateFlags.StateEncrypted | AppStateFlags.StateBackupRunning | AppStateFlags.StateCommitting | AppStateFlags.StateUpdateRequired)));
var ignores = (AppStateFlags.StateFullyInstalled | AppStateFlags.StateEncrypted | AppStateFlags.StateBackupRunning | AppStateFlags.StateCommitting | AppStateFlags.StateUpdateRequired);
if (!Utils.SteamDirParsingUtils.IsSteamOpen())
ignores |= AppStateFlags.StateAppRunning | AppStateFlags.StateFilesCorrupt | AppStateFlags.StateFilesMissing | AppStateFlags.StateValidating;

return (0 == (AppState & ~ignores));
}

public bool CanCopyIfForced()
{
if (!Utils.SteamDirParsingUtils.IsSteamOpen())
return true;
var ignores = (AppStateFlags.StateFullyInstalled | AppStateFlags.StateEncrypted | AppStateFlags.StateBackupRunning | AppStateFlags.StateCommitting | AppStateFlags.StateUpdateRequired);

ignores |= AppStateFlags.StateAppRunning | AppStateFlags.StateFilesCorrupt | AppStateFlags.StateFilesMissing | AppStateFlags.StateValidating;

return (0 == (AppState & ~ignores));
}

public void InitializeFromAcf()
Expand Down
5 changes: 5 additions & 0 deletions GamePipeLib/Model/Steam/SteamBundle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ public bool CanCopy()
return _AppsInBundle.All(x => x.CanCopy());
}

public bool CanCopyIfForced()
{
return _AppsInBundle.All(x => x.CanCopyIfForced());
}

public void RefreshFromAcf()
{
foreach (var app in _AppsInBundle)
Expand Down
8 changes: 8 additions & 0 deletions GamePipeLib/Model/Steam/SteamLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ public bool CanCopy(string appId)
return game.CanCopy();
}

public bool CanCopyIfForced(string appId)
{
var game = GetGameById(appId);
if (game == null) throw new ArgumentException(string.Format("App ID {0} not found in {1}", appId, SteamDirectory));

return game.CanCopyIfForced();
}

Stream IAppProvider.GetFileStream(string appId, string file, bool acceptCompressedFiles)
{
return GetReadFileStream(appId, file, acceptCompressedFiles);
Expand Down
12 changes: 10 additions & 2 deletions GamePipeLib/Model/TransferBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,16 @@ protected TransferBase(IAppProvider source, ITransferTarget target, ISteamApplic
}
public long ActualDiskSize { get { return _actualDiskSize; } }
public long BytesTransfered { get { return _lastReportedBytesTransferred; } }
public bool CanCopy { get { return _source.CanCopy(Application.AppId); } }

public bool ForceTransfer { get; set; }
public bool CanCopy
{
get
{
return (ForceTransfer
? _source.CanCopyIfForced(Application.AppId)
: _source.CanCopy(Application.AppId));
}
}
protected abstract void DoPostProcess();
protected abstract void DoAbortProcess();
protected abstract void DoPreProcess();
Expand Down
9 changes: 9 additions & 0 deletions GamePipeService/GameProviderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ public bool CanCopy(string appId)
return gameInfo.CanCopy();
}

public bool CanCopyIfForced(string appId)
{
var gameInfo = _rootSteam.GetGame(appId);
if (gameInfo == null)
return false;

return gameInfo.CanCopyIfForced();
}

public long GetMeasuredGameSize(string appId)
{
var gameInfo = _rootSteam.GetGame(appId);
Expand Down

0 comments on commit a6b1604

Please sign in to comment.