// public GUI() public void Init() { //guihandler _guiHandler = new GUIHandler(); _guiHandler.AttachToContext(Instances.Renderer.RC); var fontLato = AssetStorage.Get<Font>("Montserrat-Regular.ttf"); fontLato.UseKerning = true; _guiLatoBlack = new FontMap(fontLato, 18); //_guiBackground = new GUIImage(AssetStorage.Get<ImageData>("himmel.jpg"), -30, -300, -5, 1500, 1000); //_guiHandler.Add(_guiBackground); _guiPoints = new GUIText("SCORE" + " "+ Instances.Main.score, _guiLatoBlack, Instances.Main.Width - 150, 57); _guiHandler.Add(_guiPoints); }
/// <summary> /// Initializes a new instance of the <see cref="GUIPanel" /> class. /// </summary> /// <param name="text">The text.</param> /// <param name="fontMap">The font map.</param> /// <param name="x">The x-coordinate.</param> /// <param name="y">The y-coordinate.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> public GUIPanel(string text, FontMap fontMap, int x, int y, int width, int height) : base(text, fontMap, x, y, 0, width, height) { SetupPanel(); }
private SceneContainer CreateGui() { string vsTex = AssetStorage.Get <string>("texture.vert"); string psTex = AssetStorage.Get <string>("texture.frag"); string psText = AssetStorage.Get <string>("text.frag"); float canvasWidth = Width / 100f; float canvasHeight = Height / 100f; GUIButton btnFuseeLogo = new GUIButton { Name = "Canvas_Button" }; btnFuseeLogo.OnMouseEnter += BtnLogoEnter; btnFuseeLogo.OnMouseExit += BtnLogoExit; btnFuseeLogo.OnMouseDown += BtnLogoDown; Texture guiFuseeLogo = new Texture(AssetStorage.Get <ImageData>("FuseeText.png")); TextureNode fuseeLogo = new TextureNode( "fuseeLogo", vsTex, psTex, //Set the diffuse texture you want to use. guiFuseeLogo, //Define anchor points. They are given in percent, seen from the lower left corner, respectively to the width/height of the parent. //In this setup the element will stretch horizontally but stay the same vertically if the parent element is scaled. UIElementPosition.GetAnchors(AnchorPos.TopTopLeft), //Define Offset and therefor the size of the element. UIElementPosition.CalcOffsets(AnchorPos.TopTopLeft, new float2(0, canvasHeight - 0.5f), canvasHeight, canvasWidth, new float2(1.75f, 0.5f)), float2.One ); fuseeLogo.AddComponent(btnFuseeLogo); Font fontLato = AssetStorage.Get <Font>("Lato-Black.ttf"); FontMap guiLatoBlack = new FontMap(fontLato, 24); TextNode text = new TextNode( "FUSEE Camera Example", "ButtonText", vsTex, psText, UIElementPosition.GetAnchors(AnchorPos.StretchHorizontal), UIElementPosition.CalcOffsets(AnchorPos.StretchHorizontal, new float2(canvasWidth / 2 - 4, 0), canvasHeight, canvasWidth, new float2(8, 1)), guiLatoBlack, (float4)ColorUint.Greenery, HorizontalTextAlignment.Center, VerticalTextAlignment.Center); CanvasNode canvas = new CanvasNode( "Canvas", _canvasRenderMode, new MinMaxRect { Min = new float2(-canvasWidth / 2, -canvasHeight / 2f), Max = new float2(canvasWidth / 2, canvasHeight / 2f) }) { Children = new ChildList() { //Simple Texture Node, contains the fusee logo. fuseeLogo, text } }; SceneNode cam = new SceneNode() { Name = "GUICam", Components = new List <SceneComponent>() { _guiCamTransform, _guiCam } }; return(new SceneContainer { Children = new List <SceneNode> { cam, //Add canvas. canvas } }); }
private void LayoutRoot_KeyDown(object sender, KeyRoutedEventArgs e) { var ctrlState = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Control); if ((ctrlState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down) { // Check to see if any basic modals are open first if ((SettingsView != null && SettingsView.IsOpen) || (PrintPresenter != null && PrintPresenter.Child != null)) { return; } switch (e.Key) { case VirtualKey.C: FontMap.TryCopy(); break; case VirtualKey.S: if (FontMap.ViewModel.SelectedVariant is FontVariant v) { ExportManager.RequestExportFontFile(v); } break; case VirtualKey.N: if (ViewModel.SelectedFont is InstalledFont fnt) { _ = FontMapView.CreateNewViewForFontAsync(fnt); } break; case VirtualKey.P: Messenger.Default.Send(new PrintRequestedMessage()); break; case VirtualKey.Delete: if (ViewModel.SelectedFont is InstalledFont font && font.HasImportedFiles) { FlyoutHelper.RequestDelete(font); } break; case VirtualKey.Add: case (VirtualKey)187: FontMap.ViewModel.IncreaseCharacterSize(); break; case VirtualKey.Subtract: case (VirtualKey)189: FontMap.ViewModel.DecreaseCharacterSize(); break; case VirtualKey.L: TogglePane_Click(null, null); break; case VirtualKey.R: ViewModel.Settings.EnablePreviewPane = !ViewModel.Settings.EnablePreviewPane; break; case VirtualKey.B: ViewModel.Settings.EnableCopyPane = !ViewModel.Settings.EnableCopyPane; break; case VirtualKey.T: FontMap.ViewModel.ChangeDisplayMode(); break; } } }
public Label(string text, FontMap fontmap = null) { this.Text = text; this.FontMap = fontmap; }
private SceneContainer CreateGui() { var vsTex = AssetStorage.Get <string>("texture.vert"); var psTex = AssetStorage.Get <string>("texture.frag"); var canvasWidth = Width / 100f; var canvasHeight = Height / 100f; var btnFuseeLogo = new GUIButton { Name = "Canvas_Button" }; btnFuseeLogo.OnMouseEnter += BtnLogoEnter; btnFuseeLogo.OnMouseExit += BtnLogoExit; btnFuseeLogo.OnMouseDown += BtnLogoDown; var guiFuseeLogo = new Texture(AssetStorage.Get <ImageData>("FuseeText.png")); var fuseeLogo = new TextureNode( "fuseeLogo", vsTex, psTex, //Set the albedo texture you want to use. guiFuseeLogo, //Define anchor points. They are given in percent, seen from the lower left corner, respectively to the width/height of the parent. //In this setup the element will stretch horizontally but stay the same vertically if the parent element is scaled. UIElementPosition.GetAnchors(AnchorPos.TopTopLeft), //Define Offset and therefor the size of the element. UIElementPosition.CalcOffsets(AnchorPos.TopTopLeft, new float2(0, canvasHeight - 0.5f), canvasHeight, canvasWidth, new float2(1.75f, 0.5f)) ); fuseeLogo.AddComponent(btnFuseeLogo); var fontLato = AssetStorage.Get <Font>("Lato-Black.ttf"); var guiLatoBlack = new FontMap(fontLato, 24); var text = new TextNode( "FUSEE Bone Example", "ButtonText", vsTex, psTex, UIElementPosition.GetAnchors(AnchorPos.StretchHorizontal), UIElementPosition.CalcOffsets(AnchorPos.StretchHorizontal, new float2(canvasWidth / 2 - 4, 0), canvasHeight, canvasWidth, new float2(8, 1)), guiLatoBlack, ColorUint.Tofloat4(ColorUint.Greenery), HorizontalTextAlignment.Center, VerticalTextAlignment.Center); var text1 = new TextNode( "Work in progress!! Will not function as expected.", "wip", vsTex, psTex, UIElementPosition.GetAnchors(AnchorPos.StretchHorizontal), UIElementPosition.CalcOffsets(AnchorPos.StretchHorizontal, new float2(canvasWidth / 2 - 4, canvasHeight / 2 - 0.5f), canvasHeight, canvasWidth, new float2(8, 1)), guiLatoBlack, ColorUint.Tofloat4(ColorUint.Red), HorizontalTextAlignment.Center, VerticalTextAlignment.Center); var canvas = new CanvasNode( "Canvas", CanvasRenderMode.Screen, new MinMaxRect { Min = new float2(-canvasWidth / 2, -canvasHeight / 2f), Max = new float2(canvasWidth / 2, canvasHeight / 2f) }) { Children = new ChildList() { //Simple Texture Node, contains the fusee logo. fuseeLogo, text, text1 } }; return(new SceneContainer { Children = new List <SceneNode> { //Add canvas. canvas } }); }
/// <summary> /// Initializes a new instance of the <see cref="GUIButton" /> class. /// </summary> /// <param name="text">The text.</param> /// <param name="fontMap">The font map.</param> /// <param name="x">The x-coordinate.</param> /// <param name="y">The y-coordinate.</param> /// <param name="z">The z-index.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <remarks> /// The z-index: lower values means further away. If two elements have the same z-index /// then they are rendered according to their order in the <see cref="GUIHandler" />. /// </remarks> public GUIButton(string text, FontMap fontMap, int x, int y, int z, int width, int height) : base(text, fontMap, x, y, z, width, height) { SetupButton(); }