1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2026-05-09 00:22:06 +00:00

more intuitive auto-drag

This commit is contained in:
Zeno Rogue
2026-04-29 11:54:41 +02:00
parent 5b1c2e7acd
commit e7e95e8d67
2 changed files with 17 additions and 8 deletions
+17 -4
View File
@@ -200,7 +200,9 @@ enum class tmode { move, info, drag, fire, ranged };
#endif
EX bool touch_interface;
EX ld drag_sensitivity, drag_distance;
EX ld drag_sensitivity;
EX shiftpoint drag_start;
EX bool not_started_dragging;
EX tmode touchmode;
EX vector<string> touch_description = { "touch to move", "touch for info", "touch to drag", "touch to aim", "touch for ranged" };
@@ -823,11 +825,22 @@ EX void handleKeyNormal(int sym, int uni) {
multi::cpid = 0;
bool adr = drag_sensitivity && !vid.quickmouse && mouse_state != 2;
if(touchmode == tmode::drag || adr) {
if(adr) {
if(holdmouse && not_started_dragging) {
ld d = hdist(drag_start, mouseh);
if(d < 1/drag_sensitivity) actonrelease = true;
else panning(drag_start, mouseh), not_started_dragging = false;
}
else if(holdmouse) {
panning(mouseoh, mouseh);
}
else if(!holdmouse)
drag_start = mouseh, not_started_dragging = true, actonrelease = true;
holdmouse = true;
}
else if(touchmode == tmode::drag) {
if(holdmouse) panning(mouseoh, mouseh);
if(!holdmouse) drag_distance = 0;
holdmouse = true;
if(adr && drag_distance < 1/drag_sensitivity) actonrelease = true;
}
else if(touchmode == tmode::info)
gotoHelp(help);
-4
View File
@@ -2501,16 +2501,12 @@ EX void resetview() {
// SDL_UnlockSurface(s);
}
EX void panning(shiftpoint hf0, shiftpoint ht0) {
hyperpoint hf = hf0.h;
hyperpoint ht = unshift(ht0, hf0.shift);
ld d = hdist(hf, ht);
if(drag_sensitivity && d < 1/drag_sensitivity && drag_distance == 0) return;
View =
rgpushxto0(hf) * rgpushxto0(gpushxto0(hf) * ht) * gpushxto0(hf) * View;
playermoved = false; currently_scrolling = true;
drag_distance += d;
}
EX int cells_drawn, cells_generated;