Add directories to distingish between pixelized apps.
This commit is contained in:
parent
03df369e0b
commit
3f67e342a7
18 changed files with 178 additions and 108 deletions
|
|
@ -1,55 +0,0 @@
|
|||
package com.pixelized.shared.lwa
|
||||
|
||||
enum class OperatingSystem(
|
||||
val home: String = System.getProperty("user.home"),
|
||||
) {
|
||||
Windows,
|
||||
Macintosh;
|
||||
|
||||
companion object {
|
||||
val current: OperatingSystem = run {
|
||||
val name = System.getProperty("os.name")
|
||||
when {
|
||||
name.contains(other = "win", ignoreCase = true) -> Windows
|
||||
name.contains(other = "mac", ignoreCase = true) -> Macintosh
|
||||
else -> error("Unsupported operating system: $name")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun storePath(
|
||||
os: OperatingSystem = OperatingSystem.current,
|
||||
): String {
|
||||
return when (os) {
|
||||
OperatingSystem.Windows -> "${os.home}\\AppData\\Roaming\\Pixelized\\"
|
||||
OperatingSystem.Macintosh -> "${os.home}/Library/Pixelized/"
|
||||
}
|
||||
}
|
||||
|
||||
fun characterStorePath(
|
||||
os: OperatingSystem = OperatingSystem.current,
|
||||
): String {
|
||||
return when (os) {
|
||||
OperatingSystem.Windows -> "${storePath(os = os)}characters\\"
|
||||
OperatingSystem.Macintosh -> "${storePath(os = os)}characters/"
|
||||
}
|
||||
}
|
||||
|
||||
fun campaignPath(
|
||||
os: OperatingSystem = OperatingSystem.current,
|
||||
): String {
|
||||
return when (os) {
|
||||
OperatingSystem.Windows -> "${storePath(os = os)}campaign\\"
|
||||
OperatingSystem.Macintosh -> "${storePath(os = os)}campaign/"
|
||||
}
|
||||
}
|
||||
|
||||
fun alterationsPath(
|
||||
os: OperatingSystem = OperatingSystem.current,
|
||||
): String {
|
||||
return when (os) {
|
||||
OperatingSystem.Windows -> "${storePath(os = os)}alterations\\"
|
||||
OperatingSystem.Macintosh -> "${storePath(os = os)}alterations/"
|
||||
}
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ class CharacterSheetJsonFactory(
|
|||
CharacterSheetJsonV1.Skill(
|
||||
id = it.id,
|
||||
label = it.label,
|
||||
description = null,
|
||||
description = it.description,
|
||||
base = it.base,
|
||||
bonus = it.bonus,
|
||||
level = it.level,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.pixelized.shared.lwa.utils
|
||||
|
||||
enum class OperatingSystem(
|
||||
val home: String = System.getProperty("user.home"),
|
||||
) {
|
||||
Windows,
|
||||
Macintosh;
|
||||
|
||||
companion object {
|
||||
val current: OperatingSystem = run {
|
||||
val name = System.getProperty("os.name")
|
||||
when {
|
||||
name.contains(other = "win", ignoreCase = true) -> Windows
|
||||
name.contains(other = "mac", ignoreCase = true) -> Macintosh
|
||||
else -> error("Unsupported operating system: $name")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.pixelized.shared.lwa.utils
|
||||
|
||||
class PathProvider(
|
||||
private val operatingSystem: OperatingSystem = OperatingSystem.current,
|
||||
private val appName: String,
|
||||
) {
|
||||
fun storePath(
|
||||
os: OperatingSystem = this.operatingSystem,
|
||||
app: String = this.appName,
|
||||
): String {
|
||||
return when (os) {
|
||||
OperatingSystem.Windows -> "${os.home}\\AppData\\Roaming\\Pixelized\\$app\\"
|
||||
OperatingSystem.Macintosh -> "${os.home}/Library/Pixelized/$app/"
|
||||
}
|
||||
}
|
||||
|
||||
fun characterStorePath(
|
||||
os: OperatingSystem = this.operatingSystem,
|
||||
app: String = this.appName,
|
||||
): String {
|
||||
return when (os) {
|
||||
OperatingSystem.Windows -> "${storePath(os = os, app = app)}characters\\"
|
||||
OperatingSystem.Macintosh -> "${storePath(os = os, app = app)}characters/"
|
||||
}
|
||||
}
|
||||
|
||||
fun campaignPath(
|
||||
os: OperatingSystem = this.operatingSystem,
|
||||
app: String = this.appName,
|
||||
): String {
|
||||
return when (os) {
|
||||
OperatingSystem.Windows -> "${storePath(os = os, app = app)}campaign\\"
|
||||
OperatingSystem.Macintosh -> "${storePath(os = os, app = app)}campaign/"
|
||||
}
|
||||
}
|
||||
|
||||
fun alterationsPath(
|
||||
os: OperatingSystem = this.operatingSystem,
|
||||
app: String = this.appName,
|
||||
): String {
|
||||
return when (os) {
|
||||
OperatingSystem.Windows -> "${storePath(os = os, app = app)}alterations\\"
|
||||
OperatingSystem.Macintosh -> "${storePath(os = os, app = app)}alterations/"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue