Skip to content

Commit 2a493dc

Browse files
committed
Initial commit
1 parent 7b2f49a commit 2a493dc

29 files changed

Lines changed: 2198 additions & 0 deletions

COM3D2.DressCode.csproj

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net35</TargetFramework>
5+
<LangVersion>10</LangVersion>
6+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7+
<DebugType>Full</DebugType>
8+
<Product>DressCode</Product>
9+
<Version>1.0.0</Version>
10+
<Authors>Perdition</Authors>
11+
<PackageProjectUrl>https://github.com/Perdition-117/COM3D2.DressCode</PackageProjectUrl>
12+
<RepositoryUrl>https://github.com/Perdition-117/COM3D2.DressCode.git</RepositoryUrl>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="BepInEx.BaseLib" Version="5.4.19" />
17+
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.1.0" />
18+
<PackageReference Include="COM3D2.GameLibs" Version="2.13.0-r.0" />
19+
<PackageReference Include="HarmonyX" Version="2.10.0" />
20+
<PackageReference Include="UnityEngine" Version="5.6.1" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<Reference Include="COM3D2.I2PluginLocalization">
25+
<HintPath>Libs\COM3D2.I2PluginLocalization.dll</HintPath>
26+
</Reference>
27+
</ItemGroup>
28+
29+
<ItemGroup>
30+
<None Update="localization\DressCode.xml">
31+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
32+
</None>
33+
</ItemGroup>
34+
35+
</Project>

COM3D2.DressCode.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.1.32210.238
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "COM3D2.DressCode", "COM3D2.DressCode.csproj", "{5D8D2081-DEFF-4F26-81C4-4AEA02A7F757}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{5D8D2081-DEFF-4F26-81C4-4AEA02A7F757}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{5D8D2081-DEFF-4F26-81C4-4AEA02A7F757}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{5D8D2081-DEFF-4F26-81C4-4AEA02A7F757}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{5D8D2081-DEFF-4F26-81C4-4AEA02A7F757}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {4BBACB93-E320-4EC9-874F-CEF6C4A1C800}
24+
EndGlobalSection
25+
EndGlobal

Components/AnimatedButton.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace COM3D2.DressCode;
2+
3+
internal class AnimatedButton : BaseComponent {
4+
private readonly Color Hover = Color.white;
5+
private readonly Color Default = new(1, 1, 1, 0.6706f);
6+
private readonly Color Pressed = new(1, 1, 1, 0.7843f);
7+
private readonly Color Disabled = new(0.5f, 0.5f, 0.5f, 1);
8+
9+
protected readonly UISprite _sprite;
10+
protected readonly UIButton _button;
11+
12+
public AnimatedButton(BaseComponent parent, string name) : base(parent, name) {
13+
_sprite = AddComponent<UISprite>();
14+
15+
_button = AddComponent<UIButton>();
16+
_button.hover = Hover;
17+
_button.defaultColor = Default;
18+
_button.pressed = Pressed;
19+
_button.disabledColor = Disabled;
20+
21+
var animation = AddComponent<Animation>();
22+
animation.playAutomatically = false;
23+
animation.clip = Resources.Load<AnimationClip>("SceneEdit/MainMenu/Animation/ButtonPuyo");
24+
animation.AddClip(animation.clip, animation.clip.name);
25+
26+
var playAnimation = AddComponent<UIPlayAnimation>();
27+
playAnimation.trigger = AnimationOrTween.Trigger.OnHover;
28+
playAnimation.target = animation;
29+
}
30+
}

Components/BaseComponent.cs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
namespace COM3D2.DressCode;
2+
3+
internal class BaseComponent {
4+
public GameObject GameObject { get; protected set; }
5+
6+
public BaseComponent(string name) {
7+
GameObject = new GameObject(name);
8+
}
9+
10+
public BaseComponent(GameObject parent, string name) : this(name) {
11+
SetParent(parent);
12+
}
13+
14+
public BaseComponent(BaseComponent parent, string name) : this(parent.GameObject, name) { }
15+
16+
public string Name {
17+
get => GameObject.name;
18+
set => GameObject.name = value;
19+
}
20+
21+
public Vector3 Position {
22+
get => GameObject.transform.localPosition;
23+
set => GameObject.transform.localPosition = value;
24+
}
25+
26+
public Vector3 Scale {
27+
get => GameObject.transform.localScale;
28+
set => GameObject.transform.localScale = value;
29+
}
30+
31+
public void SetParent(GameObject parent) {
32+
var transform = GameObject.transform;
33+
transform.parent = parent.transform;
34+
transform.localPosition = Vector3.zero;
35+
transform.localRotation = Quaternion.identity;
36+
transform.localScale = Vector3.one;
37+
GameObject.layer = parent.layer;
38+
}
39+
40+
public void SetActive(bool isActive) {
41+
GameObject.SetActive(isActive);
42+
}
43+
44+
public BaseComponent AddChild(string name = null) {
45+
var child = new BaseComponent(GameObject, name);
46+
return child;
47+
}
48+
49+
public T AddChild<T>() where T : Component {
50+
var child = AddChild(NGUITools.GetTypeName<T>());
51+
return child.AddComponent<T>();
52+
}
53+
54+
public T AddComponent<T>() where T : Component {
55+
return GameObject.AddComponent<T>();
56+
}
57+
58+
public T GetComponent<T>() where T : Component {
59+
return GameObject.GetComponent<T>();
60+
}
61+
62+
public T GetComponentInChildren<T>() where T : Component {
63+
return GameObject.GetComponentInChildren<T>();
64+
}
65+
66+
public UISprite AddSprite(string atlasName, string spriteName) {
67+
var sprite = AddComponent<UISprite>();
68+
sprite.atlas = GetResource<UIAtlas>(atlasName);
69+
sprite.spriteName = spriteName;
70+
return sprite;
71+
}
72+
73+
public Image AddImage(string spriteName) {
74+
var image = AddComponent<Image>();
75+
image.sprite = GetResource<Sprite>(spriteName);
76+
image.type = Image.Type.Sliced;
77+
return image;
78+
}
79+
80+
public void AddWidgetCollider() {
81+
NGUITools.AddWidgetCollider(GameObject);
82+
}
83+
84+
public void UpdateWidgetCollider() {
85+
NGUITools.UpdateWidgetCollider(GameObject);
86+
}
87+
88+
public static T GetResource<T>(string name) where T : UnityEngine.Object {
89+
return Resources.FindObjectsOfTypeAll<T>().FirstOrDefault(o => o.name == name);
90+
}
91+
}

Components/CanvasComponent.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
namespace COM3D2.DressCode;
2+
3+
internal class CanvasComponent : BaseComponent {
4+
private readonly RectTransform _transform;
5+
6+
public CanvasComponent(GameObject parent, string name) : base(parent, name) {
7+
GameObject.transform.SetParent(parent.transform, false);
8+
_transform = GameObject.AddComponent<RectTransform>();
9+
}
10+
11+
public CanvasComponent(BaseComponent parent, string name) : this(parent.GameObject, name) { }
12+
13+
public Vector2 SizeDelta {
14+
get => _transform.sizeDelta;
15+
set => _transform.sizeDelta = value;
16+
}
17+
18+
public Vector2 AnchorMin {
19+
get => _transform.anchorMin;
20+
set => _transform.anchorMin = value;
21+
}
22+
23+
public Vector2 AnchorMax {
24+
get => _transform.anchorMax;
25+
set => _transform.anchorMax = value;
26+
}
27+
28+
public Vector2 OffsetMin {
29+
get => _transform.offsetMin;
30+
set => _transform.offsetMin = value;
31+
}
32+
33+
public Vector2 OffsetMax {
34+
get => _transform.offsetMax;
35+
set => _transform.offsetMax = value;
36+
}
37+
38+
public new CanvasComponent AddChild(string name) {
39+
return new(GameObject, name);
40+
}
41+
42+
public void SetAllPoints() {
43+
SizeDelta = Vector2.zero;
44+
AnchorMin = new(0, 0);
45+
AnchorMax = new(1, 1);
46+
}
47+
}

Components/CircleButton.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using I2.Loc;
2+
3+
namespace COM3D2.DressCode;
4+
5+
internal class CircleButton : AnimatedButton {
6+
private readonly UILabel _label;
7+
private readonly Localize _localize;
8+
9+
public CircleButton(BaseComponent parent, string name) : base(parent, name) {
10+
_sprite.atlas = GetResource<UIAtlas>("AtlasCommon2");
11+
_sprite.spriteName = "main_buttom";
12+
_sprite.width = 120;
13+
_sprite.height = 120;
14+
15+
AddWidgetCollider();
16+
17+
var label = AddChild("Value");
18+
19+
_label = label.AddComponent<UILabel>();
20+
_label.trueTypeFont = GetResource<Font>("NotoSansCJKjp-DemiLight");
21+
_label.fontSize = 22;
22+
_label.alignment = NGUIText.Alignment.Center;
23+
_label.depth = 2;
24+
_label.color = new(0.251f, 0.251f, 0.251f, 1);
25+
26+
_localize = label.AddComponent<Localize>();
27+
}
28+
29+
public event EventDelegate.Callback Click {
30+
add => EventDelegate.Add(_button.onClick, value);
31+
remove => EventDelegate.Remove(_button.onClick, value);
32+
}
33+
34+
public string Text {
35+
get => _label.text;
36+
set => _label.text = value;
37+
}
38+
39+
public string Term {
40+
set => _localize.Term = DressCode.GetTermKey(value);
41+
}
42+
}

Components/Label.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using I2.Loc;
2+
3+
namespace COM3D2.DressCode;
4+
5+
internal class Label : CanvasComponent {
6+
private readonly Text _labelText;
7+
private readonly Localize _localize;
8+
9+
public Label(BaseComponent parent, string name) : base(parent, name) {
10+
_labelText = AddComponent<Text>();
11+
_labelText.font = GetResource<Font>("NotoSansCJKjp-DemiLight");
12+
_labelText.fontSize = 20;
13+
_labelText.alignment = TextAnchor.MiddleCenter;
14+
15+
_localize = AddComponent<Localize>();
16+
}
17+
18+
public string Text {
19+
get => _labelText.text;
20+
set => _labelText.text = value;
21+
}
22+
23+
public string Term {
24+
set => _localize.Term = DressCode.GetTermKey(value);
25+
}
26+
27+
public int FontSize {
28+
get => _labelText.fontSize;
29+
set => _labelText.fontSize = value;
30+
}
31+
32+
public TextAnchor Alignment {
33+
get => _labelText.alignment;
34+
set => _labelText.alignment = value;
35+
}
36+
37+
public Color Color {
38+
get => _labelText.color;
39+
set => _labelText.color = value;
40+
}
41+
42+
public bool RaycastTarget {
43+
get => _labelText.raycastTarget;
44+
set => _labelText.raycastTarget = value;
45+
}
46+
}

0 commit comments

Comments
 (0)