So I finally had time to work on this… Unfortunately, try as I might, I co
uldn’t reproduce the running away paragraphs.
I took your code and dumped it inside the GeonBit.UI example project:
`#region File Description
//-----------------------------------------------------------------------------
// This program show GeonBit.UI examples and usage.
//
// GeonBit.UI is an export of the UI system used for GeonBit (an open source
// game engine in MonoGame) and is free to use under the MIT license.
//
// To learn more about GeonBit.UI, you can visit the git repo:
// https://github.com/RonenNess/GeonBit.UI
//
// Or exaplore the different README files scattered in the solution directory.
//
// Author: Ronen Ness.
// Since: 2016.
//-----------------------------------------------------------------------------
#endregion
// using MonoGame and basic system stuff
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Collections.Generic;
// using GeonBit UI elements
using GeonBit.UI.Entities;
using GeonBit.UI.Entities.TextValidators;
using GeonBit.UI.DataTypes;
namespace GeonBit.UI.Example
{
/// <summary>
/// GeonBit.UI.Example is just an example code. Everything here is not a part of the GeonBit.UI framework, but merely an example of how to use it.
/// </summary>
[System.Runtime.CompilerServices.CompilerGenerated]
class NamespaceDoc
{
}
/// <summary>
/// This is the main 'Game' instance for your game.
/// </summary>
public class GeonBitUI_Examples : Game
{
// graphics and spritebatch
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
// all the example panels (screens)
List<Panel> panels = new List<Panel>();
/// <summary>
///
/// </summary>
public Button nextExampleButton;
/// <summary>
///
/// </summary>
public Button previousExampleButton;
// current example shown
int currExample = 0;
/// <summary>
/// Create the game instance.
/// </summary>
public GeonBitUI_Examples()
{
// init graphics device manager and set content root
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
/// <summary>
/// Initialize the main application.
/// </summary>
protected override void Initialize()
{
// create and init the UI manager
UserInterface.Initialize(Content, BuiltinThemes.hd);
UserInterface.UseRenderTarget = true;
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// make the window fullscreen (but still with border and top control bar)
/* int _ScreenWidth = graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Width;
int _ScreenHeight = graphics.GraphicsDevice.Adapter.CurrentDisplayMode.Height;
graphics.PreferredBackBufferWidth = (int)_ScreenWidth;
graphics.PreferredBackBufferHeight = (int)_ScreenHeight;
graphics.IsFullScreen = true;
graphics.ApplyChanges();*/
// init ui and examples
InitExamplesAndUI();
}
/// <summary>
/// Create the top bar with next / prev buttons etc, and init all UI example panels.
/// </summary>
protected void InitExamplesAndUI()
{
UserInterface.GlobalScale = 0.7f;
UserInterface.ShowCursor = false;
Panel panel = new Panel(new Vector2(500, 600), PanelSkin.Simple, Anchor.TopRight);
panel.Draggable = false;
UserInterface.AddEntity(panel);
CheckBox toggleShader = new CheckBox("aaa");
panel.AddChild(new Paragraph("Test UI"));
panel.SetPosition(Anchor.TopRight, new Vector2(0, 0));
Paragraph fps;
panel.AddChild(fps = new Paragraph("fps :"));
panel.AddChild(toggleShader = new CheckBox("Update Shader", Anchor.Auto, null, null, true));
toggleShader.Scale = 0.5f;
toggleShader.OnValueChange = (Entity entity) =>
{
CheckBox cb = (CheckBox)entity;
};
CheckBox seamFixToggle;
panel.AddChild(seamFixToggle = new CheckBox("Fix Seams", Anchor.Auto, null, null, true));
panel.AddChild(toggleShader = new CheckBox("Rotate Model", Anchor.Auto, null, null, true));
toggleShader.Scale = 0.5f;
toggleShader.OnValueChange = (Entity entity) =>
{
CheckBox cb = (CheckBox)entity;
};
panel.AddChild(new LineSpace(1));
Paragraph sliderValue = new Paragraph("Texture resolution: 512");
panel.AddChild(sliderValue);
Slider slider = new Slider(1, 12, SliderSkin.Default);
slider.Value = 9;
slider.StepsCount = 11;
slider.OnValueChange = (Entity entity) =>
{
Slider slid = (Slider)entity;
//sliderValue.Text = "Texture resolution: " + GameSettings.g_texResolution;
};
panel.AddChild(slider);
Paragraph environmentMap = new Paragraph("ambient intensity: 1.8");
panel.AddChild(environmentMap);
Slider envIntensitySlider = new Slider(0, 400, SliderSkin.Default);
envIntensitySlider.StepsCount = 400;
envIntensitySlider.Value = 180;
envIntensitySlider.OnValueChange = (Entity entity) =>
{
Slider slid = (Slider)entity;
//environmentMap.Text = "ambient intensity: " + GameSettings.g_EnvironmentIntensity;
};
panel.AddChild(envIntensitySlider);
Paragraph seamFixSteps = new Paragraph("seam dilate pixels: 1");
panel.AddChild(seamFixSteps);
Slider seamFixStepsSlider = new Slider(0, 6, SliderSkin.Default);
seamFixStepsSlider.StepsCount = 6;
seamFixStepsSlider.Value = 1;
seamFixStepsSlider.OnValueChange = (Entity entity) =>
{
Slider slid = (Slider)entity;
//seamFixSteps.Text = "seam dilate pixels: " + GameSettings.g_SeamSearchSteps;
};
panel.AddChild(seamFixStepsSlider);
seamFixToggle.OnValueChange = (Entity entity) =>
{
CheckBox cb = (CheckBox)entity;
seamFixStepsSlider.Disabled = !cb.Checked;
};
}
/// <summary>
/// Show next UI example.
/// </summary>
public void NextExample()
{
currExample++;
UpdateAfterExapmleChange();
}
/// <summary>
/// Show previous UI example.
/// </summary>
public void PreviousExample()
{
currExample--;
UpdateAfterExapmleChange();
}
/// <summary>
/// Called after we change current example index, to hide all examples
/// except for the currently active example + disable prev / next buttons if
/// needed (if first or last example).
/// </summary>
protected void UpdateAfterExapmleChange()
{
// hide all panels and show current example panel
foreach (Panel panel in panels)
{
panel.Visible = false;
}
panels[currExample].Visible = true;
// disable / enable next and previous buttons
nextExampleButton.Disabled = currExample == panels.Count-1;
previousExampleButton.Disabled = currExample == 0;
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
// make sure window is focused
if (!IsActive)
return;
// exit on escape
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
// update UI
UserInterface.Update(gameTime);
// call base update
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
// draw ui
UserInterface.Draw(spriteBatch);
// clear buffer
GraphicsDevice.Clear(Color.CornflowerBlue);
// finalize ui rendering
UserInterface.DrawMainRenderTarget(spriteBatch);
// call base draw function
base.Draw(gameTime);
}
}
}
`
And it looks like it should, without running text:
I tried random stuff like resizing window etc, still not happening
Is your code public perhaps, somewhere I can view it? Or maybe you got more ideas I can try?
Thanks!