Fix time bug w/ controls
This commit is contained in:
parent
0bc7091bf2
commit
9e94e010a9
@ -727,7 +727,7 @@ public class ControlHandler {
|
|||||||
// MenuGenerators.makeMenuDrawable(mainMenu);
|
// MenuGenerators.makeMenuDrawable(mainMenu);
|
||||||
// Globals.controlHandler.setHandlerState(ControlsState.IN_GAME_MAIN_MENU);
|
// Globals.controlHandler.setHandlerState(ControlsState.IN_GAME_MAIN_MENU);
|
||||||
}});
|
}});
|
||||||
controls.get(DATA_STRING_INPUT_CODE_IN_GAME_MAIN_MENU).setRepeatTimeout(0.5f);
|
controls.get(DATA_STRING_INPUT_CODE_IN_GAME_MAIN_MENU).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Open inventory
|
Open inventory
|
||||||
@ -750,7 +750,7 @@ public class ControlHandler {
|
|||||||
Globals.openInventoriesCount++;
|
Globals.openInventoriesCount++;
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
controls.get(INPUT_CODE_INVENTORY_OPEN).setRepeatTimeout(0.5f);
|
controls.get(INPUT_CODE_INVENTORY_OPEN).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Open character
|
Open character
|
||||||
@ -772,7 +772,7 @@ public class ControlHandler {
|
|||||||
Globals.openInventoriesCount++;
|
Globals.openInventoriesCount++;
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
controls.get(INPUT_CODE_CHARACTER_OPEN).setRepeatTimeout(0.5f);
|
controls.get(INPUT_CODE_CHARACTER_OPEN).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,7 +821,7 @@ public class ControlHandler {
|
|||||||
Globals.mouseCallback.getButton(GLFW_MOUSE_BUTTON_2)
|
Globals.mouseCallback.getButton(GLFW_MOUSE_BUTTON_2)
|
||||||
));
|
));
|
||||||
}});
|
}});
|
||||||
controls.get(INPUT_CODE_MENU_MOUSE_PRIMARY).setRepeatTimeout(0.5f);
|
controls.get(INPUT_CODE_MENU_MOUSE_PRIMARY).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
||||||
|
|
||||||
menuNavigationControlList.add(controls.get(DATA_STRING_INPUT_CODE_MENU_BACKOUT));
|
menuNavigationControlList.add(controls.get(DATA_STRING_INPUT_CODE_MENU_BACKOUT));
|
||||||
// controls.get(DATA_STRING_INPUT_CODE_MENU_BACKOUT).setOnPress(new ControlMethod(){public void execute(){
|
// controls.get(DATA_STRING_INPUT_CODE_MENU_BACKOUT).setOnPress(new ControlMethod(){public void execute(){
|
||||||
@ -833,7 +833,7 @@ public class ControlHandler {
|
|||||||
Globals.elementManager.navigateBackwards();
|
Globals.elementManager.navigateBackwards();
|
||||||
// Globals.elementManager.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
|
// Globals.elementManager.unregisterWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
|
||||||
}});
|
}});
|
||||||
controls.get(DATA_STRING_INPUT_CODE_MENU_BACKOUT).setRepeatTimeout(0.5f);
|
controls.get(DATA_STRING_INPUT_CODE_MENU_BACKOUT).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -970,10 +970,10 @@ public class ControlHandler {
|
|||||||
if(!control.isState()){
|
if(!control.isState()){
|
||||||
//on press
|
//on press
|
||||||
control.onPress();
|
control.onPress();
|
||||||
control.setPressFrame(Main.deltaFrames);
|
control.setPressFrame(Main.getCurrentFrame());
|
||||||
} else {
|
} else {
|
||||||
//on repeat
|
//on repeat
|
||||||
if(Main.deltaFrames - control.getPressFrame() > control.getRepeatTimeout()){
|
if(Main.getCurrentFrame() - control.getPressFrame() > control.getRepeatTimeout()){
|
||||||
control.onRepeat();
|
control.onRepeat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -983,7 +983,7 @@ public class ControlHandler {
|
|||||||
//on release
|
//on release
|
||||||
control.onRelease();
|
control.onRelease();
|
||||||
//on click
|
//on click
|
||||||
if(Main.deltaFrames - control.getPressFrame() < control.getRepeatTimeout()){
|
if(Main.getCurrentFrame() - control.getPressFrame() < control.getRepeatTimeout()){
|
||||||
control.onClick();
|
control.onClick();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -228,10 +228,10 @@ public class Main {
|
|||||||
/*
|
/*
|
||||||
Frame calculation
|
Frame calculation
|
||||||
*/
|
*/
|
||||||
double currentFrame = glfwGetTime();
|
double currentTime = glfwGetTime();
|
||||||
deltaTime = currentFrame - lastFrame;
|
deltaTime = currentTime - lastFrame;
|
||||||
deltaFrames = targetFrameRate * (float)deltaTime;
|
deltaFrames = targetFrameRate * (float)deltaTime;
|
||||||
lastFrame = currentFrame;
|
lastFrame = currentTime;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -311,6 +311,10 @@ public class Main {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long getCurrentFrame(){
|
||||||
|
return frameCount;
|
||||||
|
}
|
||||||
|
|
||||||
static void sleep(int i) {
|
static void sleep(int i) {
|
||||||
try {
|
try {
|
||||||
TimeUnit.MILLISECONDS.sleep(i);
|
TimeUnit.MILLISECONDS.sleep(i);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user