internal void ConstructPageLimitOpt(GameObject parent) { //public int Default_Page_Limit = 20; var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0)); var rowGroup = rowObj.GetComponent <HorizontalLayoutGroup>(); rowGroup.childControlWidth = true; rowGroup.childForceExpandWidth = false; rowGroup.childControlHeight = true; rowGroup.childForceExpandHeight = true; var groupLayout = rowObj.AddComponent <LayoutElement>(); groupLayout.minHeight = 25; groupLayout.flexibleHeight = 0; groupLayout.minWidth = 200; groupLayout.flexibleWidth = 1000; var labelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft); var labelText = labelObj.GetComponent <Text>(); labelText.text = "Default Page Limit:"; var labelLayout = labelObj.AddComponent <LayoutElement>(); labelLayout.minWidth = 150; labelLayout.minHeight = 25; var inputObj = UIFactory.CreateInputField(rowObj); m_pageLimitInput = inputObj.GetComponent <InputField>(); m_pageLimitInput.text = ModConfig.Instance.Default_Page_Limit.ToString(); m_pageLimitInput.placeholder.gameObject.GetComponent <Text>().text = "Integer, eg. 20"; }
// UI Construction public override void ConstructPanelContent() { // Log scroll pool logScrollPool = UIFactory.CreateScrollPool <ConsoleLogCell>(this.content, "Logs", out GameObject scrollObj, out GameObject scrollContent, new Color(0.03f, 0.03f, 0.03f)); UIFactory.SetLayoutElement(scrollObj, flexibleWidth: 9999, flexibleHeight: 9999); // Buttons and toggles var optionsRow = UIFactory.CreateUIObject("OptionsRow", this.content); UIFactory.SetLayoutElement(optionsRow, minHeight: 25, flexibleWidth: 9999); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(optionsRow, false, false, true, true, 5, 2, 2, 2, 2); var clearButton = UIFactory.CreateButton(optionsRow, "ClearButton", "Clear", new Color(0.2f, 0.2f, 0.2f)); UIFactory.SetLayoutElement(clearButton.Component.gameObject, minHeight: 23, flexibleHeight: 0, minWidth: 60); clearButton.OnClick += ClearLogs; clearButton.Component.transform.SetSiblingIndex(1); var fileButton = UIFactory.CreateButton(optionsRow, "FileButton", "Open Log File", new Color(0.2f, 0.2f, 0.2f)); UIFactory.SetLayoutElement(fileButton.Component.gameObject, minHeight: 23, flexibleHeight: 0, minWidth: 100); fileButton.OnClick += OpenLogFile; fileButton.Component.transform.SetSiblingIndex(2); var unityToggle = UIFactory.CreateToggle(optionsRow, "UnityLogToggle", out var toggle, out var toggleText); UIFactory.SetLayoutElement(unityToggle, minHeight: 25, minWidth: 150); toggleText.text = "Log Unity Debug?"; toggle.isOn = ConfigManager.Log_Unity_Debug.Value; ConfigManager.Log_Unity_Debug.OnValueChanged += (bool val) => toggle.isOn = val; toggle.onValueChanged.AddListener((bool val) => ConfigManager.Log_Unity_Debug.Value = val); }
static void Main() { ICommandProcessor processor = new CommandProcessor(); IUIFactory uiFactory = new UIFactory(); var commands = new Dictionary <string, ICommand> { { "Logarithm", new LogartihmCommand(uiFactory) }, { "Pi", new PiCommand(uiFactory) }, { "e", new ExponentialCommand(uiFactory) }, { "Power", new PowerCommand(uiFactory) }, { "Arctg", new ArctgCommand(uiFactory) }, { "Arcctg", new ArcctgCommand(uiFactory) }, { "Arcsin", new ArcsinCommand(uiFactory) }, { "Arccos", new ArccosCommand(uiFactory) }, { "Coth", new HiperbolicalCothCommand(uiFactory) }, { "Tanh", new HiperbolicalTanhCommand(uiFactory) }, { "Sinh", new HiperbolicalSinhCommand(uiFactory) }, { "Cosh", new HiperbolicalCoshCommand(uiFactory) }, { "Cot", new CotCommand(uiFactory) }, { "Tan", new TanCommand(uiFactory) }, { "Sin", new SinCommand(uiFactory) }, { "Cos", new CosCommand(uiFactory) }, }; var controller = uiFactory.CreateController(commands, processor); controller.ShowMenu(); }
/// <summary> /// Check for updates, using interaction appropriate for if the user just said "check for updates" /// </summary> public UpdateStatus CheckForUpdatesAtUserRequest() { Cursor.Current = Cursors.WaitCursor; var updateAvailable = CheckForUpdates(false /* toast not appropriate, since they just requested it */); Cursor.Current = Cursors.Default; switch (updateAvailable) { case UpdateStatus.UpdateAvailable: break; case UpdateStatus.UpdateNotAvailable: UIFactory.ShowVersionIsUpToDate(); break; case UpdateStatus.UserSkipped: UIFactory.ShowVersionIsSkippedByUserRequest(); // TODO: pass skipped version no break; case UpdateStatus.CouldNotDetermine: UIFactory.ShowCannotDownloadAppcast(_appCastUrl); break; default: throw new ArgumentOutOfRangeException(); } return(updateAvailable);// in this case, we've already shown UI talking about the new version }
public override void Awake() { size = new Vector2(400, 100); anchor = UIAnchorStyle.Bottom & UIAnchorStyle.Left; backgroundSprite = "ButtonMenu"; autoLayoutPadding = new RectOffset(10, 10, 4, 4); autoLayout = true; autoFitChildrenVertically = true; autoLayoutDirection = LayoutDirection.Vertical; timeOfDay = AddUIComponent <UILabel>(); timeOfDay.textAlignment = UIHorizontalAlignment.Center; timeOfDay.size = new Vector2(width - 20, 20); timeOfDay.autoSize = false; timeSlider = UIFactory.CreateSlider(this, 0.0f, 24.0f); timeSlider.stepSize = 1f / 60.0f; timeSlider.eventValueChanged += ChangeTime; ((UIPanel)timeSlider.parent).backgroundSprite = "BudgetBarBackground"; ((UISprite)timeSlider.thumbObject).spriteName = "InfoIconBasePressed"; timeSlider.eventDragStart += timeSlider_eventDragStart; //timeSlider.eventDragEnd += timeSlider_eventDragEnd; eventMouseUp += timeSlider_eventDragEnd; UISprite pad = AddUIComponent <UISprite>(); pad.autoSize = false; pad.size = new Vector2(10, 5); }
internal void ConstructUI() { GameObject parent = MainMenu.Instance.PageViewport; Content = UIFactory.CreateVerticalGroup(parent, new Color(0.15f, 0.15f, 0.15f)); var mainGroup = Content.GetComponent <VerticalLayoutGroup>(); mainGroup.padding.left = 4; mainGroup.padding.right = 4; mainGroup.padding.top = 4; mainGroup.padding.bottom = 4; mainGroup.spacing = 5; mainGroup.childForceExpandHeight = false; mainGroup.childForceExpandWidth = true; mainGroup.childControlHeight = true; mainGroup.childControlWidth = true; // ~~~~~ Title ~~~~~ GameObject titleObj = UIFactory.CreateLabel(Content, TextAnchor.UpperLeft); Text titleLabel = titleObj.GetComponent <Text>(); titleLabel.text = "Tools"; titleLabel.fontSize = 20; LayoutElement titleLayout = titleObj.AddComponent <LayoutElement>(); titleLayout.minHeight = 30; titleLayout.flexibleHeight = 0; AddReferencedInput(out this.m_positionInput, "Player Position", "The Vector3 position of the first local player."); AddReferencedInput(out this.m_sceneInput, "Current Scene", "The build name of the current Scene."); AddReferencedInput(out this.m_soundInput, "Current Music", "The name of the current music track."); m_sceneInput.text = SceneManager.GetActiveScene().name; }
public void AddGUIToggle() { UIMultiStateButton zoomButton = GameObject.Find("ZoomButton").GetComponent <UIMultiStateButton>(); UIComponent bottomBar = zoomButton.parent; UIButton toggle = UIFactory.CreateButton(bottomBar); toggle.area = new Vector4(108, 24, 38, 38); toggle.playAudioEvents = true; toggle.normalBgSprite = "OptionBase"; toggle.focusedBgSprite = "OptionBaseFocus"; toggle.hoveredBgSprite = "OptionBaseHover"; toggle.pressedBgSprite = "OptionBasePressed"; toggle.tooltip = i18n.current["toggle_tooltip"]; toggle.normalFgSprite = "InfoIconEntertainmentDisabled"; toggle.scaleFactor = 0.75f; toggle.eventClicked += (UIComponent component, UIMouseEventParameter eventParam) => { bool active = !sunControlPanel.gameObject.active; toggle.normalBgSprite = active ? "OptionBasePressed" : "OptionBase"; sunControlPanel.gameObject.SetActive(active); timeSlider.gameObject.SetActive(active); }; }
// Second row private void ConstructSecondRow(GameObject parent) { var rowObj = UIFactory.CreateUIObject("SecondRow", parent); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(rowObj, false, false, true, true, 5, 2, 2, 2, 2); UIFactory.SetLayoutElement(rowObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999); // Scope buttons var scopeLabel = UIFactory.CreateLabel(rowObj, "ScopeLabel", "Scope:", TextAnchor.MiddleLeft, Color.grey); UIFactory.SetLayoutElement(scopeLabel.gameObject, minHeight: 25, minWidth: 60, flexibleWidth: 0); AddScopeFilterButton(rowObj, BindingFlags.Default, true); AddScopeFilterButton(rowObj, BindingFlags.Instance); AddScopeFilterButton(rowObj, BindingFlags.Static); var spacer = UIFactory.CreateUIObject("Spacer", rowObj); UIFactory.SetLayoutElement(spacer, minWidth: 15); // Member type toggles AddMemberTypeToggle(rowObj, MemberTypes.Property, 90); AddMemberTypeToggle(rowObj, MemberTypes.Field, 70); AddMemberTypeToggle(rowObj, MemberTypes.Method, 90); }
private void AddMemberTypeToggle(GameObject parent, MemberTypes type, int width) { var toggleObj = UIFactory.CreateToggle(parent, "Toggle_" + type, out Toggle toggle, out Text toggleText); UIFactory.SetLayoutElement(toggleObj, minHeight: 25, minWidth: width); var color = SignatureHighlighter.GetMemberInfoColor(type); toggleText.text = $"<color={color}>{type}</color>"; toggle.graphic.TryCast <Image>().color = color.ToColor() * 0.65f; MemberFlags flag; switch (type) { case MemberTypes.Method: flag = MemberFlags.Method; break; case MemberTypes.Property: flag = MemberFlags.Property; break; case MemberTypes.Field: flag = MemberFlags.Field; break; default: return; } toggle.onValueChanged.AddListener((bool val) => { OnMemberTypeToggled(flag, val); }); memberTypeToggles.Add(toggle); }
public override bool AddDockableAttachment(BaseAttachment attach) { if (base.AddDockableAttachment(attach)) { //attach.rigidbody.velocity = Vector3.zero; attach.rigidbody.isKinematic = true; InstrumentAttachment instrument = attach as InstrumentAttachment; attach.SetToolmodeResponse(new BaseTool.ToolMode[] { BaseTool.ToolMode.PRIMARY, BaseTool.ToolMode.GRABBING }); instrument.EnableControls(); instrument.SetCloneable(false); GameObject volumetric = UIFactory.CreateVolumetricCylinder(); volumetric.transform.position = new Vector3(attach.transform.position.x, m_volumetricYOffset, attach.transform.position.z); volumetric.transform.parent = transform; iTween.ColorTo(volumetric, iTween.Hash("color", new Color(1.0f, 1.0f, 1.0f, 0.2f), "time", 0.8f)); m_volumetrics[instrument] = volumetric; PlaceObjects(); //iTween.MoveTo(attach.gameObject, iTween.Hash("position", transform.localPosition, "uselocal", true )); return(true); } return(false); }
// First row private void ConstructFirstRow(GameObject parent) { var rowObj = UIFactory.CreateUIObject("FirstRow", parent); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(rowObj, true, true, true, true, 5, 2, 2, 2, 2); UIFactory.SetLayoutElement(rowObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999); var nameLabel = UIFactory.CreateLabel(rowObj, "NameFilterLabel", "Filter names:", TextAnchor.MiddleLeft, Color.grey); UIFactory.SetLayoutElement(nameLabel.gameObject, minHeight: 25, minWidth: 90, flexibleWidth: 0); filterInputField = UIFactory.CreateInputField(rowObj, "NameFilterInput", "..."); UIFactory.SetLayoutElement(filterInputField.UIRoot, minHeight: 25, flexibleWidth: 300); filterInputField.OnValueChanged += (string val) => { SetFilter(val); }; var spacer = UIFactory.CreateUIObject("Spacer", rowObj); UIFactory.SetLayoutElement(spacer, minWidth: 25); // Update button and toggle var updateButton = UIFactory.CreateButton(rowObj, "UpdateButton", "Update displayed values", new Color(0.22f, 0.28f, 0.22f)); UIFactory.SetLayoutElement(updateButton.Component.gameObject, minHeight: 25, minWidth: 175, flexibleWidth: 0); updateButton.OnClick += UpdateClicked; var toggleObj = UIFactory.CreateToggle(rowObj, "AutoUpdateToggle", out autoUpdateToggle, out Text toggleText); UIFactory.SetLayoutElement(toggleObj, minWidth: 125, minHeight: 25); autoUpdateToggle.isOn = false; toggleText.text = "Auto-update"; }
public override void ConstructUI(GameObject parent, GameObject subGroup) { base.ConstructUI(parent, subGroup); var baseLayout = m_baseLabel.gameObject.GetComponent <LayoutElement>(); baseLayout.flexibleWidth = 0; baseLayout.minWidth = 50; if (Owner.CanWrite) { var toggleObj = UIFactory.CreateToggle(m_valueContent, out m_toggle, out _, new Color(0.1f, 0.1f, 0.1f)); var toggleLayout = toggleObj.AddComponent <LayoutElement>(); toggleLayout.minWidth = 24; m_toggle.onValueChanged.AddListener(OnToggleValueChanged); m_baseLabel.transform.SetAsLastSibling(); var applyBtnObj = UIFactory.CreateButton(m_valueContent, new Color(0.2f, 0.2f, 0.2f)); var applyLayout = applyBtnObj.AddComponent <LayoutElement>(); applyLayout.minWidth = 50; applyLayout.minHeight = 25; applyLayout.flexibleWidth = 0; m_applyBtn = applyBtnObj.GetComponent <Button>(); m_applyBtn.onClick.AddListener(() => { Owner.SetValue(); }); var applyText = applyBtnObj.GetComponentInChildren <Text>(); applyText.text = "Apply"; toggleObj.SetActive(false); applyBtnObj.SetActive(false); } }
public GameObject BuildMainRoundButtonsMenu() { GameObject go = UIFactory.CreateMainRoundButtonsMenu(this.transform.gameObject, ColorProvider.Department.RESEARCHANDDEVELOPMENT, MainMenuButtonsCount, ButtonSize, ButtonHeight, ButtonSpacing, ToplineDisplayBezelHeight, BezelHeight, true); go.transform.Find("ToplineBezel").Find("ToplineDisplayBezel").GetComponent <RectTransform>().anchoredPosition = new Vector3( (this.transform.gameObject.GetComponent <RectTransform>().sizeDelta.x - (ButtonSpacing * (MainMenuButtonsCount - 1) + ButtonSize)) / 2, 0f, 0f); go.transform.GetComponent <Image>().color = ColorProvider.GetBezelColorFromHex(ColorProvider.COLORHEXCODE_PRIMARYBEZELS); go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[0].transform.GetComponent <RoundButtonController>().DepartmentColor = ColorProvider.Department.HUMANRESOURCES; go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[0].transform.GetComponent <RoundButtonController>().setFunctionSprite(SpritesPackage.Instance.getSpriteFor(SpritesPackage.Department.HUMANRESOURCES)); go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[1].transform.GetComponent <RoundButtonController>().DepartmentColor = ColorProvider.Department.ACCOUNTING; go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[1].transform.GetComponent <RoundButtonController>().setFunctionSprite(SpritesPackage.Instance.getSpriteFor(SpritesPackage.Department.ACCOUNTING)); go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[2].transform.GetComponent <RoundButtonController>().DepartmentColor = ColorProvider.Department.SALESANDMARKETING; go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[2].transform.GetComponent <RoundButtonController>().setFunctionSprite(SpritesPackage.Instance.getSpriteFor(SpritesPackage.Department.SALESANDMARKETING)); go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[3].transform.GetComponent <RoundButtonController>().DepartmentColor = ColorProvider.Department.INFORMATINOTECHNOLOGY; go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[3].transform.GetComponent <RoundButtonController>().setFunctionSprite(SpritesPackage.Instance.getSpriteFor(SpritesPackage.Department.INFORMATINOTECHNOLOGY)); go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[4].transform.GetComponent <RoundButtonController>().DepartmentColor = ColorProvider.Department.LOGISTICS; go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[4].transform.GetComponent <RoundButtonController>().setFunctionSprite(SpritesPackage.Instance.getSpriteFor(SpritesPackage.Department.LOGISTICS)); go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[5].transform.GetComponent <RoundButtonController>().DepartmentColor = ColorProvider.Department.PROCUREMENT; go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[5].transform.GetComponent <RoundButtonController>().setFunctionSprite(SpritesPackage.Instance.getSpriteFor(SpritesPackage.Department.PROCUREMENT)); go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[6].transform.GetComponent <RoundButtonController>().DepartmentColor = ColorProvider.Department.RESEARCHANDDEVELOPMENT; go.transform.GetComponent <RoundButtonsMainMenuController>().buttonsGameObjectList[6].transform.GetComponent <RoundButtonController>().setFunctionSprite(SpritesPackage.Instance.getSpriteFor(SpritesPackage.Department.RESEARCHANDDEVELOPMENT)); return(go); }
public GameObject BuildSquareButtonsMenu(GameObject parent, int parentButtonIndex) { int buttonsCount = (int)(parent.transform.GetComponent <RectTransform>().sizeDelta.x / ButtonSize); GameObject go = UIFactory.CreateSquareButtonsMenu(parent, parent.transform.GetComponent <RoundButtonsMenuController>().buttonsGameObjectList[parentButtonIndex].transform.GetComponent <RoundButtonController>().DepartmentColor, buttonsCount, ButtonSize, ButtonHeight, ToplineDisplayBezelHeight, BezelHeight, ButtonHeight, true); go.SetActive(false); parent.transform.GetComponent <RoundButtonsMenuController>().buttonsGameObjectList[parentButtonIndex].transform.GetComponent <RoundButtonController>().SelectCallback += () => { go.SetActive(true); }; parent.transform.GetComponent <RoundButtonsMenuController>().buttonsGameObjectList[parentButtonIndex].transform.GetComponent <RoundButtonController>().UnselectCallback += () => { go.SetActive(false); }; GameObject lParent = parent; while (lParent.transform.GetComponent <RoundButtonsMenuController>() != null || lParent.transform.GetComponent <RoundButtonsMainMenuController>() != null) { if (lParent.transform.GetComponent <RoundButtonsMainMenuController>() != null) { lParent.transform.Find("ToplineBezel").Find("ToplineDisplayBezel").GetComponent <Canvas>().sortingOrder++; } else { lParent.transform.Find("ToplineDisplayBezel").GetComponent <Canvas>().sortingOrder++; } lParent = lParent.transform.parent.gameObject; } return(go); }
public virtual void StartDragging(GameObject target) { if (IsDraggable) { //StartDragging(HydraController.Instance.GetHand(m_hand)); if (!HydraController.Instance.IsHandDragging(m_hand)) { //Clone instrument here if (IsCloneable) { BaseAttachment attach = UIFactory.CreateGhostDragger(this); attach.StartDragging(HydraController.Instance.GetHand(m_hand)); } else { if (IsDragging) { StopDragging(); } SetIsDragging(true); Undock(); FixedJoint joint = gameObject.AddComponent <FixedJoint>(); joint.connectedBody = target.GetComponent <Rigidbody>(); rigidbody.isKinematic = false; HydraController.Instance.SetHandDragging(m_hand, this); } } } }
// UI construction private void ConstructUnityObjectRow() { unityObjectRow = UIFactory.CreateUIObject("UnityObjectRow", UIRoot); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(unityObjectRow, false, false, true, true, 5); UIFactory.SetLayoutElement(unityObjectRow, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999); textureButton = UIFactory.CreateButton(unityObjectRow, "TextureButton", "View Texture", new Color(0.2f, 0.2f, 0.2f)); UIFactory.SetLayoutElement(textureButton.Component.gameObject, minHeight: 25, minWidth: 150); textureButton.OnClick += ToggleTextureViewer; var nameLabel = UIFactory.CreateLabel(unityObjectRow, "NameLabel", "Name:", TextAnchor.MiddleLeft, Color.grey); UIFactory.SetLayoutElement(nameLabel.gameObject, minHeight: 25, minWidth: 45, flexibleWidth: 0); nameInput = UIFactory.CreateInputField(unityObjectRow, "NameInput", "untitled"); UIFactory.SetLayoutElement(nameInput.UIRoot, minHeight: 25, minWidth: 100, flexibleWidth: 1000); nameInput.Component.readOnly = true; gameObjectButton = UIFactory.CreateButton(unityObjectRow, "GameObjectButton", "Inspect GameObject", new Color(0.2f, 0.2f, 0.2f)); UIFactory.SetLayoutElement(gameObjectButton.Component.gameObject, minHeight: 25, minWidth: 160); gameObjectButton.OnClick += OnGameObjectButtonClicked; var instanceLabel = UIFactory.CreateLabel(unityObjectRow, "InstanceLabel", "Instance ID:", TextAnchor.MiddleRight, Color.grey); UIFactory.SetLayoutElement(instanceLabel.gameObject, minHeight: 25, minWidth: 100, flexibleWidth: 0); instanceIdInput = UIFactory.CreateInputField(unityObjectRow, "InstanceIDInput", "ERROR"); UIFactory.SetLayoutElement(instanceIdInput.UIRoot, minHeight: 25, minWidth: 100, flexibleWidth: 0); instanceIdInput.Component.readOnly = true; unityObjectRow.SetActive(false); ConstructTextureHelper(); }
public override void ConstructPanelContent() { // hide title bar this.titleBar.SetActive(false); this.UIRoot.transform.SetParent(UIManager.CanvasRoot.transform, false); var inspectContent = UIFactory.CreateVerticalGroup(this.content, "InspectContent", true, true, true, true, 3, new Vector4(2, 2, 2, 2)); UIFactory.SetLayoutElement(inspectContent, flexibleWidth: 9999, flexibleHeight: 9999); // Title text var title = UIFactory.CreateLabel(inspectContent, "InspectLabel", "<b>Mouse Inspector</b> (press <b>ESC</b> to cancel)", TextAnchor.MiddleCenter); UIFactory.SetLayoutElement(title.gameObject, flexibleWidth: 9999); mousePosLabel = UIFactory.CreateLabel(inspectContent, "MousePosLabel", "Mouse Position:", TextAnchor.MiddleCenter); objNameLabel = UIFactory.CreateLabel(inspectContent, "HitLabelObj", "No hits...", TextAnchor.MiddleLeft); objNameLabel.horizontalOverflow = HorizontalWrapMode.Overflow; objPathLabel = UIFactory.CreateLabel(inspectContent, "PathLabel", "", TextAnchor.MiddleLeft); objPathLabel.fontStyle = FontStyle.Italic; objPathLabel.horizontalOverflow = HorizontalWrapMode.Wrap; UIFactory.SetLayoutElement(objPathLabel.gameObject, minHeight: 75); UIRoot.SetActive(false); }
private void ConstructTextureHelper() { textureViewer = UIFactory.CreateVerticalGroup(UIRoot, "TextureViewer", false, false, true, true, 2, new Vector4(5, 5, 5, 5), new Color(0.1f, 0.1f, 0.1f)); UIFactory.SetLayoutElement(textureViewer, flexibleWidth: 9999, flexibleHeight: 9999); // Save helper var saveRowObj = UIFactory.CreateHorizontalGroup(textureViewer, "SaveRow", false, false, true, true, 2, new Vector4(2, 2, 2, 2), new Color(0.1f, 0.1f, 0.1f)); var saveBtn = UIFactory.CreateButton(saveRowObj, "SaveButton", "Save .PNG", new Color(0.2f, 0.25f, 0.2f)); UIFactory.SetLayoutElement(saveBtn.Component.gameObject, minHeight: 25, minWidth: 100, flexibleWidth: 0); saveBtn.OnClick += OnSaveTextureClicked; textureSavePathInput = UIFactory.CreateInputField(saveRowObj, "SaveInput", "..."); UIFactory.SetLayoutElement(textureSavePathInput.UIRoot, minHeight: 25, minWidth: 100, flexibleWidth: 9999); // Actual texture viewer var imageObj = UIFactory.CreateUIObject("TextureViewerImage", textureViewer); textureImage = imageObj.AddComponent <Image>(); textureImageLayout = textureImage.gameObject.AddComponent <LayoutElement>(); var fitter = imageObj.AddComponent <ContentSizeFitter>(); fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; textureViewer.SetActive(false); }
internal void AddReferencedInput(out InputField inputfield, string title, string description) { var groupObj = UIFactory.CreateVerticalGroup(Content, new Color(0.1f, 0.1f, 0.1f)); var group = groupObj.GetComponent <VerticalLayoutGroup>(); group.spacing = 5; group.padding = new RectOffset(4, 4, 4, 4); group.childForceExpandWidth = true; group.childForceExpandHeight = false; var titleObj = UIFactory.CreateLabel(groupObj, TextAnchor.MiddleLeft); var titleLayout = titleObj.AddComponent <LayoutElement>(); titleLayout.minHeight = 35; var titleText = titleObj.GetComponent <Text>(); titleText.text = title; var descObj = UIFactory.CreateLabel(groupObj, TextAnchor.MiddleLeft); var descLayout = descObj.AddComponent <LayoutElement>(); descLayout.minHeight = 24; var descText = descObj.GetComponent <Text>(); descText.text = description; var inputFieldObj = UIFactory.CreateInputField(groupObj); var inputLayout = inputFieldObj.AddComponent <LayoutElement>(); inputLayout.minHeight = 25; inputLayout.flexibleHeight = 0; inputfield = inputFieldObj.GetComponent <InputField>(); }
/// <summary> /// Initializes a new instance of the <see cref="SeriesSource"/> class. /// </summary> /// <param name="windowsManager">The windows manager.</param> /// <param name="chart">The chart.</param> protected SeriesSource(WindowsManager windowsManager, Chart chart) { this.chart = chart; this.windowsManager = windowsManager; UIFactory.ChartSetup(chart); }
private void SetupButtons() { backButton = UIFactory.CreateButton("Back", new Thickness(16, 8, 16, 16), UNIFORM_BUTTON_SIZE, null); //TODO: SIDNEY'S CALLBACK HERE. backButton.Padding = new Thickness(16, 4, 16, 4); backButton.HorizontalAlignment = HorizontalAlignment.Center; backButton.VerticalAlignment = VerticalAlignment.Center; backButton.HorizontalContentAlignment = HorizontalAlignment.Center; backButton.VerticalContentAlignment = VerticalAlignment.Center; Grid.SetRow(backButton, 1); Grid.SetColumn(backButton, 0); (this.Children).Add(backButton); resetButton = UIFactory.CreateButton("Reset", new Thickness(16, 8, 16, 16), UNIFORM_BUTTON_SIZE, null); //TODO: SIDNEY'S CALLBACK HERE. resetButton.Padding = new Thickness(16, 4, 16, 4); resetButton.HorizontalAlignment = HorizontalAlignment.Center; resetButton.VerticalAlignment = VerticalAlignment.Center; resetButton.HorizontalContentAlignment = HorizontalAlignment.Center; resetButton.VerticalContentAlignment = VerticalAlignment.Center; Grid.SetRow(resetButton, 1); Grid.SetColumn(resetButton, 1); (this.Children).Add(resetButton); }
private void Update() { if (NetworkManager.Instance.RoomsReady) { NetworkManager.Instance.RoomsReady = false; loadingPrivateRooms.x = -100000f; loadingPublicRooms.x = -100000f; var iPrivate = 0; var iPublic = 0; foreach (var room in NetworkManager.Instance.Rooms) { if (room.Type != NetworkManager.Instance.PlayerData.Location) { continue; } if (room.IsPublic) { var roomUIElement = UIFactory.CreateJoinPublicRoomEntryFellini(room); roomUIElement.y = iPublic * 190 + 217; roomUIElement.x = 88f; tab3.AddChild(roomUIElement); iPublic++; } else { var roomUIElement = UIFactory.CreateJoinPrivateRoomEntryFellini(room); roomUIElement.y = iPrivate * 240 + 217; roomUIElement.x = 120f; tab2.AddChild(roomUIElement); iPrivate++; } } } }
public override void ConstructSubcontent() { base.ConstructSubcontent(); if (StructInfo == null) { ExplorerCore.LogWarning("Setting up subcontent but structinfo is null"); return; } var editorContainer = UIFactory.CreateVerticalGroup(m_subContentParent, "EditorContent", false, true, true, true, 2, new Vector4(4, 4, 4, 4), new Color(0.08f, 0.08f, 0.08f)); m_inputs = new InputField[StructInfo.FieldNames.Length]; for (int i = 0; i < StructInfo.FieldNames.Length; i++) { AddEditorRow(i, editorContainer); } if (Owner.CanWrite) { var applyBtn = UIFactory.CreateButton(editorContainer, "ApplyButton", "Apply", OnSetValue, new Color(0.2f, 0.2f, 0.2f)); UIFactory.SetLayoutElement(applyBtn.gameObject, minWidth: 175, minHeight: 25, flexibleWidth: 0); void OnSetValue() { Owner.SetValue(); RefreshUIForValue(); } } }
internal void ConstructKeycodeOpt(GameObject parent) { //public KeyCode Main_Menu_Toggle = KeyCode.F7; var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0)); var rowGroup = rowObj.GetComponent <HorizontalLayoutGroup>(); rowGroup.childControlWidth = true; rowGroup.childForceExpandWidth = false; rowGroup.childControlHeight = true; rowGroup.childForceExpandHeight = true; var groupLayout = rowObj.AddComponent <LayoutElement>(); groupLayout.minHeight = 25; groupLayout.flexibleHeight = 0; groupLayout.minWidth = 200; groupLayout.flexibleWidth = 1000; var labelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft); var labelText = labelObj.GetComponent <Text>(); labelText.text = "Main Menu Toggle:"; var labelLayout = labelObj.AddComponent <LayoutElement>(); labelLayout.minWidth = 150; labelLayout.minHeight = 25; var keycodeInputObj = UIFactory.CreateInputField(rowObj); m_keycodeInput = keycodeInputObj.GetComponent <InputField>(); m_keycodeInput.text = ModConfig.Instance.Main_Menu_Toggle.ToString(); m_keycodeInput.placeholder.gameObject.GetComponent <Text>().text = "KeyCode, eg. F7"; }
public void Start(string countryId) { UIAbstractFactory UIFactory = null; if (countryId.Equals("JP")) { UIFactory = new JapaneseUIFactory(); } if (countryId.Equals("US")) { UIFactory = new USUIFactory(); } if (UIFactory != null) { Help help = UIFactory.getHelp(); WriteLine("Help for: " + help.getHelpCountry()); Images images = UIFactory.getImages(); WriteLine("UI images for: " + images.getImagesCountry()); Locale locale = UIFactory.getLocale(); WriteLine("UI locale for: " + locale.getLocaleCountry()); } else { WriteLine("Error"); } }
internal void ConstructMouseUnlockOpt(GameObject parent) { //public bool Force_Unlock_Mouse = true; var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0)); var rowGroup = rowObj.GetComponent <HorizontalLayoutGroup>(); rowGroup.childControlWidth = true; rowGroup.childForceExpandWidth = false; rowGroup.childControlHeight = true; rowGroup.childForceExpandHeight = true; var groupLayout = rowObj.AddComponent <LayoutElement>(); groupLayout.minHeight = 25; groupLayout.flexibleHeight = 0; groupLayout.minWidth = 200; groupLayout.flexibleWidth = 1000; var labelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft); var labelText = labelObj.GetComponent <Text>(); labelText.text = "Force Unlock Mouse:"; var labelLayout = labelObj.AddComponent <LayoutElement>(); labelLayout.minWidth = 150; labelLayout.minHeight = 25; UIFactory.CreateToggle(rowObj, out m_unlockMouseToggle, out Text toggleText); m_unlockMouseToggle.isOn = ModConfig.Instance.Force_Unlock_Mouse; toggleText.text = ""; }
public GameObject CreateContent(GameObject parent) { UIRoot = UIFactory.CreateUIObject("LogCell", parent, new Vector2(25, 25)); Rect = UIRoot.GetComponent <RectTransform>(); UIFactory.SetLayoutGroup <HorizontalLayoutGroup>(UIRoot, false, false, true, true, 3); UIFactory.SetLayoutElement(UIRoot, minHeight: 25, minWidth: 50, flexibleWidth: 9999); IndexLabel = UIFactory.CreateLabel(UIRoot, "IndexLabel", "i:", TextAnchor.MiddleCenter, Color.grey, false, 12); UIFactory.SetLayoutElement(IndexLabel.gameObject, minHeight: 25, minWidth: 30, flexibleWidth: 40); Input = UIFactory.CreateInputField(UIRoot, "Input", ""); //Input.Component.gameObject.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize; UIFactory.SetLayoutElement(Input.UIRoot, minHeight: 25, flexibleWidth: 9999); RuntimeProvider.Instance.SetColorBlock(Input.Component, new Color(0.1f, 0.1f, 0.1f), new Color(0.13f, 0.13f, 0.13f), new Color(0.07f, 0.07f, 0.07f)); Input.Component.GetComponent <Image>().color = new Color(0.2f, 0.2f, 0.2f); Input.Component.readOnly = true; Input.Component.textComponent.supportRichText = true; Input.Component.lineType = InputField.LineType.MultiLineNewline; Input.Component.textComponent.font = UIManager.ConsoleFont; Input.PlaceholderText.font = UIManager.ConsoleFont; return(UIRoot); }
internal void ConstructOutputPathOpt(GameObject parent) { //public string Default_Output_Path = ExplorerCore.EXPLORER_FOLDER; var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0)); var rowGroup = rowObj.GetComponent <HorizontalLayoutGroup>(); rowGroup.childControlWidth = true; rowGroup.childForceExpandWidth = false; rowGroup.childControlHeight = true; rowGroup.childForceExpandHeight = true; var groupLayout = rowObj.AddComponent <LayoutElement>(); groupLayout.minHeight = 25; groupLayout.flexibleHeight = 0; groupLayout.minWidth = 200; groupLayout.flexibleWidth = 1000; var labelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft); var labelText = labelObj.GetComponent <Text>(); labelText.text = "Default Output Path:"; var labelLayout = labelObj.AddComponent <LayoutElement>(); labelLayout.minWidth = 150; labelLayout.minHeight = 25; var inputObj = UIFactory.CreateInputField(rowObj); m_defaultOutputInput = inputObj.GetComponent <InputField>(); m_defaultOutputInput.text = ModConfig.Instance.Default_Output_Path.ToString(); m_defaultOutputInput.placeholder.gameObject.GetComponent <Text>().text = @"Directory, eg. Mods\UnityExplorer"; }
public override void ConstructSubcontent() { base.ConstructSubcontent(); m_pageHandler = new PageHandler(null); m_pageHandler.ConstructUI(m_subContentParent); m_pageHandler.OnPageChanged += OnPageTurned; m_listContent = UIFactory.CreateVerticalGroup(this.m_subContentParent, "EnumerableContent", true, true, true, true, 2, new Vector4(5, 5, 5, 5), new Color(0.08f, 0.08f, 0.08f)); var scrollRect = m_listContent.GetComponent <RectTransform>(); scrollRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0); m_listLayout = Owner.m_mainContent.GetComponent <LayoutElement>(); m_listLayout.minHeight = 25; m_listLayout.flexibleHeight = 0; Owner.m_mainRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 25); var contentFitter = m_listContent.AddComponent <ContentSizeFitter>(); contentFitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained; contentFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; }
internal void AddEditorRow(int index, GameObject groupObj) { var rowObj = UIFactory.CreateHorizontalGroup(groupObj, new Color(1, 1, 1, 0)); var rowGroup = rowObj.GetComponent <HorizontalLayoutGroup>(); rowGroup.childForceExpandHeight = true; rowGroup.childForceExpandWidth = false; rowGroup.spacing = 5; var label = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleRight); var labelLayout = label.AddComponent <LayoutElement>(); labelLayout.minWidth = 50; labelLayout.flexibleWidth = 0; labelLayout.minHeight = 25; var labelText = label.GetComponent <Text>(); labelText.text = $"{StructInfo.FieldNames[index]}:"; labelText.color = Color.cyan; var inputFieldObj = UIFactory.CreateInputField(rowObj, 14, 3, 1); var inputField = inputFieldObj.GetComponent <InputField>(); inputField.characterValidation = InputField.CharacterValidation.Decimal; var inputLayout = inputFieldObj.AddComponent <LayoutElement>(); inputLayout.flexibleWidth = 0; inputLayout.minWidth = 120; inputLayout.minHeight = 25; m_inputs[index] = inputField; inputField.onValueChanged.AddListener((string val) => { Value = StructInfo.SetValue(ref this.Value, index, float.Parse(val)); }); }
void Start () { instance = this; type = YackerType.values; if(fillGrid) { //Create Yackers at all six locations for(int x = 0; x < UIGrid.get().rows; x++) { for(int y = 0; y < UIGrid.get().cols; y++) { createAt(x,y); Debug.Log(x + ", " + y); } } } }
protected override void LoadContent() { this.MapContent = new ContentManager(this.Services); this.MapContent.RootDirectory = this.Content.RootDirectory; GeeUIMain.Font = this.Content.Load<SpriteFont>(this.Font); if (this.firstLoadContentCall) { this.firstLoadContentCall = false; if (!Directory.Exists(this.MapDirectory)) Directory.CreateDirectory(this.MapDirectory); string challengeDirectory = Path.Combine(this.MapDirectory, "Challenge"); if (!Directory.Exists(challengeDirectory)) Directory.CreateDirectory(challengeDirectory); #if VR if (this.VR) { this.vrLeftMesh.Load(this, Ovr.Eye.Left, this.vrLeftFov); this.vrRightMesh.Load(this, Ovr.Eye.Right, this.vrRightFov); new CommandBinding(this.ReloadedContent, (Action)this.vrLeftMesh.Reload); new CommandBinding(this.ReloadedContent, (Action)this.vrRightMesh.Reload); this.reallocateVrTargets(); this.vrCamera = new Camera(); this.AddComponent(this.vrCamera); } #endif this.GraphicsDevice.PresentationParameters.PresentationInterval = PresentInterval.Immediate; this.GeeUI = new GeeUIMain(); this.AddComponent(GeeUI); this.ConsoleUI = new ConsoleUI(); this.AddComponent(ConsoleUI); this.Console = new Console.Console(); this.AddComponent(Console); Lemma.Console.Console.BindType(null, this); Lemma.Console.Console.BindType(null, Console); // Initialize Wwise AkGlobalSoundEngineInitializer initializer = new AkGlobalSoundEngineInitializer(Path.Combine(this.Content.RootDirectory, "Wwise")); this.AddComponent(initializer); this.Listener = new AkListener(); this.Listener.Add(new Binding<Vector3>(this.Listener.Position, this.Camera.Position)); this.Listener.Add(new Binding<Vector3>(this.Listener.Forward, this.Camera.Forward)); this.Listener.Add(new Binding<Vector3>(this.Listener.Up, this.Camera.Up)); this.AddComponent(this.Listener); // Create the renderer. this.LightingManager = new LightingManager(); this.AddComponent(this.LightingManager); this.Renderer = new Renderer(this, true, true, true, true, true); this.AddComponent(this.Renderer); this.Renderer.ReallocateBuffers(this.ScreenSize); this.renderParameters = new RenderParameters { Camera = this.Camera, IsMainRender = true }; // Load strings this.Strings.Load(Path.Combine(this.Content.RootDirectory, "Strings.xlsx")); this.UI = new UIRenderer(); this.UI.GeeUI = this.GeeUI; this.AddComponent(this.UI); PCInput input = new PCInput(); this.AddComponent(input); Lemma.Console.Console.BindType(null, input); Lemma.Console.Console.BindType(null, UI); Lemma.Console.Console.BindType(null, Renderer); Lemma.Console.Console.BindType(null, LightingManager); input.Add(new CommandBinding(input.GetChord(new PCInput.Chord { Modifier = Keys.LeftAlt, Key = Keys.S }), delegate() { // High-resolution screenshot bool originalModelsVisible = Editor.EditorModelsVisible; Editor.EditorModelsVisible.Value = false; Screenshot s = new Screenshot(); this.AddComponent(s); s.Take(new Point(4096, 2304), delegate() { string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string path; int i = 0; do { path = Path.Combine(desktop, string.Format("lemma-screen{0}.png", i)); i++; } while (File.Exists(path)); Screenshot.SavePng(s.Buffer, path); Editor.EditorModelsVisible.Value = originalModelsVisible; s.Delete.Execute(); }); })); this.performanceMonitor = new ListContainer(); this.performanceMonitor.Add(new Binding<Vector2, Point>(performanceMonitor.Position, x => new Vector2(x.X, 0), this.ScreenSize)); this.performanceMonitor.AnchorPoint.Value = new Vector2(1, 0); this.performanceMonitor.Visible.Value = false; this.performanceMonitor.Name.Value = "PerformanceMonitor"; this.UI.Root.Children.Add(this.performanceMonitor); Action<string, Property<double>> addTimer = delegate(string label, Property<double> property) { TextElement text = new TextElement(); text.FontFile.Value = this.Font; text.Add(new Binding<string, double>(text.Text, x => label + ": " + (x * 1000.0).ToString("F") + "ms", property)); this.performanceMonitor.Children.Add(text); }; Action<string, Property<int>> addCounter = delegate(string label, Property<int> property) { TextElement text = new TextElement(); text.FontFile.Value = this.Font; text.Add(new Binding<string, int>(text.Text, x => label + ": " + x.ToString(), property)); this.performanceMonitor.Children.Add(text); }; TextElement frameRateText = new TextElement(); frameRateText.FontFile.Value = this.Font; frameRateText.Add(new Binding<string, float>(frameRateText.Text, x => "FPS: " + x.ToString("0"), this.frameRate)); this.performanceMonitor.Children.Add(frameRateText); addTimer("Physics", this.physicsTime); addTimer("Update", this.updateTime); addTimer("Render", this.renderTime); addCounter("Draw calls", this.drawCalls); addCounter("Triangles", this.triangles); addCounter("Working set", this.workingSet); Lemma.Console.Console.AddConCommand(new ConCommand("perf", "Toggle the performance monitor", delegate(ConCommand.ArgCollection args) { this.performanceMonitor.Visible.Value = !this.performanceMonitor.Visible; })); try { IEnumerable<string> globalStaticScripts = Directory.GetFiles(Path.Combine(this.Content.RootDirectory, "GlobalStaticScripts"), "*", SearchOption.AllDirectories).Select(x => Path.Combine("..\\GlobalStaticScripts", Path.GetFileNameWithoutExtension(x))); foreach (string scriptName in globalStaticScripts) this.executeStaticScript(scriptName); } catch (IOException) { } this.UIFactory = new UIFactory(); this.AddComponent(this.UIFactory); this.AddComponent(this.Menu); // Have to do this here so the menu's Awake can use all our loaded stuff this.Spawner = new Spawner(); this.AddComponent(this.Spawner); this.UI.IsMouseVisible.Value = true; AKRESULT akresult = AkBankLoader.LoadBank("SFX_Bank_01.bnk"); if (akresult != AKRESULT.AK_Success) Log.d(string.Format("Failed to load main sound bank: {0}", akresult)); #if ANALYTICS this.SessionRecorder = new Session.Recorder(this); this.SessionRecorder.Add("Position", delegate() { Entity p = PlayerFactory.Instance; if (p != null && p.Active) return p.Get<Transform>().Position; else return Vector3.Zero; }); this.SessionRecorder.Add("Health", delegate() { Entity p = PlayerFactory.Instance; if (p != null && p.Active) return p.Get<Player>().Health; else return 0.0f; }); this.SessionRecorder.Add("Framerate", delegate() { return this.frameRate; }); this.SessionRecorder.Add("WorkingSet", delegate() { return this.workingSet; }); this.AddComponent(this.SessionRecorder); this.SessionRecorder.Add(new Binding<bool, Config.RecordAnalytics>(this.SessionRecorder.EnableUpload, x => x == Config.RecordAnalytics.On, this.Settings.Analytics)); #endif this.DefaultLighting(); new SetBinding<float>(this.Settings.SoundEffectVolume, delegate(float value) { AkSoundEngine.SetRTPCValue(AK.GAME_PARAMETERS.VOLUME_SFX, MathHelper.Clamp(value, 0.0f, 1.0f)); }); new SetBinding<float>(this.Settings.MusicVolume, delegate(float value) { AkSoundEngine.SetRTPCValue(AK.GAME_PARAMETERS.VOLUME_MUSIC, MathHelper.Clamp(value, 0.0f, 1.0f)); }); new TwoWayBinding<LightingManager.DynamicShadowSetting>(this.Settings.DynamicShadows, this.LightingManager.DynamicShadows); new TwoWayBinding<float>(this.Settings.MotionBlurAmount, this.Renderer.MotionBlurAmount); new TwoWayBinding<float>(this.Settings.Gamma, this.Renderer.Gamma); new TwoWayBinding<bool>(this.Settings.Bloom, this.Renderer.EnableBloom); new TwoWayBinding<bool>(this.Settings.SSAO, this.Renderer.EnableSSAO); new Binding<float>(this.Camera.FieldOfView, this.Settings.FieldOfView); foreach (string file in Directory.GetFiles(this.MapDirectory, "*.xlsx", SearchOption.TopDirectoryOnly)) this.Strings.Load(file); new Binding<string, Config.Lang>(this.Strings.Language, x => x.ToString(), this.Settings.Language); new NotifyBinding(this.SaveSettings, this.Settings.Language); new CommandBinding(this.MapLoaded, delegate() { this.Renderer.BlurAmount.Value = 0.0f; this.Renderer.Tint.Value = new Vector3(1.0f); }); #if VR if (this.VR) { Action loadVrEffect = delegate() { this.vrEffect = this.Content.Load<Effect>("Effects\\Oculus"); }; loadVrEffect(); new CommandBinding(this.ReloadedContent, loadVrEffect); this.UI.Add(new Binding<Point>(this.UI.RenderTargetSize, this.ScreenSize)); this.VRUI = new Lemma.Components.ModelNonPostProcessed(); this.VRUI.MapContent = false; this.VRUI.DrawOrder.Value = 100000; // On top of everything this.VRUI.Filename.Value = "Models\\plane"; this.VRUI.EffectFile.Value = "Effects\\VirtualUI"; this.VRUI.Add(new Binding<Microsoft.Xna.Framework.Graphics.RenderTarget2D>(this.VRUI.GetRenderTarget2DParameter("Diffuse" + Lemma.Components.Model.SamplerPostfix), this.UI.RenderTarget)); this.VRUI.Add(new Binding<Matrix>(this.VRUI.Transform, delegate() { Matrix rot = this.Camera.RotationMatrix; Matrix mat = Matrix.Identity; mat.Forward = rot.Right; mat.Right = rot.Forward; mat.Up = rot.Up; mat *= Matrix.CreateScale(7); mat.Translation = this.Camera.Position + rot.Forward * 4.0f; return mat; }, this.Camera.Position, this.Camera.RotationMatrix)); this.AddComponent(this.VRUI); this.UI.Setup3D(this.VRUI.Transform); } #endif #if ANALYTICS bool editorLastEnabled = this.EditorEnabled; new CommandBinding<string>(this.LoadingMap, delegate(string newMap) { if (this.MapFile.Value != null && !editorLastEnabled) { this.SessionRecorder.RecordEvent("ChangedMap", newMap); if (!this.IsChallengeMap(this.MapFile) && this.MapFile.Value != Main.MenuMap) this.SaveAnalytics(); } this.SessionRecorder.Reset(); editorLastEnabled = this.EditorEnabled; }); #endif new CommandBinding<string>(this.LoadingMap, delegate(string newMap) { this.CancelScheduledSave(); }); #if !DEVELOPMENT IO.MapLoader.Load(this, MenuMap); this.Menu.Show(initial: true); #endif #if ANALYTICS if (this.Settings.Analytics.Value == Config.RecordAnalytics.Ask) { this.Menu.ShowDialog("\\analytics prompt", "\\enable analytics", delegate() { this.Settings.Analytics.Value = Config.RecordAnalytics.On; }, "\\disable analytics", delegate() { this.Settings.Analytics.Value = Config.RecordAnalytics.Off; }); } #endif #if VR if (this.oculusNotFound) this.Menu.HideMessage(null, this.Menu.ShowMessage(null, "Error: no Oculus found."), 6.0f); if (this.VR) { this.Menu.EnableInput(false); Container vrMsg = this.Menu.BuildMessage("\\vr message", 300.0f); vrMsg.AnchorPoint.Value = new Vector2(0.5f, 0.5f); vrMsg.Add(new Binding<Vector2, Point>(vrMsg.Position, x => new Vector2(x.X * 0.5f, x.Y * 0.5f), this.ScreenSize)); this.UI.Root.Children.Add(vrMsg); input.Bind(this.Settings.RecenterVRPose, PCInput.InputState.Down, this.VRHmd.RecenterPose); input.Bind(this.Settings.RecenterVRPose, PCInput.InputState.Down, delegate() { if (vrMsg != null) { vrMsg.Delete.Execute(); vrMsg = null; } this.Menu.EnableInput(true); }); } else #endif { input.Bind(this.Settings.ToggleFullscreen, PCInput.InputState.Down, delegate() { if (this.Settings.Fullscreen) // Already fullscreen. Go to windowed mode. this.ExitFullscreen(); else // In windowed mode. Go to fullscreen. this.EnterFullscreen(); }); } input.Bind(this.Settings.QuickSave, PCInput.InputState.Down, delegate() { this.SaveWithNotification(true); }); } else { this.ReloadingContent.Execute(); foreach (IGraphicsComponent c in this.graphicsComponents) c.LoadContent(true); this.ReloadedContent.Execute(); } this.GraphicsDevice.RasterizerState = new RasterizerState { MultiSampleAntiAlias = false }; if (this.spriteBatch != null) this.spriteBatch.Dispose(); this.spriteBatch = new SpriteBatch(this.GraphicsDevice); }