Add default light profile for PortMaster
This commit is contained in:
parent
a62cce6404
commit
a3e0830bd1
16 changed files with 454 additions and 42 deletions
50
main/runtime_performance_profile.gd
Normal file
50
main/runtime_performance_profile.gd
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
class_name RuntimePerformanceProfile
|
||||
extends RefCounted
|
||||
|
||||
const PROFILE_ENVIRONMENT_VARIABLE: String = (
|
||||
"NETFISHING_PERFORMANCE_PROFILE"
|
||||
)
|
||||
const LEGACY_LIGHT_ENVIRONMENT_VARIABLE: String = "NETFISHING_LOW_END"
|
||||
const NORMAL_PROFILE: StringName = &"normal"
|
||||
const LIGHT_PROFILE: StringName = &"light"
|
||||
const NORMAL_WORLD_RENDER_SCALE: float = 1.0
|
||||
const LIGHT_WORLD_RENDER_SCALE: float = 0.5
|
||||
|
||||
var _profile_name: StringName = NORMAL_PROFILE
|
||||
|
||||
|
||||
static func from_environment() -> RuntimePerformanceProfile:
|
||||
return from_name(
|
||||
StringName(OS.get_environment(PROFILE_ENVIRONMENT_VARIABLE)),
|
||||
OS.get_environment(LEGACY_LIGHT_ENVIRONMENT_VARIABLE) == "1",
|
||||
)
|
||||
|
||||
|
||||
static func from_name(
|
||||
profile_name: StringName,
|
||||
legacy_light_requested: bool = false,
|
||||
) -> RuntimePerformanceProfile:
|
||||
var profile := RuntimePerformanceProfile.new()
|
||||
if profile_name == LIGHT_PROFILE or (
|
||||
profile_name.is_empty() and legacy_light_requested
|
||||
):
|
||||
profile._profile_name = LIGHT_PROFILE
|
||||
else:
|
||||
profile._profile_name = NORMAL_PROFILE
|
||||
return profile
|
||||
|
||||
|
||||
func get_profile_name() -> StringName:
|
||||
return _profile_name
|
||||
|
||||
|
||||
func is_light() -> bool:
|
||||
return _profile_name == LIGHT_PROFILE
|
||||
|
||||
|
||||
func get_world_render_scale() -> float:
|
||||
return (
|
||||
LIGHT_WORLD_RENDER_SCALE
|
||||
if is_light()
|
||||
else NORMAL_WORLD_RENDER_SCALE
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue