From 31dc4f7ba8218c6dcecc995c78a3606ff3804c9c Mon Sep 17 00:00:00 2001 From: LucasDelvallet Date: Thu, 26 Feb 2015 13:19:26 +0100 Subject: [PATCH] Improved greyAllConvervationStatement I've improved this method, now reward text have they own color when greyed and it only iterate text that not have been greyed yet. --- .../activity/ConversationActivity.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java index dbeb0c423..7b6437b12 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java @@ -35,6 +35,7 @@ import com.gpl.rpg.AndorsTrail.model.quest.QuestProgress; import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager; import java.util.ArrayList; +import java.util.ListIterator; public final class ConversationActivity extends Activity @@ -49,11 +50,13 @@ public final class ConversationActivity private static final int oldPhraseColor = Color.argb(255,0x5a,0x5a, 0x5a); private static final int oldPlayerNameColor = Color.argb(255, 0x5d, 0x11, 0x11); private static final int oldNPCNameColor = Color.argb(255, 0x5d, 0x5d, 0x11); + private static final int oldRewardColor = Color.argb(255, 0x4C, 0x4C, 0x2A); private WorldContext world; private Player player; private final ArrayList conversationHistory = new ArrayList(); private ConversationController.ConversationStatemachine conversationState; + private int numberOfNewMessage = 0; private StatementContainerAdapter listAdapter; private Button nextButton; @@ -210,12 +213,19 @@ public final class ConversationActivity } private void greyAllConversationStatement(){ - for(ConversationStatement conversation : this.conversationHistory ){ - conversation.textColor = oldPhraseColor; - if(conversation.isPlayerActor){ - conversation.nameColor = oldPlayerNameColor; - } else { - conversation.nameColor = oldNPCNameColor; + int numberOfMessage = this.conversationHistory.size(); + ListIterator conversations = this.conversationHistory.listIterator(numberOfMessage-this.numberOfNewMessage); + while(conversations.hasNext()){ + ConversationStatement conversation = conversations.next(); + if(conversation.hasActor()){ + conversation.textColor = oldPhraseColor; + if(conversation.isPlayerActor){ + conversation.nameColor = oldPlayerNameColor; + } else { + conversation.nameColor = oldNPCNameColor; + } + }else{ + conversation.textColor = oldRewardColor; } } } @@ -248,6 +258,7 @@ public final class ConversationActivity s.textColor = textColor; s.isPlayerActor = actor != null && actor == player; conversationHistory.add(s); + numberOfNewMessage++; statementList.clearFocus(); listAdapter.notifyDataSetChanged(); statementList.requestLayout();