void doMouse() { al_get_mouse_state(&mouse); al_get_keyboard_state(&keyboard); int32_t keymod = getKeyMods(&keyboard); Interface::get().readMouse(mouse); char stepsize = ((keymod&ALLEGRO_KEYMOD_SHIFT) ? MAPNAVIGATIONSTEPBIG : MAPNAVIGATIONSTEP); //mouse_callback = mouseProc; static int last_mouse_z; if(mouse.z < last_mouse_z) { action_decrZ(keymod); last_mouse_z = mouse.z; } if(mouse.z > last_mouse_z) { action_incrZ(keymod); last_mouse_z = mouse.z; } if( mouse.buttons & 2 ) { ssConfig.follow_DFscreen = false; int x, y; x = mouse.x; y = mouse.y; int tilex,tiley,tilez; ScreenToPoint(x,y,tilex,tiley,tilez); int diffx = tilex - ssState.SegmentSize.x/2; int diffy = tiley - ssState.SegmentSize.y/2; /*we use changeRelativeToRotation directly, and not through moveViewRelativeToRotation because we don't want to move the offset with the mouse. It just feels weird. */ // changing to +1,+1 which moves the clicked point to one of the 4 surrounding the center of rotation changeRelativeToRotation(ssState.DisplayedSegment.x, ssState.DisplayedSegment.y, diffx+1, diffy+1 ); //moveViewRelativeToRotation(diffx+1, diffy+1); timeToReloadSegment = true; //rest(50); } if( mouse.buttons & 1 ) { ssConfig.follow_DFcursor = false; int x, y; x = mouse.x;//pos >> 16; y = mouse.y; //pos & 0x0000ffff; if(x >= MiniMapTopLeftX && x <= MiniMapBottomRightX && y >= MiniMapTopLeftY && y <= MiniMapBottomRightY) { // in minimap ssState.DisplayedSegment.x = (x-MiniMapTopLeftX-MiniMapSegmentWidth/2)/oneTileInPixels; ssState.DisplayedSegment.y = (y-MiniMapTopLeftY-MiniMapSegmentHeight/2)/oneTileInPixels; } else { int tilex,tiley,tilez; ScreenToPoint(x,y,tilex,tiley,tilez); int diffx = tilex - ssState.SegmentSize.x/2; int diffy = tiley - ssState.SegmentSize.y/2; debugCursor.x = tilex; debugCursor.y = tiley; } timeToReloadSegment = true; } }
void doMouse() { al_get_mouse_state(&mouse); al_get_keyboard_state(&keyboard); int32_t keymod = getKeyMods(&keyboard); char stepsize = ((keymod&ALLEGRO_KEYMOD_SHIFT) ? MAPNAVIGATIONSTEPBIG : MAPNAVIGATIONSTEP); //mouse_callback = mouseProc; static int last_mouse_z; if(mouse.z < last_mouse_z) { action_decrZ(keymod); last_mouse_z = mouse.z; } if(mouse.z > last_mouse_z) { action_incrZ(keymod); last_mouse_z = mouse.z; } if( mouse.buttons & 2 ) { ssConfig.track_mode = GameConfiguration::TRACKING_NONE; int x, y; x = mouse.x; y = mouse.y; int tilex,tiley,tilez; ScreenToPoint(x,y,tilex,tiley,tilez); int diffx = tilex - ssState.Size.x/2; int diffy = tiley - ssState.Size.y/2; /*we use changeRelativeToRotation directly, and not through moveViewRelativeToRotation because we don't want to move the offset with the mouse. It just feels weird. */ // changing to +1,+1 which moves the clicked point to one of the 4 surrounding the center of rotation changeRelativeToRotation(ssState.Position.x, ssState.Position.y, diffx+1, diffy+1 ); //moveViewRelativeToRotation(diffx+1, diffy+1); timeToReloadSegment = true; //rest(50); } if( mouse.buttons & 1 ) { ssConfig.follow_DFcursor = false; int x, y; x = mouse.x;//pos >> 16; y = mouse.y; //pos & 0x0000ffff; if(x >= MiniMapTopLeftX && x <= MiniMapBottomRightX && y >= MiniMapTopLeftY && y <= MiniMapBottomRightY) { // in minimap ssState.Position.x = (x-MiniMapTopLeftX-MiniMapSegmentWidth/2)/oneTileInPixels; ssState.Position.y = (y-MiniMapTopLeftY-MiniMapSegmentHeight/2)/oneTileInPixels; } else { int tilex,tiley,tilez; //get the point in the segment ScreenToPoint(x,y,tilex,tiley,tilez); //then remove the segment rotation correctForRotation( tilex, tiley, (4 - ssState.Rotation) % 4, ssState.Size.x, ssState.Size.y); //Convert to zero as top layer convention tilez = tilez - (ssState.Size.z-2); //add on the segment offset tilex = tilex + ssState.Position.x; tiley = tiley + ssState.Position.y; tilez = tilez + ssState.Position.z - 1; ssState.dfCursor.x = tilex; ssState.dfCursor.y = tiley; ssState.dfCursor.z = tilez; } timeToReloadSegment = true; } }