Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/src/main/java/app/gamenative/PrefManager.kt
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't all these changes now irrelevant?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah leftover except for quickMenuLastTab, that should still stay global for continuity UX, just like it is with steam os I think, could move defaults into container config so fresh games wake up to 0 like this was doing.

Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ object PrefManager {
setPref(DRIVES, value)
}

private val QUICK_MENU_LAST_TAB = intPreferencesKey("quick_menu_last_tab")
var quickMenuLastTab: Int
get() = getPref(QUICK_MENU_LAST_TAB, 0)
set(value) {
setPref(QUICK_MENU_LAST_TAB, value.coerceIn(0, 2))
}

private val SHOW_FPS = booleanPreferencesKey("show_fps")
var showFps: Boolean
get() = getPref(SHOW_FPS, false)
Expand Down
27 changes: 22 additions & 5 deletions app/src/main/java/app/gamenative/ui/component/QuickMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import app.gamenative.PrefManager
import app.gamenative.R
import app.gamenative.ui.data.PerformanceHudConfig
import app.gamenative.ui.data.PerformanceHudSize
import app.gamenative.ui.theme.PluviaTheme
import app.gamenative.ui.util.adaptivePanelWidth
import app.gamenative.utils.MathUtils.normalizedProgress
import com.winlator.container.Container
import com.winlator.renderer.GLRenderer
import kotlinx.coroutines.delay
import kotlin.math.roundToInt
Expand Down Expand Up @@ -216,6 +218,7 @@ fun QuickMenu(
onDismiss: () -> Unit,
onItemSelected: (Int) -> Boolean,
renderer: GLRenderer? = null,
container: Container? = null,
isPerformanceHudEnabled: Boolean = false,
performanceHudConfig: PerformanceHudConfig = PerformanceHudConfig(),
onPerformanceHudConfigChanged: (PerformanceHudConfig) -> Unit = {},
Expand Down Expand Up @@ -267,7 +270,7 @@ fun QuickMenu(
)
}

var selectedTab by rememberSaveable(isVisible) { mutableIntStateOf(QuickMenuTab.HUD) }
var selectedTab by rememberSaveable { mutableIntStateOf(PrefManager.quickMenuLastTab) }
val selectedTabLabelResId = when (selectedTab) {
QuickMenuTab.HUD -> R.string.performance_hud
QuickMenuTab.EFFECTS -> R.string.screen_effects
Expand Down Expand Up @@ -381,7 +384,10 @@ fun QuickMenu(
contentDescriptionResId = R.string.performance_hud,
selected = selectedTab == QuickMenuTab.HUD,
accentColor = PluviaTheme.colors.accentPurple,
onSelected = { selectedTab = QuickMenuTab.HUD },
onSelected = {
selectedTab = QuickMenuTab.HUD
PrefManager.quickMenuLastTab = selectedTab
},
modifier = Modifier.width(56.dp),
focusRequester = hudTabFocusRequester,
)
Expand All @@ -390,7 +396,10 @@ fun QuickMenu(
contentDescriptionResId = R.string.screen_effects,
selected = selectedTab == QuickMenuTab.EFFECTS,
accentColor = PluviaTheme.colors.accentPurple,
onSelected = { selectedTab = QuickMenuTab.EFFECTS },
onSelected = {
selectedTab = QuickMenuTab.EFFECTS
PrefManager.quickMenuLastTab = selectedTab
},
modifier = Modifier.width(56.dp),
focusRequester = effectsTabFocusRequester,
)
Expand All @@ -399,7 +408,10 @@ fun QuickMenu(
contentDescriptionResId = R.string.quick_menu_tab_controller,
selected = selectedTab == QuickMenuTab.CONTROLLER,
accentColor = PluviaTheme.colors.accentPurple,
onSelected = { selectedTab = QuickMenuTab.CONTROLLER },
onSelected = {
selectedTab = QuickMenuTab.CONTROLLER
PrefManager.quickMenuLastTab = selectedTab
},
modifier = Modifier.width(56.dp),
focusRequester = controllerTabFocusRequester,
)
Expand Down Expand Up @@ -472,6 +484,7 @@ fun QuickMenu(
if (renderer != null) {
ScreenEffectsTabContent(
renderer = renderer,
container = container,
modifier = Modifier.fillMaxSize(),
firstItemFocusRequester = effectsItemFocusRequester,
scrollState = effectsScrollState,
Expand Down Expand Up @@ -527,7 +540,11 @@ fun QuickMenu(
if (isVisible) {
repeat(3) {
try {
hudItemFocusRequester.requestFocus()
when (selectedTab) {
QuickMenuTab.HUD -> hudItemFocusRequester.requestFocus()
QuickMenuTab.EFFECTS -> effectsItemFocusRequester.requestFocus()
else -> controllerItemFocusRequester.requestFocus()
}
return@LaunchedEffect
} catch (_: Exception) {
delay(80)
Expand Down
Loading
Loading