Skip to content

Commit

Permalink
Added initial KKS port
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed May 30, 2021
1 parent ea784d0 commit 5ec2dfc
Show file tree
Hide file tree
Showing 27 changed files with 382 additions and 41 deletions.
9 changes: 9 additions & 0 deletions src/KKAPI.sln
Expand Up @@ -26,6 +26,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KKSAPI", "KKSAPI\KKSAPI.csproj", "{C275954F-05F9-4AFF-8290-E8190B54A602}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Shared.KKalike\Shared.KKalike.projitems*{16441a78-1945-4d7c-b3f4-333bab848211}*SharedItemsImports = 13
Expand All @@ -42,6 +44,9 @@ Global
Shared.CharaStudio\Shared.CharaStudio.projitems*{b0aa6926-d9a2-40b8-8100-cceb9a17ff10}*SharedItemsImports = 4
Shared.Core\Shared.Core.projitems*{bd697c6c-a7d7-4307-a227-ccafc95c8744}*SharedItemsImports = 13
Shared.AIalike\Shared.AIalike.projitems*{bed55866-7531-4cc4-ba58-f406d901d3e8}*SharedItemsImports = 13
Shared.CharaStudio\Shared.CharaStudio.projitems*{c275954f-05f9-4aff-8290-e8190b54a602}*SharedItemsImports = 4
Shared.Core\Shared.Core.projitems*{c275954f-05f9-4aff-8290-e8190b54a602}*SharedItemsImports = 4
Shared.KKalike\Shared.KKalike.projitems*{c275954f-05f9-4aff-8290-e8190b54a602}*SharedItemsImports = 4
Shared.Core\Shared.Core.projitems*{f4928b3c-e2b0-4aec-9fbc-327bb2a0e6bb}*SharedItemsImports = 4
Shared.KKalike\Shared.KKalike.projitems*{f4928b3c-e2b0-4aec-9fbc-327bb2a0e6bb}*SharedItemsImports = 4
EndGlobalSection
Expand Down Expand Up @@ -70,6 +75,10 @@ Global
{32333D00-1E55-4714-AD80-291B514A4F6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32333D00-1E55-4714-AD80-291B514A4F6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32333D00-1E55-4714-AD80-291B514A4F6E}.Release|Any CPU.Build.0 = Release|Any CPU
{C275954F-05F9-4AFF-8290-E8190B54A602}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C275954F-05F9-4AFF-8290-E8190B54A602}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C275954F-05F9-4AFF-8290-E8190B54A602}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C275954F-05F9-4AFF-8290-E8190B54A602}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
176 changes: 176 additions & 0 deletions src/KKSAPI/KKSAPI.csproj

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions src/KKSAPI/KoikatuAPI.cs
@@ -0,0 +1,62 @@
using System;
using BepInEx;
using HarmonyLib;
using KKAPI.Chara;
using KKAPI.MainGame;
using KKAPI.Maker;
using KKAPI.Studio;
using Manager;
using UnityEngine;

namespace KKAPI
{
[BepInPlugin(GUID, "Modding API", VersionConst)]
public partial class KoikatuAPI : BaseUnityPlugin
{
private void Awake()
{
BaseAwake();

var insideStudio = Application.productName == "CharaStudio";
MakerAPI.Init(insideStudio);
StudioAPI.Init(insideStudio);
CharacterApi.Init();
//todo GameAPI.Init(insideStudio);
}

private void Start()
{
// Needs to be called after moreaccessories has a chance to load
AccessoriesApi.Init();
}

/// <summary>
/// Get current game mode.
/// </summary>
public static GameMode GetCurrentGameMode()
{
if (StudioAPI.InsideStudio) return GameMode.Studio;
if (MakerAPI.InsideMaker) return GameMode.Maker;
if (Game.initialized) return GameMode.MainGame;
return GameMode.Unknown;
}

/// <summary>
/// Get current version of the game.
/// </summary>
public static Version GetGameVersion()
{
return Game.Version;
}

/// <summary>
/// Check if the game is the Steam release instead of the original Japanese release.
/// <remarks>It's best to not rely on this and instead make the same code work in both versions (if possible).</remarks>
/// </summary>
[Obsolete("Not implemented yet, always false")]
public static bool IsSteamRelease()
{
return false; //typeof(DownloadScene).GetProperty("isSteam", AccessTools.all) != null; //todo
}
}
}
35 changes: 35 additions & 0 deletions src/KKSAPI/Maker/AccessoryCopyEventArgs.cs
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;

namespace KKAPI.Maker
{
/// <summary>
/// Event args for accessory copy events.
/// </summary>
public class AccessoryCopyEventArgs : EventArgs
{
/// <inheritdoc />
public AccessoryCopyEventArgs(IEnumerable<int> copiedSlotIndexes,
ChaFileDefine.CoordinateType copySource, ChaFileDefine.CoordinateType copyDestination)
{
CopiedSlotIndexes = copiedSlotIndexes ?? throw new ArgumentNullException(nameof(copiedSlotIndexes));
CopySource = copySource;
CopyDestination = copyDestination;
}

/// <summary>
/// Indexes of accessories that were selected to be copied.
/// </summary>
public IEnumerable<int> CopiedSlotIndexes { get; }

/// <summary>
/// Coordinate the accessories are copied from.
/// </summary>
public ChaFileDefine.CoordinateType CopySource { get; }

/// <summary>
/// Coordinate the accessories are copied into.
/// </summary>
public ChaFileDefine.CoordinateType CopyDestination { get; }
}
}
33 changes: 33 additions & 0 deletions src/KKSAPI/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.InteropServices;
using KKAPI;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("KKSAPI")]
[assembly: AssemblyDescription("Modding API for Koikatsu Sunshine")]
[assembly: AssemblyCompany("ManlyMarco")]
[assembly: AssemblyProduct("KKSAPI")]
[assembly: AssemblyCopyright("Copyright © 2021")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("74c2db86-55bb-47b4-9805-51b5b992ef35")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion(KoikatuAPI.VersionConst)]
[assembly: AssemblyVersion(KoikatuAPI.VersionConst)]
18 changes: 18 additions & 0 deletions src/KKSAPI/packages.config
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="IllusionLibs.BepInEx" version="5.4.8" targetFramework="net46" />
<package id="IllusionLibs.BepInEx.Harmony" version="2.3.2" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.Assembly-CSharp" version="2021.5.28" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.Assembly-CSharp-firstpass" version="2021.5.28" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.UniRx" version="2021.5.28" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.Unity.TextMeshPro" version="2019.4.9" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.UnityEngine.AudioModule" version="2019.4.9" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule" version="2019.4.9" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.UnityEngine.ImageConversionModule" version="2019.4.9" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.UnityEngine.IMGUIModule" version="2019.4.9" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.UnityEngine.InputLegacyModule" version="2019.4.9" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.UnityEngine.TextRenderingModule" version="2019.4.9" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.UnityEngine.UI" version="2019.4.9" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.UnityEngine.UIModule" version="2019.4.9" targetFramework="net46" />
<package id="IllusionLibs.XUnity.AutoTranslator.Plugin.Core" version="4.16.0" targetFramework="net46" />
</packages>
@@ -1,4 +1,4 @@
#if KK || AI || HS2
#if KK || KKS || AI || HS2
#define TMP
#endif

Expand All @@ -20,7 +20,7 @@ public class CurrentStateCategoryDropdown : BaseCurrentStateEditableGuiEntry<int
{
private readonly string[] _items;
private static GameObject _originalObject;
#if AI || HS2
#if AI || HS2 || KKS //todo KKS needs a check whenever studio comes out
private const string ObjectSourcePath = "StudioScene/Canvas Main Menu/04_System/01_Screen Effect/Screen Effect/Viewport/Content/Color Grading/Lookup Texture";
#elif KK
private const string ObjectSourcePath = "StudioScene/Canvas Main Menu/02_Manipulate/00_Chara/02_Kinematic/05_Etc/Eyes Draw";
Expand All @@ -46,7 +46,7 @@ protected override GameObject CreateItem(GameObject categoryObject)
if (_originalObject == null)
{
_originalObject = GameObject.Find(ObjectSourcePath);
#if KK || PH
#if KK || KKS || PH
// Unused controls, safe to remove for less overhead later on
foreach (var tr in _originalObject.transform.Cast<Transform>().Where(t => t.name.StartsWith("Toggle")))
Object.DestroyImmediate(tr.gameObject);
Expand Down
4 changes: 2 additions & 2 deletions src/Shared.CharaStudio/Studio/UI/SceneEffectsCategory.cs
@@ -1,4 +1,4 @@
#if KK || AI || HS2
#if KK || KKS || AI || HS2
#define TMP
#endif

Expand Down Expand Up @@ -40,7 +40,7 @@ private static void Initialize()

const string headerSourcePath = "Screen Effect/Viewport/Content/Image Depth of Field";
const string contentSourcePath = "Screen Effect/Viewport/Content/Depth of Field";
#if KK
#if KK || KKS
const string labelSourcePath = "Screen Effect/Viewport/Content/Depth of Field/TextMeshPro Draw";
const string toggleSourcePath = "Screen Effect/Viewport/Content/Depth of Field/Toggle Draw";
const string sliderSourcePath = "Screen Effect/Viewport/Content/Depth of Field/Slider Focal Size";
Expand Down
@@ -1,4 +1,4 @@
#if KK || AI || HS2
#if KK || KKS || AI || HS2
#define TMP
#endif

Expand Down
@@ -1,4 +1,4 @@
#if KK || AI || HS2
#if KK || KKS || AI || HS2
#define TMP
#endif

Expand Down
10 changes: 5 additions & 5 deletions src/Shared.Core/Chara/CharaCustomFunctionController.cs
Expand Up @@ -2,7 +2,7 @@
using KKAPI.Utilities;
using System;
using System.Collections;
#if KK
#if KK || KKS
using KKAPI.MainGame;
using UniRx;
#elif AI || HS2
Expand Down Expand Up @@ -82,7 +82,7 @@ public void SetExtendedData(PluginData data)
if (ExtendedDataId == null) throw new ArgumentException(nameof(ExtendedDataId));
ExtendedSave.SetExtendedDataById(ChaFileControl, ExtendedDataId, data);

#if KK
#if KK //todo || KKS
// Needed for propagating changes back to the original charFile since they don't get copied back.
var heroine = ChaControl.GetHeroine();
if (heroine != null)
Expand Down Expand Up @@ -284,7 +284,7 @@ internal void OnCoordinateBeingLoadedInternal(ChaFileCoordinate coordinate)
}
}

#if KK
#if KK || KKS
/// <summary>
/// Currently selected clothes on this character. Can subscribe to listen for changes.
/// </summary>
Expand All @@ -304,7 +304,7 @@ protected virtual void Update()
/// </summary>
protected virtual void OnDestroy()
{
#if KK
#if KK || KKS
CurrentCoordinate.Dispose();
#endif
}
Expand All @@ -325,7 +325,7 @@ protected virtual void OnEnable()
protected virtual void Awake()
{
ChaControl = GetComponent<ChaControl>();
#if KK
#if KK || KKS
CurrentCoordinate = new BehaviorSubject<ChaFileDefine.CoordinateType>((ChaFileDefine.CoordinateType)ChaControl.fileStatus.coordinateType);
#endif
}
Expand Down
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
#if KK || EC
#if KK || KKS || EC
using UniRx;
#elif AI || HS2
using AIChara;
Expand Down
2 changes: 1 addition & 1 deletion src/Shared.Core/Chara/CharacterApi.cs
Expand Up @@ -240,7 +240,7 @@ private static void CreateOrAddBehaviours(ChaControl target)
}
}

#if KK
#if KK || KKS
var controllers = target.GetComponents<CharaCustomFunctionController>();
target.UpdateAsObservable().Subscribe(
_ =>
Expand Down
20 changes: 14 additions & 6 deletions src/Shared.Core/Maker/MakerAPI.cs
Expand Up @@ -4,7 +4,7 @@
using KKAPI.Maker.UI;
using KKAPI.Maker.UI.Sidebar;
using UnityEngine;
#if KK || EC
#if KK || KKS || EC
using ChaCustom;
#elif AI || HS2
using CharaCustom;
Expand Down Expand Up @@ -77,7 +77,7 @@ internal static void AddSubCategory(MakerCategory category)
/// 0 is male, 1 is female
/// </summary>
public static int GetMakerSex()
#if KK || EC
#if KK || KKS || EC
=> GetMakerBase().modeSex;
#elif AI || HS2
=> CharaCustom.CharaCustom.modeSex;
Expand All @@ -100,7 +100,15 @@ public static int GetMakerSex()
/// Check if the maker was loaded from within classroom select screen in main game
/// </summary>
public static bool IsInsideClassMaker() => InsideMaker && Manager.Scene.Instance.NowSceneNames.Contains("ClassRoomSelect");
#elif KKS
/// <summary>
/// Check if the maker was loaded from within classroom select screen in main game
/// </summary>
[Obsolete("Not implemented, always false")]
public static bool IsInsideClassMaker() => false;
#endif

#if KK || KKS
/// <summary>
/// Currently selected maker coordinate
/// </summary>
Expand Down Expand Up @@ -228,7 +236,7 @@ private static void OnCreateCustomControls()
{
MakerInterfaceCreator.CreateCustomControls();

#if KK
#if KK || KKS
// Fix some plugins failing to update interface and losing state
if (IsInsideClassMaker())
{
Expand Down Expand Up @@ -413,7 +421,7 @@ public static bool IsInterfaceVisible()
if (GetIsNowLoadingFade())
return false;

#if KK || EC
#if KK || KKS || EC
// Check if UI is hidden (by pressing space)
if (mbase.customCtrl.hideFrontUI)
return false;
Expand All @@ -430,7 +438,7 @@ public static bool IsInterfaceVisible()

private static string GetAddSceneName()
{
#if HS2
#if HS2 || KKS
return Manager.Scene.AddSceneName;
#else
return Manager.Scene.Instance.AddSceneName;
Expand All @@ -439,7 +447,7 @@ private static string GetAddSceneName()

private static bool GetIsNowLoadingFade()
{
#if HS2
#if HS2 || KKS
return Manager.Scene.IsNowLoadingFade;
#else
return Manager.Scene.Instance.IsNowLoadingFade;
Expand Down
2 changes: 1 addition & 1 deletion src/Shared.Core/Maker/UI/BaseEditableGuiEntry.cs
@@ -1,4 +1,4 @@
#if AI || HS2
#if AI || HS2 || KKS
using System;
#endif
using BepInEx;
Expand Down
2 changes: 1 addition & 1 deletion src/Shared.Core/Utilities/Extensions.cs
Expand Up @@ -146,7 +146,7 @@ public static bool IsDestroyed(this UnityEngine.Object obj)
return !ReferenceEquals(obj, null) && !obj;
}

#if KK||EC
#if KK || KKS||EC
/// <summary>
/// Get value of the aaWeightsBody field
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Shared.Core/Utilities/HSceneUtils.cs
Expand Up @@ -7,7 +7,7 @@ namespace KKAPI.Utilities
/// </summary>
public static class HSceneUtils
{
#if KK
#if KK || KKS
/// <summary>
/// Get the heroine that is currently in leading position in the h scene.
/// In 3P returns the heroine the cum options affect. Outside of 3P it gets the single heroine.
Expand Down

0 comments on commit 5ec2dfc

Please sign in to comment.