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

fix: position indicator #91

Merged
merged 3 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading