Améliorations graphiques

This commit is contained in:
ynerant 2019-12-06 20:28:36 +01:00
parent 763eb69d93
commit c924564bf1
6 changed files with 35 additions and 29 deletions

View File

@ -7,8 +7,8 @@ android {
applicationId "fr.ynerant.tarot" applicationId "fr.ynerant.tarot"
minSdkVersion 24 minSdkVersion 24
targetSdkVersion 29 targetSdkVersion 29
versionCode 5 versionCode 6
versionName "0.2.1" versionName "0.2.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {

View File

@ -28,6 +28,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import fr.ynerant.tarot.ui.games.GameInfoFragment;
public class Game { public class Game {
private static final Gson GSON; private static final Gson GSON;
@SuppressLint("UseSparseArrays") @SuppressLint("UseSparseArrays")
@ -357,6 +359,12 @@ public class Game {
final List<Game> games = GSON.fromJson(new InputStreamReader(co.getInputStream()), new TypeToken<ArrayList<Game>>(){}.getType()); final List<Game> games = GSON.fromJson(new InputStreamReader(co.getInputStream()), new TypeToken<ArrayList<Game>>(){}.getType());
GAMES.clear(); GAMES.clear();
for (Player p : Player.getAllPlayers()) {
for (GameType type : GameType.values())
p.setScore(type, 0);
}
for (Game g : games) { for (Game g : games) {
GAMES.put(g.getId(), g); GAMES.put(g.getId(), g);
@ -395,16 +403,7 @@ public class Game {
if (g.player6 != null) if (g.player6 != null)
g.getMiseries().add(g.misery6); g.getMiseries().add(g.misery6);
g.points = new ArrayList<>(); g.calculateScores();
g.points.add(g.score1);
g.points.add(g.score2);
g.points.add(g.score3);
if (g.player4 != null)
g.points.add(g.score4);
if (g.player5 != null)
g.points.add(g.score5);
if (g.player6 != null)
g.points.add(g.score6);
for (Player p : g.getPlayers()) { for (Player p : g.getPlayers()) {
p.addScore(g.getGameType(), g.getPoints(p)); p.addScore(g.getGameType(), g.getPoints(p));

View File

@ -514,6 +514,22 @@ public class NewGameFragment extends Fragment {
co.disconnect(); co.disconnect();
Game.updateGames(); Game.updateGames();
MainActivity.INSTANCE.runOnUiThread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < 6; ++i) {
totalPoints[i].setText(String.valueOf(((Player) spinners[i].getSelectedItem()).getScore(Game.GameType.values()[nb_players.getProgress()])));
miseries[i].setChecked(false);
handles[i].setAlpha(1.0F);
handles[i].setText(R.string.handle0);
}
little_end.setProgress(0);
chelem_announced.setChecked(false);
chelem_realized.setChecked(false);
}
});
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
@ -545,17 +561,6 @@ public class NewGameFragment extends Fragment {
game.setMiseries(miseriesList); game.setMiseries(miseriesList);
game.calculateScores(); game.calculateScores();
for (int i = 0; i < game.getGameType().getNbPlayers(); ++i)
players.get(i).addScore(game.getGameType(), game.getPoints(players.get(i)));
MainActivity.INSTANCE.runOnUiThread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < 6; ++i)
totalPoints[i].setText(String.valueOf(((Player) spinners[i].getSelectedItem()).getScore(Game.GameType.values()[nb_players.getProgress()])));
}
});
return game; return game;
} }
}); });

View File

@ -21,7 +21,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:textAlignment="center"> android:textAlignment="center"
android:stretchColumns="0,1,2,3,4,5">
<TableRow <TableRow
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -597,10 +597,11 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TableLayout <TableLayout
android:layout_width="match_parent" android:layout_width="fill_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="horizontal"
android:textAlignment="center"> android:textAlignment="center"
android:stretchColumns="0,1,2,3,4,5">
<TableRow <TableRow
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -6,7 +6,8 @@
<TableLayout <TableLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:stretchColumns="0,1">
<TableRow> <TableRow>
<TextView <TextView
@ -19,8 +20,7 @@
android:id="@+id/points3" android:id="@+id/points3"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="18sp" android:textSize="18sp" />
android:textAlignment="textEnd"/>
</TableRow> </TableRow>
<TableRow> <TableRow>