Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jalil49 committed May 9, 2021
1 parent c48873b commit 909e76f
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 67 deletions.
63 changes: 32 additions & 31 deletions Accessory Parents/Accessory_Parents/Maker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ private void Hooks_ACC_Rotation_Change(object sender, Acc_modifier_Event_ARG e)

if (Bindings[CoordinateNum].TryGetValue(e.SlotNo, out var parentList))
{
Vector3 Rot = new Vector3(0, 0, 0);
Vector3 Rot = Vector3.zero;

if (e.Flags == 1)
{
Expand All @@ -395,7 +395,7 @@ private void Hooks_ACC_Rotation_Change(object sender, Acc_modifier_Event_ARG e)
{
Rot.z = e.Value;
}
//Logger.LogWarning($"Rot X: {Rot.x}, Rot Y: {Rot.y}, Rot Z: {Rot.z}");

Vector3[,] store;
if (e.SlotNo < 20)
{
Expand Down Expand Up @@ -453,10 +453,11 @@ private void Hooks_ACC_Rotation_Change(object sender, Acc_modifier_Event_ARG e)
}
else
{
Vector3 New_pos;
//Vector3 New_pos;
float Value;
foreach (var item in parentList)
{
//Vector3 Rot2 = Vector3.zero;
Vector3[,] store2;
if (item < 20)
{
Expand All @@ -472,17 +473,18 @@ private void Hooks_ACC_Rotation_Change(object sender, Acc_modifier_Event_ARG e)
if (e.Flags == 1)
{
Value = vectors[0, 1].x;
Rot.x = store2[e.CorrectNo, 1].x - Value;
//Rot2.x = vectors[0, 1].x - store2[e.CorrectNo, 1].x;
}
else if (e.Flags == 2)
{
Value = vectors[0, 1].y;
Rot.y = store2[e.CorrectNo, 1].y - Value;

//Rot2.y = vectors[0, 1].y - store2[e.CorrectNo, 1].y;
}
else if (e.Flags == 4)
{
Value = vectors[0, 1].z;
Rot.z = store2[e.CorrectNo, 1].z - Value;
//Rot2.z = vectors[0, 1].z - store2[e.CorrectNo, 1].z;
}
else
{
Expand All @@ -493,29 +495,29 @@ private void Hooks_ACC_Rotation_Change(object sender, Acc_modifier_Event_ARG e)
{
Value = 0;
}

New_pos = new Vector3(store2[0, 0].x, store2[0, 0].y, store2[0, 0].z) - original_pos;
New_pos = Quaternion.Euler(Rot) * New_pos;
New_pos -= new Vector3(store2[0, 0].x, store2[0, 0].y, store2[0, 0].z) - original_pos;
ChaControl.SetAccessoryRot(item, e.CorrectNo, Value, e.Add, e.Flags);

for (int i = 0; i < 3; i++)
{
int flag;
switch (i)
{
case 0:
flag = 1;
break;
case 1:
flag = 2;
break;
default:
flag = 4;
break;
}
ChaControl.SetAccessoryPos(item, e.CorrectNo, New_pos[i], true, flag);
}
//New_pos = new Vector3(store2[0, 0].x, store2[0, 0].y, store2[0, 0].z) - original_pos;
//New_pos = Quaternion.Euler(Rot2) * New_pos;
//New_pos -= new Vector3(store2[0, 0].x, store2[0, 0].y, store2[0, 0].z) - original_pos;

//for (int i = 0; i < 3; i++)
//{
// int flag;
// switch (i)
// {
// case 0:
// flag = 1;
// break;
// case 1:
// flag = 2;
// break;
// default:
// flag = 4;
// break;
// }
// ChaControl.SetAccessoryPos(item, e.CorrectNo, New_pos[i], true, flag);
//}


if (item < 20)
Expand All @@ -540,7 +542,6 @@ private void Hooks_ACC_Position_Change(object sender, Acc_modifier_Event_ARG e)
if (!e.Add && e.Value == 0 && Custom_Names[CoordinateNum].ContainsValue(e.SlotNo))
{
float Value;
Logger.LogWarning("Base set location");
if (Relative_Data[CoordinateNum].TryGetValue(e.SlotNo, out var vectors))
{
if (e.Flags == 1)
Expand Down Expand Up @@ -941,7 +942,7 @@ private void MakeChild()
}
}

private void Modify_Dropdown()
private void Modify_Dropdown(bool Generic = false)
{
if (MakerAPI.GetCharacterControl().GetAccessoryObject(AccessoriesApi.SelectedMakerAccSlot) == null)
{
Expand All @@ -953,7 +954,7 @@ private void Modify_Dropdown()
{
case 0:
var Text = textbox.Value;
if (textbox.Value == "")
if (textbox.Value == "" || Generic)
{
Text = $"Slot{(AccessoriesApi.SelectedMakerAccSlot + 1):000}";
}
Expand Down Expand Up @@ -1022,7 +1023,7 @@ protected override void Update()
else if (Input.GetKeyDown(KeyCode.F))
{
MakeChild();
Modify_Dropdown();
Modify_Dropdown(true);
Parent_DropDown.SetValue(Parent_DropDown.ControlObject.GetComponentInChildren<TMP_Dropdown>().options.Count() - 1);
}
}
Expand Down
1 change: 1 addition & 0 deletions Accessory Shortcuts/Accessory_Shortcuts/Maker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ protected override void Update()
Settings.Logger.LogWarning($"Slot num {(int)CVS_Slot.slotNo}");
CVS_Slot.UpdateSelectAccessoryType(kind);
CVS_Slot.UpdateCustomUI();
CVS_Slot.tglAcsKind.isOn = true;
}
Skip = false;
}
Expand Down
40 changes: 21 additions & 19 deletions Accessory States/CharaEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public partial class CharaEvent : CharaCustomFunctionController
{
private Data ThisCharactersData;
ChaFile chafile;
public static event EventHandler<CoordinateLoadedEventARG> coordloaded;
public static event EventHandler<CoordinateLoadedEventARG> Coordloaded;
private List<bool> Accessory_Show_Bools = new List<bool>();
public List<ChaFileAccessory.PartsInfo> Accessorys_Parts = new List<ChaFileAccessory.PartsInfo>();

Expand Down Expand Up @@ -278,7 +278,11 @@ protected override void OnReload(GameMode currentGameMode, bool maintainState)
}
}

CurrentCoordinate.Subscribe(x => Refresh());
ThisCharactersData.Update_Now_Coordinate();
CurrentCoordinate.Subscribe(x =>
{
Refresh(); StartCoroutine(WaitForSlots());
});
}
}

Expand Down Expand Up @@ -425,17 +429,17 @@ protected override void OnCoordinateBeingLoaded(ChaFileCoordinate coordinate, bo

//call event
var args = new CoordinateLoadedEventARG(ChaControl, coordinate);
if (coordloaded == null || coordloaded.GetInvocationList().Length == 0)
if (Coordloaded == null || Coordloaded.GetInvocationList().Length == 0)
{
return;
}
try
{
coordloaded?.Invoke(null, args);
Coordloaded?.Invoke(null, args);
}
catch (Exception ex)
{
Settings.Logger.LogError($"Subscriber crash in {nameof(Hooks)}.{nameof(coordloaded)} - {ex}");
Settings.Logger.LogError($"Subscriber crash in {nameof(Hooks)}.{nameof(Coordloaded)} - {ex}");
}

}
Expand Down Expand Up @@ -502,20 +506,13 @@ private void SetClothesState_switch_Case(bool condition, int clothesKind, byte s
public void Refresh()
{
Update_More_Accessories();
ThisCharactersData.Update_Now_Coordinate();
if (ChaControl.fileStatus.clothesState != null)
for (int i = 0; i < 9; i++)
{
for (int i = 0; i < 9; i++)
{
ChangedOutfit(i, ChaControl.fileStatus.clothesState[i]);
}
ChangedOutfit(i, ChaControl.fileStatus.clothesState[i]);
}
else
foreach (var item in ThisCharactersData.Now_ACC_Name_Dictionary.Keys)
{
for (int i = 0; i < 9; i++)
{
ChangedOutfit(i, 0);
}
Custom_Groups(item, 0);
}
}

Expand All @@ -526,13 +523,11 @@ private void SetClothesState_switch_Case_2(byte state, int Clotheskind)
if (ChaControl.IsClothesStateKind(Clotheskind))
{
ChangedOutfit(Clotheskind, state);
//ChaControl.fileStatus.clothesState[Clotheskind] = state;
}
}
else
{
ChangedOutfit(Clotheskind, state);
//ChaControl.fileStatus.clothesState[Clotheskind] = state;
}
}

Expand Down Expand Up @@ -617,7 +612,14 @@ protected override void Update()
{
if (Input.GetKeyDown(KeyCode.N))
{
Settings.Logger.LogWarning(ACC_Appearance_state2.Control.ControlObjects.Count());
foreach (var item in ThisCharactersData.ACC_Name_Dictionary[0])
{
Settings.Logger.LogWarning($"kind {item.Key} is called {item.Value}");
}
foreach (var item in ThisCharactersData.ACC_Binding_Dictionary[0])
{
Settings.Logger.LogWarning($"slot {item.Key} is part of kind {item.Value}");
}
}
}
base.Update();
Expand Down
6 changes: 1 addition & 5 deletions Accessory States/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,16 @@ public Data(int _Personality, string _BirthDay, string _FullName, CharaEvent con

public void Update_Now_Coordinate()
{
int outfitnum = Controller.ChaControl.fileStatus.coordinateType;
int outfitnum = (int)Controller.CurrentCoordinate.Value;
Settings.Logger.LogWarning((ChaFileDefine.CoordinateType)outfitnum);
if (KKAPI.KoikatuAPI.GetCurrentGameMode() == KKAPI.GameMode.Maker)
{
Now_ACC_Binding_Dictionary = new Dictionary<int, int>();
Now_ACC_Binding_Dictionary = ACC_Binding_Dictionary[outfitnum];

Now_ACC_Name_Dictionary = new Dictionary<int, string>();
Now_ACC_Name_Dictionary = ACC_Name_Dictionary[outfitnum];

Now_ACC_State_array = new Dictionary<int, int[]>();
Now_ACC_State_array = ACC_State_array[outfitnum];

Now_Parented_Dictionary = new Dictionary<int, bool>();
Now_Parented_Dictionary = ACC_Parented_Dictionary[outfitnum];
//Now_Parented_Name_Dictionary = ACC_Parented_Name_Dictionary[outfitnum];
}
Expand Down
6 changes: 4 additions & 2 deletions Accessory States/GameEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class GameEvent : GameCustomFunctionController
protected override void OnStartH(HSceneProc hSceneProc, bool freeH)
{
Hooks.HcoordChange += Hooks_HcoordChange;
CharaEvent.coordloaded += CharaEvent_coordloaded;
CharaEvent.Coordloaded += CharaEvent_coordloaded;
hScene = hSceneProc;
var heroines = hScene.dataH.lstFemale;
for (int i = 0; i < heroines.Count; i++)
Expand All @@ -34,6 +34,7 @@ IEnumerator Wait()
{
yield return null;
}
ThisCharactersData.Update_Now_Coordinate();
ThisCharactersData.Controller.Refresh();
}
Settings.Logger.LogWarning("length" + ThisCharactersData.Controller.ChaControl.fileStatus.clothesState.Length);
Expand Down Expand Up @@ -72,7 +73,6 @@ protected override void OnEndH(HSceneProc hSceneProc, bool freeH)

private void Hooks_HcoordChange(object sender, OnClickCoordinateChange e)
{
Settings.Logger.LogWarning("coord change button");
Buttonlogic(e.Female, false);
}

Expand Down Expand Up @@ -164,6 +164,8 @@ private void Createbutton(int Female, bool Harem, string name, int kind, Data Ch
Transform copy = Instantiate(origin.transform, parent, false);
copy.name = $"btn_{name}_{kind}";
copy.GetComponentInChildren<TextMeshProUGUI>().text = name;
var trans = copy.GetComponent<RectTransform>();
trans.sizeDelta = new Vector2(115, trans.sizeDelta.y);

Button button = copy.GetComponentInChildren<Button>();
button.onClick.SetPersistentListenerState(0, UnityEngine.Events.UnityEventCallState.Off);
Expand Down
21 changes: 13 additions & 8 deletions Accessory States/Maker.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using KKAPI.Chara;
using KKAPI;
using KKAPI.Chara;
using KKAPI.Maker;
using KKAPI.Maker.UI;
using System;
Expand Down Expand Up @@ -44,7 +45,7 @@ private void MakerAPI_RegisterCustomSubCategories(object sender, RegisterSubCate
var ThemeTextBox = new MakerTextbox(category, "Name: ", "", owner);
ThemeText = MakerAPI.AddAccessoryWindowControl<MakerTextbox>(ThemeTextBox);

var radio = new MakerRadioButtons(category, owner, "options", 0, new string[] { "Add Group", "Remove Group", "Rename" })
var radio = new MakerRadioButtons(category, owner, "Modify", 0, new string[] { "Add", "Remove", "Rename" })
{
Unify_AccessoryWindowControl = true
};
Expand Down Expand Up @@ -200,31 +201,29 @@ private void MakerAPI_RegisterCustomSubCategories(object sender, RegisterSubCate

internal void Maker_started()
{
MakerAPI.RegisterCustomSubCategories += MakerAPI_RegisterCustomSubCategories;
MakerAPI.ReloadCustomInterface += MakerAPI_ReloadCustomInterface;
MakerAPI.MakerFinishedLoading += (s, e) => VisibiltyToggle();

AccessoriesApi.MakerAccSlotAdded += AccessoriesApi_MakerAccSlotAdded;
AccessoriesApi.AccessoriesCopied += AccessoriesApi_AccessoriesCopied;
AccessoriesApi.AccessoryTransferred += AccessoriesApi_AccessoryTransferred;
AccessoriesApi.AccessoryKindChanged += AccessoriesApi_AccessoryKindChanged;
AccessoriesApi.SelectedMakerAccSlotChanged += (s, e) => VisibiltyToggle();

MakerAPI.MakerFinishedLoading += (s, e) => VisibiltyToggle();
AccessoriesApi.SelectedMakerAccSlotChanged += (s, e) => VisibiltyToggle();
Hooks.Slot_ACC_Change += (s, e) => VisibiltyToggle();
}

internal void Maker_Ended()
{
MakerAPI.RegisterCustomSubCategories -= MakerAPI_RegisterCustomSubCategories;
MakerAPI.ReloadCustomInterface -= MakerAPI_ReloadCustomInterface;
MakerAPI.MakerFinishedLoading -= (s, e) => VisibiltyToggle();

AccessoriesApi.MakerAccSlotAdded -= AccessoriesApi_MakerAccSlotAdded;
AccessoriesApi.AccessoriesCopied -= AccessoriesApi_AccessoriesCopied;
AccessoriesApi.AccessoryTransferred -= AccessoriesApi_AccessoryTransferred;
AccessoriesApi.AccessoryKindChanged -= AccessoriesApi_AccessoryKindChanged;
AccessoriesApi.SelectedMakerAccSlotChanged -= (s, e) => VisibiltyToggle();

AccessoriesApi.SelectedMakerAccSlotChanged -= (s, e) => VisibiltyToggle();
MakerAPI.MakerFinishedLoading -= (s, e) => VisibiltyToggle();
Hooks.Slot_ACC_Change -= (s, e) => VisibiltyToggle();
}

Expand Down Expand Up @@ -276,6 +275,7 @@ private void AccessoriesApi_AccessoriesCopied(object sender, AccessoryCopyEventA
private void MakerAPI_ReloadCustomInterface(object sender, EventArgs e)
{
StartCoroutine(WaitForSlots());
VisibiltyToggle();
}

private void AccessoriesApi_MakerAccSlotAdded(object sender, AccessorySlotEventArgs e)
Expand Down Expand Up @@ -473,6 +473,11 @@ private void Update_Drop_boxes()

private IEnumerator WaitForSlots()
{
if (KoikatuAPI.GetCurrentGameMode() != GameMode.Maker)
{
yield break;
}
ThisCharactersData.Update_Now_Coordinate();
Refresh();
int ACCData = Accessorys_Parts.Count();

Expand Down
Loading

0 comments on commit 909e76f

Please sign in to comment.