Class: Ogre::ApplicationLoadingBar
- Inherits:
-
ResourceGroupListenerProxy
- Object
- ResourceGroupListenerProxy
- Ogre::ApplicationLoadingBar
- Defined in:
- lib/application_loading_bar.rb
Overview
From Ogre’s ExampleLoadingBar:
Defines an example loading progress bar which you can use during startup, level changes etc to display loading progress.
Basically you just need to create an instance of this class, call start() before loading and finish() afterwards. You may also need to stop areas of your scene rendering in between since this method will call RenderWindow::update() to update the display of the bar - we advise using SceneManager’s ‘special case render queues’ for this, see SceneManager::addSpecialCaseRenderQueue for details.
This progress bar relies on you having the OgreCore.zip package already added to a resource group called ‘Bootstrap’ - this provides the basic resources required for the progress bar and will be loaded automatically.
Instance Method Summary collapse
- #finish ⇒ Object
- #resource_group_load_ended(name) ⇒ Object
- #resource_group_load_started(group_name, count) ⇒ Object
- #resource_group_scripting_ended(group_name) ⇒ Object
- #resource_group_scripting_started(group_name, count) ⇒ Object
- #resource_load_ended ⇒ Object
- #resource_load_started(resource) ⇒ Object
- #script_parse_ended(script_name) ⇒ Object
- #script_parse_started(script_name) ⇒ Object
- #start(window, num_groups_init = 1, num_groups_load = 1, initial_proportion = 0.7) ⇒ Object
- #world_geometry_stage_ended ⇒ Object
- #world_geometry_stage_started(description) ⇒ Object
Instance Method Details
#finish ⇒ Object
50 51 52 53 54 55 |
# File 'lib/application_loading_bar.rb', line 50 def finish @load_overlay.hide # See superclass unregister_as_listener end |
#resource_group_load_ended(name) ⇒ Object
112 113 |
# File 'lib/application_loading_bar.rb', line 112 def resource_group_load_ended(name) end |
#resource_group_load_started(group_name, count) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/application_loading_bar.rb', line 82 def resource_group_load_started(group_name, count) puts "", "", "Resource group started #{group_name}", "", "" unless @num_groups_load > 0 raise "You are initializing groups when you said you would not, failing before causing x / 0 error" end @progress_bar_inc = @progress_bar_max_size * (1 - @initial_proportion) / (count * 1.0) @progress_bar_inc /= @num_groups_load @loading_description_element.("Loading resources...") @window.update end |
#resource_group_scripting_ended(group_name) ⇒ Object
79 80 |
# File 'lib/application_loading_bar.rb', line 79 def resource_group_scripting_ended(group_name) end |
#resource_group_scripting_started(group_name, count) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/application_loading_bar.rb', line 57 def resource_group_scripting_started(group_name, count) unless @num_groups_init > 0 raise "You are initializing groups when you said you would not, failing before causing x / 0 error" end @progress_bar_inc = @progress_bar_max_size * @initial_proportion / (count * 1.0) @progress_bar_inc /= @num_groups_init @loading_description_element.("Parsing scripts...") @window.update end |
#resource_load_ended ⇒ Object
99 100 |
# File 'lib/application_loading_bar.rb', line 99 def resource_load_ended() end |
#resource_load_started(resource) ⇒ Object
94 95 96 97 |
# File 'lib/application_loading_bar.rb', line 94 def resource_load_started(resource) @loading_comment_element.(resource.get_name) @window.update end |
#script_parse_ended(script_name) ⇒ Object
74 75 76 77 |
# File 'lib/application_loading_bar.rb', line 74 def script_parse_ended(script_name) @loading_bar_element.set_width(@loading_bar_element.get_width + @progress_bar_inc) @window.update end |
#script_parse_started(script_name) ⇒ Object
69 70 71 72 |
# File 'lib/application_loading_bar.rb', line 69 def script_parse_started(script_name) @loading_comment_element.(script_name) @window.update end |
#start(window, num_groups_init = 1, num_groups_load = 1, initial_proportion = 0.7) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/application_loading_bar.rb', line 20 def start(window, num_groups_init = 1, num_groups_load = 1, initial_proportion = 0.7) @window = window @num_groups_init = num_groups_init @num_groups_load = num_groups_load @initial_proportion = initial_proportion ResourceGroupManager.instance.initialise_resource_group("Bootstrap") = OverlayManager.instance @load_overlay = .get_by_name("Core/LoadOverlay") unless @load_overlay raise "Cannot find loading overlay" end @load_overlay.show # Save links the loading text elements @loading_bar_element = .("Core/LoadPanel/Bar/Progress") @loading_comment_element = .("Core/LoadPanel/Comment") @loading_description_element = .("Core/LoadPanel/Description") = .("Core/LoadPanel/Bar") @progress_bar_max_size = .get_width @loading_bar_element.set_width(0) # See superclass register_as_listener end |
#world_geometry_stage_ended ⇒ Object
107 108 109 110 |
# File 'lib/application_loading_bar.rb', line 107 def world_geometry_stage_ended @loading_bar_element.set_width(@loading_bar_element.get_width + @progress_bar_inc) @window.update end |
#world_geometry_stage_started(description) ⇒ Object
102 103 104 105 |
# File 'lib/application_loading_bar.rb', line 102 def world_geometry_stage_started(description) @loading_comment_element.(description) @window.update end |