Class: UI::Window
- Defined in:
- scripts/01450 Systems/00000 General/00100 UI Generics/00200 Window.rb
Overview
Window utility allowing to make Window easilly
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_SKIN =
'message'
Instance Attribute Summary
Attributes inherited from LiteRGSS::Window
#__index__, #active, #back_opacity, #contents_opacity, #cursor_rect, #cursorskin, #height, #opacity, #ox, #oy, #pause, #pause_x, #pause_y, #pauseskin, #stretch, #viewport, #visible, #width, #window_builder, #windowskin, #x, #y, #z
Class Method Summary collapse
-
.from_metrics(viewport, x, y, width, height, skin: DEFAULT_SKIN, position: 'top_left')
Create a new window from given metrics.
-
.window_builder(skin) ⇒ Array<Integer>
Get the Window Builder according to the skin.
Instance Method Summary collapse
-
#add_line(line_index, str, align = 0, outlinesize = Text::Util::DEFAULT_OUTLINE_SIZE, type: Text, color: nil, dx: 0)
Add a text line to the window.
-
#add_text(x, y, width, height, str, align = 0, outlinesize = Text::Util::DEFAULT_OUTLINE_SIZE, type: Text, color: 0)
Add a text to the window.
-
#initialize(viewport, x = 2, y = 2, width = 316, height = 48, skin: DEFAULT_SKIN) ⇒ Window
constructor
Create a new Window.
-
#load_cursor
Load the cursor.
-
#push(x, y, bmp, *args, rect: nil, type: Sprite, ox: 0, oy: 0)
Push a sprite to the window.
-
#sprite_stack ⇒ SpriteStack
Return the sprite stack used by the window.
-
#stack ⇒ Array
Return the stack of the window if any.
Methods inherited from Window
#simple_mouse_in?, #translate_mouse_coords
Methods inherited from LiteRGSS::Window
#lock, #locked?, new, #set_origin, #set_position, #set_size, #unlock, #update
Methods inherited from LiteRGSS::Disposable
Constructor Details
#initialize(viewport, x = 2, y = 2, width = 316, height = 48, skin: DEFAULT_SKIN) ⇒ Window
Create a new Window
12 13 14 15 16 17 18 19 20 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00200 Window.rb', line 12 def initialize(, x = 2, y = 2, width = 316, height = 48, skin: DEFAULT_SKIN) super() lock set_position(x, y) set_size(width, height) self.windowskin = RPG::Cache.windowskin(skin) self.window_builder = current_window_builder(skin) unlock end |
Class Method Details
.from_metrics(viewport, x, y, width, height, skin: DEFAULT_SKIN, position: 'top_left')
Create a new window from given metrics
36 37 38 39 40 41 42 43 44 45 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00200 Window.rb', line 36 def from_metrics(, x, y, width, height, skin: DEFAULT_SKIN, position: 'top_left') wb = window_builder(skin) width = (wb[4] + wb[-2] + width) height = (wb[5] + wb[-1] + height) x -= width if position.include?('right') x -= width / 2 if position.include?('center') y -= height if position.include?('bottom') y -= height / 2 if position.include?('middle') return new(, x, y, width, height, skin: skin) end |
.window_builder(skin) ⇒ Array<Integer>
Get the Window Builder according to the skin
50 51 52 53 54 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00200 Window.rb', line 50 def window_builder(skin) return Configs.window.builders[:message_box] if skin[0, 2].casecmp?('m_') # SkinHGSS return Configs.window.builders[:generic] end |
Instance Method Details
#add_line(line_index, str, align = 0, outlinesize = Text::Util::DEFAULT_OUTLINE_SIZE, type: Text, color: nil, dx: 0)
Add a text line to the window
65 66 67 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00200 Window.rb', line 65 def add_line(line_index, str, align = 0, outlinesize = Text::Util::DEFAULT_OUTLINE_SIZE, type: Text, color: nil, dx: 0) sprite_stack.add_line(line_index, str, align, outlinesize, type: type, color: color, dx: dx) end |
#add_text(x, y, width, height, str, align = 0, outlinesize = Text::Util::DEFAULT_OUTLINE_SIZE, type: Text, color: 0)
Add a text to the window
59 60 61 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00200 Window.rb', line 59 def add_text(x, y, width, height, str, align = 0, outlinesize = Text::Util::DEFAULT_OUTLINE_SIZE, type: Text, color: 0) sprite_stack.add_text(x, y, width, height, str, align, outlinesize, type: type, color: color) end |
#load_cursor
Load the cursor
88 89 90 91 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00200 Window.rb', line 88 def load_cursor cursor_rect.set(0, 0, 16, 16) self.cursorskin = RPG::Cache.windowskin('cursor') end |
#push(x, y, bmp, *args, rect: nil, type: Sprite, ox: 0, oy: 0)
Push a sprite to the window
71 72 73 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00200 Window.rb', line 71 def push(x, y, bmp, *args, rect: nil, type: Sprite, ox: 0, oy: 0) sprite_stack.push(x, y, bmp, *args, rect: rect, type: type, ox: ox, oy: oy) end |
#sprite_stack ⇒ SpriteStack
Return the sprite stack used by the window
83 84 85 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00200 Window.rb', line 83 def sprite_stack @stack ||= SpriteStack.new(self) end |
#stack ⇒ Array
Return the stack of the window if any
77 78 79 |
# File 'scripts/01450 Systems/00000 General/00100 UI Generics/00200 Window.rb', line 77 def stack return (@stack&.stack || []) end |