mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
- Made the desktop port and the mobile port of the game use different threads when processing multiple achievements (otherwise the game tends to freeze).
This commit is contained in:
@@ -58,6 +58,11 @@ public class GuiDesktop implements IGuiBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLibgdxPort() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentVersion() {
|
||||
return BuildInfo.getVersionString();
|
||||
|
||||
@@ -55,6 +55,11 @@ public class GuiMobile implements IGuiBase {
|
||||
return Gdx.app.getType() == ApplicationType.Desktop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLibgdxPort() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentVersion() {
|
||||
return Forge.CURRENT_VERSION;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.achievement;
|
||||
|
||||
import forge.GuiBase;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Iterator;
|
||||
@@ -44,16 +45,25 @@ public abstract class AchievementCollection implements Iterable<Achievement> {
|
||||
final Player player = controller.getPlayer();
|
||||
|
||||
//update all achievements for GUI player after game finished
|
||||
//(we are doing it in different threads in different game ports to prevent freezing when processing multiple achievements)
|
||||
if (GuiBase.getInterface().isLibgdxPort()) {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doUpdateAllAchievements(game, player);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
doUpdateAllAchievements(game, player);
|
||||
}
|
||||
}
|
||||
|
||||
private static void doUpdateAllAchievements(final Game game, final Player player) {
|
||||
FModel.getAchievements(game.getRules().getGameType()).updateAll(player);
|
||||
AltWinAchievements.instance.updateAll(player);
|
||||
PlaneswalkerAchievements.instance.updateAll(player);
|
||||
ChallengeAchievements.instance.updateAll(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void buildComboBox(IComboBox<AchievementCollection> cb) {
|
||||
cb.addItem(FModel.getAchievements(GameType.Constructed));
|
||||
|
||||
@@ -19,6 +19,7 @@ import forge.util.Callback;
|
||||
|
||||
public interface IGuiBase {
|
||||
boolean isRunningOnDesktop();
|
||||
boolean isLibgdxPort();
|
||||
String getCurrentVersion();
|
||||
String getAssetsDir();
|
||||
void invokeInEdtNow(Runnable runnable);
|
||||
|
||||
Reference in New Issue
Block a user