mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-16 11:11:41 +00:00
Improve handling npc sprites
This commit is contained in:
parent
8b4af8272f
commit
31ec2652de
3 changed files with 20 additions and 2 deletions
|
|
@ -36,7 +36,7 @@ class AppConfigManager(contentRepository: ContentRepository?) : com.habitrpg.com
|
|||
private val remoteConfig = FirebaseRemoteConfig.getInstance()
|
||||
|
||||
fun shopSpriteSuffix(): String? {
|
||||
return worldState?.npcImageSuffix
|
||||
return worldState?.findNpcImageSuffix()
|
||||
}
|
||||
|
||||
fun maxChatLength(): Long {
|
||||
|
|
|
|||
|
|
@ -21,4 +21,19 @@ open class WorldState : RealmObject(), BaseObject {
|
|||
|
||||
@SerializedName("currentEventList")
|
||||
var events: RealmList<WorldStateEvent> = RealmList()
|
||||
|
||||
fun findNpcImageSuffix(): String? {
|
||||
if (!npcImageSuffix.isNullOrBlank()) {
|
||||
return npcImageSuffix
|
||||
} else if (!currentEvent?.npcImageSuffix.isNullOrBlank()) {
|
||||
return currentEvent?.npcImageSuffix
|
||||
} else {
|
||||
for (event in events) {
|
||||
if (!event.npcImageSuffix.isNullOrBlank()) {
|
||||
return event.npcImageSuffix
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,10 @@ class NPCBannerView(context: Context, attrs: AttributeSet?) : FrameLayout(contex
|
|||
|
||||
var shopSpriteSuffix: String? = null
|
||||
set(value) {
|
||||
field = if (value.isNullOrEmpty() || value.startsWith("_")) {
|
||||
|
||||
field = if (value.isNullOrEmpty()) {
|
||||
""
|
||||
} else if (value.startsWith("_")) {
|
||||
value
|
||||
} else {
|
||||
"_$value"
|
||||
|
|
|
|||
Loading…
Reference in a new issue