Hide the ribbon alteration for non GameMaster
This commit is contained in:
parent
05a6b496cb
commit
560d7653a7
4 changed files with 30 additions and 18 deletions
|
|
@ -21,6 +21,7 @@ class CharacterRibbonFactory(
|
|||
hideOverruled: Boolean,
|
||||
enableCharacterSheet: Boolean,
|
||||
enableCharacterStats: Boolean,
|
||||
enableCharacterStatus: Boolean,
|
||||
): CharacterRibbonUio? {
|
||||
if (characterSheet == null) return null
|
||||
|
||||
|
|
@ -29,23 +30,6 @@ class CharacterRibbonFactory(
|
|||
alterations = fieldAlterations,
|
||||
)
|
||||
|
||||
val status = alterations.map { alteration ->
|
||||
CharacterRibbonAlterationUio(
|
||||
icon = alteration.metadata.icon ?: DEFAULT_ICON,
|
||||
tooltips = BasicTooltipUio(
|
||||
title = alteration.metadata.name,
|
||||
description = alteration.metadata.description,
|
||||
),
|
||||
)
|
||||
}.fold(
|
||||
initial = mutableListOf<MutableList<CharacterRibbonAlterationUio>>(),
|
||||
operation = { acc, item ->
|
||||
if (acc.isEmpty() || acc.last().size == 5) acc.add(mutableListOf())
|
||||
acc.last().add(item)
|
||||
acc
|
||||
}
|
||||
)
|
||||
|
||||
return CharacterRibbonUio(
|
||||
characterSheetId = characterSheet.id,
|
||||
hideOverruled = hideOverruled,
|
||||
|
|
@ -63,7 +47,24 @@ class CharacterRibbonFactory(
|
|||
)
|
||||
},
|
||||
),
|
||||
status = status,
|
||||
status = takeIf { enableCharacterStats }?.let {
|
||||
alterations.map { alteration ->
|
||||
CharacterRibbonAlterationUio(
|
||||
icon = alteration.metadata.icon ?: DEFAULT_ICON,
|
||||
tooltips = BasicTooltipUio(
|
||||
title = alteration.metadata.name,
|
||||
description = alteration.metadata.description,
|
||||
),
|
||||
)
|
||||
}.fold(
|
||||
initial = mutableListOf<MutableList<CharacterRibbonAlterationUio>>(),
|
||||
operation = { acc, item ->
|
||||
if (acc.isEmpty() || acc.last().size == 5) acc.add(mutableListOf())
|
||||
acc.last().add(item)
|
||||
acc
|
||||
}
|
||||
)
|
||||
} ?: emptyList(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -61,6 +61,10 @@ abstract class CharacterRibbonViewModel(
|
|||
settings: Settings,
|
||||
): Boolean
|
||||
|
||||
abstract fun enableCharacterStatus(
|
||||
settings: Settings,
|
||||
): Boolean
|
||||
|
||||
/**
|
||||
* This flow is a tad complex so there is an explanation of wtf it's about :
|
||||
* On a campaign update it go through every element of the abstract [fetch] list and either:
|
||||
|
|
@ -93,6 +97,7 @@ abstract class CharacterRibbonViewModel(
|
|||
hideOverruled = hideOverruled,
|
||||
enableCharacterSheet = enableCharacterSheet(settings = settings),
|
||||
enableCharacterStats = enableCharacterStats(settings = settings),
|
||||
enableCharacterStatus = enableCharacterStatus(settings = settings),
|
||||
)
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -43,4 +43,8 @@ class NpcRibbonViewModel(
|
|||
override fun enableCharacterStats(settings: Settings): Boolean {
|
||||
return settings.isGameMaster ?: false
|
||||
}
|
||||
|
||||
override fun enableCharacterStatus(settings: Settings): Boolean {
|
||||
return settings.isGameMaster ?: false
|
||||
}
|
||||
}
|
||||
|
|
@ -39,4 +39,6 @@ class PlayerRibbonViewModel(
|
|||
override fun enableCharacterSheet(settings: Settings) = true
|
||||
|
||||
override fun enableCharacterStats(settings: Settings) = true
|
||||
|
||||
override fun enableCharacterStatus(settings: Settings) = true
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue