more GUI stuff
This commit is contained in:
@@ -16,10 +16,20 @@ namespace Barotrauma
|
||||
env = _env;
|
||||
|
||||
RectTransform = UserData.CreateStatic<RectTransform>();
|
||||
GUILayoutGroup = UserData.CreateStatic<GUILayoutGroup>();
|
||||
GUIButton = UserData.CreateStatic<GUIButton>();
|
||||
GUITextBox = UserData.CreateStatic<GUITextBox>();
|
||||
LayoutGroup = UserData.CreateStatic<GUILayoutGroup>();
|
||||
Button = UserData.CreateStatic<GUIButton>();
|
||||
TextBox = UserData.CreateStatic<GUITextBox>();
|
||||
Canvas = UserData.CreateStatic<GUICanvas>();
|
||||
Frame = UserData.CreateStatic<GUIFrame>();
|
||||
TextBlock = UserData.CreateStatic<GUITextBlock>();
|
||||
TickBox = UserData.CreateStatic<GUITickBox>();
|
||||
Image = UserData.CreateStatic<GUIImage>();
|
||||
ListBox = UserData.CreateStatic<GUIListBox>();
|
||||
|
||||
Anchor = UserData.CreateStatic<Anchor>();
|
||||
Alignment = UserData.CreateStatic<Alignment>();
|
||||
Pivot = UserData.CreateStatic<Pivot>();
|
||||
|
||||
}
|
||||
|
||||
public ChatBox ChatBox
|
||||
@@ -31,10 +41,20 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
public static object RectTransform;
|
||||
public static object GUILayoutGroup;
|
||||
public static object GUIButton;
|
||||
public static object GUITextBox;
|
||||
public static object LayoutGroup;
|
||||
public static object Button;
|
||||
public static object TextBox;
|
||||
public static object Canvas;
|
||||
public static object Frame;
|
||||
public static object TextBlock;
|
||||
public static object TickBox;
|
||||
public static object Image;
|
||||
public static object ListBox;
|
||||
|
||||
public static object Pivot;
|
||||
public static object Anchor;
|
||||
public static object Alignment;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,19 @@ namespace Barotrauma
|
||||
RegisterAction<Character>();
|
||||
RegisterAction<Entity>();
|
||||
RegisterAction();
|
||||
|
||||
|
||||
#if CLIENT
|
||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(GUIButton.OnClickedHandler), v =>
|
||||
{
|
||||
|
||||
var function = v.Function;
|
||||
return (GUIButton.OnClickedHandler)((GUIButton a, object b) => new LuaResult(function.Call(a, b)).Bool());
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public static void RegisterAction<T>()
|
||||
{
|
||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action<T>), v =>
|
||||
@@ -27,8 +38,6 @@ namespace Barotrauma
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void RegisterAction()
|
||||
{
|
||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action), v =>
|
||||
@@ -37,5 +46,7 @@ namespace Barotrauma
|
||||
return (Action)(() => function.Call());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@ using System.Linq;
|
||||
using MoonSharp.Interpreter.Interop;
|
||||
using System.Reflection;
|
||||
|
||||
#if CLIENT
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
#endif
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class LuaSetup
|
||||
@@ -219,6 +223,8 @@ namespace Barotrauma
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
hook.Call("stop", new object[] { });
|
||||
|
||||
hook = new LuaHook(null);
|
||||
game = new LuaGame(null);
|
||||
networking = new LuaNetworking(null);
|
||||
@@ -229,6 +235,8 @@ namespace Barotrauma
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Stop();
|
||||
|
||||
luaSetup = this;
|
||||
|
||||
PrintMessage("Lua!");
|
||||
@@ -241,7 +249,6 @@ namespace Barotrauma
|
||||
UserData.RegisterType<TraitorMessageType>();
|
||||
UserData.RegisterType<JobPrefab>();
|
||||
UserData.RegisterType<Job>();
|
||||
UserData.RegisterType<Rectangle>();
|
||||
UserData.RegisterType<Point>();
|
||||
UserData.RegisterType<Level.InterestingPosition>();
|
||||
UserData.RegisterType<Level.PositionType>();
|
||||
@@ -337,6 +344,7 @@ namespace Barotrauma
|
||||
AddCallMetaMember(UserData.RegisterType<Signal>());
|
||||
AddCallMetaMember(UserData.RegisterType<Color>());
|
||||
AddCallMetaMember(UserData.RegisterType<Point>());
|
||||
AddCallMetaMember(UserData.RegisterType<Rectangle>());
|
||||
AddCallMetaMember(UserData.RegisterType<SubmarineInfo>());
|
||||
|
||||
#if SERVER
|
||||
@@ -344,13 +352,24 @@ namespace Barotrauma
|
||||
#elif CLIENT
|
||||
UserData.RegisterType<LuaGUI>();
|
||||
UserData.RegisterType<ChatBox>();
|
||||
UserData.RegisterType<GUICanvas>();
|
||||
UserData.RegisterType<Anchor>();
|
||||
UserData.RegisterType<Alignment>();
|
||||
UserData.RegisterType<Pivot>();
|
||||
UserData.RegisterType<Texture2D>();
|
||||
|
||||
AddCallMetaMember(UserData.RegisterType<Sprite>());
|
||||
|
||||
AddCallMetaMember(UserData.RegisterType<GUILayoutGroup>());
|
||||
AddCallMetaMember(UserData.RegisterType<GUITextBox>());
|
||||
AddCallMetaMember(UserData.RegisterType<GUITextBlock>());
|
||||
AddCallMetaMember(UserData.RegisterType<GUIButton>());
|
||||
AddCallMetaMember(UserData.RegisterType<RectTransform>());
|
||||
AddCallMetaMember(UserData.RegisterType<GUIFrame>());
|
||||
AddCallMetaMember(UserData.RegisterType<GUITickBox>());
|
||||
AddCallMetaMember(UserData.RegisterType<GUICustomComponent>());
|
||||
AddCallMetaMember(UserData.RegisterType<GUIImage>());
|
||||
AddCallMetaMember(UserData.RegisterType<GUIListBox>());
|
||||
#endif
|
||||
lua = new Script(CoreModules.Preset_SoftSandbox);
|
||||
|
||||
@@ -416,11 +435,14 @@ namespace Barotrauma
|
||||
lua.Globals["ServerPacketHeader"] = UserData.CreateStatic<ServerPacketHeader>();
|
||||
lua.Globals["RandSync"] = UserData.CreateStatic<Rand.RandSync>();
|
||||
lua.Globals["SubmarineInfo"] = UserData.CreateStatic<SubmarineInfo>();
|
||||
lua.Globals["Rectangle"] = UserData.CreateStatic<Rectangle>();
|
||||
|
||||
#if SERVER
|
||||
|
||||
#elif CLIENT
|
||||
lua.Globals["GUI"] = new LuaGUI(this);
|
||||
lua.Globals["Sprite"] = UserData.CreateStatic<Sprite>();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user