public void BeforeRender() { if (!Focused || !Visible || Lines == null) { return; } if (logBuffer == null) { logBuffer = VirtualContent.CreateRenderTarget("loggedprogress-log", logBounds.Width, logBounds.Height); } Engine.Graphics.GraphicsDevice.SetRenderTarget(logBuffer.Target); Engine.Graphics.GraphicsDevice.Clear(Color.Transparent); Draw.SpriteBatch.Begin(); for (int i = 0; i < Lines.Count; i++) { ActiveFont.Draw( Lines[i], new Vector2(8f, logBuffer.Height - 8f - (30f * (Lines.Count - i))), Vector2.Zero, Vector2.One * 0.5f, Color.White ); } Draw.SpriteBatch.End(); }
public static Language FromModExport(ModAsset asset) { Language lang = new Language(); using (BinaryReader reader = new BinaryReader(asset.Stream)) { lang.Id = reader.ReadString(); lang.Label = reader.ReadString(); lang.IconPath = reader.ReadString(); lang.Icon = new MTexture(VirtualContent.CreateTexture(Path.Combine("Dialog", lang.IconPath))); lang.Order = reader.ReadInt32(); lang.FontFace = reader.ReadString(); lang.FontFaceSize = reader.ReadSingle(); lang.SplitRegex = reader.ReadString(); lang.CommaCharacters = reader.ReadString(); lang.PeriodCharacters = reader.ReadString(); lang.Lines = reader.ReadInt32(); lang.Words = reader.ReadInt32(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { string key = reader.ReadString(); lang.Dialog[key] = reader.ReadString(); lang.Cleaned[key] = reader.ReadString(); } } return(lang); }
public override void LoadContent(bool firstLoad) { // Check if the current input GUI override is still valid. If so, apply it. if (!string.IsNullOrEmpty(Settings.InputGui)) { string inputGuiPath = $"controls/{Settings.InputGui}/"; if (GFX.Gui.GetTextures().Any(kvp => kvp.Key.StartsWith(inputGuiPath))) { Input.OverrideInputPrefix = Settings.InputGui; } else { Settings.InputGui = ""; } } if (firstLoad && !Everest.Flags.AvoidRenderTargets) { SubHudRenderer.Buffer = VirtualContent.CreateRenderTarget("subhud-target", 1922, 1082); } if (Everest.Flags.AvoidRenderTargets && Celeste.HudTarget != null) { Celeste.HudTarget.Dispose(); Celeste.HudTarget = null; } if (GFX.MountainTerrain == null && Settings.NonThreadedGL) { GFX.MountainTerrain = ObjModel.Create(Path.Combine(Engine.ContentDirectory, "Overworld", "mountain.obj")); GFX.MountainBuildings = ObjModel.Create(Path.Combine(Engine.ContentDirectory, "Overworld", "buildings.obj")); GFX.MountainCoreWall = ObjModel.Create(Path.Combine(Engine.ContentDirectory, "Overworld", "mountain_wall.obj")); } // Otherwise loaded in GameLoader.LoadThread }
private void onGameplayBuffersCreate(On.Celeste.GameplayBuffers.orig_Create orig) { orig(); // create the foreground effect buffer as well. foregroundEffectBuffer = VirtualContent.CreateRenderTarget("foreground-effect-buffer", 320, 180); }
public override void LoadContent(bool firstLoad) { // Check if the current input GUI override is still valid. If so, apply it. if (!string.IsNullOrEmpty(Settings.InputGui)) { string inputGuiPath = $"controls/{Settings.InputGui}/"; if (GFX.Gui.GetTextures().Any(kvp => kvp.Key.StartsWith(inputGuiPath))) { Input.OverrideInputPrefix = Settings.InputGui; } else { Settings.InputGui = ""; } } if (firstLoad && !Everest.Flags.AvoidRenderTargets) { SubHudRenderer.Buffer = VirtualContent.CreateRenderTarget("subhud-target", 1922, 1082); } if (Everest.Flags.AvoidRenderTargets && Celeste.HudTarget != null) { Celeste.HudTarget.Dispose(); Celeste.HudTarget = null; } }
private void onGameplayBuffersCreate(On.Celeste.GameplayBuffers.orig_Create orig) { orig(); // create the blur temp buffer as well. tempBuffer = VirtualContent.CreateRenderTarget("extended-variants-temp-blur-buffer", 320, 180); }
private void onGameplayBuffersCreate(On.Celeste.GameplayBuffers.orig_Create orig) { orig(); // create the black mask as well. blackMask = VirtualContent.CreateRenderTarget("extended-variants-black-mask", 320, 180); }
public void Alloc() { if (allocated) { return; } allocated = true; HudTarget = VirtualContent.CreateRenderTarget("hud-target", 1922, 1082); }
public DreamJellyfishRenderer() { Depth = Depths.Player - 4; Tag = Tags.Global | Tags.TransitionUpdate; /* * Okay, so this was the only way I could imagine doing this. * I was told that using a render target for masking stuff was a bit brutal, but I couldn't find another way. */ renderTarget = VirtualContent.CreateRenderTarget("communalhelper-dreamjellyfishrenderer", 48, 42); }
public override void Load() { IL.Celeste.Level.Render += modLevelRender; On.Celeste.GameplayBuffers.Create += onGameplayBuffersCreate; On.Celeste.GameplayBuffers.Unload += onGameplayBuffersUnload; if (Engine.Scene is Level) { // we are already in a map, aaaaa, create the blur temp buffer real quick tempBuffer = VirtualContent.CreateRenderTarget("extended-variants-temp-blur-buffer", 320, 180); } }
public Emulator(Scene returnTo, int levelX = 0, int levelY = 0) { ReturnTo = returnTo; bootLevel = new Point(levelX, levelY); buffer = VirtualContent.CreateRenderTarget("pico-8", 128, 128); // sprites var atlas = GFX.Game["pico8/atlas"]; sprites = new MTexture[(atlas.Width / 8) * (atlas.Height / 8)]; for (int ty = 0; ty < atlas.Height / 8; ty++) { for (int tx = 0; tx < atlas.Width / 8; tx++) { sprites[tx + ty * (atlas.Width / 8)] = atlas.GetSubtexture(tx * 8, ty * 8, 8, 8); } } // tilemap var tiledata = MapData; tiledata = Regex.Replace(tiledata, @"\s+", ""); tilemap = new byte[tiledata.Length / 2]; for (int i = 0, len = tiledata.Length, hlen = len / 2; i < len; i += 2) { var a = tiledata[i]; var b = tiledata[i + 1]; var str = (i < hlen ? (a.ToString() + b.ToString()) : (b.ToString() + a.ToString())); tilemap[i / 2] = (byte)int.Parse(str, System.Globalization.NumberStyles.HexNumber); } // font var fontatlas = GFX.Game["pico8/font"]; font = new MTexture[(fontatlas.Width / 4) * (fontatlas.Height / 6)]; for (var ty = 0; ty < fontatlas.Height / 6; ty++) { for (var tx = 0; tx < fontatlas.Width / 4; tx++) { font[tx + ty * (fontatlas.Width / 4)] = fontatlas.GetSubtexture(tx * 4, ty * 6, 4, 6); } } // boot stuff picoBootLogo = GFX.Game["pico8/logo"]; ResetScreen(); Audio.SetMusic(null); Audio.SetAmbience(null); new FadeWipe(this, true); RendererList.UpdateLists(); }
public override void Load() { IL.Celeste.Level.Render += modLevelRender; On.Celeste.Level.BeforeRender += onLevelBeforeRender; On.Celeste.GameplayBuffers.Create += onGameplayBuffersCreate; On.Celeste.GameplayBuffers.Unload += onGameplayBuffersUnload; if (Engine.Scene is Level) { // we are already in a map, aaaaa, create the black mask real quick blackMask = VirtualContent.CreateRenderTarget("extended-variants-black-mask", 320, 180); } }
private void BeforeRender() { if (BlockFill == null) { BlockFill = VirtualContent.CreateRenderTarget("block-fill", 320, 180, false, true, 0); } if (this.vertexCount <= 0) { return; } Engine.Graphics.GraphicsDevice.SetRenderTarget((RenderTarget2D)BlockFill); Engine.Graphics.GraphicsDevice.Clear(wipeColor); GFX.DrawVertices <VertexPositionColor>(Matrix.Identity, this.vertices, this.vertexCount, (Effect)null, (BlendState)null); }
public override void LoadContent(bool firstLoad) { // Check if the current input GUI override is still valid. If so, apply it. if (!string.IsNullOrEmpty(Settings.InputGui)) { string inputGuiPath = $"controls/{Settings.InputGui}/"; if (GFX.Gui.GetTextures().Any(kvp => kvp.Key.StartsWith(inputGuiPath))) { Input.OverrideInputPrefix = Settings.InputGui; } else { Settings.InputGui = ""; } } if (firstLoad && !Everest.Flags.AvoidRenderTargets) { SubHudRenderer.Buffer = VirtualContent.CreateRenderTarget("subhud-target", 1922, 1082); } if (Everest.Flags.AvoidRenderTargets && Celeste.HudTarget != null) { Celeste.HudTarget.Dispose(); Celeste.HudTarget = null; } if (Settings.NonThreadedGL) { GFX.Load(); MTN.Load(); GFX.LoadData(); MTN.LoadData(); } // Otherwise loaded in GameLoader.LoadThread // Celeste 1.3.0.0 gets rid of those. for (int i = 0; i <= 29; i++) { GFX.Game[$"objects/checkpoint/flag{i:D2}"] = GFX.Game["util/pixel"]; } for (int i = 0; i <= 27; i++) { GFX.Game[$"objects/checkpoint/obelisk{i:D2}"] = GFX.Game["util/pixel"]; } GFX.Gui["fileselect/assist"] = GFX.Game["util/pixel"]; GFX.Gui["fileselect/cheatmode"] = GFX.Game["util/pixel"]; }
protected override void LoadContent() { // Note: You may instinctually call base.LoadContent(); // DON'T! The original method is orig_LoadContent bool firstLoad = this.firstLoad; orig_LoadContent(); if (firstLoad) { SubHudRenderer.Buffer = VirtualContent.CreateRenderTarget("subhud-target", 1922, 1082); } Everest.Invoke("LoadContent"); Everest.Invoke("LoadContent", firstLoad); }
public static void PostLanguageLoad() { Language[] langs = Dialog.Languages.Values.Distinct().ToArray(); Dialog.Languages.Clear(); foreach (Language lang in langs) { if (lang.Dialog.Count == 0 || (string.IsNullOrEmpty(lang.Label) && string.IsNullOrEmpty(lang.FontFace) && string.IsNullOrEmpty(lang.IconPath))) { if (lang.Icon != null) { lang.Dispose(); } continue; } if (string.IsNullOrEmpty(lang.FontFace)) { lang.FontFace = "Renogare"; lang.FontFaceSize = 64; } if (lang.Icon == null) { lang.Icon = new MTexture(VirtualContent.CreateTexture(Path.Combine("Graphics", "Atlases", "Gui", "menu", "langnoicon"))); } Dialog.Languages[lang.Id] = lang; if (lang.Id.Equals("english", StringComparison.InvariantCultureIgnoreCase)) { FallbackLanguage = lang; } } Dialog.OrderedLanguages = new List <Language>(); foreach (KeyValuePair <string, Language> keyValuePair in Dialog.Languages) { Dialog.OrderedLanguages.Add(keyValuePair.Value); } Dialog.OrderedLanguages.Sort((a, b) => a.Order != b.Order ? a.Order - b.Order : a.Id.CompareTo(b.Id)); }
public IEnumerator Enter() { PageIndex = 0; Visible = true; X = -1920f; turningPage = false; turningScale = 1f; rotation = 0f; dot = 0f; dotTarget = 0f; dotEase = 0f; leftArrowEase = 0f; rightArrowEase = 0f; NextPageBuffer = VirtualContent.CreateRenderTarget("journal-a", 1610, 1000, false, true, 0); CurrentPageBuffer = VirtualContent.CreateRenderTarget("journal-b", 1610, 1000, false, true, 0); int num = 0; foreach (CustomJournalPage CustomJournalPage in Pages) { CustomJournalPage.PageIndex = num++; } Pages[0].Redraw(CurrentPageBuffer); //this.cameraStart = this.Overworld.Mountain.UntiltedCamera; //this.cameraEnd = this.cameraStart; //this.cameraEnd.Position = this.cameraEnd.Position + -this.cameraStart.Rotation.Forward() * 1f; //this.Overworld.Mountain.EaseCamera(this.Overworld.Mountain.Area, this.cameraEnd, new float?(2f), true, false); //this.Overworld.Mountain.AllowUserRotation = false; for (float p = 0f; p < 1f; p += Engine.DeltaTime / 0.4f) { rotation = -0.025f * Ease.BackOut(p); X = -1920f + 1920f * Ease.CubeInOut(p); dotEase = p; yield return(null); } dotEase = 1f; yield break; }
private void BeforeRender() { List <Entity> glassBlocks = Scene.Tracker.GetEntities <CustomizableGlassBlock>(); hasBlocks = (glassBlocks.Count > 0); if (!hasBlocks) { return; } Camera camera = (Scene as Level).Camera; int screenWidth = 320; int screenHeight = 180; // draw stars if (starsTarget == null) { starsTarget = VirtualContent.CreateRenderTarget("customizable-glass-block-surfaces", screenWidth, screenHeight); } Engine.Graphics.GraphicsDevice.SetRenderTarget(starsTarget); Engine.Graphics.GraphicsDevice.Clear(Color.Transparent); Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, null, Matrix.Identity); Vector2 origin = new Vector2(8f, 8f); for (int i = 0; i < stars.Length; i++) { MTexture starTexture = stars[i].Texture; Color starColor = stars[i].Color * alpha; Vector2 starScroll = stars[i].Scroll; Vector2 starActualPosition = default; starActualPosition.X = Mod(stars[i].Position.X - camera.X * (1f - starScroll.X), screenWidth); starActualPosition.Y = Mod(stars[i].Position.Y - camera.Y * (1f - starScroll.Y), screenHeight); starTexture.Draw(starActualPosition, origin, starColor); if (starActualPosition.X < origin.X) { starTexture.Draw(starActualPosition + new Vector2(screenWidth, 0f), origin, starColor); } else if (starActualPosition.X > screenWidth - origin.X) { starTexture.Draw(starActualPosition - new Vector2(screenWidth, 0f), origin, starColor); } if (starActualPosition.Y < origin.Y) { starTexture.Draw(starActualPosition + new Vector2(0f, screenHeight), origin, starColor); } else if (starActualPosition.Y > screenHeight - origin.Y) { starTexture.Draw(starActualPosition - new Vector2(0f, screenHeight), origin, starColor); } } Draw.SpriteBatch.End(); // draw rays/beams int vertex = 0; for (int j = 0; j < rays.Length; j++) { Vector2 rayPosition = default; rayPosition.X = Mod(rays[j].Position.X - camera.X * 0.9f, screenWidth); rayPosition.Y = Mod(rays[j].Position.Y - camera.Y * 0.9f, screenHeight); DrawRay(rayPosition, ref vertex, ref rays[j]); if (rayPosition.X < 64f) { DrawRay(rayPosition + new Vector2(screenWidth, 0f), ref vertex, ref rays[j]); } else if (rayPosition.X > (screenWidth - 64)) { DrawRay(rayPosition - new Vector2(screenWidth, 0f), ref vertex, ref rays[j]); } if (rayPosition.Y < 64f) { DrawRay(rayPosition + new Vector2(0f, screenHeight), ref vertex, ref rays[j]); } else if (rayPosition.Y > (screenHeight - 64)) { DrawRay(rayPosition - new Vector2(0f, screenHeight), ref vertex, ref rays[j]); } } if (beamsTarget == null) { beamsTarget = VirtualContent.CreateRenderTarget("customizable-glass-block-beams", screenWidth, screenHeight); } Engine.Graphics.GraphicsDevice.SetRenderTarget(beamsTarget); Engine.Graphics.GraphicsDevice.Clear(Color.Transparent); GFX.DrawVertices(Matrix.Identity, verts, vertex); // if fading in, update the alpha value to fade in in ~0.25 seconds. if (alpha != 1f) { alpha = Calc.Approach(alpha, 1f, Engine.DeltaTime * 4f); } }
private static void ReadAtlasData(Atlas _atlas, string path, AtlasDataFormat format) { if (VTextureToMTextureMap == null) { VTextureToMTextureMap = new Dictionary <string, MTexture>(); } patch_Atlas atlas = (patch_Atlas)_atlas; string pathFull = Path.Combine(Engine.ContentDirectory, path); XmlDocument xmlDoc; VirtualTexture texV; MTexture texM; switch (format) { case AtlasDataFormat.TexturePacker_Sparrow: xmlDoc = Calc.LoadContentXML(path); XmlElement xmlTextureAtlas = xmlDoc["TextureAtlas"]; if (xmlTextureAtlas == null) { break; } texV = VirtualContent.CreateTexture(Path.Combine(Path.GetDirectoryName(path), xmlTextureAtlas.Attr("imagePath", ""))); texM = new MTexture(texV); VTextureToMTextureMap[texV.Name] = texM; atlas.Sources.Add(texV); XmlNodeList xmlSubs = xmlTextureAtlas.GetElementsByTagName("SubTexture"); foreach (XmlElement xmlSub in xmlSubs) { string name = xmlSub.Attr("name"); Rectangle clipRect = xmlSub.Rect(); if (xmlSub.HasAttr("frameX")) { atlas.textures[name] = new MTexture( texM, name, clipRect, new Vector2(-xmlSub.AttrInt("frameX"), -xmlSub.AttrInt("frameY")), xmlSub.AttrInt("frameWidth"), xmlSub.AttrInt("frameHeight") ); } else { atlas.textures[name] = new MTexture(texM, name, clipRect); } } break; case AtlasDataFormat.CrunchXml: if (!File.Exists(pathFull)) { break; } xmlDoc = Calc.LoadContentXML(path); XmlElement xmlAtlas = xmlDoc["atlas"]; foreach (XmlElement xmlAtlasSource in xmlAtlas) { texV = VirtualContent.CreateTexture(Path.Combine(Path.GetDirectoryName(path), xmlAtlasSource.Attr("n", "") + ".png")); texM = new MTexture(texV); VTextureToMTextureMap[texV.Name] = texM; atlas.Sources.Add(texV); foreach (XmlElement xmlSub in xmlAtlasSource) { string name = xmlSub.Attr("n"); Rectangle clipRect = new Rectangle(xmlSub.AttrInt("x"), xmlSub.AttrInt("y"), xmlSub.AttrInt("w"), xmlSub.AttrInt("h")); if (xmlSub.HasAttr("fx")) { atlas.textures[name] = new MTexture( texM, name, clipRect, new Vector2(-xmlSub.AttrInt("fx"), -xmlSub.AttrInt("fy")), xmlSub.AttrInt("fw"), xmlSub.AttrInt("fh") ); } else { atlas.textures[name] = new MTexture(texM, name, clipRect); } } } break; case AtlasDataFormat.CrunchBinary: if (!File.Exists(pathFull)) { break; } using (FileStream stream = File.OpenRead(pathFull)) using (BinaryReader reader = new BinaryReader(stream)) { short sources = reader.ReadInt16(); for (int i = 0; i < sources; i++) { texV = VirtualContent.CreateTexture(Path.Combine(Path.GetDirectoryName(path), reader.ReadNullTerminatedString() + ".png")); texM = new MTexture(texV); VTextureToMTextureMap[texV.Name] = texM; atlas.Sources.Add(texV); short subs = reader.ReadInt16(); for (int j = 0; j < subs; j++) { string name = reader.ReadNullTerminatedString(); short clipX = reader.ReadInt16(); short clipY = reader.ReadInt16(); short clipWidth = reader.ReadInt16(); short clipHeight = reader.ReadInt16(); short offsX = reader.ReadInt16(); short offsY = reader.ReadInt16(); short width = reader.ReadInt16(); short height = reader.ReadInt16(); atlas.textures[name] = new MTexture( texM, name, new Rectangle(clipX, clipY, clipWidth, clipHeight), new Vector2(-offsX, -offsY), width, height ); } } } break; case AtlasDataFormat.CrunchXmlOrBinary: if (File.Exists(pathFull + ".bin")) { ReadAtlasData(atlas, path + ".bin", AtlasDataFormat.CrunchBinary); } else if (File.Exists(pathFull + ".xml")) { ReadAtlasData(atlas, path + ".xml", AtlasDataFormat.CrunchXml); } return; case AtlasDataFormat.CrunchBinaryNoAtlas: if (!File.Exists(pathFull + ".bin")) { break; } using (FileStream stream = File.OpenRead(pathFull + ".bin")) using (BinaryReader reader = new BinaryReader(stream)) { short sources = reader.ReadInt16(); for (int i = 0; i < sources; i++) { string sourcePath = Path.Combine(Path.GetDirectoryName(path), reader.ReadNullTerminatedString()); short subs = reader.ReadInt16(); for (int j = 0; j < subs; j++) { string name = reader.ReadNullTerminatedString(); short unknownA = reader.ReadInt16(); short unknownB = reader.ReadInt16(); short unknownC = reader.ReadInt16(); short unknownD = reader.ReadInt16(); short offsX = reader.ReadInt16(); short offsY = reader.ReadInt16(); short width = reader.ReadInt16(); short height = reader.ReadInt16(); texV = VirtualContent.CreateTexture(Path.Combine(sourcePath, name + ".png")); atlas.textures[name] = VTextureToMTextureMap[texV.Name] = new MTexture(texV, new Vector2(-offsX, -offsY), width, height); atlas.Sources.Add(texV); } } } break; case AtlasDataFormat.Packer: if (!File.Exists(pathFull + ".meta")) { break; } using (FileStream stream = File.OpenRead(pathFull + ".meta")) using (BinaryReader reader = new BinaryReader(stream)) { reader.ReadInt32(); // ??? reader.ReadString(); // ??? reader.ReadInt32(); // ??? short sources = reader.ReadInt16(); for (int i = 0; i < sources; i++) { texV = VirtualContent.CreateTexture(Path.Combine(Path.GetDirectoryName(path), reader.ReadString() + ".data")); texM = new MTexture(texV); VTextureToMTextureMap[texV.Name] = texM; atlas.Sources.Add(texV); short subs = reader.ReadInt16(); for (int j = 0; j < subs; j++) { string name = reader.ReadString().Replace('\\', '/'); short clipX = reader.ReadInt16(); short clipY = reader.ReadInt16(); short clipWidth = reader.ReadInt16(); short clipHeight = reader.ReadInt16(); short offsX = reader.ReadInt16(); short offsY = reader.ReadInt16(); short width = reader.ReadInt16(); short height = reader.ReadInt16(); atlas.textures[name] = new MTexture( texM, name, new Rectangle(clipX, clipY, clipWidth, clipHeight), new Vector2(-offsX, -offsY), width, height ); } } } break; case AtlasDataFormat.PackerNoAtlas: if (!File.Exists(pathFull + ".meta")) { break; } using (FileStream stream = File.OpenRead(pathFull + ".meta")) using (BinaryReader reader = new BinaryReader(stream)) { reader.ReadInt32(); reader.ReadString(); reader.ReadInt32(); short sources = reader.ReadInt16(); for (int i = 0; i < sources; i++) { string sourcePath = Path.Combine(Path.GetDirectoryName(path), reader.ReadString()); short subs = reader.ReadInt16(); for (int j = 0; j < subs; j++) { string name = reader.ReadString().Replace('\\', '/'); short unknownA = reader.ReadInt16(); short unknownB = reader.ReadInt16(); short unknownC = reader.ReadInt16(); short unknownD = reader.ReadInt16(); short offsX = reader.ReadInt16(); short offsY = reader.ReadInt16(); short width = reader.ReadInt16(); short height = reader.ReadInt16(); texV = VirtualContent.CreateTexture(Path.Combine(sourcePath, name + ".data")); atlas.textures[name] = VTextureToMTextureMap[texV.Name] = new MTexture(texV, new Vector2(-offsX, -offsY), width, height); atlas.Sources.Add(texV); } } } break; default: break; } }
public static Language LoadLanguage(string filename) { Language language = orig_LoadLanguage(filename); if (language.Id.Equals("english", StringComparison.InvariantCultureIgnoreCase)) { FallbackLanguage = language; } string path = filename; if (path.StartsWith(Everest.Content.PathContentOrig)) { path = path.Substring(Everest.Content.PathContentOrig.Length + 1); } path = path.Replace('\\', '/'); if (path.EndsWith(".txt")) { path = path.Substring(0, path.Length - 4); } IEnumerable <ModAsset> metas = Everest.Content.Mods.Select(mod => { ModAsset asset; if (mod.Map.TryGetValue(path, out asset)) { return(asset); } return(null); }).Where(asset => asset != null); if (!metas.Any()) { return(language); } foreach (ModAsset meta in metas) { string line; string currentName = ""; StringBuilder builder = new StringBuilder(); string prev = ""; using (StreamReader reader = new StreamReader(meta.Stream)) while (reader.Peek() != -1) { line = reader.ReadLine().Trim('\r', '\n').Trim(); // The following is the original parser decompiled and formatted to our best understanding. // ??? bool startsWithVariable = false; foreach (string variable in LanguageDataVariables) { if (!string.IsNullOrEmpty(variable) && line.StartsWith(variable, StringComparison.InvariantCultureIgnoreCase)) { startsWithVariable = true; break; } } if (!startsWithVariable) { line = Regex.Replace(line, @"\[unknown\]", @"", RegexOptions.IgnoreCase); line = Regex.Replace(line, @"\[left\]", @"{left}", RegexOptions.IgnoreCase); line = Regex.Replace(line, @"\[right\]", @"{right}", RegexOptions.IgnoreCase); line = Regex.Replace(line, @"\[(?<content>[^\[\\]*(?:\\.[^\]\\]*)*)\]", @"{portrait ${content}}"); } if (line.Length <= 0) { continue; } if (line[0] == '#') { continue; } line = line.Replace("\\#", "#"); bool isVariable = variable.IsMatch(line); if (!isVariable) { if (builder.Length > 0) { string built = builder.ToString(); if (!built.EndsWith("{break}") && !built.EndsWith("{n}") && command.Replace(prev, "").Length > 0) { builder.Append("{break}"); } } builder.Append(line); goto Next; } if (!string.IsNullOrEmpty(currentName) && !language.Dialog.ContainsKey(currentName)) { language.Dialog.Add(currentName, builder.ToString()); } string[] splitByEqual = line.Split('='); string name = splitByEqual[0].Trim(); string value = (splitByEqual.Length > 1) ? splitByEqual[1].Trim() : ""; if (name.Equals("language", StringComparison.OrdinalIgnoreCase)) { string[] splitByComma = value.Split(','); if (!Dialog.Languages.TryGetValue(splitByComma[0], out language)) { language = new Language(); language.FontFace = null; language.Id = splitByComma[0]; Dialog.Languages.Add(language.Id, language); } if (splitByComma.Length > 1) { language.Label = splitByComma[1]; } goto Next; } if (name.Equals("icon", StringComparison.OrdinalIgnoreCase)) { VirtualTexture texture = VirtualContent.CreateTexture(Path.Combine("Dialog", value)); language.Icon = new MTexture(texture); goto Next; } if (name.Equals("order", StringComparison.OrdinalIgnoreCase)) { language.Order = int.Parse(value); goto Next; } if (name.Equals("font", StringComparison.OrdinalIgnoreCase)) { string[] splitByComma = value.Split(','); language.FontFace = splitByComma[0]; language.FontFaceSize = float.Parse(splitByComma[1], CultureInfo.InvariantCulture); goto Next; } if (name.Equals("SPLIT_REGEX", StringComparison.OrdinalIgnoreCase)) { language.SplitRegex = value; goto Next; } if (name.Equals("commas", StringComparison.OrdinalIgnoreCase)) { language.CommaCharacters = value; goto Next; } if (name.Equals("periods", StringComparison.OrdinalIgnoreCase)) { language.PeriodCharacters = value; goto Next; } currentName = name; builder.Clear(); builder.Append(value); Next: prev = line; } // The game originally also checks if the key already exists and uses Add(...). if (!string.IsNullOrEmpty(currentName) /* && !language.Dialog.ContainsKey(currentName)*/) { // language.Dialog.Add(currentName, builder.ToString()); language.Dialog[currentName] = builder.ToString(); } } return(language); }
public override void Awake(Scene scene) { base.Awake(scene); renderTarget = VirtualContent.CreateRenderTarget("madelineparty-better-textmenu", Crop.Width, Crop.Height); }
private void BeforeRender() { if (loading) { return; } if (screenBuffer == null || screenBuffer.IsDisposed) { screenBuffer = VirtualContent.CreateRenderTarget("WaveDash-Buffer", ScreenWidth, ScreenHeight, true, true, 0); } if (prevPageBuffer == null || prevPageBuffer.IsDisposed) { prevPageBuffer = VirtualContent.CreateRenderTarget("WaveDash-Screen1", ScreenWidth, ScreenHeight, false, true, 0); } if (currPageBuffer == null || currPageBuffer.IsDisposed) { currPageBuffer = VirtualContent.CreateRenderTarget("WaveDash-Screen2", ScreenWidth, ScreenHeight, false, true, 0); } if (pageTurning && PrevPage != null) { Engine.Graphics.GraphicsDevice.SetRenderTarget(prevPageBuffer); Engine.Graphics.GraphicsDevice.Clear(PrevPage.ClearColor); Draw.SpriteBatch.Begin(); PrevPage.Render(); Draw.SpriteBatch.End(); } if (CurrPage != null) { Engine.Graphics.GraphicsDevice.SetRenderTarget(currPageBuffer); Engine.Graphics.GraphicsDevice.Clear(CurrPage.ClearColor); Draw.SpriteBatch.Begin(); CurrPage.Render(); Draw.SpriteBatch.End(); } Engine.Graphics.GraphicsDevice.SetRenderTarget(screenBuffer); Engine.Graphics.GraphicsDevice.Clear(Color.Black); if (pageTurning) { if (CurrPage.Transition == WallbouncePresentationPage.Transitions.ScaleIn) { Draw.SpriteBatch.Begin(); Draw.SpriteBatch.Draw(prevPageBuffer, Vector2.Zero, Color.White); Vector2 scale = Vector2.One * pageEase; Draw.SpriteBatch.Draw(currPageBuffer, ScaleInPoint, new Rectangle?(currPageBuffer.Bounds), Color.White, 0f, ScaleInPoint, scale, SpriteEffects.None, 0f); Draw.SpriteBatch.End(); return; } if (CurrPage.Transition == WallbouncePresentationPage.Transitions.FadeIn) { Draw.SpriteBatch.Begin(); Draw.SpriteBatch.Draw(prevPageBuffer, Vector2.Zero, Color.White); Draw.SpriteBatch.Draw(currPageBuffer, Vector2.Zero, Color.White * pageEase); Draw.SpriteBatch.End(); return; } if (CurrPage.Transition == WallbouncePresentationPage.Transitions.Rotate3D) { float num = -1.57079637f * pageEase; RenderQuad(prevPageBuffer, pageEase, num); RenderQuad(currPageBuffer, pageEase, 1.57079637f + num); return; } if (CurrPage.Transition == WallbouncePresentationPage.Transitions.Blocky) { Draw.SpriteBatch.Begin(); Draw.SpriteBatch.Draw(prevPageBuffer, Vector2.Zero, Color.White); uint num2 = 1u; int num3 = ScreenWidth / 60; for (int i = 0; i < ScreenWidth; i += num3) { for (int j = 0; j < ScreenHeight; j += num3) { if (WaveDashPresentation.PseudoRandRange(ref num2, 0f, 1f) <= pageEase) { Draw.SpriteBatch.Draw(currPageBuffer, new Rectangle(i, j, num3, num3), new Rectangle?(new Rectangle(i, j, num3, num3)), Color.White); } } } Draw.SpriteBatch.End(); return; } if (CurrPage.Transition == WallbouncePresentationPage.Transitions.Spiral) { Draw.SpriteBatch.Begin(); Draw.SpriteBatch.Draw(prevPageBuffer, Vector2.Zero, Color.White); Vector2 scale2 = Vector2.One * pageEase; float rotation = (1f - pageEase) * 12f; Draw.SpriteBatch.Draw(currPageBuffer, Celeste.Celeste.TargetCenter, new Rectangle?(currPageBuffer.Bounds), Color.White, rotation, Celeste.Celeste.TargetCenter, scale2, SpriteEffects.None, 0f); Draw.SpriteBatch.End(); return; } } else { Draw.SpriteBatch.Begin(); Draw.SpriteBatch.Draw(currPageBuffer, Vector2.Zero, Color.White); Draw.SpriteBatch.End(); } }