/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { SampleLoader loader = new SampleLoader(Content) { Key = "112233445566778899aabbccddeeff" }; Gwen.Platform.Platform.Init(new Gwen.Platform.MonoGame.MonoGamePlatform()); Gwen.Loader.LoaderBase.Init(loader); renderer = new Gwen.Renderer.MonoGame.MonoGame(GraphicsDevice, Content, Content.Load <Effect>("GwenEffect")); renderer.Resize(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); skin = new Gwen.Skin.TexturedBase(renderer, "Skins/DefaultSkin"); skin.DefaultFont = new Font(renderer, "Arial", 11); canvas = new Canvas(skin); input = new Gwen.Renderer.MonoGame.Input.MonoGame(this); input.Initialize(canvas); canvas.SetSize(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); canvas.ShouldDrawBackground = true; canvas.BackgroundColor = new Color(255, 150, 170, 170); m_Time = 0; script = new Script(CoreModules.Preset_SoftSandbox | CoreModules.LoadMethods); script.Options.ScriptLoader = loader; GwenNetLua.Lua.Init(script); GwenNetLua.Lua.SetCanvas(canvas); DynValue result; try { result = script.DoString("return require 'Sample'"); } catch (ScriptRuntimeException ex) { throw new Exception(String.Format("Runtime error: {0}", ex.DecoratedMessage), ex); } catch (SyntaxErrorException ex) { throw new Exception(String.Format("Syntax error: {0}", ex.DecoratedMessage), ex); } catch (Exception ex) { throw new Exception(String.Format("Error: {0}", ex.Message), ex); } if (result.Type == DataType.UserData) { GwenNetLua.Control.ListBox textOutput = result.UserData.Object as GwenNetLua.Control.ListBox; if (textOutput != null) { script.Options.DebugPrint = t => { textOutput.AddRow(t); textOutput.ScrollToBottom(); } } ; } }
/// <summary> /// UnloadContent will be called once per game and is the place to unload /// game-specific content. /// </summary> protected override void UnloadContent() { if (canvas != null) { canvas.Dispose(); canvas = null; } if (skin != null) { skin.Dispose(); skin = null; } if (renderer != null) { renderer.Dispose(); renderer = null; } }
/// <summary> /// UnloadContent will be called once per game and is the place to unload /// game-specific content. /// </summary> protected override void UnloadContent() { if (m_Canvas != null) { m_Canvas.Dispose(); m_Canvas = null; } if (m_Skin != null) { m_Skin.Dispose(); m_Skin = null; } if (m_Renderer != null) { m_Renderer.Dispose(); m_Renderer = null; } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { Platform.Platform.Init(new Gwen.Platform.MonoGame.MonoGamePlatform()); Loader.LoaderBase.Init(new Gwen.Loader.MonoGame.MonoGameAssetLoader(Content)); m_Renderer = new Gwen.Renderer.MonoGame.MonoGame(GraphicsDevice, Content, Content.Load <Effect>("GwenEffect")); m_Renderer.Resize(m_Graphics.PreferredBackBufferWidth, m_Graphics.PreferredBackBufferHeight); m_Skin = new Gwen.Skin.TexturedBase(m_Renderer, "Skins/DefaultSkin", "Skins/DefaultSkinDefinition"); m_Skin.DefaultFont = new Font(m_Renderer, "Arial", 11); m_Canvas = new Canvas(m_Skin); m_Input = new Gwen.Renderer.MonoGame.Input.MonoGame(this); m_Input.Initialize(m_Canvas); m_Canvas.SetSize(m_Graphics.PreferredBackBufferWidth, m_Graphics.PreferredBackBufferHeight); m_Canvas.ShouldDrawBackground = true; m_Canvas.BackgroundColor = new Color(255, 150, 170, 170); m_UnitTest = new Gwen.UnitTest.UnitTest(m_Canvas); m_Time = 0; }