Refactor conversations to state machine - minor bugfixes for "next" button disabling.

This commit is contained in:
Oskar Wiksten
2013-02-22 14:09:31 +01:00
parent 2da410118e
commit 9fd5508070
2 changed files with 12 additions and 10 deletions

View File

@@ -87,13 +87,15 @@ public final class Dialogs {
}
public static void addMonsterIdentifiers(Intent intent, Monster monster) {
addMonsterIdentifiers(intent.getExtras(), monster);
if (monster == null) return;
intent.putExtra("x", monster.position.x);
intent.putExtra("y", monster.position.y);
}
public static void addMonsterIdentifiers(Bundle bundle, Monster monster) {
if (monster == null) return;
bundle.putInt("x", monster.position.x);
bundle.putInt("y", monster.position.y);
}
if (monster == null) return;
bundle.putInt("x", monster.position.x);
bundle.putInt("y", monster.position.y);
}
public static Monster getMonsterFromIntent(Intent intent, final WorldContext world) {
return getMonsterFromBundle(intent.getExtras(), world);

View File

@@ -91,8 +91,9 @@ public final class ConversationActivity extends Activity implements OnKeyListene
nextButtonClicked();
}
});
nextButton.setEnabled(false);
statementList.setOnKeyListener(this);
statementList.setOnKeyListener(this);
statementList.setSelected(false);
statementList.setFocusable(false);
@@ -193,11 +194,12 @@ public final class ConversationActivity extends Activity implements OnKeyListene
}
private void nextButtonClicked() {
RadioButton rb = getSelectedReplyButton();
replyGroup.removeAllViews();
if (conversationState.hasOnlyOneNextReply()) {
nextButton.setEnabled(false);
if (conversationState.hasOnlyOneNextReply()) {
conversationState.playerSelectedNextStep();
} else {
RadioButton rb = getSelectedReplyButton();
if (rb == null) return;
Reply r = (Reply) rb.getTag();
addConversationStatement(player, rb.getText().toString());
@@ -391,7 +393,5 @@ public final class ConversationActivity extends Activity implements OnKeyListene
rb.setFocusable(false);
rb.setFocusableInTouchMode(false);
replyGroup.addView(rb, layoutParams);
nextButton.setEnabled(false);
}
}