Compare commits
17
Commits
c8361d7ebf
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4226c2be0 | ||
|
|
ef7def0790 | ||
|
|
e5c35b9941 | ||
|
|
50fb0c1410 | ||
|
|
4bd6862b46 | ||
|
|
3e6d700200 | ||
|
|
900b97583b | ||
|
|
9389a13d2e | ||
|
|
2820d0860b | ||
|
|
d95935d140 | ||
|
|
7a1227d588 | ||
|
|
f53b8fa854 | ||
|
|
3c623afb79 | ||
|
|
e4205b59bd | ||
|
|
8398bf5f12 | ||
|
|
3ceaff0d4e | ||
|
|
9117362f03 |
@@ -1,8 +1,9 @@
|
|||||||
using System;
|
using System.IO;
|
||||||
using System.Collections;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using HarmonyLib;
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
|
||||||
namespace IngameReveries
|
namespace IngameReveries
|
||||||
@@ -11,6 +12,11 @@ namespace IngameReveries
|
|||||||
// Multiple ModBehaviours in your mod will share the same container.
|
// Multiple ModBehaviours in your mod will share the same container.
|
||||||
public class IngameReveries : ModBehaviour
|
public class IngameReveries : ModBehaviour
|
||||||
{
|
{
|
||||||
|
private GameObject _ingameReveriesUI;
|
||||||
|
|
||||||
|
private AssetBundle _reveriesBundle;
|
||||||
|
private GameObject _reveriesPrefab;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
// Metadata of your mod is stored in this.about
|
// Metadata of your mod is stored in this.about
|
||||||
@@ -21,11 +27,148 @@ namespace IngameReveries
|
|||||||
harmony.PatchAll();
|
harmony.PatchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
InitializeAssets();
|
||||||
|
|
||||||
|
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
// Make sure you clean up properly to support Live Reload.
|
// Make sure you clean up properly to support Live Reload.
|
||||||
Debug.Log("Good bye! " + mod.metadata.id);
|
Debug.Log("Good bye! " + mod.metadata.id);
|
||||||
harmony.UnpatchAll();
|
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<UI_Reveries>();
|
||||||
|
|
||||||
|
// Show reveries window
|
||||||
|
var canvasGroup = _ingameReveriesUI.GetComponent<CanvasGroup>();
|
||||||
|
canvasGroup.alpha = 1f;
|
||||||
|
canvasGroup.interactable = true;
|
||||||
|
canvasGroup.blocksRaycasts = true;
|
||||||
|
|
||||||
|
// Position reveries window top left
|
||||||
|
var rect = _ingameReveriesUI.GetComponent<RectTransform>();
|
||||||
|
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<GameObject>(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<TMP_FontAsset>();
|
||||||
|
|
||||||
|
// Get all text from the reveries window
|
||||||
|
TMP_Text[] textComponents = _ingameReveriesUI.GetComponentsInChildren<TMP_Text>(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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,6 +219,10 @@
|
|||||||
<HintPath>$(GameManagedDir)\Unity.VisualEffectGraph.Runtime.dll</HintPath>
|
<HintPath>$(GameManagedDir)\Unity.VisualEffectGraph.Runtime.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.AssetBundleModule">
|
||||||
|
<HintPath>$(GameManagedDir)\UnityEngine.AssetBundleModule.dll</HintPath>
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="UnityEngine.CoreModule">
|
<Reference Include="UnityEngine.CoreModule">
|
||||||
<HintPath>$(GameManagedDir)\UnityEngine.CoreModule.dll</HintPath>
|
<HintPath>$(GameManagedDir)\UnityEngine.CoreModule.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
@@ -231,6 +235,10 @@
|
|||||||
<HintPath>$(GameManagedDir)\UnityEngine.UI.dll</HintPath>
|
<HintPath>$(GameManagedDir)\UnityEngine.UI.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UIModule">
|
||||||
|
<HintPath>$(GameManagedDir)\UnityEngine.UIModule.dll</HintPath>
|
||||||
|
<Private>False</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="UnityEngine.XR.LegacyInputHelpers">
|
<Reference Include="UnityEngine.XR.LegacyInputHelpers">
|
||||||
<HintPath>$(GameManagedDir)\UnityEngine.XR.LegacyInputHelpers.dll</HintPath>
|
<HintPath>$(GameManagedDir)\UnityEngine.XR.LegacyInputHelpers.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
@@ -277,7 +285,11 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="src\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
<Exec Command="echo "Copy build to game folder"
mkdir -p "$(GameModsDir)"
cp -r "$(ProjectDir)about" "$(GameModsDir)"
cp -r "$(ProjectDir)bin" "$(GameModsDir)"" />
|
<Exec Command="echo "Copy build to game folder"
mkdir -p "$(GameModsDir)"
cp -r "$(ProjectDir)about" "$(GameModsDir)"
cp -r "$(ProjectDir)bin" "$(GameModsDir)"
cp -r "$(ProjectDir)assets" "$(GameModsDir)"" />
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
[h1]Hello World![/h1]
|
[h1]Ingame Reveries[/h1]
|
||||||
This description will be shown on the mod manager, and be uploaded to Steam Workshop.
|
Displays the daily reveries from the title screen in the ingame pause menu.
|
||||||
Note some tags like tables, links and images are not supported in the in-game mod manager and will be either omitted / shown as plain-text.
|
[h2]Note[/h2]
|
||||||
|
Current progress won't be displayed until you go back to the title screen and save the game.
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 31 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 269 KiB |
Binary file not shown.
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
joa coole mod die in einem run ermöglicht, daily quests (Reveries) anzuschauen.
|
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
|
## Links
|
||||||
|
|
||||||
- [Shape of Dreams Docs](https://github.com/LizardSmoothie/ShapeOfDreamsModDocs)
|
- [Shape of Dreams Docs](https://github.com/LizardSmoothie/ShapeOfDreamsModDocs)
|
||||||
|
|||||||
Reference in New Issue
Block a user