Example #1
0
        public static void NewFrame(ImVec2 size, ImVec2 scale, ImVec2 mousePosition, uint mouseMask, ref float mouseWheel, bool[] mousePressed, ref double g_Time)
        {
            ImGuiIO io = ImGui.GetIO();

            io.DisplaySize             = size;
            io.DisplayFramebufferScale = scale;

            double currentTime = SDL.SDL_GetTicks() / 1000D;

            io.DeltaTime = g_Time > 0D ? (float)(currentTime - g_Time) : (1f / 60f);
            g_Time       = currentTime;

            io.MousePosition = mousePosition;

            io.MouseDown[0] = mousePressed[0] || (mouseMask & SDL.SDL_BUTTON(SDL.SDL_BUTTON_LEFT)) != 0;
            io.MouseDown[1] = mousePressed[1] || (mouseMask & SDL.SDL_BUTTON(SDL.SDL_BUTTON_RIGHT)) != 0;
            io.MouseDown[2] = mousePressed[2] || (mouseMask & SDL.SDL_BUTTON(SDL.SDL_BUTTON_MIDDLE)) != 0;
            mousePressed[0] = mousePressed[1] = mousePressed[2] = false;

            io.MouseWheel = mouseWheel;
            mouseWheel    = 0f;

            SDL.SDL_ShowCursor(io.MouseDrawCursor ? 0 : 1);

            ImGui.NewFrame();
        }
Example #2
0
        public Vector4 MouseWorldCoordinate()
        {
            ImVec2 mouseCoord = ImGui.GetMousePos();
            double x          = ((mouseCoord.x - ViewPortCenter.x) / ZoomLevel) - CameraWorldPosition.X;
            double y          = -(((mouseCoord.y - ViewPortCenter.y) / ZoomLevel) - CameraWorldPosition.Y);

            return(new Vector4(x, y, 0, 0));
        }
Example #3
0
 public static void Render(ImVec2 size)
 {
     ImGui.Render();
     if (ImGui.IO.RenderDrawListsFn == IntPtr.Zero)
     {
         RenderDrawData(ImGui.GetDrawData(), (int)Math.Round(size.X), (int)Math.Round(size.Y));
     }
 }
Example #4
0
        /// <summary>
        /// Returns the translation matrix for a world position, relative to the camera position
        /// </summary>
        /// <param name="position">Position in World Units</param>
        /// <returns></returns>
        public Matrix GetViewProjectionMatrix(ImVec2 position)
        {
            var    transformMatrix = new Matrix();
            double x = CameraWorldPosition.X + position.x;
            double y = CameraWorldPosition.Y + position.y;

            transformMatrix.Translate(x, y);  //ViewCoordinate(x, y));
            return(transformMatrix);
        }
Example #5
0
        void TargetSelected()
        {
            TargetEntity = _state.LastClickedEntity;

            _state.Camera.PinToEntity(TargetEntity.Entity);

            var soiWorldRad_AU = GMath.GetSOI(TargetEntity.Entity);

            _apMax = soiWorldRad_AU;

            float soiViewUnits = _state.Camera.ViewDistance(soiWorldRad_AU);

            ImVec2 viewPortSize = _state.Camera.ViewPortSize;
            float  windowLen    = Math.Min(viewPortSize.x, viewPortSize.y);

            if (soiViewUnits < windowLen * 0.5)
            {
                //zoom so soi fills ~3/4 screen.
                var soilenwanted = windowLen * 0.375;
                _state.Camera.ZoomLevel = (float)(soilenwanted / _apMax);
            }


            if (_orbitWidget != null)
            {
                int index = _state.MapRendering.UIWidgets.IndexOf(_orbitWidget);
                _orbitWidget = new OrbitOrderWiget(TargetEntity.Entity);
                if (index != -1)
                {
                    _state.MapRendering.UIWidgets[index] = _orbitWidget;
                }
                else
                {
                    _state.MapRendering.UIWidgets.Add(_orbitWidget);
                }
            }
            else
            {
                _orbitWidget = new OrbitOrderWiget(TargetEntity.Entity);
                _state.MapRendering.UIWidgets.Add(_orbitWidget);
            }
            if (_moveWidget == null)
            {
                _moveWidget = new TranslateMoveOrderWidget(_state, OrderingEntity.Entity);
                _state.MapRendering.UIWidgets.Add(_moveWidget);
            }

            _moveWidget.SetArrivalTarget(TargetEntity.Entity);

            _targetRadius = TargetEntity.Entity.GetDataBlob <MassVolumeDB>().RadiusInKM;
            //_intercept = InterceptCalcs.FTLIntercept(OrderingEntity.Entity, TargetEntity.Entity.GetDataBlob<OrbitDB>(), TargetEntity.Entity.Manager.ManagerSubpulses.SystemLocalDateTime);
            //_intercept = InterceptCalcs.GetInterceptPosition(OrderingEntity.Entity, TargetEntity.Entity.GetDataBlob<OrbitDB>(), _state.CurrentSystemDateTime);
            _tooltipText = "Select Insertion Point";
            CurrentState = States.NeedsInsertionPoint;
        }
Example #6
0
        public static NameIcon operator +(NameIcon nameIcon, SDL.SDL_Point point)
        {
            ImVec2 newpoint = new ImVec2()
            {
                x = nameIcon.ViewOffset.x + point.x,
                y = nameIcon.ViewOffset.y + point.y
            };

            nameIcon.ViewOffset = newpoint;

            return(nameIcon);
        }
Example #7
0
        public override void OnFrameUpdate(Matrix matrix, Camera camera)
        {
            //DefaultViewOffset = new SDL.SDL_Point() { x = Width, y = -Height };

            ImVec2 defualtOffset = new ImVec2(4, -(Height / 2));

            ViewOffset = defualtOffset;
            base.OnFrameUpdate(matrix, camera);

            ViewDisplayRect.X = ViewScreenPos.x;
            ViewDisplayRect.Y = ViewScreenPos.y;
        }
Example #8
0
        //~ImFont();

        void Clear()
        {
            FontSize        = 0.0f;
            DisplayOffset   = new ImVec2(0.0f, 1.0f);
            ConfigData      = null;
            ConfigDataCount = 0;
            Ascent          = Descent = 0.0f;
            ContainerAtlas  = null;
            Glyphs.clear();
            FallbackGlyph    = null;
            FallbackXAdvance = 0.0f;
            IndexXAdvance.clear();
            IndexLookup.clear();
        }
Example #9
0
        internal int FocusIdxTabRequestNext;             // "

        internal ImGuiWindow(string name)
        {
            DC           = new ImGuiDrawContext();
            IDStack      = new ImVector <uint>();
            StateStorage = new ImGuiStorage();
            MenuColumns  = new ImGuiSimpleColumns();
            DrawList     = new ImDrawList();

            Name = name;

            ID = ImGui.Hash(0, name);
            IDStack.push_back(ID);
            MoveID = GetID("#MOVE");

            Flags                    = 0;
            PosFloat                 = Pos = new ImVec2(0.0f, 0.0f);
            Size                     = SizeFull = new ImVec2(0.0f, 0.0f);
            SizeContents             = SizeContentsExplicit = new ImVec2(0.0f, 0.0f);
            WindowPadding            = new ImVec2(0.0f, 0.0f);
            Scroll                   = new ImVec2(0.0f, 0.0f);
            ScrollTarget             = new ImVec2(float.MaxValue, float.MaxValue);
            ScrollTargetCenterRatio  = new ImVec2(0.5f, 0.5f);
            ScrollbarX               = ScrollbarY = false;
            ScrollbarSizes           = new ImVec2(0.0f, 0.0f);
            BorderSize               = 0.0f;
            Active                   = WasActive = false;
            Accessed                 = false;
            Collapsed                = false;
            SkipItems                = false;
            BeginCount               = 0;
            PopupID                  = 0;
            AutoFitFramesX           = AutoFitFramesY = -1;
            AutoFitOnlyGrows         = false;
            AutoPosLastDirection     = -1;
            HiddenFrames             = 0;
            SetWindowPosAllowFlags   = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = (int)(ImGuiSetCond.ImGuiSetCond_Always | ImGuiSetCond.ImGuiSetCond_Once | ImGuiSetCond.ImGuiSetCond_FirstUseEver | ImGuiSetCond.ImGuiSetCond_Appearing);
            SetWindowPosCenterWanted = false;

            LastFrameActive  = -1;
            ItemWidthDefault = 0.0f;
            FontWindowScale  = 1.0f;

            RootWindow         = null;
            RootNonPopupWindow = null;

            FocusIdxAllCounter        = FocusIdxTabCounter = -1;
            FocusIdxAllRequestCurrent = FocusIdxTabRequestCurrent = int.MaxValue;
            FocusIdxAllRequestNext    = FocusIdxTabRequestNext = int.MaxValue;
        }
Example #10
0
        internal override void Display()
        {
            if (IsActive)
            {
                ImVec2 size = new ImVec2(200, 100);
                ImVec2 pos  = new ImVec2(_state.MainWinSize.x / 2 - size.x / 2, _state.MainWinSize.y / 2 - size.y / 2);
                ImGui.SetNextWindowSize(size, ImGuiCond.FirstUseEver);
                ImGui.SetNextWindowPos(pos, ImGuiCond.Always);

                if (ImGui.Begin("Pulsar4X Main Menu", ref IsActive, _flags))
                {
                    if (ImGui.Button("Start a New Game", buttonSize))
                    {
                        //_state.NewGameOptions.IsActive = true;
                        var newgameoptions = NewGameOptions.GetInstance();
                        newgameoptions.IsActive = true;
                        this.IsActive           = false;
                    }
                    if (_state.IsGameLoaded)
                    {
                        if (ImGui.Button("Save Current Game", buttonSize))
                        {
                            _saveGame = !_saveGame;
                        }
                        if (ImGui.Button("Options", buttonSize))
                        {
                            SettingsWindow.GetInstance().IsActive = !SettingsWindow.GetInstance().IsActive;
                            IsActive = false;
                        }
                    }
                    ImGui.Button("Resume a Current Game", buttonSize);
                    ImGui.Button("Connect to a Network Game", buttonSize);
                }


                if (ImGui.Button("SM Mode", buttonSize))
                {
                    var pannel = SMPannel.GetInstance();
                    _state.ActiveWindow = pannel;
                    pannel.IsActive     = true;
                    this.IsActive       = false;
                }

                //if (_saveGame)

                ImGui.End();
            }
        }
Example #11
0
        public override void Draw(IntPtr rendererPtr, Camera camera)
        {
            var    camerapoint = camera.CameraViewCoordinate();
            int    x           = (int)(X + camerapoint.x + ViewOffset.x);
            int    y           = (int)(Y + camerapoint.y + ViewOffset.y);
            ImVec2 pos         = new ImVec2(x, y);

            ImGui.PushStyleColor(ImGuiCol.WindowBg, new ImVec4(0, 0, 0, 0)); //make the background transperent.
            ImGui.SetNextWindowPos(pos, ImGuiCond.Always);


            ImGui.Begin(NameString, ref IsActive, _flags);

            ImGui.PushStyleColor(ImGuiCol.Button, new ImVec4(0, 0, 0, 0));
            if (ImGui.Button(NameString)) //If the name gets clicked, we tell the state.
            {
                _state.EntityClicked(_entityGuid, MouseButtons.Primary);
            }
            var size = ImGui.GetLastItemRectSize();

            Height = size.y;
            Width  = size.x;
            ViewDisplayRect.Width  = size.x;
            ViewDisplayRect.Height = size.y;

            ImGui.PopStyleColor();
            if (ImGui.BeginPopupContextItem("NameContextMenu", 1))
            {
                _state.EntityClicked(_entityGuid, MouseButtons.Alt);
                _state.ContextMenu = new EntityContextMenu(_state, _entityGuid);
                _state.ContextMenu.Display();

                ImGui.EndPopup();
            }



            ImGui.End();
            ImGui.PopStyleColor(); //have to pop the color change after pushing it.
        }
Example #12
0
        internal ImGuiDrawContext()
        {
            ItemWidthStack          = new ImVector <float>();
            TextWrapPosStack        = new ImVector <float>();
            AllowKeyboardFocusStack = new ImVector <bool>();
            ButtonRepeatStack       = new ImVector <bool>();
            GroupStack   = new ImVector <ImGuiGroupData>();
            ChildWindows = new ImVector <ImGuiWindow>();
            ColumnsData  = new ImVector <ImGuiColumnData>();

            CursorPos                 = CursorPosPrevLine = CursorStartPos = CursorMaxPos = new ImVec2(0.0f, 0.0f);
            CurrentLineHeight         = PrevLineHeight = 0.0f;
            CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
            LogLinePosY               = -1.0f;
            TreeDepth                 = 0;
            LastItemID                = 0;
            LastItemRect              = new ImRect(0.0f, 0.0f, 0.0f, 0.0f);
            LastItemHoveredAndUsable  = LastItemHoveredRect = false;
            MenuBarAppending          = false;
            MenuBarOffsetX            = 0.0f;
            StateStorage              = null;
            LayoutType                = ImGuiLayoutType.ImGuiLayoutType_Vertical;
            ItemWidth                 = 0.0f;
            ButtonRepeat              = false;
            AllowKeyboardFocus        = true;
            TextWrapPos               = -1.0f;
            ColorEditMode             = ImGuiColorEditMode.ImGuiColorEditMode_RGB;
            //memset(StackSizesBackup, 0, sizeof(StackSizesBackup));

            IndentX            = 0.0f;
            ColumnsOffsetX     = 0.0f;
            ColumnsCurrent     = 0;
            ColumnsCount       = 1;
            ColumnsMinX        = ColumnsMaxX = 0.0f;
            ColumnsStartPosY   = 0.0f;
            ColumnsCellMinY    = ColumnsCellMaxY = 0.0f;
            ColumnsShowBorders = true;
            ColumnsSetID       = 0;
        }
Example #13
0
        internal override void Display()
        {
            if (IsActive)
            {
                ImVec2 size = new ImVec2(200, 100);
                ImVec2 pos  = new ImVec2(0, 0);

                ImGui.SetNextWindowSize(size, ImGuiCond.FirstUseEver);
                ImGui.SetNextWindowPos(pos, ImGuiCond.Appearing);

                if (ImGui.Begin("Settings", ref IsActive, _flags))
                {
                    if (ImGui.Button("Show Debug Window"))
                    {
                        DebugWindow.GetInstance().IsActive = true;
                        //_state.LoadedWindows.Add(_state.Debug);
                    }
                    if (ImGui.CollapsingHeader("Process settings", _xpanderFlags))
                    {
                        if (ImGui.Checkbox("MultiThreaded", ref IsThreaded))
                        {
                            _state.Game.Settings.EnableMultiThreading = IsThreaded;
                        }
                    }


                    if (ImGui.CollapsingHeader("Map Settings", _xpanderFlags))
                    {
                        //TODO: make this a knob/dial? need to create a custom control: https://github.com/ocornut/imgui/issues/942
                        if (ImGui.SliderAngle("Sweep Angle", ref _userOrbitSettings.EllipseSweepRadians, 1f, 360f))
                        {
                            _state.MapRendering.UpdateUserOrbitSettings();
                        }

                        if (ImGui.SliderInt("Number Of Segments", ref _arcSegments, 1, 255, _userOrbitSettings.NumberOfArcSegments.ToString()))
                        {
                            _userOrbitSettings.NumberOfArcSegments = (byte)_arcSegments;
                            _state.MapRendering.UpdateUserOrbitSettings();
                        }

                        if (ImGui.ColorEdit3("Orbit Ring Colour", ref _colour, false))
                        {
                            _userOrbitSettings.Red = Helpers.Color(_colour.x);
                            _userOrbitSettings.Grn = Helpers.Color(_colour.y);
                            _userOrbitSettings.Blu = Helpers.Color(_colour.z);
                        }
                        if (ImGui.SliderInt("Max Alpha", ref _maxAlpha, _minAlpha, 255, ""))
                        {
                            _userOrbitSettings.MaxAlpha = (byte)_maxAlpha;
                            _state.MapRendering.UpdateUserOrbitSettings();
                        }

                        if (ImGui.SliderInt("Min Alpha", ref _minAlpha, 0, _maxAlpha, ""))
                        {
                            _userOrbitSettings.MinAlpha = (byte)_minAlpha;
                            _state.MapRendering.UpdateUserOrbitSettings();
                        }
                    }
                }

                ImGui.End();
            }
        }
Example #14
0
        internal override void Display()
        {
            if (IsActive)
            {
                ImVec2 size = new ImVec2(200, 100);
                ImVec2 pos  = new ImVec2(_state.MainWinSize.x / 2 - size.x / 2, _state.MainWinSize.y / 2 - size.y / 2);

                ImGui.SetNextWindowSize(size, ImGuiCond.FirstUseEver);
                ImGui.SetNextWindowPos(pos, ImGuiCond.FirstUseEver);

                if (ImGui.Begin(_displayText, ref IsActive, _flags))
                {
                    ImGui.SetTooltip(_tooltipText);
                    ImGui.Text("Target: ");
                    ImGui.SameLine();
                    ImGui.Text(TargetEntity.Name);

                    ImGui.Text("Apoapsis: ");
                    ImGui.SameLine();
                    ImGui.Text(_apoapsisKm.ToString("g3") + " (Alt: " + _apAlt.ToString("g3") + ")");

                    ImGui.Text("Periapsis: ");
                    ImGui.SameLine();
                    ImGui.Text(_periapsisKM.ToString("g3") + " (Alt: " + _peAlt.ToString("g3") + ")");

                    ImGui.Text("OrbitalVelocity: ");
                    ImGui.SameLine();
                    ImGui.Text(_PreciseOrbitalSpeedKm_s.ToString());

                    if (ImGui.Button("Action Order"))
                    {
                        fsm[(byte)CurrentState, (byte)Events.ClickedAction].Invoke();
                    }

                    if (_smMode)
                    {
                        ImGui.SameLine();
                        if (ImGui.Button("Add OrbitDB"))
                        {
                            ActionAddDB();
                        }
                    }

                    if (_orbitWidget != null)
                    {
                        switch (CurrentState)
                        {
                        case States.NeedsEntity:

                            break;

                        case States.NeedsTarget:

                            break;

                        case States.NeedsInsertionPoint:
                        {
                            var mousePos = ImGui.GetMousePos();

                            var mouseWorldPos = _state.Camera.MouseWorldCoordinate();
                            _targetInsertionPoint_AU = (mouseWorldPos - GetTargetPosition());

                            //var intercept = InterceptCalcs.GetInterceptPosition(OrderingEntity.Entity, TargetEntity.Entity.GetDataBlob<OrbitDB>(), TargetEntity.Entity.Manager.ManagerSubpulses.SystemLocalDateTime);

                            //var distanceAU = (GetTargetPosition() - mouseWorldPos).Length();
                            //var distanceSelectedKM = Distance.AuToKm(distanceAU);
                            //var d1 = Math.Min(_apMax, distanceSelectedKM); //can't be higher than SOI
                            //_apoapsisKm = Math.Max(d1, _peMin); //cant be lower than the body radius

                            //_moveWidget.SetArrivalRadius(distanceAU);
                            _moveWidget.SetArrivalPosition(_targetInsertionPoint_AU);

                            var massCurrBody   = OrderingEntity.Entity.GetDataBlob <OrbitDB>().Parent.GetDataBlob <MassVolumeDB>().Mass;
                            var massTargetBody = TargetEntity.Entity.GetDataBlob <MassVolumeDB>().Mass;
                            var mymass         = OrderingEntity.Entity.GetDataBlob <MassVolumeDB>().Mass;

                            var ralPosCBAU    = OrderingEntity.Entity.GetDataBlob <PositionDB>().RelativePosition_AU;
                            var smaCurrOrbtAU = OrderingEntity.Entity.GetDataBlob <OrbitDB>().SemiMajorAxis;

                            var sgpCBAU = GameConstants.Science.GravitationalConstant * (massCurrBody + mymass) / 3.347928976e33;        // (149597870700 * 149597870700 * 149597870700);
                            var velAU   = OrbitProcessor.PreciseOrbitalVector(sgpCBAU, ralPosCBAU, smaCurrOrbtAU);
                            var sgpTBAU = GameConstants.Science.GravitationalConstant * (massTargetBody + mymass) / 3.347928976e33;

                            var ke = OrbitMath.KeplerFromVelocityAndPosition(sgpTBAU, _targetInsertionPoint_AU, velAU);

                            _PreciseOrbitalSpeedKm_s = Distance.AuToKm(velAU.Length());

                            _orbitWidget.SetParametersFromKeplerElements(ke, _targetInsertionPoint_AU);
                            _apoapsisKm  = Distance.AuToKm(ke.Apoapsis);
                            _periapsisKM = Distance.AuToKm(ke.Periapsis);
                            break;
                        }

                        /*
                         * case States.NeedsSecondApsis:
                         * {
                         *   TODO: when we've got newtonion engines, allow second apsis choise and expend Dv.
                         *  var mousePos = ImGui.GetMousePos();
                         *
                         *  var mouseWorldPos = _state.Camera.MouseWorldCoordinate();
                         *
                         *  var ralitivePos = (GetTargetPosition() - mouseWorldPos);
                         *  _orbitWidget.SetPeriapsis(ralitivePos.X, ralitivePos.Y);
                         *
                         *  //_periapsisKM = Distance.AuToKm((GetTargetPosition() - mouseWorldPos).Length());
                         *  var distanceSelected = Distance.AuToKm((GetTargetPosition() - mouseWorldPos).Length());
                         *  var d1 = Math.Max(_peMin, distanceSelected); //can't be lower than body radius
                         *  _periapsisKM = Math.Min(d1, _apoapsisKm);  //can't be higher than apoapsis.
                         *
                         *  break;
                         * }*/
                        case States.NeedsActioning:
                            break;

                        default:
                            break;
                        }
                    }



                    ImGui.End();
                }
            }
        }
Example #15
0
        /// <summary>
        /// Returns the size of an object in view-Coordinates
        /// </summary>
        /// <param name="worldSize"></param>
        /// <returns></returns>
        public ImVec2 ViewSize(ImVec2 worldSize)
        {
            ImVec2 viewSize = new ImVec2(worldSize.X * ZoomLevel, worldSize.Y * ZoomLevel);

            return(viewSize);
        }
Example #16
0
 /// <summary>
 /// Returns the size of an object in world-Coordinates
 /// </summary>
 /// <param name="viewSize"></param>
 /// <returns></returns>
 public ImVec2 WorldSize(ImVec2 viewSize)
 {
     return(new ImVec2(viewSize.x / ZoomLevel, viewSize.y / ZoomLevel));
 }
Example #17
0
        internal ImGuiStyle()
        {
            Alpha                  = 1.0f;                       // Global alpha applies to everything in ImGui
            WindowPadding          = new ImVec2(8, 8);           // Padding within a window
            WindowMinSize          = new ImVec2(32, 32);         // Minimum window size
            WindowRounding         = 9.0f;                       // Radius of window corners rounding. Set to 0.0f to have rectangular windows
            WindowTitleAlign       = ImGuiAlign.ImGuiAlign_Left; // Alignment for title bar text
            ChildWindowRounding    = 0.0f;                       // Radius of child window corners rounding. Set to 0.0f to have rectangular windows
            FramePadding           = new ImVec2(4, 3);           // Padding within a framed rectangle (used by most widgets)
            FrameRounding          = 0.0f;                       // Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets).
            ItemSpacing            = new ImVec2(8, 4);           // Horizontal and vertical spacing between widgets/lines
            ItemInnerSpacing       = new ImVec2(4, 4);           // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
            TouchExtraPadding      = new ImVec2(0, 0);           // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
            WindowFillAlphaDefault = 0.70f;                      // Default alpha of window background, if not specified in ImGui::Begin()
            IndentSpacing          = 22.0f;                      // Horizontal spacing when e.g. entering a tree node
            ColumnsMinSpacing      = 6.0f;                       // Minimum horizontal spacing between two columns
            ScrollbarSize          = 16.0f;                      // Width of the vertical scrollbar, Height of the horizontal scrollbar
            ScrollbarRounding      = 9.0f;                       // Radius of grab corners rounding for scrollbar
            GrabMinSize            = 10.0f;                      // Minimum width/height of a grab box for slider/scrollbar
            GrabRounding           = 0.0f;                       // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
            DisplayWindowPadding   = new ImVec2(22, 22);         // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
            DisplaySafeAreaPadding = new ImVec2(4, 4);           // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
            AntiAliasedLines       = true;                       // Enable anti-aliasing on lines/borders. Disable if you are really short on CPU/GPU.
            AntiAliasedShapes      = true;                       // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
            CurveTessellationTol   = 1.25f;                      // Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.

            Colors[(int)ImGuiCol.ImGuiCol_Text]                 = new ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_TextDisabled]         = new ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_WindowBg]             = new ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_ChildWindowBg]        = new ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
            Colors[(int)ImGuiCol.ImGuiCol_Border]               = new ImVec4(0.70f, 0.70f, 0.70f, 0.65f);
            Colors[(int)ImGuiCol.ImGuiCol_BorderShadow]         = new ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
            Colors[(int)ImGuiCol.ImGuiCol_FrameBg]              = new ImVec4(0.80f, 0.80f, 0.80f, 0.30f); // Background of checkbox, radio button, plot, slider, text input
            Colors[(int)ImGuiCol.ImGuiCol_FrameBgHovered]       = new ImVec4(0.90f, 0.80f, 0.80f, 0.40f);
            Colors[(int)ImGuiCol.ImGuiCol_FrameBgActive]        = new ImVec4(0.90f, 0.65f, 0.65f, 0.45f);
            Colors[(int)ImGuiCol.ImGuiCol_TitleBg]              = new ImVec4(0.50f, 0.50f, 1.00f, 0.45f);
            Colors[(int)ImGuiCol.ImGuiCol_TitleBgCollapsed]     = new ImVec4(0.40f, 0.40f, 0.80f, 0.20f);
            Colors[(int)ImGuiCol.ImGuiCol_TitleBgActive]        = new ImVec4(0.50f, 0.50f, 1.00f, 0.55f);
            Colors[(int)ImGuiCol.ImGuiCol_MenuBarBg]            = new ImVec4(0.40f, 0.40f, 0.55f, 0.80f);
            Colors[(int)ImGuiCol.ImGuiCol_ScrollbarBg]          = new ImVec4(0.20f, 0.25f, 0.30f, 0.60f);
            Colors[(int)ImGuiCol.ImGuiCol_ScrollbarGrab]        = new ImVec4(0.40f, 0.40f, 0.80f, 0.30f);
            Colors[(int)ImGuiCol.ImGuiCol_ScrollbarGrabHovered] = new ImVec4(0.40f, 0.40f, 0.80f, 0.40f);
            Colors[(int)ImGuiCol.ImGuiCol_ScrollbarGrabActive]  = new ImVec4(0.80f, 0.50f, 0.50f, 0.40f);
            Colors[(int)ImGuiCol.ImGuiCol_ComboBg]              = new ImVec4(0.20f, 0.20f, 0.20f, 0.99f);
            Colors[(int)ImGuiCol.ImGuiCol_CheckMark]            = new ImVec4(0.90f, 0.90f, 0.90f, 0.50f);
            Colors[(int)ImGuiCol.ImGuiCol_SliderGrab]           = new ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
            Colors[(int)ImGuiCol.ImGuiCol_SliderGrabActive]     = new ImVec4(0.80f, 0.50f, 0.50f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_Button]               = new ImVec4(0.67f, 0.40f, 0.40f, 0.60f);
            Colors[(int)ImGuiCol.ImGuiCol_ButtonHovered]        = new ImVec4(0.67f, 0.40f, 0.40f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_ButtonActive]         = new ImVec4(0.80f, 0.50f, 0.50f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_Header]               = new ImVec4(0.40f, 0.40f, 0.90f, 0.45f);
            Colors[(int)ImGuiCol.ImGuiCol_HeaderHovered]        = new ImVec4(0.45f, 0.45f, 0.90f, 0.80f);
            Colors[(int)ImGuiCol.ImGuiCol_HeaderActive]         = new ImVec4(0.53f, 0.53f, 0.87f, 0.80f);
            Colors[(int)ImGuiCol.ImGuiCol_Column]               = new ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_ColumnHovered]        = new ImVec4(0.70f, 0.60f, 0.60f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_ColumnActive]         = new ImVec4(0.90f, 0.70f, 0.70f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_ResizeGrip]           = new ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
            Colors[(int)ImGuiCol.ImGuiCol_ResizeGripHovered]    = new ImVec4(1.00f, 1.00f, 1.00f, 0.60f);
            Colors[(int)ImGuiCol.ImGuiCol_ResizeGripActive]     = new ImVec4(1.00f, 1.00f, 1.00f, 0.90f);
            Colors[(int)ImGuiCol.ImGuiCol_CloseButton]          = new ImVec4(0.50f, 0.50f, 0.90f, 0.50f);
            Colors[(int)ImGuiCol.ImGuiCol_CloseButtonHovered]   = new ImVec4(0.70f, 0.70f, 0.90f, 0.60f);
            Colors[(int)ImGuiCol.ImGuiCol_CloseButtonActive]    = new ImVec4(0.70f, 0.70f, 0.70f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_PlotLines]            = new ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_PlotLinesHovered]     = new ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_PlotHistogram]        = new ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_PlotHistogramHovered] = new ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
            Colors[(int)ImGuiCol.ImGuiCol_TextSelectedBg]       = new ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
            Colors[(int)ImGuiCol.ImGuiCol_TooltipBg]            = new ImVec4(0.05f, 0.05f, 0.10f, 0.90f);
            Colors[(int)ImGuiCol.ImGuiCol_ModalWindowDarkening] = new ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
        }
Example #18
0
        internal ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup

        internal ImGuiPopupRef(uint id, ImGuiWindow parent_window, uint parent_menu_set, ImVec2 mouse_pos)
        {
            PopupID = id; Window = null; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos;
        }
Example #19
0
        // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
        // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
        //ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL){
        internal int CalcTextSizeA(out ImVec2 textSize, float size, float max_width, float wrap_width, string text, int text_begin, int text_end = -1)
        {
            if (text_end == -1)
            {
                text_end = text.Length; // FIXME-OPT: Need to avoid this.
            }
            float line_height = size;
            float scale       = size / FontSize;

            ImVec2 text_size  = new ImVec2(0, 0);
            float  line_width = 0.0f;

            bool word_wrap_enabled = (wrap_width > 0.0f);
            int  word_wrap_eol     = -1;

            int s = text_begin;

            while (s < text_end)
            {
                if (word_wrap_enabled)
                {
                    // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
                    if (word_wrap_eol == -1)
                    {
                        word_wrap_eol = CalcWordWrapPositionA(scale, text, s, text_end, wrap_width - line_width);
                        if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity.
                        {
                            word_wrap_eol++;    // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below
                        }
                    }

                    if (s >= word_wrap_eol)
                    {
                        if (text_size.x < line_width)
                        {
                            text_size.x = line_width;
                        }

                        text_size.y  += line_height;
                        line_width    = 0.0f;
                        word_wrap_eol = -1;

                        // Wrapping skips upcoming blanks
                        while (s < text_end)
                        {
                            char wc = text[s];
                            if (char.IsSeparator(wc))
                            {
                                s++;
                            }
                            //else if (wc == '\t') { s++; break; }
                            else if (wc == '\n')
                            {
                                s++; break;
                            }
                            else
                            {
                                break;
                            }
                        }
                        continue;
                    }
                }

                // Decode and advance source
                int  prev_s = s;
                char c      = text[s++];
                //if (c < 0x80)
                //{
                //    s += 1;
                //}
                //else
                //{
                //    s += ImTextCharFromUtf8(&c, s, text_end);
                //    if (c == 0)
                //        break;
                //}

                if (c < 32)
                {
                    if (c == '\n')
                    {
                        text_size.x  = ImGui.Max(text_size.x, line_width);
                        text_size.y += line_height;
                        line_width   = 0.0f;
                        continue;
                    }
                    if (c == '\r')
                    {
                        continue;
                    }
                }

                float char_width = (c < IndexXAdvance.Size ? IndexXAdvance[c] : FallbackXAdvance) * scale;
                if (line_width + char_width >= max_width)
                {
                    s = prev_s;
                    break;
                }

                line_width += char_width;
            }

            if (text_size.x < line_width)
            {
                text_size.x = line_width;
            }

            if (line_width > 0 || text_size.y == 0.0f)
            {
                text_size.y += line_height;
            }

            textSize = text_size;
            return(s); //return the position we stopped at
        }
Example #20
0
        public void TextIconsDistribute()
        {
            if (_nameIcons.Count == 0)
            {
                return;
            }
            var occupiedPosition             = new List <IRectangle>();
            IComparer <IRectangle> byViewPos = new ByViewPosition();
            var textIconList = new List <NameIcon>(_nameIcons.Values);


            //Consolidate TextIcons that share the same position and name
            textIconList.Sort();
            int listLength       = textIconList.Count;
            int textIconQuantity = 1;

            for (int i = 1; i < listLength; i++)
            {
                if (textIconList[i - 1].CompareTo(textIconList[i]) == 0)
                {
                    textIconQuantity++;
                    textIconList.RemoveAt(i);
                    i--;
                    listLength--;
                }
                else if (textIconQuantity > 1)
                {
                    textIconList[i - 1].NameString += " x" + textIconQuantity;
                    textIconQuantity = 1;
                }
            }

            //Placement happens bottom to top, left to right
            //Each newly placed Texticon is compared to only the Texticons that are placed above its position
            //Therefore a sorted list of the occupied Positions is maintained
            occupiedPosition.Add(textIconList[0]);



            List <NameIcon> texiconsCopy = new List <NameIcon>();

            texiconsCopy.AddRange(_nameIcons.Values);

            int numTextIcons = texiconsCopy.Count;

            for (int i = 1; i < numTextIcons; i++)
            {
                var    item   = texiconsCopy[i - 1];
                ImVec2 height = new ImVec2()
                {
                    x = 0, y = item.Height
                };
                int lowestPosIndex = occupiedPosition.BinarySearch(item.ViewDisplayRect + height, byViewPos);
                int lpi            = lowestPosIndex;
                if (lowestPosIndex < 0)
                {
                    lpi = ~lowestPosIndex;
                }

                for (int j = lpi; j < occupiedPosition.Count; j++)
                {
                    if (item.ViewDisplayRect.Intersects(occupiedPosition[j]))
                    {
                        var newpoint = new ImVec2()
                        {
                            x = item.ViewOffset.x,
                            y = item.ViewOffset.Y - occupiedPosition[j].Height
                        };
                        item.ViewOffset = newpoint;
                    }
                }
                //Inserts the new label sorted
                int insertIndex = occupiedPosition.BinarySearch(item, byViewPos);
                if (insertIndex < 0)
                {
                    insertIndex = ~insertIndex;
                }
                occupiedPosition.Insert(insertIndex, item);
            }
        }
Example #21
0
        internal ImRect RenderText(float size, ImVec2 pos, uint col, ImVec4 clip_rect, char[] text, int text_begin, int text_end, ImDrawList draw_list, float wrap_width = 0.0f, bool cpu_fine_clip = false)
        {
            if (text_end == -1)
            {
                text_end = text.Length; // FIXME-OPT: Need to avoid this.
            }
            // Align to be pixel perfect
            pos.x = (int)pos.x + DisplayOffset.x;
            pos.y = (int)pos.y + DisplayOffset.y;
            float x = pos.x;
            float y = pos.y;

            if (y > clip_rect.w)
            {
                return(new ImRect());
            }

            float scale             = size / FontSize;
            float line_height       = FontSize * scale;
            bool  word_wrap_enabled = (wrap_width > 0.0f);
            int   word_wrap_eol     = -1;

            int  vtx_write       = draw_list._VtxWritePtr;
            int  idx_write       = draw_list._IdxWritePtr;
            uint vtx_current_idx = draw_list._VtxCurrentIdx;

            int s = text_begin;

            if (!word_wrap_enabled && y + line_height < clip_rect.y)
            {
                while (s < text_end && text[s] != '\n')  // Fast-forward to next line
                {
                    s++;
                }
            }

            while (s < text_end)
            {
                if (word_wrap_enabled)
                {
                    // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
                    if (word_wrap_eol != -1)
                    {
                        word_wrap_eol = CalcWordWrapPositionA(scale, text, s, text_end, wrap_width - (x - pos.x));
                        if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity.
                        {
                            word_wrap_eol++;    // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below
                        }
                    }

                    if (s >= word_wrap_eol)
                    {
                        x             = pos.x;
                        y            += line_height;
                        word_wrap_eol = -1;

                        // Wrapping skips upcoming blanks
                        while (s < text_end)
                        {
                            char wc = text[s];
                            if (char.IsSeparator(wc))
                            {
                                s++;
                            }
                            else if (wc == '\n')
                            {
                                s++; break;
                            }
                            else
                            {
                                break;
                            }
                        }
                        continue;
                    }
                }

                // Decode and advance source
                char c = text[s++];
                //if (c< 0x80)
                //{
                // s += 1;
                //}
                //else
                //{
                // s += ImTextCharFromUtf8(&c, s, text_end);
                // if (c == 0)
                //  break;
                //}

                if (c < 32)
                {
                    if (c == '\n')
                    {
                        x  = pos.x;
                        y += line_height;

                        if (y > clip_rect.w)
                        {
                            break;
                        }
                        if (!word_wrap_enabled && y + line_height < clip_rect.y)
                        {
                            while (s < text_end && text[s] != '\n')  // Fast-forward to next line
                            {
                                s++;
                            }
                        }

                        continue;
                    }
                    if (c == '\r')
                    {
                        continue;
                    }
                }

                float char_width = 0.0f;
                Glyph glyph;
                if (FindGlyph(c, out glyph))
                {
                    char_width = glyph.XAdvance * scale;

                    // Arbitrarily assume that both space and tabs are empty glyphs as an optimization
                    if (c != ' ' && c != '\t')
                    {
                        // We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w
                        float y1 = (float)(y + glyph.Y0 * scale);
                        float y2 = (float)(y + glyph.Y1 * scale);

                        float x1 = (float)(x + glyph.X0 * scale);
                        float x2 = (float)(x + glyph.X1 * scale);
                        if (x1 <= clip_rect.z && x2 >= clip_rect.x)
                        {
                            // Render a character
                            float u1 = glyph.U0;
                            float v1 = glyph.V0;
                            float u2 = glyph.U1;
                            float v2 = glyph.V1;

                            // CPU side clipping used to fit text in their frame when the frame is too small. Only does clipping for axis aligned quads.
                            if (cpu_fine_clip)
                            {
                                if (x1 < clip_rect.x)
                                {
                                    u1 = u1 + (1.0f - (x2 - clip_rect.x) / (x2 - x1)) * (u2 - u1);
                                    x1 = clip_rect.x;
                                }
                                if (y1 < clip_rect.y)
                                {
                                    v1 = v1 + (1.0f - (y2 - clip_rect.y) / (y2 - y1)) * (v2 - v1);
                                    y1 = clip_rect.y;
                                }
                                if (x2 > clip_rect.z)
                                {
                                    u2 = u1 + ((clip_rect.z - x1) / (x2 - x1)) * (u2 - u1);
                                    x2 = clip_rect.z;
                                }
                                if (y2 > clip_rect.w)
                                {
                                    v2 = v1 + ((clip_rect.w - y1) / (y2 - y1)) * (v2 - v1);
                                    y2 = clip_rect.w;
                                }
                                if (y1 >= y2)
                                {
                                    x += char_width;
                                    continue;
                                }
                            }

                            // We are NOT calling PrimRectUV() here because non-inlined causes too much overhead in a debug build.
                            // Inlined here:
                            {
                                draw_list.IdxBuffer[idx_write++] = (ImDrawIdx)(vtx_current_idx); draw_list.IdxBuffer[idx_write++] = (ImDrawIdx)(vtx_current_idx + 1); draw_list.IdxBuffer[idx_write++] = (ImDrawIdx)(vtx_current_idx + 2);
                                draw_list.IdxBuffer[idx_write++] = (ImDrawIdx)(vtx_current_idx); draw_list.IdxBuffer[idx_write++] = (ImDrawIdx)(vtx_current_idx + 2); draw_list.IdxBuffer[idx_write++] = (ImDrawIdx)(vtx_current_idx + 3);
                                draw_list.VtxBuffer[vtx_write++] = new ImDrawVert()
                                {
                                    pos = new ImVec2(x1, y1), uv = new ImVec2(u1, v1), col = col
                                };
                                draw_list.VtxBuffer[vtx_write++] = new ImDrawVert()
                                {
                                    pos = new ImVec2(x2, y1), uv = new ImVec2(u2, v1), col = col
                                };
                                draw_list.VtxBuffer[vtx_write++] = new ImDrawVert()
                                {
                                    pos = new ImVec2(x2, y2), uv = new ImVec2(u2, v2), col = col
                                };
                                draw_list.VtxBuffer[vtx_write++] = new ImDrawVert()
                                {
                                    pos = new ImVec2(x1, y2), uv = new ImVec2(u1, v2), col = col
                                };
                                vtx_current_idx += 4;
                            }
                        }
                    }
                }

                x += char_width;
            }

            draw_list._VtxWritePtr   = vtx_write;
            draw_list._VtxCurrentIdx = vtx_current_idx;
            draw_list._IdxWritePtr   = idx_write;
            return(new ImRect(pos, new ImVec2(x, y + line_height)));
        }
Example #22
0
        internal override void Display()
        {
            if (IsActive)
            {
                ImVec2 size = new ImVec2(200, 100);
                ImVec2 pos  = new ImVec2(_state.MainWinSize.x / 2 - size.x / 2, _state.MainWinSize.y / 2 - size.y / 2);

                ImGui.SetNextWindowSize(size, ImGuiCond.FirstUseEver);
                ImGui.SetNextWindowPos(pos, ImGuiCond.FirstUseEver);

                if (ImGui.Begin("Weapon Targeting", ref IsActive, _flags))
                {
                    int  selectable = 0;
                    bool selected   = false;
                    ImGui.BeginGroup();
                    foreach (var fc in _shipFCDB.FireControlInsances)
                    {
                        if (ImGui.Selectable("FC " + selectable, selected, ImGuiSelectableFlags.Default, _selectableBtnSize))
                        {
                            _selectedItemIndex         = selectable;
                            _selectedFC                = fc.OwningEntity.Guid;
                            _selectedFCAssignedWeapons = new List <Guid>();
                            foreach (var item in fc.AssignedWeapons)
                            {
                                _selectedFCAssignedWeapons.Add(item.Guid);
                            }
                        }

                        /*
                         * ImGui.Text("Assigned Weapons: ");
                         * foreach (var weapon in fc.AssignedWeapons)
                         * {
                         *  bool isEnabled = weapon.GetDataBlob<ComponentInstanceInfoDB>().IsEnabled;
                         *  if (ImGui.Checkbox(weaponNames[weapon.Guid], ref isEnabled))
                         *  {
                         *      //give an enable/disable order.
                         *  }
                         * }*/
                        ImGui.Text("Target: ");
                        ImGui.SameLine();
                        if (fc.Target == null)
                        {
                            ImGui.Text("No Target");
                        }
                        else
                        {
                            ImGui.Text(fc.Target.GetDataBlob <NameDB>().GetName(_state.Faction));
                        }
                        selectable++;
                    }
                    ImGui.EndGroup();
                    if (_selectedItemIndex > -1)
                    {
                        ImGui.SameLine();
                        ImGui.BeginGroup();
                        {
                            ImGui.BeginGroup();
                            //ImGui.BeginChild("AssignedWeapons", true);

                            ImGui.Text("Assigned Weapons");
                            foreach (var wpn in _selectedFCAssignedWeapons.ToArray())
                            {
                                if (ImGui.Button(_weaponNames[wpn]))
                                {
                                    _unAssignedWeapons.Add(wpn);
                                    _selectedFCAssignedWeapons.Remove(wpn);
                                    SetWeaponsFireControlOrder.CreateCommand(_state.Game, _state.CurrentSystemDateTime, _state.Faction.Guid, _orderingEntity.Guid, _selectedFC, _selectedFCAssignedWeapons);
                                }
                            }
                            ImGui.EndGroup();
                            ImGui.BeginGroup();
                            //ImGui.EndChild();
                            //ImGui.BeginChild("Un Assigned Weapons", true);

                            ImGui.Text("Un Assigned Weapons");
                            foreach (var wpn in _unAssignedWeapons.ToArray())
                            {
                                if (ImGui.Button(_weaponNames[wpn]))
                                {
                                    _selectedFCAssignedWeapons.Add(wpn);
                                    _unAssignedWeapons.Remove(wpn);
                                    SetWeaponsFireControlOrder.CreateCommand(_state.Game, _state.CurrentSystemDateTime, _state.Faction.Guid, _orderingEntity.Guid, _selectedFC, _selectedFCAssignedWeapons);
                                }
                            }
                            ImGui.EndGroup();
                            //ImGui.EndChild();
                        }
                        ImGui.EndGroup();
                        ImGui.SameLine();
                        ImGui.BeginGroup();
                        {
                            ImGui.Text("Set Target");
                            foreach (var item in _systemEntityNames)
                            {
                                if (ImGui.SmallButton(item.Value))
                                {
                                    SetTargetFireControlOrder.CreateCommand(_state.Game, _state.CurrentSystemDateTime, _state.Faction.Guid, _orderingEntity.Guid, _selectedFC, item.Key);
                                }
                            }
                        }
                        ImGui.EndGroup();
                        ImGui.SameLine();
                        ImGui.BeginGroup();
                        {
                            ImGui.Text("Range in AU");
                            foreach (var item in _systemEntityNames)
                            {
                                Entity targetEntity = _systemEntites[item.Key];
                                double distance     = _orderingEntity.GetDataBlob <PositionDB>().GetDistanceTo(targetEntity.GetDataBlob <PositionDB>());
                                ImGui.Text(distance.ToString());
                            }
                        }
                        ImGui.EndGroup();
                    }
                }
                ImGui.End();
            }
        }
Example #23
0
        internal override void Display()
        {
            ImVec2 size = new ImVec2(200, 100);
            ImVec2 pos  = new ImVec2(0, 0);

            ImGui.SetNextWindowSize(size, ImGuiCond.FirstUseEver);
            ImGui.SetNextWindowPos(pos, ImGuiCond.Appearing);

            ImGui.Begin("TimeControl", ref IsActive, _flags);
            ImGui.PushItemWidth(100);
            ImGui.PushStyleColor(ImGuiCol.Header, new ImVec4(0, 0, 0, 0));
            ImGui.PushStyleColor(ImGuiCol.HeaderActive, new ImVec4(0, 0, 0, 0));
            ImGui.PushStyleColor(ImGuiCol.HeaderHovered, new ImVec4(0, 0, 0, 0));
            if (ImGui.CollapsingHeader("", _xpanderFlags))
            {
                _expanded = true;
            }
            else
            {
                _expanded = false;
            }
            ImGui.PopStyleColor(3);
            ImGui.SameLine();
            if (ImGui.SliderInt("##spnSldr", ref _timeSpanValue, 1, 60, _timeSpanValue.ToString()))
            {
                AdjustTimeSpan();
            }
            ImGui.SameLine();
            if (ImGui.Combo("##spnCmbo", ref _timeSpanType, _timespanTypeSelection))
            {
                AdjustTimeSpan();
            }
            ImGui.SameLine();

            if (ImGui.ImageButton(_state.GLImageDictionary["PlayImg"], new ImVec2(16, 16), new ImVec2(0, 0), new ImVec2(16, 16), 0, new ImVec4(0, 0, 0, 0), new ImVec4(0, 0, 0, 0)))
            {
                PausePlayPressed();
            }
            ImGui.SameLine();
            if (ImGui.Button("||>"))
            {
                OneStepPressed();
            }
            if (_expanded)
            {
                ImGui.PushItemWidth(100);
                if (ImGui.SliderFloat("##freqSldr", ref _freqTimeSpanValue, 0.1f, 1, _freqTimeSpanValue.ToString(), 1))
                {
                    AdjustFreqency();
                }
                ImGui.SameLine();
                if (ImGui.Combo("##freqCmbo", ref _freqSpanType, _timespanTypeSelection))
                {
                    AdjustFreqency();
                }
            }



            ImGui.End();
        }