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