Skip to content

Commit

Permalink
fix: position indicator (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
phacUFPE authored Aug 10, 2024
1 parent 3958ef0 commit 78686d7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ world
*.opendb
*.vs

vcproj/generated/
vcproj/ipch/
vcproj/Beta Release/
vcproj/Debug/
Expand Down
2 changes: 2 additions & 0 deletions source/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ namespace rme {
constexpr int MinActionId = 100;
constexpr int MaxActionId = 65535;

constexpr int PositionIndicatorDuration = 5000;

} // namespace rme

#endif // RME_CONST_H_
5 changes: 4 additions & 1 deletion source/map_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void MapCanvas::OnPaint(wxPaintEvent &event) {

options.dragging = boundbox_selection;

if (options.show_preview) {
if (options.show_preview || drawer->GetPositionIndicatorTime() != 0) {
animation_timer->Start();
} else {
animation_timer->Stop();
Expand Down Expand Up @@ -257,6 +257,9 @@ void MapCanvas::OnPaint(wxPaintEvent &event) {
void MapCanvas::ShowPositionIndicator(const Position &position) {
if (drawer) {
drawer->ShowPositionIndicator(position);
if (!animation_timer->IsRunning()) {
Update();
}
}
}

Expand Down
5 changes: 2 additions & 3 deletions source/map_drawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1796,9 +1796,8 @@ void MapDrawer::DrawPositionIndicator(int z) {
return;
}

constexpr int duration = 5000;
const long time = pos_indicator_timer.Time();
if (time >= duration) {
const long time = GetPositionIndicatorTime();
if (time == 0) {
return;
}

Expand Down
7 changes: 7 additions & 0 deletions source/map_drawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ class MapDrawer {
void TakeScreenshot(uint8_t* screenshot_buffer);

void ShowPositionIndicator(const Position &position);
long GetPositionIndicatorTime() const {
const long time = pos_indicator_timer.Time();
if (time < rme::PositionIndicatorDuration) {
return time;
}
return 0;
}

DrawingOptions &getOptions() noexcept {
return options;
Expand Down
1 change: 1 addition & 0 deletions source/map_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ void MapWindow::SetScreenCenterPosition(const Position &position, bool showIndic

if (showIndicator) {
canvas->ShowPositionIndicator(position);
Refresh();
}
}

Expand Down

0 comments on commit 78686d7

Please sign in to comment.