Skip to content
Merged
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Onboarding asks whether the OneConfig keybind should open the Mods Menu or the HUD Editor first
- Hotwire and LootBeams have icons in the mods list
- A Share Performance Stats setting, on by default. It sends your in-game FPS, basic hardware info (CPU, GPU and RAM), video settings and installed mods to OneClient so performance problems get caught and fixed. If spark is installed, it also sends a one-minute profile while you're AFK. Nothing is sent unless you've allowed online services
- Controller support with Controlify. The lobby, onboarding, wardrobe, social windows and pause screens all work with a gamepad, and the emote and ping wheels follow the right stick. B switches between your emote wheels while one is open. In the lobby, Y lets you answer party invites and join requests
- Controlify controls for opening Socials and the Wardrobe, the emote wheel, pings and party voice. Opening Socials or the Wardrobe and the voice toggles can also go in Controlify's radial menu

### Changed
- Cosmetics are now rendered in Rust by Polyfrost's plus-renderer, so they're slightly faster and look the same as on the website and in the launcher
Expand All @@ -37,11 +39,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- If the OneClient Menu fails to load, its button stays greyed out until you restart
- Sentry crash reports no longer send your computer name
- Updated to OneConfig 1.9.1
- Needs PolyCompose 3.0.9
- Store cards show the live preview, like the Wardrobe does, instead of playing an animated clip when you hover over them
- The lobby play card reopens on the tab you last used
- The Compact pause screen has a Mods button
- The HUD Editor shows the OneClient logo in the middle
- Needs OneConfig 1.10.0 and PolyCompose 3.1.0

### Fixed
- Fixed the lobby UI staying hidden when using Iris shaders
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ tasks.withType<ProcessResources>().configureEach {
if (isOrnithe) filter { line ->
line.replace("\"fabric-api\": \"*\"", "\"osl-keybinds\": \"*\"")
.replace("\"java\": \">=21\"", "\"java\": \">=25\"")
.replace("\"controlify\": \"*\"", "")
}
expand(
mapOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ object PolyPlusClient {
step("startup sounds") { StartupSounds.prepare() }
step("cosmetics config preload") { PolyPlusCosmeticsConfig.preload() }
step("pylon raw input") { PylonRawInput.initialize() }
step("controller actions") { PolyPlusControllers.initialize() }
step("privacy enforcement") { PrivacyEnforcement.syncConfig() }
step("legal documents") {
if (PrivacyConsent.state() == PrivacyConsent.State.ACCEPTED && !PrivacyConsent.managedByLauncher) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.polyfrost.polyplus.client

import org.polyfrost.compose.host.controller.ControllerAction
import org.polyfrost.compose.host.controller.ControllerButton
import org.polyfrost.compose.host.controller.Controllers
import org.polyfrost.oneconfig.api.event.v1.eventHandler
import org.polyfrost.oneconfig.api.event.v1.events.TickEvent
import org.polyfrost.polyplus.client.emotes.EmoteWheelKeybind
import org.polyfrost.polyplus.client.gui.PolyPlusOneConfigIntegration
import org.polyfrost.polyplus.client.gui.WheelOverlay
import org.polyfrost.polyplus.client.party.PartyVoice
import org.polyfrost.polyplus.client.ping.PingInput
import org.polyfrost.polyplus.client.social.SocialOverlay

object PolyPlusControllers {
private const val CATEGORY = "polyplus.controller.category"

private class Held(val action: ControllerAction, val onChange: (Boolean) -> Unit) {
var down = false

fun poll() {
val now = action.isPressed
if (now == down) return
down = now
onChange(now)
}
}

private val held = ArrayList<Held>()
private var emoteWheel: ControllerAction? = null

fun initialize() {
tap("open_socials", "openSocials") { SocialOverlay.toggle() }
tap("open_wardrobe", "openWardrobe") { PolyPlusOneConfigIntegration.openCosmeticsFromKeybind() }
tap("toggle_mute", "toggleMute") { PartyVoice.onToggleMuteKey() }
tap("toggle_deafen", "toggleDeafen") { PartyVoice.onToggleDeafenKey() }
tap("join_leave_voice", "joinLeaveVoice") { PartyVoice.onJoinLeaveKey() }
emoteWheel = hold("emote_wheel", "emoteWheel") { EmoteWheelKeybind.onControllerState(it) }
register("emote_wheel_next", "emoteWheelNext", radial = false, ControllerButton.B).onPress { WheelOverlay.page(1) }
hold("ping", "ping") { PingInput.onControllerState(it) }
hold("push_to_talk", "pushToTalk") { PartyVoice.onControllerPushToTalk(it) }
eventHandler<TickEvent.End> { for (entry in held) entry.poll() }
}

fun canBindEmoteWheel(): Boolean = emoteWheel?.isRebindable == true

private fun register(id: String, name: String, radial: Boolean, button: ControllerButton = ControllerButton.NONE): ControllerAction =
Controllers.register("polyplus:$id", "polyplus.controller.$name", button, category = CATEGORY, radial = radial)

private fun tap(id: String, name: String, run: () -> Unit) {
register(id, name, radial = true).onPress { run() }
}

private fun hold(id: String, name: String, onChange: (Boolean) -> Unit): ControllerAction =
register(id, name, radial = false).also { held += Held(it, onChange) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ import org.polyfrost.oneconfig.api.ui.v1.ExperimentalOneConfigUiApi
import org.polyfrost.oneconfig.api.ui.v1.keybind.KeybindManager
import org.polyfrost.oneconfig.api.ui.v1.keybind.TextInputFocus
import org.polyfrost.polyplus.client.PolyPlusConfig
import org.polyfrost.polyplus.client.PolyPlusControllers
import org.polyfrost.polyplus.client.gui.EmoteWheelOverlay
import org.polyfrost.polyplus.client.gui.WheelOverlay
import org.polyfrost.polyplus.client.utils.ClientPlatform

object EmoteWheelKeybind {
@Volatile
private var held = false
private var keyHeld = false

fun isHeld(): Boolean = held
@Volatile
private var controllerHeld = false

fun isHeld(): Boolean = keyHeld || controllerHeld

fun onKeybindState(pressed: Boolean) {
held = pressed
keyHeld = pressed
if (!pressed || WheelOverlay.isOpen) return
if (Minecraft.getInstance().player != null && ClientPlatform.currentScreen() == null) {
EmoteWheelOverlay.open()
Expand All @@ -27,6 +31,13 @@ object EmoteWheelKeybind {
EmoteWheelOverlay.openOverLobby()
}

fun onControllerState(pressed: Boolean) {
controllerHeld = pressed
if (!pressed || WheelOverlay.isOpen) return
if (Minecraft.getInstance().player == null || ClientPlatform.currentScreen() != null) return
EmoteWheelOverlay.open()
}

fun isBound(): Boolean = PolyPlusConfig.emoteWheelKeybind.isBound

fun claimsKey(key: Int, modifiers: Int): Boolean {
Expand All @@ -42,6 +53,8 @@ object EmoteWheelKeybind {

private const val MODIFIER_MASK = 0xF

fun canBindController(): Boolean = PolyPlusControllers.canBindEmoteWheel()

fun conflictingKeybindNames(): List<String> {
val wheel = PolyPlusConfig.emoteWheelKeybind
if (!wheel.isBound) return emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import org.polyfrost.compose.host.controller.ControllerButton
import org.polyfrost.compose.host.controller.Controllers
import org.polyfrost.compose.host.controller.controllerAction
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.graphics.Color
Expand Down Expand Up @@ -289,6 +295,26 @@ private fun AccountRow(state: AccountsPanelState, account: OneLauncherAccounts.A
val theme = OneConfigTheme.current
val hover = rememberHoverState()
var confirmRemove by remember { mutableStateOf(false) }
var confirmByController by remember { mutableStateOf(false) }
var refocusRow by remember { mutableIntStateOf(0) }
val rowFocus = remember { FocusRequester() }
val keepFocus = remember { FocusRequester() }
fun closeConfirm() {
confirmRemove = false
if (confirmByController) {
confirmByController = false
refocusRow++
}
}
LaunchedEffect(confirmRemove, confirmByController) {
if (confirmRemove && confirmByController) runCatching { keepFocus.requestFocus() }
}
LaunchedEffect(refocusRow) {
if (refocusRow > 0) runCatching { rowFocus.requestFocus() }
}
if (confirmRemove && confirmByController) EscapeCloses { closeConfirm() }
var focused by remember { mutableStateOf(false) }
val revealed = hover.hovered || focused
val busy = actions.refreshingId == account.id || state.pendingId == account.id
val idle = actions.idle
val shape = OneConfigTheme.shape(CustomizeKit.RowRadius)
Expand All @@ -305,6 +331,14 @@ private fun AccountRow(state: AccountsPanelState, account: OneLauncherAccounts.A
.fillMaxWidth()
.height(CustomizeKit.RowHeight)
.graphicsLayer { alpha = if (idle || busy) 1f else theme.disabledAlpha }
.onFocusChanged { focused = it.hasFocus }
.focusRequester(rowFocus)
.controllerAction(ControllerButton.X, "Remove", enabled = idle && !busy && !confirmRemove) {
confirmByController = true
confirmRemove = true
}
.controllerAction(ControllerButton.Y, "Refresh", enabled = idle && !busy && !confirmRemove && account.refreshable) { state.refresh(account) }
.then(if (account.active) Modifier.focusableOnController() else Modifier)
.hoverable(hover.interactionSource)
.selectableRow(
false,
Expand Down Expand Up @@ -341,19 +375,22 @@ private fun AccountRow(state: AccountsPanelState, account: OneLauncherAccounts.A
busy -> Spinner(OneConfigTheme.accent)
confirmRemove -> {
RowIcon("check", "Remove ${account.username}", SocialDangerText, idle) {
confirmRemove = false
closeConfirm()
state.remove(account)
}
RowIcon("x-close", "Keep ${account.username}", theme.textColorSecondary, true) { confirmRemove = false }
RowIcon("x-close", "Keep ${account.username}", theme.textColorSecondary, true, Modifier.focusRequester(keepFocus)) { closeConfirm() }
}
else -> {
if (account.expired && account.refreshable) {
TextButton(text = "Sign in again", onClick = { state.refresh(account) }, size = ControlSize.Compact, enabled = idle)
} else if (hover.hovered && account.refreshable) {
} else if (revealed && account.refreshable) {
RowIcon("refresh-cw-01", "Refresh ${account.username}", theme.textColorSecondary, idle) { state.refresh(account) }
}
if (hover.hovered) {
RowIcon("trash-01", "Remove ${account.username}", theme.textColorSecondary, idle) { confirmRemove = true }
if (revealed) {
RowIcon("trash-01", "Remove ${account.username}", theme.textColorSecondary, idle) {
if (Controllers.isDispatching) confirmByController = true
confirmRemove = true
}
} else if (account.active) {
LobbyIcon("check", OneConfigTheme.accent, 18.dp)
}
Expand Down Expand Up @@ -606,11 +643,12 @@ private fun Spinner(color: Color, size: Dp = 16.dp) {
}

@Composable
private fun RowIcon(icon: String, label: String, tint: Color, enabled: Boolean, onClick: () -> Unit) {
private fun RowIcon(icon: String, label: String, tint: Color, enabled: Boolean, modifier: Modifier = Modifier, onClick: () -> Unit) {
IconButton(
icon = "$ASSETS$icon.svg",
contentDescription = label,
onClick = onClick,
modifier = modifier,
enabled = enabled,
tooltip = null,
tint = tint,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.polyfrost.polyplus.client.gui

import androidx.compose.foundation.focusable
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.focusProperties
import org.polyfrost.compose.host.controller.Controllers

internal fun Modifier.controllerFocusOnly(): Modifier {
val active = Controllers.isActive
return focusProperties { canFocus = active }
}

internal fun Modifier.focusableOnController(): Modifier = focusable(enabled = Controllers.isActive)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.runtime.withFrameNanos
import kotlinx.coroutines.launch
import org.apache.logging.log4j.LogManager
import org.polyfrost.compose.host.controller.Controllers
import org.polyfrost.oneconfig.api.event.v1.eventHandler
import org.polyfrost.oneconfig.api.event.v1.events.WorldEvent
import org.polyfrost.oneconfig.api.ui.v1.ExperimentalOneConfigUiApi
Expand Down Expand Up @@ -258,6 +259,7 @@ private fun EmoteWheelContent(session: WheelSession, lobby: Boolean) {
val subtitle = when {
empty -> null
wheelCount > 1 && lobbyDuo -> "Wheel ${wheelIndex + 1} of $wheelCount · $LOBBY_DUO_NOTE"
wheelCount > 1 && Controllers.isActive -> "Wheel ${wheelIndex + 1} of $wheelCount"
wheelCount > 1 -> "Wheel ${wheelIndex + 1} of $wheelCount · Scroll for more"
lobbyDuo -> LOBBY_DUO_NOTE
else -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package org.polyfrost.polyplus.client.gui

import org.polyfrost.compose.host.controller.ControllerGuide
import org.polyfrost.oneconfig.api.ui.v1.ExperimentalOneConfigUiApi
import androidx.compose.runtime.Composable
import com.mojang.blaze3d.platform.InputConstants
Expand All @@ -12,6 +13,7 @@ import net.minecraft.client.gui.GuiGraphicsExtractor
*///?} else {
/*import net.minecraft.client.gui.screen.Screen
*///?}
import org.polyfrost.compose.host.controller.Controllers
import org.polyfrost.oneconfig.api.ui.v1.components.ProvidePopupSounds
import org.polyfrost.oneconfig.api.ui.v1.platform.OneConfigComposeScreen
import org.polyfrost.oneconfig.api.ui.v1.keybind.KeybindManager
Expand Down Expand Up @@ -41,6 +43,8 @@ class PolyPlusLobbyScreen internal constructor(firstPage: LobbyPage) : OneConfig

override val dimBackground: Boolean get() = false

override val controllerGuide: ControllerGuide get() = ControllerGuide.BottomCenter

override fun init() {
lobby.open()
super.init()
Expand Down Expand Up @@ -80,7 +84,7 @@ class PolyPlusLobbyScreen internal constructor(firstPage: LobbyPage) : OneConfig
return key !in wheelKeys
}
if (emoteWheelReady() && EmoteWheelKeybind.claimsKey(key, modifiers)) return true
if (key in navigationKeys) keyNavigated = true
if (key in navigationKeys || Controllers.isDispatching) keyNavigated = true
LobbyAntics.key(key, lobby.calm())
if (lobby.setup && StartupAccessibility.handleKey(key, modifiers)) return true
if (lobby.setup && OnboardingKeyCapture.capture(key)) return true
Expand All @@ -96,7 +100,8 @@ class PolyPlusLobbyScreen internal constructor(firstPage: LobbyPage) : OneConfig
*///?}
}
val enter = key == InputConstants.KEY_RETURN || key == InputConstants.KEY_NUMPADENTER
if (enter && (lobby.tour != null || !keyNavigated || !LobbyA11y.keyboardFocused()) && lobby.openSocial()) return true
val keyboardOnly = !Controllers.isDispatching && (!keyNavigated || !LobbyA11y.keyboardFocused())
if (enter && (lobby.tour != null || keyboardOnly) && lobby.openSocial()) return true
return super.handleKeyPressed(key, modifiers)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Size
import org.polyfrost.compose.backend.drawPoly
import org.polyfrost.compose.host.controller.Controllers
import org.polyfrost.compose.render.FilterQuality
import org.polyfrost.compose.render.PolyBitmap
import org.polyfrost.compose.render.PolyColor
Expand Down Expand Up @@ -2479,7 +2480,7 @@ internal object OnboardingKeyCapture {
fun capture(key: Int): Boolean {
val capture = pending ?: return false
capture(
if (key == InputConstants.KEY_ESCAPE) {
if (key == InputConstants.KEY_ESCAPE || Controllers.isDispatching) {
null
} else {
//? if >= 26.3 || = 1.8.9 {
Expand Down Expand Up @@ -2524,7 +2525,7 @@ internal object OnboardingKeys {
when (key) {
InputConstants.KEY_ESCAPE -> if (!BackStack.dispatch()) (back ?: return false)()
InputConstants.KEY_RETURN, InputConstants.KEY_NUMPADENTER -> {
if (LobbyA11y.keyboardFocused()) return false
if (LobbyA11y.keyboardFocused() || Controllers.isDispatching) return false
if (System.currentTimeMillis() - pageAt < PAGE_SETTLE_MS) return true
val action = next
when {
Expand Down
Loading