Skip to content

Commit

Permalink
fix(PowerTools): re-add power profile dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowApex committed Nov 11, 2023
1 parent a378fdd commit 5fd3fcd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
15 changes: 13 additions & 2 deletions core/systems/performance/performance_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,27 @@ func apply_profile(profile: PerformanceProfile) -> void:
logger.debug("Applying GPU performance settings from profile")
card.manual_clock = profile.gpu_manual_enabled
if profile.tdp_current > 0:
logger.debug("Applying TDP: " + str(profile.tdp_current))
card.tdp = profile.tdp_current
if profile.tdp_boost_current > 0:
logger.debug("Applying TDP Boost: " + str(profile.tdp_boost_current))
card.boost = profile.tdp_boost_current
if profile.gpu_freq_min_current > 0:
logger.debug("Applying Clock Freq Min: " + str(profile.gpu_freq_min_current))
card.clock_value_mhz_min = profile.gpu_freq_min_current
if profile.gpu_freq_max_current > 0:
logger.debug("Applying Clock Freq Max: " + str(profile.gpu_freq_max_current))
card.clock_value_mhz_max = profile.gpu_freq_max_current
#if profile.gpu_power_profile > 0:
# card.power_profile = profile.gpu_power_profile # TODO: Fix this
if profile.gpu_power_profile >= 0:
var power_profile := "max-performance"
if profile.gpu_power_profile == 0:
power_profile = "max-performance"
if profile.gpu_power_profile == 1:
power_profile = "power-saving"
logger.debug("Applying Power Profile: " + power_profile)
card.power_profile = power_profile
if profile.gpu_temp_current > 0:
logger.debug("Applying Thermal Throttle Limit: " + str(profile.gpu_temp_current))
card.thermal_throttle_limit_c = profile.gpu_temp_current

logger.info("Applied Performance Profile: " + profile.name)
Expand Down
11 changes: 7 additions & 4 deletions core/ui/common/quick_bar/powertools_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ func _ready() -> void:
gpu_freq_enable.pressed.connect(on_manual_freq)

# Setup dropdowns
power_profile_dropdown.clear()
power_profile_dropdown.add_item("Max Performance", 0)
power_profile_dropdown.add_item("Power Saving", 1)
thermal_profile_dropdown.clear()
thermal_profile_dropdown.add_item("Balanced", 0)
thermal_profile_dropdown.add_item("Performance", 1)
thermal_profile_dropdown.add_item("Silent", 2)
power_profile_dropdown.clear()
power_profile_dropdown.add_item("Max Performance", 0)
power_profile_dropdown.add_item("Power Saving", 1)

# Set the initial values
_on_profile_loaded(performance_manager.current_profile)
Expand All @@ -131,13 +131,14 @@ func _on_apply_timer_timeout() -> void:
# Update the profile based on the currently set values
current_profile.cpu_boost_enabled = cpu_boost_button.button_pressed
current_profile.cpu_smt_enabled = smt_button.button_pressed
current_profile.cpu_core_count_current = cpu_cores_slider.value
current_profile.cpu_core_count_current = int(cpu_cores_slider.value)
current_profile.tdp_current = tdp_slider.value
current_profile.tdp_boost_current = tdp_boost_slider.value
current_profile.gpu_manual_enabled = gpu_freq_enable.button_pressed
current_profile.gpu_freq_min_current = gpu_freq_min_slider.value
current_profile.gpu_freq_max_current = gpu_freq_max_slider.value
current_profile.gpu_temp_current = gpu_temp_slider.value
current_profile.gpu_power_profile = power_profile_dropdown.selected

performance_manager.apply_and_save_profile(current_profile)

Expand Down Expand Up @@ -178,6 +179,7 @@ func _on_profile_loaded(profile: PerformanceProfile) -> void:

power_profile_dropdown.select(profile.gpu_power_profile)
thermal_profile_dropdown.select(profile.thermal_profile)

profile_loading = false


Expand Down Expand Up @@ -219,6 +221,7 @@ func _setup_interface() -> void:
tdp_boost_slider.visible = true
tdp_boost_slider.max_value = hardware_manager.gpu.max_boost
gpu_freq_enable.visible = true
power_profile_dropdown.visible = true
if card.clock_limit_mhz_min > 0 and card.clock_limit_mhz_max > 0:
gpu_freq_min_slider.visible = card.manual_clock
gpu_freq_min_slider.min_value = card.clock_limit_mhz_min
Expand Down
9 changes: 9 additions & 0 deletions core/ui/components/dropdown.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ signal item_selected(index: int)
disabled = v
if option_button:
option_button.disabled = v
@export var selected: int:
get:
if option_button:
return option_button.selected
return selected
set(v):
selected = v
if option_button:
option_button.selected = v

@onready var label := $%Label as Label
@onready var description_label := $%DescriptionLabel as Label
Expand Down
1 change: 1 addition & 0 deletions core/ui/components/dropdown.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ focus_mode = 2
script = ExtResource("1_k5c4s")
title = "Setting"
description = "Description"
selected = -1

[node name="Label" type="Label" parent="."]
unique_name_in_owner = true
Expand Down

0 comments on commit 5fd3fcd

Please sign in to comment.