Skip to content

Commit 238eab5

Browse files
committed
feat: Mod Manifest Edit
- Added the ability to edit the mod.manifest with an option in the project dropdown menu - Updated the program version to 0.0.3 - Fixed bug with the File focus in the Table Editor never resetting.
1 parent fcc888a commit 238eab5

File tree

9 files changed

+363
-48
lines changed

9 files changed

+363
-48
lines changed

src/Studio.App/Warbox/Warbox.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<OutputType>WinExe</OutputType>
55
<TargetFramework>net8.0-windows</TargetFramework>
66
<Authors>Vawser</Authors>
7-
<Version>0.0.1</Version>
7+
<Version>0.0.3</Version>
88
<ApplicationIcon>icon.ico</ApplicationIcon>
9-
<PackageVersion>0.0.1</PackageVersion>
10-
<AssemblyVersion>0.0.1</AssemblyVersion>
9+
<PackageVersion>0.0.3</PackageVersion>
10+
<AssemblyVersion>0.0.3</AssemblyVersion>
1111
<ApplicationManifest>app.manifest</ApplicationManifest>
1212
<LangVersion>12</LangVersion>
1313
<IsPackable>false</IsPackable>

src/Studio.App/Warbox/imgui.ini

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ Size=619,324
16731673
Collapsed=0
16741674

16751675
[Window][Project Creation]
1676-
Pos=897,491
1676+
Pos=174,289
16771677
Size=603,149
16781678
Collapsed=0
16791679

@@ -2028,19 +2028,19 @@ DockId=0x00000129,0
20282028

20292029
[Window][Files##textFileView]
20302030
Pos=0,40
2031-
Size=451,1329
2031+
Size=2560,1329
20322032
Collapsed=0
20332033
DockId=0x0000012E,0
20342034

20352035
[Window][Rows##textRowView]
2036-
Pos=453,40
2037-
Size=1001,1329
2036+
Pos=0,0
2037+
Size=100,100
20382038
Collapsed=0
20392039
DockId=0x0000012C,0
20402040

20412041
[Window][Entries##textCellView]
2042-
Pos=1456,40
2043-
Size=1104,1329
2042+
Pos=0,0
2043+
Size=100,100
20442044
Collapsed=0
20452045
DockId=0x0000012D,0
20462046

@@ -2088,13 +2088,13 @@ DockId=0x00000135,0
20882088

20892089
[Window][Properties##tablePropertyView]
20902090
Pos=1088,40
2091-
Size=1040,1329
2091+
Size=977,1329
20922092
Collapsed=0
20932093
DockId=0x00000133,0
20942094

20952095
[Window][Tools##tableToolsView]
2096-
Pos=2130,40
2097-
Size=430,1329
2096+
Pos=2067,40
2097+
Size=493,1329
20982098
Collapsed=0
20992099
DockId=0x00000137,0
21002100

@@ -2108,6 +2108,11 @@ Pos=1178,451
21082108
Size=602,162
21092109
Collapsed=0
21102110

2111+
[Window][Mod Manifest]
2112+
Pos=816,291
2113+
Size=590,268
2114+
Collapsed=0
2115+
21112116
[Table][0x26F51C17,3]
21122117
Column 0 Weight=1.0000
21132118
Column 1 Weight=1.0000
@@ -4120,16 +4125,16 @@ DockSpace ID=0x746B0339 Pos=0,40 Size=2560,1329 Split=X Selected
41204125
DockNode ID=0x00000112 Parent=0x00000111 SizeRef=835,1329 Selected=0x6DCE2B48
41214126
DockNode ID=0x00000113 Parent=0x00000111 SizeRef=1375,1329 Selected=0x8A4A5361
41224127
DockSpace ID=0x89C13D1D Window=0x83EB0717 Pos=0,40 Size=2560,1329 Split=X Selected=0x729AD3A6
4123-
DockNode ID=0x00000136 Parent=0x89C13D1D SizeRef=2128,1329 Split=X
4128+
DockNode ID=0x00000136 Parent=0x89C13D1D SizeRef=2065,1329 Split=X
41244129
DockNode ID=0x00000132 Parent=0x00000136 SizeRef=1086,1329 Split=X
41254130
DockNode ID=0x0000012A Parent=0x00000132 SizeRef=297,1329 Split=X Selected=0x729AD3A6
41264131
DockNode ID=0x00000134 Parent=0x0000012A SizeRef=405,1329 CentralNode=1 Selected=0x729AD3A6
41274132
DockNode ID=0x00000135 Parent=0x0000012A SizeRef=679,1329 Selected=0xEE506E54
41284133
DockNode ID=0x0000012B Parent=0x00000132 SizeRef=2261,1329 Split=X Selected=0x476D9CF4
41294134
DockNode ID=0x00000130 Parent=0x0000012B SizeRef=775,1329 Selected=0x476D9CF4
41304135
DockNode ID=0x00000131 Parent=0x0000012B SizeRef=1484,1329 Selected=0xE120521B
4131-
DockNode ID=0x00000133 Parent=0x00000136 SizeRef=1040,1329 Selected=0x30E57A84
4132-
DockNode ID=0x00000137 Parent=0x89C13D1D SizeRef=430,1329 Selected=0x9CCA0CB4
4136+
DockNode ID=0x00000133 Parent=0x00000136 SizeRef=977,1329 Selected=0x30E57A84
4137+
DockNode ID=0x00000137 Parent=0x89C13D1D SizeRef=493,1329 Selected=0x9CCA0CB4
41334138
DockSpace ID=0xA747ECD2 Pos=0,40 Size=2560,1329 Split=X
41344139
DockNode ID=0x000000FE Parent=0xA747ECD2 SizeRef=1946,1329 Split=X
41354140
DockNode ID=0x00000005 Parent=0x000000FE SizeRef=365,1329 Split=Y Selected=0x93373FAE
@@ -4166,7 +4171,7 @@ DockSpace ID=0xA747ECD2 Pos=0,40 Size=2560,1329 Split=X
41664171
DockNode ID=0x00000081 Parent=0x000000A7 SizeRef=402,533 Selected=0x7B3E482D
41674172
DockNode ID=0x000000FF Parent=0xA747ECD2 SizeRef=612,1329 Selected=0xED2A9248
41684173
DockSpace ID=0xA9009494 Pos=0,40 Size=2560,1329 CentralNode=1 Selected=0x7816B966
4169-
DockSpace ID=0xAEE10BF6 Window=0xD77BF10C Pos=0,20 Size=2560,1349 CentralNode=1 Selected=0xBD2C7209
4174+
DockSpace ID=0xAEE10BF6 Window=0xD77BF10C Pos=0,20 Size=2560,1349 CentralNode=1 Selected=0x887C8646
41704175
DockSpace ID=0xC9AF448A Pos=0,40 Size=2560,1329 Split=Y Selected=0x3842B150
41714176
DockNode ID=0x000000D8 Parent=0xC9AF448A SizeRef=2560,164 CentralNode=1 Selected=0x3842B150
41724177
DockNode ID=0x000000D9 Parent=0xC9AF448A SizeRef=2560,1163 Selected=0x68196DB2
Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
using ImGuiNET;
2+
using StudioCore.Core.Project;
3+
using StudioCore.Interface;
4+
using StudioCore.Platform;
5+
using StudioCore.Utilities;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.IO;
9+
using System.Linq;
10+
using System.Numerics;
11+
using System.Text;
12+
using System.Threading.Tasks;
13+
14+
namespace StudioCore.Core.Manifest;
15+
16+
public static class ManifestEditWindow
17+
{
18+
private static string _name = "";
19+
private static string _modid = "";
20+
private static string _description = "";
21+
private static string _author = "";
22+
private static string _version = "";
23+
private static string _created_on = "";
24+
private static string _modifies_level = "";
25+
private static bool _modifies_levelBool = false;
26+
private static string _dependencies = "";
27+
28+
private static bool MenuOpenState = false;
29+
30+
public static void ToggleMenuVisibility()
31+
{
32+
if(ManifestHandler.ManifestDocument != null)
33+
{
34+
MenuOpenState = !MenuOpenState;
35+
36+
var infoElement = ManifestHandler.ManifestDocument.Root.Element("info");
37+
38+
_name = infoElement.Element("name").Value;
39+
_modid = infoElement.Element("modid").Value;
40+
_description = infoElement.Element("description").Value;
41+
_author = infoElement.Element("author").Value;
42+
_version = infoElement.Element("version").Value;
43+
_created_on = infoElement.Element("created_on").Value;
44+
_modifies_level = infoElement.Element("modifies_level").Value;
45+
_dependencies = infoElement.Element("dependencies").Value;
46+
47+
if(_modifies_level == "true")
48+
{
49+
_modifies_levelBool = true;
50+
}
51+
}
52+
}
53+
54+
public static void Display()
55+
{
56+
var scale = Warbox.GetUIScale();
57+
58+
if (!MenuOpenState)
59+
return;
60+
61+
if (ManifestHandler.ManifestDocument == null)
62+
return;
63+
64+
ImGui.SetNextWindowSize(new Vector2(600.0f, 400.0f) * scale, ImGuiCond.FirstUseEver);
65+
ImGui.PushStyleColor(ImGuiCol.WindowBg, CFG.Current.Imgui_Moveable_MainBg);
66+
ImGui.PushStyleColor(ImGuiCol.TitleBg, CFG.Current.Imgui_Moveable_TitleBg);
67+
ImGui.PushStyleColor(ImGuiCol.TitleBgActive, CFG.Current.Imgui_Moveable_TitleBg_Active);
68+
ImGui.PushStyleColor(ImGuiCol.ChildBg, CFG.Current.Imgui_Moveable_ChildBg);
69+
ImGui.PushStyleColor(ImGuiCol.Text, CFG.Current.ImGui_Default_Text_Color);
70+
ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(10.0f, 10.0f) * scale);
71+
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(5.0f, 5.0f) * scale);
72+
ImGui.PushStyleVar(ImGuiStyleVar.IndentSpacing, 20.0f * scale);
73+
74+
var flags = ImGuiWindowFlags.NoDocking | ImGuiWindowFlags.NoResize;
75+
76+
if (ImGui.Begin("Mod Manifest", ref MenuOpenState, flags))
77+
{
78+
DisplayModManifestEdit();
79+
}
80+
81+
ImGui.End();
82+
83+
ImGui.PopStyleVar(3);
84+
ImGui.PopStyleColor(5);
85+
}
86+
87+
public static void DisplayModManifestEdit()
88+
{
89+
var width = ImGui.GetWindowWidth();
90+
var flags = ImGuiTableFlags.SizingFixedFit;
91+
92+
var infoElement = ManifestHandler.ManifestDocument.Root.Element("info");
93+
94+
if (ImGui.BeginTable($"ModManifestTable", 2, flags))
95+
{
96+
ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.WidthFixed, 150);
97+
ImGui.TableSetupColumn("Input", ImGuiTableColumnFlags.WidthFixed, 400);
98+
99+
// Name
100+
ImGui.TableNextRow();
101+
102+
ImGui.TableSetColumnIndex(0);
103+
ImGui.AlignTextToFramePadding();
104+
105+
ImGui.Text("Name");
106+
UIHelper.ShowHoverTooltip("The name of the mod.");
107+
108+
ImGui.TableSetColumnIndex(1);
109+
110+
ImGui.AlignTextToFramePadding();
111+
112+
ImGui.SetNextItemWidth(400);
113+
if(ImGui.InputText("##input_name", ref _name, 255))
114+
{
115+
infoElement.Element("name").Value = _name;
116+
}
117+
118+
// Mod ID
119+
ImGui.TableNextRow();
120+
121+
ImGui.TableSetColumnIndex(0);
122+
ImGui.AlignTextToFramePadding();
123+
124+
ImGui.Text("Mod ID");
125+
UIHelper.ShowHoverTooltip("The name of the mod when appending to files for patching purposes.");
126+
127+
ImGui.TableSetColumnIndex(1);
128+
129+
ImGui.AlignTextToFramePadding();
130+
131+
ImGui.SetNextItemWidth(400);
132+
if (ImGui.InputText("##input_modid", ref _modid, 255))
133+
{
134+
infoElement.Element("modid").Value = _modid;
135+
}
136+
137+
// Description
138+
ImGui.TableNextRow();
139+
140+
ImGui.TableSetColumnIndex(0);
141+
ImGui.AlignTextToFramePadding();
142+
143+
ImGui.Text("Description");
144+
UIHelper.ShowHoverTooltip("A description of what the mod does.");
145+
146+
ImGui.TableSetColumnIndex(1);
147+
148+
ImGui.AlignTextToFramePadding();
149+
150+
ImGui.SetNextItemWidth(400);
151+
if (ImGui.InputText("##input_description", ref _description, 255))
152+
{
153+
infoElement.Element("description").Value = _description;
154+
}
155+
156+
// Author
157+
ImGui.TableNextRow();
158+
159+
ImGui.TableSetColumnIndex(0);
160+
ImGui.AlignTextToFramePadding();
161+
162+
ImGui.Text("Author");
163+
UIHelper.ShowHoverTooltip("The names of the author or authors of the mod.");
164+
165+
ImGui.TableSetColumnIndex(1);
166+
167+
ImGui.AlignTextToFramePadding();
168+
169+
ImGui.SetNextItemWidth(400);
170+
if (ImGui.InputText("##input_author", ref _author, 255))
171+
{
172+
infoElement.Element("author").Value = _author;
173+
}
174+
175+
// Version
176+
ImGui.TableNextRow();
177+
178+
ImGui.TableSetColumnIndex(0);
179+
ImGui.AlignTextToFramePadding();
180+
181+
ImGui.Text("Version");
182+
UIHelper.ShowHoverTooltip("The version of the mod these files represent.");
183+
184+
ImGui.TableSetColumnIndex(1);
185+
186+
ImGui.AlignTextToFramePadding();
187+
188+
ImGui.SetNextItemWidth(400);
189+
if (ImGui.InputText("##input_version", ref _version, 255))
190+
{
191+
infoElement.Element("version").Value = _version;
192+
}
193+
194+
// Created On
195+
ImGui.TableNextRow();
196+
197+
ImGui.TableSetColumnIndex(0);
198+
ImGui.AlignTextToFramePadding();
199+
200+
ImGui.Text("Created On");
201+
UIHelper.ShowHoverTooltip("The date on which this mod was created.");
202+
203+
ImGui.TableSetColumnIndex(1);
204+
205+
ImGui.AlignTextToFramePadding();
206+
207+
ImGui.SetNextItemWidth(400);
208+
if (ImGui.InputText("##input_created_on", ref _created_on, 255))
209+
{
210+
infoElement.Element("created_on").Value = _created_on;
211+
}
212+
213+
// Modifies Level
214+
ImGui.TableNextRow();
215+
216+
ImGui.TableSetColumnIndex(0);
217+
ImGui.AlignTextToFramePadding();
218+
219+
ImGui.Text("Modifies Map");
220+
UIHelper.ShowHoverTooltip("Whether this mod affects any of the maps.");
221+
222+
ImGui.TableSetColumnIndex(1);
223+
224+
ImGui.AlignTextToFramePadding();
225+
226+
ImGui.SetNextItemWidth(400);
227+
if (ImGui.Checkbox("##input_modifies_level", ref _modifies_levelBool))
228+
{
229+
if(_modifies_levelBool)
230+
{
231+
infoElement.Element("modifies_level").Value = "true";
232+
}
233+
else
234+
{
235+
infoElement.Element("modifies_level").Value = "false";
236+
}
237+
}
238+
239+
// Dependencies
240+
ImGui.TableNextRow();
241+
242+
ImGui.TableSetColumnIndex(0);
243+
ImGui.AlignTextToFramePadding();
244+
245+
ImGui.Text("Dependencies");
246+
UIHelper.ShowHoverTooltip("Any mod dependencies this mod has.");
247+
248+
ImGui.TableSetColumnIndex(1);
249+
250+
ImGui.AlignTextToFramePadding();
251+
252+
ImGui.SetNextItemWidth(400);
253+
if (ImGui.InputText("##input_dependencies", ref _dependencies, 255))
254+
{
255+
infoElement.Element("dependencies").Value = _dependencies;
256+
}
257+
258+
// Edit
259+
if (ImGui.Button("Commit Edits", new Vector2(400, 24)))
260+
{
261+
ManifestHandler.WriteManifest();
262+
263+
ToggleMenuVisibility();
264+
}
265+
266+
ImGui.EndTable();
267+
}
268+
}
269+
}

0 commit comments

Comments
 (0)