Add description for object actions.
This commit is contained in:
parent
805a8f673f
commit
43ea748e51
4 changed files with 22 additions and 15 deletions
|
|
@ -41,12 +41,12 @@ fun ObjectItem(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
padding: PaddingValues = PaddingValues(top = 4.dp, bottom = 4.dp, start = 16.dp, end = 16.dp),
|
padding: PaddingValues = PaddingValues(top = 4.dp, bottom = 4.dp, start = 16.dp, end = 16.dp),
|
||||||
item: ObjectItemUio,
|
item: ObjectItemUio,
|
||||||
onObject: (String) -> Unit,
|
onObject: (ObjectItemUio) -> Unit,
|
||||||
onUse: (String) -> Unit,
|
onUse: (ObjectItemUio) -> Unit,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clickable { onObject(item.name) }
|
.clickable { onObject(item) }
|
||||||
.padding(paddingValues = padding)
|
.padding(paddingValues = padding)
|
||||||
.then(other = modifier),
|
.then(other = modifier),
|
||||||
horizontalArrangement = Arrangement.spacedBy(space = 12.dp),
|
horizontalArrangement = Arrangement.spacedBy(space = 12.dp),
|
||||||
|
|
@ -85,7 +85,7 @@ fun ObjectItem(
|
||||||
width = 1.dp,
|
width = 1.dp,
|
||||||
color = MaterialTheme.colorScheme.primary,
|
color = MaterialTheme.colorScheme.primary,
|
||||||
),
|
),
|
||||||
onClick = { onUse(item.name) },
|
onClick = { onUse(item) },
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(id = R.string.character_sheet_action_spell_cast),
|
text = stringResource(id = R.string.character_sheet_action_spell_cast),
|
||||||
|
|
|
||||||
|
|
@ -77,12 +77,12 @@ fun ActionPage(
|
||||||
overlay.showOverlay()
|
overlay.showOverlay()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onObject = { id ->
|
onObject = {
|
||||||
|
skillViewModel.showSkillDetailDialog(item = it.name)
|
||||||
},
|
},
|
||||||
onUseObject = { id ->
|
onUseObject = {
|
||||||
objectsViewModel.onUse(id)?.let {
|
objectsViewModel.onUse(it.name)?.let { throws ->
|
||||||
overlay.prepareRoll(diceThrow = it)
|
overlay.prepareRoll(diceThrow = throws)
|
||||||
overlay.showOverlay()
|
overlay.showOverlay()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -94,7 +94,7 @@ fun ActionPage(
|
||||||
overlay.showOverlay()
|
overlay.showOverlay()
|
||||||
},
|
},
|
||||||
onSkillInfo = {
|
onSkillInfo = {
|
||||||
skillViewModel.showSkillDetailDialog(item = it)
|
skillViewModel.showSkillDetailDialog(item = it.label)
|
||||||
},
|
},
|
||||||
onSpellLevel = { level: Int, value: Int, max: Int ->
|
onSpellLevel = { level: Int, value: Int, max: Int ->
|
||||||
spellsViewModel.showSpellEditDialog(level = level, value = value, max = max)
|
spellsViewModel.showSpellEditDialog(level = level, value = value, max = max)
|
||||||
|
|
@ -153,8 +153,8 @@ fun ActionsPageContent(
|
||||||
spells: State<List<Pair<SpellHeaderUio, List<SpellUio>>>>,
|
spells: State<List<Pair<SpellHeaderUio, List<SpellUio>>>>,
|
||||||
onAttackHit: (id: String) -> Unit,
|
onAttackHit: (id: String) -> Unit,
|
||||||
onAttackDamage: (id: String) -> Unit,
|
onAttackDamage: (id: String) -> Unit,
|
||||||
onObject: (id: String) -> Unit,
|
onObject: (ObjectItemUio) -> Unit,
|
||||||
onUseObject: (id: String) -> Unit,
|
onUseObject: (ObjectItemUio) -> Unit,
|
||||||
onSkillThrow: (SkillItemUio) -> Unit,
|
onSkillThrow: (SkillItemUio) -> Unit,
|
||||||
onSkillCount: (SkillItemUio) -> Unit,
|
onSkillCount: (SkillItemUio) -> Unit,
|
||||||
onSkillInfo: (SkillItemUio) -> Unit,
|
onSkillInfo: (SkillItemUio) -> Unit,
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,9 @@ class ObjectsViewModel @Inject constructor(
|
||||||
private val _objects = mutableStateOf<List<ObjectItemUio>>(emptyList())
|
private val _objects = mutableStateOf<List<ObjectItemUio>>(emptyList())
|
||||||
val objects: State<List<ObjectItemUio>> get() = _objects
|
val objects: State<List<ObjectItemUio>> get() = _objects
|
||||||
|
|
||||||
|
private val _dialog = mutableStateOf<SkillDetailUio?>(null)
|
||||||
|
val dialog: State<SkillDetailUio?> get() = _dialog
|
||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
objectsRepository.data.collect { objects ->
|
objectsRepository.data.collect { objects ->
|
||||||
|
|
@ -44,6 +47,10 @@ class ObjectsViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onDetail(name: String) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fun onUse(name: String): DiceThrow? {
|
fun onUse(name: String): DiceThrow? {
|
||||||
val item = objectsRepository.find(character = character, item = name)
|
val item = objectsRepository.find(character = character, item = name)
|
||||||
return item?.let {
|
return item?.let {
|
||||||
|
|
|
||||||
|
|
@ -104,12 +104,12 @@ class SkillsViewModel @Inject constructor(
|
||||||
skill = name,
|
skill = name,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun showSkillDetailDialog(item: SkillItemUio) {
|
fun showSkillDetailDialog(item: String) {
|
||||||
_skillDetailDialog.value = descriptionRepository
|
_skillDetailDialog.value = descriptionRepository
|
||||||
.find(name = item.label)
|
.find(name = item)
|
||||||
?.let { description ->
|
?.let { description ->
|
||||||
SkillDetailUio(
|
SkillDetailUio(
|
||||||
name = item.label,
|
name = item,
|
||||||
original = description.original,
|
original = description.original,
|
||||||
description = description.description
|
description = description.description
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue