void AddUndoRedo(Cockpit cockpit) { HUDButton undoButton = HUDBuilder.CreateIconClickButton( new HUDShape(HUDShapeType.Disc, fDiscButtonRadius1) { Slices = 32 }, fCockpitRadiusButton, -6.5f, -50.0f, "icons/undo_v1"); //UnityUtil.TranslateInFrame(undoButton.RootGameObject, -fDiscButtonRadius1*1.1f, 0, 0, CoordSpace.WorldCoords); undoButton.Name = "undo"; undoButton.OnClicked += (o, e) => { cockpit.Scene.History.InteractiveStepBack(); }; cockpit.AddUIElement(undoButton, true); HUDButton redoButton = HUDBuilder.CreateIconClickButton( new HUDShape(HUDShapeType.Disc, fDiscButtonRadius1) { Slices = 32 }, fCockpitRadiusButton, 6.5f, -50.0f, "icons/redo_v1"); //UnityUtil.TranslateInFrame(redoButton.RootGameObject, fDiscButtonRadius1*1.1f, 0, 0, CoordSpace.WorldCoords); redoButton.Name = "redo"; redoButton.OnClicked += (o, e) => { cockpit.Scene.History.InteractiveStepForward(); }; cockpit.AddUIElement(redoButton, true); }
// creates navigation mode toggle group void AddNavModeToggleGroup(Cockpit cockpit) { float h = 25.0f; float dh = 13.0f; float v = -50.0f; float dv = 13.0f; HUDToggleButton tumbleButton = HUDBuilder.CreateToggleButton( fDiscButtonRadius1, fCockpitRadiusButton, h, v, "cockpit_icons/view_controls/bunny_enabled", "cockpit_icons/view_controls/bunny_disabled", new IconMeshGenerator() { Path = "icon_meshes/camera", Scale = 0.07f, Color = ColorUtil.make(30, 30, 30), Translate = new Vector3(0.04f, -0.07f, 0.04f), Rotate = Quaternion.AngleAxis(30.0f, Vector3.up) * Quaternion.AngleAxis(-90.0f, Vector3.right) } ); tumbleButton.Name = "tumbleNavMode"; cockpit.AddUIElement(tumbleButton, true); HUDToggleButton flyButton = HUDBuilder.CreateToggleButton( fDiscButtonRadius1, fCockpitRadiusButton, h + dh, v, "cockpit_icons/view_controls/sponza_enabled", "cockpit_icons/view_controls/sponza_disabled"); flyButton.Name = "flyNavMode"; cockpit.AddUIElement(flyButton, true); HUDToggleGroup group = new HUDToggleGroup(); group.AddButton(tumbleButton); group.AddButton(flyButton); group.Selected = 1; group.OnToggled += (sender, nSelected) => { if (nSelected == 0) { cockpit.Context.MouseCameraController = new MayaCameraHotkeys(); } else { cockpit.Context.MouseCameraController = new RateControlledEgocentricCamera(); } }; // set initial state group.Selected = 0; HUDButton resetButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, h + 0.3f * dh, v - 0.7f * dv, "icons/reset_v1"); resetButton.Name = "export"; cockpit.AddUIElement(resetButton, true); resetButton.OnClicked += (s, e) => { cockpit.Context.ResetView(true); }; }
void AddTransformToolToggleGroup(Cockpit cockpit) { float va = -42.0f; float vb = -32.0f; float vbdelta = 12.0f; HUDToggleButton widgetButton = HUDBuilder.CreateToggleButton( fDiscButtonRadius1, fCockpitRadiusButton, vb - vbdelta, va, "cockpit_icons/transform_modes/transformmode_widget_enabled_v1", "cockpit_icons/transform_modes/transformmode_widget_disabled_v1"); widgetButton.Name = "transformWidgetToggle"; cockpit.AddUIElement(widgetButton, true); HUDToggleButton snapButton = HUDBuilder.CreateToggleButton( fDiscButtonRadius1, fCockpitRadiusButton, vb, va, "cockpit_icons/transform_modes/transformmode_snap_enabled_v1", "cockpit_icons/transform_modes/transformmode_snap_disabled_v1"); snapButton.Name = "transformSnapToggle"; cockpit.AddUIElement(snapButton, true); HUDToggleButton editButton = HUDBuilder.CreateToggleButton( fDiscButtonRadius1, fCockpitRadiusButton, vb + vbdelta, va, "cockpit_icons/transform_modes/transformmode_edit_enabled_v1", "cockpit_icons/transform_modes/transformmode_edit_disabled_v1"); editButton.Name = "transformEditToggle"; cockpit.AddUIElement(editButton, true); HUDToggleGroup group = new HUDToggleGroup(); group.AddButton(widgetButton); group.AddButton(snapButton); group.AddButton(editButton); group.Selected = 0; group.OnToggled += (sender, nSelected) => { if (nSelected == 1) { cockpit.Context.TransformManager.SetActiveGizmoType("snap_drag"); } else if (nSelected == 2) { cockpit.Context.TransformManager.SetActiveGizmoType("object_edit"); } else { cockpit.Context.TransformManager.SetActiveGizmoType("default"); } }; // [TODO] remember last setting? per object? }
public void add_text_entry_field(Cockpit cockpit) { float fUseRadius = HUDRadius * 0.85f; float fAngle = -35.0f; entryField = new HUDTextEntry(); entryField.Text = GetDefaultFileName(); entryField.Width = 1.0f; entryField.Height = 0.08f; entryField.TextHeight = 0.06f; entryField.Create(); entryField.Name = "selectFileName"; HUDUtil.PlaceInSphere(entryField, fUseRadius, 0.0f, fAngle); cockpit.AddUIElement(entryField, true); tooltipText = new HUDLabel(); tooltipText.Shape = new HUDShape(HUDShapeType.Rectangle, 1.0f, 0.04f); tooltipText.Text = Tooltip; tooltipText.TextHeight = 0.03f; tooltipText.BackgroundColor = Colorf.TransparentBlack; tooltipText.TextColor = Colorf.Silver; tooltipText.Create(); tooltipText.Name = "tooltip"; HUDUtil.PlaceInSphere(tooltipText, fUseRadius, 0.0f, fAngle); UnityUtil.TranslateInFrame(tooltipText.RootGameObject, 0.0f, -entryField.Height, 0, CoordSpace.WorldCoords); cockpit.AddUIElement(tooltipText, true); HUDButton saveButton = HUDBuilder.CreateRectIconClickButton( 0.2f, 0.1f, fUseRadius, 0.0f, fAngle, "icons/save_v1"); UnityUtil.TranslateInFrame(saveButton.RootGameObject, 0.2f, -0.1f, 0, CoordSpace.WorldCoords); saveButton.Name = "save"; cockpit.AddUIElement(saveButton, true); saveButton.OnClicked += (s, e) => { SaveFromEntryText(); }; HUDButton cancelButton = HUDBuilder.CreateRectIconClickButton( 0.2f, 0.1f, fUseRadius, 0.0f, fAngle, "icons/cancel_v1"); UnityUtil.TranslateInFrame(cancelButton.RootGameObject, 0.4f, -0.1f, 0, CoordSpace.WorldCoords); cancelButton.Name = "cancel"; cockpit.AddUIElement(cancelButton, true); cancelButton.OnClicked += (s, e) => { cockpit.Context.PopCockpit(true); }; }
public static void ShowCenteredPopupMessage(string sTitleText, string sText, Cockpit cockpit) { HUDPopupMessage message = new HUDPopupMessage() { Width = 500 * cockpit.GetPixelScale(), Height = 250 * cockpit.GetPixelScale(), TitleTextHeight = 30 * cockpit.GetPixelScale(), TextHeight = 20 * cockpit.GetPixelScale(), BackgroundColor = Colorf.Silver, TextColor = Colorf.VideoBlack, TitleText = sTitleText, Text = sText }; message.Create(); if (FPlatform.IsUsingVR()) { HUDUtil.PlaceInSphere(message, 0.5f, 0, 0); } else { HUDUtil.PlaceInSphere(message, 1.5f, 0, 0); } message.Name = "popup"; cockpit.AddUIElement(message, true); message.OnDismissed += (s, e) => { AnimatedDimiss_Cockpit(message, cockpit, true); }; AnimatedShow(message); }
void BuildParameterPanel(Cockpit cockpit) { float panel_width = 500 * cockpit.GetPixelScale(); HUDParametersPanel paramPanel = new HUDParametersPanel(cockpit) { Width = panel_width, Height = panel_width, ParameterRowHeight = panel_width / 10.0f, ParametersPadding = panel_width * 0.025f, }; paramPanel.Create(); paramPanel.Name = "ParametersPanel"; cockpit.AddUIElement(paramPanel, true); paramPanel.IsVisible = true; cockpit.DefaultLayout.Add(paramPanel, new LayoutOptions() { Flags = LayoutFlags.None, PinSourcePoint2D = LayoutUtil.BoxPointF(paramPanel, BoxPosition.TopLeft), PinTargetPoint2D = LayoutUtil.BoxPointF(cockpit.DefaultLayout.BoxElement, BoxPosition.TopRight) //PinTargetPoint2D = LayoutUtil.BoxPointInterpF(cockpit.DefaultLayout.BoxElement, BoxPosition.TopRight, BoxPosition.BottomRight, 0.5f) }); //UnityUtil.TranslateInFrame(shapesButton.RootGameObject, fButtonW * 0.5f, 0, 0, CoordSpace.WorldCoords); }
public static void ShowToastStaticPopupMessage(string sImagePath, Cockpit cockpit) { Material mat = MaterialUtil.CreateTransparentImageMaterial(sImagePath); float fAspect = (float)mat.mainTexture.width / (float)mat.mainTexture.height; float fScale = 2.0f; // should this be a parameter?? HUDPopupMessage message = new HUDPopupMessage() { Shape = new HUDShape() { Type = HUDShapeType.Rectangle, Width = fScale * 1.0f, Height = fScale * 1.0f / fAspect, UseUVSubRegion = false } }; message.Create(mat); HUDUtil.PlaceInSphere(message, 3.0f, 30, -10); UnityUtil.TranslateInFrame(message.RootGameObject, 0.75f, -0.5f, 0.0f, CoordSpace.WorldCoords); message.Name = "popup"; cockpit.AddUIElement(message, true); message.OnDismissed += (s, e) => { AnimatedDimiss_Cockpit(message, cockpit); }; AnimatedShow(message, 0.5f); }
public void Initialize(Cockpit cockpit) { Frame3 cockpitF = cockpit.GetLocalFrame(CoordSpace.WorldCoords); float fHUDRadius = 0.7f; Color bgColor = new Color(0.7f, 0.7f, 1.0f); Material bgMaterial = MaterialUtil.CreateTransparentMaterial(bgColor, 0.7f); Material primMaterial = MaterialUtil.CreateStandardMaterial(Color.yellow); HUDButton addCylinderButton = new HUDButton() { Radius = 0.08f }; addCylinderButton.Create(PrimitiveType.Cylinder, bgMaterial, primMaterial); Frame3 cylFrame = addCylinderButton.GetObjectFrame(); Frame3 cylHUDFrame = make_hud_sphere_frame(fHUDRadius, -45.0f, 0.0f); addCylinderButton.SetObjectFrame( cylFrame.Translated(cylHUDFrame.Origin) .Rotated(Quaternion.FromToRotation(cylFrame.Z, cylHUDFrame.Z))); addCylinderButton.OnClicked += (s, e) => { cockpit.Parent.Scene.AddCylinder(); }; cockpit.AddUIElement(addCylinderButton, true); HUDButton addBoxButton = new HUDButton() { Radius = 0.08f }; addBoxButton.Create(PrimitiveType.Cube, bgMaterial, primMaterial); Frame3 boxFrame = addBoxButton.GetObjectFrame(); Frame3 boxHUDFrame = make_hud_sphere_frame(fHUDRadius, -45.0f, -15.0f); addBoxButton.SetObjectFrame( boxFrame.Translated(boxHUDFrame.Origin) .Rotated(Quaternion.FromToRotation(boxFrame.Z, boxHUDFrame.Z))); addBoxButton.OnClicked += (s, e) => { cockpit.Parent.Scene.AddBox(); }; cockpit.AddUIElement(addBoxButton, true); }
// creates world/local frame toggle buttons, that are grouped so clicking // one disables the other. Connect up to TransformManager for events/etc. void AddFrameToggleGroup(Cockpit cockpit) { HUDToggleButton worldButton = HUDBuilder.CreateToggleButton( fDiscButtonRadius1, fCockpitRadiusButton, -38.0f, -50.0f, "icons/frame_world_enabled", "icons/frame_world_disabled", new IconMeshGenerator() { Path = "icon_meshes/axis_frame", Scale = 0.08f, Translate = new Vector3(0.06f, -0.06f, 0.05f), Color = ColorUtil.ForestGreen } ); worldButton.Name = "worldFrameToggle"; cockpit.AddUIElement(worldButton, true); HUDToggleButton localButton = HUDBuilder.CreateToggleButton( fDiscButtonRadius1, fCockpitRadiusButton, -25.0f, -50.0f, "icons/frame_local_enabled", "icons/frame_local_disabled"); localButton.Name = "localFrameToggle"; cockpit.AddUIElement(localButton, true); HUDToggleGroup group = new HUDToggleGroup(); group.AddButton(worldButton); group.AddButton(localButton); group.Selected = 1; group.OnToggled += (sender, nSelected) => { FrameType eSetType = (nSelected == 0) ? FrameType.WorldFrame : FrameType.LocalFrame; cockpit.Context.TransformManager.ActiveFrameType = eSetType; }; cockpit.Context.TransformManager.OnActiveGizmoModified += (s, e) => { FrameType eSet = cockpit.Context.TransformManager.ActiveFrameType; group.Selected = (eSet == FrameType.WorldFrame) ? 0 : 1; }; // set initial state FrameType eInitial = cockpit.Context.TransformManager.ActiveFrameType; group.Selected = (eInitial == FrameType.WorldFrame) ? 0 : 1; }
void add(HUDStandardItem element, LayoutOptions options) { if (element.IsVisible == false) { element.IsVisible = true; } IBoxModelElement elemBoxModel = element as IBoxModelElement; // for 2D view (but doesn't matter if we are doing a layout anyway!) Frame3f viewFrame = Cockpit.GetViewFrame2D(); // with 3D view we should use this... //Frame3f viewFrame = Frame3f.Identity; element.SetObjectFrame(Frame3f.Identity); HUDUtil.PlaceInViewPlane(element, viewFrame); Cockpit.AddUIElement(element); Func <Vector2f> pinSourceF = options.PinSourcePoint2D; if (pinSourceF == null) { pinSourceF = LayoutUtil.BoxPointF(elemBoxModel, BoxPosition.Center); } Func <Vector2f> pinTargetF = options.PinTargetPoint2D; if (pinTargetF == null) { pinTargetF = LayoutUtil.BoxPointF(Solver.Container, BoxPosition.Center); } Solver.AddLayoutItem(element, pinSourceF, pinTargetF, this.StandardDepth + options.DepthShift); // if we want to shift result in its layout frame, do that via a post-transform if (options.FrameAxesShift != Vector3f.Zero) { Solver.AddPostTransform(element, (e) => { Frame3f f = (e as IElementFrame).GetObjectFrame(); f.Translate(options.FrameAxesShift.x * f.X + options.FrameAxesShift.y * f.Y + options.FrameAxesShift.z * f.Z); (e as IElementFrame).SetObjectFrame(f); }); } // auto-show if ((options.Flags & LayoutFlags.AnimatedShow) != 0) { HUDUtil.AnimatedShow(element); } }
void add(HUDStandardItem element, LayoutOptions options) { if (element.IsVisible == false) { element.IsVisible = true; } IBoxModelElement elemBoxModel = element as IBoxModelElement; // for 2D view (but doesn't matter if we are doing a layout anyway!) Frame3f viewFrame = Cockpit.GetViewFrame2D(); // with 3D view we should use this... //Frame3f viewFrame = Frame3f.Identity; element.SetObjectFrame(Frame3f.Identity); HUDUtil.PlaceInViewPlane(element, viewFrame); Cockpit.AddUIElement(element); Func <Vector2f> pinSourceF = options.PinSourcePoint2D; if (pinSourceF == null) { pinSourceF = LayoutUtil.BoxPointF(elemBoxModel, BoxPosition.Center); } Func <Vector2f> pinTargetF = options.PinTargetPoint2D; if (pinTargetF == null) { pinTargetF = LayoutUtil.BoxPointF(Solver.Container, BoxPosition.Center); } Solver.AddLayoutItem(element, pinSourceF, pinTargetF, this.StandardDepth + options.DepthShift); // auto-show if ((options.Flags & LayoutFlags.AnimatedShow) != 0) { HUDUtil.AnimatedShow(element); } }
public static void ShowToastPopupMessage(string sText, Cockpit cockpit, float heightScale = 1.0f, float textScale = 1.0f) { // [TODO] should size based on VR or not-VR...for VR use visual radius? HUDPopupMessage message = new HUDPopupMessage() { Width = 500 * cockpit.GetPixelScale(), Height = heightScale * 150 * cockpit.GetPixelScale(), TextHeight = textScale * 50 * cockpit.GetPixelScale(), BackgroundColor = Colorf.DarkYellow, TextColor = Colorf.VideoBlack, Text = sText }; message.Create(); HUDUtil.PlaceInSphere(message, 1.0f, 30, -30); message.Name = "popup"; cockpit.AddUIElement(message, true); message.OnDismissed += (s, e) => { AnimatedDimiss_Cockpit(message, cockpit, true); }; AnimatedShow(message, 0.5f); }
HUDToggleGroup BuildPanels(Cockpit cockpit) { float vx = -50.0f; float vy = 10.0f; float fButtonW = fDiscButtonRadius1; HUDPrimitivesPanel primPanel = new HUDPrimitivesPanel(); primPanel.Create(cockpit); primPanel.Name = "PrimitivesPanel"; cockpit.AddUIElement(primPanel, true); HUDToolsPanel toolPanel = new HUDToolsPanel(); toolPanel.Create(cockpit); toolPanel.Name = "ToolPanel"; cockpit.AddUIElement(toolPanel, true); toolPanel.IsVisible = false; HUDMaterialsPanel matPanel = new HUDMaterialsPanel(); matPanel.Create(cockpit); matPanel.Name = "MaterialPanel"; cockpit.AddUIElement(matPanel, true); matPanel.IsVisible = false; float fIconAspect = 1.25f; HUDToggleButton materialsButton = HUDBuilder.CreateToggleButton( new HUDShape(HUDShapeType.Rectangle, fButtonW, fButtonW / fIconAspect) { UseUVSubRegion = true }, fCockpitRadiusButton, vx, vy, "panel_tabs/materials_active_v1", "panel_tabs/materials_inactive_v1"); UnityUtil.TranslateInFrame(materialsButton.RootGameObject, -fButtonW * 1.5f, 0, 0, CoordSpace.WorldCoords); materialsButton.Name = "toggleMaterials"; cockpit.AddUIElement(materialsButton, true); HUDToggleButton toolsButton = HUDBuilder.CreateToggleButton( new HUDShape(HUDShapeType.Rectangle, fButtonW, fButtonW / fIconAspect) { UseUVSubRegion = true }, fCockpitRadiusButton, vx, vy, "panel_tabs/tools_active_v1", "panel_tabs/tools_inactive_v1"); UnityUtil.TranslateInFrame(toolsButton.RootGameObject, -fButtonW * 0.5f, 0, 0, CoordSpace.WorldCoords); toolsButton.Name = "toggleTools"; cockpit.AddUIElement(toolsButton, true); HUDToggleButton shapesButton = HUDBuilder.CreateToggleButton( new HUDShape(HUDShapeType.Rectangle, fButtonW, fButtonW / fIconAspect) { UseUVSubRegion = true }, fCockpitRadiusButton, vx, vy, "panel_tabs/shapes_active_v1", "panel_tabs/shapes_inactive_v1"); UnityUtil.TranslateInFrame(shapesButton.RootGameObject, fButtonW * 0.5f, 0, 0, CoordSpace.WorldCoords); shapesButton.Name = "toggleShapes"; cockpit.AddUIElement(shapesButton, true); HUDToggleGroup group = new HUDToggleGroup(); group.AddButton(shapesButton); group.AddButton(toolsButton); group.AddButton(materialsButton); group.Selected = 0; group.OnToggled += (sender, nSelected) => { if (nSelected == 0) { matPanel.IsVisible = toolPanel.IsVisible = false; primPanel.IsVisible = true; } else if (nSelected == 1) { primPanel.IsVisible = matPanel.IsVisible = false; toolPanel.IsVisible = true; } else { primPanel.IsVisible = toolPanel.IsVisible = false; matPanel.IsVisible = true; } }; return(group); }
void AddMenuButtonsGroup(Cockpit cockpit) { HUDButton importButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, //0.1f, 0.05f, 0.7f, 5.0f, -5.0f, // for debugging "icons/import_v1"); importButton.Name = "import"; cockpit.AddUIElement(importButton, true); importButton.OnClicked += (s, e) => { var cp = new FileImportCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; cockpit.Context.PushCockpit(cp); }; HUDButton exportButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, //0.1f, 0.05f, 0.7f, 5.0f, -5.0f, // for debugging convenience "icons/export_v1"); UnityUtil.TranslateInFrame(exportButton.RootGameObject, 0, -0.055f, 0, CoordSpace.WorldCoords); exportButton.Name = "export"; cockpit.AddUIElement(exportButton, true); exportButton.OnClicked += (s, e) => { var cp = new FileExportCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; cockpit.Context.PushCockpit(cp); }; HUDButton janusButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, //0.1f, 0.05f, 0.7f, 5.0f, -5.0f, // for debugging convenience "cockpit_icons/menu_buttons/janus_v1"); UnityUtil.TranslateInFrame(janusButton.RootGameObject, 0, 2.0f * -0.055f, 0, CoordSpace.WorldCoords); janusButton.Name = "export"; cockpit.AddUIElement(janusButton, true); janusButton.OnClicked += (s, e) => { var cp = new JanusVRExportCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; cockpit.Context.PushCockpit(cp); }; HUDButton loadButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, // 0.1f, 0.05f, 0.7f, 5.0f, -5.0f, // for debugging convenience "icons/load_v1"); UnityUtil.TranslateInFrame(loadButton.RootGameObject, 0.12f, 0, 0, CoordSpace.WorldCoords); loadButton.Name = "load"; cockpit.AddUIElement(loadButton, true); loadButton.OnClicked += (s, e) => { var cp = new FileLoadSceneCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; cockpit.Context.PushCockpit(cp); }; HUDButton saveButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, // 0.1f, 0.05f, 0.7f, 5.0f, -5.0f, // for debugging "icons/save_v1"); UnityUtil.TranslateInFrame(saveButton.RootGameObject, 0.12f, -0.055f, 0, CoordSpace.WorldCoords); saveButton.Name = "save"; cockpit.AddUIElement(saveButton, true); saveButton.OnClicked += (s, e) => { var cp = new FileSaveSceneCockpit() { InitialPath = SceneGraphConfig.LastFileOpenPath }; cockpit.Context.PushCockpit(cp); }; HUDButton newButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, "icons/new_v1"); UnityUtil.TranslateInFrame(newButton.RootGameObject, 0.24f, 0, 0, CoordSpace.WorldCoords); newButton.Name = "new"; cockpit.AddUIElement(newButton, true); newButton.OnClicked += (s, e) => { cockpit.Context.NewScene(true); }; HUDButton quitButton = HUDBuilder.CreateRectIconClickButton( 0.1f, 0.05f, 0.7f, 55.0f, -50.0f, "icons/quit_v1"); UnityUtil.TranslateInFrame(quitButton.RootGameObject, 0.24f, -0.055f, 0, CoordSpace.WorldCoords); quitButton.Name = "quit"; cockpit.AddUIElement(quitButton, true); quitButton.OnClicked += (s, e) => { FPlatform.QuitApplication(); }; }
public void Initialize(Cockpit cockpit, float fCockpitRadius) { activeCockpit = cockpit; activeCockpit.PositionMode = Cockpit.MovementMode.Static; activeCockpit.GrabFocus = true; activeHUDRadius = fCockpitRadius; string[] files, folders; try { files = Source.GetFiles(FolderPath); folders = Source.GetFolders(FolderPath); } catch (Exception e) { Debug.Log("[CurrentFolderList.Initialize] exception! " + e.Message); return; } float fMinHorz = -45.0f, fMaxHorz = 45.0f; float fStartVert = 15.0f; float fTop = HUDUtil.GetSphereFrame(fCockpitRadius, 0.0f, fStartVert).Origin.y; int folderi = 0, filei = 0; Mesh folderMesh = Resources.Load <Mesh>("icon_meshes/folder_v1"); Color folderColor = ColorUtil.make(241, 213, 146); Color inaccessibleFolderColor = ColorUtil.make(100, 100, 100); Mesh fileMesh = Resources.Load <Mesh>("icon_meshes/file_v1"); Color fileColor = ColorUtil.make(250, 250, 250); // [TODO] something wrong here, icons are loading backwards...?? Quaternion meshRotation = Quaternion.AngleAxis(270.0f, Vector3.right) * Quaternion.AngleAxis(180.0f + 25.0f, Vector3.forward); float meshScale = IconSize * 0.9f; HUDCylinder hudSurf = new HUDCylinder() { Radius = fCockpitRadius, VerticalCoordIsAngle = false }; float fStepH = VRUtil.HorizontalStepAngle(fCockpitRadius, 0, IconSize + IconPadding); int nStepsHorz = (int)((fMaxHorz - fMinHorz) / fStepH); fMinHorz = -(nStepsHorz * fStepH * 0.5f); fMaxHorz = (nStepsHorz * fStepH * 0.5f); float fStepV = IconSize + IconPadding; IconCollection = new HUDCollection(); IconCollection.Create(); bool bDone = false; int yi = 0; while (!bDone) { float fCurV = fTop - yi * fStepV; yi++; for (int xi = 0; xi < nStepsHorz && bDone == false; ++xi) { float fCurH = fMinHorz + ((float)xi + 0.5f) * fStepH; string name = "x"; fMesh useMesh = null; Color useColor = Color.white; bool bAccessible = true; bool bIsFile = false; if (folderi < folders.Length) { name = folders[folderi++]; useMesh = new fMesh(UnityEngine.Object.Instantiate <Mesh>(folderMesh)); useColor = folderColor; if (Source.FilterInaccessibleFolders == false && FileSystemUtils.CanAccessFolder(Path.Combine(FolderPath, name)) == false) { bAccessible = false; useColor = inaccessibleFolderColor; } } else if (filei < files.Length) { name = files[filei++]; useMesh = new fMesh(UnityEngine.Object.Instantiate <Mesh>(fileMesh)); useColor = fileColor; bIsFile = true; } else { bDone = true; break; } //useColor.a = 0.999f; // [RMS] can use this to force into alpha pass string displayName = name; if (displayName.Length > 12) { displayName = name.Substring(0, 12) + "..."; } //float TextScale = 0.01f, ShiftX = -IconSize * 0.5f; float TextScale = 0.005f, ShiftX = -IconSize * 0.5f; HUDButton iconButton = HUDBuilder.CreateMeshClickButton( useMesh, useColor, meshScale, meshRotation, hudSurf, fCurH, fCurV, new TextLabelGenerator() { Text = displayName, Scale = TextScale, Translate = new Vector3(ShiftX, 0.0f, 0.0f) }); iconButton.Name = name; //cockpit.AddUIElement(iconButton, true); IconCollection.AddChild(iconButton); if (bIsFile) { iconButton.OnClicked += (o, e) => { if (this.OnFileClicked != null) { this.OnFileClicked(name); } }; } if (bAccessible) { iconButton.OnDoubleClicked += IconButton_DoubleClick; } } } cockpit.AddUIElement(IconCollection, true); fCurMaxScroll = Mathf.Max(0, (yi - 4) * fStepV); }
public void Initialize(Cockpit cockpit) { cockpit.Name = "splashCockpit"; cockpit.DefaultCursorDepth = 3.0f; cockpit.PositionMode = Cockpit.MovementMode.Static; // create black sphere around camera to hide existing scene fGameObject blackBackground = new fGameObject( UnityUtil.CreateMeshGO("background_delete", "icon_meshes/inverted_sphere_tiny", 1.0f, UnityUtil.MeshAlignOption.AllAxesCentered, MaterialUtil.CreateFlatMaterial(Color.black), false)); // add as bounds object to do mouse hit-test cockpit.Context.Scene.AddWorldBoundsObject(blackBackground); // re-parent from Scene so the sphere tracks the camera cockpit.FixedCameraTrackingGO.AddChild(blackBackground, false); HUDButton title = HUDBuilder.CreateIconClickButton( new HUDShape(HUDShapeType.Rectangle, 2.0f, 0.8f), 3.0f, 0.0f, 2.5f, "simplex_startup/simplex_v2"); title.Name = "title"; title.Enabled = false; cockpit.AddUIElement(title, true); HUDButton start = HUDBuilder.CreateIconClickButton( new HUDShape(HUDShapeType.Rectangle, 0.5f, 0.25f), 3.0f, 8.0f, -10, "simplex_startup/start_v1"); start.Name = "start"; start.OnClicked += (s, e) => { cockpit.ActiveCamera.Animator().DoActionDuringDipToBlack(() => { cockpit.Context.Scene.RemoveWorldBoundsObject(blackBackground); UnityEngine.GameObject.Destroy(blackBackground); cockpit.Context.PushCockpit( new SetupCADCockpit_V1()); }, 1.0f); }; cockpit.AddUIElement(start, true); HUDButton quit = HUDBuilder.CreateIconClickButton( new HUDShape(HUDShapeType.Rectangle, 0.5f, 0.25f), 3.0f, -8.0f, -10, "simplex_startup/quit_v1"); quit.Name = "quit"; quit.OnClicked += (s, e) => { FPlatform.QuitApplication(); }; cockpit.AddUIElement(quit, true); HUDButton logo = HUDBuilder.CreateIconClickButton( new HUDShape(HUDShapeType.Rectangle, 0.8f, 0.2f), 3.0f, 0.0f, -25.0f, "simplex_startup/gradientspace_splash"); logo.Name = "logo"; logo.Enabled = false; cockpit.AddUIElement(logo, true); HUDButton about_arrow = HUDBuilder.CreateIconClickButton( new HUDShape(HUDShapeType.Rectangle, 0.75f, 0.75f), 3.0f, -30.0f, -10.0f, "simplex_startup/about_arrow"); about_arrow.Name = "about_arrow"; about_arrow.Enabled = false; cockpit.AddUIElement(about_arrow, true); float about_text_scale = 3.0f; float angle_left = -65.0f; HUDButton about_text = HUDBuilder.CreateIconClickButton( new HUDShape(HUDShapeType.Rectangle, 0.8f * about_text_scale, 1.0f * about_text_scale) { UseUVSubRegion = false }, 3.0f, angle_left, 0.0f, "simplex_startup/about_text"); UnityUtil.TranslateInFrame(about_text.RootGameObject, 0.0f, -0.5f, 0, CoordSpace.WorldCoords); about_text.Name = "about_text"; about_text.Enabled = false; cockpit.AddUIElement(about_text, true); HUDButton controls_arrow = HUDBuilder.CreateIconClickButton( new HUDShape(HUDShapeType.Rectangle, 0.75f, 0.75f), 3.0f, 30.0f, -10.0f, "simplex_startup/controls_arrow"); controls_arrow.Name = "controls_arrow"; controls_arrow.Enabled = false; cockpit.AddUIElement(controls_arrow, true); float text_scale = 3.0f; float angle_right = 65.0f; HUDButton controls_mouse = HUDBuilder.CreateIconClickButton( new HUDShape(HUDShapeType.Rectangle, 0.7f * text_scale, 0.7f * text_scale) { UseUVSubRegion = false }, 3.0f, angle_right, 0.0f, "simplex_startup/controls_mouse"); UnityUtil.TranslateInFrame(controls_mouse.RootGameObject, 0.25f, 0.1f, 0, CoordSpace.WorldCoords); controls_mouse.Name = "controls_mouse"; controls_mouse.Enabled = false; cockpit.AddUIElement(controls_mouse, true); HUDButton controls_gamepad = HUDBuilder.CreateIconClickButton( new HUDShape(HUDShapeType.Rectangle, 0.7f * text_scale, 0.7f * text_scale) { UseUVSubRegion = false }, 3.0f, angle_right, 0.0f, "simplex_startup/controls_gamepad"); UnityUtil.TranslateInFrame(controls_gamepad.RootGameObject, 0.25f, 0.1f, 0, CoordSpace.WorldCoords); controls_gamepad.Name = "controls_gamepad"; controls_gamepad.Enabled = false; cockpit.AddUIElement(controls_gamepad, true); controls_gamepad.RootGameObject.Hide(); HUDToggleButton mouse_button = HUDBuilder.CreateToggleButton( new HUDShape(HUDShapeType.Rectangle, 1.0f, 1.0f), 2.9f, angle_right, 0.0f, "simplex_startup/mouse", "simplex_startup/mouse_disabled"); UnityUtil.TranslateInFrame(mouse_button.RootGameObject, -0.5f, -1.0f, 0, CoordSpace.WorldCoords); mouse_button.Name = "mouse_button"; cockpit.AddUIElement(mouse_button, true); HUDToggleButton gamepad_button = HUDBuilder.CreateToggleButton( new HUDShape(HUDShapeType.Rectangle, 1.0f, 1.0f), 2.9f, angle_right, 0.0f, "simplex_startup/gamepad_with_labels", "simplex_startup/gamepad_disabled"); UnityUtil.TranslateInFrame(gamepad_button.RootGameObject, 0.5f, -1.0f, 0, CoordSpace.WorldCoords); gamepad_button.Name = "gamepad_button"; cockpit.AddUIElement(gamepad_button, true); HUDToggleGroup group = new HUDToggleGroup(); group.AddButton(mouse_button); group.AddButton(gamepad_button); group.Selected = 0; group.OnToggled += (sender, nSelected) => { if (nSelected == 0) { controls_gamepad.RootGameObject.Hide(); controls_mouse.RootGameObject.Show(); } else { controls_gamepad.RootGameObject.Show(); controls_mouse.RootGameObject.Hide(); } }; // setup key handlers (need to move to behavior...) cockpit.AddKeyHandler(new SplashScreenKeyHandler(cockpit.Context)); cockpit.InputBehaviors.Add(new VRMouseUIBehavior(cockpit.Context) { Priority = 0 }); cockpit.InputBehaviors.Add(new VRGamepadUIBehavior(cockpit.Context) { Priority = 0 }); cockpit.InputBehaviors.Add(new VRSpatialDeviceUIBehavior(cockpit.Context) { Priority = 0 }); }