minor fixing, adapting for mobile web
This commit is contained in:
1 parent
44cc0fba67
commit
eac914e073
6 files changed
+393
-129
No files matched your search
+35
-7
@@ -54,21 +54,49 @@ namespace ZL {
|
||||
MenuManager menuManager;
|
||||
|
||||
private:
|
||||
bool rightMouseDown = false;
|
||||
int lastMouseX = 0;
|
||||
int lastMouseY = 0;
|
||||
// Unified pointer handling: mouse-left and a single touch share one path.
|
||||
// A press becomes a tap (interact / walk-to) on release if it never crossed
|
||||
// CAMERA_DRAG_PIXEL_THRESHOLD; otherwise it becomes a camera-rotation drag.
|
||||
// Two simultaneous touches enter pinch-zoom instead.
|
||||
static constexpr int CAMERA_DRAG_PIXEL_THRESHOLD = 12;
|
||||
|
||||
struct PointerState {
|
||||
int eventX = 0, eventY = 0; // current raw window-pixel coords
|
||||
int mx = 0, my = 0; // current projection-space coords
|
||||
int downEventX = 0, downEventY = 0;// where the press started (raw px)
|
||||
int downMx = 0, downMy = 0; // where the press started (proj)
|
||||
bool capturedByUi = false;
|
||||
};
|
||||
std::unordered_map<int64_t, PointerState> activePointers;
|
||||
bool hasPrimaryPointer = false;
|
||||
int64_t primaryPointerId = 0;
|
||||
bool cameraDragging = false;
|
||||
|
||||
bool pinchActive = false;
|
||||
int64_t pinchFingerA = 0;
|
||||
int64_t pinchFingerB = 0;
|
||||
float pinchStartDistance = 0.0f;
|
||||
float pinchStartZoom = 0.0f;
|
||||
|
||||
std::unique_ptr<AudioPlayerAsync> audioPlayer;
|
||||
|
||||
int64_t getSyncTimeMs();
|
||||
void processTickCount();
|
||||
void drawScene();
|
||||
void drawUI();
|
||||
|
||||
|
||||
void drawLoading();
|
||||
|
||||
void handleDown(int64_t fingerId, int mx, int my);
|
||||
void handleUp(int64_t fingerId, int mx, int my);
|
||||
void handleMotion(int64_t fingerId, int mx, int my);
|
||||
void onPointerDown(int64_t fingerId, int eventX, int eventY, int mx, int my);
|
||||
void onPointerUp(int64_t fingerId, int eventX, int eventY, int mx, int my);
|
||||
void onPointerMotion(int64_t fingerId, int eventX, int eventY, int mx, int my);
|
||||
|
||||
void enterCameraDragMode(int eventX, int eventY);
|
||||
void exitCameraDragMode();
|
||||
void startPinch();
|
||||
void updatePinchZoom();
|
||||
void endPinch();
|
||||
int countNonUiPointers() const;
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
static Game* s_instance;
|
||||
|
||||
Reference in new issue
Block a user