public NewPurchaseHistoriesUI(Size2 size) { Branch = new ClickUIBranch("Purchases", (int)ClickUIPriorities.Pad); _grid = new GridLayout(size, new List <Definition> { new ConcreteDefinition(120), new ShareDefintion(), new ConcreteDefinition(120) }, 1); var backButton = ImageTextButtonFactory.CreateRotated("<<", Vector2.Zero, NavigateBack, () => _index != 0 && _isInCall); var smartBackButton = new SmartControl(backButton, (int)ClickUIPriorities.Pad); Branch.Add(smartBackButton.Branch); _grid.AddSpatial(smartBackButton, backButton.Transform, 1, 1); var forwardButton = ImageTextButtonFactory.CreateRotated(">>", Vector2.Zero, NavigateForward, () => (_purchaseSupplier?.Current != null || _index + _ordersPerPage < _purchaseUIs.Count) && _isInCall); var smartForwardButton = new SmartControl(forwardButton, (int)ClickUIPriorities.Pad); Branch.Add(smartForwardButton.Branch); _grid.AddSpatial(smartForwardButton, forwardButton.Transform, 3, 1); _branches.Add(smartForwardButton.Branch); _branches.Add(smartBackButton.Branch); World.Subscribe(EventSubscription.Create <PurchaseInspected>(x => Inspect(), this)); World.Subscribe(EventSubscription.Create <PurchasesListed>(x => ListPurchases(), this)); World.Subscribe(EventSubscription.Create <CallResolved>(x => EndCall(), this)); World.Subscribe(EventSubscription.Create <CallStarted>(x => StartCall(x.Call), this)); }
public NewSelectSleepDurationUI(Action cancel) { _grid = new GridLayout(new Size2(1600, 900), 1, 1); var innerGrid = new GridLayout(new Size2(250, 525), new List <Definition> { new ConcreteDefinition(25), new ConcreteDefinition(200), new ConcreteDefinition(25), }, new List <Definition> { new ConcreteDefinition(25), new ConcreteDefinition(50), new ConcreteDefinition(25), new ConcreteDefinition(70), new ConcreteDefinition(10), new ConcreteDefinition(50), new ConcreteDefinition(10), new ConcreteDefinition(70), new ConcreteDefinition(25), new ConcreteDefinition(70), new ConcreteDefinition(25), new ConcreteDefinition(70), new ConcreteDefinition(25) }); var summary = new Label { BackgroundColor = Color.Transparent, TextColor = Color.White, Font = "Fonts/16", Transform = new Transform2(innerGrid.GetBlockSize(1, 2, 4, 1)), Text = "How long do you want to sleep for?" }; var upHour = ImageTextButtonFactory.CreateUpArrow(Vector2.Zero, AddHour); var smartUpHour = new SmartControl(upHour, (int)ClickUIPriorities.Room); var downHour = ImageTextButtonFactory.CreateDownArrow(Vector2.Zero, ReduceHour); var smartDownHour = new SmartControl(downHour, (int)ClickUIPriorities.Room); _timeLabel = new ImageLabel(_hours + " Hours", "Images/UI/label-small", new Transform2(Sizes.SmallLabel)); var sleepButton = ImageTextButtonFactory.Create("Sleep", Vector2.Zero, () => World.Publish(new WentToBed(_hours))); var smartSleepButton = new SmartControl(sleepButton, (int)ClickUIPriorities.Room); var cancelButton = ImageTextButtonFactory.Create("Cancel", Vector2.Zero, cancel); var smartCancelButton = new SmartControl(cancelButton, (int)ClickUIPriorities.Room); _grid.AddSpatial(innerGrid, new Transform2(innerGrid.Size), 1, 1); innerGrid.AddSpatial(new ImageBox(new Transform2(innerGrid.Size), "Images/UI/messenger"), new Transform2(innerGrid.Size), 1, 1, 3, 13); innerGrid.AddSpatial(summary, summary.Transform, 2, 2); innerGrid.AddSpatial(smartUpHour, new Transform2(new Size2(70, 70)), 2, 4); innerGrid.AddSpatial(_timeLabel, new Transform2(Sizes.SmallLabel), 2, 6); innerGrid.AddSpatial(smartDownHour, new Transform2(new Size2(70, 70)), 2, 8); innerGrid.AddSpatial(smartSleepButton, sleepButton.Transform, 2, 10); innerGrid.AddSpatial(smartCancelButton, cancelButton.Transform, 2, 12); Branch = new ClickUIBranch("Sleep Duration", (int)ClickUIPriorities.Room); Branch.Add(smartUpHour.Branch); Branch.Add(smartDownHour.Branch); Branch.Add(smartSleepButton.Branch); Branch.Add(smartCancelButton.Branch); }
public void OnCallStart(Call call) { for (int i = 0; i < call.Options.Count; i++) { var button = ImageTextButtonFactory.Create(call.Options[i].Description, Vector2.Zero, call.Options[i].Go); var smartButton = new SmartControl(button, (int)ClickUIPriorities.Pad); _choices.Add(smartButton); _grid.AddSpatial(smartButton, button.Transform, i + 1, 1); Branch.Add(smartButton.Branch); } }
/// <summary> /// Load a Control Scheme. /// </summary> /// <param name="scheme"></param> /// <param name="loadCustomControls"></param> public static void LoadControlScheme(ControlScheme scheme, bool loadCustomControls) { //Debug.Log("load scheme asset!"); schemeLoaded = false; Init(); //make sure we know what gamepads are connected //and load their common mappings if they are needed CheckGamepads(true); //Generate controls from controlScheme asset List <Control> loadedControls = new List <Control>(); for (int i = 0; i < scheme.controls.Count; i++) { Control newControl = new Control(scheme.controls[i].name); for (int k = 0; k < scheme.controls[i].keyboardInputs.Count; k++) { newControl.AddKeyboardInput((KeyCode)Enum.Parse(typeof(KeyCode), scheme.controls[i].keyboardInputs[k].ToString())); } for (int k = 0; k < scheme.controls[i].gamepadInputs.Count; k++) { newControl.AddGamepadInput(scheme.controls[i].gamepadInputs[k]); } for (int k = 0; k < scheme.controls[i].mouseInputs.Count; k++) { newControl.AddMouseInput(scheme.controls[i].mouseInputs[k]); } for (int k = 0; k < scheme.controls[i].virtualInputs.Count; k++) { newControl.AddVirtualInput(scheme.controls[i].virtualInputs[k]); } for (int k = 0; k < scheme.controls[i].xrInputs.Count; k++) { newControl.AddGamepadInput(scheme.controls[i].xrInputs[k]); } loadedControls.Add(newControl); } _controls = loadedControls.ToArray(); //Generate smartControls from controlScheme asset List <SmartControl> loadedSmartControls = new List <SmartControl>(); for (int i = 0; i < scheme.smartControls.Count; i++) { SmartControl newControl = new SmartControl(scheme.smartControls[i].name); newControl.positiveControl = scheme.smartControls[i].positiveControl; newControl.negativeControl = scheme.smartControls[i].negativeControl; newControl.gravity = scheme.smartControls[i].gravity; newControl.deadzone = scheme.smartControls[i].deadzone; newControl.speed = scheme.smartControls[i].speed; newControl.snap = scheme.smartControls[i].snap; //newControl.scale = scheme.smartControls[i].scale; newControl.inversion = new bool[_totalPossibleDeviceSlots]; newControl.scales = new float[_totalPossibleDeviceSlots]; for (int k = 0; k < _totalPossibleDeviceSlots; k++) { newControl.inversion[k] = scheme.smartControls[i].invert; newControl.scales[k] = scheme.smartControls[i].scale; } loadedSmartControls.Add(newControl); } _smartControls = loadedSmartControls.ToArray(); for (int i = 0; i < _smartControls.Length; i++) { _smartControls[i].Init(); } //now load any saved control scheme with custom rebound inputs if (loadCustomControls && SinputFileIO.SaveDataExists(controlSchemeName)) { //Debug.Log("Found saved binding!"); _controls = SinputFileIO.LoadControls(_controls, controlSchemeName); } //make sure controls have any gamepad-relevant stuff set correctly RefreshGamepadControls(); schemeLoaded = true; lastUpdateFrame = -99; }