Skip to content

Commit

Permalink
Create UI Status
Browse files Browse the repository at this point in the history
  • Loading branch information
Mvivant committed May 3, 2017
1 parent ad63c5b commit 9c8f1de
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
1 change: 1 addition & 0 deletions VRSandbox/Assets/Shared/MainScene.xkscene
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Hierarchy:
8440e488bc01259a140ead20182a7c7f: !Xenko3dRudder.Movement3dRudder,VRSandbox.Game
Id: ed3b68d0-0d18-4a1c-90a0-a2e52ec89785
Camera: ref!! c0a4222a-ae01-420f-8bb5-1e82ad1cfcf3
Page: d93c8e1d-ccc0-4626-9555-acc087a6ba57:Page
Port3dRudder: 0
Rotate: true
mode: ValueWithCurveNonSymmetricalPitch
Expand Down
38 changes: 36 additions & 2 deletions VRSandbox/Assets/Shared/Page.xkuipage
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,29 @@ Hierarchy:
RootPartIds:
- c8a83548-ab0a-420d-82bc-ded3b9b36b34
Parts:
- UIElement: !TextBlock
Id: 293e53ee-874c-4a73-9ae2-e44b195e540f
DependencyProperties: {}
BackgroundColor: {R: 0, G: 255, B: 199, A: 255}
Width: 512.0
Height: 115.0
VerticalAlignment: Bottom
Margin: {Bottom: 133.0}
Name:
Text: Status 3dRudder
Font: 3a8a297a-d543-4202-9ff9-d2925298e9b9:SpriteFont
TextSize: 40.0
TextColor: {R: 1, G: 1, B: 1, A: 255}
TextAlignment: Center
WrapText: true
- UIElement: !TextBlock
Id: 48e2f7cf-b8a6-4262-b9e5-6735f2226245
DependencyProperties: {}
BackgroundColor: {R: 0, G: 0, B: 0, A: 0}
Margin: {}
Text: You can display UI easily using overlays. Check out the GraphicsCompositor and the UIPage assets for details.
Width: 512.0
Height: 297.0
Margin: {Bottom: 215.0}
Text: can display UI easily using overlays. Check out the GraphicsCompositor and the UIPage assets for details.
Font: 3a8a297a-d543-4202-9ff9-d2925298e9b9:SpriteFont
TextSize: 36.0
TextColor: {R: 240, G: 240, B: 240, A: 255}
Expand All @@ -25,6 +42,23 @@ Hierarchy:
Margin: {}
Children:
e83e06b3b5534c1eeea7ea008c95530a: !TextBlock ref!! 48e2f7cf-b8a6-4262-b9e5-6735f2226245
6ea2b66b2249b44af88423738bb5dabe: !TextBlock ref!! 293e53ee-874c-4a73-9ae2-e44b195e540f
a27dec9ac56ac41ee54985cb51ddbbb8: !TextBlock ref!! f1b65aa0-5626-4f07-adc2-7ca0f96cd27d
RowDefinitions: {}
ColumnDefinitions: {}
LayerDefinitions: {}
- UIElement: !TextBlock
Id: f1b65aa0-5626-4f07-adc2-7ca0f96cd27d
DependencyProperties: {}
BackgroundColor: {R: 0, G: 255, B: 199, A: 255}
Width: 512.0
Height: 133.0
VerticalAlignment: Bottom
Margin: {}
Name: Status
Text:
Font: 3a8a297a-d543-4202-9ff9-d2925298e9b9:SpriteFont
TextSize: 40.0
TextColor: {R: 0, G: 0, B: 0, A: 255}
TextAlignment: Center
SynchronousCharacterGeneration: true
15 changes: 11 additions & 4 deletions VRSandbox/VRSandbox.Game/Player/3dRudderInput.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
// Copyright (c) 2011-2017 Silicon Studio Corp. All rights reserved. (https://www.siliconstudio.co.jp)
// See LICENSE.md for full license information.
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SiliconStudio.Core.Mathematics;
using SiliconStudio.Xenko.Input;
using SiliconStudio.Xenko.Engine;
using SiliconStudio.Xenko.UI;
using SiliconStudio.Xenko.UI.Controls;
using ns3DRudder;
using System.Text.RegularExpressions;

namespace Xenko3dRudder
{
public class Movement3dRudder : SyncScript
{
// Declared public member fields and properties will show in the game studio
public Entity Camera { get; set; }
public Entity Camera { get; set; }
public UIPage Page { get; set; }
public uint Port3dRudder { get; set; } = 0;
public bool Rotate { get; set; } = false;
public ModeAxis mode { get; set; } = ModeAxis.ValueWithCurveNonSymmetricalPitch;
Expand All @@ -26,17 +28,22 @@ public class Movement3dRudder : SyncScript
private CSdk sdk;
private CurveArray curves;
private Axis axis;
private TextBlock status;

public override void Start()
{
// Initialization of the script.
sdk = i3DR.GetSDK();
curves = new CurveArray();
axis = new Axis();

var root = Page.RootElement;
status = root.FindVisualChildOfType<TextBlock>("Status");
}

public override void Update()
{
status.Text = Regex.Replace(sdk.GetStatus(0).ToString(), "(\\B[A-Z])", " $1").ToUpper();
// 3dRudder connected
if (sdk.IsDeviceConnected(Port3dRudder))
{
Expand Down

0 comments on commit 9c8f1de

Please sign in to comment.