Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add System Overview Widget to System Map view #5327

Merged
merged 10 commits into from
Jan 24, 2022

Conversation

Web-eWorks
Copy link
Member

This PR adds the System Overview widget (the body list in the top right of the world view) to both of the System Map view modes. It also refactors out the layout code from both the Sector Map and System Map into a single reusable module for creating full-screen UIs.

It also changes the focus-object interaction in the SystemView to use double-clicks instead of single-clicks; this may be a slightly controversial change, but having selection state decoupled from focus state is fairly useful when interacting with the overview widget.

This is likely the last of the work branches I have outstanding to be merged into the release, nothing else is close enough to done to be a viable candidate.

@impaktor
Copy link
Member

It also refactors out the layout code from both the Sector Map and System Map into a single reusable module for creating full-screen UIs.

Perchance, a base could be painted on this.... onto which one could walk.... and stabby-stabby-stabby people, and take their loot, and in a bar listen to their tales of great adventure, and stuff. (One of these days, I'll muster up the energy to get cracking on this, (as the British say)).

@Web-eWorks
Copy link
Member Author

Perchance, a base could be painted on this.... onto which one could walk.... and stabby-stabby-stabby people, and take their loot, and in a bar listen to their tales of great adventure, and stuff. (One of these days, I'll muster up the energy to get cracking on this, (as the British say)).

Unfortunately probably not, this is specifically designed for creating a UI on top of other fullscreen interactable content (e.g. Flight UI, Map screens, etc.). For something like the Bar screen I might have a few ideas up my sleeve in the future to make it a bit easier to build, but I can't really say anything concrete at this juncture. Having a proper mockup / concept art really helps make UI a reality though, so perhaps @nozmajner would be happy to help... in the appropriate discussion venue, of course.

@Gliese852
Copy link
Contributor

when I try to open a system map, for example, in Barnard Star, I get an assertion
src/galaxy/StarSystem.cpp:202: SystemBody* StarSystem::GetBodyByPath(const SystemPath&) const : Assertion 'm_path.IsSameSystem(path)' failed.

@Gliese852
Copy link
Contributor

How can I hide system-overview-window in the system map?

@Gliese852
Copy link
Contributor

Gliese852 commented Jan 21, 2022

'center' context menu item does not center
EDIT: although this is not from this PR

@Web-eWorks
Copy link
Member Author

when I try to open a system map, for example, in Barnard Star, I get an assertion src/galaxy/StarSystem.cpp:202: SystemBody* StarSystem::GetBodyByPath(const SystemPath&) const : Assertion 'm_path.IsSameSystem(path)' failed.

Dangit, that's what I get for running without assertions enabled. Will look into that.

The system overview widget does not have a hide button in the map screen, although that is probably something worth adding.

data/pigui/libs/window-layout.lua Show resolved Hide resolved
data/pigui/modules/flight-ui/system-overview.lua Outdated Show resolved Hide resolved
data/pigui/modules/flight-ui/system-overview.lua Outdated Show resolved Hide resolved
data/pigui/modules/system-overview-window.lua Show resolved Hide resolved
data/pigui/views/map-sector-view.lua Show resolved Hide resolved
data/pigui/views/map-sector-view.lua Outdated Show resolved Hide resolved
data/pigui/libs/wrappers.lua Outdated Show resolved Hide resolved
The window-layout class abstracts common functionality from Sector and System views and provides a simpler interface for building auto-sizing windows.
SystemOverviewWidget now contains all reusable logic for displaying the list of SystemBodies in a system.

The system-overview FlightUI module now handles displaying the flight-UI specific body overview list.
Due to unknown issues with SystemBody refs using different userdata 'wrapper' objects, we must propagate selection state in entries instead using the selected array.
Avoids the complication of passing the disableCeil parameter to rescaleUI
Scissor test state was not properly tracked by the render state cache, leading to it being incorrectly enabled.
@Gliese852
Copy link
Contributor

Gliese852 commented Jan 22, 2022

@Web-eWorks

when I try to open a system map, for example, in Barnard Star, I get an assertion src/galaxy/StarSystem.cpp:202: SystemBody* StarSystem::GetBodyByPath(const SystemPath&) const : Assertion 'm_path.IsSameSystem(path)' failed.

Dangit, that's what I get for running without assertions enabled. Will look into that.

Also, this is not in the master, this PR is to blame

backtrace:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff572a921 in __GI_abort () at abort.c:79
#2  0x00007ffff571a48a in __assert_fail_base (fmt=0x7ffff58a1750 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x555555a37cb2 "m_path.IsSameSystem(path)", file=file@entry=0x555555a377d0 ".../pioneer/src/galaxy/StarSystem.cpp", line=line@entry=202, function=function@entry=0x555555a396a0 <StarSystem::GetBodyByPath(SystemPath const&) const::__PRETTY_FUNCTION__> "SystemBody* StarSystem::GetBodyByPath(const SystemPath&) const") at assert.c:92
#3  0x00007ffff571a502 in __GI___assert_fail (assertion=assertion@entry=0x555555a37cb2 "m_path.IsSameSystem(path)", file=file@entry=0x555555a377d0 ".../pioneer/src/galaxy/StarSystem.cpp", line=line@entry=202, function=function@entry=0x555555a396a0 <St arSystem::GetBodyByPath(SystemPath const&) const::__PRETTY_FUNCTION__> "SystemBody* StarSystem::GetBodyByPath(const SystemPath&) const") at assert.c:101
#4  0x000055555568273d in StarSystem::GetBodyByPath (this=<optimized out>, path=...) at .../pioneer/src/galaxy/StarSystem.cpp:202
#5  0x0000555555633250 in Space::FindBodyForPath (this=0x55555ea92a30, path=<optimized out>) at .../pioneer/src/Space.cpp:545
#6  0x00005555558c4a28 in l_sbody_attr_body (l=0x555555e4e160) at .../pioneer/src/lua/LuaSystemBody.cpp:633
#7  0x00005555558e0d06 in luaD_precall (L=L@entry=0x555555e4e160, func=<optimized out>, nresults=1) at .../pioneer/contrib/lua/src/ldo.c:318
#8  0x00005555558e1082 in luaD_call (L=0x555555e4e160, func=<optimized out>, nResults=<optimized out>, allowyield=<optimized out>) at .../pioneer/contrib/lua/src/ldo.c:394
#9  0x00005555558e05df in luaD_rawrunprotected (L=L@entry=0x555555e4e160, f=f@entry=0x5555558d7f70 <f_call>, ud=ud@entry=0x7fffffffd500) at .../pioneer/contrib/lua/src/ldo.c:131
#10 0x00005555558e137f in luaD_pcall (L=L@entry=0x555555e4e160, func=func@entry=0x5555558d7f70 <f_call>, u=u@entry=0x7fffffffd500, old_top=1600, ef=<optimized out>) at .../pioneer/contrib/lua/src/ldo.c:595
#11 0x00005555558da0d5 in lua_pcallk (L=L@entry=0x555555e4e160, nargs=nargs@entry=1, nresults=nresults@entry=1, errfunc=errfunc@entry=6, ctx=ctx@entry=0, k=k@entry=0x0) at .../pioneer/contrib/lua/src/lapi.c:949
#12 0x00005555558d770e in pi_lua_protected_call (L=L@entry=0x555555e4e160, nargs=nargs@entry=1, nresults=nresults@entry=1) at .../pioneer/src/lua/core/Sandbox.cpp:177
#13 0x0000555555891d4c in get_method_or_attr (l=l@entry=0x555555e4e160) at .../pioneer/src/lua/LuaMetaType.cpp:76
#14 0x0000555555892698 in l_index (l=0x555555e4e160) at .../pioneer/src/lua/LuaMetaType.cpp:133
#15 0x00005555558e0d06 in luaD_precall (L=L@entry=0x555555e4e160, func=<optimized out>, nresults=1) at .../pioneer/contrib/lua/src/ldo.c:318
#16 0x00005555558e10a8 in luaD_call (L=L@entry=0x555555e4e160, func=<optimized out>, nResults=nResults@entry=1, allowyield=<optimized out>) at .../pioneer/contrib/lua/src/ldo.c:394
#17 0x00005555558edf0a in callTM (L=L@entry=0x555555e4e160, p1=p1@entry=0x555568b8acc0, p2=p2@entry=0x555556ac78d0, p3=p3@entry=0x555568b8ad10, hasres=1, f=<optimized out>, f=<optimized out>) at .../pioneer/contrib/lua/src/lvm.c:102
#18 0x00005555558ee21c in luaV_gettable (L=L@entry=0x555555e4e160, t=0x555568b8acc0, key=0x555556ac78d0, val=val@entry=0x555568b8ad10) at .../pioneer/contrib/lua/src/lvm.c:127
#19 0x00005555558ef8d0 in luaV_execute (L=L@entry=0x555555e4e160) at .../pioneer/contrib/lua/src/lvm.c:588
#20 0x00005555558e108e in luaD_call (L=0x555555e4e160, func=<optimized out>, nResults=<optimized out>, allowyield=<optimized out>) at .../pioneer/contrib/lua/src/ldo.c:395
#21 0x00005555558e05df in luaD_rawrunprotected (L=L@entry=0x555555e4e160, f=f@entry=0x5555558d7f70 <f_call>, ud=ud@entry=0x7fffffffd920) at .../pioneer/contrib/lua/src/ldo.c:131
#22 0x00005555558e137f in luaD_pcall (L=L@entry=0x555555e4e160, func=func@entry=0x5555558d7f70 <f_call>, u=u@entry=0x7fffffffd920, old_top=304, ef=<optimized out>) at .../pioneer/contrib/lua/src/ldo.c:595
#23 0x00005555558da0d5 in lua_pcallk (L=L@entry=0x555555e4e160, nargs=nargs@entry=1, nresults=nresults@entry=1, errfunc=errfunc@entry=18, ctx=ctx@entry=0, k=k@entry=0x0) at .../pioneer/contrib/lua/src/lapi.c:949
#24 0x00005555558d770e in pi_lua_protected_call (L=0x555555e4e160, nargs=nargs@entry=1, nresults=nresults@entry=1) at .../pioneer/src/lua/core/Sandbox.cpp:177
#25 0x00005555556b90cd in LuaTable::Call<bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, double> (this=this@entry=0x7fffffffda40, key="system-view") at .../pioneer/src/lua/LuaTable.h:402
#26 0x00005555556b847b in PiGui::RunHandler (delta=<optimized out>, handler="system-view") at .../pioneer/src/pigui/LuaPiGui.cpp:85
#27 0x00005555556d28b3 in PiGuiView::DrawPiGui (this=<optimized out>) at .../pioneer/src/pigui/PiGuiView.cpp:10
#28 0x00005555555dab84 in GameLoop::Update (this=0x555555e3e1d0, deltaTime=0.0160664637) at .../pioneer/src/Pi.cpp:1024
#29 0x00005555559b5306 in Application::Run (this=0x555555e3def0) at .../pioneer/src/core/Application.cpp:187
#30 0x00005555555aa5cd in main (argc=1, argv=0x7fffffffdf38) at .../pioneer/src/main.cpp:186

@impaktor
Copy link
Member

Ah, I get it now. The new System Atlas Mode (#5239) only shows orbital bodies, not stations on them (like the old version did), so this will solve that problem neatly.

@Gliese852
Copy link
Contributor

when I try to open a system map, for example, in Barnard Star, I get an assertion
src/galaxy/StarSystem.cpp:202: SystemBody* StarSystem::GetBodyByPath(const SystemPath&) const : Assertion 'm_path.IsSameSystem(path)' failed.

@Web-eWorks here is lua traceback:

[C](-1): ?                                                                                                                                                                                                                                                                       
[C](-1): __index                                                                                                                                                                                                                                                                 
[string "[T] @pigui/modules/system-overview-window.lua..."](77): calculateEntry                                                                                                                                                                                                  
[string "[T] @pigui/modules/system-overview-window.lua..."](224): fun                                                                                                                                                                                                            
[string "[T] @pigui/libs/wrappers.lua"](235): child                                                                                                                                                                                                                              
[string "[T] @pigui/modules/system-overview-window.lua..."](223): display                                                                                                                                                                                                        
[string "[T] @pigui/modules/system-view-ui.lua"](205): fun                                                                                                                                                                                                                       
[string "[T] @pigui/libs/wrappers.lua"](543): withFont                                                                                                                                                                                                                           
[string "[T] @pigui/modules/system-view-ui.lua"](204): Show                                                                                                                                                                                                                      
[string "[T] @pigui/libs/window-layout.lua"](74): fun                                                                                                                                                                                                                            
[string "[T] @pigui/libs/wrappers.lua"](90): window                                                                                                                                                                                                                              
[string "[T] @pigui/libs/window-layout.lua"](73): fun                                                                                                                                                                                                                            
[string "[T] @pigui/libs/wrappers.lua"](543): withFont                                                                                                                                                                                                                           
[string "[T] @pigui/libs/window-layout.lua"](69): display                                                                                                                                                                                                                        
[string "[T] @pigui/modules/system-view-ui.lua"](718): window_fnc                                                                                                                                                                                                                
[string "[T] @pigui/baseui.lua"](49): fun                                                                                                                                                                                                                                        
[string "[T] @pigui/libs/wrappers.lua"](90): window                                                                                                                                                                                                                              
[string "[T] @pigui/baseui.lua"](47): ?

as I understand it, this is due to the fact that you use the body attribute on the systemBody, and for remote systems, the systemBody does not have a real body. I counted ~10 accesses to this attribute in system-overview-window.lua and all that will not work when the system map does not display the current system.

Attempting to access SystemBody.body from Lua returns nil for remote systems.
@Web-eWorks
Copy link
Member Author

as I understand it, this is due to the fact that you use the body attribute on the systemBody, and for remote systems, the systemBody does not have a real body. I counted ~10 accesses to this attribute in system-overview-window.lua and all that will not work when the system map does not display the current system.

Fixed. That assert is something that Lua shouldn't be able to trigger (and doesn't have any easy way to tell if a system body has a real body associated without querying that variable) so I added some error handling for that case.

@Web-eWorks Web-eWorks merged commit a43780c into pioneerspacesim:master Jan 24, 2022
@Web-eWorks Web-eWorks deleted the system-overview-widget branch May 14, 2022 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants