Skip to content

Commit

Permalink
Allow saves without images
Browse files Browse the repository at this point in the history
  • Loading branch information
counter185 committed Aug 29, 2021
1 parent 769e966 commit cb3e0a0
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 15 deletions.
4 changes: 2 additions & 2 deletions PSPSync/FTPClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public string[] DirectoryListSimple(string directory)
}

}
catch (WebException) { Console.WriteLine(directory);/*Console.WriteLine(ex.ToString());*/ }
catch (WebException) { /*Console.WriteLine(directory);Console.WriteLine(ex.ToString());*/ }
/* Return an Empty string Array if an Exception Occurs */
return new string[0];
}
Expand All @@ -392,7 +392,7 @@ public bool ServerAvailable() {
}
catch (WebException e)
{
Console.WriteLine(e.Message);
//Console.WriteLine(e.Message);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion PSPSync/MTPDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public MTPDevice(MediaDevice dev) {
device.Connect();
try
{
Console.WriteLine(device.FriendlyName);
//Console.WriteLine("Connecting to " + device.FriendlyName);
if (!device.FriendlyName.EndsWith(":\\")) //that means it's already mounted as a drive. don't trust it.
{
foreach (string a in device.GetDirectories("/"))
Expand Down
1 change: 0 additions & 1 deletion PSPSync/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ public void SetMgrEnabled(bool enabled) {
public void CopySave(SaveMeta srcMeta, SaveMeta otherMeta, NamedStream[] files, IStorageDevice dest, int updateDevice) {
SetMgrEnabled(false);
string id = GetGameID(srcMeta.directory);
Console.WriteLine(dest.HasSave(id) + " " + id);
if (dest.HasSave(id))
{
if (otherMeta == null)
Expand Down
19 changes: 12 additions & 7 deletions PSPSync/SDs/FTPSaveDir.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using System.IO;
using System.Windows.Media.Animation;
using System.Windows.Media;

namespace PSPSync
{
Expand Down Expand Up @@ -63,7 +64,7 @@ public NamedStream[] ReadSave(string directory)
}
}
MemoryStream file = client.Download(directory + "/" + files[x]);
Console.WriteLine(directory + "/" + files[x]);
//Console.WriteLine(directory + "/" + files[x]);
file.Position = 0;
ret[x] = new NamedStream(file, filename);
}
Expand All @@ -81,7 +82,7 @@ public List<SaveMeta> ScanSaves()
foreach (string dr2 in ss)
{
string a = mainDir + dr2;
if (!client.FileExists(a + "/PARAM.SFO") || !client.FileExists(a + "/ICON0.PNG"))
if (!client.FileExists(a + "/PARAM.SFO"))
{
continue;
}
Expand All @@ -102,11 +103,16 @@ public List<SaveMeta> ScanSaves()
title = Encoding.UTF8.GetString(reader);
b.Close();

MemoryStream imageStream = client.Download(a + "/ICON0.PNG");
Console.WriteLine(a);
imageStream.Position = 0;

saves.Add(new SaveMeta(title, info, info2, a, MTPSaveDir.BitmapFromStream(imageStream), new System.DateTime(0)));
ImageSource thumbnailImg = null;
if (client.FileExists(a + "/ICON0.PNG"))
{
MemoryStream imageStream = client.Download(a + "/ICON0.PNG");
imageStream.Position = 0;
thumbnailImg = MTPSaveDir.BitmapFromStream(imageStream);
}

saves.Add(new SaveMeta(title, info, info2, a, thumbnailImg, new System.DateTime(0)));
}
return saves;
}
Expand All @@ -122,7 +128,6 @@ public void WriteSave(string directoryName, NamedStream[] files)
{
client.Upload(dr + "/" + stm.name, stm.stream);
}
Console.WriteLine("done holy shit");
}

public GeneralDeviceSpeed GetDeviceSpeed() {
Expand Down
1 change: 0 additions & 1 deletion PSPSync/SDs/MTPSaveDir.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public void WriteSave(string directoryName, NamedStream[] files)
{
parent.device.UploadFile(stm.stream, dr + "/" + stm.name);
}
Console.WriteLine("done holy shit");
}

public GeneralDeviceSpeed GetDeviceSpeed()
Expand Down
3 changes: 1 addition & 2 deletions PSPSync/SDs/PSPSaveDir.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public List<SaveMeta> ScanSaves()
b.Seek(0x12B0, SeekOrigin.Begin);
b.Read(reader, 0, 128);
title = Encoding.UTF8.GetString(reader);
saves.Add(new SaveMeta(title, info, info2, a, BitmapFromUri(new Uri(a + "/ICON0.PNG")), File.GetLastWriteTime(a + "/PARAM.SFO")));
saves.Add(new SaveMeta(title, info, info2, a, (File.Exists(a+"/ICON0.PNG") ? BitmapFromUri(new Uri(a + "/ICON0.PNG")) : null), File.GetLastWriteTime(a + "/PARAM.SFO")));
b.Close();
}
return saves;
Expand Down Expand Up @@ -119,7 +119,6 @@ public void WriteSave(string directoryName, NamedStream[] files)
}
a.Close();
}
Console.WriteLine("done holy shit");
}

public GeneralDeviceSpeed GetDeviceSpeed()
Expand Down
1 change: 1 addition & 0 deletions PSPSync/SaveListItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Label x:Name="MissingIcon" Content="Missing ICON0.PNG" HorizontalAlignment="Left" Margin="10,20,0,0" VerticalAlignment="Top" Height="43" Width="126" Foreground="White"/>
<Image x:Name="GamePic" HorizontalAlignment="Left" Height="75" VerticalAlignment="Top" Width="136" Margin="0,13,0,0"/>
<Label x:Name="GameName" Content="Game name" HorizontalAlignment="Left" Margin="141,0,0,0" VerticalAlignment="Top" FontSize="14" Foreground="White"/>
<Label x:Name="GameInfo" Content="info" HorizontalAlignment="Left" Margin="141,13,0,0" VerticalAlignment="Top" FontSize="11" Foreground="White"/>
Expand Down
6 changes: 5 additions & 1 deletion PSPSync/SaveListItem.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public void GiveMeta(SaveMeta a) {
this.GameInfo.Content = a.info;
this.GameInfo2.Content = a.info2;
this.GameDate.Content = a.timeModified.ToString();
this.GamePic.Source = a.thumbnail;
if (a.thumbnail != null)
{
this.MissingIcon.Visibility = Visibility.Hidden;
this.GamePic.Source = a.thumbnail;
}
}
else {
this.GameName.Content = "Corrupted data (no PARAM.SFO)";
Expand Down

0 comments on commit cb3e0a0

Please sign in to comment.