devcycle-based version name (alpha, beta thing)

This commit is contained in:
minjaesong
2024-03-11 02:44:05 +09:00
parent 60eeeae759
commit 707abe8c6d
6 changed files with 86 additions and 12 deletions

View File

@@ -70,16 +70,11 @@ public class App implements ApplicationListener {
public static final String VERSION_TAG = TerrarumAppConfiguration.VERSION_TAG;
public static final String getVERSION_STRING() {
var snap = TerrarumAppConfiguration.INSTANCE.getVERSION_SNAPSHOT();
return String.format("%d.%d.%d", VERSION_RAW >>> 48, (VERSION_RAW & 0xffff000000L) >>> 24, VERSION_RAW & 0xffffffL) +
(VERSION_TAG.isBlank() ? "" : "-"+VERSION_TAG) + (snap == null ? "" : (" (" + snap + ")"));
return TerrarumAppConfiguration.INSTANCE.getVERSION_STRING();
}
public static final String getVERSION_STRING_WITHOUT_SNAPSHOT() {
return String.format("%d.%d.%d", VERSION_RAW >>> 48, (VERSION_RAW & 0xffff000000L) >>> 24, VERSION_RAW & 0xffffffL) +
(VERSION_TAG.isBlank() ? "" : "-"+VERSION_TAG);
return TerrarumAppConfiguration.INSTANCE.getVERSION_STRING_WITHOUT_SNAPSHOT();
}
/**

View File

@@ -77,12 +77,91 @@ basegame
// Commit counts up to the Release 0.4.0: 3631
// Commit counts up to the Release 0.4.1: 3678
val DEV_CYCLE: Map<String, Long> = mapOf(
"Alpha" to 0x0000_000004_000000,
"Beta" to 0x0000_FFFFFF_000000,
)
val VERSION_NUMBER: String = String.format(
"%d.%d.%d",
VERSION_RAW ushr 48,
(VERSION_RAW and 0xffff000000L) ushr 24,
VERSION_RAW and 0xffffffL
)
private val DEV_CYCLE_LIST_SORTED = DEV_CYCLE.toList().sortedBy { it.second }
val CURRENT_DEV_CYCLE: String? = DEV_CYCLE_LIST_SORTED.map { it.first to VERSION_RAW - it.second }.firstOrNull { it.second >= 0L }?.first
val VERSION_SNAPSHOT = Snapshot(0) // for normal dev
// val VERSION_SNAPSHOT = ForcedSnapshot("24w07d") // for snapshot release
// val VERSION_SNAPSHOT = null // for the release
const val VERSION_TAG: String = ""
val VERSION_STRING: String
get() {
val major = if (VERSION_RAW >= 0x0001_000000_000000)
VERSION_NUMBER
else if (CURRENT_DEV_CYCLE != null) {
val delta = VERSION_RAW - DEV_CYCLE[CURRENT_DEV_CYCLE]!!
CURRENT_DEV_CYCLE + " " + String.format("%d.%d", ((delta and 0xffff000000L) ushr 24) + 1, delta and 0xffffffL)
}
else
VERSION_NUMBER
val tag = if (VERSION_TAG.isNotBlank()) "-$VERSION_TAG" else ""
val snapshot = if (VERSION_SNAPSHOT == null) "" else " ($VERSION_SNAPSHOT)"
return "$major$tag$snapshot"
}
val VERSION_STRING_WITHOUT_SNAPSHOT: String
get() {
val major = if (VERSION_RAW >= 0x0001_000000_000000)
VERSION_NUMBER
else if (CURRENT_DEV_CYCLE != null) {
val delta = VERSION_RAW - DEV_CYCLE[CURRENT_DEV_CYCLE ?: ""]!!
CURRENT_DEV_CYCLE + " " + String.format("%d.%d", ((delta and 0xffff000000L) ushr 24) + 1, delta and 0xffffffL)
}
else
VERSION_NUMBER
val tag = if (VERSION_TAG.isNotBlank()) "-$VERSION_TAG" else ""
return "$major$tag"
}
fun convertVersionNumberToReadable(semverStr: String, snapshotObj: Snapshot? = null): String {
val numbers = semverStr.split('.')
val maj = numbers[0].toLong()
val min = numbers.getOrNull(1)?.toLong() ?: 0L
val pat = numbers.getOrNull(2)?.toLong() ?: 0L
val VERSION_RAW = maj.shl(48) or min.shl(24) or pat
val CURRENT_DEV_CYCLE: String? = DEV_CYCLE_LIST_SORTED.map { it.first to VERSION_RAW - it.second }.firstOrNull { it.second >= 0L }?.first
val major = if (VERSION_RAW >= 0x0001_000000_000000)
semverStr
else if (CURRENT_DEV_CYCLE != null) {
val delta = VERSION_RAW - DEV_CYCLE[CURRENT_DEV_CYCLE]!!
CURRENT_DEV_CYCLE + " " + String.format("%d.%d", ((delta and 0xffff000000L) ushr 24) + 1, delta and 0xffffffL)
}
else
semverStr
// val tag = if (VERSION_TAG.isNotBlank()) "-$VERSION_TAG" else ""
val snapshot = if (snapshotObj == null) "" else " (${snapshotObj})"
return "$major$snapshot"
}
fun convertVersionNumberToReadableShort(semverStr: String, snapshotObj: Snapshot? = null): String {
val s = convertVersionNumberToReadable(semverStr, snapshotObj)
return s.replace("Alpha", "α").replace("Beta", "β")
}
//////////////////////////////////////////////////////////
// CONFIGURATION FOR TILE MAKER //
// MAKE SURE THESE VALUES ARE UNIQUE IN THE SOURCE CODE //

View File

@@ -350,7 +350,7 @@ object TerrarumPostProcessor : Disposable {
private val defaultResStr = "Ingame UI Area"
private val currentResStr = "${App.scr.width}x${App.scr.height}"
private val safeAreaStr = "TV Safe Area"
private val versionStr = "Version ${App.getVERSION_STRING()}"
private val versionStr = "${App.getVERSION_STRING()}"
internal val thisIsDebugStr = "${App.GAME_NAME} ${if (App.IS_DEVELOPMENT_BUILD) "Development Build" else "Release"} $versionStr"
/**

View File

@@ -515,7 +515,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
printdbg(this, "loaded successfully.")
}
else {
App.getLoadScreen().addMessage("${App.GAME_NAME} version ${App.getVERSION_STRING()}")
App.getLoadScreen().addMessage("${App.GAME_NAME} ${App.getVERSION_STRING()}")
App.getLoadScreen().addMessage("Creating new world")

View File

@@ -544,7 +544,7 @@ class UIItemPlayerCells(
}
val snap = loadable.getSaveSnapshotVersion()
versionString = genver + (if (snap != null) "-$snap" else "")
versionString = TerrarumAppConfiguration.convertVersionNumberToReadable(genver, snap)// genver + (if (snap != null) "-$snap" else "")
val savegameVersionNum = // 0x GGGG GGGGGG GGGGGG YY WW RR
BigInteger(genverLong.toString()) * BigInteger("16777216") + BigInteger(snap?.hashCode()?.toString() ?: "16777215")

View File

@@ -9,6 +9,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.App
import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.TerrarumAppConfiguration
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.serialise.LoadSavegame
@@ -481,8 +482,7 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
}
val snap = this.getSaveSnapshotVersion()?.toString()
// val versionString = genver + (if (snap != null) "-$snap" else "")
val versionString = if (snap != null) "$snap" else genver
val versionString = if (snap != null) "$snap" else TerrarumAppConfiguration.convertVersionNumberToReadableShort(genver)
return SavegameMeta(
lastPlayTime,