Debug hitbox toggle hotkey
This commit is contained in:
@@ -1394,6 +1394,7 @@ keybind.chat_mode.name = Change Chat Mode
|
|||||||
keybind.drop_unit.name = Drop Unit
|
keybind.drop_unit.name = Drop Unit
|
||||||
keybind.zoom_minimap.name = Zoom Minimap
|
keybind.zoom_minimap.name = Zoom Minimap
|
||||||
keybind.detach_camera.name = Toggle Free Camera
|
keybind.detach_camera.name = Toggle Free Camera
|
||||||
|
keybind.debug_hitboxes.name = Toggle Debug Hitboxes
|
||||||
mode.help.title = Description of modes
|
mode.help.title = Description of modes
|
||||||
mode.survival.name = Survival
|
mode.survival.name = Survival
|
||||||
mode.survival.description = The normal mode. Limited resources and automatic incoming waves.\n[gray]Requires enemy spawns in the map to play.
|
mode.survival.description = The normal mode. Limited resources and automatic incoming waves.\n[gray]Requires enemy spawns in the map to play.
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ public class Vars implements Loadable{
|
|||||||
* Do not change unless you know exactly what you are doing.*/
|
* Do not change unless you know exactly what you are doing.*/
|
||||||
public static boolean enableDarkness = true;
|
public static boolean enableDarkness = true;
|
||||||
/** Whether to draw debug lines for collisions. */
|
/** Whether to draw debug lines for collisions. */
|
||||||
public static boolean drawCollisionDebug = false;
|
public static boolean drawDebugHitboxes = false;
|
||||||
/** application data directory, equivalent to {@link Settings#getDataDirectory()} */
|
/** application data directory, equivalent to {@link Settings#getDataDirectory()} */
|
||||||
public static Fi dataDirectory;
|
public static Fi dataDirectory;
|
||||||
/** data subdirectory used for screenshots */
|
/** data subdirectory used for screenshots */
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ public class Renderer implements ApplicationListener{
|
|||||||
|
|
||||||
Groups.draw.draw(Drawc::draw);
|
Groups.draw.draw(Drawc::draw);
|
||||||
|
|
||||||
if(drawCollisionDebug){
|
if(drawDebugHitboxes){
|
||||||
DebugCollisionRenderer.draw();
|
DebugCollisionRenderer.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ import static arc.Core.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class DebugCollisionRenderer{
|
public class DebugCollisionRenderer{
|
||||||
|
static final float[] edges = {
|
||||||
|
1, -1,
|
||||||
|
1, 1,
|
||||||
|
-1, 1,
|
||||||
|
-1, -1,
|
||||||
|
};
|
||||||
|
|
||||||
public static void draw(){
|
public static void draw(){
|
||||||
Rect rect = camera.bounds(new Rect());
|
Rect rect = camera.bounds(new Rect());
|
||||||
@@ -27,7 +33,7 @@ public class DebugCollisionRenderer{
|
|||||||
});
|
});
|
||||||
|
|
||||||
//tile hitboxes for units
|
//tile hitboxes for units
|
||||||
Lines.stroke(0.3f, Color.magenta);
|
Lines.stroke(0.4f, Color.magenta);
|
||||||
|
|
||||||
int rx = Mathf.clamp((int)(Core.camera.width / tilesize / 2) + 1, 0, world.width()/2);
|
int rx = Mathf.clamp((int)(Core.camera.width / tilesize / 2) + 1, 0, world.width()/2);
|
||||||
int ry = Mathf.clamp((int)(Core.camera.height / tilesize / 2) + 1, 0, world.height()/2);
|
int ry = Mathf.clamp((int)(Core.camera.height / tilesize / 2) + 1, 0, world.height()/2);
|
||||||
@@ -38,8 +44,19 @@ public class DebugCollisionRenderer{
|
|||||||
int wy = World.toTile(Core.camera.position.y) + y;
|
int wy = World.toTile(Core.camera.position.y) + y;
|
||||||
Tile tile = world.tile(wx, wy);
|
Tile tile = world.tile(wx, wy);
|
||||||
if(tile != null && tile.solid()){
|
if(tile != null && tile.solid()){
|
||||||
Draw.color(tile.legSolid() ? Color.pink : Color.magenta);
|
for(int i = 0; i < 4; i++){
|
||||||
Lines.rect(wx * tilesize - tilesize/2f, wy * tilesize - tilesize/2f, tilesize, tilesize);
|
Tile other = tile.nearby(i);
|
||||||
|
if(other == null || !other.solid()){
|
||||||
|
Lines.line(
|
||||||
|
wx * tilesize + edges[i*2] * tilesize/2f,
|
||||||
|
wy * tilesize + edges[i*2+1] * tilesize/2f,
|
||||||
|
wx * tilesize + edges[((i + 1) % 4)*2] * tilesize/2f,
|
||||||
|
wy * tilesize + edges[((i + 1) % 4)*2+1] * tilesize/2f
|
||||||
|
);
|
||||||
|
|
||||||
|
//Lines.rect(wx * tilesize - tilesize/2f, wy * tilesize - tilesize/2f, tilesize, tilesize);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ public class Binding{
|
|||||||
schematicFlipY = KeyBind.add("schematic_flip_y", KeyCode.x),
|
schematicFlipY = KeyBind.add("schematic_flip_y", KeyCode.x),
|
||||||
schematicMenu = KeyBind.add("schematic_menu", KeyCode.t),
|
schematicMenu = KeyBind.add("schematic_menu", KeyCode.t),
|
||||||
|
|
||||||
|
|
||||||
commandMode = KeyBind.add("command_mode", KeyCode.shiftLeft, "command"),
|
commandMode = KeyBind.add("command_mode", KeyCode.shiftLeft, "command"),
|
||||||
commandQueue = KeyBind.add("command_queue", KeyCode.mouseMiddle),
|
commandQueue = KeyBind.add("command_queue", KeyCode.mouseMiddle),
|
||||||
createControlGroup = KeyBind.add("create_control_group", KeyCode.controlLeft),
|
createControlGroup = KeyBind.add("create_control_group", KeyCode.controlLeft),
|
||||||
@@ -103,7 +102,8 @@ public class Binding{
|
|||||||
chatHistoryNext = KeyBind.add("chat_history_next", KeyCode.down),
|
chatHistoryNext = KeyBind.add("chat_history_next", KeyCode.down),
|
||||||
chatScroll = KeyBind.add("chat_scroll", new Axis(KeyCode.scroll)),
|
chatScroll = KeyBind.add("chat_scroll", new Axis(KeyCode.scroll)),
|
||||||
chatMode = KeyBind.add("chat_mode", KeyCode.tab),
|
chatMode = KeyBind.add("chat_mode", KeyCode.tab),
|
||||||
console = KeyBind.add("console", KeyCode.f8)
|
console = KeyBind.add("console", KeyCode.f8),
|
||||||
|
debugHitboxes = KeyBind.add("debug_hitboxes", KeyCode.unset)
|
||||||
;
|
;
|
||||||
|
|
||||||
//dummy static class initializer
|
//dummy static class initializer
|
||||||
|
|||||||
@@ -234,6 +234,10 @@ public class DesktopInput extends InputHandler{
|
|||||||
boolean detached = settings.getBool("detach-camera", false);
|
boolean detached = settings.getBool("detach-camera", false);
|
||||||
|
|
||||||
if(!scene.hasField() && !scene.hasDialog()){
|
if(!scene.hasField() && !scene.hasDialog()){
|
||||||
|
if(input.keyTap(Binding.debugHitboxes)){
|
||||||
|
drawDebugHitboxes = !drawDebugHitboxes;
|
||||||
|
}
|
||||||
|
|
||||||
if(input.keyTap(Binding.detachCamera)){
|
if(input.keyTap(Binding.detachCamera)){
|
||||||
settings.put("detach-camera", detached = !detached);
|
settings.put("detach-camera", detached = !detached);
|
||||||
if(!detached){
|
if(!detached){
|
||||||
|
|||||||
Reference in New Issue
Block a user