Commit Graph

230 Commits (2a8c39f854ce5b0801716e145106e27ee1cabc10)

Author SHA1 Message Date
Gliese852 5004b09483 Improve/fix system map
- add a "static" orbit for bodies that are not moving anywhere
- now bodies in a rotating frame and also in the spaceport frame have
  such "static" orbits
- add display of the orbits of objects moving strictly to the star or
  from the star
- fix compile warning for possibly uninitiated variable in
  LuaSystemView.cpp
- fix an issue where smooth animation sometimes have a hard time
  catching up with a newly selected object

Fixes #5062
2021-02-01 02:31:24 -05:00
Gliese852 04cf347dd3 Do not try to GetStarSystem from hyperspace
Small fix to segfault when opening the system map during a hyperjump

fixes #5096
2021-01-16 14:37:03 -05:00
Karl F 9e44b09314 Happy new year!
HAPPY MERRY 2021!
2021-01-03 19:40:16 +01:00
Gliese852 775bb689a9
Fix SIGSEGV on switch to system map after HJ (#5077)
If you turn on the ships in the system map, turn off the system map and
jump into another system, then pointers to the ships from the previous
system remain in m_projectables, which cause the a segfault. Now clear
this when switching from view.
2020-12-15 12:17:06 -05:00
Webster Sheets 013721f405 Draw space background in SystemView
- Steal the current space's background object; ideally SystemView should have its own copy it generates for systems
- Don't draw stars sourced from the current system's position when looking at other systems
- The background system in general doesn't respect the plane of the ecliptic vs the galactic plane.
  This is a problem that affects WorldView as well as the SystemView
2020-12-11 17:42:16 -05:00
Webster Sheets 365476dfe3 Move TransferPlanner to its own file 2020-12-11 17:42:16 -05:00
Gliese852 5b1e62e978 Show surface starports in the system map 2020-12-10 18:04:03 -05:00
Gliese852 8bb5d451e9 Some map fixes
- fix segfault in the system map if a centered ship is removed
- reset the system map view if the centered ship is hidden
- if the mission target is a specific systembody, when you press the "set
  as nav target" button, the sector map is set to the correct star of the
  multiple system
- shrink the searchbar window in the sector map when nothing is shown on
  it
2020-12-03 16:56:31 -05:00
Webster Sheets e16b978fca Use PiGuiView instead of UIView 2020-11-25 13:57:52 -05:00
Webster Sheets 37c96041e1
Refactor Body inheritance tree to remove Object and CityOnPlanet (#4995)
* Remove CityOnPlanet from Object hierarchy

* Remove Object from the inheritance hierarchy

* Rename Object -> ObjectType
2020-11-11 19:33:04 -05:00
Webster Sheets f5d7038d69 Refactor to InputFrame 2.0
Significantly refactored the Input class, added Input::Manager to handle
most duties of the Input system.

Replaced the legacy KeyBindings system with the new InputBindings
(namespace subject to change) system for handling key state and key
chords - among other improvements, there is no longer a hardcoded
dependency on Pi::input anymore, as well as storing the binding state in
the binding itself, completely decoupling InputBindings from the input
system that handles input events and significantly reducing the
complexity of the binding system.

Input::Manager now is totally responsible for generating binding events,
removing the need for WorldView::HandleSDLEvent and its ilk - interested
parties can simply bind to the onPressed event and they will only be
notified when the binding in question is part of an active input frame
and nothing else has grabbed the input event, vastly simplifying control
flow.

Among other effects, this almost totally eradicates the need for
Pi::IsConsoleActive().

The lua Console widget is slightly broken as a result of this change,
it doesn't handle activation/deactivation state changes properly. The
solution to this seems to simply be a direct rewrite in PiGui, which
I don't expect to cause too many issues.

I've added a CMake option to use LLD to speed up incremental build link
times; this seems to be somewhat platform dependent and is not
implemented for windows at this time.

Serialization of key bindings to the config file is totally completed,
although support for a graphical method of binding multi-key chords is
not anticipated for this pull request.
2020-11-11 18:41:34 -05:00
Webster Sheets d3fd88a9ec Add Graphics::ProjectToScreen
This is intended to replace Gui::Screen::Project in 90% of cases
It's a much better function to use especially in the case of a resizing screen.
Rewrite part of SystemView to take advantage of this function.

Fix directional indicators not screen-culling
2020-10-22 16:38:34 -04:00
Webster Sheets dea84d1de0 Use Reverse-Z depth buffer
Converts clip space from -1..1 to 0..1, and maps 1.0 to the near plane to symmetrize floating point precision
This means we can entirely drop the logZ hack and use the early-Z depth test.
Also add (and comment) several projection matrix functions.
2020-10-22 16:38:34 -04:00
Webster Sheets f16ad5711f Fix #includes
Move PiGui::RunHandler to pigui/LuaPiGui.h
Fix includes for new LuaPiGui header location.
2020-09-27 13:11:11 -04:00
Webster Sheets ca6d23a71a
Merge pull request #4907 from Gliese852/safe-hyperspace
No more crashes when hyperjumping
2020-09-09 11:30:19 -04:00
Webster Sheets 0d1cca4cd1 Remove matrix4x4ftod and its ilk
Replace all instances of the manual conversion with an explicit conversion constructor.
2020-09-07 15:31:15 -04:00
Gliese852 aeeea56e97 Fix crashes when hyperjump with a map opened
Fixes #4901

System map: add a check to see if we are in hyperspace

Sector map:
 - move the drawing of the player's indicator from DrawNearSector up to
Draw3D
 - calculate the interpolated position of the player's indicator during
a hyperjump
 - don't display current system during hyperjump (lua-side)
 - fix selected system indicator (green circle), it pointed not to
the the selected system, but to the current system

Also:
 - add easing function into utils.cpp to smooth the movement of the
player indicator
 - move fuel reduction from the start of the hyperjump to the end
 - force handling of lua events immediately after entering system
2020-09-06 13:00:19 +03:00
Gliese852 5330100577 Additional minor tweaks to the maps
- move detailed route calculation to a separate function, now it does
not execute every frame, only when changing the route or when changing
the equipment
- attach lambda functions to the OnPressed callbacks of these input actions
instead of the generic OnKeyPressed callback
- add some comments
2020-06-30 21:15:25 +03:00
Gliese852 17e850e3a3 Add input bindings for the maps to the settings
- Used the previously defined lines in /core/*.json, so I added an
additional line search for this directory
- Add some strings to input-core/en.json
- Convert key pairs in axis
- Remove unused bindings in KeyBindings.h
- Completely remove several bindings that became irrelevant
- Use some input bindings for the sector map in the system map
2020-06-05 22:45:44 +03:00
Gliese852 9d8be40bc9 Fixes/improvements to the system map
- Separate grid color and grid leg color, adjust that colors.
- Fix little problem with popup menu (sometimes is started showing the
wrong object)

src/SystemView.cpp:

- Refactor zooming in the SystemView: make zoom part of the camera space
matrix. Now, multiplying by m_zoom is done only once, (there were 17).
- Fix that smooth transitions did not affect the grid
- Add clamping the camera pitch, like in the SectorView
- Add grid legs for every "icon object" in the system map
2020-06-05 22:45:38 +03:00
Edoardo Morandi e6b9cd8d71 Remove many warnings 2020-04-25 01:31:42 +02:00
Gliese852 ac7e98248e Additional fixes related (almost) to System Map
- Now only those orbits whose radius is less than 1% of the screen width are not shown.
- Add smooth transition when click object.
- Improve system bodies orbits.
- Fix that ..apsis and lagrange points were displayed in the wrong place.

- After rescanning enums, an error was found in the pigui/Face.h, fixed. fixes #4801
- Some indentations to pass clang
- Added static_cast to Space.cpp, because it caused a warning at compilation.
2020-04-04 16:27:44 +03:00
Gliese852 af5d52cfd9 Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.

The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.

To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.

The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.

All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.

* Improvements/fixes: *

- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
    planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
    Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.

* Changes in the files explained *

    SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json

The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.

    LuaEngine.cpp

Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)

    Space.cpp

Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.

    LuaSystemBody.cpp

Added attributes to determine the shape of the icon and set the
navigation target.

    enum_table.cpp, enum_table.h

Rescanned enums to pass color settings and object types between Lua and
C++.

    LuaGame.cpp

The float does not have enough accuracy to display time up to seconds,
change to double.

    icons.svg, themes/default.lua

Add rotate view icon
2020-04-04 11:56:10 +03:00
Webster Sheets 0c67f400c9 Clean up header dependencies
A lot of source files were depending on utils.h being included by other headers
Cleaned up code that was depending on Input.h being included in Pi.h
2020-03-27 16:45:17 -04:00
Webster Sheets 64e768e9c5 Change Pi::input to a pointer
Pi.cpp is not included because it's currently being gutted
Decoupled Input::Init() from Pi::config to better support headless mode
2020-03-26 00:34:04 -04:00
Webster Sheets 485643ce13 Merge branch 'ui-hot-reload-refactor' into master 2020-02-19 14:40:31 -05:00
Gliese852 a086c771f6 indentation & clang satisfaction 2020-02-02 15:16:39 +03:00
Gliese852 393408cd34 Minor improvements to System Map
1. Reject back-projected 2d objects.
Since the function Gui::Screen::Project does not cull points
(and most likely should not), this must be done manually, as was
done in the SectorView.cpp for labels. Checking z < 1 in the Normalized Device
Coordinates discards points that are further than the zfar clipping plane,
and beyond the center of the camera. The points between the center of the
camera and the znear clipping plane remain. They may be needed.

2. Adjust z-far plane for projection to clip space.
With a severe zooming in, the coordinates of objects can become too large and
fly out of the z-far plane. Therefore, it was done so that the z-far plane
moved away proportionally. But with a severe zooming out, it z-far plane can
become smaller than DEFAULT_VIEW_DISTANCE, and this is also taken into account.

3. Change the axis of rotation when dragging the mouse horizontally.
Set horizontal rotation around the axis of the ecliptic. It seems to me that
it’s more convenient to examine the system. For good, it was necessary to
rename the variable from m_rot_z to m_rot_y, but I did not want to
recompile everything.

4. Do not calculate and draw the player’s orbit when it is docked or landed.
2020-02-02 15:16:39 +03:00
Webster Sheets ec410f31d8 Update includes to point to new lua/ directory 2020-01-20 18:13:45 -05:00
Karl F 436db08636 Happy new decade!
May you live long and prosper!
2020-01-01 10:47:46 +01:00
mike-f1 4f1eaa41d3 Update all files to store and use FrameId instead of raw pointers 2019-11-16 17:54:14 +01:00
mike-f1 e1c389c12d Added grid and legs display and a reset orient to SystemView 2019-11-16 17:54:14 +01:00
mike-f1 e6403fc1ad Decouple includes; Remove some unused variable; Fix an equation in Space.cpp 2019-10-20 11:19:45 +02:00
mike-f1 c5412ffcc7 Run clang-format on everything 2019-01-22 20:13:40 +01:00
mike-f1 21455de80b clean Game includes 2019-01-22 20:11:26 +01:00
mike-f1 f1a53cffd6 Remove some inludes from Pi and get things right in order to compile 2019-01-22 20:10:28 +01:00
mike-f1 bcb31c6e28 Clean includes in Body 2019-01-22 20:08:25 +01:00
Webster Sheets 5cdaefad6a Run clang-format over the entire code base.
Fix hidden header-inclusion-order dependency errors.
Update .clang-format for v7.0.1.
2019-01-05 17:09:05 -05:00
Karl F d2ab921b62 Happy New Year!
Awesome sauce (for next year):
find . -type f -exec sed -i 's/2008-2018 Pioneer Developers'/'2008-2019 Pioneer Developers/g' {} \;

closes #4507
2019-01-03 15:28:42 +01:00
CylonicRaider 8e7f5057b8 Bring smooth transitions to system view
Code for animating the zoom level was present but buggy; this corrects
the issue and also animates the current rotation.
2018-10-20 17:58:28 +02:00
Webster Sheets e8a98c2b6a Improve Joystick / Input Handling (#4432)
* Get input handling into its own class, get it out of the core monolith.

* Started work on implementing the input refactor.

Don't even bother compiling this one, it is absolutely broken.

* Continue upgrading and implementing.

Still don't try to compile this.

* IT'S ALIVE!

Or, in other words, it compiles and runs just fine. Still need to re-implement
axis binding and finish moving away from KeyBindings.inc.h, but we're most of
the way there.

* Moved the lua-side code over to the new system.

Still needs changes to work with the localization system and properly
implement axis deadzone and inversion, but it's most of the way there.

* Finalized the new Input changes.
2018-09-06 12:15:17 +01:00
Joscha 94677375ef Uninvert system map camera 2018-07-06 17:59:01 +00:00
Paul B Mahol f550b38e67 Do not clear info label text for explored system
Before this change, selected label text would only appear for one frame.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-06-19 21:59:32 +02:00
Paul B Mahol 5d0c0416c5 Fix some issues with system view
* Do not put landed or docked ship at center of system
* Try to correctly put ships near stations in system view

Closes #3128 and #3509.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-06-19 19:42:46 +02:00
Paul B Mahol e9a57aae7d make ship labels more visible on white disks
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-06-19 19:42:46 +02:00
Jon Jenkins c5d14360f2 Small display changes
Added registration number to ship info screen
Added new icon for systems management, not used yet
Changed color param so orbits are visible in system view

 Changes to be committed:
	modified:   data/icons/icons.svg
	modified:   data/pigui/themes/default.lua
	modified:   data/ui/InfoView/ShipInfo.lua
	modified:   src/SystemView.cpp
2018-01-13 19:06:10 -06:00
Karl F 7225e9c723 Happy New Year!
Ten years in the making now, but how can we improve upon perfection
for ten more years?
2018-01-01 21:22:12 +01:00
Peter d570cfdcd2 Fix all GCC 7.1.1 warnings.
- Use explicit Json::Value::Int.
- Resize some snprintf buffers.
- Ignore -Wfloat-equal where necessary.
2017-06-22 08:21:07 +02:00
Andrew Copland 8cb1555f67 Eliminate the evil trailing whitespace 2017-03-05 13:15:55 +00:00
Andrew Copland 74d50958fe MERRY HAPPY 2017 2017-01-04 15:11:15 +00:00