mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-21 05:09:00 +00:00
Fix showing lostMasterclasser4 quest art. Fixes #974
This commit is contained in:
parent
e438be8f55
commit
30cacf160a
8 changed files with 128 additions and 189 deletions
|
|
@ -1,165 +0,0 @@
|
|||
package com.habitrpg.android.habitica.models.inventory;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import io.realm.RealmList;
|
||||
import io.realm.RealmObject;
|
||||
import io.realm.annotations.PrimaryKey;
|
||||
|
||||
public class QuestContent extends RealmObject implements Item {
|
||||
|
||||
@PrimaryKey
|
||||
String key;
|
||||
String text, notes;
|
||||
int value, owned;
|
||||
private String previous;
|
||||
private int lvl;
|
||||
private boolean canBuy;
|
||||
private String category;
|
||||
@Nullable
|
||||
private QuestBoss boss;
|
||||
@Nullable
|
||||
private QuestDrops drop;
|
||||
@Nullable
|
||||
private QuestColors colors;
|
||||
|
||||
RealmList<QuestCollect> collect;
|
||||
|
||||
public String getPrevious() {
|
||||
return previous;
|
||||
}
|
||||
|
||||
public void setPrevious(String previous) {
|
||||
this.previous = previous;
|
||||
}
|
||||
|
||||
public int getLvl() {
|
||||
return lvl;
|
||||
}
|
||||
|
||||
public void setLvl(int lvl) {
|
||||
this.lvl = lvl;
|
||||
}
|
||||
|
||||
public boolean isCanBuy() {
|
||||
return canBuy;
|
||||
}
|
||||
|
||||
public void setCanBuy(boolean canBuy) {
|
||||
this.canBuy = canBuy;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public QuestBoss getBoss() {
|
||||
return boss;
|
||||
}
|
||||
|
||||
public void setBoss(QuestBoss boss) {
|
||||
this.boss = boss;
|
||||
if (boss != null) {
|
||||
boss.setKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public QuestColors getColors() {
|
||||
return colors;
|
||||
}
|
||||
|
||||
public void setColors(QuestColors colors) {
|
||||
this.colors = colors;
|
||||
if (colors != null) {
|
||||
colors.setKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
public RealmList<QuestCollect> getCollect() {
|
||||
return collect;
|
||||
}
|
||||
|
||||
public void setCollect(RealmList<QuestCollect> collect) {
|
||||
this.collect = collect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "quests";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwned(int size) {
|
||||
owned = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getOwned() {
|
||||
return owned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setValue(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setNotes(String notes) {
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public QuestCollect getCollectWithKey(String key) {
|
||||
for (QuestCollect collect : this.collect) {
|
||||
if (collect.key.equals(key)) {
|
||||
return collect;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public QuestDrops getDrop() {
|
||||
return drop;
|
||||
}
|
||||
|
||||
public void setDrop(QuestDrops drop) {
|
||||
this.drop = drop;
|
||||
if (drop != null) {
|
||||
drop.setKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBossQuest() {
|
||||
return boss != null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
package com.habitrpg.android.habitica.models.inventory
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
import io.realm.RealmList
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class QuestContent : RealmObject(), Item {
|
||||
|
||||
@PrimaryKey
|
||||
internal var key: String = ""
|
||||
internal var text: String = ""
|
||||
var notes: String = ""
|
||||
internal var value: Int = 0
|
||||
internal var owned: Int = 0
|
||||
var previous: String? = null
|
||||
var lvl: Int = 0
|
||||
var isCanBuy: Boolean = false
|
||||
var category: String? = null
|
||||
var boss: QuestBoss? = null
|
||||
set(boss) {
|
||||
field = boss
|
||||
if (boss != null) {
|
||||
boss.key = key
|
||||
}
|
||||
}
|
||||
var drop: QuestDrops? = null
|
||||
set(drop) {
|
||||
field = drop
|
||||
if (drop != null) {
|
||||
drop.key = key
|
||||
}
|
||||
}
|
||||
var colors: QuestColors? = null
|
||||
set(colors) {
|
||||
field = colors
|
||||
if (colors != null) {
|
||||
colors.key = key
|
||||
}
|
||||
}
|
||||
|
||||
var collect: RealmList<QuestCollect>? = null
|
||||
|
||||
val isBossQuest: Boolean
|
||||
get() = this.boss != null
|
||||
|
||||
override fun getType(): String {
|
||||
return "quests"
|
||||
}
|
||||
|
||||
override fun getKey(): String {
|
||||
return key
|
||||
}
|
||||
|
||||
override fun setOwned(size: Int) {
|
||||
owned = size
|
||||
}
|
||||
|
||||
override fun getText(): String {
|
||||
return text
|
||||
}
|
||||
|
||||
override fun getOwned(): Int? {
|
||||
return owned
|
||||
}
|
||||
|
||||
override fun getValue(): Int? {
|
||||
return value
|
||||
}
|
||||
|
||||
fun setText(text: String) {
|
||||
this.text = text
|
||||
}
|
||||
|
||||
fun setValue(value: Int?) {
|
||||
this.value = value!!
|
||||
}
|
||||
|
||||
fun setKey(key: String) {
|
||||
this.key = key
|
||||
}
|
||||
|
||||
fun getCollectWithKey(key: String): QuestCollect? {
|
||||
for (collect in this.collect ?: emptyList<QuestCollect>()) {
|
||||
if (collect.key == key) {
|
||||
return collect
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun hasGifImage(): Boolean {
|
||||
val gifImageKeys = listOf("lostMasterclasser4")
|
||||
if (gifImageKeys.contains(key)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
@ -182,7 +182,7 @@ class TavernDetailFragment : BaseFragment() {
|
|||
|
||||
fun showWorldBossInfoDialog(context: Context, quest: QuestContent) {
|
||||
val alert = HabiticaAlertDialog(context)
|
||||
val bossName = quest.boss.name ?: ""
|
||||
val bossName = quest.boss?.name ?: ""
|
||||
alert.setTitle(R.string.world_boss_description_title)
|
||||
alert.setTitleBackgroundColor(quest.colors?.lightColor ?: 0)
|
||||
alert.setSubtitle(context.getString(R.string.world_boss_description_subtitle, bossName))
|
||||
|
|
|
|||
|
|
@ -185,7 +185,11 @@ class PartyDetailFragment : BaseFragment() {
|
|||
}
|
||||
questTitleView?.text = questContent.text
|
||||
DataBindingUtils.loadImage(questScrollImageView, "inventory_quest_scroll_" + questContent.key)
|
||||
DataBindingUtils.loadImage(questImageView, "quest_" + questContent.key)
|
||||
if (questContent.hasGifImage()) {
|
||||
DataBindingUtils.loadImage(questImageView, "quest_" + questContent.key, "gif")
|
||||
} else {
|
||||
DataBindingUtils.loadImage(questImageView, "quest_" + questContent.key)
|
||||
}
|
||||
if (isQuestActive) {
|
||||
questProgressView?.visibility = View.VISIBLE
|
||||
questProgressView?.setData(questContent, quest?.progress)
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@ class PurchaseDialogQuestContent : PurchaseDialogContent {
|
|||
if (questContent.isBossQuest) {
|
||||
questTypeTextView.setText(R.string.boss_quest)
|
||||
questCollectView.visibility = View.GONE
|
||||
bossHealthTextView.text = questContent.boss.hp.toString()
|
||||
if (questContent.boss.hasRage()) {
|
||||
bossHealthTextView.text = questContent.boss?.hp.toString()
|
||||
if (questContent.boss?.hasRage() == true) {
|
||||
rageMeterView.visibility = View.VISIBLE
|
||||
}
|
||||
questDifficultyView.rating = questContent.boss.str
|
||||
questDifficultyView.rating = questContent.boss?.str ?: 1f
|
||||
} else {
|
||||
questTypeTextView.setText(R.string.collection_quest)
|
||||
val collectionList = questContent.collect.map { it.count.toString() + " " + it.text }
|
||||
val collectionList = questContent.collect?.map { it.count.toString() + " " + it.text }
|
||||
questCollectTextView.text = TextUtils.join(", ", collectionList)
|
||||
|
||||
bossHealthView.visibility = View.GONE
|
||||
|
|
@ -62,13 +62,13 @@ class PurchaseDialogQuestContent : PurchaseDialogContent {
|
|||
|
||||
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as? LayoutInflater
|
||||
|
||||
if (questContent.drop != null && questContent.drop.items != null) {
|
||||
questContent.drop.items
|
||||
.filterNot { it.isOnlyOwner }
|
||||
.forEach { addRewardsRow(inflater, it, rewardsList) }
|
||||
if (questContent.drop != null && questContent.drop?.items != null) {
|
||||
questContent.drop?.items
|
||||
?.filterNot { it.isOnlyOwner }
|
||||
?.forEach { addRewardsRow(inflater, it, rewardsList) }
|
||||
|
||||
var hasOwnerRewards = false
|
||||
for (item in questContent.drop.items) {
|
||||
for (item in questContent.drop?.items ?: emptyList<QuestDropItem>()) {
|
||||
if (item.isOnlyOwner) {
|
||||
addRewardsRow(inflater, item, ownerRewardsList)
|
||||
hasOwnerRewards = true
|
||||
|
|
@ -79,23 +79,23 @@ class PurchaseDialogQuestContent : PurchaseDialogContent {
|
|||
ownerRewardsList.visibility = View.GONE
|
||||
}
|
||||
|
||||
if (questContent.drop.exp > 0) {
|
||||
if (questContent.drop?.exp ?: 0 > 0) {
|
||||
val view = inflater?.inflate(R.layout.row_quest_reward_imageview, rewardsList, false) as? ViewGroup
|
||||
val imageView = view?.findViewById<ImageView>(R.id.imageView)
|
||||
imageView?.scaleType = ImageView.ScaleType.CENTER
|
||||
imageView?.setImageBitmap(HabiticaIconsHelper.imageOfExperienceReward())
|
||||
val titleTextView = view?.findViewById<TextView>(R.id.titleTextView)
|
||||
titleTextView?.text = context.getString(R.string.experience_reward, questContent.drop.exp)
|
||||
titleTextView?.text = context.getString(R.string.experience_reward, questContent.drop?.exp)
|
||||
rewardsList.addView(view)
|
||||
}
|
||||
|
||||
if (questContent.drop.gp > 0) {
|
||||
if (questContent.drop?.gp ?: 0 > 0) {
|
||||
val view = inflater?.inflate(R.layout.row_quest_reward_imageview, rewardsList, false) as? ViewGroup
|
||||
val imageView = view?.findViewById<ImageView>(R.id.imageView)
|
||||
imageView?.scaleType = ImageView.ScaleType.CENTER
|
||||
imageView?.setImageBitmap(HabiticaIconsHelper.imageOfGoldReward())
|
||||
val titleTextView = view?.findViewById<TextView>(R.id.titleTextView)
|
||||
titleTextView?.text = context.getString(R.string.gold_reward, questContent.drop.gp)
|
||||
titleTextView?.text = context.getString(R.string.gold_reward, questContent.drop?.gp)
|
||||
rewardsList.addView(view)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,13 +71,13 @@ class OldQuestProgressView : LinearLayout {
|
|||
fun setData(quest: QuestContent, progress: QuestProgress?) {
|
||||
collectionContainer.removeAllViews()
|
||||
if (quest.isBossQuest) {
|
||||
bossNameView.text = quest.boss.name
|
||||
bossNameView.text = quest.boss?.name
|
||||
if (progress != null) {
|
||||
bossHealthView.set(progress.hp, quest.boss.hp.toDouble())
|
||||
bossHealthView.set(progress.hp, quest.boss?.hp?.toDouble() ?: 0.0)
|
||||
}
|
||||
if (quest.boss.hasRage()) {
|
||||
if (quest.boss?.hasRage() == true) {
|
||||
bossRageView.visibility = View.VISIBLE
|
||||
bossRageView.set(progress?.rage ?: 0.0, quest.boss.rage?.value ?: 0.0)
|
||||
bossRageView.set(progress?.rage ?: 0.0, quest.boss?.rage?.value ?: 0.0)
|
||||
} else {
|
||||
bossRageView.visibility = View.GONE
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,11 +71,11 @@ class QuestMenuView : LinearLayout {
|
|||
|
||||
fun configure(questContent: QuestContent) {
|
||||
this.questContent = questContent
|
||||
healthBarView.maxValue = questContent.boss.hp.toDouble()
|
||||
healthBarView.maxValue = questContent.boss?.hp?.toDouble() ?: 0.0
|
||||
bottomView.setBackgroundColor(questContent.colors?.darkColor ?: 0)
|
||||
bossArtView.setBackgroundColor(questContent.colors?.mediumColor ?: 0)
|
||||
DataBindingUtils.loadImage(bossArtView, "quest_"+questContent.key)
|
||||
bossNameView.text = questContent.boss.name
|
||||
bossNameView.text = questContent.boss?.name
|
||||
}
|
||||
|
||||
fun configure(user: User) {
|
||||
|
|
|
|||
|
|
@ -134,15 +134,15 @@ class QuestProgressView : LinearLayout {
|
|||
}
|
||||
collectionContainer.removeAllViews()
|
||||
if (quest.isBossQuest) {
|
||||
bossNameView.text = quest.boss.name
|
||||
bossNameView.text = quest.boss?.name
|
||||
bossNameView.visibility = View.VISIBLE
|
||||
bossHealthView.visibility = View.VISIBLE
|
||||
bossHealthView.set(progress.progress?.hp ?: 0.0, quest.boss?.hp?.toDouble() ?: 0.0)
|
||||
|
||||
if (quest.boss.hasRage()) {
|
||||
if (quest.boss?.hasRage() == true) {
|
||||
rageMeterView.visibility = View.VISIBLE
|
||||
bossRageView.visibility = View.VISIBLE
|
||||
rageMeterView.text = quest.boss.rage?.title
|
||||
rageMeterView.text = quest.boss?.rage?.title
|
||||
bossRageView.set(progress.progress?.rage ?: 0.0, quest.boss?.rage?.value ?: 0.0)
|
||||
if (progress.hasRageStrikes()) {
|
||||
setupRageStrikeViews()
|
||||
|
|
|
|||
Loading…
Reference in a new issue