diff --git a/AndorsTrail/res/values/strings.xml b/AndorsTrail/res/values/strings.xml
index 8beb3ed95..c425ad6c9 100644
--- a/AndorsTrail/res/values/strings.xml
+++ b/AndorsTrail/res/values/strings.xml
@@ -563,5 +563,7 @@
Re-equip cost (AP):
Use item cost (AP):
Combat log
+ [Quest completed: \"%1$s\"]
+ [Quest updated: \"%1$s\"]
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java
index 781b6b5e7..0d6289d87 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java
@@ -29,6 +29,9 @@ import com.gpl.rpg.AndorsTrail.model.actor.Actor;
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
import com.gpl.rpg.AndorsTrail.model.actor.Player;
import com.gpl.rpg.AndorsTrail.model.item.Loot;
+import com.gpl.rpg.AndorsTrail.model.quest.Quest;
+import com.gpl.rpg.AndorsTrail.model.quest.QuestLogEntry;
+import com.gpl.rpg.AndorsTrail.model.quest.QuestProgress;
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
import java.util.ArrayList;
@@ -37,9 +40,13 @@ public final class ConversationActivity extends Activity implements OnKeyListene
, ConversationController.ConversationStatemachine.ConversationStateListener {
public static final int ACTIVITYRESULT_ATTACK = Activity.RESULT_FIRST_USER + 1;
public static final int ACTIVITYRESULT_REMOVE = Activity.RESULT_FIRST_USER + 2;
- private static final int playerConversationColor = Color.argb(255, 0xbb, 0x22, 0x22);
- private static final int NPCConversationColor = Color.argb(255, 0xbb, 0xbb, 0x22);
-
+ private static final int playerNameColor = Color.argb(255, 0xbb, 0x22, 0x22);
+ private static final int NPCNameColor = Color.argb(255, 0xbb, 0xbb, 0x22);
+ private static final int playerPhraseColor = 0;
+ private static final int NPCPhraseColor = 0;
+ private static final int rewardColor = Color.argb(255, 0x99, 0x99, 0x55);
+
+ private WorldContext world;
private Player player;
private ArrayList conversationHistory = new ArrayList();
private ConversationController.ConversationStatemachine conversationState;
@@ -55,7 +62,7 @@ public final class ConversationActivity extends Activity implements OnKeyListene
super.onCreate(savedInstanceState);
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
if (!app.isInitialized()) { finish(); return; }
- WorldContext world = app.getWorld();
+ this.world = app.getWorld();
this.player = world.model.player;
this.conversationState = new ConversationController.ConversationStatemachine(world, app.getControllerContext(), getResources(), this);
@@ -202,12 +209,12 @@ public final class ConversationActivity extends Activity implements OnKeyListene
} else {
if (rb == null) return;
Reply r = (Reply) rb.getTag();
- addConversationStatement(player, rb.getText().toString());
+ addConversationStatement(player, rb.getText().toString(), playerPhraseColor);
conversationState.playerSelectedReply(r);
}
}
- private void addConversationStatement(Actor actor, String text) {
+ private void addConversationStatement(Actor actor, String text, int textColor) {
ConversationStatement s = new ConversationStatement();
if (actor != null) {
s.iconID = actor.iconID;
@@ -216,7 +223,8 @@ public final class ConversationActivity extends Activity implements OnKeyListene
s.iconID = ConversationStatement.NO_ICON;
}
s.text = text;
- s.color = actor == player ? playerConversationColor : NPCConversationColor;
+ s.nameColor = actor == player ? playerNameColor : NPCNameColor;
+ s.textColor = textColor;
s.isPlayerActor = actor != null && actor == player;
conversationHistory.add(s);
statementList.clearFocus();
@@ -237,7 +245,8 @@ public final class ConversationActivity extends Activity implements OnKeyListene
public String actorName;
public String text;
public int iconID;
- public int color;
+ public int nameColor;
+ public int textColor;
public boolean isPlayerActor;
public boolean hasActor() {
@@ -252,7 +261,8 @@ public final class ConversationActivity extends Activity implements OnKeyListene
dest.writeString(actorName);
dest.writeString(text);
dest.writeInt(iconID);
- dest.writeInt(color);
+ dest.writeInt(nameColor);
+ dest.writeInt(textColor);
dest.writeByte((byte) (isPlayerActor ? 1 : 0));
}
@@ -263,7 +273,8 @@ public final class ConversationActivity extends Activity implements OnKeyListene
result.actorName = in.readString();
result.text = in.readString();
result.iconID = in.readInt();
- result.color = in.readInt();
+ result.nameColor = in.readInt();
+ result.textColor = in.readInt();
result.isPlayerActor = in.readByte() == 1;
return result;
}
@@ -299,10 +310,19 @@ public final class ConversationActivity extends Activity implements OnKeyListene
tv.setText(statement.actorName + ": " + statement.text, BufferType.SPANNABLE);
Spannable sp = (Spannable) tv.getText();
- sp.setSpan(new ForegroundColorSpan(statement.color), 0, statement.actorName.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ sp.setSpan(new ForegroundColorSpan(statement.nameColor), 0, statement.actorName.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ if (statement.textColor != 0) {
+ sp.setSpan(new ForegroundColorSpan(statement.textColor), statement.actorName.length()+1, sp.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
} else {
tv.setCompoundDrawables(null, null, null, null);
- tv.setText(statement.text);
+ if (statement.textColor == 0) {
+ tv.setText(statement.text);
+ } else {
+ tv.setText(statement.text, BufferType.SPANNABLE);
+ Spannable sp = (Spannable) tv.getText();
+ sp.setSpan(new ForegroundColorSpan(statement.textColor), 0, statement.text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
}
return result;
@@ -321,14 +341,23 @@ public final class ConversationActivity extends Activity implements OnKeyListene
@Override
public void onTextPhraseReached(String message, Actor actor) {
- addConversationStatement(actor, message);
+ addConversationStatement(actor, message, NPCPhraseColor);
}
@Override
public void onPlayerReceivedRewards(ConversationController.PhraseRewards phraseRewards) {
Loot loot = phraseRewards.loot;
- if (!loot.hasItemsOrExp()) return;
+ for (QuestProgress reward : phraseRewards.questProgress) {
+ Quest q = world.quests.getQuest(reward.questID);
+ if (!q.showInLog) continue;
+ QuestLogEntry logEntry = q.getQuestLogEntry(reward.progress);
+ if (logEntry.finishesQuest) {
+ addRewardMessage(getString(R.string.conversation_reward_quest_finished, q.name));
+ } else {
+ addRewardMessage(getString(R.string.conversation_reward_quest_updated, q.name));
+ }
+ }
if (loot.exp > 0) {
addRewardMessage(getString(R.string.conversation_rewardexp, loot.exp));
}
@@ -348,7 +377,7 @@ public final class ConversationActivity extends Activity implements OnKeyListene
}
private void addRewardMessage(String text) {
- addConversationStatement(null, text);
+ addConversationStatement(null, text, rewardColor);
}
@Override
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/quest/Quest.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/quest/Quest.java
index d58bd6b70..64a3dc9a8 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/quest/Quest.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/quest/Quest.java
@@ -1,6 +1,8 @@
package com.gpl.rpg.AndorsTrail.model.quest;
+import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
import com.gpl.rpg.AndorsTrail.model.actor.Player;
+import com.gpl.rpg.AndorsTrail.util.L;
public final class Quest implements Comparable {
public final String questID;
@@ -16,7 +18,17 @@ public final class Quest implements Comparable {
this.showInLog = showInLog;
this.sortOrder = sortOrder;
}
-
+
+ public QuestLogEntry getQuestLogEntry(final int progress) {
+ for (QuestLogEntry s : stages) {
+ if (s.progress == progress) return s;
+ }
+ if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
+ L.log("WARNING: Cannot find stage " + progress + " in quest \"" + questID + "\".");
+ }
+ return null;
+ }
+
public boolean isCompleted(final Player player) {
for (QuestLogEntry e : stages) {
if (!e.finishesQuest) continue;
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/quest/QuestCollection.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/quest/QuestCollection.java
index 55d4fff60..aafb2639a 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/quest/QuestCollection.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/quest/QuestCollection.java
@@ -21,16 +21,9 @@ public final class QuestCollection {
public QuestLogEntry getQuestLogEntry(final QuestProgress stage) {
Quest q = getQuest(stage.questID);
if (q == null) return null;
-
- for (QuestLogEntry s : q.stages) {
- if (s.progress == stage.progress) return s;
- }
- if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
- L.log("WARNING: Cannot find stage " + stage.progress + " in quest \"" + stage.questID + "\".");
- }
- return null;
+ return q.getQuestLogEntry(stage.progress);
}
-
+
public Quest getQuest(final String questID) {
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
if (!quests.containsKey(questID)) {