Add default light profile for PortMaster
This commit is contained in:
parent
a62cce6404
commit
a3e0830bd1
16 changed files with 454 additions and 42 deletions
16
main/main.gd
16
main/main.gd
|
|
@ -39,6 +39,9 @@ const PixelationResetOverlayType = preload(
|
|||
const WorldPixelationPostprocessType = preload(
|
||||
"res://main/world_pixelation_postprocess.gd"
|
||||
)
|
||||
const RuntimePerformanceProfileType = preload(
|
||||
"res://main/runtime_performance_profile.gd"
|
||||
)
|
||||
const NetworkSessionType = preload("res://network/network_session.gd")
|
||||
const DiscoveryClientType = preload("res://network/discovery_client.gd")
|
||||
const DedicatedServerConfigType = preload(
|
||||
|
|
@ -235,6 +238,7 @@ var _data_folder_dialog: FileDialog
|
|||
var _data_folder_picker_generation: int = 0
|
||||
var _restore_data_setup_after_picker: bool = false
|
||||
var _application_initialized := false
|
||||
var _performance_profile: RuntimePerformanceProfileType
|
||||
var _pending_existing_root_path := ""
|
||||
var _local_recovery_attempt_id: String = ""
|
||||
var _dedicated_runtime: bool = false
|
||||
|
|
@ -244,10 +248,17 @@ var _rain_ambience: RainAmbienceType
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
_performance_profile = RuntimePerformanceProfileType.from_environment()
|
||||
_dedicated_runtime = _is_dedicated_server_runtime()
|
||||
if _dedicated_runtime:
|
||||
call_deferred("_start_dedicated_server")
|
||||
return
|
||||
_world_pixelation.set_light_performance_profile(
|
||||
_performance_profile.is_light()
|
||||
)
|
||||
_test_world.set_light_performance_profile(
|
||||
_performance_profile.is_light()
|
||||
)
|
||||
DisplayServer.window_set_title("NETfishing")
|
||||
_rain_ambience = RainAmbienceType.new()
|
||||
_rain_ambience.name = "RainAmbience"
|
||||
|
|
@ -441,6 +452,7 @@ func _initialize_application(dedicated: bool) -> void:
|
|||
_world_weather,
|
||||
_player,
|
||||
Callable(_player, "get_active_gameplay_camera"),
|
||||
_performance_profile.is_light(),
|
||||
)
|
||||
if not _world_time.natural_time_advanced.is_connected(
|
||||
_on_natural_time_advanced
|
||||
|
|
@ -1324,9 +1336,7 @@ func _apply_world_pixelation(pixel_size: int) -> void:
|
|||
var root_viewport: Viewport = get_viewport()
|
||||
root_viewport.scaling_3d_mode = Viewport.SCALING_3D_MODE_NEAREST
|
||||
root_viewport.scaling_3d_scale = (
|
||||
0.75
|
||||
if OS.get_environment("NETFISHING_LOW_END") == "1"
|
||||
else 1.0
|
||||
_performance_profile.get_world_render_scale()
|
||||
)
|
||||
root_viewport.msaa_3d = Viewport.MSAA_DISABLED
|
||||
root_viewport.screen_space_aa = Viewport.SCREEN_SPACE_AA_DISABLED
|
||||
|
|
|
|||
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
|
||||
)
|
||||
1
main/runtime_performance_profile.gd.uid
Normal file
1
main/runtime_performance_profile.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://8vm104r2264h
|
||||
|
|
@ -5,6 +5,7 @@ extends CanvasLayer
|
|||
|
||||
var _pixel_size: int = PlayerSettings.DEFAULT_WORLD_PIXEL_SIZE
|
||||
var _gameplay_active: bool = false
|
||||
var _light_performance_profile: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -26,6 +27,15 @@ func set_gameplay_active(active: bool) -> void:
|
|||
_refresh_grid()
|
||||
|
||||
|
||||
func set_light_performance_profile(enabled: bool) -> void:
|
||||
_light_performance_profile = enabled
|
||||
_refresh_grid()
|
||||
|
||||
|
||||
func is_light_performance_profile() -> bool:
|
||||
return _light_performance_profile
|
||||
|
||||
|
||||
func get_grid_size() -> Vector2i:
|
||||
return PlayerSettings.get_world_grid_size(
|
||||
_pixel_size,
|
||||
|
|
@ -38,6 +48,7 @@ func _refresh_grid() -> void:
|
|||
return
|
||||
var effect_enabled: bool = (
|
||||
_gameplay_active
|
||||
and not _light_performance_profile
|
||||
and _pixel_size != PlayerSettings.MIN_WORLD_PIXEL_SIZE
|
||||
)
|
||||
_screen_grid.visible = effect_enabled
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue