Skip to content

Commit f5a385c

Browse files
committed
Add project files.
1 parent 82b5e98 commit f5a385c

File tree

6 files changed

+183
-0
lines changed

6 files changed

+183
-0
lines changed

StarMap-ExampleMods.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StarMap.SimpleMod", "StarMap.SimpleMod\StarMap.SimpleMod.csproj", "{E768970D-A7FD-4D63-AE39-39836983ACCC}"
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+
{E768970D-A7FD-4D63-AE39-39836983ACCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E768970D-A7FD-4D63-AE39-39836983ACCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E768970D-A7FD-4D63-AE39-39836983ACCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E768970D-A7FD-4D63-AE39-39836983ACCC}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

StarMap-ExampleMods.sln.bak

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+

2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StarMap.SimpleMod", "StarMap-ExampleMods\StarMap.SimpleMod.csproj", "{E768970D-A7FD-4D63-AE39-39836983ACCC}"
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+
{E768970D-A7FD-4D63-AE39-39836983ACCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E768970D-A7FD-4D63-AE39-39836983ACCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E768970D-A7FD-4D63-AE39-39836983ACCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E768970D-A7FD-4D63-AE39-39836983ACCC}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

StarMap.SimpleMod/Patcher.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Brutal.GlfwApi;
2+
using Brutal.ImGuiApi;
3+
using Brutal.Numerics;
4+
using HarmonyLib;
5+
using KSA;
6+
using System.Reflection;
7+
8+
namespace StarMap.SimpleExampleMod
9+
{
10+
[HarmonyPatch]
11+
internal static class Patcher
12+
{
13+
private static Harmony? _harmony = new Harmony("StarMap.SimpleMod");
14+
15+
public static void Patch()
16+
{
17+
_harmony?.PatchAll();
18+
}
19+
20+
public static void Unload()
21+
{
22+
_harmony?.UnpatchAll(_harmony.Id);
23+
_harmony = null;
24+
}
25+
}
26+
}

StarMap.SimpleMod/SimpleMod.cs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using KSA;
2+
using Brutal.ImGuiApi;
3+
using StarMap.Types;
4+
using Brutal.ImGuiApi.Extensions;
5+
using System;
6+
using Brutal.Numerics;
7+
using Brutal.GlfwApi;
8+
9+
namespace StarMap.SimpleExampleMod
10+
{
11+
public class SimpleMod : IStarMapMod
12+
{
13+
public bool ImmediateUnload => false;
14+
15+
public void OnFullyLoaded()
16+
{
17+
Patcher.Patch();
18+
SimpleWindow.Create();
19+
20+
}
21+
22+
public void OnImmediatLoad()
23+
{
24+
}
25+
26+
public void Unload()
27+
{
28+
Patcher.Unload();
29+
}
30+
internal class SimpleWindow : Popup
31+
{
32+
private float _width;
33+
private readonly IPopupWidget<SimpleWindow>[] _widgetMatrix;
34+
private readonly PopupToken[] _textList;
35+
36+
private string _text = "Hello world!";
37+
38+
public SimpleWindow()
39+
{
40+
this._widgetMatrix = new IPopupWidget<SimpleWindow>[]
41+
{
42+
Popup.PopupButtonOkay,
43+
};
44+
this._textList = StringTokenParser.Parse(this._text).ToArray();
45+
}
46+
47+
public static SimpleWindow Create() { return new SimpleWindow(); }
48+
49+
protected override void OnDrawUi()
50+
{
51+
ImGui.OpenPopup("SimpleMod", ImGuiPopupFlags.None);
52+
ImGui.BeginPopupModal("SimpleMod", ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.Popup | ImGuiWindowFlags.Modal);
53+
GlfwWindow window = Program.GetWindow();
54+
int2 size = window.Size;
55+
float2 @float = Brutal.Numerics.float2.Unpack(size, Unpack.Float.Cast);
56+
this._width = float.Clamp(@float.X * 0.85f, 600f * GameSettings.GetInterfaceScale(), 2048f * GameSettings.GetInterfaceScale());
57+
float2 float2 = new float2(this._width, -1f);
58+
ImGui.SetWindowSize(float2, ImGuiCond.None);
59+
ImGuiHelper.SetCurrentWindowToCenter(ImGuiCond.Always);
60+
PopupToken.Draw(this._textList);
61+
ImGui.Separator();
62+
Popup.DrawUi<SimpleWindow>(this, this._widgetMatrix);
63+
ImGui.EndPopup();
64+
}
65+
}
66+
}
67+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<RootNamespace>StarMap.SimpleMod</RootNamespace>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Lib.Harmony" Version="2.4.1" />
12+
<PackageReference Include="StarMap.API" Version="0.0.2" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="mod.toml">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
</ItemGroup>
20+
21+
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
22+
<Reference Include="..\..\Import\KSA.dll">
23+
<ExcludeAssets>runtime</ExcludeAssets>
24+
</Reference>
25+
<Reference Include="..\..\Import\Brutal.ImGui.dll">
26+
<ExcludeAssets>runtime</ExcludeAssets>
27+
</Reference>
28+
<Reference Include="..\..\Import\Brutal.ImGui.Extensions.dll">
29+
<ExcludeAssets>runtime</ExcludeAssets>
30+
</Reference>
31+
<Reference Include="..\..\Import\Brutal.Core.Numerics.dll">
32+
<ExcludeAssets>runtime</ExcludeAssets>
33+
</Reference>
34+
<Reference Include="..\..\Import\Brutal.Glfw.dll">
35+
<ExcludeAssets>runtime</ExcludeAssets>
36+
</Reference>
37+
</ItemGroup>
38+
39+
<ItemGroup Condition="'$(Configuration)' != 'Debug'">
40+
<PackageReference Include="StarMap.KSA.Dummy" Version="1.0.4">
41+
<ExcludeAssets>runtime</ExcludeAssets>
42+
</PackageReference>
43+
</ItemGroup>
44+
45+
</Project>

StarMap.SimpleMod/mod.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name = "StarMap.SimpleMod"

0 commit comments

Comments
 (0)