diff --git a/IngameReveries/.gitignore b/IngameReveries/.gitignore new file mode 100644 index 0000000..5c4396b --- /dev/null +++ b/IngameReveries/.gitignore @@ -0,0 +1,217 @@ +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Rr]elease/ +x64/ +[Bb]in/ +[Oo]bj/ +# build folder is nowadays used for build scripts and should not be ignored +#build/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings +modulesbin/ +tempbin/ + +# EPiServer Site file (VPP) +AppData/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# vim +*.txt~ +*.swp +*.swo + +# Temp files when opening LibreOffice on ubuntu +.~lock.* + +# svn +.svn + +# CVS - Source Control +**/CVS/ + +# Remainings from resolving conflicts in Source Control +*.orig + +# SQL Server files +**/App_Data/*.mdf +**/App_Data/*.ldf +**/App_Data/*.sdf + + +#LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# OS generated files # +Icon? + +# Mac desktop service store files +.DS_Store + +# SASS Compiler cache +.sass-cache + +# Visual Studio 2014 CTP +**/*.sln.ide + +# Visual Studio temp something +.vs/ + +# dotnet stuff +project.lock.json + +# VS 2015+ +*.vc.vc.opendb +*.vc.db + +# Rider +.idea/ + +# Visual Studio Code +.vscode/ + +# Output folder used by Webpack or other FE stuff +**/node_modules/* +**/wwwroot/* + +# SpecFlow specific +*.feature.cs +*.feature.xlsx.* +*.Specs_*.html + +# UWP Projects +AppPackages/ + +##### +# End of core ignore list, below put you custom 'per project' settings (patterns or path) +##### diff --git a/IngameReveries/IngameReveries.cs b/IngameReveries/IngameReveries.cs new file mode 100644 index 0000000..6902d4f --- /dev/null +++ b/IngameReveries/IngameReveries.cs @@ -0,0 +1,174 @@ +using System.IO; +using System.Linq; +using TMPro; +using UnityEngine; +using UnityEngine.SceneManagement; +using UnityEngine.UI; + + +namespace IngameReveries +{ + // ModBehaviour will be instantiated and attached as a component in a container game object named + // Multiple ModBehaviours in your mod will share the same container. + public class IngameReveries : ModBehaviour + { + private GameObject _ingameReveriesUI; + + private AssetBundle _reveriesBundle; + private GameObject _reveriesPrefab; + + private void Awake() + { + // Metadata of your mod is stored in this.about + Debug.Log("Hello! I'm loaded! " + mod.metadata.id); + + // If you need to patch with Harmony, you can use this.harmony to access the Harmony instance for your mod. + // It will be created with your mod's id automatically, the first time you access the property. + harmony.PatchAll(); + } + + private void Start() + { + InitializeAssets(); + + SceneManager.sceneLoaded += OnSceneLoaded; + } + + private void OnDestroy() + { + // Make sure you clean up properly to support Live Reload. + Debug.Log("Good bye! " + mod.metadata.id); + harmony.UnpatchAll(); + + SceneManager.sceneLoaded -= OnSceneLoaded; + } + + private void OnSceneLoaded(Scene scene, LoadSceneMode mode) + { + // Check if UI already instantiated + if (_ingameReveriesUI != null) + { + return; + } + + string gameSceneDir = "Assets/Dew/Zones/"; + string relativeToScene = Path.GetRelativePath(gameSceneDir, scene.path); + + if (!relativeToScene.StartsWith("..")) + { + Debug.Log($"[IngameReveries] Switched to scene inside {gameSceneDir}"); + + GameObject menuViewGO = GameObject.Find("GameLogicPackage/UI/InGame/UI_Common_MenuView"); + if (menuViewGO == null) + { + Debug.Log("Couldn't find menu view"); + return; + } + + _ingameReveriesUI = Instantiate(_reveriesPrefab, menuViewGO.transform); + _ingameReveriesUI.SetActive(true); + _ingameReveriesUI.name = "IngameReveriesUI"; + _ingameReveriesUI.transform.SetSiblingIndex(1); + + var reveries = _ingameReveriesUI.GetComponent(); + + // Show reveries window + var canvasGroup = _ingameReveriesUI.GetComponent(); + canvasGroup.alpha = 1f; + canvasGroup.interactable = true; + canvasGroup.blocksRaycasts = true; + + // Position reveries window top left + var rect = _ingameReveriesUI.GetComponent(); + rect.anchorMin = new Vector2(0f, 1f); + rect.anchorMax = new Vector2(0f, 1f); + rect.pivot = new Vector2(0f, 1f); + rect.anchoredPosition = new Vector2(+70f, -400f); + + FixFonts(); + } + } + + private void InitializeAssets() + { + string bundlePath = Path.Combine(mod.path, "assets", "bundle"); + + if (!File.Exists(bundlePath)) + { + Debug.LogError($"[IngameReveries] Bundle not found at: {bundlePath}"); + return; + } + + _reveriesBundle = AssetBundle.GetAllLoadedAssetBundles() + .FirstOrDefault(b => b.name == "bundle" || b.mainAsset != null); + + if (_reveriesBundle == null) + { + // If it isn't loaded yet, load it from disk + Debug.Log("[IngameReveries] Loading Bundle"); + _reveriesBundle = AssetBundle.LoadFromFile(bundlePath); + } + else + { + Debug.Log("[IngameReveries] Bundle already loaded"); + } + + if (_reveriesBundle == null) + { + Debug.LogError("[IngameReveries] Failed to load AssetBundle!"); + return; + } + + // Load the prefab from the bundle + string assetName = _reveriesBundle.GetAllAssetNames().First(); + _reveriesPrefab = _reveriesBundle.LoadAsset(assetName); + + if (_reveriesPrefab == null) + { + Debug.LogError("[IngameReveries] Failed to load prefab!"); + + // List what's in the bundle for debugging + string[] assetNames = _reveriesBundle.GetAllAssetNames(); + Debug.Log("[IngameReveries] Assets in bundle:"); + foreach (string name in assetNames) + { + Debug.Log($" - {name}"); + } + + return; + } + + Debug.Log("[IngameReveries] Successfully loaded prefab!"); + } + + private void FixFonts() + { + // Get all fonts + TMP_FontAsset[] loadedFonts = Resources.FindObjectsOfTypeAll(); + + // Get all text from the reveries window + TMP_Text[] textComponents = _ingameReveriesUI.GetComponentsInChildren(true); + foreach (TMP_Text textComp in textComponents) + { + if (textComp.font == null) continue; + + string originalFontName = textComp.font.name; + + // Match the font by name, ensuring we don't pick the dead assetbundle version + foreach (TMP_FontAsset loadedFont in loadedFonts) + { + // Pick a matching font that has an active atlas/material + if (loadedFont.name == originalFontName && loadedFont.atlasTexture != null) + { + textComp.font = loadedFont; + + // Force TMP to update its internal mesh and material reference + textComp.ForceMeshUpdate(); + textComp.SetAllDirty(); + break; + } + } + } + } + } +} \ No newline at end of file diff --git a/IngameReveries/IngameReveries.csproj b/IngameReveries/IngameReveries.csproj new file mode 100644 index 0000000..c671fc3 --- /dev/null +++ b/IngameReveries/IngameReveries.csproj @@ -0,0 +1,295 @@ + + + + + + netstandard2.1 + 9.0 + true + true + true + + false + IngameReveries + IngameReveries + ModAuthor + 1.0.0.0 + 1.0.0.0 + Debug + + ..\..\ + $(GameDir)Shape of Dreams_Data\Managed + $(GameDir)Mods\$(AssemblyTitle) + + + + bin\Debug\ + DEBUG;TRACE + true + full + false + + + + bin\Release\ + TRACE + pdbonly + true + + + + + $(GameManagedDir)\mscorlib.dll + False + + + $(GameManagedDir)\netstandard.dll + False + + + $(GameManagedDir)\System.dll + False + + + $(GameManagedDir)\System.Core.dll + False + + + + $(GameManagedDir)\0Harmony.dll + False + + + $(GameManagedDir)\Assembly-CSharp.dll + False + + + $(GameManagedDir)\Dew.Contents.dll + False + + + $(GameManagedDir)\Dew.Core.dll + False + + + $(GameManagedDir)\Dew.External.dll + False + + + $(GameManagedDir)\Dew.UI.dll + False + + + $(GameManagedDir)\Unity.Addressables.dll + False + + + $(GameManagedDir)\Unity.Collections.dll + False + + + $(GameManagedDir)\Unity.Formats.Fbx.Runtime.dll + False + + + $(GameManagedDir)\Unity.InputSystem.dll + False + + + $(GameManagedDir)\Unity.InputSystem.ForUI.dll + False + + + $(GameManagedDir)\Unity.Mathematics.dll + False + + + $(GameManagedDir)\Unity.Mirror.CodeGen.dll + False + + + $(GameManagedDir)\Unity.Profiling.Core.dll + False + + + $(GameManagedDir)\Unity.RenderPipeline.Universal.ShaderLibrary.dll + False + + + $(GameManagedDir)\Unity.RenderPipelines.Core.Runtime.dll + False + + + $(GameManagedDir)\Unity.RenderPipelines.Core.ShaderLibrary.dll + False + + + $(GameManagedDir)\Unity.RenderPipelines.Universal.Runtime.dll + False + + + $(GameManagedDir)\Unity.RenderPipelines.Universal.Runtime.Tests.dll + False + + + $(GameManagedDir)\Unity.RenderPipelines.Universal.Shaders.dll + False + + + $(GameManagedDir)\Unity.ResourceManager.dll + False + + + $(GameManagedDir)\Unity.ScriptableBuildPipeline.dll + False + + + $(GameManagedDir)\Unity.Services.Analytics.dll + False + + + $(GameManagedDir)\Unity.Services.Authentication.dll + False + + + $(GameManagedDir)\Unity.Services.Core.dll + False + + + $(GameManagedDir)\Unity.Services.Core.Analytics.dll + False + + + $(GameManagedDir)\Unity.Services.Core.Configuration.dll + False + + + $(GameManagedDir)\Unity.Services.Core.Device.dll + False + + + $(GameManagedDir)\Unity.Services.Core.Environments.dll + False + + + $(GameManagedDir)\Unity.Services.Core.Environments.Internal.dll + False + + + $(GameManagedDir)\Unity.Services.Core.Internal.dll + False + + + $(GameManagedDir)\Unity.Services.Core.Networking.dll + False + + + $(GameManagedDir)\Unity.Services.Core.Registration.dll + False + + + $(GameManagedDir)\Unity.Services.Core.Scheduler.dll + False + + + $(GameManagedDir)\Unity.Services.Core.Telemetry.dll + False + + + $(GameManagedDir)\Unity.Services.Core.Threading.dll + False + + + $(GameManagedDir)\Unity.Services.Lobbies.dll + False + + + $(GameManagedDir)\Unity.Services.Wire.Internal.dll + False + + + $(GameManagedDir)\Unity.ShaderGraph.Utilities.dll + False + + + $(GameManagedDir)\Unity.TextMeshPro.dll + False + + + $(GameManagedDir)\Unity.VisualEffectGraph.Runtime.dll + False + + + $(GameManagedDir)\UnityEngine.AssetBundleModule.dll + False + + + $(GameManagedDir)\UnityEngine.CoreModule.dll + False + + + $(GameManagedDir)\UnityEngine.IMGUIModule.dll + False + + + $(GameManagedDir)\UnityEngine.UI.dll + False + + + $(GameManagedDir)\UnityEngine.UIModule.dll + False + + + $(GameManagedDir)\UnityEngine.XR.LegacyInputHelpers.dll + False + + + $(GameManagedDir)\UnityEngine.InputLegacyModule.dll + False + + + $(GameManagedDir)\Mirror.dll + False + + + $(GameManagedDir)\Mirror.Authenticators.dll + False + + + $(GameManagedDir)\Mirror.CompilerSymbols.dll + False + + + $(GameManagedDir)\Mirror.Components.dll + False + + + $(GameManagedDir)\Mirror.Transports.dll + False + + + $(GameManagedDir)\Newtonsoft.Json.dll + False + + + $(GameManagedDir)\UniTask.dll + False + + + $(GameManagedDir)\UnityEngine.TextRenderingModule.dll + False + + + $(GameManagedDir)\Cinemachine.dll + False + + + + + + + + + + + \ No newline at end of file diff --git a/IngameReveries/IngameReveries.sln b/IngameReveries/IngameReveries.sln new file mode 100644 index 0000000..67caa47 --- /dev/null +++ b/IngameReveries/IngameReveries.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IngameReveries", "IngameReveries.csproj", "{5FB17C69-0D7A-4FDF-B93E-ACD93A0546A3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5FB17C69-0D7A-4FDF-B93E-ACD93A0546A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5FB17C69-0D7A-4FDF-B93E-ACD93A0546A3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5FB17C69-0D7A-4FDF-B93E-ACD93A0546A3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5FB17C69-0D7A-4FDF-B93E-ACD93A0546A3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/IngameReveries/about/description.txt b/IngameReveries/about/description.txt new file mode 100644 index 0000000..05d8cf8 --- /dev/null +++ b/IngameReveries/about/description.txt @@ -0,0 +1,4 @@ +[h1]Ingame Reveries[/h1] +Displays the daily reveries from the title screen in the ingame pause menu. +[h2]Note[/h2] +Current progress won't be displayed until you go back to the title screen and save the game. \ No newline at end of file diff --git a/IngameReveries/about/icon.png b/IngameReveries/about/icon.png new file mode 100644 index 0000000..9417a73 Binary files /dev/null and b/IngameReveries/about/icon.png differ diff --git a/IngameReveries/about/metadata.json b/IngameReveries/about/metadata.json new file mode 100644 index 0000000..38e19e2 --- /dev/null +++ b/IngameReveries/about/metadata.json @@ -0,0 +1,12 @@ +{ + "id": "com.stuhl.ingamereveries", + "name": "IngameReveries", + "author": "Stuhl", + "modVer": "1.0", + "supportedGameVer": [ + "*" + ], + "assemblies": [ + "bin/Debug/netstandard2.1/IngameReveries.dll" + ] +} \ No newline at end of file diff --git a/IngameReveries/about/preview.png b/IngameReveries/about/preview.png new file mode 100644 index 0000000..550f31d Binary files /dev/null and b/IngameReveries/about/preview.png differ diff --git a/IngameReveries/assets/bundle b/IngameReveries/assets/bundle new file mode 100644 index 0000000..3b20013 Binary files /dev/null and b/IngameReveries/assets/bundle differ diff --git a/README.md b/README.md index fa11b5c..8889834 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ joa coole mod die in einem run ermöglicht, daily quests (Reveries) anzuschauen. +## Current Behaiviour + +Progress lässt sich erst nach dem Rausgehen eines Spiels aktuallisieren. Reroll und claim gehen denoch. + ## Links - [Shape of Dreams Docs](https://github.com/LizardSmoothie/ShapeOfDreamsModDocs)