Skip to content

Commit

Permalink
Limit fps
Browse files Browse the repository at this point in the history
Cleanup
Mikhael-Danilov committed Dec 27, 2024
1 parent 45e9daa commit 5634430
Showing 6 changed files with 10 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -237,13 +237,14 @@ public void onFrame() {
}

if (framesSinceInit > 2 && !Game.softPaused && loadingOrSaving.get() == 0) {
stepExecutor.submit(() -> {
stepExecutor.execute(() -> {
update();
});
}

NoosaScript.get().resetCamera();
Gl.clear();
Gl.flush();

synchronized (stepLock) {
if (scene != null) {
@@ -260,7 +261,7 @@ public void update() {
scene.update();
}
Camera.updateAll();
}
}
}

private void switchScene(Scene requestedScene) {
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ protected void onClick() {
var pleaseUpdateButton = new RedButton(R.string.Wnd_Button_Ok) {
@Override
protected void onClick() {
InstallMod.openPlayStore();
Game.openPlayStore();
}
};
pleaseUpdateButton.setSize(width / 2f - 4, BUTTON_HEIGHT);
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ public static void main(String[] args) {
cfg.setWindowedMode(480, 800);
cfg.setBackBufferConfig(8, 8, 8, 8, 16, 0, 0);
cfg.enableGLDebugOutput(true, System.err);
cfg.setForegroundFPS(30);

final Lwjgl3Application app = new Lwjgl3Application(new RemixedDungeon(), cfg);
}
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@ public class Game implements ApplicationListener, InputProcessor {
public Iap iap = new Iap();

public PlayGames playGames = new PlayGames();
public long renderThreadId;

public Game(Class<? extends Scene> c) {
super();
@@ -125,8 +124,6 @@ public void render() {
Gl.blendSrcAlphaOneMinusAlpha();
Gdx.gl20.glEnable(Gdx.gl20.GL_SCISSOR_TEST);

renderThreadId = Thread.currentThread().getId();

gameLoop.onFrame();
}

Original file line number Diff line number Diff line change
@@ -1,81 +1,6 @@
package com.nyrds.platform.game;

import com.nyrds.pixeldungeon.game.GameLoop;
import com.nyrds.platform.EventCollector;
import com.nyrds.platform.storage.FileSystem;

import com.nyrds.util.Unzip;
import com.nyrds.util.UnzipStateListener;
import com.watabou.noosa.InterstitialPoint;
import com.watabou.pixeldungeon.utils.GLog;
import com.watabou.pixeldungeon.utils.Utils;
import com.watabou.pixeldungeon.windows.WndError;
import com.watabou.pixeldungeon.windows.WndMessage;
import com.watabou.pixeldungeon.windows.WndModInstall;
import com.watabou.pixeldungeon.windows.WndModSelect;

import java.io.FileNotFoundException;


import lombok.SneakyThrows;

public class InstallMod extends RemixedDungeon implements UnzipStateListener, InterstitialPoint{

private boolean permissionsRequested = false;

public InstallMod() {
}

private String modFileName = Utils.EMPTY_STRING;



public void render() {
super.render();
}

private WndMessage unzipProgress;

@Override
public void UnzipComplete(final Boolean result) {
GameLoop.pushUiTask(() -> {
if(unzipProgress!=null) {
unzipProgress.hide();
unzipProgress = null;
}

if (result) {
GameLoop.addToScene(new WndModSelect());
} else {
GameLoop.addToScene(new WndError(Utils.format("unzipping %s failed", modFileName)));
}
});

}

@Override
public void UnzipProgress(Integer unpacked) {
GameLoop.pushUiTask(() -> {
if (unzipProgress == null) {
unzipProgress = new WndMessage("Unpacking: ...") {
@Override
public void onBackPressed() { }
};
GameLoop.addToScene(unzipProgress);
}
if (unzipProgress.getParent() == GameLoop.scene()) {
unzipProgress.setText(Utils.format("Unpacking: %d", unpacked));
}
});
}

@SneakyThrows
@Override
public void returnToWork(boolean result) {
GLog.i("Install mod: %b", result);
}

public class InstallMod extends RemixedDungeon{
public void installMod() {

}
}
Original file line number Diff line number Diff line change
@@ -24,4 +24,8 @@ public static void glCheck() {
throw new RuntimeException();
}
}

public static void flush() {
Gdx.gl20.glFlush();
}
}

0 comments on commit 5634430

Please sign in to comment.