Skip to content

Commit

Permalink
Fix initial shivering on desktop while dragging building plan. (#9334)
Browse files Browse the repository at this point in the history
Co-authored-by: Anuken <[email protected]>
  • Loading branch information
apollovy and Anuken authored Oct 5, 2024
1 parent 4f08873 commit a2d2812
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions core/assets/contributors
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ Gabriel "red" Fondato
CoCo Snow
summoner
OpalSoPL
apollovy
BalaM314
Redstonneur1256
ApsZoldat
Expand Down
13 changes: 8 additions & 5 deletions core/src/mindustry/input/DesktopInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class DesktopInput extends InputHandler{
/** Time of most recent control group selection */
public long lastCtrlGroupSelectMillis;

private final Vec2 buildPlanMouseOffsetPX = new Vec2();

boolean showHint(){
return ui.hudfrag.shown && Core.settings.getBool("hints") && selectPlans.isEmpty() && !player.dead() &&
(!isBuilding && !Core.settings.getBool("buildautopause") || player.unit().isBuilding() || !player.dead() && !player.unit().spawnedByCore());
Expand Down Expand Up @@ -639,11 +641,10 @@ void pollInput(){
}

if(splan != null){
float offset = ((splan.block.size + 2) % 2) * tilesize / 2f;
float x = Core.input.mouseWorld().x + offset;
float y = Core.input.mouseWorld().y + offset;
splan.x = (int)(x / tilesize);
splan.y = (int)(y / tilesize);
float x = Core.input.mouseWorld().x + buildPlanMouseOffsetPX.x;
float y = Core.input.mouseWorld().y + buildPlanMouseOffsetPX.y;
splan.x = Math.round(x / tilesize);
splan.y = Math.round(y / tilesize);
}

if(block == null || mode != placing){
Expand Down Expand Up @@ -687,6 +688,8 @@ void pollInput(){
updateLine(selectX, selectY);
}else if(plan != null && !plan.breaking && mode == none && !plan.initialized && plan.progress <= 0f){
splan = plan;
buildPlanMouseOffsetPX.x = splan.x * tilesize - Core.input.mouseWorld().x;
buildPlanMouseOffsetPX.y = splan.y * tilesize - Core.input.mouseWorld().y;
}else if(plan != null && plan.breaking){
deleting = true;
}else if(commandMode){
Expand Down

0 comments on commit a2d2812

Please sign in to comment.