Class: UI::Bar
- Defined in:
- scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb
Overview
Class that display a bar on screen using the whole texture to display the bar component
Instance Attribute Summary collapse
-
#data_source
Return the data source to get the rate info through data=.
-
#rate ⇒ Numeric
Returns the rate of the bar.
Instance Method Summary collapse
-
#data=(data)
Change the data value (for SpriteStack usage).
-
#dispose
Dispose the bar.
-
#initialize(viewport, x, y, bmp, bw, bh, bx, by, nb_states, background_width = nil) ⇒ Bar
constructor
Create a new bar.
-
#set_position(x, y)
Change the position of the bar.
-
#visible ⇒ Boolean
Returns the visible state of the bar.
-
#visible=(value)
Change the visible state of the bar.
-
#x ⇒ Integer
Returns the x position of the bar.
-
#x=(value)
Change the x position of the bar.
-
#y ⇒ Integer
Returns the y position of the bar.
-
#y=(value)
Change the y position of the bar.
-
#z ⇒ Integer
Returns the z position of the bar.
-
#z=(value)
Change the z position of the bar.
Constructor Details
#initialize(viewport, x, y, bmp, bw, bh, bx, by, nb_states, background_width = nil) ⇒ Bar
Create a new bar
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 20 def initialize(, x, y, bmp, bw, bh, bx, by, nb_states, background_width = nil) @background = Sprite.new().set_bitmap(bmp) @background.src_rect.set(0, 0, background_width, bmp.height - nb_states * bh) @bar = Sprite.new().set_bitmap(bmp) @bar.src_rect.set(0, @background.src_rect.height, 0, @bh = bh) @nb_states = nb_states @bx = bx @by = by @bw = bw @bar.x = (@background.x = x) + bx @bar.y = (@background.y = y) + by @rate = 0 @data_source = nil end |
Instance Attribute Details
#data_source
Return the data source to get the rate info through data=
8 9 10 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 8 def data_source @data_source end |
#rate ⇒ Numeric
Returns the rate of the bar
6 7 8 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 6 def rate @rate end |
Instance Method Details
#data=(data)
Change the data value (for SpriteStack usage)
115 116 117 118 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 115 def data=(data) return unless @data_source self.rate = data.send(*@data_source) if (self.visible = data) end |
#dispose
Dispose the bar
108 109 110 111 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 108 def dispose @background.dispose @bar.dispose end |
#set_position(x, y)
Change the position of the bar
89 90 91 92 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 89 def set_position(x, y) @background.set_position(x, y) @bar.set_position(x + @bx, y + @by) end |
#visible ⇒ Boolean
Returns the visible state of the bar
56 57 58 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 56 def visible return @bar.visible end |
#visible=(value)
Change the visible state of the bar
50 51 52 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 50 def visible=(value) @bar.visible = @background.visible = value end |
#x ⇒ Integer
Returns the x position of the bar
62 63 64 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 62 def x return @background.x end |
#x=(value)
Change the x position of the bar
74 75 76 77 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 74 def x=(value) @background.x = value @bar.x = value + @bx end |
#y ⇒ Integer
Returns the y position of the bar
68 69 70 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 68 def y return @background.y end |
#y=(value)
Change the y position of the bar
81 82 83 84 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 81 def y=(value) @background.y = value @bar.y = value + @by end |
#z ⇒ Integer
Returns the z position of the bar
96 97 98 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 96 def z return @background.z end |
#z=(value)
Change the z position of the bar
102 103 104 105 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00300 Bar.rb', line 102 def z=(value) @background.z = value @bar.z = value end |