Add other materies to the character sheet.
This commit is contained in:
parent
cbb0460bbf
commit
4a44d8fc51
8 changed files with 240 additions and 23 deletions
|
|
@ -49,6 +49,9 @@ data class CharacterSheet(
|
|||
val sleightOfHand: Int, // DEX, Représentation
|
||||
val stealth: Int, // DEX, Survie
|
||||
val survival: Int, // WIS, Tromperie
|
||||
val martial: List<String>, // martial masteries
|
||||
val languages: List<String>, // languages masteries
|
||||
val others: List<String>, // others masteries
|
||||
) {
|
||||
val isWarlock: Boolean get() = characterClass.contains(CLASS_WARLOCK)
|
||||
|
||||
|
|
|
|||
|
|
@ -54,12 +54,12 @@ class CharacterSheetParser @Inject constructor() {
|
|||
intelligence = item.parseInt(column = INTELLIGENCE) ?: 10,
|
||||
wisdom = item.parseInt(column = WISDOM) ?: 10,
|
||||
charisma = item.parseInt(column = CHARISMA) ?: 10,
|
||||
strengthSavingThrows = item.parseInt(column = STRENGTH_SAVING_THROW) ?: 0,
|
||||
dexteritySavingThrows = item.parseInt(column = DEXTERITY_SAVING_THROW) ?: 0,
|
||||
constitutionSavingThrows = item.parseInt(column = CONSTITUTION_SAVING_THROW) ?: 0,
|
||||
intelligenceSavingThrows = item.parseInt(column = INTELLIGENCE_SAVING_THROW) ?: 0,
|
||||
wisdomSavingThrows = item.parseInt(column = WISDOM_SAVING_THROW) ?: 0,
|
||||
charismaSavingThrows = item.parseInt(column = CHARISMA_SAVING_THROW) ?: 0,
|
||||
strengthSavingThrows = item.parseInt(column = STRENGTH_ST) ?: 0,
|
||||
dexteritySavingThrows = item.parseInt(column = DEXTERITY_ST) ?: 0,
|
||||
constitutionSavingThrows = item.parseInt(column = CONSTITUTION_ST) ?: 0,
|
||||
intelligenceSavingThrows = item.parseInt(column = INTELLIGENCE_ST) ?: 0,
|
||||
wisdomSavingThrows = item.parseInt(column = WISDOM_ST) ?: 0,
|
||||
charismaSavingThrows = item.parseInt(column = CHARISMA_ST) ?: 0,
|
||||
acrobatics = item.parseInt(column = ACROBATICS) ?: 0,
|
||||
animalHandling = item.parseInt(column = ANIMAL_HANDLING) ?: 0,
|
||||
arcana = item.parseInt(column = ARCANA) ?: 0,
|
||||
|
|
@ -78,6 +78,18 @@ class CharacterSheetParser @Inject constructor() {
|
|||
sleightOfHand = item.parseInt(column = SLEIGHT_OF_HAND) ?: 0,
|
||||
stealth = item.parseInt(column = STEALTH) ?: 0,
|
||||
survival = item.parseInt(column = SURVIVAL) ?: 0,
|
||||
martial = item.parse(column = MARTIAL)
|
||||
?.split(",")
|
||||
?.map { it.trim() }
|
||||
?: emptyList(),
|
||||
languages = item.parse(column = LANGUAGE)
|
||||
?.split(",")
|
||||
?.map { it.trim() }
|
||||
?: emptyList(),
|
||||
others = item.parse(column = OTHERS)
|
||||
?.split(",")
|
||||
?.map { it.trim() }
|
||||
?: emptyList(),
|
||||
)
|
||||
} else {
|
||||
null
|
||||
|
|
@ -112,12 +124,12 @@ class CharacterSheetParser @Inject constructor() {
|
|||
private val INTELLIGENCE = column("Intelligence")
|
||||
private val WISDOM = column("Sagesse")
|
||||
private val CHARISMA = column("Charisme")
|
||||
private val STRENGTH_SAVING_THROW = column("Jet de sauvegarde: Force")
|
||||
private val DEXTERITY_SAVING_THROW = column("Jet de sauvegarde: Dextérité")
|
||||
private val CONSTITUTION_SAVING_THROW = column("Jet de sauvegarde: Constitution")
|
||||
private val INTELLIGENCE_SAVING_THROW = column("Jet de sauvegarde: Intelligence")
|
||||
private val WISDOM_SAVING_THROW = column("Jet de sauvegarde: Sagesse")
|
||||
private val CHARISMA_SAVING_THROW = column("Jet de sauvegarde: Charisme")
|
||||
private val STRENGTH_ST = column("Jet de sauvegarde: Force")
|
||||
private val DEXTERITY_ST = column("Jet de sauvegarde: Dextérité")
|
||||
private val CONSTITUTION_ST = column("Jet de sauvegarde: Constitution")
|
||||
private val INTELLIGENCE_ST = column("Jet de sauvegarde: Intelligence")
|
||||
private val WISDOM_ST = column("Jet de sauvegarde: Sagesse")
|
||||
private val CHARISMA_ST = column("Jet de sauvegarde: Charisme")
|
||||
private val ACROBATICS = column("Acrobaties")
|
||||
private val ANIMAL_HANDLING = column("Dressage")
|
||||
private val ARCANA = column("Arcanes")
|
||||
|
|
@ -136,6 +148,9 @@ class CharacterSheetParser @Inject constructor() {
|
|||
private val SLEIGHT_OF_HAND = column("Escamotage")
|
||||
private val STEALTH = column("Discrétion")
|
||||
private val SURVIVAL = column("Survie")
|
||||
private val MARTIAL = column("Maitrise martiale")
|
||||
private val LANGUAGE = column("Maitrise language")
|
||||
private val OTHERS = column("Autres maitrises")
|
||||
|
||||
private val ROWS
|
||||
get() = listOf(
|
||||
|
|
@ -163,12 +178,12 @@ class CharacterSheetParser @Inject constructor() {
|
|||
INTELLIGENCE,
|
||||
WISDOM,
|
||||
CHARISMA,
|
||||
STRENGTH_SAVING_THROW,
|
||||
DEXTERITY_SAVING_THROW,
|
||||
CONSTITUTION_SAVING_THROW,
|
||||
INTELLIGENCE_SAVING_THROW,
|
||||
WISDOM_SAVING_THROW,
|
||||
CHARISMA_SAVING_THROW,
|
||||
STRENGTH_ST,
|
||||
DEXTERITY_ST,
|
||||
CONSTITUTION_ST,
|
||||
INTELLIGENCE_ST,
|
||||
WISDOM_ST,
|
||||
CHARISMA_ST,
|
||||
ACROBATICS,
|
||||
ANIMAL_HANDLING,
|
||||
ARCANA,
|
||||
|
|
@ -187,6 +202,9 @@ class CharacterSheetParser @Inject constructor() {
|
|||
SLEIGHT_OF_HAND,
|
||||
STEALTH,
|
||||
SURVIVAL,
|
||||
MARTIAL,
|
||||
LANGUAGE,
|
||||
OTHERS,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
package com.pixelized.rplexicon.ui.screens.character.composable.character
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.preview.rememberCharacterSheetStatePreview
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import com.pixelized.rplexicon.utilitary.LOS_HOLLOW
|
||||
|
||||
@Stable
|
||||
data class MasteriesUio(
|
||||
val martial: List<String> = emptyList(),
|
||||
val languages: List<String> = emptyList(),
|
||||
val others: List<String> = emptyList(),
|
||||
)
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
fun Masteries(
|
||||
modifier: Modifier = Modifier,
|
||||
paddingValues: PaddingValues = PaddingValues(vertical = 8.dp, horizontal = 12.dp),
|
||||
masteries: MasteriesUio,
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(paddingValues),
|
||||
) {
|
||||
Text(
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
text = stringResource(id = R.string.character_sheet_martial_masteries),
|
||||
)
|
||||
|
||||
FlowRow(
|
||||
horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
|
||||
) {
|
||||
if (masteries.martial.isEmpty()) {
|
||||
Text(
|
||||
modifier = Modifier.alignByBaseline(),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
text = "-",
|
||||
)
|
||||
}
|
||||
masteries.martial.forEach {
|
||||
Text(
|
||||
modifier = Modifier.alignByBaseline(),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
fontWeight = FontWeight.Light,
|
||||
maxLines = 1,
|
||||
text = "$LOS_HOLLOW $it",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Text(
|
||||
modifier = Modifier.padding(top = 4.dp),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
text = stringResource(id = R.string.character_sheet_languages_masteries),
|
||||
)
|
||||
|
||||
FlowRow(
|
||||
horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
|
||||
) {
|
||||
if (masteries.languages.isEmpty()) {
|
||||
Text(
|
||||
modifier = Modifier.alignByBaseline(),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
text = "-",
|
||||
)
|
||||
}
|
||||
masteries.languages.forEach {
|
||||
Text(
|
||||
modifier = Modifier.alignByBaseline(),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
fontWeight = FontWeight.Light,
|
||||
maxLines = 1,
|
||||
text = "$LOS_HOLLOW $it",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Text(
|
||||
modifier = Modifier.padding(top = 4.dp),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
text = stringResource(id = R.string.character_sheet_others_masteries),
|
||||
)
|
||||
|
||||
FlowRow(
|
||||
horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
|
||||
) {
|
||||
if (masteries.others.isEmpty()) {
|
||||
Text(
|
||||
modifier = Modifier.alignByBaseline(),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
text = "-",
|
||||
)
|
||||
}
|
||||
masteries.others.forEach {
|
||||
Text(
|
||||
modifier = Modifier.alignByBaseline(),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
fontWeight = FontWeight.Light,
|
||||
maxLines = 1,
|
||||
text = "$LOS_HOLLOW $it",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO)
|
||||
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
private fun MasteriesPreview() {
|
||||
LexiconTheme {
|
||||
Surface {
|
||||
val sheet by rememberCharacterSheetStatePreview()
|
||||
Masteries(
|
||||
masteries = sheet.masteries,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import androidx.compose.runtime.mutableStateOf
|
|||
import androidx.compose.runtime.remember
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.LabelPointUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.MasteriesUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.ProficiencyUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.StatUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.pages.proficiency.CharacterSheetUio
|
||||
|
|
@ -175,6 +176,11 @@ fun rememberCharacterSheetStatePreview() = remember {
|
|||
modifier = 4,
|
||||
),
|
||||
),
|
||||
masteries = MasteriesUio(
|
||||
martial = listOf("Common & war weapons", "Light & Medium & Heavy Armors"),
|
||||
languages = listOf("Common", "Orc", "Elvish"),
|
||||
others = listOf("Pan flute"),
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import com.pixelized.rplexicon.data.model.Alteration
|
|||
import com.pixelized.rplexicon.data.model.CharacterSheet
|
||||
import com.pixelized.rplexicon.data.model.Property
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.LabelPointUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.MasteriesUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.ProficiencyUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.StatUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.pages.proficiency.CharacterSheetUio
|
||||
|
|
@ -189,6 +190,11 @@ class CharacterSheetUioFactory @Inject constructor() {
|
|||
modifier = charisma.modifier + alterations[Property.DECEPTION].sum + sheet.deception * proficiency,
|
||||
),
|
||||
),
|
||||
masteries = MasteriesUio(
|
||||
martial = sheet.martial,
|
||||
languages = sheet.languages,
|
||||
others = sheet.others,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -37,6 +37,8 @@ import androidx.hilt.navigation.compose.hiltViewModel
|
|||
import com.pixelized.rplexicon.LocalRollOverlay
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.LabelPointUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.Masteries
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.MasteriesUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.Proficiency
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.ProficiencyUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.character.Stat
|
||||
|
|
@ -51,6 +53,7 @@ data class CharacterSheetUio(
|
|||
val stats: List<StatUio>,
|
||||
val savingThrows: List<ProficiencyUio>,
|
||||
val proficiencies: List<ProficiencyUio>,
|
||||
val masteries: MasteriesUio,
|
||||
)
|
||||
|
||||
@Composable
|
||||
|
|
@ -151,6 +154,16 @@ fun ProficiencyPageContent(
|
|||
text = stringResource(id = R.string.character_sheet_title_proficiencies)
|
||||
)
|
||||
},
|
||||
masteries = {
|
||||
Masteries(
|
||||
masteries = sheet.masteries,
|
||||
)
|
||||
Text(
|
||||
modifier = Modifier.padding(vertical = 4.dp),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
text = stringResource(id = R.string.character_sheet_title_masteries)
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -163,6 +176,7 @@ private fun ProficiencyLayout(
|
|||
stats: @Composable ColumnScope.() -> Unit,
|
||||
savingThrows: @Composable ColumnScope.() -> Unit,
|
||||
proficiencies: @Composable ColumnScope.() -> Unit,
|
||||
masteries: @Composable ColumnScope.() -> Unit,
|
||||
) {
|
||||
val density = LocalDensity.current
|
||||
Layout(
|
||||
|
|
@ -187,6 +201,13 @@ private fun ProficiencyLayout(
|
|||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
content = proficiencies,
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.layoutId("Masteries")
|
||||
.ddBorder(inner = inner, outline = outline),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
content = masteries,
|
||||
)
|
||||
},
|
||||
measurePolicy = { measurables, constraints ->
|
||||
val spacingPx = with(density) { spacing.toPx().toInt() }
|
||||
|
|
@ -205,7 +226,6 @@ private fun ProficiencyLayout(
|
|||
maxWidth = proficienciesWidth,
|
||||
)
|
||||
)
|
||||
|
||||
val statsHeight = savingThrowsMeasure.height + proficienciesMeasure.height + spacingPx
|
||||
val statsMeasure = measurables.stats.measure(
|
||||
constraints.copy(
|
||||
|
|
@ -215,8 +235,12 @@ private fun ProficiencyLayout(
|
|||
maxHeight = statsHeight,
|
||||
)
|
||||
)
|
||||
val othersMeasure = measurables.others.measure(constraints)
|
||||
|
||||
layout(width = constraints.maxWidth, height = statsMeasure.height) {
|
||||
layout(
|
||||
width = constraints.maxWidth,
|
||||
height = statsMeasure.height + othersMeasure.measuredHeight + spacingPx,
|
||||
) {
|
||||
statsMeasure.place(
|
||||
x = 0,
|
||||
y = 0,
|
||||
|
|
@ -229,6 +253,10 @@ private fun ProficiencyLayout(
|
|||
x = statsWidth + spacingPx,
|
||||
y = savingThrowsMeasure.height + spacingPx,
|
||||
)
|
||||
othersMeasure.place(
|
||||
x = 0,
|
||||
y = statsHeight + spacingPx,
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
@ -237,10 +265,11 @@ private fun ProficiencyLayout(
|
|||
val List<Measurable>.stats get() = first { it.layoutId == "StatsId" }
|
||||
val List<Measurable>.savingThrows get() = first { it.layoutId == "SavingThrowsId" }
|
||||
val List<Measurable>.proficiencies get() = first { it.layoutId == "ProficienciesId" }
|
||||
val List<Measurable>.others get() = first { it.layoutId == "Masteries" }
|
||||
|
||||
@Composable
|
||||
@Preview(uiMode = UI_MODE_NIGHT_NO, heightDp = 1060)
|
||||
@Preview(uiMode = UI_MODE_NIGHT_YES, heightDp = 1060)
|
||||
@Preview(uiMode = UI_MODE_NIGHT_NO, heightDp = 1300)
|
||||
@Preview(uiMode = UI_MODE_NIGHT_YES, heightDp = 1300)
|
||||
fun ProficiencyPreview() {
|
||||
LexiconTheme {
|
||||
Surface {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,11 @@
|
|||
<string name="character_sheet_title_speed">Vitesse</string>
|
||||
<string name="character_sheet_title_initiative">Initiative</string>
|
||||
<string name="character_sheet_title_saving_throws">Jet de sauvegarde</string>
|
||||
<string name="character_sheet_title_proficiencies">Maîtrises</string>
|
||||
<string name="character_sheet_title_proficiencies">Talents</string>
|
||||
<string name="character_sheet_title_masteries">Maîtrises & Langues</string>
|
||||
<string name="character_sheet_martial_masteries">Maîtrise martiale:</string>
|
||||
<string name="character_sheet_languages_masteries">Maîtrise de langues:</string>
|
||||
<string name="character_sheet_others_masteries">Autres maîtrises :</string>
|
||||
<string name="character_sheet_title_skills">Capacités</string>
|
||||
<string name="character_sheet_title_attacks">Attaques</string>
|
||||
<string name="character_sheet_title_objects">Objets</string>
|
||||
|
|
|
|||
|
|
@ -99,6 +99,10 @@
|
|||
<string name="character_sheet_title_initiative">Initiative</string>
|
||||
<string name="character_sheet_title_saving_throws">Saving Throws</string>
|
||||
<string name="character_sheet_title_proficiencies">Proficiencies</string>
|
||||
<string name="character_sheet_title_masteries">Masteries & Languages</string>
|
||||
<string name="character_sheet_martial_masteries">Martial masteries:</string>
|
||||
<string name="character_sheet_languages_masteries">Languages masteries:</string>
|
||||
<string name="character_sheet_others_masteries">Others masteries:</string>
|
||||
<string name="character_sheet_title_attacks">Attacks</string>
|
||||
<string name="character_sheet_title_objects">Objects</string>
|
||||
<string name="character_sheet_title_skills">Skills</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue