private static void CustomIllustLoad(MenuIllustration self, string folder) { //Resource Assembly assembly = Assembly.GetExecutingAssembly(); string name = assembly.GetManifestResourceNames().Single(str => str.EndsWith(self.fileName + ".txt")); Debug.Log("LoadingCustomIllustration: " + name); string s; using (Stream manifestResourceStream = assembly.GetManifestResourceStream(name)) { using (StreamReader streamReader = new StreamReader(manifestResourceStream)) { s = streamReader.ReadToEnd(); } } byte[] data = Convert.FromBase64String(s); string text = Custom.RootFolderDirectory() + self.fileName + ".txt"; File.WriteAllBytes(text, data); self.www = new WWW("file:///" + text); //Apply self.texture = new Texture2D(1, 1, TextureFormat.ARGB32, false); self.texture.wrapMode = TextureWrapMode.Clamp; if (self.crispPixels) { self.texture.anisoLevel = 0; self.texture.filterMode = FilterMode.Point; } self.www.LoadImageIntoTexture(self.texture); HeavyTexturesCache.LoadAndCacheAtlasFromTexture(self.fileName, self.texture); self.www = null; File.Delete(text); }
public void Update(MenuScene owner) { if (!alive) { return; } int handle = 0; Vector2?mousePos = Input.mousePosition; // Fade out handles not close to the mouse MenuIllustration closestIllust = null; { float minIllustDist = 20f * 20f; for (int i = 0; i < owner.subObjects.Count; i++) { if (!(owner.subObjects[i] is MenuIllustration illust)) { continue; } float dist = Vector2.SqrMagnitude(illust.pos + illust.size / 2f - mousePos.Value); if (minIllustDist > dist) { closestIllust = illust; minIllustDist = dist; } } } // Update move handles for (int i = 0; i < owner.subObjects.Count; i++) { if (!(owner.subObjects[i] is MenuIllustration illust)) { continue; } if (!customRep.TryGet(illust, out SceneImage csi)) { continue; } Vector2 centerPos = illust.pos + illust.size / 2f; if (handles.Count <= handle) { handles.Add(new MoveHandle(csi.DisplayName)); } handles[handle].SetVisible(illust.sprite.concatenatedAlpha > 0f); handles[handle].Update(ref centerPos, ref mousePos, closestIllust != null && closestIllust != illust); illust.pos = centerPos - illust.size / 2f; csi.Pos = illust.pos; handle++; } // Save on request if (Input.GetKeyDown(KeyCode.LeftBracket)) { CustomScene sceneToSave = null; foreach (var subObj in owner.subObjects) { if (!(subObj is MenuIllustration illust)) { continue; } SceneImage csi = customRep[illust]; if (csi != null && csi.Owner.dirty) { sceneToSave = csi.Owner; break; } } if (sceneToSave != null) { SaveEditedScene(sceneToSave); } } }
private void BuildScene() { switch (this.sceneID) { // Intake System case (MenuScene.SceneID)patch_MenuScene.SceneID.Landscape_IS: this.sceneFolder = "Scenes" + Path.DirectorySeparatorChar + "Landscape - IS"; if (this.flatMode) { this.AddIllustration(new MenuIllustration(this.menu, this, this.sceneFolder, "Landscape - IS - Flat", new Vector2(683f, 384f), false, true)); } else { this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "IS_Landscape - 4", new Vector2(0, 0), 7f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "IS_Landscape - 3", new Vector2(0, 0), 4.2f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "IS_Landscape - 2", new Vector2(0, 0), 3.7f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "IS_Landscape - 1", new Vector2(0, 0), 0.75f, MenuDepthIllustration.MenuShader.Normal)); } if (this.menu.ID == ProcessManager.ProcessID.FastTravelScreen || this.menu.ID == ProcessManager.ProcessID.RegionsOverviewScreen) { this.AddIllustration(new MenuIllustration(this.menu, this, string.Empty, "Title_IS_Shadow", new Vector2(0.01f, 0.01f), true, false)); this.AddIllustration(new MenuIllustration(this.menu, this, string.Empty, "Title_IS", new Vector2(0.01f, 0.01f), true, false)); this.flatIllustrations[this.flatIllustrations.Count - 1].sprite.shader = this.menu.manager.rainWorld.Shaders["MenuText"]; } break; // Forest Sanctuary case (MenuScene.SceneID)patch_MenuScene.SceneID.Landscape_FS: Debug.Log("Loading forest sanctuary"); this.sceneFolder = "Scenes" + Path.DirectorySeparatorChar + "Landscape - FS"; if (this.flatMode) { this.AddIllustration(new MenuIllustration(this.menu, this, this.sceneFolder, "Landscape - FS - Flat", new Vector2(683f, 384f), false, true)); } else { this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "FS_Landscape - 7", new Vector2(0, 0), 13f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "FS_Landscape - 6", new Vector2(0, 0), 11f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "FS_Landscape - 5", new Vector2(0, 0), 9f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "FS_Landscape - 4", new Vector2(0, 0), 7f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "FS_Landscape - 3", new Vector2(0, 0), 4.2f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "FS_Landscape - 2", new Vector2(0, 0), 3.7f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "FS_Landscape - 1", new Vector2(0, 0), 0.75f, MenuDepthIllustration.MenuShader.Normal)); } if (this.menu.ID == ProcessManager.ProcessID.FastTravelScreen || this.menu.ID == ProcessManager.ProcessID.RegionsOverviewScreen) { this.AddIllustration(new MenuIllustration(this.menu, this, string.Empty, "Title_FS_Shadow", new Vector2(0.01f, 0.01f), true, false)); this.AddIllustration(new MenuIllustration(this.menu, this, string.Empty, "Title_FS", new Vector2(0.01f, 0.01f), true, false)); this.flatIllustrations[this.flatIllustrations.Count - 1].sprite.shader = this.menu.manager.rainWorld.Shaders["MenuText"]; } break; // The Fragmented Exterior case (MenuScene.SceneID)patch_MenuScene.SceneID.Landscape_MW: this.sceneFolder = "Scenes" + Path.DirectorySeparatorChar + "Landscape - MW"; if (this.flatMode) { this.AddIllustration(new MenuIllustration(this.menu, this, this.sceneFolder, "Landscape - MW - Flat", new Vector2(683f, 384f), false, true)); } else { this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "MW_Landscape - 4", new Vector2(0, 0), 7f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "MW_Landscape - 3", new Vector2(0, 0), 4.2f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "MW_Landscape - 2", new Vector2(0, 0), 3.7f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "MW_Landscape - 1", new Vector2(0, 0), 0.75f, MenuDepthIllustration.MenuShader.Normal)); } if (this.menu.ID == ProcessManager.ProcessID.FastTravelScreen || this.menu.ID == ProcessManager.ProcessID.RegionsOverviewScreen) { this.AddIllustration(new MenuIllustration(this.menu, this, string.Empty, "Title_MW_Shadow", new Vector2(0.01f, 0.01f), true, false)); this.AddIllustration(new MenuIllustration(this.menu, this, string.Empty, "Title_MW", new Vector2(0.01f, 0.01f), true, false)); this.flatIllustrations[this.flatIllustrations.Count - 1].sprite.shader = this.menu.manager.rainWorld.Shaders["MenuText"]; } break; // Looks To The Moon case (MenuScene.SceneID)patch_MenuScene.SceneID.Landscape_LM: this.sceneFolder = "Scenes" + Path.DirectorySeparatorChar + "Landscape - LM"; if (this.flatMode) { this.AddIllustration(new MenuIllustration(this.menu, this, this.sceneFolder, "Landscape - LM - Flat", new Vector2(683f, 384f), false, true)); } else { this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "LM_Landscape - 7", new Vector2(0, 0), 13f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "LM_Landscape - 6", new Vector2(0, 0), 11f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "LM_Landscape - 5", new Vector2(0, 0), 9f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "LM_Landscape - 4", new Vector2(0, 0), 7f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "LM_Landscape - 3", new Vector2(0, 0), 4.2f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "LM_Landscape - 2", new Vector2(0, 0), 3.7f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "LM_Landscape - 1", new Vector2(0, 0), 0.75f, MenuDepthIllustration.MenuShader.Normal)); } if (this.menu.ID == ProcessManager.ProcessID.FastTravelScreen || this.menu.ID == ProcessManager.ProcessID.RegionsOverviewScreen) { this.AddIllustration(new MenuIllustration(this.menu, this, string.Empty, "Title_LM_Shadow", new Vector2(0.01f, 0.01f), true, false)); this.AddIllustration(new MenuIllustration(this.menu, this, string.Empty, "Title_LM", new Vector2(0.01f, 0.01f), true, false)); this.flatIllustrations[this.flatIllustrations.Count - 1].sprite.shader = this.menu.manager.rainWorld.Shaders["MenuText"]; } break; case (MenuScene.SceneID)patch_MenuScene.SceneID.Dream_Message: if ((this as MenuScene) is InteractiveMenuScene) { ((this as MenuScene) as InteractiveMenuScene).idleDepths = new List <float>(); } Vector2 vector = new Vector2(0f, 0f); this.sceneFolder = "Scenes" + Path.DirectorySeparatorChar + "Dream - Message"; if (this.flatMode) { this.AddIllustration(new MenuIllustration(this.menu, this, this.sceneFolder, "Dream - Message - Flat", new Vector2(683f, 384f), false, true)); } else { this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "Message - 6", new Vector2(71f, 49f), 5f, MenuDepthIllustration.MenuShader.LightEdges)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "Message - 5", new Vector2(71f, 49f), 3f, MenuDepthIllustration.MenuShader.Lighten)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "Message - 4", new Vector2(71f, 49f), 2.5f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "Message - 3", new Vector2(71f, 49f), 2.2f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "Message - 2", new Vector2(71f, 49f), 2.3f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "Message - 1", new Vector2(71f, 49f), 1.5f, MenuDepthIllustration.MenuShader.Lighten)); ((this as MenuScene) as Menu.InteractiveMenuScene).idleDepths.Add(3f); ((this as MenuScene) as Menu.InteractiveMenuScene).idleDepths.Add(2.5f); ((this as MenuScene) as Menu.InteractiveMenuScene).idleDepths.Add(2.3f); ((this as MenuScene) as Menu.InteractiveMenuScene).idleDepths.Add(2.3f); ((this as MenuScene) as Menu.InteractiveMenuScene).idleDepths.Add(1.4f); this.AddIllustration(new MenuIllustration(this.menu, this, this.sceneFolder, "Message - Symbol", new Vector2(683f, 70f), true, false)); MenuIllustration menuIllustration = this.flatIllustrations[this.flatIllustrations.Count - 1]; menuIllustration.pos.x = menuIllustration.pos.x - this.flatIllustrations[this.flatIllustrations.Count - 1].size.x / 2f; } /*string path = Custom.RootFolderDirectory() + Path.DirectorySeparatorChar + "Assets" + Path.DirectorySeparatorChar + "Futile" + Path.DirectorySeparatorChar + "Resources" + Path.DirectorySeparatorChar + this.sceneFolder + Path.DirectorySeparatorChar + "positions.txt"; * * if (this.sceneFolder != string.Empty && File.Exists(path)) * { * string[] array = File.ReadAllLines(path); * int num2 = 0; * while (num2 < array.Length && num2 < this.depthIllustrations.Count) * { * this.depthIllustrations[num2].pos.x = float.Parse(Regex.Split(array[num2], ", ")[0]) + vector.x; * this.depthIllustrations[num2].pos.y = float.Parse(Regex.Split(array[num2], ", ")[1]) + vector.y; * this.depthIllustrations[num2].lastPos = this.depthIllustrations[num2].pos; * num2++; * } * }*/ break; } try { orig_BuildScene(); } catch (Exception e) { Debug.Log("NEW REGION EXCEPTION: " + e); } }
private static void MenuIllustration_LoadFile_1(On.Menu.MenuIllustration.orig_LoadFile_1 orig, MenuIllustration self, string folder) { if (folder.Length >= "KarmaAppetite".Length && folder.Substring(0, "KarmaAppetite".Length) == "KarmaAppetite") { if ((self.fileName.Length >= "Sleep - 2".Length && self.fileName.Substring(0, "Sleep - 2".Length) == "Sleep - 2") || (self.fileName.Length >= "Sleep Screen".Length && self.fileName.Substring(0, "Sleep Screen".Length) == "Sleep Screen")) { CustomIllustLoad(self, folder.Remove(0, "KarmaAppetite".Length)); } else { orig.Invoke(self, folder.Remove(0, "KarmaAppetite".Length)); } } else { orig.Invoke(self, folder); } }
private static void MenuScene_BuildScene(On.Menu.MenuScene.orig_BuildScene orig, MenuScene self) { // Automatically override scenes if the current character has a scene by the same name SlugBaseCharacter currentPlayer; if (PlayerManager.UsingCustomCharacter) { currentPlayer = PlayerManager.CurrentCharacter; } else { int index; if (self.menu.manager.currentMainLoop is RainWorldGame rwg) { index = rwg.StoryCharacter; } else { index = self.menu.manager.rainWorld.progression.PlayingAsSlugcat; } currentPlayer = PlayerManager.GetCustomPlayer(index); } if (currentPlayer != null) { string sceneName = self.sceneID.ToString(); if (sceneOverride == null && currentPlayer.HasScene(sceneName)) { OverrideNextScene(currentPlayer, sceneName); } } if (sceneOverride != null) { try { self.sceneFolder = resourceFolderName; // Check for flatmode support bool hasFlatmode = false; foreach (var img in sceneOverride.Images) { if (img.HasTag("FLATMODE")) { hasFlatmode = true; break; } } // Load all images into the scene for (int imgIndex = 0; imgIndex < sceneOverride.Images.Count; imgIndex++) { var img = sceneOverride.Images[imgIndex]; // Hide disabled images if (!img.Enabled) { continue; } // Allow images to use their own sprites if (!img.OnBuild(self)) { continue; } // Skip this image if it is flatmode only and flatmode is disabled, and vice versa bool flat = img.depth < 0f; bool flatmodeOnly = hasFlatmode && img.HasTag("flatmode"); if (hasFlatmode && (self.flatMode != flatmodeOnly)) { continue; } // Parse alpha float alpha = img.GetProperty <float?>("alpha") ?? 1f; string assetPath = $"{sceneOverride.Owner.Name}\\Scenes\\{sceneOverride.Name}\\{img.assetName}"; Vector2 pos = img.Pos; bool crisp = img.HasTag("CRISP"); string shaderName = img.GetProperty <string>("shader"); FShader shader = null; MenuIllustration illust; if (flat) { // It's Friday // Parse shader if (shaderName != null) { if (!self.menu.manager.rainWorld.Shaders.TryGetValue(shaderName, out shader)) { shader = null; } } // Add a flat illustration illust = new MenuIllustration(self.menu, self, self.sceneFolder, assetPath, pos, crisp, false); if (shader != null) { illust.sprite.shader = shader; } } else { // Parse shader MenuDepthIllustration.MenuShader menuShader = MenuDepthIllustration.MenuShader.Normal; if (shaderName != null) { try { menuShader = Custom.ParseEnum <MenuDepthIllustration.MenuShader>(shaderName); shader = null; } catch { if (!self.menu.manager.rainWorld.Shaders.TryGetValue(shaderName, out shader)) { shader = null; } menuShader = MenuDepthIllustration.MenuShader.Normal; } } // Add an illustration with depth illust = new MenuDepthIllustration(self.menu, self, self.sceneFolder, assetPath, pos, img.Depth, menuShader); // Apply crisp pixels if (crisp) { illust.sprite.element.atlas.texture.filterMode = FilterMode.Point; } } // Add idle depths if (self is InteractiveMenuScene ims) { ims.idleDepths = new List <float>(); List <object> depths = sceneOverride.GetProperty <List <object> >("idledepths"); if (depths != null) { for (int i = 0; i < depths.Count; i++) { if (depths[i] is double depth) { ims.idleDepths.Add((float)depth); } } } } // Apply tags if (shader != null) { illust.sprite.shader = shader; } illust.setAlpha = alpha; self.AddIllustration(illust); // Link back to the custom scene image customRep[illust] = img; } } finally { ClearSceneOverride(); } } else { orig(self); } }
private void BuildScene() { orig_BuildScene(); if (sceneID == (MenuScene.SceneID)patch_MenuScene.SceneID.Dream_Message) { if ((this as MenuScene) is InteractiveMenuScene) { ((this as MenuScene) as InteractiveMenuScene).idleDepths = new List <float>(); } Vector2 vector = new Vector2(0f, 0f); this.sceneFolder = "Scenes" + Path.DirectorySeparatorChar + "Dream - Message"; if (this.flatMode) { this.AddIllustration(new MenuIllustration(this.menu, this, this.sceneFolder, "Dream - Message - Flat", new Vector2(683f, 384f), false, true)); } else { this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "Message - 6", new Vector2(71f, 49f), 5f, MenuDepthIllustration.MenuShader.LightEdges)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "Message - 5", new Vector2(71f, 49f), 3f, MenuDepthIllustration.MenuShader.Lighten)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "Message - 4", new Vector2(71f, 49f), 2.5f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "Message - 3", new Vector2(71f, 49f), 2.2f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "Message - 2", new Vector2(71f, 49f), 2.3f, MenuDepthIllustration.MenuShader.Normal)); this.AddIllustration(new MenuDepthIllustration(this.menu, this, this.sceneFolder, "Message - 1", new Vector2(71f, 49f), 1.5f, MenuDepthIllustration.MenuShader.Lighten)); ((this as MenuScene) as Menu.InteractiveMenuScene).idleDepths.Add(3f); ((this as MenuScene) as Menu.InteractiveMenuScene).idleDepths.Add(2.5f); ((this as MenuScene) as Menu.InteractiveMenuScene).idleDepths.Add(2.3f); ((this as MenuScene) as Menu.InteractiveMenuScene).idleDepths.Add(2.3f); ((this as MenuScene) as Menu.InteractiveMenuScene).idleDepths.Add(1.4f); this.AddIllustration(new MenuIllustration(this.menu, this, this.sceneFolder, "Message - Symbol", new Vector2(683f, 70f), true, false)); MenuIllustration menuIllustration = this.flatIllustrations[this.flatIllustrations.Count - 1]; menuIllustration.pos.x = menuIllustration.pos.x - this.flatIllustrations[this.flatIllustrations.Count - 1].size.x / 2f; } if (this.sceneFolder != string.Empty && File.Exists(string.Concat(new object[] { Custom.RootFolderDirectory(), Path.DirectorySeparatorChar, "Assets", Path.DirectorySeparatorChar, "Futile", Path.DirectorySeparatorChar, "Resources", Path.DirectorySeparatorChar, this.sceneFolder, Path.DirectorySeparatorChar, "positions.txt" }))) { string[] array = File.ReadAllLines(string.Concat(new object[] { Custom.RootFolderDirectory(), Path.DirectorySeparatorChar, "Assets", Path.DirectorySeparatorChar, "Futile", Path.DirectorySeparatorChar, "Resources", Path.DirectorySeparatorChar, this.sceneFolder, Path.DirectorySeparatorChar, "positions.txt" })); int num2 = 0; while (num2 < array.Length && num2 < this.depthIllustrations.Count) { this.depthIllustrations[num2].pos.x = float.Parse(Regex.Split(array[num2], ", ")[0]) + vector.x; this.depthIllustrations[num2].pos.y = float.Parse(Regex.Split(array[num2], ", ")[1]) + vector.y; this.depthIllustrations[num2].lastPos = this.depthIllustrations[num2].pos; num2++; } } } }
private static void MenuScene_AddIllustration(On.Menu.MenuScene.orig_AddIllustration orig, MenuScene self, MenuIllustration newIllu) { SlugBaseCharacter chara = PlayerManager.GetCustomPlayer(self.menu.manager.rainWorld.progression.miscProgressionData.currentlySelectedSinglePlayerSlugcat); if (newIllu.fileName == "Sleep - 2 - Red" && chara != null && !chara.HasScene("SleepScreen") && ((self.menu as SleepAndDeathScreen)?.IsSleepScreen ?? false) && newIllu is MenuDepthIllustration mdi) { string folder = string.Concat(new object[] { "Scenes", Path.DirectorySeparatorChar, "Sleep Screen - White", }); newIllu.RemoveSprites(); newIllu = new MenuDepthIllustration(newIllu.menu, newIllu.owner, folder, "Sleep - 2 - White", new Vector2(677f, 63f), mdi.depth, mdi.shader); moveImages.Add(new KeyValuePair <MenuDepthIllustration, Vector2>((MenuDepthIllustration)newIllu, new Vector2(677f, 63f))); } orig(self, newIllu); }