コード例 #1
0
ファイル: DistanceRuler.cs プロジェクト: Moth-Tolias/Pulsar4x
        internal override void Display()
        {
            if (IsActive == true && ImGui.Begin("Map Scale", ref IsActive, _flags))//Lets the user close the ruler
            {
                //displays the size in meters of the current screen area account for zoom and window dimensions
                var windowCornerInWorldCoordinate = _uiState.Camera.WorldCoordinate_m((int)_uiState.MainWinSize.X, (int)_uiState.MainWinSize.Y);
                ImGui.Text("Current screen is:");
                ImGui.Text(ECSLib.Stringify.Distance(((windowCornerInWorldCoordinate.X - _uiState.Camera.CameraWorldPosition_m.X) * 2)) + " wide.");
                ImGui.Text(ECSLib.Stringify.Distance((-(windowCornerInWorldCoordinate.Y - _uiState.Camera.CameraWorldPosition_m.Y) * 2)) + " tall.");
                //ImGui.Text((_uiState.Camera.WorldCoordinate_m((int)_uiState.Camera.ViewPortSize.X, (int)_uiState.Camera.ViewPortSize.Y).X - _uiState.Camera.CameraWorldPosition_m.X).ToString());
                var mpp = _uiState.Camera.WorldDistance_m(1);

                /* I can't math. why can't I math?
                 * var lightMetersPerS = 299792458;
                 * var lightsecondsPerMeter = 3.33564e-9;
                 * var lspp = lightsecondsPerMeter * mpp;
                 * var ppls = mpp / 299792458;
                 * ImGui.Text("Meters Per Pixel: " + mpp);
                 * ImGui.Text("Light Seconds Per Pixel: " + lspp);
                 * ImGui.Text("Pixels Per Light Second: " + ppls);
                 */
                //the measure button, when clicked class starts listening for first mouse click to start measuring stick, wherever the mouse goes after that is the other end of the measuring stick.
                if (ImGui.Button("Measure"))
                {
                    _measuring = true;
                }
                //if the first click hasnt been done but the Measure button has been clicked, then display tooltip indicating you are measuring.
                if (_measuring && !_firstClickDone)
                {
                    ImGui.SetTooltip("measuring...");
                }
                //if the first click has already been done, then start showing distance and draw line between first click and the latest mouse position
                else if (_firstClickDone)
                {
                    if (_zoomLevelAtFirstClick != _uiState.Camera.ZoomLevel)
                    {
                        _stopMeasuring();
                    }
                    else
                    {
                        ECSLib.Vector3 lastMousePos            = _uiState.Camera.MouseWorldCoordinate_m();
                        Vector2        lastMousePosInViewCoord = ImGui.GetMousePos();

                        SDL.SDL_SetRenderDrawColor(_uiState.rendererPtr, 255, 255, 255, 255);
                        SDL.SDL_RenderDrawLine(_uiState.rendererPtr, (int)_firstClickInViewCoord.X, (int)_firstClickInViewCoord.Y, (int)lastMousePosInViewCoord.X, (int)lastMousePosInViewCoord.Y);
                        double metricDistance = Math.Sqrt(Math.Pow(_firstClick.X - lastMousePos.X, 2) + Math.Pow(_firstClick.Y - lastMousePos.Y, 2));
                        double lightseconds   = metricDistance / 299792458;
                        string tooltipString  = Stringify.Distance(metricDistance) + "\r\n" + lightseconds + "ls";
                        ImGui.SetTooltip(tooltipString);
                    }
                }

                ImGui.End();
            }
            else
            {
                _stopMeasuring();
            }
        }
コード例 #2
0
        public bool Display()
        {
            bool  changes       = false;
            float maxprogradeDV = (float)(_maxDV - Math.Abs(_radialDV));
            float maxradialDV   = (float)(_maxDV - Math.Abs(_progradeDV));

            if (ImGui.SliderFloat("Prograde DV", ref _progradeDV, -maxprogradeDV, maxprogradeDV))
            {
                Calcs();
                changes = true;
            }
            if (ImGui.SliderFloat("Radial DV", ref _radialDV, -maxradialDV, maxradialDV))
            {
                Calcs();
                changes = true;
            }

            ImGui.Text("Fuel to burn:" + Stringify.Mass(_fuelToBurn));
            ImGui.Text("Burn time: " + (int)(_fuelToBurn / _fuelRate) + " s");
            ImGui.Text("DeltaV: " + Stringify.Distance(DeltaV.Length()) + "/s of " + Stringify.Distance(_maxDV) + "/s");
            ImGui.Text("Eccentricity: " + Eccentricity.ToString("g3"));
            return(changes);
        }
コード例 #3
0
        internal override void Display()
        {
            if (IsActive)
            {
                var size = new Vector2(200, 100);
                var pos  = new Vector2(_uiState.MainWinSize.X / 2 - size.X / 2, _uiState.MainWinSize.Y / 2 - size.Y / 2);

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

                if (ImGui.Begin(_displayText, ref IsActive, _flags))
                {
                    //put calcs that needs refreshing each frame in here. (ie calculations from mouse cursor position)
                    if (_orbitWidget != null)
                    {
                        switch (CurrentState)
                        {
                        case States.NeedsEntity:

                            break;

                        case States.NeedsTarget:
                        {
                        }

                        break;

                        case States.NeedsInsertionPoint:
                        {
                            if (_newtonUI != null)
                            {
                                if (_newtonUI.Display())
                                {
                                    InsertionCalcs();
                                }
                            }

                            var mousePos = ImGui.GetMousePos();

                            var mouseWorldPos = _uiState.Camera.MouseWorldCoordinate_m();
                            _targetInsertionPoint_m = (mouseWorldPos - GetTargetPosition());         //ralitive to the target body

                            _moveWidget.SetArrivalPosition(_targetInsertionPoint_m);

                            //var velAU = OrbitProcessor.PreciseOrbitalVector(sgpCBAU, ralPosCBAU, smaCurrOrbtAU);


                            _ke_m = OrbitMath.KeplerFromPositionAndVelocity(_stdGravParamTargetBody_m, _targetInsertionPoint_m, _insertionOrbitalVelocity_m, _departureDateTime);


                            _orbitWidget.SetParametersFromKeplerElements(_ke_m, _targetInsertionPoint_m);
                            _apoapsis_m  = _ke_m.Apoapsis;
                            _periapsis_m = _ke_m.Periapsis;
                            Eccentricity = _ke_m.Eccentricity;
                            break;
                        }

                        case States.NeedsActioning:
                        {
                            if (_newtonUI != null)
                            {
                                if (_newtonUI.Display())
                                {
                                    InsertionCalcs();
                                }
                            }
                            _ke_m = OrbitMath.KeplerFromPositionAndVelocity(_stdGravParamTargetBody_m, _targetInsertionPoint_m, _insertionOrbitalVelocity_m, _departureDateTime);

                            _orbitWidget.SetParametersFromKeplerElements(_ke_m, _targetInsertionPoint_m);
                            _apoapsis_m  = _ke_m.Apoapsis;
                            _periapsis_m = _ke_m.Periapsis;
                            Eccentricity = _ke_m.Eccentricity;
                            break;
                        }

                        default:
                            break;
                        }
                    }


                    ImGui.SetTooltip(_tooltipText);
                    ImGui.Text("Target: ");
                    if (TargetEntity != null)
                    {
                        ImGui.SameLine();
                        ImGui.Text(TargetEntity.Name);
                    }

                    //ImGui.Text("Eccentricity: " + _eccentricity.ToString("g3"));

                    if (ImGui.CollapsingHeader("Orbit Data"))
                    {
                        ImGui.Text("Apoapsis: ");
                        ImGui.SameLine();
                        ImGui.Text(Stringify.Distance(_apoapsis_m) + " (Alt: " + Stringify.Distance(_apAlt) + ")");

                        ImGui.Text("Periapsis: ");
                        ImGui.SameLine();
                        ImGui.Text(Stringify.Distance(_periapsis_m) + " (Alt: " + Stringify.Distance(_peAlt) + ")");

                        ImGui.Text("DepartureSpeed: ");
                        //ImGui.SameLine();
                        ImGui.Text(Stringify.Distance(_departureOrbitalSpeed_m) + "/s");

                        ImGui.Text("InsertionSpeed: ");
                        //ImGui.SameLine();
                        ImGui.Text(Stringify.Distance(_insertionOrbitalSpeed_m) + "/s");



                        ImGui.Text("Departure Vector: ");
                        //ImGui.SameLine();
                        ImGui.Text("X: " + Stringify.Distance(_departureOrbitalVelocity_m.X) + "/s");
                        ImGui.Text("Y: " + Stringify.Distance(_departureOrbitalVelocity_m.Y) + "/s");
                        ImGui.Text("Z: " + Stringify.Distance(_departureOrbitalVelocity_m.Z) + "/s");


                        ImGui.Text("Departure Angle: ");
                        ImGui.SameLine();
                        ImGui.Text(_departureAngle.ToString("g3") + " radians or " + Angle.ToDegrees(_departureAngle).ToString("F") + " deg ");

                        /*
                         * var pc = OrbitProcessor.InstantaneousOrbitalVelocityPolarCoordinate(_orderEntityOrbit, _departureDateTime);
                         *
                         * ImGui.Text("Departure Polar Coordinates: ");
                         * ImGui.Text(pc.Item1.ToString() + " AU or " + Distance.AuToMt(pc.Item1).ToString("F") + " m/s");
                         * ImGui.Text(pc.Item2.ToString("g3") + " radians or " + Angle.ToDegrees(pc.Item2).ToString("F") + " deg ");
                         * ;
                         */

                        ImGui.Text("Insertion Vector: ");
                        ImGui.Text("X: " + Stringify.Distance(_insertionOrbitalVelocity_m.X) + "/s");
                        ImGui.Text("Y: " + Stringify.Distance(_insertionOrbitalVelocity_m.Y) + "/s");
                        ImGui.Text("Z: " + Stringify.Distance(_insertionOrbitalVelocity_m.Z) + "/s");

                        ImGui.Text("Insertion Position: ");
                        ImGui.Text("X: " + Stringify.Distance(_targetInsertionPoint_m.X));
                        ImGui.Text("Y: " + Stringify.Distance(_targetInsertionPoint_m.Y));
                        ImGui.Text("Z: " + Stringify.Distance(_targetInsertionPoint_m.Z));

                        ImGui.Text("LoAN: ");
                        ImGui.SameLine();
                        ImGui.Text(_ke_m.LoAN.ToString("g3"));

                        ImGui.Text("AoP: ");
                        ImGui.SameLine();
                        ImGui.Text(_ke_m.AoP.ToString("g3"));

                        ImGui.Text("LoP Angle: ");
                        ImGui.SameLine();
                        ImGui.Text((_ke_m.LoAN + _ke_m.AoP).ToString("g3") + " radians or " + Angle.ToDegrees(_ke_m.LoAN + _ke_m.AoP).ToString("F") + " deg ");

                        if (_orbitWidget != null)
                        {
                            ImGui.Text("Is Retrograde " + _orbitWidget.IsRetrogradeOrbit.ToString());
                        }
                    }

                    //if (CurrentState != States.NeedsActioning) //use alpha on the button if it's not useable.
                    //ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
                    if (ImGui.Button("Action Order") && CurrentState == States.NeedsActioning) //only do suff if clicked if it's usable.
                    {
                        fsm[(byte)CurrentState, (byte)Events.ClickedAction].Invoke();
                        //ImGui.PopStyleVar();
                    }

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

                    ImGui.End();
                }
            }
        }
コード例 #4
0
        internal override void Display()
        {
            ImGui.SetNextWindowSize(new Vector2(400, 400), ImGuiCond.Once);
            if (IsActive == true && ImGui.Begin("Planetary window: " + _lookedAtEntity.Name, ref IsActive, _flags))
            {
                if (ImGui.SmallButton("general info"))
                {
                    _selectedSubWindow = PlanetarySubWindows.generalInfo;
                }
                ImGui.SameLine();
                if (ImGui.SmallButton("installations"))
                {
                    _selectedSubWindow = PlanetarySubWindows.installations;
                }
                ImGui.BeginChild("data");
                switch (_selectedSubWindow)
                {
                case PlanetarySubWindows.generalInfo:
                    if (_lookedAtEntity.Entity.HasDataBlob <MassVolumeDB>())
                    {
                        var tempMassVolume = _lookedAtEntity.Entity.GetDataBlob <MassVolumeDB>();
                        ImGui.Text("radius: " + Stringify.Distance(tempMassVolume.RadiusInM));
                        ImGui.Text("mass: " + tempMassVolume.MassDry.ToString() + " kg");
                        ImGui.Text("volume: " + tempMassVolume.Volume_m3.ToString() + " m^3");
                        ImGui.Text("density: " + tempMassVolume.Density_gcm + " kg/m^3");
                    }
                    if (_lookedAtEntity.Entity.HasDataBlob <ColonyInfoDB>())
                    {
                        ColonyInfoDB tempColonyInfo = _lookedAtEntity.Entity.GetDataBlob <ColonyInfoDB>();
                        ImGui.Text("populations: ");
                        foreach (var popPerSpecies in tempColonyInfo.Population)
                        {
                            ImGui.Text(popPerSpecies.Value.ToString() + " of species: ");
                            ImGui.SameLine();
                            if (popPerSpecies.Key.HasDataBlob <NameDB>())
                            {
                                ImGui.Text(popPerSpecies.Key.GetDataBlob <NameDB>().DefaultName);
                            }
                            else
                            {
                                ImGui.Text("unknown.");
                            }
                        }
                    }
                    if (_lookedAtEntity.Entity.HasDataBlob <InstallationsDB>())
                    {
                        InstallationsDB tempInstallations = _lookedAtEntity.Entity.GetDataBlob <InstallationsDB>();
                    }


                    break;

                case PlanetarySubWindows.installations:
                    break;

                default:
                    break;
                }
                ImGui.EndChild();
                ImGui.End();
            }
        }