internal VideoTexture(string videoFile, SkinSource source, Clocks clock) { this.clock = clock; videoFile = GeneralHelper.PathSanitise(videoFile); byte[] videoBytes = null; if ((source & SkinSource.Skin) > 0) { string filename = Path.Combine(SkinManager.Current.FullPath, videoFile.IndexOf('.') < 0 ? videoFile + @".mp4" : videoFile); videoBytes = GetFileBytes(filename); } if (videoBytes == null && (source & SkinSource.Osu) > 0) { videoBytes = (byte[])osu_ui.ResourcesStore.ResourceManager.GetObject(videoFile); } if (videoBytes == null && (source & SkinSource.Beatmap) > 0) { videoBytes = BeatmapManager.Current.GetFileBytes(videoFile); } vd = new VideoDecoder(clock == Clocks.Game ? 4 : (int)(AudioEngine.CurrentPlaybackRate / 100f * 4)); if (!vd.Open(videoBytes)) { return; } width = vd.width; height = vd.height; videoTextures = new pTexture[FRAME_BUFFER]; Initialize(); length = (int)vd.Length; }
internal pSpriteText(string text, string fontname, float spacingOverlap, Fields fieldType, Origins origin, Clocks clock, Vector2 startPosition, float drawDepth, bool alwaysDraw, Color colour, bool precache = true, SkinSource source = SkinSource.All) : base(null, fieldType, origin, clock, startPosition, drawDepth, alwaysDraw, colour) { Text = text; this.source = source; localTexture = null; TextFont = fontname; TextFontPrefix = fontname + '-'; SpacingOverlap = spacingOverlap; atlas = GetFontAtlas(fontname, source); if (precache) { //cache all sprites that may be used in the future. for (int i = 0; i < 10; i++) { TextureManager.Load(TextFontPrefix + i, source, atlas); } TextureManager.Load(TextFontPrefix + @"dot", source, atlas); TextureManager.Load(TextFontPrefix + @"comma", source, atlas); TextureManager.Load(TextFontPrefix + @"percent", source, atlas); } }
internal static pTexture LoadFirst(string s, SkinSource source = SkinSource.All, bool dashSeparator = true) { pTexture sourceTex = Load(s, source); pTexture[] texArray = LoadAll(s, source, dashSeparator); pTexture alternateTex = texArray != null ? texArray[0] : null; return(textureFromMostSpecificSkin(sourceTex, alternateTex)); }
internal pTexture[] LoadAll(string imageMapName, string defaultName, SkinSource skinSource) { pTexture[] p = null; if (imageMap[imageMapName] != null) { p = TextureManager.LoadAll(imageMap[imageMapName], skinSource); } return(p ?? TextureManager.LoadAll(defaultName, skinSource)); }
internal pVideo(string filename, SkinSource source, Clocks clock, int startTime = 0) : base(null, Fields.StoryboardCentre, Origins.Centre, clock, Vector2.Zero, 0.1F, true, Color.White) { video = new VideoTexture(filename, source, clock); StartTime = (clock == Clocks.Game ? GameBase.Time : 0) + startTime; EndTime = StartTime + video.length; Width = DrawWidth = video.Width; Height = DrawHeight = video.Height; OriginPosition = new Vector2(video.Width / 2, video.Height / 2); }
internal static pTexture LoadFirstAvailable(string[] names, SkinSource source = SkinSource.All) { pTexture t = null; foreach (string s in names) { if ((t = Load(s, source)) != null) { break; } } return(t); }
internal static int GetCacheCount(SkinSource source) { switch (source) { case SkinSource.Beatmap: return(BeatmapSpriteCache.Count); case SkinSource.Skin: return(SkinSpriteCache.Count); case SkinSource.Osu: return(DefaultSpriteCache.Count); } return(0); }
private static TextureAtlas GetFontAtlas(string fontname, SkinSource source) { if (!spriteFontAtlases.ContainsKey(source)) { spriteFontAtlases[source] = new Dictionary <string, TextureAtlas>(); } var dict = spriteFontAtlases[source]; if (dict.ContainsKey(fontname)) { return(dict[fontname]); } TextureAtlas atlas = new TextureAtlas(512, 512); dict[fontname] = atlas; return(atlas); }
internal static pTexture[] LoadAll(string s, SkinSource source = SkinSource.All, bool dashSeparator = true) { pTexture[] texArray; if (AnimationCache.TryGetValue(s, out texArray) && texArray[0].Source == source) { return(texArray); } int frameSuffixPosition = s.LastIndexOf('.'); string dash = dashSeparator ? @"-" : string.Empty; string frame0Name = frameSuffixPosition == -1 ? s + dash + 0 : s.Insert(frameSuffixPosition, dash + 0); pTexture animated = Load(frame0Name, source); pTexture sprite = Load(s, source); if (animated != null && animated == textureFromMostSpecificSkin(animated, sprite)) { List <pTexture> textures = new List <pTexture>(); for (int i = 1; animated != null; i++) { textures.Add(animated); string frameIName = frameSuffixPosition == -1 ? s + dash + i : s.Insert(frameSuffixPosition, dash + i); animated = Load(frameIName, animated.Source); } texArray = textures.ToArray(); AnimationCache[s] = texArray; return(texArray); } if (sprite != null) { texArray = new[] { sprite }; AnimationCache[s] = texArray; return(texArray); } return(null); }
//notice: notes' drawDepth are 0.8F protected override void PostProcessing() { //some important value PreEmpt = Math.Max((int)SpeedMania.TimeAt(0, ManiaStage.Skin.HitPosition), LongestTime) + 200; CountTotal = CountNormal + CountLong; //init lighting SkinSource skinSource = Beatmap.PlayMode == PlayModes.OsuMania ? SkinSource.All : (SkinSource.Skin | SkinSource.Osu); Score s = Player.currentScore; if (s != null && ModManager.CheckActive(s.EnabledMods, Mods.Perfect)) { perfectMod = true; } ReCalculate(-1);//for there maybe some notes put at 0 offset. Debug.Print("--------Mania--------"); Debug.Write(string.Format("Note Count:{0}({1}/{2})\nPreEmpty:{3}\nMania Star:{4}\n", CountTotal, CountNormal, CountLong, PreEmpt, Beatmap.DifficultyBemaniStars)); }
public void SetUp() => Schedule(() => { Add(new SkinProvidingContainer(source1 = new SkinSource()) .WithChild(new SkinProvidingContainer(source2 = new SkinSource()) .WithChild(requester = new SkinRequester()))); });
internal static pTexture Load(string name, SkinSource source = SkinSource.All, TextureAtlas atlas = null) { if (name == null) { return(null); } if (SkinManager.IgnoreBeatmapSkin && source != SkinSource.Beatmap) { source &= ~SkinSource.Beatmap; } if (source == SkinSource.All) { switch (GameBase.Mode) { case OsuModes.Play: case OsuModes.Edit: break; default: //As a default, don't load from the beatmap unless we are in play or edit mode. source &= ~SkinSource.Beatmap; break; } } pTexture tex = null; Dictionary <string, pTexture> dic = null; if (!LookupCache.TryGetValue(source, out dic)) { dic = LookupCache[source] = new Dictionary <string, pTexture>(); } if (dic.TryGetValue(name, out tex)) { return(tex); } try { //Check for beatmap-specific sprite availability Beatmap current = null; if ((source & SkinSource.Beatmap) > 0 && (current = BeatmapManager.Current) != null) { if (BeatmapSpriteCache.TryGetValue(name, out tex)) { //Cached sprite is available. //Note that we must check null *inside* this if block because a cached null means this source has no available file. //If we find a null, we don't want to enter the else block and check for a file every time, so we quietly ignore this source here. if (tex != null) { return(tex); } } else { string filename = name.IndexOf('.') < 0 ? name + @".png" : name; using (Stream stream = current.GetFileStream(filename)) { if (stream != null) { tex = pTexture.FromStream(stream, atlas); if (tex != null) { tex.Filename = filename; tex.AssetName = name; tex.Source = SkinSource.Beatmap; tex.UploadNextFrame(); } BeatmapSpriteCache[name] = tex; if (atlas != null) { BeatmapTextureAtlases.Add(atlas); } return(tex); } } BeatmapSpriteCache[name] = null; } } if ((source & SkinSource.Skin) > 0 && !SkinManager.IsDefault) { if (SkinSpriteCache.TryGetValue(name, out tex)) { //Cached sprite is available. //Note that we must check null *inside* this if block because a cached null means this source has no available file. //If we find a null, we don't want to enter the else block and check for a file every time, so we quietly ignore this source here. if (tex != null) { return(tex); } } else { string filename = Path.Combine(SkinManager.Current.FullPath, name.IndexOf('.') < 0 ? name + @".png" : name); string filename2x = filename.Insert(filename.LastIndexOf('.'), @"@2x"); if (GameBase.UseHighResolutionSprites && File.Exists(filename2x)) { tex = pTexture.FromFile(filename2x, atlas); SkinSpriteCache[name] = tex; if (atlas != null) { SkinTextureAtlases.Add(atlas); } if (tex != null) { tex.DpiScale = 2; tex.Source = SkinSource.Skin; tex.AssetName = name; tex.UploadNextFrame(); } return(tex); } if (File.Exists(filename)) { tex = pTexture.FromFile(filename, atlas); SkinSpriteCache[name] = tex; if (atlas != null) { SkinTextureAtlases.Add(atlas); } if (tex != null) { tex.Source = SkinSource.Skin; tex.AssetName = name; tex.UploadNextFrame(); } return(tex); } SkinSpriteCache[name] = null; } } if ((source & SkinSource.Osu) == 0) { return(null); } try { if (DefaultSpriteCache.TryGetValue(name, out tex)) { return(tex); } #if LOAD_LOCAL if ((tex = Load(name, SkinSource.Skin)) != null) { return(tex); } #endif name = GeneralHelper.PathSanitise(name); tex = name.IndexOf(Path.DirectorySeparatorChar) > 0 ? pTexture.FromFile(name, atlas) : pTexture.FromResourceStore(GeneralHelper.StripExtension(name), atlas); DefaultSpriteCache[name] = tex; if (atlas != null) { DefaultTextureAtlases.Add(atlas); } if (tex != null) { tex.Source = SkinSource.Osu; tex.AssetName = name; tex.UploadNextFrame(); } return(tex); } catch { return(null); } } finally { dic[name] = tex; } }