Fix time bug w/ controls
This commit is contained in:
parent
0bc7091bf2
commit
9e94e010a9
@ -727,7 +727,7 @@ public class ControlHandler {
|
||||
// MenuGenerators.makeMenuDrawable(mainMenu);
|
||||
// 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
|
||||
@ -750,7 +750,7 @@ public class ControlHandler {
|
||||
Globals.openInventoriesCount++;
|
||||
}
|
||||
}});
|
||||
controls.get(INPUT_CODE_INVENTORY_OPEN).setRepeatTimeout(0.5f);
|
||||
controls.get(INPUT_CODE_INVENTORY_OPEN).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
||||
|
||||
/*
|
||||
Open character
|
||||
@ -772,7 +772,7 @@ public class ControlHandler {
|
||||
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)
|
||||
));
|
||||
}});
|
||||
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));
|
||||
// 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.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()){
|
||||
//on press
|
||||
control.onPress();
|
||||
control.setPressFrame(Main.deltaFrames);
|
||||
control.setPressFrame(Main.getCurrentFrame());
|
||||
} else {
|
||||
//on repeat
|
||||
if(Main.deltaFrames - control.getPressFrame() > control.getRepeatTimeout()){
|
||||
if(Main.getCurrentFrame() - control.getPressFrame() > control.getRepeatTimeout()){
|
||||
control.onRepeat();
|
||||
}
|
||||
}
|
||||
@ -983,7 +983,7 @@ public class ControlHandler {
|
||||
//on release
|
||||
control.onRelease();
|
||||
//on click
|
||||
if(Main.deltaFrames - control.getPressFrame() < control.getRepeatTimeout()){
|
||||
if(Main.getCurrentFrame() - control.getPressFrame() < control.getRepeatTimeout()){
|
||||
control.onClick();
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -228,10 +228,10 @@ public class Main {
|
||||
/*
|
||||
Frame calculation
|
||||
*/
|
||||
double currentFrame = glfwGetTime();
|
||||
deltaTime = currentFrame - lastFrame;
|
||||
double currentTime = glfwGetTime();
|
||||
deltaTime = currentTime - lastFrame;
|
||||
deltaFrames = targetFrameRate * (float)deltaTime;
|
||||
lastFrame = currentFrame;
|
||||
lastFrame = currentTime;
|
||||
|
||||
|
||||
///
|
||||
@ -310,6 +310,10 @@ public class Main {
|
||||
Globals.audioEngine.shutdown();
|
||||
|
||||
}
|
||||
|
||||
public static long getCurrentFrame(){
|
||||
return frameCount;
|
||||
}
|
||||
|
||||
static void sleep(int i) {
|
||||
try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user