It starts to look like something
This commit is contained in:
parent
f804af8b9d
commit
09c7fef71c
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -8,7 +8,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
android:theme="@style/Theme.AppCompat">
|
||||
<activity android:name=".MainActivity"
|
||||
android:screenOrientation="landscape">
|
||||
<intent-filter>
|
||||
|
@ -16,7 +16,7 @@ class Dialog : DialogFragment() {
|
||||
.setPositiveButton(R.string.go, DialogInterface.OnClickListener { dialog, id ->
|
||||
// FIRE ZE MISSILES!
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, DialogInterface.OnClickListener { dialog, id ->
|
||||
.setNegativeButton(R.string.quit, DialogInterface.OnClickListener { dialog, id ->
|
||||
// User cancelled the dialog
|
||||
})
|
||||
.setView(view)
|
||||
|
@ -2,19 +2,94 @@ package adrienmalin.pingpoints
|
||||
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
var players: Array<Player> = arrayOf(
|
||||
Player(),
|
||||
Player()
|
||||
)
|
||||
var server: Int = 0
|
||||
var notServer: Int = 1
|
||||
|
||||
var buttonPlayers: Array<Button> = emptyArray()
|
||||
var serviceTexts: Array<Array<String>> = arrayOf(
|
||||
arrayOf("""_o/°""", ""),
|
||||
arrayOf("", """°\o_""")
|
||||
)
|
||||
|
||||
var textScore: android.widget.TextView? = null
|
||||
var textService: android.widget.TextView? = null
|
||||
var stringScore:String = ""
|
||||
var stringService:String = ""
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
val names: Array<String> = resources.getStringArray(R.array.players_names)
|
||||
for ((player, name) in players.zip(names)) {
|
||||
player.name = name
|
||||
}
|
||||
|
||||
textScore = findViewById(R.id.textScore)
|
||||
textService = findViewById(R.id.textService)
|
||||
|
||||
stringScore = getString(R.string.score)
|
||||
stringService = getString(R.string.service)
|
||||
|
||||
|
||||
buttonPlayers = arrayOf(
|
||||
findViewById(R.id.buttonPlayer1),
|
||||
findViewById(R.id.buttonPlayer2)
|
||||
)
|
||||
|
||||
update_ui()
|
||||
}
|
||||
|
||||
fun updateScore(scoringPlayerId: Int) {
|
||||
players[scoringPlayerId].score ++
|
||||
|
||||
val joueurs: Array<Joueur> = arrayOf(Joueur(getString(R.string.nom_joueur_1)), Joueur(getString(R.string.nom_joueur_2)))
|
||||
val serveur: Int? = null
|
||||
if (players.sumBy { it.score } % 2 == 0) {
|
||||
server = notServer.also { notServer = server }
|
||||
}
|
||||
|
||||
update_ui()
|
||||
}
|
||||
|
||||
fun onClickPlayer1(view: View) {
|
||||
updateScore(0)
|
||||
}
|
||||
|
||||
fun onClickPlayer2(view: View) {
|
||||
updateScore(1)
|
||||
}
|
||||
|
||||
fun update_ui(){
|
||||
|
||||
textScore?.text = "$stringScore ${players[server].score} - ${players[notServer].score}"
|
||||
|
||||
textService?.text = "$stringService ${players[server].name}"
|
||||
|
||||
for ((player, serviceText) in players.zip(serviceTexts[server])) {
|
||||
player.serviceText = serviceText
|
||||
}
|
||||
|
||||
for ((button, player) in buttonPlayers.zip(players)) {
|
||||
button.text = """
|
||||
|${player.name}
|
||||
|${player.score}
|
||||
|${player.serviceText}""".trimMargin()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Joueur(nom: String, score: Int = 0)
|
||||
class Player(
|
||||
var name: String = "",
|
||||
var score: Int = 0,
|
||||
var serviceText: String = ""
|
||||
)
|
@ -7,84 +7,113 @@
|
||||
tools:context=".MainActivity"
|
||||
tools:layout_editor_absoluteY="73dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="R.strings.info"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textService"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textService"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="R.strings.service"
|
||||
android:text="@string/service"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Large"
|
||||
app:layout_constraintBottom_toTopOf="@+id/linearLayout"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView2" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonJoueur1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Button"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textScore"
|
||||
app:layout_constraintEnd_toStartOf="@+id/buttonJoueur2"
|
||||
app:layout_constraintHorizontal_chainStyle="spread_inside"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textService" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonJoueur2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Button"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textScore"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/buttonJoueur1"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textService" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/textScore" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textScore"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="TextView"
|
||||
android:text="@string/score"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Large"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="18dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/info"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/buttonJoueur1" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/textService">
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonPlayer1"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_weight="1"
|
||||
android:onClick="onClickPlayer1"
|
||||
android:text="Button"
|
||||
android:textAllCaps="false"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textScore"
|
||||
app:layout_constraintEnd_toStartOf="@+id/buttonPlayer2"
|
||||
app:layout_constraintHorizontal_chainStyle="spread_inside"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textService" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonPlayer2"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_weight="1"
|
||||
android:onClick="onClickPlayer2"
|
||||
android:text="Button"
|
||||
android:textAllCaps="false"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textScore"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/buttonPlayer1"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textService" />
|
||||
</LinearLayout>
|
||||
</android.support.constraint.ConstraintLayout>
|
15
app/src/main/res/values-fr/strings.xml
Normal file
15
app/src/main/res/values-fr/strings.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Ping Points</string>
|
||||
<string name="go">Allons-y !</string>
|
||||
<string name="dialog_title">Nouvelle partie</string>
|
||||
<string name="dialog_message">Qui commence ?</string>
|
||||
<string name="info">Cliquez sur le joueur qui a marqué</string>
|
||||
<string name="service">Service :</string>
|
||||
<string name="score">Score :</string>
|
||||
<string name="quit">Quitter</string>
|
||||
<string-array name="players_names">
|
||||
<item>Joueur 1</item>
|
||||
<item>Joueur 2</item>
|
||||
</string-array>
|
||||
</resources>
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimary">#3f51b5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
</resources>
|
||||
|
@ -1,12 +1,14 @@
|
||||
<resources>
|
||||
<string name="app_name">Ping Points</string>
|
||||
<string name="go">Allons-y !</string>
|
||||
<string name="cancel">Annuler</string>
|
||||
<string name="dialog_title">Nouvelle partie</string>
|
||||
<string name="dialog_message">Qui commence ?</string>
|
||||
<string name="nom_joueur_1">Joueur 1</string>
|
||||
<string name="nom_joueur_2">Joueur 2</string>
|
||||
<string name="info">Cliquez sur le joueur qui a marqué</string>
|
||||
<string name="service">Service</string>
|
||||
<string name="score">Score</string>
|
||||
<string name="go">Play</string>
|
||||
<string name="quit">Quit</string>
|
||||
<string name="dialog_title">New match</string>
|
||||
<string name="dialog_message">Who starts?</string>
|
||||
<string name="info">Click on the scoring player</string>
|
||||
<string name="service">Service:</string>
|
||||
<string name="score">Score:</string>
|
||||
<string-array name="players_names">
|
||||
<item>Player 1</item>
|
||||
<item>Player 2</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user