add missing translation, minor speedup generating map

This commit is contained in:
Anthony Calosa
2024-11-03 05:58:28 +08:00
parent bdcf8ecb87
commit c6aecafe6b
11 changed files with 545 additions and 428 deletions

View File

@@ -244,7 +244,7 @@ public class SaveLoadScene extends UIScene {
loaded = false;
if (WorldSave.load(currentSlot)) {
WorldSave.getCurrentSave().clearChanges();
WorldSave.getCurrentSave().getWorld().generateNew(0);
if (WorldSave.getCurrentSave().getWorld().generateNew(0)) {
if (difficulty != null)
Current.player().updateDifficulty(Config.instance().getConfigData().difficulties[difficulty.getSelectedIndex()]);
Current.player().setWorldPosY((int) (WorldSave.getCurrentSave().getWorld().getData().playerStartPosY * WorldSave.getCurrentSave().getWorld().getData().height * WorldSave.getCurrentSave().getWorld().getTileSize()));
@@ -259,6 +259,9 @@ public class SaveLoadScene extends UIScene {
} else {
Forge.clearTransitionScreen();
}
} else {
Forge.clearTransitionScreen();
}
}, null, false, true, Forge.getLocalizer().getMessage("lblGeneratingWorld")));
} catch (Exception e) {
loaded = false;

View File

@@ -19,6 +19,7 @@ public class ColorMap
}
public ColorMap(FileHandle file) {
if (file.exists()) {
Pixmap pdata=new Pixmap(file);
width=pdata.getWidth();
height=pdata.getHeight();
@@ -29,6 +30,12 @@ public class ColorMap
data[x+y*width]=new Color(pdata.getPixel(x,y));
}
pdata.dispose();
} else {
width = 0;
height = 0;
data = new Color[0];
System.err.println("Cannot find file for ColorMap: " + file.path());
}
}
public int getWidth() {

View File

@@ -26,6 +26,7 @@ import forge.gui.GuiBase;
import org.apache.commons.lang3.tuple.Pair;
import java.util.*;
import java.util.concurrent.CompletableFuture;
/**
* Class that will create the world from the configuration
@@ -289,7 +290,8 @@ public class World implements Disposable, SaveFileContent {
return currentTime;
}
public World generateNew(long seed) {
public boolean generateNew(long seed) {
try {
if (GuiBase.isAndroid())
GuiBase.getInterface().preventSystemSleep(true);
final long[] currentTime = {System.currentTimeMillis()};
@@ -328,20 +330,26 @@ public class World implements Disposable, SaveFileContent {
//////////////////
///////// calculation structure position with wavefunctioncollapse
//////////////////
List<CompletableFuture<Long>> futures = new ArrayList<>();
for (BiomeData biome : data.GetBiomes()) {
if (biome.structures != null) {
int biomeWidth = (int) Math.round(biome.width * (double) width);
int biomeHeight = (int) Math.round(biome.height * (double) height);
for (BiomeStructureData data : biome.structures) {
long localSeed = seed;
futures.add(CompletableFuture.supplyAsync(()-> {
long threadStartTime = System.currentTimeMillis();
BiomeStructure structure = new BiomeStructure(data, localSeed, biomeWidth, biomeHeight);
structure.initialize();
structureDataMap.put(data, structure);
measureGenerationTime("wavefunctioncollapse " + data.sourcePath, threadStartTime);
return measureGenerationTime("wavefunctioncollapse " + data.sourcePath, threadStartTime);
}));
}
}
}
CompletableFuture<?>[] futuresArray = futures.toArray(new CompletableFuture<?>[0]);
CompletableFuture.allOf(futuresArray).join();
futures.clear();
//////////////////
///////// calculation each biome position based on noise and radius
@@ -612,7 +620,7 @@ public class World implements Disposable, SaveFileContent {
//reset terrain path to the next town
for (Pair<PointOfInterest, PointOfInterest> poiToTown : allPOIPathsToNextTown) {
futures.add(CompletableFuture.supplyAsync(()-> {
int startX = (int) poiToTown.getKey().getTilePosition(data.tileSize).x;
int startY = (int) poiToTown.getKey().getTilePosition(data.tileSize).y;
int x1 = (int) poiToTown.getValue().getTilePosition(data.tileSize).x;
@@ -639,10 +647,14 @@ public class World implements Disposable, SaveFileContent {
startY = startY + sy;
}
}
return 0l;
}));
}
futuresArray = futures.toArray(new CompletableFuture<?>[0]);
CompletableFuture.allOf(futuresArray).join();
futures.clear();
for (Pair<PointOfInterest, PointOfInterest> townPair : allSortedTowns) {
futures.add(CompletableFuture.supplyAsync(()-> {
int startX = (int) townPair.getKey().getTilePosition(data.tileSize).x;
int startY = (int) townPair.getKey().getTilePosition(data.tileSize).y;
int x1 = (int) townPair.getValue().getTilePosition(data.tileSize).x;
@@ -676,7 +688,12 @@ public class World implements Disposable, SaveFileContent {
startY = startY + sy;
}
}
return 0l;
}));
}
futuresArray = futures.toArray(new CompletableFuture<?>[0]);
CompletableFuture.allOf(futuresArray).join();
futures.clear();
currentTime[0] = measureGenerationTime("roads", currentTime[0]);
//////////////////
@@ -784,7 +801,11 @@ public class World implements Disposable, SaveFileContent {
if (GuiBase.isAndroid())
GuiBase.getInterface().preventSystemSleep(false);
return this;
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
HashMap<String, Pair<Pixmap, HashMap<String, Pixmap>>> pixmapHash = new HashMap<>();

View File

@@ -79,7 +79,8 @@ public class WorldSave {
} catch (Exception e) {
System.err.println("Generating New World");
currentSave.world.generateNew(0);
if (!currentSave.world.generateNew(0))
return false;
}
currentSave.onLoadList.emit();

View File

@@ -3445,3 +3445,16 @@ lblSnapshot=Schnappschuss
lblNewSnapshotVersion=NEU FORGE-{0}!
cbSnapshotUpdate=Überprüfen Sie Snapshot-Updates beim Start.
nlSnapshotUpdate=Wenn diese Option aktiviert ist, werden Snapshot-Updates beim Start automatisch überprüft und die Benachrichtigung in der Titelleiste angezeigt.
lblAddCommander=Satz
lblaspartnercommander=als Partnerkommandant
lblfromattractiondeck=vom Attraktionsdeck
lbltoattractiondeck=zum Attraktionsdeck
lblAddDeckSection=Variantenabschnitt hinzufügen...
lblAddDeckSectionSelect=Wählen Sie den Abschnitt zum Hinzufügen aus
lblFrom=aus
lblAttractions=Attraktionen
lblConspiracies=Verschwörungen
lblChooseOrderCardsPutIntoAttractionDeck=Wählen Sie die Reihenfolge der Karten aus, die in den Attraktionsstapel gelegt werden sollen
lblAttractionRollResult={0} gewürfelt, um ihre Attraktionen zu besuchen. Ergebnis: {1}.
lblAttractionDeckZone=Attraktionsdeck
lblLights=Lichter

View File

@@ -3459,3 +3459,10 @@ lblSnapshot=Instantánea
lblNewSnapshotVersion=NUEVO FORGE-{0}!
cbSnapshotUpdate=Verifique las actualizaciones de instantáneas al inicio.
nlSnapshotUpdate=Cuando está habilitado, verifica automáticamente las actualizaciones de instantáneas al inicio y muestra la notificación en la barra de título.
lblaspartnercommander=como comandante compañero
lblfromattractiondeck=desde la plataforma de atracción
lbltoattractiondeck=a la plataforma de atracción
lblFrom=de
lblChooseOrderCardsPutIntoAttractionDeck=Elige el orden de las cartas para colocarlas en el mazo de atracciones.
lblAttractionRollResult={0} rodó para visitar sus atracciones. Resultado: {1}.
lblLights=Luces

View File

@@ -3453,3 +3453,16 @@ lblSnapshot=Instantané
lblNewSnapshotVersion=NOUVEAU FORGE{0}!
cbSnapshotUpdate=Vérifiez les mises à jour des instantanés au démarrage.
nlSnapshotUpdate=Lorsqu'il est activé, vérifie automatiquement les mises à jour des instantanés au démarrage et affiche la notification sur la barre de titre.
lblAddCommander=Ensemble
lblaspartnercommander=en tant que commandant partenaire
lblfromattractiondeck=depuis le pont d'attraction
lbltoattractiondeck=au pont d'attraction
lblAddDeckSection=Ajouter une section de variante...
lblAddDeckSectionSelect=Sélectionnez la section à ajouter
lblFrom=depuis
lblAttractions=Attractions
lblConspiracies=Conspirations
lblChooseOrderCardsPutIntoAttractionDeck=Choisissez l'ordre des cartes à mettre dans le jeu d'attraction
lblAttractionRollResult={0} ont lancé un jet pour visiter leurs attractions. Résultat: {1}.
lblAttractionDeckZone=pont d'attraction
lblLights=Lumières

View File

@@ -3451,3 +3451,16 @@ lblSnapshot=Istantanea
lblNewSnapshotVersion=NUOVO FORGE-{0}!
cbSnapshotUpdate=Controlla gli aggiornamenti delle istantanee all'avvio.
nlSnapshotUpdate=Se abilitato, controlla automaticamente gli aggiornamenti delle istantanee all'avvio e visualizza la notifica sulla barra del titolo.
lblAddCommander=Impostato
lblaspartnercommander=come comandante partner
lblfromattractiondeck=dal ponte delle attrazioni
lbltoattractiondeck=al ponte delle attrazioni
lblAddDeckSection=Aggiungi sezione variante...
lblAddDeckSectionSelect=Seleziona la sezione da aggiungere
lblFrom=da
lblAttractions=Attrazioni
lblConspiracies=Cospirazioni
lblChooseOrderCardsPutIntoAttractionDeck=Scegli l'ordine delle carte da inserire nel mazzo delle attrazioni
lblAttractionRollResult={0} ha rotolato per visitare le sue attrazioni. Risultato: {1}.
lblAttractionDeckZone=attrazione
lblLights=Luci

View File

@@ -3447,3 +3447,16 @@ lblSnapshot=スナップショット
lblNewSnapshotVersion=新しい FORGE-{0}!
cbSnapshotUpdate=起動時にスナップショットの更新を確認します。
nlSnapshotUpdate=有効にすると、起動時にスナップショットの更新が自動的にチェックされ、タイトル バーに通知が表示されます。
lblAddCommander=セット
lblaspartnercommander=パートナー指揮官として
lblfromattractiondeck=アトラクションデッキから
lbltoattractiondeck=アトラクションデッキへ
lblAddDeckSection=バリアント セクションを追加...
lblAddDeckSectionSelect=追加するセクションを選択してください
lblFrom=から
lblAttractions=アトラクション
lblConspiracies=陰謀
lblChooseOrderCardsPutIntoAttractionDeck=アトラクションデッキに入れるカードの順番を選択してください
lblAttractionRollResult={0} はアトラクションを訪れるために転がりました。結果: {1}。
lblAttractionDeckZone=アトラクションデッキ
lblLights=ライト

View File

@@ -3537,3 +3537,16 @@ lblSnapshot=Instantâneo
lblNewSnapshotVersion=NOVO FORGE-{0}!
cbSnapshotUpdate=Verifique as atualizações de instantâneos na inicialização.
nlSnapshotUpdate=Quando ativado, verifica automaticamente as atualizações do snapshot na inicialização e exibe a notificação na barra de título.
lblAddCommander=Definir
lblaspartnercommander=como comandante parceiro
lblfromattractiondeck=do deck de atração
lbltoattractiondeck=para o deck de atração
lblAddDeckSection=Adicionar seção de variante...
lblAddDeckSectionSelect=Selecione a seção a ser adicionada
lblFrom=de
lblAttractions=Atrações
lblConspiracies=Conspirações
lblChooseOrderCardsPutIntoAttractionDeck=Escolha a ordem das cartas para colocar no baralho de atração
lblAttractionRollResult={0} rolou para visitar suas atrações. Resultado: {1}.
lblAttractionDeckZone=deck de atração
lblLights=Luzes

View File

@@ -3438,3 +3438,16 @@ lblSnapshot=快照
lblNewSnapshotVersion=新 FORGE-{0}!
cbSnapshotUpdate=启动时检查快照更新。
nlSnapshotUpdate=启用后,启动时自动检查快照更新并在标题栏上显示通知。
lblAddCommander=
lblaspartnercommander=作为伙伴指挥官
lblfromattractiondeck=从景点甲板
lbltoattractiondeck=到景点甲板
lblAddDeckSection=添加变体部分...
lblAddDeckSectionSelect=选择要添加的部分
lblFrom=
lblAttractions=景点
lblConspiracies=阴谋
lblChooseOrderCardsPutIntoAttractionDeck=选择放入景点牌组的卡片顺序
lblAttractionRollResult={0} 滚动访问他们的景点。结果:{1}。
lblAttractionDeckZone=吸引力甲板
lblLights=