public static STexture AddTexture(string TexturePath, int MaxSize) { if (MaxSize == 0) { return(_Draw.AddTexture(TexturePath)); } if (!System.IO.File.Exists(TexturePath)) { return(new STexture(-1)); } Bitmap origin = new Bitmap(TexturePath); int w = MaxSize; int h = MaxSize; if (origin.Width >= origin.Height && origin.Width > w) { h = (int)Math.Round((float)w / origin.Width * origin.Height); } else if (origin.Height > origin.Width && origin.Height > h) { w = (int)Math.Round((float)h / origin.Height * origin.Width); } Bitmap bmp = new Bitmap(origin, w, h); STexture tex = _Draw.AddTexture(bmp); bmp.Dispose(); return(tex); }
public static void LoadAvatars() { for (int i = 0; i < _Avatars.Count; i++) { STexture texture = _Avatars[i].Texture; CDraw.RemoveTexture(ref texture); } _Avatars.Clear(); List <string> files = new List <string>(); files.AddRange(Helper.ListFiles(CSettings.sFolderProfiles, "*.png", true, true)); files.AddRange(Helper.ListFiles(CSettings.sFolderProfiles, "*.jpg", true, true)); files.AddRange(Helper.ListFiles(CSettings.sFolderProfiles, "*.jpeg", true, true)); files.AddRange(Helper.ListFiles(CSettings.sFolderProfiles, "*.bmp", true, true)); foreach (string file in files) { STexture tex = CDraw.AddTexture(file); if (tex.index != -1) { SAvatar avatar = new SAvatar(); avatar.Texture = tex; avatar.FileName = Path.GetFileName(file); _Avatars.Add(avatar); } } }
public VideoPlayer() { _VideoTimer = new Stopwatch(); _VideoTexture = new STexture(-1); _Finished = false; _Loaded = false; }
// queued adding public void enqueue(params object[] rawAssets) { foreach(var rawAsset in rawAssets) { var assetType = rawAsset.GetType(); if(assetType == typeof(UnityEngine.Texture2D) || assetType == typeof(UnityEngine.Texture)){ addTexture( (rawAsset as Texture).name, STexture.fromTexture((rawAsset as Texture), null, null) ); } else if(assetType == typeof(starling.texture.TextureAtlas)){ addTextureAtlas( (rawAsset as TextureAtlas).name, (rawAsset as TextureAtlas) ); } else if (assetType == typeof(UnityEngine.TextAsset)) { addXML( (rawAsset as TextAsset).name, (rawAsset as TextAsset).text.toXmlDocument() ); } else if (assetType == typeof(System.String)) { enqueueWithName(rawAsset); } else { log("Ignoring unsupported asset type: " + rawAsset.GetType().ToString()); } } }
private void loadRawAsset(String name, object rawAsset, List<XmlDocument> xmls, Delegate onProgress, Delegate onComplete) { var assetType = rawAsset.GetType(); if (assetType == typeof(System.String)) { var loadedAsset = Resources.Load(name); var loadedAssetType = loadedAsset.GetType(); if(loadedAssetType == typeof(UnityEngine.Texture2D) || loadedAssetType == typeof(UnityEngine.Texture)) { addTexture( (loadedAsset as Texture).name, STexture.fromTexture((loadedAsset as Texture), null, null) ); onComplete.DynamicInvoke(); } else if(loadedAssetType == typeof(UnityEngine.TextAsset)) { var xml = (loadedAsset as TextAsset).text.toXmlDocument(); addXML( (loadedAsset as TextAsset).name, xml ); xmls.Add(xml); onComplete.DynamicInvoke(); } else { log("Ignoring unsupported asset type: " + rawAsset.GetType().ToString()); onComplete.DynamicInvoke(); } } else { log("Ignoring unsupported asset type: " + rawAsset.GetType().ToString()); onComplete.DynamicInvoke(); } }
public override void OnShow() { base.OnShow(); _FadeOut = false; _CurrentVideo = -1; _CurrentVideoTexture = new STexture(-1); _CurrentBeat = -100; _CurrentTime = 0f; _FinishTime = 0f; _TimeToFirstNote = 0f; _TimeToFirstNoteDuet = 0f; _Pause = false; _TimeRects.Clear(); SingNotes[htSingNotes(SingBars)].Reset(); for (int i = 0; i < CSettings.MaxNumPlayer; i++) { NoteLines[i] = -1; } SetVisuability(); CBackgroundMusic.Pause(); }
/** Adds a frame at a certain index, optionally with a sound and a custom duration. */ public void addFrameAt(int frameID, STexture texture, Sound sound = null, float duration = -1) { if (frameID < 0 || frameID > numFrames) { throw new ArgumentError("Invalid frame id"); } if (duration < 0) { duration = mDefaultFrameDuration; } mTextures.Insert(frameID, texture); mSounds.Insert(frameID, sound); mDurations.Insert(frameID, duration); if (frameID > 0 && frameID == numFrames) { mStartTimes[frameID] = mStartTimes[frameID - 1] + mDurations[frameID - 1]; } else { updateStartTimes(); } }
public void Draw(bool ForceDraw) { if (!Visible && CSettings.GameState != EGameState.EditTheme && !ForceDraw) { return; } STexture texture = new STexture(-1); if (!Selected) { texture = CTheme.GetSkinTexture(_Theme.TextureName); CDraw.DrawTexture(texture, Rect, Color); if (Reflection) { CDraw.DrawTextureReflection(texture, Rect, Color, Rect, ReflectionSpace, ReflectionHeight); } } else { texture = CTheme.GetSkinTexture(_Theme.STextureName); CDraw.DrawTexture(texture, Rect, SColor); if (Reflection) { CDraw.DrawTextureReflection(texture, Rect, SColor, Rect, ReflectionSpace, ReflectionHeight); } } Text.DrawRelative(Rect.X, Rect.Y); if (Reflection) { Text.DrawRelative(Rect.X, Rect.Y, ReflectionSpace, ReflectionHeight, Rect.H); } }
/** Sets the texture of a certain frame. */ public void setFrameTexture(int frameID, STexture texture) { if (frameID < 0 || frameID >= numFrames) { throw new ArgumentError("Invalid frame id"); } mTextures[frameID] = texture; }
// direct adding /** Register a texture under a certain name. It will be available right away. */ public void addTexture(String name, STexture texture) { log("Adding texture '" + name + "'"); if (mTextures.ContainsKey(name)) throw new Error("Duplicate texture name: " + name); else mTextures[name] = texture; }
// Create STexture public static STexture AddTexture(GameObject gameObject) { STexture texture = UGUITools.AddChild <STexture>(gameObject); (texture as RawImage).raycastTarget = false; UGUITools.ResetGameObject(texture.gameObject); return(texture); }
/// <summary> /// Reloads cover to use a new cover-theme /// </summary> public static void ReloadCover() { foreach (SCover cover in _Cover) { STexture texture = cover.Texture; CDraw.RemoveTexture(ref texture); } _Cover.Clear(); LoadCover(CConfig.CoverTheme); }
public void RenameValue(int selection, string NewName, STexture NewTexture) { if (selection < 0 && selection >= _ValueNames.Count) { return; } _ValueNames[selection] = NewName; _Textures[selection] = NewTexture; }
public static void LoadSongs() { CLog.StartBenchmark(1, "Load Songs"); _SongsLoaded = false; _Songs.Clear(); CLog.StartBenchmark(2, "List Songs"); List <string> files = new List <string>(); foreach (string p in CConfig.SongFolder) { string path = p; files.AddRange(Helper.ListFiles(path, "*.txt", true, true)); files.AddRange(Helper.ListFiles(path, "*.txd", true, true)); } CLog.StopBenchmark(2, "List Songs"); CLog.StartBenchmark(2, "Read TXTs"); foreach (string file in files) { CSong Song = new CSong(); if (Song.ReadTXTSong(file)) { Song.ID = _Songs.Count; _Songs.Add(Song); } } CLog.StopBenchmark(2, "Read TXTs"); CLog.StartBenchmark(2, "Sort Songs"); Sort(CConfig.SongSorting); CLog.StopBenchmark(2, "Sort Songs"); Category = -1; _SongsLoaded = true; if (CConfig.Renderer != ERenderer.TR_CONFIG_SOFTWARE && CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART) { CLog.StartBenchmark(2, "Load Cover"); for (int i = 0; i < _Songs.Count; i++) { CSong song = _Songs[i]; song.ReadNotes(); STexture texture = song.CoverTextureSmall; song.CoverTextureBig = texture; _CoverLoadIndex++; } _CoverLoaded = true; CDataBase.CommitCovers(); CLog.StopBenchmark(2, "Load Cover"); } CLog.StopBenchmark(1, "Load Songs "); }
public Image(STexture sTexture = null) : base() { if (sTexture != null) { mPivotX = mPivotY = 0.0f; textureManager = TextureManager.instance; texture = sTexture; } else { throw new ArgumentError("Texture cannot be null"); } }
public CParticleEffect(int MaxNumber, SColorF Color, SRectF Area, STexture texture, float Size, EParticeType Type) { _Stars = new List <CParticle>(); _Area = Area; _Color = Color; _TextureName = String.Empty; _Texture = texture; _MaxNumber = MaxNumber; _Size = Size; _Type = Type; _SpawnTimer = new Stopwatch(); _NextSpawnTime = 0f; }
public void AddValue(string value, STexture texture, int valueIndex) { _ValueNames.Add(value); _Textures.Add(texture); _ValueIndexes.Add(valueIndex); if (Selection == -1) { Selection = 0; } _ValueBounds.Clear(); }
private void DrawNoteBG(SRectF Rect, SColorF Color, float factor, Stopwatch Timer) { const int spacing = 0; const float period = 1.5f; //[s] if (!Timer.IsRunning) { Timer.Start(); } if (Timer.ElapsedMilliseconds / 1000f > period) { Timer.Reset(); Timer.Start(); } float alpha = (float)((Math.Cos((Timer.ElapsedMilliseconds / 1000f) / period * Math.PI * 2) + 1) / 2.0) / 2f + 0.5f; float d = (1f - factor) / 2 * Rect.H; float dw = d; if (2 * dw > Rect.W) { dw = Rect.W / 2; } SRectF r = new SRectF( Rect.X + dw + spacing, Rect.Y + d + spacing, Rect.W - 2 * dw - 2 * spacing, Rect.H - 2 * d - 2 * spacing, Rect.Z ); STexture NoteBackgroundBegin = CTheme.GetSkinTexture(_Theme.SkinBackgroundLeftName); STexture NoteBackgroundMiddle = CTheme.GetSkinTexture(_Theme.SkinBackgroundMiddleName); STexture NoteBackgroundEnd = CTheme.GetSkinTexture(_Theme.SkinBackgroundRightName); float dx = NoteBackgroundBegin.width * r.H / NoteBackgroundBegin.height; if (2 * dx > r.W) { dx = r.W / 2; } SColorF col = new SColorF(Color.R, Color.G, Color.B, Color.A * alpha); CDraw.DrawTexture(NoteBackgroundBegin, new SRectF(r.X, r.Y, dx, r.H, r.Z), col); CDraw.DrawTexture(NoteBackgroundMiddle, new SRectF(r.X + dx, r.Y, r.W - 2 * dx, r.H, r.Z), col); CDraw.DrawTexture(NoteBackgroundEnd, new SRectF(r.X + r.W - dx, r.Y, dx, r.H, r.Z), col); }
public static void DrawTexture(CStatic StaticBounds, STexture Texture, EAspect Aspect) { RectangleF bounds = new RectangleF(StaticBounds.Rect.X, StaticBounds.Rect.Y, StaticBounds.Rect.W, StaticBounds.Rect.H); RectangleF rect = new RectangleF(0f, 0f, Texture.width, Texture.height); if (rect.Height <= 0f) { return; } CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, Aspect); DrawTexture(Texture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, StaticBounds.Rect.Z), Texture.color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f), false); }
public override bool GetFrame(int StreamID, ref STexture Frame, float Time, ref float VideoTime) { if (_Initialized) { lock (MutexDecoder) { if (AlreadyAdded(StreamID)) { return(_Decoder[GetStreamIndex(StreamID)].GetFrame(ref Frame, Time, ref VideoTime)); } } } return(false); }
private static void _LoadCover() { for (int i = 0; i < _Songs.Count; i++) { CSong song = _Songs[i]; song.ReadNotes(); STexture texture = song.CoverTextureSmall; song.CoverTextureBig = texture; _CoverLoadIndex++; } _CoverLoaded = true; CDataBase.CommitCovers(); }
private bool DrawVideo() { STexture VideoTexture = CTheme.GetSkinVideoTexture(_Theme.VideoName); if (VideoTexture.height > 0) { RectangleF bounds = new RectangleF(0f, 0f, CSettings.iRenderW, CSettings.iRenderH); RectangleF rect = new RectangleF(0f, 0f, VideoTexture.width, VideoTexture.height); CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, EAspect.Crop); CDraw.DrawTexture(VideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CSettings.zFar / 4)); return(true); } return(false); }
public void LoadTextures() { _TextureEmptyTile = CTheme.GetSkinTexture(_Theme.TextureEmptyTileName); _TextureTileSelected = CTheme.GetSkinTexture(_Theme.TextureTileSelectedName); if (_Theme.ColorEmptyTileName != String.Empty) { ColorEmptyTile = CTheme.GetColor(_Theme.ColorEmptyTileName); } if (_Theme.NameColorName != String.Empty) { _Theme.NameColor = CTheme.GetColor(_Theme.NameColorName); } }
public CStatic(CStatic s) { _Theme = new SThemeStatic(); _ThemeLoaded = false; _Texture = s.Texture; Color = new SColorF(s.Color); Rect = new SRectF(s.Rect); Reflection = s.Reflection; ReflectionSpace = s.ReflectionHeight; ReflectionHeight = s.ReflectionSpace; Selected = s.Selected; Alpha = s.Alpha; Visible = s.Visible; }
public CStatic() { _Theme = new SThemeStatic(); _ThemeLoaded = false; _Texture = new STexture(-1); Color = new SColorF(); Rect = new SRectF(); Reflection = false; ReflectionSpace = 0f; ReflectionHeight = 0f; Selected = false; Alpha = 1f; Visible = true; }
public CStatic(STexture texture, SColorF color, SRectF rect) { _Theme = new SThemeStatic(); _ThemeLoaded = false; _Texture = texture; Color = color; Rect = rect; Reflection = false; ReflectionSpace = 0f; ReflectionHeight = 0f; Selected = false; Alpha = 1f; Visible = true; }
/// <summary> /// Returns true if a cover with the given name exists. /// </summary> public static bool CoverExists(string Name) { STexture cov = _NoCover; lock (_MutexCover) { foreach (SCover cover in _Cover) { if (cover.Name == Name) { return(true); } } } return(false); }
public override void Init() { base.Init(); _Rect = _Theme.songMenuTileBoard.TileRect; _NumW = _Theme.songMenuTileBoard.numW; _NumH = _Theme.songMenuTileBoard.numH; _SpaceW = _Theme.songMenuTileBoard.spaceW; _SpaceH = _Theme.songMenuTileBoard.spaceH; _PendingTime = 100L; _TileW = (int)((_Theme.songMenuTileBoard.TileRect.W - _SpaceW * (_NumW - 1)) / _NumW); _TileH = (int)((_Theme.songMenuTileBoard.TileRect.H - _SpaceH * (_NumH - 1)) / _NumH); _CoverTexture = CTheme.GetSkinTexture(_Theme.CoverBackgroundName); _CoverBigTexture = CTheme.GetSkinTexture(_Theme.CoverBigBackgroundName); _Tiles = new List <CStatic>(); for (int i = 0; i < _NumH; i++) { for (int j = 0; j < _NumW; j++) { SRectF rect = new SRectF(_Theme.songMenuTileBoard.TileRect.X + j * (_TileW + _SpaceW), _Theme.songMenuTileBoard.TileRect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, _Rect.Z); CStatic tile = new CStatic(_CoverTexture, Color, rect); _Tiles.Add(tile); } } _ScrollRect = new SRectF(0, 0, CSettings.iRenderW, CSettings.iRenderH, _Theme.songMenuTileBoard.TileRect.Z); _PreviewSelected = -1; _Offset = 0; _CoverBig = _Theme.songMenuTileBoard.StaticCoverBig; _TextBG = _Theme.songMenuTileBoard.StaticTextBG; _DuetIcon = _Theme.songMenuTileBoard.StaticDuetIcon; _VideoIcon = _Theme.songMenuTileBoard.StaticVideoIcon; _MedleyCalcIcon = _Theme.songMenuTileBoard.StaticMedleyCalcIcon; _MedleyTagIcon = _Theme.songMenuTileBoard.StaticMedleyTagIcon; _Artist = _Theme.songMenuTileBoard.TextArtist; _Title = _Theme.songMenuTileBoard.TextTitle; _SongLength = _Theme.songMenuTileBoard.TextSongLength; }
public CStatic(string TextureSkinName, SColorF color, SRectF rect) { _Theme = new SThemeStatic(); _Theme.TextureName = TextureSkinName; _ThemeLoaded = false; _Texture = new STexture(-1); Color = color; Rect = rect; Reflection = false; ReflectionSpace = 0f; ReflectionHeight = 0f; Selected = false; Alpha = 1f; Visible = true; }
/// <summary> /// Returns a STexture for a given cover name. Returns "NoCover" if the cover does not exist. /// </summary> public static STexture Cover(string Name) { STexture cov = _NoCover; lock (_MutexCover) { foreach (SCover cover in _Cover) { if (cover.Name == Name) { cov = cover.Texture; break; } } } return(cov); }