private void ReadLegacyData(PluginData data) { foreach (TexType texType in Enum.GetValues(typeof(TexType))) { if (texType == TexType.Unknown) { continue; } if (data != null && data.data.TryGetValue(texType.ToString(), out var texData) && texData is byte[] bytes && bytes.Length > 0) { if (texType == TexType.EyeOver) { OverlayStorage.SetTexture(TexType.EyeOverL, bytes); OverlayStorage.SetTexture(TexType.EyeOverR, bytes); } else if (texType == TexType.EyeUnder) { OverlayStorage.SetTexture(TexType.EyeUnderL, bytes); OverlayStorage.SetTexture(TexType.EyeUnderR, bytes); } else { OverlayStorage.SetTexture(texType, bytes); } } } #if KK OverlayStorage.CopyToOtherCoords(); #endif }
protected override void OnCardBeingSaved(GameMode currentGameMode) { var pd = new PluginData { version = 2 }; OverlayStorage.Save(pd); #if !EC if (!EnableInStudioSkin) { pd.data[nameof(EnableInStudioSkin)] = EnableInStudioSkin; } if (!EnableInStudioIris) { pd.data[nameof(EnableInStudioIris)] = EnableInStudioIris; } #endif SetExtendedData(pd.data.Count > 0 ? pd : null); #if KK || KKS ExtendedSave.SetExtendedDataById(ChaFileControl, "com.jim60105.kk.charaoverlaysbasedoncoordinate", null); #endif }
protected override void Awake() { base.Awake(); OverlayStorage = new OverlayStorage(this); #if KK CurrentCoordinate.Subscribe(v => UpdateTexture(0)); #endif }
private void RemoveAllOverlays(bool removeAdditional) { OverlayStorage.Clear(); if (removeAdditional) { AdditionalTextures.Clear(); } }
public static void Init() { Harmony.CreateAndPatchAll(typeof(Hooks), nameof(KoiSkinOverlayMgr.GUID)); #if KKS ExtendedSave.CardBeingImported += (data, mapping) => { if (data.TryGetValue(KoiSkinOverlayMgr.GUID, out var pluginData) && pluginData != null) { OverlayStorage.ImportFromKK(pluginData, mapping); } }; #endif }
public Texture2D SetOverlayTex(byte[] overlayTex, TexType overlayType) { if (overlayType == TexType.EyeOver || overlayType == TexType.EyeUnder) { SetOverlayTex(overlayTex, overlayType + 2); return(SetOverlayTex(overlayTex, overlayType + 4)); } OverlayStorage.SetTexture(overlayType, overlayTex); UpdateTexture(overlayType); return(OverlayStorage.GetTexture(overlayType)); }
protected override void Awake() { base.Awake(); OverlayStorage = new OverlayStorage(this); #if KK || KKS // this causes massive lag on overworld since charas change coords in background so avoid running this whenever possible CurrentCoordinate.Subscribe(v => { if (OverlayStorage.IsPerCoord()) { UpdateTexture(WhatTexturesNeedUpdating()); } }); #endif }
internal IEnumerable <Texture2D> GetOverlayTextures(TexType overlayType) { if (IsShown(overlayType)) { var tex = OverlayStorage.GetTexture(overlayType); if (tex) { yield return(tex); } } foreach (var additionalTexture in AdditionalTextures.Where(x => x.OverlayType == overlayType && x.Texture != null).OrderBy(x => x.ApplyOrder)) { yield return(additionalTexture.Texture); } }
protected override void OnReload(GameMode currentGameMode, bool maintainState) { if (maintainState) { return; } var needsUpdate = OverlayStorage.GetCount() > 0; RemoveAllOverlays(false); #if !EC EnableInStudioSkin = true; EnableInStudioIris = true; #endif var data = GetExtendedData(); if (data != null) { if (data.version <= 1) { ReadLegacyData(data); } else { OverlayStorage.Load(data); #if !EC EnableInStudioSkin = !data.data.TryGetValue(nameof(EnableInStudioSkin), out var val1) || !(val1 is bool) || (bool)val1; EnableInStudioIris = !data.data.TryGetValue(nameof(EnableInStudioIris), out var val2) || !(val2 is bool) || (bool)val2; #endif } } else { TryImportCOBOC(); } if (needsUpdate || OverlayStorage.GetCount() > 0) { UpdateTexture(TexType.Unknown); } }
protected override void OnCardBeingSaved(GameMode currentGameMode) { var pd = new PluginData { version = 2 }; OverlayStorage.Save(pd); #if !EC if (!EnableInStudioSkin) { pd.data[nameof(EnableInStudioSkin)] = EnableInStudioSkin; } if (!EnableInStudioIris) { pd.data[nameof(EnableInStudioIris)] = EnableInStudioIris; } #endif SetExtendedData(pd.data.Count > 0 ? pd : null); }
private void ReadLegacyData(PluginData data) { if (TryImportCOBOC()) { return; } KoiSkinOverlayMgr.Logger.LogInfo("Reading legacy overlay data"); foreach (TexType texType in Enum.GetValues(typeof(TexType))) { if (texType == TexType.Unknown) { continue; } if (data != null && data.data.TryGetValue(texType.ToString(), out var texData) && texData is byte[] bytes && bytes.Length > 0) { if (texType == TexType.EyeOver) { OverlayStorage.SetTexture(TexType.EyeOverL, bytes); OverlayStorage.SetTexture(TexType.EyeOverR, bytes); } else if (texType == TexType.EyeUnder) { OverlayStorage.SetTexture(TexType.EyeUnderL, bytes); OverlayStorage.SetTexture(TexType.EyeUnderR, bytes); } else { OverlayStorage.SetTexture(texType, bytes); } } } #if KK || KKS OverlayStorage.CopyToOtherCoords(); #endif }