Skip to content
This repository was archived by the owner on Feb 20, 2025. It is now read-only.

Commit c944de7

Browse files
committed
2 parents 526db10 + 938018f commit c944de7

24 files changed

+335
-7
lines changed

APITest/APITest.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
<Reference Include="System.Data" />
8787
<Reference Include="System.Net.Http" />
8888
<Reference Include="System.Xml" />
89-
<Reference Include="System.Drawing" />
89+
<Reference Include="System.Drawing" />
9090
<Reference Include="Unity.TextMeshPro">
9191
<HintPath>..\Lib\Unity.TextMeshPro.dll</HintPath>
9292
</Reference>
@@ -108,7 +108,10 @@
108108
<Compile Include="APITestMain.cs" />
109109
<Compile Include="Commands\AddUI.cs" />
110110
<Compile Include="Properties\AssemblyInfo.cs" />
111+
<Compile Include="UI\Elements\ProfilePictureElement.cs" />
112+
<Compile Include="UI\Elements\HelloWorldElement.cs" />
111113
<Compile Include="UI\PersonalDisplayBuilder.cs" />
114+
<Compile Include="UI\PersonalElementDisplay.cs" />
112115
</ItemGroup>
113116
<ItemGroup>
114117
<ProjectReference Include="..\NotAnAPI\NotAnAPI.csproj">

APITest/Commands/AddUI.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using APITest.UI;
2+
using APITest.UI.Elements;
23
using CommandSystem;
34
using Exiled.API.Features;
45
using MEC;
@@ -26,14 +27,25 @@ public class AddUI : NotCommands
2627

2728
public override string[] GetPerms() => null;
2829

29-
public override bool Function(string[] args, ICommandSender sender, out string result)
30+
public override bool GetRequirePlayer() => true;
31+
32+
public override bool PlayerBasedFunction(Player player, string[] args, out string result)
3033
{
31-
Player player = Player.Get(sender);
34+
if (!TryGetArgument(args, 1, out string arg1))
35+
{
36+
PersonalDisplayBuilder display1 = new PersonalDisplayBuilder(StringBuilderPool.Shared.Rent());
37+
38+
player.GameObject.AddComponent<UIManager>()._mainDisplay = display1;
3239

33-
PersonalDisplayBuilder display = new PersonalDisplayBuilder(StringBuilderPool.Shared.Rent());
40+
result = "PersonalDisplay enabled!";
41+
return true;
42+
}
43+
44+
PersonalElementDisplay display = new PersonalElementDisplay(StringBuilderPool.Shared.Rent());
3445

3546
player.GameObject.AddComponent<UIManager>()._mainDisplay = display;
36-
result = $"Working.";
47+
48+
result = $"PersonalElement Enabled";
3749
return false;
3850
}
3951

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using NotAnAPI.Features.UI.API.Elements;
2+
using NotAnAPI.Features.UI.API.Enums;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using UnityEngine;
9+
10+
namespace APITest.UI.Elements
11+
{
12+
public class HelloWorldElement : Element
13+
{
14+
public override string Name { get; set; } = "Hello World";
15+
public override string Text { get; set; } = "Hello World";
16+
public override Vector2 Position { get; set; } = new Vector2(-500, 300);
17+
18+
public override TextSettings Settings { get; set; } = new()
19+
{
20+
Size = 60,
21+
};
22+
23+
public override UIScreenZone Zone { get; set; } = UIScreenZone.Center;
24+
public override UIType UI { get; set; } = UIType.Alive;
25+
26+
public override string OnRender()
27+
{
28+
Position = new Vector2(UnityEngine.Random.Range(0, 301), UnityEngine.Random.Range(0, 301));
29+
30+
return base.OnRender();
31+
}
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using NotAnAPI.Features.UI.API.Elements;
2+
using NotAnAPI.Features.UI.API.Enums;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using UnityEngine;
9+
10+
namespace APITest.UI.Elements
11+
{
12+
public class ProfilePictureElement : Element
13+
{
14+
public override string Name { get; set; } = "Profile Picture";
15+
public override string Text { get; set; } = "PFP";
16+
public override Vector2 Position { get; set; } = new Vector2(-900, 300);
17+
18+
public override TextSettings Settings { get; set; } = new()
19+
{
20+
Size = 1.5f,
21+
};
22+
23+
public override UIScreenZone Zone { get; set; } = UIScreenZone.Center;
24+
public override UIType UI { get; set; } = UIType.Both;
25+
26+
public override string OnRender()
27+
{
28+
Position = new Vector2(UnityEngine.Random.Range(0, 501), UnityEngine.Random.Range(0, 501));
29+
30+
return base.OnRender();
31+
}
32+
}
33+
}

APITest/UI/PersonalElementDisplay.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using APITest.UI.Elements;
2+
using NorthwoodLib.Pools;
3+
using NotAnAPI.Features.UI.API.Abstract;
4+
using NotAnAPI.Features.UI.API.Elements;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace APITest.UI
12+
{
13+
public class PersonalElementDisplay : GameElementDisplay
14+
{
15+
private readonly StringBuilder _builder;
16+
17+
public PersonalElementDisplay(StringBuilder builder) : base(builder)
18+
{
19+
_builder = builder;
20+
}
21+
22+
~PersonalElementDisplay() => StringBuilderPool.Shared.Return(_builder);
23+
24+
public override List<Element> Elements { get; set; } = new()
25+
{
26+
//Alive Elements
27+
new HelloWorldElement(),
28+
29+
//Both
30+
new ProfilePictureElement(),
31+
};
32+
}
33+
}

Build/APITest.dll

-7 KB
Binary file not shown.

Build/NotAnAPI.dll

-306 KB
Binary file not shown.

Lib/Assembly-CSharp-Publicized.dll

-2.45 MB
Binary file not shown.

Lib/Assembly-CSharp-firstpass.dll

-226 KB
Binary file not shown.

Lib/Assembly-CSharp.dll

-2.46 MB
Binary file not shown.

0 commit comments

Comments
 (0)