even more GUI
This commit is contained in:
@@ -25,6 +25,9 @@ namespace Barotrauma
|
||||
TickBox = UserData.CreateStatic<GUITickBox>();
|
||||
Image = UserData.CreateStatic<GUIImage>();
|
||||
ListBox = UserData.CreateStatic<GUIListBox>();
|
||||
ScrollBar = UserData.CreateStatic<GUIScrollBar>();
|
||||
|
||||
Screen = UserData.CreateStatic<Screen>();
|
||||
|
||||
Anchor = UserData.CreateStatic<Anchor>();
|
||||
Alignment = UserData.CreateStatic<Alignment>();
|
||||
@@ -40,6 +43,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static object Screen;
|
||||
|
||||
public static object RectTransform;
|
||||
public static object LayoutGroup;
|
||||
public static object Button;
|
||||
@@ -50,6 +55,7 @@ namespace Barotrauma
|
||||
public static object TickBox;
|
||||
public static object Image;
|
||||
public static object ListBox;
|
||||
public static object ScrollBar;
|
||||
|
||||
public static object Pivot;
|
||||
public static object Anchor;
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlayerInput
|
||||
public class PlayerInput
|
||||
{
|
||||
static MouseState mouseState, oldMouseState;
|
||||
static MouseState latestMouseState; //the absolute latest state, do NOT use for player interaction
|
||||
@@ -502,6 +502,8 @@ namespace Barotrauma
|
||||
allowInput = true;
|
||||
}
|
||||
|
||||
GameMain.Lua.hook.Call("keyUpdate", new object[] { deltaTime });
|
||||
|
||||
oldMouseState = mouseState;
|
||||
mouseState = latestMouseState;
|
||||
UpdateVariable();
|
||||
|
||||
@@ -92,6 +92,7 @@ namespace Barotrauma
|
||||
if (GameMain.GameSession != null) GameMain.GameSession.AddToGUIUpdateList();
|
||||
|
||||
Character.AddAllToGUIUpdateList();
|
||||
base.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||
|
||||
@@ -80,6 +80,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public GameScreen GameScreen
|
||||
{
|
||||
get
|
||||
{
|
||||
return GameMain.GameScreen;
|
||||
}
|
||||
}
|
||||
|
||||
public void OverrideTraitors(bool o)
|
||||
{
|
||||
overrideTraitors = o;
|
||||
|
||||
@@ -17,13 +17,24 @@ namespace Barotrauma
|
||||
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());
|
||||
return (GUIButton.OnClickedHandler)((GUIButton a, object b) => new LuaResult(LuaSetup.luaSetup.CallFunction(function, a, b)).Bool());
|
||||
});
|
||||
|
||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(GUITextBox.OnTextChangedHandler), v =>
|
||||
{
|
||||
var function = v.Function;
|
||||
return (GUITextBox.OnTextChangedHandler)((GUITextBox a, string b) => new LuaResult(LuaSetup.luaSetup.CallFunction(function, a, b)).Bool());
|
||||
});
|
||||
|
||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(GUITextBox.OnEnterHandler), v =>
|
||||
{
|
||||
var function = v.Function;
|
||||
return (GUITextBox.OnEnterHandler)((GUITextBox a, string b) => new LuaResult(LuaSetup.luaSetup.CallFunction(function, a, b)).Bool());
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ using System.Reflection;
|
||||
|
||||
#if CLIENT
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using EventInput;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
#endif
|
||||
|
||||
namespace Barotrauma
|
||||
@@ -165,13 +167,21 @@ namespace Barotrauma
|
||||
return DynValue.Nil;
|
||||
|
||||
return UserData.Create(o);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public object CallFunction(object function, object[] arguments)
|
||||
public object CallFunction(object function, params object[] arguments)
|
||||
{
|
||||
return lua.Call(function, arguments);
|
||||
try
|
||||
{
|
||||
return lua.Call(function, arguments);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
HandleLuaException(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetModulePaths(string[] str)
|
||||
@@ -235,6 +245,7 @@ namespace Barotrauma
|
||||
luaScriptLoader = null;
|
||||
|
||||
luaSetup = null;
|
||||
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
@@ -341,6 +352,10 @@ namespace Barotrauma
|
||||
UserData.RegisterType<Skill>();
|
||||
UserData.RegisterType<SkillPrefab>();
|
||||
|
||||
UserData.RegisterType<Screen>();
|
||||
UserData.RegisterType<GameScreen>();
|
||||
UserData.RegisterType<Camera>();
|
||||
|
||||
AddCallMetaMember(UserData.RegisterType<Vector2>());
|
||||
AddCallMetaMember(UserData.RegisterType<Vector3>());
|
||||
AddCallMetaMember(UserData.RegisterType<Vector4>());
|
||||
@@ -350,7 +365,7 @@ namespace Barotrauma
|
||||
AddCallMetaMember(UserData.RegisterType<Point>());
|
||||
AddCallMetaMember(UserData.RegisterType<Rectangle>());
|
||||
AddCallMetaMember(UserData.RegisterType<SubmarineInfo>());
|
||||
|
||||
|
||||
#if SERVER
|
||||
|
||||
#elif CLIENT
|
||||
@@ -361,9 +376,12 @@ namespace Barotrauma
|
||||
UserData.RegisterType<Alignment>();
|
||||
UserData.RegisterType<Pivot>();
|
||||
UserData.RegisterType<Texture2D>();
|
||||
UserData.RegisterType<KeyEventArgs>();
|
||||
UserData.RegisterType<Key>();
|
||||
UserData.RegisterType<Keys>();
|
||||
UserData.RegisterType<PlayerInput>();
|
||||
|
||||
AddCallMetaMember(UserData.RegisterType<Sprite>());
|
||||
|
||||
AddCallMetaMember(UserData.RegisterType<GUILayoutGroup>());
|
||||
AddCallMetaMember(UserData.RegisterType<GUITextBox>());
|
||||
AddCallMetaMember(UserData.RegisterType<GUITextBlock>());
|
||||
@@ -374,9 +392,12 @@ namespace Barotrauma
|
||||
AddCallMetaMember(UserData.RegisterType<GUICustomComponent>());
|
||||
AddCallMetaMember(UserData.RegisterType<GUIImage>());
|
||||
AddCallMetaMember(UserData.RegisterType<GUIListBox>());
|
||||
AddCallMetaMember(UserData.RegisterType<GUIScrollBar>());
|
||||
|
||||
|
||||
#endif
|
||||
lua = new Script(CoreModules.Preset_SoftSandbox);
|
||||
|
||||
|
||||
lua.Options.DebugPrint = PrintMessage;
|
||||
|
||||
lua.Options.ScriptLoader = luaScriptLoader;
|
||||
@@ -447,10 +468,9 @@ namespace Barotrauma
|
||||
#elif CLIENT
|
||||
lua.Globals["GUI"] = new LuaGUI(this);
|
||||
lua.Globals["Sprite"] = UserData.CreateStatic<Sprite>();
|
||||
|
||||
lua.Globals["Keys"] = UserData.CreateStatic<Keys>();
|
||||
lua.Globals["PlayerInput"] = UserData.CreateStatic<PlayerInput>();
|
||||
#endif
|
||||
|
||||
|
||||
// obsolete
|
||||
lua.Globals["CreateVector2"] = (Func<float, float, Vector2>)CreateVector2;
|
||||
lua.Globals["CreateVector3"] = (Func<float, float, float, Vector3>)CreateVector3;
|
||||
|
||||
Reference in New Issue
Block a user