mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-19 12:18:53 +07:00
First attempt at making Unciv Android-TV-compatible
This commit is contained in:
@ -6,12 +6,17 @@
|
||||
<uses-sdk/>
|
||||
|
||||
<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
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/uncivicon2"
|
||||
android:label="@string/app_name"
|
||||
android:isGame="true"
|
||||
android:appCategory="game"
|
||||
android:banner="@drawable/banner"
|
||||
android:theme="@style/GdxTheme" >
|
||||
<activity
|
||||
android:name="com.unciv.app.AndroidLauncher"
|
||||
@ -25,6 +30,19 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</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" />
|
||||
</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 java.io.File
|
||||
|
||||
class AndroidLauncher : AndroidApplication() {
|
||||
open class AndroidLauncher : AndroidApplication() {
|
||||
private var customSaveLocationHelper: CustomSaveLocationHelperAndroid? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -88,3 +88,5 @@ class AndroidLauncher : AndroidApplication() {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
}
|
||||
|
||||
class AndroidTvLauncher:AndroidLauncher()
|
@ -71,7 +71,6 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
private var backButtonListener: InputListener
|
||||
|
||||
|
||||
|
||||
init {
|
||||
topBar.setPosition(0f, stage.height - topBar.height)
|
||||
topBar.width = stage.width
|
||||
@ -147,14 +146,14 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
// isDaemon = true, in order to not block the app closing
|
||||
multiPlayerRefresher = Timer("multiPlayerRefresh", true).apply {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
tutorialController.allTutorialsShowedCallback = {
|
||||
shouldUpdate = true
|
||||
}
|
||||
tutorialController.allTutorialsShowedCallback = { shouldUpdate = true }
|
||||
|
||||
backButtonListener = onBackButtonClicked { backButtonAndESCHandler() }
|
||||
|
||||
@ -246,8 +245,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
if (gameInfo.isUpToDate && gameInfo.currentPlayer == latestGame.currentPlayer) {
|
||||
Gdx.app.postRunnable { loadingGamePopup.close() }
|
||||
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()
|
||||
|
||||
latestGame.isUpToDate = true
|
||||
@ -568,6 +566,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
nextTurnButton.isEnabled = !isSomethingOpen && isPlayersTurn && !waitingForAutosave
|
||||
nextTurnButton.setPosition(stage.width - nextTurnButton.width - 10f, topBar.y - nextTurnButton.height - 10f)
|
||||
}
|
||||
|
||||
fun enableNextTurnButtonAfterOptions() {
|
||||
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.row()
|
||||
promptWindow.addButton("Yes") { Gdx.app.exit() }
|
||||
promptWindow.addButton("No") {
|
||||
promptWindow.close()
|
||||
}
|
||||
promptWindow.addButton("No") { promptWindow.close() }
|
||||
// show the dialog
|
||||
promptWindow.open(true) // true = always on top
|
||||
}
|
||||
@ -706,4 +703,3 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
private var multiPlayerRefresher: Timer? = null
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user