Coder Social home page Coder Social logo

gwen-net-lua's Introduction

Gwen.Net Lua

MoonSharp proxy classes for Gwen.Net Ex.

MoonSharp is a Lua interpreter written entirely in C# for the .NET, Mono and Unity platforms.

Gwen.Net Ex is a port of Gwen.Net extended with a two-pass layout engine.

Getting Started

In this example we use desktop version of Gwen.Net and OpenTK renderer. This will work on Windows, Linux and MacOS platforms.

// Set platform
Gwen.Platform.Platform.Init(new Gwen.Platform.Windows.WindowsPlatform());
// Set image and XML loader.
// In this example we use embedded resource loader and images from sample codes
Gwen.Loader.LoaderBase.Init(
	new Gwen.Loader.EmbeddedResourceLoader(
		typeof(GwenNetLua.Sample.Sample).Assembly,
		typeof(GwenNetLua.Sample.Sample).Namespace + ".Images",
		typeof(GwenNetLua.Sample.Sample).Namespace + ".Xml"));
// Create renderer
var renderer = new Gwen.Renderer.OpenTK.OpenTKGL40();
// Create skin
var skin = new Gwen.Skin.TexturedBase(renderer, "Skins/DefaultSkin.png");
// Set default font
skin.DefaultFont = new Gwen.Font(renderer, "Arial", 11);
// Create GWEN.NET canvas
var canvas = new Gwen.Control.Canvas(skin);
// Create input handler
var input = new Gwen.Renderer.OpenTK.Input.OpenTK(this);
// Initialize input handler
input.Initialize(canvas);
// Initialize canvas properties
canvas.SetSize(Width, Height); // Width and Height are the size of a window
canvas.ShouldDrawBackground = true;
canvas.BackgroundColor = new Gwen.Color(255, 150, 170, 170);
// Create MoonSharp script instance
var script = new Script(CoreModules.Preset_SoftSandbox);
// Initialize script instance with Gwen.Net Lua proxy classes and other needed stuff
GwenNetLua.Lua.Init(script);
// Set canvas
GwenNetLua.Lua.SetCanvas(canvas);
// Lua script
string lua = @"
	button = Gwen.Button.Create(Gwen.Canvas)
	button.HorizontalAlignment = Gwen.HorizontalAlignment.Center
	button.VerticalAlignment = Gwen.VerticalAlignment.Center
	button.Padding = Gwen.Padding.Five
	button.Text = 'Click Me'
	";
// Run Lua script
script.DoString(lua);

gwen-net-lua's People

Contributors

kpalosaa avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.