Dedicated crafting button
This commit is contained in:
parent
5fee2d06af
commit
e20843d3f4
@ -1134,6 +1134,7 @@ Clean up top level folder
|
||||
Break out dependency documentation into a dedicated file
|
||||
Fix terrain editing
|
||||
Fix foliage not updating at edited chunk
|
||||
Dedicated control for opening crafting
|
||||
|
||||
|
||||
# TODO
|
||||
|
||||
@ -105,10 +105,6 @@ public class ControlCategoryFreecam {
|
||||
controlMap.get(FREECAM_RIGHT).setOnClick(freeCamRightCallback);
|
||||
controlMap.get(FREECAM_RIGHT).setOnRepeat(freeCamRightCallback);
|
||||
|
||||
//terrain controls -- these should have already been defined in the main game controls section
|
||||
freeCameraControlList.add(controlMap.get(ControlCategoryMainGame.INPUT_CODE_PLACE_TERRAIN));
|
||||
freeCameraControlList.add(controlMap.get(ControlCategoryMainGame.INPUT_CODE_REMOVE_TERRAIN));
|
||||
|
||||
freeCameraControlList.add(controlMap.get(FREECAM_MOUSE));
|
||||
controlMap.get(FREECAM_MOUSE).setOnMove(new Control.MouseCallback(){public void execute(MouseState mouseState, MouseEvent event){
|
||||
Globals.cameraHandler.handleMouseEvent(event);
|
||||
|
||||
@ -11,7 +11,6 @@ import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType;
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.client.entity.crosshair.Crosshair;
|
||||
import electrosphere.client.item.ItemActions;
|
||||
import electrosphere.client.terrain.editing.TerrainEditing;
|
||||
import electrosphere.client.ui.components.PlayerInventoryWindow;
|
||||
import electrosphere.client.ui.menu.WindowStrings;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
@ -72,9 +71,8 @@ public class ControlCategoryMainGame {
|
||||
public static final String INPUT_CODE_DROP = "drop";
|
||||
public static final String INPUT_CODE_INVENTORY_OPEN = "inventoryOpen";
|
||||
public static final String ITEM_SECONDARY = "actionItemSecondary";
|
||||
public static final String INPUT_CODE_PLACE_TERRAIN = "placeTerrain";
|
||||
public static final String INPUT_CODE_REMOVE_TERRAIN = "removeTerrain";
|
||||
public static final String TOOLBAR_SCROLL = "toolbarScroll";
|
||||
public static final String OPEN_CRAFTING = "openCrafting";
|
||||
|
||||
/**
|
||||
* Maps the controls
|
||||
@ -101,8 +99,7 @@ public class ControlCategoryMainGame {
|
||||
handler.addControl(INPUT_CODE_INVENTORY_OPEN, new Control(ControlType.KEY,GLFW.GLFW_KEY_TAB,false,"Inventory","Opens the player's inventory"));
|
||||
handler.addControl(ITEM_SECONDARY, new Control(ControlType.MOUSE_BUTTON,GLFW.GLFW_MOUSE_BUTTON_RIGHT,false,"Secondary","Uses the secondary equipped item"));
|
||||
handler.addControl(TOOLBAR_SCROLL, new Control(ControlType.MOUSE_SCROLL,0,false,"",""));
|
||||
handler.addControl(INPUT_CODE_PLACE_TERRAIN, new Control(ControlType.KEY,GLFW.GLFW_KEY_T,false,"Place Terrain","Places terrain"));
|
||||
handler.addControl(INPUT_CODE_REMOVE_TERRAIN, new Control(ControlType.KEY,GLFW.GLFW_KEY_Y,false,"Remove Terrain","Removes terrain"));
|
||||
handler.addControl(OPEN_CRAFTING, new Control(ControlType.KEY,GLFW.GLFW_KEY_C,true,"Open Crafting Menu", "Opens the crafting menu"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -724,70 +721,16 @@ public class ControlCategoryMainGame {
|
||||
}});
|
||||
controlMap.get(INPUT_CODE_INVENTORY_OPEN).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
||||
|
||||
/**
|
||||
* Places terrain
|
||||
*/
|
||||
mainGameControlList.add(controlMap.get(INPUT_CODE_PLACE_TERRAIN));
|
||||
controlMap.get(INPUT_CODE_PLACE_TERRAIN).setOnPress(new ControlMethod(){public void execute(MouseState mouseState){
|
||||
CollisionEngine collisionEngine = Globals.clientSceneWrapper.getCollisionEngine();
|
||||
Entity camera = Globals.playerCamera;
|
||||
if(
|
||||
collisionEngine != null &&
|
||||
camera != null
|
||||
){
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(camera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(camera));
|
||||
Vector3d cursorPos = collisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||
if(Globals.clientSelectedVoxelType != null){
|
||||
TerrainEditing.editTerrain(cursorPos, 1.1f, Globals.clientSelectedVoxelType.getId(), 0.1f);
|
||||
}
|
||||
}
|
||||
/*
|
||||
Open crafting
|
||||
*/
|
||||
mainGameControlList.add(controlMap.get(OPEN_CRAFTING));
|
||||
inventoryControlList.add(controlMap.get(OPEN_CRAFTING));
|
||||
controlMap.get(OPEN_CRAFTING).setOnClick(new ControlMethod(){public void execute(MouseState mouseState){
|
||||
Globals.interactionTarget = null;
|
||||
WindowUtils.openInteractionMenu(WindowStrings.CRAFTING);
|
||||
}});
|
||||
controlMap.get(INPUT_CODE_PLACE_TERRAIN).setOnRepeat(new ControlMethod(){public void execute(MouseState mouseState){
|
||||
CollisionEngine collisionEngine = Globals.clientSceneWrapper.getCollisionEngine();
|
||||
Entity camera = Globals.playerCamera;
|
||||
if(
|
||||
collisionEngine != null &&
|
||||
camera != null
|
||||
){
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(camera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(camera));
|
||||
Vector3d cursorPos = collisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||
if(Globals.clientSelectedVoxelType != null){
|
||||
TerrainEditing.editTerrain(cursorPos, 1.1f, Globals.clientSelectedVoxelType.getId(), 0.1f);
|
||||
}
|
||||
}
|
||||
}});
|
||||
controlMap.get(INPUT_CODE_PLACE_TERRAIN).setRepeatTimeout(0.2f * Main.targetFrameRate);
|
||||
|
||||
mainGameControlList.add(controlMap.get(INPUT_CODE_REMOVE_TERRAIN));
|
||||
controlMap.get(INPUT_CODE_REMOVE_TERRAIN).setOnPress(new ControlMethod(){public void execute(MouseState mouseState){
|
||||
CollisionEngine collisionEngine = Globals.clientSceneWrapper.getCollisionEngine();
|
||||
Entity camera = Globals.playerCamera;
|
||||
if(
|
||||
collisionEngine != null &&
|
||||
camera != null
|
||||
){
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(camera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(camera));
|
||||
Vector3d cursorPos = collisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||
TerrainEditing.editTerrain(cursorPos, 1.1f, 1, -0.01f);
|
||||
}
|
||||
}});
|
||||
controlMap.get(INPUT_CODE_REMOVE_TERRAIN).setOnRepeat(new ControlMethod(){public void execute(MouseState mouseState){
|
||||
CollisionEngine collisionEngine = Globals.clientSceneWrapper.getCollisionEngine();
|
||||
Entity camera = Globals.playerCamera;
|
||||
if(
|
||||
collisionEngine != null &&
|
||||
camera != null
|
||||
){
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(camera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(camera));
|
||||
Vector3d cursorPos = collisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||
TerrainEditing.editTerrain(cursorPos, 1.1f, 1, -0.01f);
|
||||
}
|
||||
}});
|
||||
controlMap.get(INPUT_CODE_REMOVE_TERRAIN).setRepeatTimeout(0.2f * Main.targetFrameRate);
|
||||
controlMap.get(OPEN_CRAFTING).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user