-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement preferences, start on ui work, start on itch api
- Loading branch information
Showing
42 changed files
with
20,629 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,5 @@ | |
.gradle | ||
build/ | ||
*.log | ||
.abysltcg/ | ||
|
||
|
||
.abysl/ | ||
data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
package com.abysl.assetmanager | ||
|
||
import com.abysl.assetmanager.db.tables.PreferencesTable | ||
import kotlinx.coroutines.selects.select | ||
import okio.Path.Companion.toPath | ||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq | ||
import org.jetbrains.exposed.sql.transactions.transaction | ||
|
||
object Prefs { | ||
|
||
val HOME_FOLDER = ".abysltcg".toPath().toFile().also { it.mkdir() } | ||
val IMAGE_FOLDER = (HOME_FOLDER.path + "/images").toPath().toFile().also { it.mkdir() } | ||
val DB_FILE = (Prefs.HOME_FOLDER.path + "/db.sqlite").toPath().toFile().also { it.createNewFile() } | ||
val HOME_FOLDER = ".abysl/assetmanager".toPath().toFile().also { it.mkdir() } | ||
val DB_FILE = HOME_FOLDER.resolve("assetmanager.sqlite").also { it.createNewFile() } | ||
val IMAGE_PATH = HOME_FOLDER.resolve("images").also { it.mkdirs() } | ||
val IMAGE_CACHE = IMAGE_PATH.resolve("cache").also { it.mkdirs() } | ||
|
||
val itchApiKey by lazy { PreferencesTable["itchApiKey"] } | ||
} |
4 changes: 0 additions & 4 deletions
4
src/main/kotlin/com/abysl/assetmanager/components/game/GameContext.kt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
src/main/kotlin/com/abysl/assetmanager/components/game/GameScreen.kt
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/kotlin/com/abysl/assetmanager/components/shared/navigationbar/NavigationContext.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/kotlin/com/abysl/assetmanager/db/migrations/AssetCreator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.abysl.assetmanager.db.migrations | ||
|
||
import com.abysl.assetmanager.db.Migration | ||
import com.abysl.assetmanager.db.tables.AssetTable | ||
import com.abysl.assetmanager.model.Asset | ||
import com.abysl.humble.Humble | ||
import org.jetbrains.exposed.sql.SchemaUtils | ||
import org.jetbrains.exposed.sql.transactions.transaction | ||
import org.jetbrains.exposed.sql.update | ||
|
||
class AssetCreator : Migration() { | ||
override fun up() { | ||
val assets = Humble().getProducts().map { | ||
Asset( | ||
name = it.name, | ||
creator = it.creator, | ||
iconUrl = it.iconUrl, | ||
sourceUrl = it.url, | ||
downloads = it.downloads | ||
) | ||
} | ||
transaction { | ||
SchemaUtils.createMissingTablesAndColumns(AssetTable) | ||
assets.forEach {asset -> | ||
AssetTable.update({AssetTable.name eq asset.name }) { | ||
it[creator] = asset.creator | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
override fun down() { | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/kotlin/com/abysl/assetmanager/db/migrations/AssetStoreSchema.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.abysl.assetmanager.db.migrations | ||
|
||
import com.abysl.assetmanager.db.Migration | ||
import com.abysl.assetmanager.db.tables.AssetTable | ||
import com.abysl.assetmanager.db.tables.AssetTable.downloads | ||
import com.abysl.assetmanager.db.tables.AssetTable.iconUrl | ||
import com.abysl.assetmanager.db.tables.AssetTable.name | ||
import com.abysl.assetmanager.db.tables.AssetTable.sourceUrl | ||
import com.abysl.assetmanager.db.tables.ImageTable | ||
import com.abysl.assetmanager.model.Asset | ||
import com.abysl.humble.Humble | ||
import kotlinx.serialization.encodeToString | ||
import kotlinx.serialization.json.Json | ||
import org.jetbrains.exposed.sql.SchemaUtils | ||
import org.jetbrains.exposed.sql.batchInsert | ||
import org.jetbrains.exposed.sql.insert | ||
import org.jetbrains.exposed.sql.transactions.transaction | ||
|
||
class AssetStoreSchema: Migration() { | ||
override fun up() { | ||
transaction { | ||
SchemaUtils.create (AssetTable) | ||
SchemaUtils.create (ImageTable) | ||
|
||
transaction { | ||
val assets = Humble().getProducts().map { | ||
Asset( | ||
name = it.name, | ||
creator = it.creator, | ||
iconUrl = it.iconUrl, | ||
sourceUrl = it.url, | ||
downloads = it.downloads | ||
) } | ||
AssetTable.batchInsert(assets) { asset -> | ||
this[name] = asset.name | ||
this[iconUrl] = asset.iconUrl | ||
this[sourceUrl] = asset.sourceUrl | ||
this[downloads] = Json.encodeToString(asset.downloads) | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun down() { | ||
transaction { | ||
SchemaUtils.drop (AssetTable) | ||
} | ||
} | ||
} |
6 changes: 2 additions & 4 deletions
6
src/main/kotlin/com/abysl/assetmanager/db/migrations/InitialSchema.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/com/abysl/assetmanager/db/migrations/PreferencesMigration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.abysl.assetmanager.db.migrations | ||
|
||
import com.abysl.assetmanager.db.Migration | ||
import com.abysl.assetmanager.db.tables.PreferencesTable | ||
import org.jetbrains.exposed.sql.SchemaUtils | ||
import org.jetbrains.exposed.sql.transactions.transaction | ||
|
||
class PreferencesMigration: Migration() { | ||
override fun up() { | ||
transaction { | ||
SchemaUtils.create(PreferencesTable) | ||
} | ||
} | ||
|
||
override fun down() { | ||
transaction { | ||
SchemaUtils.drop(PreferencesTable) | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/com/abysl/assetmanager/db/tables/AssetTable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.abysl.assetmanager.db.tables | ||
|
||
import com.abysl.assetmanager.model.Asset | ||
import kotlinx.serialization.decodeFromString | ||
import kotlinx.serialization.json.Json | ||
import org.jetbrains.exposed.dao.id.IntIdTable | ||
import org.jetbrains.exposed.sql.ResultRow | ||
|
||
object AssetTable: IntIdTable() { | ||
val name = varchar("name", 256); | ||
val creator = varchar("creator", 256).default("Unknown") | ||
val iconUrl = varchar("iconUrl", 256) | ||
val sourceUrl = varchar("sourceUrl", 256); | ||
val downloads = varchar("downloads", 4096) | ||
|
||
fun fromRow(row: ResultRow): Asset = | ||
Asset( | ||
name = row[name], | ||
creator = row[creator], | ||
iconUrl = row[iconUrl], | ||
sourceUrl = row[sourceUrl], | ||
downloads = Json.decodeFromString(row[downloads]) | ||
) | ||
} |
18 changes: 0 additions & 18 deletions
18
src/main/kotlin/com/abysl/assetmanager/db/tables/CardTable.kt
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
src/main/kotlin/com/abysl/assetmanager/db/tables/ImageTable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.abysl.assetmanager.db.tables | ||
|
||
import com.abysl.assetmanager.model.CachedImage | ||
import org.jetbrains.exposed.dao.id.IntIdTable | ||
import org.jetbrains.exposed.sql.ResultRow | ||
|
||
object ImageTable: IntIdTable() { | ||
val url = varchar("name", 256); | ||
|
||
fun fromRow(row: ResultRow): CachedImage = | ||
CachedImage( | ||
url = row[url], | ||
id = row[id].value, | ||
) | ||
} |
Oops, something went wrong.