From 681347e933bfc662e2322f4c91042c1edc102049 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 15 Sep 2019 15:47:42 -0400 Subject: [PATCH] Mobile scrolling fix --- core/assets/bundles/bundle.properties | 3 +- .../io/anuke/mindustry/game/MusicControl.java | 2 +- .../io/anuke/mindustry/input/MobileInput.java | 28 ++++++++++++++++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 8a40e0a99e..d0ef17bcad 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -915,7 +915,7 @@ unit.lich.name = Lich unit.reaper.name = Reaper tutorial.next = [lightgray] tutorial.intro = You have entered the[scarlet] Mindustry Tutorial.[]\nBegin by[accent] mining copper[]. Tap a copper ore vein near your core to do this.\n\n[accent]{0}/{1} copper -tutorial.drill = Mining manually is inefficient.\n[accent]Drills []can mine automatically.\nClick the drill tab in the bottom right.\nSelect the[accent] mechanical drill[]. Place it on a copper vein by clicking.\n[accent]Right-click[] to stop building. +tutorial.drill = Mining manually is inefficient.\n[accent]Drills []can mine automatically.\nClick the drill tab in the bottom right.\nSelect the[accent] mechanical drill[]. Place it on a copper vein by clicking.\n[accent]Right-click[] to stop building, and[accent] Hold Ctrl while scrolling[] to zoom in and out. tutorial.drill.mobile = Mining manually is inefficient.\n[accent]Drills []can mine automatically.\nTap the drill tab in the bottom right.\nSelect the[accent] mechanical drill[].\nPlace it on a copper vein by tapping, then press the[accent] checkmark[] below to confirm your selection.\nPress the[accent] X button[] to cancel placement. tutorial.blockinfo = Each block has different stats. Each drill can only mine certain ores.\nTo check a block's info and stats,[accent] tap the "?" button while selecting it in the build menu.[]\n\n[accent]Access the Mechanical Drill's stats now.[] tutorial.conveyor = [accent]Conveyors[] are used to transport items to the core.\nMake a line of conveyors from the drill to the core.\n[accent]Hold down the mouse to place in a line.[]\nHold[accent] CTRL[] while selecting a line to place diagonally.\n\n[accent]Place 2 conveyors with the line tool, then deliver an item into the core. @@ -934,7 +934,6 @@ tutorial.waves = The[lightgray] enemy[] approaches.\n\nDefend the core for 2 wav tutorial.waves.mobile = The[lightgray] enemy[] approaches.\n\nDefend the core for 2 waves. Your ship will automatically fire at enemies.\nBuild more turrets and drills. Mine more copper. tutorial.launch = Once you reach a specific wave, you are able to[accent] launch the core[], leaving your defenses behind and[accent] obtaining all the resources in your core.[]\nThese resources can then be used to research new technology.\n\n[accent]Press the launch button. - item.copper.description = The most basic structural material. Used extensively in all types of blocks. item.lead.description = A basic starter material. Used extensively in electronics and liquid transportation blocks. item.metaglass.description = A super-tough glass compound. Extensively used for liquid distribution and storage. diff --git a/core/src/io/anuke/mindustry/game/MusicControl.java b/core/src/io/anuke/mindustry/game/MusicControl.java index dc16c5d464..c7d6e9c87f 100644 --- a/core/src/io/anuke/mindustry/game/MusicControl.java +++ b/core/src/io/anuke/mindustry/game/MusicControl.java @@ -134,7 +134,7 @@ public class MusicControl{ /** Plays a music track once and only once. If something is already playing, does nothing.*/ private void playOnce(@NonNull Music music){ - if(current != null) return; //do not interrupt already-playing tracks + if(current != null || music == null) return; //do not interrupt already-playing tracks //save last random track played to prevent duplicates lastRandomPlayed = music; diff --git a/core/src/io/anuke/mindustry/input/MobileInput.java b/core/src/io/anuke/mindustry/input/MobileInput.java index eebfd6c152..14f86e360f 100644 --- a/core/src/io/anuke/mindustry/input/MobileInput.java +++ b/core/src/io/anuke/mindustry/input/MobileInput.java @@ -67,7 +67,33 @@ public class MobileInput extends InputHandler implements GestureListener{ public MobileInput(){ Events.on(ClientLoadEvent.class, e -> { - Core.input.addProcessor(new GestureDetector(20, 0.5f, 0.4f, 0.15f, this)); + GestureDetector dec = new GestureDetector(20, 0.5f, 0.4f, 0.15f, this){ + boolean clearMouse = false; + + @Override + public boolean touchDown(int x, int y, int pointer, KeyCode button){ + if(Core.scene.hasMouse(x, y)){ + clearMouse = true; + return false; + } + return super.touchDown(x, y, pointer, button); + } + + @Override + public boolean touchDragged(int x, int y, int pointer){ + if(!clearMouse){ + return super.touchDragged(x, y, pointer); + } + return false; + } + + @Override + public boolean touchUp(int x, int y, int pointer, KeyCode button){ + clearMouse = false; + return super.touchUp(x, y, pointer, button); + } + }; + Core.input.getInputProcessors().insert(0, dec); }); }