Added GUI.* to Lua docs

This commit is contained in:
EvilFactory
2024-08-25 16:49:45 -03:00
parent fd29b395a7
commit 4e9ef97fac
33 changed files with 281 additions and 11 deletions

View File

@@ -29,9 +29,11 @@ After downloading the zip file, extract the contents to the `Refs` folder in pro
./Refs
----/Linux/Barotrauma.dll
----/Linux/DedicatedServer.dll
----/Linux/BarotraumaCore.dll
----/Windows/Barotrauma.dll
----/Windows/DedicatedServer.dll
...
----/Windows/BarotraumaCore.dll
...other files
```
### 4. Setup the project

View File

@@ -17,7 +17,7 @@ Source files inside the CSharp/Server and CSharp/Client folders will only be com
____
`<mod_root>/CSharp/Shared/ExampleMod.cs`
```csharp
```cs
using System;
using Barotrauma;

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.CreditsPlayer
]]
-- @code GUI.CreditsPlayer
-- @pragma nostrip
local CreditsPlayer = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUI
]]
-- @code GUI
-- @pragma nostrip
local GUI = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUIButton
]]
-- @code GUI.Button
-- @pragma nostrip
local GUIButton = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUICanvas
]]
-- @code GUI.Canvas
-- @pragma nostrip
local GUICanvas = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUIColorPicker
]]
-- @code GUI.ColorPicker
-- @pragma nostrip
local GUIColorPicker = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUIComponent
]]
-- @code GUI.Component
-- @pragma nostrip
local GUIComponent = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUICustomComponent
]]
-- @code GUI.CustomComponent
-- @pragma nostrip
local GUICustomComponent = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUIDragHandle
]]
-- @code GUI.DragHandle
-- @pragma nostrip
local GUIDragHandle = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUIDropDown
]]
-- @code GUI.DropDown
-- @pragma nostrip
local GUIDropDown = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUIFrame
]]
-- @code GUI.Frame
-- @pragma nostrip
local GUIFrame = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUIImage
]]
-- @code GUI.Image
-- @pragma nostrip
local GUIImage = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUILayoutGroup
]]
-- @code GUI.LayoutGroup
-- @pragma nostrip
local GUILayoutGroup = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUIListBox
]]
-- @code GUI.ListBox
-- @pragma nostrip
local GUIListBox = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUIMessageBox
]]
-- @code GUI.MessageBox
-- @pragma nostrip
local GUIMessageBox = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUINumberInput
]]
-- @code GUI.NumberInput
-- @pragma nostrip
local GUINumberInput = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUIProgressBar
]]
-- @code GUI.ProgressBar
-- @pragma nostrip
local GUIProgressBar = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUIScissorComponent
]]
-- @code GUI.ScissorComponent
-- @pragma nostrip
local GUIScissorComponent = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUIScrollBar
]]
-- @code GUI.ScrollBar
-- @pragma nostrip
local GUIScrollBar = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUIStyle
]]
-- @code GUI.Style
-- @pragma nostrip
local GUIStyle = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUITextBlock
]]
-- @code GUI.TextBlock
-- @pragma nostrip
local GUITextBlock = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUITextBox
]]
-- @code GUI.TextBox
-- @pragma nostrip
local GUITextBox = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.GUITickBox
]]
-- @code GUI.TickBox
-- @pragma nostrip
local GUITickBox = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.Graph
]]
-- @code GUI.Graph
-- @pragma nostrip
local Graph = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.RectTransform
]]
-- @code GUI.RectTransform
-- @pragma nostrip
local RectTransform = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.Screen
]]
-- @code GUI.Screen
-- @pragma nostrip
local Screen = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.SerializableEntityEditor
]]
-- @code GUI.SerializableEntityEditor
-- @pragma nostrip
local SerializableEntityEditor = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.SlideshowPlayer
]]
-- @code GUI.SlideshowPlayer
-- @pragma nostrip
local SlideshowPlayer = {}

View File

@@ -0,0 +1,8 @@
-- luacheck: ignore 111
--[[--
Barotrauma.VideoPlayer
]]
-- @code GUI.VideoPlayer
-- @pragma nostrip
local VideoPlayer = {}

View File

@@ -181,9 +181,9 @@ function character.death(character) end
-- @realm shared
function character.applyAffliction(character, limbHealth, newAffliction, allowStacking) end
--- Gets gets called every time an attack damage.
--- Gets gets called every time a character gets damaged by an attack.
-- @realm shared
function character.applyDamage(character, attackResult, hitLimb, allowStacking) end
function character.applyDamage(characterHealth, attackResult, hitLimb, allowStacking) end
--- Gets called every time an affliction updates.

View File

@@ -528,14 +528,16 @@ local {type.Name} = {{}}".ReplaceLineEndings("\n");
File.WriteAllText(outFile, sb.ToString());
}
public static void GenerateEnum(Type enumType, string outFile, string realm = "shared")
public static void GenerateEnum(Type enumType, string outFile, string categoryName = null, string realm = "shared")
{
StringBuilder sb = new StringBuilder();
categoryName = categoryName ?? enumType.Name;
sb.AppendLine($@"--[[--
{enumType.Name} enum.
]]
-- @enum {enumType.Name}");
-- @enum {categoryName}");
sb.AppendLine();
@@ -546,9 +548,9 @@ local {type.Name} = {{}}".ReplaceLineEndings("\n");
if (fields[i].Name.Equals("value__")) { continue; }
sb.AppendLine("---");
sb.AppendLine($"-- {enumType.Name}.{fields[i].Name} = {fields[i].GetRawConstantValue()}");
sb.AppendLine($"-- {categoryName}.{fields[i].Name} = {fields[i].GetRawConstantValue()}");
sb.AppendLine($"-- @realm {realm}");
sb.AppendLine($"-- @number {enumType.Name}.{fields[i].Name}");
sb.AppendLine($"-- @number {categoryName}.{fields[i].Name}");
sb.AppendLine();
}

View File

@@ -10,6 +10,10 @@ namespace LuaDocsGenerator
private static string generatedDir = "";
private static string baseLuaDir = "";
private static void GenerateDocs(Type type, string file, string? categoryName = null, string realm = "shared")
{
DocsGenerator.GenerateDocs(type, $"{baseLuaDir}/{file}", $"{generatedDir}/{file}", categoryName, realm);
}
private static void GenerateDocs<T>(string file, string? categoryName = null, string realm = "shared")
{
DocsGenerator.GenerateDocs(typeof(T), $"{baseLuaDir}/{file}", $"{generatedDir}/{file}", categoryName, realm);
@@ -24,11 +28,14 @@ namespace LuaDocsGenerator
{
DocsGenerator.GenerateDocs(clientType, serverType, $"{baseLuaDir}/{file}", $"{generatedDir}/{file}", categoryName);
}
private static void GenerateEnum<T>(string file, string realm = "shared")
private static void GenerateEnum<T>(string file, string categoryName = null, string realm = "shared")
{
DocsGenerator.GenerateEnum(typeof(T), $"{generatedDir}/{file}", realm);
DocsGenerator.GenerateEnum(typeof(T), $"{generatedDir}/{file}", categoryName, realm);
}
private static void GenerateEnum(Type type, string file, string categoryName = null, string realm = "shared")
{
DocsGenerator.GenerateEnum(type, $"{generatedDir}/{file}", categoryName, realm);
}
static void Main(string[] args)
{
@@ -91,6 +98,41 @@ namespace LuaDocsGenerator
GenerateDocs<BarotraumaClient::Barotrauma.Networking.IReadMessage, BarotraumaServer::Barotrauma.Networking.IReadMessage>("IReadMessage.lua");
GenerateDocs<BarotraumaClient::Barotrauma.Networking.IWriteMessage, BarotraumaServer::Barotrauma.Networking.IWriteMessage>("IWriteMessage.lua");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUI), "GUI.lua", "GUI", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUIStyle), "GUIStyle.lua", "GUI.Style", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUIComponent), "GUIComponent.lua", "GUI.Component", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.RectTransform), "RectTransform.lua", "GUI.RectTransform", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUILayoutGroup), "GUILayoutGroup.lua", "GUI.LayoutGroup", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUIButton),"GUIButton.lua", "GUI.Button", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUITextBox),"GUITextBox.lua", "GUI.TextBox", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUICanvas),"GUICanvas.lua", "GUI.Canvas", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUIFrame),"GUIFrame.lua", "GUI.Frame", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUITextBlock),"GUITextBlock.lua", "GUI.TextBlock", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUITickBox),"GUITickBox.lua", "GUI.TickBox", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUIImage),"GUIImage.lua", "GUI.Image", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUIListBox),"GUIListBox.lua", "GUI.ListBox", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUIScrollBar),"GUIScrollBar.lua", "GUI.ScrollBar", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUIDropDown),"GUIDropDown.lua", "GUI.DropDown", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUINumberInput),"GUINumberInput.lua", "GUI.NumberInput", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUIMessageBox),"GUIMessageBox.lua", "GUI.MessageBox", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUIColorPicker),"GUIColorPicker.lua", "GUI.ColorPicker", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUIProgressBar),"GUIProgressBar.lua", "GUI.ProgressBar", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUICustomComponent),"GUICustomComponent.lua", "GUI.CustomComponent", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUIScissorComponent),"GUIScissorComponent.lua", "GUI.ScissorComponent", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.VideoPlayer),"VideoPlayer.lua", "GUI.VideoPlayer", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.Graph),"Graph.lua", "GUI.Graph", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.SerializableEntityEditor),"SerializableEntityEditor.lua", "GUI.SerializableEntityEditor", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.SlideshowPlayer),"SlideshowPlayer.lua", "GUI.SlideshowPlayer", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.CreditsPlayer),"CreditsPlayer.lua", "GUI.CreditsPlayer", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.GUIDragHandle),"GUIDragHandle.lua", "GUI.DragHandle", "client");
GenerateDocs(typeof(BarotraumaClient::Barotrauma.Screen),"Screen.lua", "GUI.Screen", "client");
GenerateEnum<BarotraumaClient::Barotrauma.Anchor>("Anchor.lua", "GUI.Anchor", "client");
GenerateEnum<BarotraumaClient::Barotrauma.Pivot>("Pivot.lua", "GUI.Pivot", "client");
GenerateEnum<BarotraumaClient::Barotrauma.GUISoundType>("GUISoundType.lua", "GUI.SoundType", "client");
GenerateEnum<BarotraumaClient::Barotrauma.CursorState>("CursorState.lua", "GUI.CursorState", "client");
GenerateEnum<Barotrauma.Alignment>("Alignment.lua", "GUI.Alignment", "client");
GenerateEnum<BarotraumaClient.Barotrauma.CauseOfDeathType>("CauseOfDeathType.lua");
GenerateEnum<BarotraumaClient.Barotrauma.CharacterTeamType>("CharacterTeamType.lua");
GenerateEnum<BarotraumaClient.Barotrauma.Networking.ClientPermissions>("ClientPermissions.lua");