Added FPS cap setting / Bugfixes
This commit is contained in:
@@ -322,6 +322,9 @@ text.category.liquids=Liquids
|
|||||||
text.category.items=Items
|
text.category.items=Items
|
||||||
text.category.crafting=Crafting
|
text.category.crafting=Crafting
|
||||||
text.category.shooting=Shooting
|
text.category.shooting=Shooting
|
||||||
|
setting.fpscap.name=Max FPS
|
||||||
|
setting.fpscap.none=None
|
||||||
|
setting.fpscap.text={0} FPS
|
||||||
setting.difficulty.easy=easy
|
setting.difficulty.easy=easy
|
||||||
setting.difficulty.normal=normal
|
setting.difficulty.normal=normal
|
||||||
setting.difficulty.hard=hard
|
setting.difficulty.hard=hard
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ public class Mindustry extends ModuleCore{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(){
|
public void render(){
|
||||||
|
threads.handleBeginRender();
|
||||||
super.render();
|
super.render();
|
||||||
threads.handleRender();
|
threads.handleEndRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,12 +76,12 @@ public class TurretBullets extends BulletList implements ContentList{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
basicFlame = new BulletType(2f, 5){
|
basicFlame = new BulletType(2.3f, 5){
|
||||||
{
|
{
|
||||||
hitsize = 7f;
|
hitsize = 7f;
|
||||||
lifetime = 30f;
|
lifetime = 35f;
|
||||||
pierce = true;
|
pierce = true;
|
||||||
drag = 0.07f;
|
drag = 0.05f;
|
||||||
hiteffect = BulletFx.hitFlameSmall;
|
hiteffect = BulletFx.hitFlameSmall;
|
||||||
despawneffect = Fx.none;
|
despawneffect = Fx.none;
|
||||||
status = StatusEffects.burning;
|
status = StatusEffects.burning;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class ShootFx extends FxList implements ContentList{
|
|||||||
shootSmallFlame = new Effect(30f, e -> {
|
shootSmallFlame = new Effect(30f, e -> {
|
||||||
Draw.color(Palette.lightFlame, Palette.darkFlame, Color.GRAY, e.fin());
|
Draw.color(Palette.lightFlame, Palette.darkFlame, Color.GRAY, e.fin());
|
||||||
|
|
||||||
Angles.randLenVectors(e.id, 8, e.finpow() * 26f, e.rotation, 10f, (x, y) -> {
|
Angles.randLenVectors(e.id, 8, e.finpow() * 36f, e.rotation, 10f, (x, y) -> {
|
||||||
Fill.circle(e.x + x, e.y + y, 0.65f + e.fout() * 1.5f);
|
Fill.circle(e.x + x, e.y + y, 0.65f + e.fout() * 1.5f);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.anuke.mindustry.core;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.utils.Queue;
|
import com.badlogic.gdx.utils.Queue;
|
||||||
import com.badlogic.gdx.utils.TimeUtils;
|
import com.badlogic.gdx.utils.TimeUtils;
|
||||||
|
import io.anuke.ucore.core.Settings;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.util.Log;
|
import io.anuke.ucore.util.Log;
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ public class ThreadHandler{
|
|||||||
private float framesSinceUpdate;
|
private float framesSinceUpdate;
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
private boolean rendered = true;
|
private boolean rendered = true;
|
||||||
|
private long lastFrameTime;
|
||||||
|
|
||||||
public ThreadHandler(ThreadProvider impl){
|
public ThreadHandler(ThreadProvider impl){
|
||||||
this.impl = impl;
|
this.impl = impl;
|
||||||
@@ -69,7 +71,24 @@ public class ThreadHandler{
|
|||||||
return framesSinceUpdate;
|
return framesSinceUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleRender(){
|
public void handleBeginRender(){
|
||||||
|
lastFrameTime = TimeUtils.millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleEndRender(){
|
||||||
|
int fpsCap = Settings.getInt("fpscap", 125);
|
||||||
|
|
||||||
|
if(fpsCap <= 120){
|
||||||
|
long target = 1000/fpsCap;
|
||||||
|
long elapsed = TimeUtils.timeSinceMillis(lastFrameTime);
|
||||||
|
if(elapsed < target){
|
||||||
|
try{
|
||||||
|
impl.sleep(target - elapsed);
|
||||||
|
}catch(InterruptedException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!enabled) return;
|
if(!enabled) return;
|
||||||
|
|
||||||
|
|||||||
@@ -134,6 +134,10 @@ public class SettingsMenuDialog extends SettingsDialog{
|
|||||||
//game.sliderPref("sensitivity", 100, 10, 300, i -> i + "%");
|
//game.sliderPref("sensitivity", 100, 10, 300, i -> i + "%");
|
||||||
game.sliderPref("saveinterval", 90, 10, 5 * 120, i -> Bundles.format("setting.seconds", i));
|
game.sliderPref("saveinterval", 90, 10, 5 * 120, i -> Bundles.format("setting.seconds", i));
|
||||||
|
|
||||||
|
if(!gwt){
|
||||||
|
graphics.sliderPref("fpscap", 125, 5, 125, 5, s -> (s > 120 ? Bundles.get("setting.fpscap.none") : Bundles.format("setting.fpscap.text", s)));
|
||||||
|
}
|
||||||
|
|
||||||
if(!gwt){
|
if(!gwt){
|
||||||
graphics.checkPref("multithread", true, threads::setEnabled);
|
graphics.checkPref("multithread", true, threads::setEnabled);
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ public abstract class LiquidTurret extends Turret{
|
|||||||
|
|
||||||
TurretEntity entity = tile.entity();
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
Effects.effect(shootEffect, type.liquid.color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
Effects.effect(type.shootEffect, type.liquid.color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
||||||
Effects.effect(smokeEffect, type.liquid.color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
Effects.effect(type.smokeEffect, type.liquid.color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
||||||
|
|
||||||
if(shootShake > 0){
|
if(shootShake > 0){
|
||||||
Effects.shake(shootShake, shootShake, tile.entity);
|
Effects.shake(shootShake, shootShake, tile.entity);
|
||||||
|
|||||||
@@ -141,11 +141,6 @@ public class Conveyor extends Block{
|
|||||||
return super.getIcon();
|
return super.getIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isLayer(Tile tile){
|
|
||||||
return tile.<ConveyorEntity>entity().convey.size > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawLayer(Tile tile){
|
public void drawLayer(Tile tile){
|
||||||
ConveyorEntity entity = tile.entity();
|
ConveyorEntity entity = tile.entity();
|
||||||
@@ -265,7 +260,9 @@ public class Conveyor extends Block{
|
|||||||
entity.carrying = 0f;
|
entity.carrying = 0f;
|
||||||
entity.minCarry = 2f;
|
entity.minCarry = 2f;
|
||||||
|
|
||||||
if(totalMoved/Timers.delta() <= 0.0001f){
|
Tile next = tile.getNearby(tile.getRotation());
|
||||||
|
|
||||||
|
if((next != null && next.block() instanceof Conveyor) && totalMoved/Timers.delta() <= 0.0001f){
|
||||||
entity.sleep();
|
entity.sleep();
|
||||||
}else{
|
}else{
|
||||||
entity.noSleep();
|
entity.noSleep();
|
||||||
|
|||||||
Reference in New Issue
Block a user