mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Reduce update interval when inactive
This commit is contained in:
@@ -15,6 +15,9 @@ class W3DHub
|
||||
I18n.locale = :en
|
||||
end
|
||||
|
||||
@last_interaction = Gosu.milliseconds
|
||||
@last_mouse_position = CyberarmEngine::Vector.new(mouse_x, mouse_y)
|
||||
|
||||
# push_state(W3DHub::States::DemoInputDelay)
|
||||
push_state(W3DHub::States::Boot)
|
||||
end
|
||||
@@ -23,6 +26,13 @@ class W3DHub
|
||||
super
|
||||
|
||||
Store.application_manager.start_next_available_task if Store.application_manager.idle?
|
||||
manage_update_interval
|
||||
end
|
||||
|
||||
def button_down(id)
|
||||
super
|
||||
|
||||
@last_interaction = Gosu.milliseconds
|
||||
end
|
||||
|
||||
def close
|
||||
@@ -31,6 +41,19 @@ class W3DHub
|
||||
super if Store.application_manager.idle?
|
||||
end
|
||||
|
||||
def manage_update_interval
|
||||
@last_interaction = Gosu.milliseconds if @last_mouse_position.x != mouse_x || @last_mouse_position.y != mouse_y
|
||||
|
||||
self.update_interval = if Gosu.milliseconds - @last_interaction >= 1_000
|
||||
1000.0 / 10
|
||||
else
|
||||
1000.0 / 60
|
||||
end
|
||||
|
||||
@last_mouse_position.x = mouse_x
|
||||
@last_mouse_position.y = mouse_y
|
||||
end
|
||||
|
||||
def main_thread_queue
|
||||
if current_state.is_a?(W3DHub::States::Interface)
|
||||
current_state.main_thread_queue
|
||||
|
||||
Reference in New Issue
Block a user