mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 15:01:09 -04:00
First attempt at making Unciv Android-TV-compatible
This commit is contained in:
parent
07cee7e679
commit
0feb9bdefc
@ -6,12 +6,17 @@
|
|||||||
<uses-sdk/>
|
<uses-sdk/>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<!-- See https://developer.android.com/training/tv/start/start -->
|
||||||
|
<uses-feature android:name="android.software.leanback" android:required="false" />
|
||||||
|
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@drawable/uncivicon2"
|
android:icon="@drawable/uncivicon2"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:isGame="true"
|
android:isGame="true"
|
||||||
|
android:appCategory="game"
|
||||||
|
android:banner="@drawable/banner"
|
||||||
android:theme="@style/GdxTheme" >
|
android:theme="@style/GdxTheme" >
|
||||||
<activity
|
<activity
|
||||||
android:name="com.unciv.app.AndroidLauncher"
|
android:name="com.unciv.app.AndroidLauncher"
|
||||||
@ -25,6 +30,19 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="com.unciv.app.AndroidTvLauncher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/GdxTheme">
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
</activity>
|
||||||
<receiver android:name=".CopyToClipboardReceiver" android:exported="false" />
|
<receiver android:name=".CopyToClipboardReceiver" android:exported="false" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
BIN
android/res/drawable-xhdpi/banner.png
Normal file
BIN
android/res/drawable-xhdpi/banner.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
@ -13,7 +13,7 @@ import com.unciv.logic.GameSaver
|
|||||||
import com.unciv.ui.utils.ORIGINAL_FONT_SIZE
|
import com.unciv.ui.utils.ORIGINAL_FONT_SIZE
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class AndroidLauncher : AndroidApplication() {
|
open class AndroidLauncher : AndroidApplication() {
|
||||||
private var customSaveLocationHelper: CustomSaveLocationHelperAndroid? = null
|
private var customSaveLocationHelper: CustomSaveLocationHelperAndroid? = null
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@ -88,3 +88,5 @@ class AndroidLauncher : AndroidApplication() {
|
|||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AndroidTvLauncher:AndroidLauncher()
|
@ -71,7 +71,6 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
private var backButtonListener: InputListener
|
private var backButtonListener: InputListener
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
topBar.setPosition(0f, stage.height - topBar.height)
|
topBar.setPosition(0f, stage.height - topBar.height)
|
||||||
topBar.width = stage.width
|
topBar.width = stage.width
|
||||||
@ -147,14 +146,14 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
// isDaemon = true, in order to not block the app closing
|
// isDaemon = true, in order to not block the app closing
|
||||||
multiPlayerRefresher = Timer("multiPlayerRefresh", true).apply {
|
multiPlayerRefresher = Timer("multiPlayerRefresh", true).apply {
|
||||||
schedule(object : TimerTask() { //todo maybe not use timer for web request, from timer docs "Timer tasks should complete quickly."
|
schedule(object : TimerTask() { //todo maybe not use timer for web request, from timer docs "Timer tasks should complete quickly."
|
||||||
override fun run() { loadLatestMultiplayerState() }
|
override fun run() {
|
||||||
|
loadLatestMultiplayerState()
|
||||||
|
}
|
||||||
}, 0, 10000) // 10 seconds
|
}, 0, 10000) // 10 seconds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tutorialController.allTutorialsShowedCallback = {
|
tutorialController.allTutorialsShowedCallback = { shouldUpdate = true }
|
||||||
shouldUpdate = true
|
|
||||||
}
|
|
||||||
|
|
||||||
backButtonListener = onBackButtonClicked { backButtonAndESCHandler() }
|
backButtonListener = onBackButtonClicked { backButtonAndESCHandler() }
|
||||||
|
|
||||||
@ -246,8 +245,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
if (gameInfo.isUpToDate && gameInfo.currentPlayer == latestGame.currentPlayer) {
|
if (gameInfo.isUpToDate && gameInfo.currentPlayer == latestGame.currentPlayer) {
|
||||||
Gdx.app.postRunnable { loadingGamePopup.close() }
|
Gdx.app.postRunnable { loadingGamePopup.close() }
|
||||||
return
|
return
|
||||||
}
|
} else { //else we found it is the player's turn again, turn off polling and load turn
|
||||||
else{ //else we found it is the player's turn again, turn off polling and load turn
|
|
||||||
stopMultiPlayerRefresher()
|
stopMultiPlayerRefresher()
|
||||||
|
|
||||||
latestGame.isUpToDate = true
|
latestGame.isUpToDate = true
|
||||||
@ -568,6 +566,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
nextTurnButton.isEnabled = !isSomethingOpen && isPlayersTurn && !waitingForAutosave
|
nextTurnButton.isEnabled = !isSomethingOpen && isPlayersTurn && !waitingForAutosave
|
||||||
nextTurnButton.setPosition(stage.width - nextTurnButton.width - 10f, topBar.y - nextTurnButton.height - 10f)
|
nextTurnButton.setPosition(stage.width - nextTurnButton.width - 10f, topBar.y - nextTurnButton.height - 10f)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun enableNextTurnButtonAfterOptions() {
|
fun enableNextTurnButtonAfterOptions() {
|
||||||
nextTurnButton.isEnabled = isPlayersTurn && !waitingForAutosave
|
nextTurnButton.isEnabled = isPlayersTurn && !waitingForAutosave
|
||||||
}
|
}
|
||||||
@ -693,9 +692,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
promptWindow.addGoodSizedLabel("Do you want to exit the game?".tr())
|
promptWindow.addGoodSizedLabel("Do you want to exit the game?".tr())
|
||||||
promptWindow.row()
|
promptWindow.row()
|
||||||
promptWindow.addButton("Yes") { Gdx.app.exit() }
|
promptWindow.addButton("Yes") { Gdx.app.exit() }
|
||||||
promptWindow.addButton("No") {
|
promptWindow.addButton("No") { promptWindow.close() }
|
||||||
promptWindow.close()
|
|
||||||
}
|
|
||||||
// show the dialog
|
// show the dialog
|
||||||
promptWindow.open(true) // true = always on top
|
promptWindow.open(true) // true = always on top
|
||||||
}
|
}
|
||||||
@ -706,4 +703,3 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
private var multiPlayerRefresher: Timer? = null
|
private var multiPlayerRefresher: Timer? = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user