mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-01 02:15:07 +01:00
Use per-game settings during emulation
This commit is contained in:
parent
1a11aaa651
commit
2f4778247c
@ -73,7 +73,9 @@ class AppDialog : BottomSheetDialogFragment() {
|
|||||||
|
|
||||||
binding.gamePlay.isEnabled = item.loaderResult == LoaderResult.Success
|
binding.gamePlay.isEnabled = item.loaderResult == LoaderResult.Success
|
||||||
binding.gamePlay.setOnClickListener {
|
binding.gamePlay.setOnClickListener {
|
||||||
startActivity(Intent(activity, EmulationActivity::class.java).apply { data = item.uri })
|
startActivity(Intent(activity, EmulationActivity::class.java).apply {
|
||||||
|
putExtras(requireArguments())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.gameSettings.isEnabled = item.loaderResult == LoaderResult.Success
|
binding.gameSettings.isEnabled = item.loaderResult == LoaderResult.Success
|
||||||
|
@ -26,8 +26,10 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import emu.skyline.applet.swkbd.SoftwareKeyboardConfig
|
import emu.skyline.applet.swkbd.SoftwareKeyboardConfig
|
||||||
import emu.skyline.applet.swkbd.SoftwareKeyboardDialog
|
import emu.skyline.applet.swkbd.SoftwareKeyboardDialog
|
||||||
|
import emu.skyline.data.AppItem
|
||||||
import emu.skyline.databinding.EmuActivityBinding
|
import emu.skyline.databinding.EmuActivityBinding
|
||||||
import emu.skyline.input.*
|
import emu.skyline.input.*
|
||||||
|
import emu.skyline.loader.RomFile
|
||||||
import emu.skyline.loader.getRomFormat
|
import emu.skyline.loader.getRomFormat
|
||||||
import emu.skyline.settings.AppSettings
|
import emu.skyline.settings.AppSettings
|
||||||
import emu.skyline.settings.EmulationSettings
|
import emu.skyline.settings.EmulationSettings
|
||||||
@ -54,6 +56,11 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
|
|
||||||
private val binding by lazy { EmuActivityBinding.inflate(layoutInflater) }
|
private val binding by lazy { EmuActivityBinding.inflate(layoutInflater) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The [AppItem] of the app that is being emulated
|
||||||
|
*/
|
||||||
|
lateinit var item : AppItem
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map of [Vibrator]s that correspond to [InputManager.controllers]
|
* A map of [Vibrator]s that correspond to [InputManager.controllers]
|
||||||
*/
|
*/
|
||||||
@ -191,8 +198,8 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
shouldFinish = true
|
shouldFinish = true
|
||||||
returnToMain = intent.getBooleanExtra(ReturnToMainTag, false)
|
returnToMain = intent.getBooleanExtra(ReturnToMainTag, false)
|
||||||
|
|
||||||
val rom = intent.data!!
|
val rom = item.uri
|
||||||
val romType = getRomFormat(rom, contentResolver).ordinal
|
val romType = item.format.ordinal
|
||||||
|
|
||||||
@SuppressLint("Recycle")
|
@SuppressLint("Recycle")
|
||||||
val romFd = contentResolver.openFileDescriptor(rom, "r")!!
|
val romFd = contentResolver.openFileDescriptor(rom, "r")!!
|
||||||
@ -206,10 +213,29 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
|
|||||||
emulationThread!!.start()
|
emulationThread!!.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates the [item] member with data from the intent
|
||||||
|
*/
|
||||||
|
private fun populateAppItem() {
|
||||||
|
val intentItem = intent.getSerializableExtra("item") as AppItem?
|
||||||
|
if (intentItem != null) {
|
||||||
|
item = intentItem
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// The intent did not contain an app item, fall back to the data URI
|
||||||
|
val uri = intent.data!!
|
||||||
|
val romFormat = getRomFormat(uri, contentResolver)
|
||||||
|
val romFile = RomFile(this, romFormat, uri, EmulationSettings.global.systemLanguage)
|
||||||
|
|
||||||
|
item = AppItem(romFile.takeIf { it.valid }!!.appEntry)
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n", "ClickableViewAccessibility")
|
@SuppressLint("SetTextI18n", "ClickableViewAccessibility")
|
||||||
override fun onCreate(savedInstanceState : Bundle?) {
|
override fun onCreate(savedInstanceState : Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
emulationSettings = EmulationSettings.global
|
populateAppItem()
|
||||||
|
emulationSettings = EmulationSettings.forEmulation(item.titleId ?: item.key())
|
||||||
|
|
||||||
requestedOrientation = emulationSettings.orientation
|
requestedOrientation = emulationSettings.orientation
|
||||||
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
||||||
|
@ -286,7 +286,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (appSettings.selectAction) {
|
if (appSettings.selectAction) {
|
||||||
AppDialog.newInstance(appItem).show(supportFragmentManager, "game")
|
AppDialog.newInstance(appItem).show(supportFragmentManager, "game")
|
||||||
} else if (appItem.loaderResult == LoaderResult.Success) {
|
} else if (appItem.loaderResult == LoaderResult.Success) {
|
||||||
startActivity(Intent(this, EmulationActivity::class.java).apply { data = appItem.uri; putExtra(EmulationActivity.ReturnToMainTag, true); addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) })
|
startActivity(Intent(this, EmulationActivity::class.java).apply {
|
||||||
|
putExtra("item", appItem)
|
||||||
|
putExtra(EmulationActivity.ReturnToMainTag, true)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user