void moveViewRelativeToRotation( int stepx, int stepy ) { if (config.follow_DFscreen) changeRelativeToRotation(config.viewXoffset, config.viewYoffset, stepx, stepy ); else changeRelativeToRotation(DisplayedSegmentX, DisplayedSegmentY, stepx, stepy ); }
void doKeys(){ char stepsize = (key[KEY_LSHIFT] || key[KEY_RSHIFT] ? MAPNAVIGATIONSTEPBIG : MAPNAVIGATIONSTEP); //mouse_callback = mouseProc; static int last_mouse_z; if(mouse_z < last_mouse_z) { config.follow_DFscreen = false; if(key[KEY_LCONTROL] || key[KEY_RCONTROL]) { config.segmentSize.z++; } else { if (config.follow_DFscreen) config.viewZoffset -= stepsize; else DisplayedSegmentZ -= stepsize; if(DisplayedSegmentZ<0) DisplayedSegmentZ = 0; } timeToReloadSegment = true; last_mouse_z = mouse_z; } if(mouse_z > last_mouse_z){ config.follow_DFscreen = false; if(key[KEY_LCONTROL] || key[KEY_RCONTROL]) { config.segmentSize.z--; if(config.segmentSize.z <= 0) config.segmentSize.z = 1; } else { if (config.follow_DFscreen) config.viewZoffset += stepsize; else DisplayedSegmentZ += stepsize; if(DisplayedSegmentZ<0) DisplayedSegmentZ = 0; } timeToReloadSegment = true; last_mouse_z = mouse_z; } if( mouse_b & 2 ){ config.follow_DFscreen = false; int pos, x, y; pos = mouse_pos; x = pos >> 16; y = pos & 0x0000ffff; int blockx,blocky,blockz; ScreenToPoint(x,y,blockx,blocky,blockz); int diffx = blockx - config.segmentSize.x/2; int diffy = blocky - config.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(DisplayedSegmentX, DisplayedSegmentY, diffx+1, diffy+1 ); //moveViewRelativeToRotation(diffx+1, diffy+1); timeToReloadSegment = true; //rest(50); }
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 moveViewRelativeToRotation( int stepx, int stepy ) { if (ssConfig.track_mode != GameConfiguration::TRACKING_NONE) { changeRelativeToRotation(ssConfig.viewXoffset, ssConfig.viewYoffset, stepx, stepy ); } //if we're following the DF screen, we DO NOT bound the view, since we have a simple way to get back else { changeRelativeToRotation(ssState.Position.x, ssState.Position.y, stepx, stepy ); //bound view to world if((int)ssState.Position.x > (int)ssState.RegionDim.x -(int)ssState.Size.x/2) { ssState.Position.x = ssState.RegionDim.x -ssState.Size.x/2; } if((int)ssState.Position.y > (int)ssState.RegionDim.y -(int)ssState.Size.y/2) { ssState.Position.y = ssState.RegionDim.y -ssState.Size.y/2; } if((int)ssState.Position.x < -(int)ssState.Size.x/2) { ssState.Position.x = -ssState.Size.x/2; } if((int)ssState.Position.y < -(int)ssState.Size.y/2) { ssState.Position.y = -ssState.Size.y/2; } } }
void moveViewRelativeToRotation( int stepx, int stepy ) { if (ssConfig.follow_DFscreen) { changeRelativeToRotation(ssConfig.viewXoffset, ssConfig.viewYoffset, stepx, stepy ); } //if we're following the DF screen, we DO NOT bound the view, since we have a simple way to get back else { changeRelativeToRotation(ssState.DisplayedSegment.x, ssState.DisplayedSegment.y, stepx, stepy ); //bound view to world if((int)ssState.DisplayedSegment.x > (int)ssState.RegionDim.x -(int)ssState.SegmentSize.x/2) { ssState.DisplayedSegment.x = ssState.RegionDim.x -ssState.SegmentSize.x/2; } if((int)ssState.DisplayedSegment.y > (int)ssState.RegionDim.y -(int)ssState.SegmentSize.y/2) { ssState.DisplayedSegment.y = ssState.RegionDim.y -ssState.SegmentSize.y/2; } if((int)ssState.DisplayedSegment.x < -(int)ssState.SegmentSize.x/2) { ssState.DisplayedSegment.x = -ssState.SegmentSize.x/2; } if((int)ssState.DisplayedSegment.y < -(int)ssState.SegmentSize.y/2) { ssState.DisplayedSegment.y = -ssState.SegmentSize.y/2; } } }
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; } }