Skip to content

Commit

Permalink
Merge pull request #152 from MidwayMarshall/legacy
Browse files Browse the repository at this point in the history
2.6.1
  • Loading branch information
MidwayMarshall committed Sep 24, 2015
2 parents 99d5b1f + 63f2c10 commit 477b47a
Show file tree
Hide file tree
Showing 8 changed files with 353 additions and 405 deletions.
10 changes: 9 additions & 1 deletion res/layout/player_info_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/player_info"></ListView>
android:layout_below="@+id/player_info">
</ListView>

<TextView
android:id="@+id/player_info"
Expand All @@ -35,4 +36,11 @@
android:text="@string/rearrange_team_description"
android:textSize="12sp" />

<TextView
android:id="@+id/chall_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/player_info"
android:textSize="12sp"/>

</RelativeLayout>
453 changes: 197 additions & 256 deletions res/layout/rearrange_team_dialog.xml

Large diffs are not rendered by default.

87 changes: 29 additions & 58 deletions src/com/podevs/android/poAndroid/battle/BattleActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,24 +307,24 @@ public void animateHpBarTo(final int i, final int goal) {

public void updateBattleInfo(boolean scroll) {
runOnUiThread(new Runnable() {
public void run() {
if (battle == null)
return;
synchronized (battle.histDelta) {
infoView.append(battle.histDelta);
if (battle.histDelta.length() != 0 || true) {
infoScroll.post(new Runnable() {
public void run() {
infoScroll.smoothScrollTo(0, infoView.getMeasuredHeight());
}
});
}
infoScroll.invalidate();
battle.hist.append(battle.histDelta);
battle.histDelta.clear();
}
}
});
public void run() {
if (battle == null)
return;
synchronized (battle.histDelta) {
infoView.append(battle.histDelta);
if (battle.histDelta.length() != 0 || true) {
infoScroll.post(new Runnable() {
public void run() {
infoScroll.smoothScrollTo(0, infoView.getMeasuredHeight());
}
});
}
infoScroll.invalidate();
battle.hist.append(battle.histDelta);
battle.histDelta.clear();
}
}
});
}

public void updatePokes(byte player) {
Expand Down Expand Up @@ -733,7 +733,7 @@ public boolean onLongClick(View view) {
.setTitle("Battle Chat")
.setMessage("Send Battle Message")
.setView(input)
.setPositiveButton("Send", new DialogInterface.OnClickListener() {
.setPositiveButton("Send", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface i, int j) {
String message = input.getText().toString();
if (message.length() > 0) {
Expand Down Expand Up @@ -972,21 +972,9 @@ protected Dialog onCreateDialog(final int id) {
switch(BattleDialog.values()[id]) {
case RearrangeTeam: {
View layout = inflater.inflate(R.layout.rearrange_team_dialog, (RelativeLayout) findViewById(R.id.rearrange_team_dialog));
final TextView nameAndType = (TextView) layout.findViewById(R.id.nameTypeView);
final TextView statNames = (TextView) layout.findViewById(R.id.statNamesView);
final TextView statNums = (TextView) layout.findViewById(R.id.statNumsView);
final TextView moves = (TextView) layout.findViewById(R.id.moveString);

String s = "HP:";
s += "\nAttack:";
s += "\nDefense:";
s += "\nSp. Att:";
s += "\nSp. Def:";
s += "\nSpeed:";
statNames.setText(s);

builder.setView(layout)
.setPositiveButton("Done", new DialogInterface.OnClickListener() {
.setPositiveButton(R.string.done, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
netServ.socket.sendMessage(activeBattle.constructRearrange(), Command.BattleMessage);
battle.shouldShowPreview = false;
Expand All @@ -997,19 +985,6 @@ public void onClick(DialogInterface dialog, int which) {
dialog = builder.create();

mDragLayer = (DragLayer)layout.findViewById(R.id.drag_my_poke);
mDragLayer.addDragListener(new DragController.DragListener() {
@Override
public void onDragStart(View v, DragSource source, Object info, int dragAction) {

}

@Override
public void onDragEnd() {
nameAndType.setText(activeBattle.myTeam.pokes[0].nameAndType());
statNums.setText(activeBattle.myTeam.pokes[0].printStats());
moves.setText(activeBattle.myTeam.pokes[0].movesString());
}
});

for(int i = 0; i < 6; i++){
BattlePoke poke = activeBattle.myTeam.pokes[i];
Expand All @@ -1022,22 +997,18 @@ public void onDragEnd() {
ShallowShownPoke oppPoke = activeBattle.oppTeam.pokes[i];
oppArrangePokeIcons[i] = (ImageView)layout.findViewById(resources.getIdentifier("foe_arrange_poke" + (i+1), "id", InfoConfig.pkgName));
oppArrangePokeIcons[i].setImageDrawable(PokemonInfo.iconDrawableCache(oppPoke.uID));

nameAndType.setText(activeBattle.myTeam.pokes[0].nameAndType());
statNums.setText(activeBattle.myTeam.pokes[0].printStats());
moves.setText(activeBattle.myTeam.pokes[0].movesString());
}
return dialog;
}
case ConfirmForfeit:
builder.setMessage("Really Forfeit?")
.setCancelable(true)
.setPositiveButton("Forfeit", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
endBattle();
}
})
.setNegativeButton("Cancel", null);
public void onClick(DialogInterface dialog, int which) {
endBattle();
}
})
.setNegativeButton(R.string.cancel, null);
return builder.create();
case OppDynamicInfo:
player = opp;
Expand Down Expand Up @@ -1086,10 +1057,10 @@ public void onClick(View v) {
dialog = builder.setTitle(lastClickedMove.toString())
.setMessage(lastClickedMove.descAndEffects())
.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
removeDialog(id);
}
})
public void onCancel(DialogInterface dialog) {
removeDialog(id);
}
})
.create();
dialog.setCanceledOnTouchOutside(true);
return dialog;
Expand Down
17 changes: 17 additions & 0 deletions src/com/podevs/android/poAndroid/battle/ChallengeEnums.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.podevs.android.poAndroid.battle;

import android.util.Log;

public class ChallengeEnums {
public enum ChallengeDesc
{
Expand Down Expand Up @@ -59,4 +61,19 @@ public enum Mode
Triples,
Rotation,
};

public static String clausesToStringHtml(int clauses) {
String s = "";
for (int i = 0; i < Clauses.values().length; i++) {
//String clauseNumber = Integer.toBinaryString(1 << i);
//String clausesID = Integer.toBinaryString(clauses);
//Log.e("Clauses", "" + clauseNumber);
//Log.e("Clauses", "" + clausesID);
if ((clauses & (1 << i)) > 0 ? true : false) {
//Log.e("Clauses", "true");
s += "<br />" + Clauses.values()[i].toString();
}
}
return s;
}
}
12 changes: 10 additions & 2 deletions src/com/podevs/android/poAndroid/chat/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.widget.*;
import android.widget.AdapterView.OnItemClickListener;
import com.podevs.android.poAndroid.*;
import com.podevs.android.poAndroid.battle.ChallengeEnums;
import com.podevs.android.poAndroid.battle.ChallengeEnums.ChallengeDesc;
import com.podevs.android.poAndroid.battle.ChallengeEnums.Clauses;
import com.podevs.android.poAndroid.battle.ChallengeEnums.Mode;
Expand Down Expand Up @@ -520,15 +521,15 @@ protected Dialog onCreateDialog(final int id) {
return null;
}
final IncomingChallenge challenge = netServ.challenges.poll();
View challengedLayout = inflater.inflate(R.layout.player_info_dialog, (LinearLayout)findViewById(R.id.player_info_dialog));
View challengedLayout = inflater.inflate(R.layout.player_info_dialog, (RelativeLayout) findViewById(R.id.player_info_dialog));
PlayerInfo opp = netServ.players.get(challenge.opponent);

/* Like when activity resumed after a long time */
if (opp == null) {
return null;
}

TextView oppInfo, oppName;
TextView oppInfo, oppName, challInfo;
builder.setView(challengedLayout)
.setCancelable(false)
.setNegativeButton(this.getString(R.string.decline), new DialogInterface.OnClickListener() {
Expand Down Expand Up @@ -575,6 +576,13 @@ public void onClick(DialogInterface dialog, int which) {
oppInfo = (TextView)challengedLayout.findViewById(getResources().getIdentifier("player_info", "id", packName));
oppInfo.setText(Html.fromHtml("<b>Info: </b>" + StringUtilities.escapeHtml(opp.info())));

challInfo = (TextView) challengedLayout.findViewById(R.id.chall_info);
challInfo.setText(Html.fromHtml(
"<b>Their Tier: </b>" + challenge.srcTier + "<br />" +
"<b>Your Tier: </b>" + challenge.destTier + "<br />" +
"<b>Clauses: </b> " + ChallengeEnums.clausesToStringHtml(challenge.clauses)));
challInfo.setGravity(Gravity.CENTER_HORIZONTAL);

oppName = (TextView)challengedLayout.findViewById(getResources().getIdentifier("player_info_name", "id", packName));
oppName.setText(this.getString(R.string.accept_challenge) + " " + opp.nick() + "?");
oppName.setTextSize(18);
Expand Down
10 changes: 5 additions & 5 deletions src/com/podevs/android/poAndroid/pms/PrivateMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import com.podevs.android.utilities.StringUtilities;

import java.util.LinkedList;

/**
* Data containing the information of a private message
*
*/
public class PrivateMessage {
PrivateMessageListener listener;
protected ListView privateList;
LinkedList<Message> messages = new LinkedList<PrivateMessage.Message>();
PlayerInfo me, other;
protected ListView privateList = null;

public PrivateMessage(PlayerInfo other, PlayerInfo me) {
this.other = other;
Expand All @@ -29,7 +32,7 @@ public void addMessage(PlayerInfo info, String message, Boolean timeStamp) {
}
messages.add(new Message(info, message));
if (listener != null) {
listener.onNewMessage(messages.getLast());
listener.onNewMessage(messages.getLast());
}
}
}
Expand All @@ -52,9 +55,6 @@ public Message(PlayerInfo info, String message) {
String message;
}

LinkedList<Message> messages = new LinkedList<PrivateMessage.Message>();
PlayerInfo me, other;

interface PrivateMessageListener {
void onNewMessage(Message message);
}
Expand Down
Loading

0 comments on commit 477b47a

Please sign in to comment.