Skip to content

Commit

Permalink
avoid steam API
Browse files Browse the repository at this point in the history
  • Loading branch information
kianzarrin committed Jul 5, 2022
1 parent a5cf9d1 commit 847b784
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 54 deletions.
11 changes: 11 additions & 0 deletions LoadOrder.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,38 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
DEBUG2|Any CPU = DEBUG2|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B89FEAE6-A22E-4576-9683-D2B5A1732544}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B89FEAE6-A22E-4576-9683-D2B5A1732544}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B89FEAE6-A22E-4576-9683-D2B5A1732544}.DEBUG2|Any CPU.ActiveCfg = DEBUG2|Any CPU
{B89FEAE6-A22E-4576-9683-D2B5A1732544}.DEBUG2|Any CPU.Build.0 = DEBUG2|Any CPU
{B89FEAE6-A22E-4576-9683-D2B5A1732544}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B89FEAE6-A22E-4576-9683-D2B5A1732544}.Release|Any CPU.Build.0 = Release|Any CPU
{F75E7E61-C575-44A8-AA22-690CD89E9BA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F75E7E61-C575-44A8-AA22-690CD89E9BA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F75E7E61-C575-44A8-AA22-690CD89E9BA2}.DEBUG2|Any CPU.ActiveCfg = DEBUG2|Any CPU
{F75E7E61-C575-44A8-AA22-690CD89E9BA2}.DEBUG2|Any CPU.Build.0 = DEBUG2|Any CPU
{F75E7E61-C575-44A8-AA22-690CD89E9BA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F75E7E61-C575-44A8-AA22-690CD89E9BA2}.Release|Any CPU.Build.0 = Release|Any CPU
{DB8FAB10-147B-484A-A18B-0EFB2B6442E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB8FAB10-147B-484A-A18B-0EFB2B6442E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB8FAB10-147B-484A-A18B-0EFB2B6442E9}.DEBUG2|Any CPU.ActiveCfg = Debug|Any CPU
{DB8FAB10-147B-484A-A18B-0EFB2B6442E9}.DEBUG2|Any CPU.Build.0 = Debug|Any CPU
{DB8FAB10-147B-484A-A18B-0EFB2B6442E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB8FAB10-147B-484A-A18B-0EFB2B6442E9}.Release|Any CPU.Build.0 = Release|Any CPU
{16FA65D4-EB2B-4863-B95E-8629F97BC9B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{16FA65D4-EB2B-4863-B95E-8629F97BC9B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16FA65D4-EB2B-4863-B95E-8629F97BC9B9}.DEBUG2|Any CPU.ActiveCfg = DEBUG2|Any CPU
{16FA65D4-EB2B-4863-B95E-8629F97BC9B9}.DEBUG2|Any CPU.Build.0 = DEBUG2|Any CPU
{16FA65D4-EB2B-4863-B95E-8629F97BC9B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16FA65D4-EB2B-4863-B95E-8629F97BC9B9}.Release|Any CPU.Build.0 = Release|Any CPU
{70A25201-8EA4-48F8-A4A6-ED13ADF8823C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70A25201-8EA4-48F8-A4A6-ED13ADF8823C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70A25201-8EA4-48F8-A4A6-ED13ADF8823C}.DEBUG2|Any CPU.ActiveCfg = Debug|Any CPU
{70A25201-8EA4-48F8-A4A6-ED13ADF8823C}.DEBUG2|Any CPU.Build.0 = Debug|Any CPU
{70A25201-8EA4-48F8-A4A6-ED13ADF8823C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70A25201-8EA4-48F8-A4A6-ED13ADF8823C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
Expand Down
6 changes: 6 additions & 0 deletions LoadOrder/LoadOrderTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<Product>Load Order Tool</Product>
<LangVersion>latest</LangVersion>
<Description>Helps to manage your mods and assets</Description>
<Configurations>Debug;Release;DEBUG2</Configurations>
</PropertyGroup>
<PropertyGroup>
<Deterministic>false</Deterministic>
Expand All @@ -22,6 +23,11 @@
<DebugType>embedded</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DEBUG2|AnyCPU'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>embedded</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<Compile Remove="CO\Plugins\**" />
Expand Down
3 changes: 3 additions & 0 deletions LoadOrder/UI/LoadOrderWindowMenuStrip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ public class LoadOrderWindowMenuStrip : MenuStrip {
var advancedItems = new ToolStripItem[] { tsmiRandomOrder, tsmiHarmonyOrder, tsmiReverseOrder, tsmiReloadSettings, tsmiResetCache, tsmiResetAllSettings, toolStripSeparator1 };
foreach (var item in advancedItems)
item.Visible = ConfigWrapper.instance.Advanced;
#if !CO_STEAM_API
tsmiMassSubscribe.Visible = false;
#endif
}

private void TsmiAdvanced_CheckedChanged(object sender, EventArgs e) {
Expand Down
5 changes: 5 additions & 0 deletions LoadOrder/UI/OpenProfileDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 22 additions & 14 deletions LoadOrderInjections/Injections/SubscriptionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class TestComponent : MonoBehaviour {
}
}

#if CO_STEAM_API
public class MassSubscribe : MonoBehaviour
{
public enum StateT
Expand Down Expand Up @@ -316,6 +317,7 @@ public class ItemT {
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
}
#endif


public class Example : MonoBehaviour {
Expand Down Expand Up @@ -417,18 +419,24 @@ public static class SubscriptionManager {
Log.Called();
if (SteamUtilities.sman) {
new GameObject().AddComponent<Camera>();
//new GameObject("base").AddComponent<Example>();
#if CO_STEAM_API
new GameObject("base").AddComponent<Example>();
new GameObject("test go").AddComponent<TestComponent>();
#endif
return true;
} else if (SteamUtilities.GetMassSub(out _)) {
new GameObject().AddComponent<Camera>();
//new GameObject("base").AddComponent<Example>();
#if CO_STEAM_API
new GameObject("mass subscribe go").AddComponent<MassSubscribe>();
#endif
return true;
} else if(SteamUtilities.GetMassUnSub(out _)) {
new GameObject().AddComponent<Camera>();
//new GameObject("base").AddComponent<Example>();
#if CO_STEAM_API
new GameObject("mass unsubscribe go").AddComponent<MassUnSubscribe>();
#endif
return true;
} else {
return false.LogRet(ThisMethod);
Expand Down Expand Up @@ -568,17 +576,17 @@ public static class SteamUtilities {
return default;
}

public static void OnRequestItemDetailsClicked() {
Log.Debug("RequestItemDetails pressed");
foreach (var id in PlatformService.workshop.GetSubscribedItems())
PlatformService.workshop.RequestItemDetails(id).LogRet($"RequestItemDetails({id.AsUInt64})");
//var id = new PublishedFileId(2040656402ul);
//PlatformService.workshop.RequestItemDetails(id).LogRet($"RequestItemDetails({id.AsUInt64})");
}
public static void OnQueryItemsClicked() {
Log.Debug("QueryItems pressed");
PlatformService.workshop.QueryItems().LogRet($"QueryItems()"); ;
}
//public static void OnRequestItemDetailsClicked() {
// Log.Debug("RequestItemDetails pressed");
// foreach (var id in PlatformService.workshop.GetSubscribedItems())
// PlatformService.workshop.RequestItemDetails(id).LogRet($"RequestItemDetails({id.AsUInt64})");
// //var id = new PublishedFileId(2040656402ul);
// //PlatformService.workshop.RequestItemDetails(id).LogRet($"RequestItemDetails({id.AsUInt64})");
//}
//public static void OnQueryItemsClicked() {
// Log.Debug("QueryItems pressed");
// PlatformService.workshop.QueryItems().LogRet($"QueryItems()"); ;
//}

private static void OnSubmitItemUpdate(SubmitItemUpdateResult result, bool ioError) {
Log.Debug($"PlatformService.workshop.eventSubmitItemUpdate(result:{result.result}, {ioError})");
Expand Down Expand Up @@ -857,8 +865,8 @@ public static string ToSTR(this ref UGCDetails result)
var items = PlatformService.workshop.GetSubscribedItems();
foreach (var id in items) {
EnsureIncludedOrExcluded(id);
PlatformService.workshop.RequestItemDetails(id)
.LogRet($"RequestItemDetails({id.AsUInt64})");
//PlatformService.workshop.RequestItemDetails(id)
// .LogRet($"RequestItemDetails({id.AsUInt64})");
}
}

Expand Down
4 changes: 4 additions & 0 deletions LoadOrderInjections/LoadOrderInjections.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<PathMap>$(MSBuildProjectDirectory)/=$(ProjectName)/</PathMap>
<Configurations>Debug;Release;DEBUG2</Configurations>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DEBUG2|AnyCPU'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<ManagedDLLPath>../dependencies</ManagedDLLPath>
<SteamPath>~/Library/Application Support/Steam/</SteamPath>
Expand Down
4 changes: 3 additions & 1 deletion LoadOrderMod/LoadOrderMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<DebugSymbols>true</DebugSymbols>
<PathMap>$(MSBuildProjectDirectory)/=$(ProjectName)/</PathMap>
<DefineConstants Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">DEBUG;TRACE</DefineConstants>
<DefineConstants Condition="'$(Configuration)|$(Platform)'=='DEBUG2|AnyCPU'">DEBUG;TRACE</DefineConstants>
<Configurations>Debug;Release;DEBUG2</Configurations>
</PropertyGroup>
<PropertyGroup>
<ManagedDLLPath>../dependencies</ManagedDLLPath>
Expand Down Expand Up @@ -148,7 +150,7 @@

<Copy SourceFiles="@(AuxiliaryFiles)" DestinationFolder="$(DeployDir)" />
<Copy SourceFiles="@(ResourceFiles)" DestinationFolder="$(DeployDir)Resources" />
<Move SourceFiles="$(DeployDir)Resources/PreviewImage.png" DestinationFolder="$(DeployDir)" />
<Move SourceFiles="$(DeployDir)Resources/PreviewImage.png" DestinationFolder="$(DeployDir)" />
<Delete Files="$(DeployDir)$(TargetFileName)" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(DeployDir)" />
<Message Importance="high" Text="AssemblyVersion=@(VersionNumber) time=$(Now)" />
Expand Down
8 changes: 4 additions & 4 deletions LoadOrderMod/Settings/Tabs/DebugTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ static class DebugTab {
Log.Exception(ex);
}
}
static void OnQueryItemsClicked() {
Log.Debug("QueryItems pressed");
PlatformService.workshop.QueryItems().LogRet($"QueryItems()"); ;
}
//static void OnQueryItemsClicked() {
// Log.Debug("QueryItems pressed");
// PlatformService.workshop.QueryItems().LogRet($"QueryItems()"); ;
//}

static void OnUGCQueryCompleted(UGCDetails result, bool ioError) {
Log.Debug($"OnUGCQueryCompleted(result:{result.result} {result.publishedFileId}, ioError:{ioError})");
Expand Down
8 changes: 5 additions & 3 deletions LoadOrderMod/Settings/Tabs/SubscriptionsTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ static class SubscriptionsTab {
UICheckBox checkBox;
//g.AddButton("Perform All", OnPerformAllClicked);

button = panelHelper.AddButton("Refresh workshop items (checks for bad items)", RequestItemDetails) as UIButton;
button.tooltip = "checks for missing/partially downloaded/outdated items";
//button = panelHelper.AddButton("Refresh workshop items (checks for bad items)", RequestItemDetails) as UIButton;
//button.tooltip = "checks for missing/partially downloaded/outdated items";

#if CO_STEAM_API
button = panelHelper.AddButton("unsubscribe from deprecated workshop items [EXPERIMENTAL] ", () => CheckSubsUtil.Instance.UnsubDepricated()) as UIButton;
button.tooltip = "if steam does not return item path, i assume its deprecated.";
#endif

button = panelHelper.AddButton("Resubscribe to all broken downloads (exits game) [EXPERIMENTAL]", CheckSubsUtil.ResubcribeExternally) as UIButton;
button.tooltip = "less steam can hide problems. if you use less steam please click 'Refresh workshop items' to get all broken downloads";
Expand Down Expand Up @@ -105,6 +107,6 @@ static class SubscriptionsTab {
CheckSubsUtil.EnsureAll();
SteamUtilities.DeleteUnsubbed();
}
static void RequestItemDetails() => CheckSubsUtil.Instance.RequestItemDetails();
//static void RequestItemDetails() => CheckSubsUtil.Instance.RequestItemDetails();
}
}
64 changes: 33 additions & 31 deletions LoadOrderMod/Util/CheckSubsUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class CheckSubsUtil : MonoBehaviour {

public static void EnsureAll() {
Instance.EnsureIncludedOrExcluded();
Instance.RequestItemDetails();
//Instance.RequestItemDetails();
}

public Coroutine EnsureIncludedOrExcluded() => StartCoroutine(EnsureIncludedOrExcludedCoroutine());
Expand All @@ -51,22 +51,23 @@ public class CheckSubsUtil : MonoBehaviour {
}
}

public Coroutine RequestItemDetails() => StartCoroutine(RequiestItemDetailsCoroutine());
public IEnumerator RequiestItemDetailsCoroutine() {
Log.DisplayMesage($"Checking all items ...");
RegisterEvents();
var items = PlatformService.workshop.GetSubscribedItems();
int counter = 0;
foreach (var id in items) {
PlatformService.workshop.RequestItemDetails(id)
.LogRet($"RequestItemDetails({id.AsUInt64})");
if (counter >= 100) {
counter = 0;
yield return 0;
}
}
}

//public Coroutine RequestItemDetails() => StartCoroutine(RequiestItemDetailsCoroutine());
//public IEnumerator RequiestItemDetailsCoroutine() {
// Log.DisplayMesage($"Checking all items ...");
// RegisterEvents();
// var items = PlatformService.workshop.GetSubscribedItems();
// int counter = 0;
// foreach (var id in items) {
// PlatformService.workshop.RequestItemDetails(id)
// .LogRet($"RequestItemDetails({id.AsUInt64})");
// if (counter >= 100) {
// counter = 0;
// yield return 0;
// }
// }
//}

#if CO_SREAM_API
public Coroutine UnsubDepricated() => StartCoroutine(UnsubDepricatedCoroutine());

public IEnumerator UnsubDepricatedCoroutine() {
Expand Down Expand Up @@ -94,6 +95,7 @@ public class CheckSubsUtil : MonoBehaviour {

Log.DisplayMesage($"Unsubscribing from {nUnsubbed} deprecated items.");
}
#endif

public static List<PublishedFileId> GetBrokenDownloads() {
List<PublishedFileId> ids = new List<PublishedFileId>();
Expand Down Expand Up @@ -249,23 +251,23 @@ public class CheckSubsUtil : MonoBehaviour {
}
}

public Coroutine Resubscribe(PublishedFileId id) => StartCoroutine(ResubscribeCoroutine(id));
public IEnumerator ResubscribeCoroutine(PublishedFileId id) {
Log.Called(id);
if (id != PublishedFileId.invalid) {
try { PlatformService.workshop.Unsubscribe(id); } catch(Exception ex) { ex.Log(); }
//public Coroutine Resubscribe(PublishedFileId id) => StartCoroutine(ResubscribeCoroutine(id));
//public IEnumerator ResubscribeCoroutine(PublishedFileId id) {
// Log.Called(id);
// if (id != PublishedFileId.invalid) {
// try { PlatformService.workshop.Unsubscribe(id); } catch(Exception ex) { ex.Log(); }

yield return new WaitForSeconds(3);
// yield return new WaitForSeconds(3);

try {
//string path = PlatformService.workshop.GetSubscribedItemPath(id);
//if (Directory.Exists(path))
// Directory.Delete(path, true);
} catch(Exception ex) { ex.Log(); }
// try {
// //string path = PlatformService.workshop.GetSubscribedItemPath(id);
// //if (Directory.Exists(path))
// // Directory.Delete(path, true);
// } catch(Exception ex) { ex.Log(); }

try { PlatformService.workshop.Subscribe(id); } catch (Exception ex) { ex.Log(); }
}
}
// try { PlatformService.workshop.Subscribe(id); } catch (Exception ex) { ex.Log(); }
// }
//}

public static void RemoveEvents() {
PlatformService.workshop.eventUGCRequestUGCDetailsCompleted -= OnUGCRequestUGCDetailsCompleted;
Expand Down
2 changes: 1 addition & 1 deletion Version.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<AssemblyVersion>1.5.5.*</AssemblyVersion>
<AssemblyVersion>1.6.0.*</AssemblyVersion>
</PropertyGroup>
</Project>

0 comments on commit 847b784

Please sign in to comment.