Skip to content

Commit

Permalink
fixup! reset selected system after hyperspace jump
Browse files Browse the repository at this point in the history
Refactor the implementation so that the logic is handled inside the Lua
"onEnterSystem" callback instead.

Note we are still using the new "ResetSelectedSystem" instead of
"SetSystem" as the latter is not a public function. We could, instead,
change "SetSystem" to be public.

TODO: figure out a way to delay changing the map screen after a hyperspace
jump if the map is currently open.
  • Loading branch information
mwerle committed Sep 27, 2024
1 parent bbb4727 commit 2155638
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 15 deletions.
6 changes: 5 additions & 1 deletion data/pigui/views/map-sector-view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,11 @@ end})
Event.Register("onGameStart", onGameStart)
Event.Register("onEnterSystem", function(ship)
hyperJumpPlanner.onEnterSystem(ship)
if ship:IsPlayer() then hyperspaceDetailsCache = {} end
if ship:IsPlayer() then
hyperspaceDetailsCache = {}
sectorView:ResetHyperspaceTarget()
sectorView:ResetSelectedSystem()
end
end)

-- reset cached data
Expand Down
1 change: 0 additions & 1 deletion src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,6 @@ void Game::SwitchToNormalSpace()

m_player->EnterSystem();
RequestTimeAccel(TIMEACCEL_1X);
onSystemEntered.emit();
}

const float Game::s_timeAccelRates[] = {
Expand Down
5 changes: 0 additions & 5 deletions src/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ class Game {

GameLog *log;

/* Signals */

/** Emitted when exitting hyperspace into a system. */
sigc::signal<void()> onSystemEntered;

private:
class Views {
public:
Expand Down
6 changes: 0 additions & 6 deletions src/SectorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,6 @@ void SectorView::SetDrawRouteLines(bool value)

void SectorView::InitObject()
{
// signal handlers
m_onSystemEntered = m_game.onSystemEntered.connect([&]() {
ResetHyperspaceTarget();
ResetSelectedSystem();
});

// single keystroke handlers
m_onToggleSelectionFollowView =
InputBindings.mapToggleSelectionFollowView->onPressed.connect([&]() {
Expand Down
2 changes: 0 additions & 2 deletions src/SectorView.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ class SectorView : public PiGuiView, public DeleteEmitter {
float m_playerHyperspaceRange;
Uint8 m_detailBoxVisible;

ConnectionTicket m_onSystemEntered;

ConnectionTicket m_onToggleSelectionFollowView;
ConnectionTicket m_onWarpToCurrent;
ConnectionTicket m_onWarpToSelected;
Expand Down
1 change: 1 addition & 0 deletions src/lua/LuaSectorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void LuaObject<SectorView>::RegisterClass()
.AddFunction("AddToRoute", &SectorView::AddToRoute)
.AddFunction("SwitchToPath", &SectorView::SwitchToPath)
.AddFunction("ResetView", &SectorView::ResetView)
.AddFunction("ResetSelectedSystem", &SectorView::ResetSelectedSystem)
.AddFunction("SetHyperspaceTarget", &SectorView::SetHyperspaceTarget)
.AddFunction("ResetHyperspaceTarget", &SectorView::ResetHyperspaceTarget)
.AddFunction("GetMap", [](lua_State *l, SectorView *sv) {
Expand Down

0 comments on commit 2155638

Please sign in to comment.