-
-
Notifications
You must be signed in to change notification settings - Fork 356
Extended Performancehud #1776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Extended Performancehud #1776
Changes from 1 commit
4845277
1ecfa8f
0f6a90d
954ec29
317c2a4
a746a9b
4e5e044
79c85e5
f93a8c3
879d430
fe58701
5f818cf
8ece481
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||
| package app.gamenative.ui.widget | ||||||
|
|
||||||
| import android.R.attr.opacity | ||||||
|
Smithsonian1974 marked this conversation as resolved.
Outdated
|
||||||
| import android.app.ActivityManager | ||||||
| import android.content.Context | ||||||
| import android.content.Intent | ||||||
|
|
@@ -9,8 +10,10 @@ import android.graphics.Color | |||||
| import android.graphics.Paint | ||||||
| import android.graphics.Path | ||||||
| import android.graphics.Typeface | ||||||
| import android.graphics.drawable.ColorDrawable | ||||||
| import android.graphics.drawable.GradientDrawable | ||||||
| import android.os.BatteryManager | ||||||
| import android.os.Build | ||||||
| import android.text.TextUtils | ||||||
| import android.text.format.DateFormat | ||||||
| import android.util.TypedValue | ||||||
|
|
@@ -40,6 +43,13 @@ import kotlinx.coroutines.delay | |||||
| import kotlinx.coroutines.isActive | ||||||
| import kotlinx.coroutines.launch | ||||||
| import kotlinx.coroutines.withContext | ||||||
| import android.hardware.BatteryState | ||||||
| import android.view.InputDevice | ||||||
| import androidx.annotation.RequiresApi | ||||||
| import kotlin.math.roundToInt | ||||||
| import android.media.AudioManager | ||||||
| import android.media.ToneGenerator | ||||||
|
|
||||||
|
|
||||||
| /** | ||||||
| * Lightweight floating HUD shown above the in-game surface. | ||||||
|
|
@@ -109,6 +119,21 @@ class PerformanceHudView( | |||||
| private val gpuTempMetric = createMetricViews(MetricId.GPU_TEMP, 0xFFBDBDBD.toInt()) | ||||||
| private val batteryTempMetric = createMetricViews(MetricId.BATTERY_TEMP, 0xFFBDBDBD.toInt()) | ||||||
|
|
||||||
| private var currentBackgroundColor = (backgroundDrawable as? GradientDrawable) | ||||||
| ?.color?.defaultColor ?: Color.BLACK | ||||||
|
|
||||||
| private val backupBackgroundColor = currentBackgroundColor | ||||||
|
Smithsonian1974 marked this conversation as resolved.
Smithsonian1974 marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: HUD background becomes opaque black after its first update, ignoring Prompt for AI agents |
||||||
| private val batteryLevelBackgroundColor = Color.argb( | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: Warning colors are embedded in the view instead of named shared color resources, making theme changes and visual maintenance harder. Define named warning colors in resources and resolve them here. (Based on your team's feedback about hardcoded UI colors.) Prompt for AI agents |
||||||
| (opacity * 255f).roundToInt(), | ||||||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
|
||||||
| 128, | ||||||
| 0, | ||||||
| 0) | ||||||
|
|
||||||
| private val batteryTempBackgroundColor = Color.argb( | ||||||
| (opacity * 255f).roundToInt(), | ||||||
| 128, | ||||||
| 0, | ||||||
| 128) | ||||||
| private val allMetrics = listOf( | ||||||
| fpsMetric, | ||||||
| cpuMetric, | ||||||
|
|
@@ -216,6 +241,32 @@ class PerformanceHudView( | |||||
| collectSnapshot(currentFps) | ||||||
| } | ||||||
| renderSnapshot(snapshot) | ||||||
|
|
||||||
| val levelWarning = config.batteryLevelWarningEnabled && | ||||||
| snapshot.batteryPercent < (config.batteryLevelWarningLimit * 100) | ||||||
| val tempWarning = config.batteryTemperatureWarningEnabled && | ||||||
| snapshot.batteryTempValue > (config.batteryTemperatureWarningLimit * 100) | ||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: A temperature exactly at the selected limit does not warn; default 40 °C only starts alerting above 40 °C. Include the limit in the high-temperature condition. Prompt for AI agents
Suggested change
|
||||||
|
|
||||||
| if (levelWarning) { | ||||||
| ToneGenerator(AudioManager.STREAM_ALARM, 100).startTone(ToneGenerator.TONE_PROP_ACK, 150) | ||||||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
|
||||||
| } | ||||||
| if (tempWarning) { | ||||||
| ToneGenerator(AudioManager.STREAM_ALARM, 100).startTone(ToneGenerator.TONE_CDMA_PIP, 150) | ||||||
| } | ||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||
|
|
||||||
| val warningColor = when { | ||||||
| tempWarning -> batteryTempBackgroundColor | ||||||
| levelWarning -> batteryLevelBackgroundColor | ||||||
| else -> null | ||||||
| } | ||||||
|
|
||||||
| currentBackgroundColor = if (warningColor != null) { | ||||||
| if (currentBackgroundColor == backupBackgroundColor) warningColor else backupBackgroundColor | ||||||
| } else { | ||||||
| backupBackgroundColor | ||||||
| } | ||||||
| backgroundDrawable.setColor(currentBackgroundColor) | ||||||
|
|
||||||
| delay(UPDATE_INTERVAL_MS) | ||||||
| } | ||||||
| } | ||||||
|
|
@@ -321,11 +372,13 @@ class PerformanceHudView( | |||||
| gpu = gpuPercent?.let { "GPU $it%" }, | ||||||
| ram = "RAM ${readUsedRamText()}", | ||||||
| battery = batterySnapshot.percent?.let { "BAT $it%" }, | ||||||
| batteryPercent = batterySnapshot.percent ?: -1 , | ||||||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
|
||||||
| power = batterySnapshot.powerWatts?.let { watts -> | ||||||
| String.format(Locale.US, "PWR %.1fW", watts) | ||||||
| }, | ||||||
| runtime = batterySnapshot.runtimeText, | ||||||
| batteryTemp = batterySnapshot.temperatureC?.let { "BAT TEMP ${it}°C" }, | ||||||
| batteryTempValue = batterySnapshot.temperatureC ?: 0, | ||||||
| clock = readClockText(), | ||||||
| cpuTemp = readCpuTempC()?.let { "CPU TEMP ${it}°C" }, | ||||||
| gpuTemp = readGpuTempC()?.let { "GPU TEMP ${it}°C" }, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -343,6 +343,10 @@ | |||||
| <string name="performance_hud_clock_time">Uhrzeit</string> | ||||||
| <string name="performance_hud_cpu_temperature">CPU-Temperatur</string> | ||||||
| <string name="performance_hud_gpu_temperature">GPU-Temperatur</string> | ||||||
| <string name="performance_hud_battery_level_warning">Batteriestand Warnung</string> | ||||||
| <string name="performance_hud_battery_level_limit">Batteriestand Limit</string> | ||||||
| <string name="performance_hud_battery_temp_warning">Batterie Temp Warnung</string> | ||||||
|
Smithsonian1974 marked this conversation as resolved.
Outdated
|
||||||
| <string name="performance_hud_battery_temp_limit">Batterie Temp Limit</string> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Prompt for AI agents
Suggested change
|
||||||
| <string name="touchpad_help">Touchpad-Hilfe</string> | ||||||
| <string name="hide_controls_with_controller">On-Screen-Controller bei Gamepad ausblenden</string> | ||||||
| <string name="hide_controls_with_controller_description">On-Screen-Steuerung automatisch ausblenden, wenn ein physischer Controller verbunden ist</string> | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The battery temperature value display uses inline string interpolation (
"${...} °C") instead of a localized string resource. The battery level row already follows the proper pattern usingstringResource(R.string.performance_hud_percentage_value, ...). Consider adding a string resource like<string name="performance_hud_temperature_value">%1$d °C</string>tostrings.xmland referencing it from code for consistency and localization support.Prompt for AI agents