Skip to content

Commit

Permalink
Added missing namespaces for UniGif
Browse files Browse the repository at this point in the history
  • Loading branch information
Shoko84 committed Mar 5, 2019
1 parent e111294 commit f149ba7
Show file tree
Hide file tree
Showing 8 changed files with 1,558 additions and 1,534 deletions.
2 changes: 2 additions & 0 deletions BeatSaberDrinkWater/BeatSaberDrinkWater/DrinkWaterPanel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using BeatSaberDrinkWater.Settings;
using BeatSaberDrinkWater.UniGif;
using BeatSaberDrinkWater.UniGif.Utility;
using BeatSaberDrinkWater.Utilities;
using CustomUI.BeatSaber;
using System;
Expand Down
95 changes: 49 additions & 46 deletions BeatSaberDrinkWater/BeatSaberDrinkWater/UniGif/UniGif.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,63 +10,66 @@ This software is released under the MIT License.
using System.Collections.Generic;
using UnityEngine;

public static partial class UniGif
namespace BeatSaberDrinkWater.UniGif
{
/// <summary>
/// Get GIF texture list Coroutine
/// </summary>
/// <param name="bytes">GIF file byte data</param>
/// <param name="callback">Callback method(param is GIF texture list, Animation loop count, GIF image width (px), GIF image height (px))</param>
/// <param name="filterMode">Textures filter mode</param>
/// <param name="wrapMode">Textures wrap mode</param>
/// <param name="debugLog">Debug Log Flag</param>
/// <returns>IEnumerator</returns>
public static IEnumerator GetTextureListCoroutine(
byte[] bytes,
Action<List<GifTexture>, int, int, int> callback,
FilterMode filterMode = FilterMode.Bilinear,
TextureWrapMode wrapMode = TextureWrapMode.Clamp,
bool debugLog = false)
public static partial class UniGif
{
int loopCount = -1;
int width = 0;
int height = 0;

// Set GIF data
var gifData = new GifData();
if (SetGifData(bytes, ref gifData, debugLog) == false)
/// <summary>
/// Get GIF texture list Coroutine
/// </summary>
/// <param name="bytes">GIF file byte data</param>
/// <param name="callback">Callback method(param is GIF texture list, Animation loop count, GIF image width (px), GIF image height (px))</param>
/// <param name="filterMode">Textures filter mode</param>
/// <param name="wrapMode">Textures wrap mode</param>
/// <param name="debugLog">Debug Log Flag</param>
/// <returns>IEnumerator</returns>
public static IEnumerator GetTextureListCoroutine(
byte[] bytes,
Action<List<GifTexture>, int, int, int> callback,
FilterMode filterMode = FilterMode.Bilinear,
TextureWrapMode wrapMode = TextureWrapMode.Clamp,
bool debugLog = false)
{
Debug.LogError("GIF file data set error.");
if (callback != null)
int loopCount = -1;
int width = 0;
int height = 0;

// Set GIF data
var gifData = new GifData();
if (SetGifData(bytes, ref gifData, debugLog) == false)
{
callback(null, loopCount, width, height);
Debug.LogError("GIF file data set error.");
if (callback != null)
{
callback(null, loopCount, width, height);
}
yield break;
}
yield break;
}

// Decode to textures from GIF data
List<GifTexture> gifTexList = null;
yield return DecodeTextureCoroutine(gifData, result => gifTexList = result, filterMode, wrapMode);
// Decode to textures from GIF data
List<GifTexture> gifTexList = null;
yield return DecodeTextureCoroutine(gifData, result => gifTexList = result, filterMode, wrapMode);

if (gifTexList == null || gifTexList.Count <= 0)
{
Debug.LogError("GIF texture decode error.");
if (callback != null)
if (gifTexList == null || gifTexList.Count <= 0)
{
callback(null, loopCount, width, height);
Debug.LogError("GIF texture decode error.");
if (callback != null)
{
callback(null, loopCount, width, height);
}
yield break;
}
yield break;
}

loopCount = gifData.m_appEx.loopCount;
width = gifData.m_logicalScreenWidth;
height = gifData.m_logicalScreenHeight;
loopCount = gifData.m_appEx.loopCount;
width = gifData.m_logicalScreenWidth;
height = gifData.m_logicalScreenHeight;

if (callback != null)
{
callback(gifTexList, loopCount, width, height);
}
if (callback != null)
{
callback(gifTexList, loopCount, width, height);
}

yield break;
yield break;
}
}
}
Loading

0 comments on commit f149ba7

Please sign in to comment.