Skip to content

Commit

Permalink
Merge pull request #1445 from alynsarcana/Hotfix/FixPageUp-DownStruct…
Browse files Browse the repository at this point in the history
…urePicker

Fix PgUp/PgDown not changing structure palette
  • Loading branch information
DanRStevens authored Apr 13, 2024
2 parents 48783f4 + 43b3619 commit 0a22150
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
41 changes: 32 additions & 9 deletions OPHD/States/MapViewState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,11 @@ void MapViewState::onKeyDown(NAS2D::EventHandler::KeyCode key, NAS2D::EventHandl
break;

case NAS2D::EventHandler::KeyCode::KEY_PAGEUP:
mMapView->moveView(MapOffsetUp);
moveView(MapOffsetUp);
break;

case NAS2D::EventHandler::KeyCode::KEY_PAGEDOWN:
mMapView->moveView(MapOffsetDown);
moveView(MapOffsetDown);
break;


Expand Down Expand Up @@ -552,7 +552,7 @@ void MapViewState::onMouseDown(NAS2D::EventHandler::MouseButton button, NAS2D::P
mNavControl->onClick(MOUSE_COORDS);
if (oldDepth != mMapView->currentDepth())
{
changeViewDepth(mMapView->currentDepth());
onChangeDepth(oldDepth, mMapView->currentDepth());
}

// MiniMap Check
Expand Down Expand Up @@ -725,21 +725,44 @@ void MapViewState::onSystemMenu()
resetUi();
}

/**
* Handle side effects of changing depth view
*/
void MapViewState::onChangeDepth(int oldDepth, int newDepth) {
if (mBtnTogglePoliceOverlay.isPressed())
{
changePoliceOverlayDepth(oldDepth, newDepth);
}

if (mInsertMode != InsertMode::Robot) { clearMode(); }

populateStructureMenu();
}

void MapViewState::moveView(MapOffset offset) {
int oldZLevel = mMapView->currentDepth();

mMapView->moveView(offset);

int newZLevel = mMapView->currentDepth();
if (oldZLevel != newZLevel) {
onChangeDepth(oldZLevel, newZLevel);
}
}

/**
* Changes the current view depth.
*/
void MapViewState::changeViewDepth(int depth)
{
if (mBtnTogglePoliceOverlay.isPressed())
{
changePoliceOverlayDepth(mMapView->currentDepth(), depth);
}
int oldZLevel = mMapView->currentDepth();

mMapView->currentDepth(depth);

if (mInsertMode != InsertMode::Robot) { clearMode(); }
populateStructureMenu();
int newZLevel = mMapView->currentDepth();
if (oldZLevel != newZLevel) {
onChangeDepth(oldZLevel, newZLevel);
}
}


Expand Down
2 changes: 2 additions & 0 deletions OPHD/States/MapViewState.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ class MapViewState : public Wrapper
void resetPoliceOverlays();
void updateConnectedness();
void changeViewDepth(int);
void moveView(MapOffset offset);
void onChangeDepth(int oldDepth, int newDepth);

void pullRobotFromFactory(ProductType pt, Factory& factory);
void onFactoryProductionComplete(Factory& factory);
Expand Down

0 comments on commit 0a22150

Please sign in to comment.