diff --git a/composeApp/src/commonMain/composeResources/values/strings.xml b/composeApp/src/commonMain/composeResources/values/strings.xml
index 7506605..4e5d68a 100644
--- a/composeApp/src/commonMain/composeResources/values/strings.xml
+++ b/composeApp/src/commonMain/composeResources/values/strings.xml
@@ -59,6 +59,7 @@
Création de personnage
Édition de personnage
+ Identifiant du personnage
Nom
Sauvegarder
Caractéristiques
@@ -69,9 +70,11 @@
Intelligence
Pouvoir
Charisme
- Level
+ Niveau
Portrait
- Thumbnail
+ Vignette
+ Occupation
+ Lien externe
Caractéristiques dérivées
Déplacement
Points de vie maximum
@@ -87,8 +90,10 @@
Ajouter une compétence spéciale
Compétences magiques
Ajouter une compétence magique
- Description
+ Identifiant de la compétence
+ Label
Base
+ Description
Bonus
Niveau
Compétences
@@ -143,6 +148,7 @@
Level Up
Occupations
Ajouter une occupation
+ Identifiant de l'action
Nom
Description
Action normal
@@ -273,15 +279,18 @@
Admin
GameMaster
Sauvegarder
+ Sauvegarder sous
Filtrer par nom :
niv: %1$d
Joueur
Npc
Afficher le portrait
+ Lien externe
Ajouter au groupe
Retirer du groupe
Ajouter aux Npcs
Retirer des Npcs
+ Supprimer le personnage
Créer un personnage
Édition d'Altération
Filtrer par nom :
@@ -304,5 +313,6 @@
Empilable
Équipable
Consommable
+ Édition de personnage
\ No newline at end of file
diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/Module.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/Module.kt
index db2533a..543ac83 100644
--- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/Module.kt
+++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/Module.kt
@@ -56,6 +56,10 @@ import com.pixelized.desktop.lwa.ui.screen.gamemaster.alteration.edit.GMAlterati
import com.pixelized.desktop.lwa.ui.screen.gamemaster.alteration.edit.GMAlterationEditViewModel
import com.pixelized.desktop.lwa.ui.screen.gamemaster.alteration.list.GMAlterationFactory
import com.pixelized.desktop.lwa.ui.screen.gamemaster.alteration.list.GMAlterationViewModel
+import com.pixelized.desktop.lwa.ui.screen.gamemaster.character.edit.GMCharacterEditFactory
+import com.pixelized.desktop.lwa.ui.screen.gamemaster.character.edit.GMCharacterEditViewModel
+import com.pixelized.desktop.lwa.ui.screen.gamemaster.character.edit.dialog.GMCharacterSheetCopyDialogFactory
+import com.pixelized.desktop.lwa.ui.screen.gamemaster.character.edit.dialog.GMCharacterSheetCopyDialogViewModel
import com.pixelized.desktop.lwa.ui.screen.gamemaster.character.list.GMCharacterFactory
import com.pixelized.desktop.lwa.ui.screen.gamemaster.character.list.GMCharacterViewModel
import com.pixelized.desktop.lwa.ui.screen.gamemaster.common.tag.GMTagFactory
@@ -156,10 +160,12 @@ val factoryDependencies
factoryOf(::InventoryDialogFactory)
factoryOf(::ItemDetailDialogFactory)
factoryOf(::PurseDialogFactory)
+ factoryOf(::GMCharacterSheetCopyDialogFactory)
factoryOf(::TextMessageFactory)
factoryOf(::LevelUpFactory)
factoryOf(::GMTagFactory)
factoryOf(::GMCharacterFactory)
+ factoryOf(::GMCharacterEditFactory)
factoryOf(::GMAlterationFactory)
factoryOf(::GMAlterationEditFactory)
factoryOf(::GMItemFactory)
@@ -184,12 +190,14 @@ val viewModelDependencies
viewModelOf(::InventoryDialogViewModel)
viewModelOf(::ItemDetailDialogViewModel)
viewModelOf(::PurseDialogViewModel)
+ viewModelOf(::GMCharacterSheetCopyDialogViewModel)
viewModelOf(::CampaignChatViewModel)
viewModelOf(::SettingsViewModel)
viewModelOf(::LevelUpViewModel)
viewModelOf(::PortraitOverlayViewModel)
- viewModelOf(::GMCharacterViewModel)
viewModelOf(::GameMasterViewModel)
+ viewModelOf(::GMCharacterViewModel)
+ viewModelOf(::GMCharacterEditViewModel)
viewModelOf(::GMActionViewModel)
viewModelOf(::GMAlterationViewModel)
viewModelOf(::GMAlterationEditViewModel)
diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/network/LwaClient.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/network/LwaClient.kt
index dff8ec1..e8c7ec4 100644
--- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/network/LwaClient.kt
+++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/network/LwaClient.kt
@@ -3,7 +3,6 @@ package com.pixelized.desktop.lwa.network
import com.pixelized.shared.lwa.model.alteration.AlterationJson
import com.pixelized.shared.lwa.model.campaign.CampaignJson
import com.pixelized.shared.lwa.model.characterSheet.CharacterSheetJson
-import com.pixelized.shared.lwa.model.inventory.Inventory
import com.pixelized.shared.lwa.model.inventory.InventoryJson
import com.pixelized.shared.lwa.model.item.ItemJson
import com.pixelized.shared.lwa.model.tag.TagJson
@@ -51,7 +50,9 @@ interface LwaClient {
// Character
- suspend fun getCharacters(): APIResponse>
+ suspend fun getCharacterPreviews(): APIResponse>
+
+ suspend fun getCharacterPreview(characterSheetId: String): APIResponse
suspend fun getCharacter(
characterSheetId: String,
diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/network/LwaClientImpl.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/network/LwaClientImpl.kt
index 17a7e4e..381cfd8 100644
--- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/network/LwaClientImpl.kt
+++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/network/LwaClientImpl.kt
@@ -86,8 +86,15 @@ class LwaClientImpl(
.body>()
@Throws
- override suspend fun getCharacters(): APIResponse> = client
- .get("$root/character/all")
+ override suspend fun getCharacterPreviews(): APIResponse> = client
+ .get("$root/character/preview/all")
+ .body()
+
+ @Throws
+ override suspend fun getCharacterPreview(
+ characterSheetId: String,
+ ): APIResponse = client
+ .get("$root/character/preview/detail?characterSheetId=$characterSheetId")
.body()
@Throws
diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/repository/characterSheet/CharacterSheetStore.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/repository/characterSheet/CharacterSheetStore.kt
index f842148..54cd7b2 100644
--- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/repository/characterSheet/CharacterSheetStore.kt
+++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/repository/characterSheet/CharacterSheetStore.kt
@@ -1,6 +1,5 @@
package com.pixelized.desktop.lwa.repository.characterSheet
-import androidx.compose.runtime.clearCompositionErrors
import com.pixelized.desktop.lwa.network.LwaClient
import com.pixelized.desktop.lwa.repository.alteration.AlterationStore
import com.pixelized.desktop.lwa.repository.network.NetworkRepository
@@ -17,6 +16,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
+import kotlinx.serialization.json.Json
class CharacterSheetStore(
private val alterationStore: AlterationStore,
@@ -42,7 +42,7 @@ class CharacterSheetStore(
suspend fun updateCharactersPreviewFlow() {
_previewFlow.value = try {
- getCharacters()
+ getCharacterPreviews()
} catch (exception: Exception) {
println(exception.message) // TODO proper exception handling
emptyList()
@@ -67,8 +67,8 @@ class CharacterSheetStore(
}
@Throws
- suspend fun getCharacters(): List {
- val request = client.getCharacters()
+ suspend fun getCharacterPreviews(): List {
+ val request = client.getCharacterPreviews()
return when (request.success) {
true -> request.data
?.map { factory.convertFromJson(it) }
@@ -78,6 +78,17 @@ class CharacterSheetStore(
}
}
+ @Throws
+ suspend fun getCharacterPreview(
+ characterSheetId: String,
+ ): CharacterSheetPreview {
+ val request = client.getCharacterPreview(characterSheetId = characterSheetId)
+ return when (request.success) {
+ true -> factory.convertFromJson(request.data!!)
+ else -> LwaClient.error(error = request)
+ }
+ }
+
@Throws
suspend fun getCharacterSheet(
characterSheetId: String,
@@ -135,12 +146,15 @@ class CharacterSheetStore(
is ApiSynchronisation.CharacterSheetApiSynchronisation -> try {
when (message) {
is ApiSynchronisation.CharacterSheetUpdate -> {
- _detailFlow.update(
- sheet = getCharacterSheet(characterSheetId = message.characterSheetId)
+ val characterSheet = getCharacterSheet(
+ characterSheetId = message.characterSheetId,
+ )
+ _detailFlow.update(
+ sheet = characterSheet
+ )
+ _previewFlow.update(
+ preview = factory.convertToPreview(sheet = characterSheet),
)
- if (_previewFlow.value.firstOrNull { it.characterSheetId == message.characterSheetId } == null) {
- _previewFlow.value = getCharacters()
- }
}
is ApiSynchronisation.CharacterSheetDelete -> {
@@ -267,7 +281,6 @@ class CharacterSheetStore(
// endregion
-
private fun MutableStateFlow