diff --git a/detekt/baseline.xml b/detekt/baseline.xml index be192b2..2f9530e 100644 --- a/detekt/baseline.xml +++ b/detekt/baseline.xml @@ -3,6 +3,7 @@ LongMethod:CharacterFactoryView.kt$@Composable fun CharacterFactoryView() + LongMethod:CharacterFactoryView.kt$@Composable private fun Traits( traitSelection: TraitSelection, personalityTraitSelectionState: SnapshotStateMap<Trait, Boolean>, commanderTraitSelectionState: SnapshotStateMap<Trait, Boolean>, criminalTraitSelectionState: SnapshotStateMap<Trait, Boolean>, copingTraitSelectionState: SnapshotStateMap<Trait, Boolean>, healthTraitSelectionState: SnapshotStateMap<Trait, Boolean>, dynastyTraitSelectionState: SnapshotStateMap<Trait, Boolean>, descendantTraitSelectionState: SnapshotStateMap<Trait, Boolean>, diseaseTraitSelectionState: SnapshotStateMap<Trait, Boolean>, childhoodTraitSelectionState: SnapshotStateMap<Trait, Boolean>, educationalTraitSelectionState: SnapshotStateMap<LeveledTrait, Int>, physicalTraitSelectionState: SnapshotStateMap<Trait, Boolean>, lifestyleTraitSelectionState: SnapshotStateMap<Trait, Boolean>, leveledLifestyleTraitSelectionState: SnapshotStateMap<LeveledTrait, Int>, congenitalTraitSelectionState: SnapshotStateMap<Trait, Boolean>, leveledCongenitalTraitSelectionState: SnapshotStateMap<LeveledTrait, Int> ) ReturnCount:ProjectFileFilter.kt$ProjectFileFilter$override fun accept(file: File?): Boolean TooManyFunctions:TraitSelection.kt$TraitSelection diff --git a/src/main/kotlin/com/github/xetra11/ck3workbench/module/character/SkillSelection.kt b/src/main/kotlin/com/github/xetra11/ck3workbench/module/character/SkillSelection.kt index ea54975..df402bb 100644 --- a/src/main/kotlin/com/github/xetra11/ck3workbench/module/character/SkillSelection.kt +++ b/src/main/kotlin/com/github/xetra11/ck3workbench/module/character/SkillSelection.kt @@ -15,7 +15,6 @@ import androidx.compose.runtime.setValue import androidx.compose.runtime.snapshots.SnapshotStateMap import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.alpha import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.imageFromResource import androidx.compose.ui.unit.TextUnit @@ -37,9 +36,9 @@ class SkillSelection { @Composable fun Skills( - selectionState: SnapshotStateMap + selectionState: SnapshotStateMap ) { - val chunks = enumValues().toList().chunked(5) + val chunks = enumValues().toList().chunked(6) chunks.forEach { Row { it.forEach { @@ -52,42 +51,29 @@ class SkillSelection { @Composable fun SkillIcon( skill: Skill, - selectionState: SnapshotStateMap + selectionState: SnapshotStateMap ) { - var isSelected by remember { mutableStateOf(false) } - var selectionModifier by remember { mutableStateOf(Modifier.alpha(0.2F)) } + var counter by remember { mutableStateOf(5) } + selectionState[skill] = counter Column( - modifier = Modifier.size(60.dp, 75.dp), + modifier = Modifier.size(75.dp, 80.dp), horizontalAlignment = Alignment.CenterHorizontally ) { - Box( - Modifier.clickable( - onClick = { - isSelected = !isSelected - selectionState[skill] = isSelected - selectionModifier = if (!isSelected) Modifier.alpha(0.2F) else Modifier.alpha(1F) - } - ), - contentAlignment = Alignment.Center, - ) { - SkillIconImage(selectionModifier, skill) + Box(contentAlignment = Alignment.Center) { + Image(modifier = Modifier.size(60.dp), bitmap = skillImage(skill)) + } + Row { + Text(modifier = Modifier.clickable { counter = if (counter <= 1) 0 else counter.minus(1) }, text = "<") + Text(counter.toString()) + Text( + modifier = Modifier.clickable { counter = if (counter >= 100) 100 else counter.plus(1) }, + text = ">" + ) } - if (isSelected) SkillLabel(skill) } } - @Composable - fun SkillIconImage( - selectionModifier: Modifier, - skill: Skill - ) { - Image( - modifier = selectionModifier, - bitmap = skillImage(skill) - ) - } - @Composable fun SkillLabel(skill: Skill) { Text( @@ -105,6 +91,6 @@ class SkillSelection { } companion object { - val skillIconPath = "icons/skill_icons" + const val skillIconPath = "icons/skill_icons" } } diff --git a/src/main/kotlin/com/github/xetra11/ck3workbench/module/character/TraitSelection.kt b/src/main/kotlin/com/github/xetra11/ck3workbench/module/character/TraitSelection.kt index 71ec37e..322d83a 100644 --- a/src/main/kotlin/com/github/xetra11/ck3workbench/module/character/TraitSelection.kt +++ b/src/main/kotlin/com/github/xetra11/ck3workbench/module/character/TraitSelection.kt @@ -418,7 +418,6 @@ class TraitSelection { } companion object { - val traitIconPath = "icons/trait_icons" - + const val traitIconPath = "icons/trait_icons" } } diff --git a/src/main/kotlin/com/github/xetra11/ck3workbench/module/character/view/CharacterFactoryView.kt b/src/main/kotlin/com/github/xetra11/ck3workbench/module/character/view/CharacterFactoryView.kt index 9116723..ba9000a 100644 --- a/src/main/kotlin/com/github/xetra11/ck3workbench/module/character/view/CharacterFactoryView.kt +++ b/src/main/kotlin/com/github/xetra11/ck3workbench/module/character/view/CharacterFactoryView.kt @@ -80,7 +80,7 @@ fun CharacterFactoryView() { val leveledLifestyleTraitSelectionState = remember { mutableStateMapOf() } val leveledCongenitalTraitSelectionState = remember { mutableStateMapOf() } - val skillSelectionState = remember { mutableStateMapOf() } + val skillSelectionState = remember { mutableStateMapOf() } Column( modifier = Modifier.padding(top = 15.dp, bottom = 7.dp).fillMaxSize(), @@ -227,20 +227,22 @@ private fun Traits( congenitalTraitSelectionState: SnapshotStateMap, leveledCongenitalTraitSelectionState: SnapshotStateMap ) { - Spoiler(label = { - Box( - Modifier.background(Color.LightGray) - .sizeIn(100.dp, 30.dp) - .padding(5.dp), - contentAlignment = Alignment.Center - ) { - Text( - fontSize = TextUnit.Em(1.2), - fontWeight = FontWeight.Bold, - text = "Traits" - ) + Spoiler( + label = { + Box( + Modifier.background(Color.LightGray) + .sizeIn(100.dp, 30.dp) + .padding(5.dp), + contentAlignment = Alignment.Center + ) { + Text( + fontSize = TextUnit.Em(1.2), + fontWeight = FontWeight.Bold, + text = "Traits" + ) + } } - }) { + ) { TraitSection("Personality Traits") { traitSelection.Traits(personalityTraitSelectionState) }