diff --git a/BeefProj.toml b/BeefProj.toml
index 2bb6413..58f3911 100644
--- a/BeefProj.toml
+++ b/BeefProj.toml
@@ -1,5 +1,5 @@
FileVersion = 1
-Dependencies = {corlib = "*", raylib-beef = "*"}
+Dependencies = {corlib = "*", corlib = "*", raylib-beef = "*"}
[Project]
Name = "TheaterGui"
diff --git a/BeefSpace.toml b/BeefSpace.toml
deleted file mode 100644
index ad3e583..0000000
--- a/BeefSpace.toml
+++ /dev/null
@@ -1,26 +0,0 @@
-FileVersion = 1
-Projects = {TheaterGui = {Path = "."}, raylib-beef = {Path = "../../External/raylib-beef/raylib-beef"}, ExampleGui = {Path = "../../../Projects/ExampleGui"}}
-
-[Workspace]
-StartupProject = "ExampleGui"
-
-[Configs.Debug.Win64]
-ConfigSelections = {raylib-beef = {Config = "StaticDebug"}}
-
-[Configs.Debug.wasm32]
-AllocType = "CRT"
-EnableObjectDebugFlags = false
-EmitObjectAccessCheck = false
-
-[Configs.Release.Win64]
-ConfigSelections = {raylib-beef = {Config = "StaticRelease"}}
-
-[Configs.Paranoid.wasm32]
-AllocType = "CRT"
-EnableObjectDebugFlags = false
-EmitObjectAccessCheck = false
-
-[Configs.Test.wasm32]
-AllocType = "CRT"
-EnableObjectDebugFlags = false
-EmitObjectAccessCheck = false
diff --git a/examples/BeefProj.toml b/examples/BeefProj.toml
index 0bad17a..4185c75 100644
--- a/examples/BeefProj.toml
+++ b/examples/BeefProj.toml
@@ -4,3 +4,6 @@ Dependencies = {corlib = "*", TheaterGui = "*"}
[Project]
Name = "examples"
StartupObject = "examples.Program"
+
+[Configs.Release.wasm32]
+OtherLinkFlags = "$(LinkFlags) --shell-file $(ProjectDir)/index.html"
diff --git a/examples/BeefSpace.toml b/examples/BeefSpace.toml
index 94fac71..79c8f27 100644
--- a/examples/BeefSpace.toml
+++ b/examples/BeefSpace.toml
@@ -3,3 +3,18 @@ Projects = {examples = {Path = "."}, TheaterGui = {Path = ".."}}
[Workspace]
StartupProject = "examples"
+
+[Configs.Debug.wasm32]
+AllocType = "CRT"
+EnableObjectDebugFlags = false
+EmitObjectAccessCheck = false
+
+[Configs.Paranoid.wasm32]
+AllocType = "CRT"
+EnableObjectDebugFlags = false
+EmitObjectAccessCheck = false
+
+[Configs.Test.wasm32]
+AllocType = "CRT"
+EnableObjectDebugFlags = false
+EmitObjectAccessCheck = false
diff --git a/examples/index.html b/examples/index.html
new file mode 100644
index 0000000..9ea438a
--- /dev/null
+++ b/examples/index.html
@@ -0,0 +1,45 @@
+
+
Game
+
+
+
+
+
+
+
+
+{{{ SCRIPT }}}
\ No newline at end of file
diff --git a/examples/src/ExampleToolbar.bf b/examples/src/ExampleToolbar.bf
index f16f77f..bae38b9 100644
--- a/examples/src/ExampleToolbar.bf
+++ b/examples/src/ExampleToolbar.bf
@@ -20,14 +20,18 @@ class ExampleToolbar : Toolbar
public void PrintVersion()
{
+#if !BF_PLATFORM_WASM
System.Console.WriteLine("1.0");
+#endif
}
public void PrintAbout()
{
+#if !BF_PLATFORM_WASM
System.Console.WriteLine("""
TheaterGui by Booklordofthedings
A simple easy to use gui library for tools
""");
+#endif
}
}
\ No newline at end of file
diff --git a/examples/src/HorSlider.bf b/examples/src/HorSlider.bf
index 29465fc..7fca7b9 100644
--- a/examples/src/HorSlider.bf
+++ b/examples/src/HorSlider.bf
@@ -18,6 +18,8 @@ class HorSlider : HSlider
public override void OnValueChange(float newVal)
{
+#if !BF_PLATFORM_WASM
System.Console.WriteLine(Value);
+#endif
}
}
\ No newline at end of file
diff --git a/src/App.bf b/src/App.bf
index c6dee70..139b48d 100644
--- a/src/App.bf
+++ b/src/App.bf
@@ -42,6 +42,7 @@ class App
if (_CurrentScreen != null)
delete _CurrentScreen;
_CurrentScreen = value;
+ _CurrentScreen.Reorder(Width);
}
};
@@ -187,6 +188,9 @@ class App
Input.HandleRightClick();
else
Input.HandleHover();
+
+ if(Selected != null)
+ Selected.WhileSelected();
}
diff --git a/src/Components/Component.bf b/src/Components/Component.bf
index 1f25871..a3618d8 100644
--- a/src/Components/Component.bf
+++ b/src/Components/Component.bf
@@ -7,7 +7,7 @@ abstract class Component
{
public this(StringView pComponentName, StringView pLabel)
{
- _ComponentType.Append(pComponentName);
+ ComponentType = pComponentName;
Label = pLabel;
}
diff --git a/src/Components/Container.bf b/src/Components/Container.bf
index 3f1c799..04d51ff 100644
--- a/src/Components/Container.bf
+++ b/src/Components/Container.bf
@@ -11,9 +11,10 @@ class Container : Component
}
private List _LayoutData = new .() ~ delete _;
+
public List Children = new .() ~ DeleteContainerAndItems!(_);
-
+
///Recalculate the layout of all entries
public virtual void Reorder(int32 w)
diff --git a/src/Components/InputField.bf b/src/Components/InputField.bf
new file mode 100644
index 0000000..8900f78
--- /dev/null
+++ b/src/Components/InputField.bf
@@ -0,0 +1,72 @@
+namespace TheaterGui.Components;
+
+using System;
+
+using RaylibBeef;
+
+class InputField : Component
+{
+ public NPatchInfo PatchInfo;
+ public String InputContent = new .() ~ delete _;
+
+
+ String text = new .() ~ delete _;
+ public this(StringView pLabel) : base("InputField", pLabel)
+ {
+ Label = "Test Data";
+ Sprite = App.Textures.GetAsset("n_button");
+ Width = 128 * 2;
+ Height = 32;
+ Margin = 10;
+ Tint = Theme.Background;
+ PatchInfo = .(Sprite.SourceRect, 7, 7, 7, 7, (.)NPatchLayout.NPATCH_NINE_PATCH);
+ }
+ public override void Render(int32 soy)
+ {
+ Raylib.DrawTextureNPatch(
+ *Sprite.Source,
+ PatchInfo,
+ Rectangle(X, Y + soy, Width, Height),
+ Vector2(0, 0),
+ 0,
+ Tint);
+
+ if (_IsHovered || App.Selected == this)
+ Raylib.DrawTextureNPatch(*Sprite.Source, PatchInfo, Rectangle(X, Y + soy, Width, Height), Vector2(0, 0), 0, Theme.Tint.SetAlpha(120));
+ _IsHovered = false;
+
+ var measure = Raylib.MeasureTextEx(Theme.Font, text, Theme.FontSize, 0);
+ Raylib.DrawTextEx(Theme.Font, text, Vector2(X + 7, Y + Height / 2 - measure.y / 2 + soy), Theme.FontSize, 0, Theme.Text);
+ }
+
+ protected bool _IsHovered = false;
+ public override Component OnHover(int32 x, int32 y)
+ {
+ _IsHovered = true;
+ return this;
+ }
+
+ public override bool OnClick(int32 x, int32 y)
+ {
+ App.Selected = this;
+ return true;
+ }
+
+ public override void WhileSelected()
+ {
+ int key = Raylib.GetCharPressed();
+ while (key > 0)
+ {
+ // NOTE: Only allow keys in range [32..125]
+ if ((key >= 32) && (key <= 125) && (text.Length < 100))
+ text.Append((char8)key);
+
+ key = Raylib.GetCharPressed(); // Check next character in the queue
+ }
+
+ if (Raylib.IsKeyPressed((.)KeyboardKey.KEY_BACKSPACE))
+ text.RemoveFromEnd(1);
+ if(Raylib.IsKeyPressed((.)KeyboardKey.KEY_ESCAPE))
+ App.Selected = null;
+ }
+}
\ No newline at end of file
diff --git a/src/Extensions.bf b/src/Extensions.bf
index eeee49a..67fd0fc 100644
--- a/src/Extensions.bf
+++ b/src/Extensions.bf
@@ -10,6 +10,14 @@ namespace RaylibBeef
return false;
}
}
+
+ extension Color
+ {
+ public Color SetRed(uint8 red) => .(red, g, b, a);
+ public Color SetGreen(uint8 green) => .(r, green, b, a);
+ public Color SetBlue(uint8 blue) => .(r, g, blue, a);
+ public Color SetAlpha(uint8 alpha) => .(r, g, b, alpha);
+ }
}
namespace System
@@ -25,7 +33,7 @@ namespace System
Compiler.EmitTypeBody(fieldInfo.DeclaringType, scope $"""
public StringView {fieldInfo.Name.Substring(1)}
{{
- public get => {fieldInfo.Name};
+ public get => {fieldInfo.Name} == null ? "" : {fieldInfo.Name}..EnsureNullTerminator();
public set => String.NewOrSet!({fieldInfo.Name}, value);
}};
""");