public void MatchWindowState(ParamCharaController controller) { ChaFileDefine.CoordinateType coordinate = controller.GetNowCoordinate(); ParamCharaController.ParamsKind kind = controller.GetNowBustWear(); coordinateSelect.Select(coordinate); kindSelect.Select(kind); }
public void Apply(CoordinateType coordinate) { if (BoneTransform == null) { return; } var modifier = GetModifier(coordinate); if (CanApply(modifier)) { BoneTransform.localScale = new Vector3( _sclBaseline.x * modifier.ScaleModifier.x, _sclBaseline.y * modifier.ScaleModifier.y, _sclBaseline.z * modifier.ScaleModifier.z); if (_lenModForceUpdate || modifier.HasLength()) { // todo don't run if lenMod was never used? if (BoneTransform.localPosition != Vector3.zero && HasLenBaseline()) { BoneTransform.localPosition = BoneTransform.localPosition / BoneTransform.localPosition.magnitude * _lenBaseline * modifier.LengthModifier; _lenModForceUpdate = false; } } } }
public void ChangeOutfit_Internal_KCOX(KCOXHelper helper) { Dictionary <ChaFileDefine.CoordinateType, Dictionary <string, ClothesTexData> > data = new Dictionary <ChaFileDefine.CoordinateType, Dictionary <string, ClothesTexData> >(); foreach (KeyValuePair <string, Dictionary <string, ClothesTexData> > a in helper.KCOX) { try { ChaFileDefine.CoordinateType key = (ChaFileDefine.CoordinateType)Enum.Parse( typeof(ChaFileDefine.CoordinateType), a.Key, true ); Dictionary <string, ClothesTexData> entry = data[key] = new Dictionary <string, ClothesTexData>(); foreach (KeyValuePair <string, ClothesTexData> b in a.Value) { if (b.Value != null) { entry[b.Key] = b.Value; } } } catch { } } kcox.SetExtendedData(data.KCOXData()); }
private void InitGUI() { //Coordinate Select ChaFileDefine.CoordinateType[] coordinateList = new ChaFileDefine.CoordinateType[] { ChaFileDefine.CoordinateType.School01, ChaFileDefine.CoordinateType.School02, ChaFileDefine.CoordinateType.Gym, ChaFileDefine.CoordinateType.Swim, ChaFileDefine.CoordinateType.Club, ChaFileDefine.CoordinateType.Plain, ChaFileDefine.CoordinateType.Pajamas, }; List <string> coordinateStringList = new List <string>(); for (int i = 0; i < coordinateList.Count(); i++) { coordinateStringList.Add(coordinateList[i].ToString()); } coordinateSelect = new CoordinateSelect(coordinateStringList.ToArray(), coordinateList, ""); //Preset select presetSelectBust = new PresetSelect(PluginPath.presetDirBust, "Load Bust preset", 0, 20); presetSelectHip = new PresetSelect(PluginPath.presetDirHip, "Load Hip preset", 0, 20); //Save dialog s_dialog = new DialogSavePreset(_parent, _s_dialogID, "Save preset", SDRect); //message box msgBox = new MessageBox(WindowID.GetNewID()); }
protected override void OnReload(GameMode currentGameMode, bool maintainState) { KSOXController = CharacterApi.GetRegisteredBehaviour(typeof(KoiSkinOverlayController)).Instances.Where(x => x.ChaControl == base.ChaControl).Single() as KoiSkinOverlayController; BackCoordinateType = CurrentCoordinate.Value; //Maker沒有打勾就不載入 if (!CheckLoad(true)) { return; } LoadingLock = true; UpdateOldGUIDSaveData((ChaFile)ChaFileControl); OverlayTable.Clear(); IrisDisplaySide = new int[] { 0, 0, 0, 0, 0, 0, 0 }; PluginData data = GetExtendedData(); if (null != data && data.version != 3) { UpdateOldVersionSaveData(data); } else { ReadPluginData(data); } Logger.LogDebug($"{ChaFileControl.parameter.fullname} Load Extended Data"); OverwriteOverlay(); LoadingLock = false; UpdateInterface(); }
/// <inheritdoc /> public AccessoryCopyEventArgs(IEnumerable <int> copiedSlotIndexes, ChaFileDefine.CoordinateType copySource, ChaFileDefine.CoordinateType copyDestination) { CopiedSlotIndexes = copiedSlotIndexes ?? throw new ArgumentNullException(nameof(copiedSlotIndexes)); CopySource = copySource; CopyDestination = copyDestination; }
public bool LoadParamFromChara(ChaFileDefine.CoordinateType coordinate, ParamsKind paramsKind) { if (paramCustom == null) { return(false); } changedInfo.SetInfo(coordinate, paramsKind, false, true, true); switch (paramsKind) { case ParamsKind.Naked: return(paramCustom.paramBustNaked.LoadParamsFromCharacter(this)); case ParamsKind.Bra: return(paramCustom.paramBust[coordinate][ParamsKind.Bra].LoadParamsFromCharacter(this)); case ParamsKind.Tops: return(paramCustom.paramBust[coordinate][ParamsKind.Tops].LoadParamsFromCharacter(this)); case ParamsKind.Hip: return(paramCustom.paramHip.LoadParamsFromCharacter(this)); default: return(false); } }
internal void DressPlayer(ChaFileDefine.CoordinateType newCoordinateType) { if (!_monitoringChange) { return; } var player = Singleton <Game> .Instance?.Player; if (player == null) { return; } var mode = Mode.Value; var playerClothesIsAuto = player.changeClothesType < 0; if (mode != PluginMode.Always || (mode == PluginMode.AutomaticOnly && !playerClothesIsAuto)) { return; } if (player.chaCtrl.ChangeCoordinateTypeAndReload(newCoordinateType)) { Logger.LogDebug($"Changed player clothes to {newCoordinateType}"); if (!playerClothesIsAuto) { // update selected clothes to match so you can change back player.changeClothesType = (int)newCoordinateType; } } _monitoringChange = false; }
internal static void CoordinateDoPostfix(Coordinate __instance, int ___no, ChaFileDefine.CoordinateType ___type) { try { Logger.DebugLogDebug( $"{nameof(CoordinateDoPostfix)}: no={___no}, type={___type}, monitoringChange={Instance != null && Instance._monitoringChange}"); if (Instance == null || !Enabled.Value || !Instance._monitoringChange) { return; } __instance.SafeProc(coord => coord.scenario.SafeProcObject(s => s.commandController.SafeProcObject(cc => { if (!cc.GetChara(___no).IsNullOrNpc()) { Instance.DressPlayer(___type); } }))); } catch (Exception err) { Logger.LogException(err, nameof(CoordinateDoPostfix)); } }
public BoneModifierData GetModifier(CoordinateType coordinate) { if (CoordinateModifiers.Length == 1) { return(CoordinateModifiers[0]); } return(CoordinateModifiers[(int)coordinate]); }
public void SetInfo(ChaFileDefine.CoordinateType coordinate, ParamCharaController.ParamsKind kind, bool changedEnabled, bool changedParam, bool forceChanged = false) { this.coordinate = coordinate; this.kind = kind; this.changedEnabled = changedEnabled; this.changedParam = changedParam; this.forceChanged = forceChanged; }
public void CopyParamAllCoordinate(ChaFileDefine.CoordinateType srcCoordinate) { foreach (ChaFileDefine.CoordinateType coordinate in Enum.GetValues(typeof(ChaFileDefine.CoordinateType))) { paramCustom.paramBust[coordinate][ParamsKind.Bra].CopyParamsFrom(paramCustom.paramBust[srcCoordinate][ParamsKind.Bra]); paramCustom.paramBust[coordinate][ParamsKind.Tops].CopyParamsFrom(paramCustom.paramBust[srcCoordinate][ParamsKind.Tops]); } changedInfo.SetInfo(ChaFileDefine.CoordinateType.School01, ParamsKind.Naked, false, true, true); }
public void Select(ChaFileDefine.CoordinateType coordinate) { for (int i = 0; i < _coordinateType.Count(); i++) { if (_coordinateType[i] == coordinate) { _selectedIndex = i; return; } } }
private Dictionary <TexType, int> GetOverlayTextures(CoordinateType coordinateType) { _allOverlayTextures.TryGetValue(coordinateType, out var dict); if (dict == null) { dict = new Dictionary <TexType, int>(); _allOverlayTextures.Add(coordinateType, dict); } return(dict); }
public ParamBustCustom(ChaFileDefine.CoordinateType coordinate, ParamCharaController.ParamsKind wearState) { enabled = false; gravity = 0; _coordinate = coordinate; _wearState = wearState; paramBones = new Dictionary <string, ParamBone>(); for (int i = 0; i < Bones.Count(); i++) { paramBones.Add(Bones[i], new ParamBone(Bones[i])); } }
public BoneModifierData GetModifier(CoordinateType coordinate) { if (!IsCoordinateSpecific()) { return(CoordinateModifiers[0]); } if (CoordinateModifiers.Length <= (int)coordinate) { #if DEBUG Console.WriteLine($"CoordinateModifiers.Length={CoordinateModifiers.Length} <= (int)coordinate={(int)coordinate}"); #endif return(null); } return(CoordinateModifiers[(int)coordinate]); }
private Dictionary <string, ClothesTexData> GetOverlayTextures(CoordinateType coordinateType) { if (_allOverlayTextures == null) { return(null); } _allOverlayTextures.TryGetValue(coordinateType, out var dict); if (dict == null) { dict = new Dictionary <string, ClothesTexData>(); _allOverlayTextures.Add(coordinateType, dict); } return(dict); }
public bool TryGetOverlayByCoordinateType(ChaFileDefine.CoordinateType type, out Dictionary <TexType, byte[]> result) { result = new Dictionary <TexType, byte[]>(); if (OverlayTable.TryGetValue(type, out Dictionary <TexType, int> tmp)) { foreach (KeyValuePair <TexType, int> kvp in tmp) { result.Add(kvp.Key, kvp.Value < Resources.Count ? Resources[kvp.Value] : null); } } else { result = null; return(false); } return(true); }
/// <summary> /// 讀入overlay至插件內 /// </summary> /// <param name="coordinateType">服裝類型</param> /// <param name="overlay">要讀入的Overlay</param> /// <returns>OverlayTable</returns> public Dictionary <TexType, int> SetOverlayByCoordinateType(ChaFileDefine.CoordinateType?coordinateType, Dictionary <TexType, byte[]> overlay) { bool notNullFlag = null != coordinateType; Dictionary <TexType, int> result = new Dictionary <TexType, int>(); ChaFileDefine.CoordinateType type = coordinateType ?? ChaFileDefine.CoordinateType.School01; foreach (KeyValuePair <TexType, byte[]> kvp in overlay) { result[kvp.Key] = InputOverlayTexture(kvp.Value); //if (0 != result[kvp.Key] && notNullFlag && KoikatuAPI.GetCurrentGameMode() == GameMode.Maker) Logger.LogDebug($"Input Texture: {type.ToString()}({kvp.Key.ToString()}): {result[kvp.Key]}"); } if (notNullFlag) { OverlayTable[type] = result; //OverlaysReadyToSave[type] = PrepareOverlayToSave(OverlayTable[type], out _); } return(result); }
public override BoneModifierData GetEffect(string bone, BoneController origin, ChaFileDefine.CoordinateType coordinate) { switch (bone) { case "cf_d_bnip01_L": return(_nipModifierL); case "cf_d_bnip01_R": return(_nipModifierR); case "cf_d_ana": return(_anaModifier); default: return(null); } }
private bool OnPresetSelected(PresetSelect presetSelect) { ParamCharaController controller = _parent.GetSelectedController(); ChaFileDefine.CoordinateType coordinate = _parent.GetSelectedCoordinate(); ParamCharaController.ParamsKind kind = _parent.GetSelectedParamsKind(); string xmlPath = presetSelect.GetSelectedFilePath(); switch (_parent.GetSelectedParamsKind()) { case ParamCharaController.ParamsKind.Naked: if (!XMLPresetIO.LoadXMLBust(controller.paramCustom.paramBustNaked, xmlPath)) { return(false); } break; case ParamCharaController.ParamsKind.Bra: if (!XMLPresetIO.LoadXMLBust(controller.paramCustom.paramBust[coordinate][kind], xmlPath)) { return(false); } break; case ParamCharaController.ParamsKind.Tops: if (!XMLPresetIO.LoadXMLBust(controller.paramCustom.paramBust[coordinate][kind], xmlPath)) { return(false); } break; case ParamCharaController.ParamsKind.Hip: if (!XMLPresetIO.LoadXMLHip(controller.paramCustom.paramHip, xmlPath)) { return(false); } break; default: break; } controller.changedInfo.SetInfo(coordinate, kind, false, true, false); return(true); }
internal void DressPlayer(ChaFileDefine.CoordinateType newCoordinateType) { if (!_monitoringChange || !Game.IsInstance() || Game.Instance == null) { return; } var player = Game.Instance.Player; if (player == null) { return; } var mode = Mode.Value; var playerClothesIsAuto = player.changeClothesType < 0; var playerShouldChange = playerClothesIsAuto || mode == PluginMode.Always; Logger.DebugLogDebug( $"{nameof(DressPlayer)}: mode={mode}, playerClothesIsAuto={playerClothesIsAuto}, playerShouldChange={playerShouldChange}"); if (!playerShouldChange) { return; } player.chaCtrl.SafeProc(cc => { if (!cc.ChangeCoordinateTypeAndReload(newCoordinateType)) { return; } Logger.LogDebug($"Changed player clothes to {newCoordinateType}"); if (!playerClothesIsAuto) { // update selected clothes to match so you can change back player.changeClothesType = (int)newCoordinateType; } }); _monitoringChange = false; }
private void InitGUI() { //Character Select List <ParamCharaController> controllers = DBControllerManager.GetAllController(); charaSelect = new CharaSelect(DBControllerManager._controllers, "No character loaded", 0, 25); //Enbale Checkbox controllEnable = new ToggleEnabled("Enable controller", false); //Coordinate Select ChaFileDefine.CoordinateType[] coordinateList = new ChaFileDefine.CoordinateType[] { ChaFileDefine.CoordinateType.School01, ChaFileDefine.CoordinateType.School02, ChaFileDefine.CoordinateType.Gym, ChaFileDefine.CoordinateType.Swim, ChaFileDefine.CoordinateType.Club, ChaFileDefine.CoordinateType.Plain, ChaFileDefine.CoordinateType.Pajamas, }; List <string> coordinateStringList = new List <string>(); for (int i = 0; i < coordinateList.Count(); i++) { coordinateStringList.Add(coordinateList[i].ToString()); } coordinateSelect = new CoordinateSelect(coordinateStringList.ToArray(), coordinateList, "", 175, 25); //State Select kindSelect = new SelectableButton <ParamCharaController.ParamsKind>(Color.cyan); //Parameter editors editorBust = new EditorBust(); editorHip = new EditorHip(); //Tools Window tools = new ToolsWindow(_toolsWindowId, _s_dialogID, this); //GUI Style styleMatchState = new GUIStyle(Skin.defaultSkin.button); styleMatchState.fixedHeight = 25; }
private Dictionary <TexType, int> GetOverlayTextures(CoordinateType coordinateType) { _allOverlayTextures.TryGetValue(coordinateType, out var dict); if (dict == null) { #if KK || KKS if (!IsPerCoord() && _allOverlayTextures.Count > 0) { dict = new Dictionary <TexType, int>(_allOverlayTextures.First().Value); } else #endif dict = new Dictionary <TexType, int>(); _allOverlayTextures.Add(coordinateType, dict); } return(dict); }
public void Apply(CoordinateType coordinate, ICollection <BoneModifierData> additionalModifiers, bool isDuringHScene) { if (BoneTransform == null) { return; } var modifier = GetModifier(coordinate); if (additionalModifiers.Count > 0) { modifier = CombineModifiers(modifier, additionalModifiers); } if (CanApply(modifier)) { BoneTransform.localScale = new Vector3( _sclBaseline.x * modifier.ScaleModifier.x, _sclBaseline.y * modifier.ScaleModifier.y, _sclBaseline.z * modifier.ScaleModifier.z); if (_lenModForceUpdate || modifier.HasLength()) { if (HasLenBaseline()) { var localPosition = BoneTransform.localPosition; // Handle negative position modifiers, needed to prevent position sign changing on every frame // (since negative modifier.LengthModifier would constantly flip it) // Also needed for values near 0 to prevent losing the position data if (modifier.LengthModifier < 0.1f || localPosition == Vector3.zero || isDuringHScene) { // Fall back to more aggresive mode localPosition = _positionBaseline; _lenModNeedsPositionRestore = true; } BoneTransform.localPosition = localPosition / localPosition.magnitude * _lenBaseline * modifier.LengthModifier; _lenModForceUpdate = false; } } } }
private bool IsMatchState(ParamsKind paramsKind, ChaFileDefine.CoordinateType coordinate = ChaFileDefine.CoordinateType.School01) { switch (paramsKind) { case ParamsKind.Naked: if (GetNowBustWear() == ParamsKind.Naked) { return(true); } else { return(false); } case ParamsKind.Bra: if (coordinate == GetNowCoordinate() && paramsKind == GetNowBustWear()) { return(true); } else { return(false); } case ParamsKind.Tops: if (coordinate == GetNowCoordinate() && paramsKind == GetNowBustWear()) { return(true); } else { return(false); } case ParamsKind.Hip: return(true); default: return(false); } }
public bool isEnabledNowBust() { if (paramCustom == null) { return(false); } ChaFileDefine.CoordinateType coordinate = GetNowCoordinate(); ParamsKind state = GetNowBustWear(); if (state == ParamsKind.Naked) { return(paramCustom.paramBustNaked.enabled); } else if (state == ParamsKind.Bra || state == ParamsKind.Tops) { return(paramCustom.paramBust[coordinate][state].enabled); } return(false); }
public override BoneModifierData GetEffect(string bone, BoneController origin, ChaFileDefine.CoordinateType coordinate) { var isPregnant = _controller.Data.IsPregnant; if (isPregnant) { if (_pregnancyFullValues.TryGetValue(bone, out var mod)) { var prEffect = GetPregnancyEffectPercent(); return(LerpModifier(mod, prEffect)); } } if (isPregnant || _controller.IsInflated) { if (_bellyFullValues.TryGetValue(bone, out var mod)) { var prEffect = GetPregnancyEffectPercent(); var infEffect = _controller.GetInflationEffectPercent() + prEffect / 2; var bellySize = Mathf.Max(prEffect, infEffect); return(LerpModifier(mod, bellySize)); } } return(null); }
public bool Draw(ParamCharaController controller, ChaFileDefine.CoordinateType coordinate, ParamCharaController.ParamsKind kind) { if (controller.paramCustom == null) { return(false); } //ParamBustCustom param ParamBustCustom param = null; if (kind == ParamCharaController.ParamsKind.Naked) { param = controller.paramCustom.paramBustNaked; } else if (kind == ParamCharaController.ParamsKind.Bra || kind == ParamCharaController.ParamsKind.Tops) { param = controller.paramCustom.paramBust[coordinate][kind]; } else { return(false); } bool changedEnabled = false; bool changedParam = false; //Enabled changedEnabled = enabled.Draw(ref param.enabled, Style.ToggleMiddle); //GUILayout.Label("Parameters", Style.LabedMiddleSubject); GUILayout.Space(Style.defaultSpace); changedParam = changedParam | gravity.Draw(ref param.gravity); /*Bust01 * GUILayout.Label(ParamBustCustom.Bones[0],Style.LabedMiddle); * irc01.Draw(); //If IsRotationCalc of Bust01 changed, bust animation is broken. * changedParam = changedParam | damping01.Draw(ref param.paramBones[ParamBustCustom.Bones[0]].Damping); * changedParam = changedParam | elasticity01.Draw(ref param.paramBones[ParamBustCustom.Bones[0]].Elasticity); * changedParam = changedParam | stiffness01.Draw(ref param.paramBones[ParamBustCustom.Bones[0]].Stiffness); * changedParam = changedParam | inert01.Draw(ref param.paramBones[ParamBustCustom.Bones[0]].Inert); * GUILayout.Space(Style.defaultSpace); */ //Bust02 GUILayout.Label(ParamBustCustom.Bones[1], Style.LabedMiddleSubject); GUILayout.Space(Style.defaultSpace); GUI.skin.label.fontSize = 12; changedParam = changedParam | irc02.Draw(ref param.paramBones[ParamBustCustom.Bones[1]].IsRotationCalc); changedParam = changedParam | damping02.Draw(ref param.paramBones[ParamBustCustom.Bones[1]].Damping); changedParam = changedParam | elasticity02.Draw(ref param.paramBones[ParamBustCustom.Bones[1]].Elasticity); changedParam = changedParam | stiffness02.Draw(ref param.paramBones[ParamBustCustom.Bones[1]].Stiffness); changedParam = changedParam | inert02.Draw(ref param.paramBones[ParamBustCustom.Bones[1]].Inert); GUILayout.Space(Style.defaultSpace); //Bust03 GUILayout.Label(ParamBustCustom.Bones[2], Style.LabedMiddleSubject); GUILayout.Space(Style.defaultSpace); GUI.skin.label.fontSize = 12; changedParam = changedParam | irc03.Draw(ref param.paramBones[ParamBustCustom.Bones[2]].IsRotationCalc); changedParam = changedParam | damping03.Draw(ref param.paramBones[ParamBustCustom.Bones[2]].Damping); changedParam = changedParam | elasticity03.Draw(ref param.paramBones[ParamBustCustom.Bones[2]].Elasticity); changedParam = changedParam | stiffness03.Draw(ref param.paramBones[ParamBustCustom.Bones[2]].Stiffness); changedParam = changedParam | inert03.Draw(ref param.paramBones[ParamBustCustom.Bones[2]].Inert); GUILayout.Space(Style.defaultSpace); if (changedEnabled) { controller.changedInfo.SetInfo(coordinate, kind, true, false); } else if (changedParam) { controller.changedInfo.SetInfo(coordinate, kind, false, true); } return(changedParam | changedEnabled); }
public static void CopyKCOXData(ChaControl sourceChaCtrl, ChaControl targetChaCtrl, int kind, bool?main = true) { if (sourceChaCtrl != KCOX_Support.sourceChaCtrl || targetChaCtrl != KCOX_Support.targetChaCtrl) { if (!GetControllerAndBackupData(sourceChaCtrl, targetChaCtrl)) { Logger.LogError("Skip on KCOX Controller not found."); CleanKCOXBackup(); return; } } string name = ""; switch (main) { case true: name = MainClothesNames[kind]; switch (kind) { case 0: //換上衣時處理sub和BodyMask、InnerMask for (int i = 0; i < 3; i++) { CopyKCOXData(sourceChaCtrl, targetChaCtrl, i, false); } for (int i = 0; i < 2; i++) { CopyKCOXData(sourceChaCtrl, targetChaCtrl, i, null); } break; case 2: //換胸罩時處理BraMask CopyKCOXData(sourceChaCtrl, targetChaCtrl, 2, null); break; } break; case false: name = SubClothesNames[kind]; break; case null: name = MaskKind[kind]; break; } bool exist = SourceKCOXBackup.TryGetValue(name, out object tex); //KCOXController.Invoke("SetOverlayTex", new object[] { tex, name }); ChaFileDefine.CoordinateType coordinateType = (ChaFileDefine.CoordinateType)targetChaCtrl.fileStatus.coordinateType; Dictionary <ChaFileDefine.CoordinateType, object> _allOverlayTextures = TargetKCOXController.GetField("_allOverlayTextures").ToDictionary <ChaFileDefine.CoordinateType, object>(); if (TargetKCOXController.GetProperty("CurrentOverlayTextures").ToDictionary <string, object>().TryGetValue(name, out object clothesTexData)) { if (!exist || tex == null || (bool)tex.Invoke("IsEmpty")) { clothesTexData.Invoke("Clear"); clothesTexData.SetField("Override", false); _allOverlayTextures[coordinateType].Invoke("Remove", new object[] { name }); Logger.LogDebug($"->Clear Overlay/Mask: {name}"); } else { clothesTexData.SetProperty("Texture", tex.GetProperty("Texture")); if (null != tex.GetField("Override")) { clothesTexData.SetField("Override", tex.GetField("Override")); } Logger.LogDebug($"->Replace Overlay/Mask: {name}"); } } else { if (exist && tex != null && !(bool)tex.Invoke("IsEmpty")) { _allOverlayTextures[coordinateType].Invoke("Add", new object[] { name, tex }); Logger.LogDebug($"->Add Overlay/Mask: {name}"); } } }