├── presentation
├── readme.md
├── fony1.png
├── fony2.png
├── fony3.png
├── fony4.png
├── fony5.png
├── fony6.png
├── fony9.gif
├── exemple1.png
├── exemple2.png
├── exemple3.png
├── exemple4.png
├── exemple5.png
├── exemple6.png
├── exemple7.png
└── exemple8.png
├── Font.png
├── Bilou2k3.fon
├── Font_color.png
├── LICENSE
├── README.md
└── orms.rb
/presentation/readme.md:
--------------------------------------------------------------------------------
1 | images pour présentation
2 |
--------------------------------------------------------------------------------
/Font.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/Font.png
--------------------------------------------------------------------------------
/Bilou2k3.fon:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/Bilou2k3.fon
--------------------------------------------------------------------------------
/Font_color.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/Font_color.png
--------------------------------------------------------------------------------
/presentation/fony1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/fony1.png
--------------------------------------------------------------------------------
/presentation/fony2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/fony2.png
--------------------------------------------------------------------------------
/presentation/fony3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/fony3.png
--------------------------------------------------------------------------------
/presentation/fony4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/fony4.png
--------------------------------------------------------------------------------
/presentation/fony5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/fony5.png
--------------------------------------------------------------------------------
/presentation/fony6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/fony6.png
--------------------------------------------------------------------------------
/presentation/fony9.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/fony9.gif
--------------------------------------------------------------------------------
/presentation/exemple1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/exemple1.png
--------------------------------------------------------------------------------
/presentation/exemple2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/exemple2.png
--------------------------------------------------------------------------------
/presentation/exemple3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/exemple3.png
--------------------------------------------------------------------------------
/presentation/exemple4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/exemple4.png
--------------------------------------------------------------------------------
/presentation/exemple5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/exemple5.png
--------------------------------------------------------------------------------
/presentation/exemple6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/exemple6.png
--------------------------------------------------------------------------------
/presentation/exemple7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/exemple7.png
--------------------------------------------------------------------------------
/presentation/exemple8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RMEx/orms/HEAD/presentation/exemple8.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 RMEx
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [Join us on Discord!](https://discord.gg/yRUZcdQ)
2 |
3 | # [](http://rmex.github.io) [ORMS : Old RPG Maker Style](https://github.com/RMEx/orms/blob/master/orms.rb) v1.1.4
4 | > Make a RM2K(3)-like game with RMVXAce!
5 |
6 | 
7 |
8 | ***
9 |
10 | # Installation
11 |
12 | orms holds in one script and two resources (Font.png and Font_color.png)
13 | Check-out the [lastest release!](https://github.com/RMEx/orms/releases/latest)
14 |
15 | ---
16 |
17 | # Configuration
18 |
19 | OLD_RM_STYLE is really versatile, see the first module **ORMS_CONFIG** in the script to configure it!
20 | **All the features are optional**, just activate the features you want, deactivate the features you don't, and... *enjoy!*
21 |
22 | ---
23 |
24 | # Features
25 |
26 | ## BITMAP_FONT
27 |
28 | Use the bitmaps **Font** and **Font_color** to draw texts
29 |
30 | Image name | Example
31 | --- | ---
32 | Font.png | 
33 | Font_color.png | 
34 |
35 | ## BITMAP_FONT OPTIONS:
36 | Option | Description | Default value
37 | --- | --- | ---
38 | **FONT_WIDTH
FONT HEIGHT** | The character size of your font bitmap | 6 x 14
39 | **DOUBLE_FONT_SIZE** | Double the size of the bitmap font/text | true
40 | **LINE_HEIGHT** | Change the line height | 32
41 | **PADDING** | Change the padding of the message and battle windows | 16
42 | **SHADOW** | Draw text shadow using the last color in "Font_color.png" | true
43 | **REWRITE_ALL_TEXTS** | Rewrite Bitmap.draw_text instead of Window_Base.draw_text | true
44 |
45 | ## BOX_FEATURES:
46 | Feature | Description | Default value
47 | --- | --- | ---
48 | **OPAQUE_BOX** | Opaque text box if true | false
49 | **STOP_CURSOR_BLINKING** | Stop cursor blinking if true | true
50 | **OLDSCHOOL_CHOICE_LIST** | RM2K(3)-like choice list like if true | true
51 |
52 | ## SCREEN_FEATURES:
53 | Feature | Description | Default value
54 | --- | --- | ---
55 | **OLD_RESOLUTION** | Just set game resolution to 640*480 (to simulate RM2k(3)'s 320*240) | false
56 | **[NEW!] TOGGLE_FULLSCREEN** | The shortcut (:F3..:F11) to toggle the fullscreen mode like RM2k(3).
Set the shortcut to 0 if you want none. | :F4
57 | **[NEW!] TOGGLE_WINDOW_MODE** | The shortcut (:F3..:F11) to toggle to TINY 1x WINDOW MODE like RM2k(3).
Set the shortcut to 0 if you want none. | :F5
58 | **PIXELATE_SCREEN** | If you want fat pixels everywhere!
This feature is a bit greedy, but it tries to optimize itself with a custom frame skipping method.
This feature activate a custom FPS display (F2) that shows the real FPS, counting the frame skipping. | false
59 | **[NEW!] PIXELATION_SHORTCUT** | The shortcut (:F3..:F11) to activate/deactivate pixelation ingame.
Set the shortcut to 0 if you want none.
Don't forget to tell the player he can use this shortcut! An alternative is to use the `Orms.set(:pixelate_screen, false)` method. | :F6
60 |
61 | ### NOTE:
62 | **TOGGLE_FULLSCREEN** and **TOGGLE_WINDOW_MODE** re-define also the Fullscreen++ shortcuts if you use it too. If you use Fullscreen++, place Fullscreen++ right before orms!
63 |
64 | [Get Fullscreen++](https://forums.rpgmakerweb.com/index.php?threads/fullscreen.14081/)
65 |
66 | ## RESSOURCES_FEATURES:
67 | Use these features if you want to directly use RM2k(3) ressources!
68 |
69 | Feature | Description | Default value
70 | --- | --- | ---
71 | **USE_OLD_RM_BACKDROP** | Battlebacks1/2 auto-resized by two | false
72 | **USE_OLD_RM_MONSTER** | Battlers auto-resized by two | false
73 | **USE_OLD_RM_PANORAMA** | Parallaxes auto-resized by two | false
74 | **USE_OLD_RM_PICTURE** | Pictures auto-resized by two | false
75 | **USE_OLD_RM_TITLE** | Titles1/2 auto-resized by two | false
76 | **USE_OLD_RM_CHARSET** | Characters auto-resized by two | false
77 | **[NEW!] BACKDROP_ALIGN_TOP** | Align Battlebacks to top instead of center (for RM2K backdrops) | false
78 | **KILL_CHARSET_SHIFT_Y** | Does as if all "Characters" had "!" in their name | false
79 | **OLD_CHARSET_DIRECTION** | In VXAce's ressources, directions are "DOWN, LEFT, RIGHT, UP" but in RM2k(3)'s ressources, it's "UP, RIGHT, DOWN, LEFT"
this fix allows you to use directly charsets from 2k(3)! | false
80 |
81 | ## DESTROY_NEW_RM_FEATURE:
82 | Feature | Description | Default value
83 | --- | --- | ---
84 | **DEACTIVATE_DASH** | No dash when you press shift if true | false
85 |
86 | ---
87 |
88 | # [NEW!] Ingame methods for users
89 |
90 | Method | Description
91 | --- | ---
92 | `Orms.set(feature, false)` | Change the features ingame! Example: `Orms.set(:bitmap_font, false)`
93 | `Orms.deactivate` | Deactivate all the features
94 | `Orms.activate` | Activate all the features
95 |
96 | ---
97 |
98 | # Examples
99 |
100 | 
101 | 
102 |
103 | > Example of the **OLDSCHOOL_CHOICE_LIST** and **TOGGLE_WINDOW_MODE** features
104 |
105 | 
106 |
107 | > Example of the **DOUBLE_FONT_SIZE** feature (false)
108 |
109 | 
110 |
111 | > Example of the default menu displayed with the **BITMAP_FONT** feature
112 |
113 | 
114 | 
115 | 
116 |
117 | > Examples of a game using orms and Luna Engine (by **JosephSeraph**)
118 |
119 | 
120 |
121 | > Example of a **beautiful customized** bitmap font (by **JosephSeraph**)
122 |
123 | ---
124 |
125 | # HOW TO MAKE YOUR OWN AWESOME BITMAP FONT
126 |
127 | The **Font.png** is generated by the awesome tool [Fony](https://fony.en.softonic.com/#app-softonic-review)
128 |
129 | For example :
130 |
131 | 1. load "Bilou2k3.fon" with Fony
132 |
133 | 
134 |
135 | 2. Use **Edit > resize** to make a smaller font in height
136 |
137 | 
138 |
139 | 
140 |
141 | 3. Use **Edit > Boldify**... why not?
142 |
143 | 
144 |
145 | After that you need to have **all the bottom line transparent** for all the characters, to render the text shadow without trouble after
146 |
147 | 4. Select all the characters in the right pannel
148 |
149 | 
150 |
151 | 5. Then press the **"up"** button
152 |
153 | 
154 |
155 | **NOTE :** You also need to have **all the right column transparent** for all the characters, to render the text shadow without trouble!
156 |
157 | Use the same method as above, but with the **"left"** button!
158 |
159 | 6. Save your new font, and do **File > Export > Bitmap**, save as "Font.png" in `Graphics/System/`
160 |
161 | Then you get A SHINY PERFECT NEW "FONT.PNG" YOU CAN EDIT BACK WITH FONY ULTRA QUICKLY ANYTIME!!
162 |
163 | 
164 |
165 | Instead of **6\*14** like RM200(3), this one is **7\*11** (just count the pixels in Fony), you can specify that in my script :
166 |
167 | ```
168 | # BITMAP_FONT_FEATURE_OPTIONS:
169 | FONT_WIDTH = 7 # See BMP Font character's width
170 | FONT_HEIGHT = 11 # See BMP Font character's height
171 | ```
172 | instead of :
173 | ```
174 | # BITMAP_FONT_FEATURE_OPTIONS:
175 | FONT_WIDTH = 6 # See BMP Font character's width
176 | FONT_HEIGHT = 14 # See BMP Font character's height
177 | ```
178 |
179 | And since the height is now smaller, you can also reduce the line height :
180 | ```
181 | LINE_HEIGHT = 24 # Line height: VXAce: 24 2K(3): 32
182 | ```
183 |
184 | ---
185 |
186 | # CUSTOM FONT ISSUES WITH FONY
187 |
188 | Of course you can edit the font you want with Fony, ".fon" or not. But there is some important things to verify before the bitmap exportation!
189 |
190 | * You **must** have a **blank row** at the bottom and a **blank column** at the right:
191 |
192 | 
193 |
194 | If not, just **select all the characters** into the right pannel and use the **arrow buttons**.
195 |
196 | * In **Edit > Properties** (Ctrl + H), you **must** set the **First char** to 0, the **Last char** to 255, and check **Monospaced**:
197 |
198 | 
199 |
200 | **If you get a too wide character width** when you convert the font to **monospaced**, it's because some characters are too wide like W, w, M, m, Æ, æ.
201 | There is a very simple method to **reduce the width of all characters at one time**:
202 |
203 | 
204 |
205 | When you have an accurate monospaced width, you can stretch manually the cropped fonts that were too wide (like W, w, M, m, Æ, æ) by redrawing them.
206 |
207 | ---
208 |
209 | # COMING SOON!
210 |
211 | **TODO LIST:**
212 |
213 | - [x] **Verify/fix** compatibility between `PIXELATE_SCREEN` and some nervous scripts
214 | - [x] RME (camera commands)
215 | - [x] Luna Engine
216 | - [ ] Theo's Sideview battle system
217 | - [ ] MGC's mode 7
218 | - [x] **Fix** name input
219 | - [ ] **Fix** current feature status not saved in save files yet
220 | - [ ] **Fix** characters direction in save/load menus (when `OLD_CHARSET_DIRECTION` is used)
221 | - [ ] **Add** the feature `NO_MAP_SHADOWS` in `DESTROY_NEW_RM_FEATURES` to deactivate the VXA shadow display in maps ingame
222 | - [ ] **Extend** `OLD_CHARSET_DIRECTION` behaviour: Will not change the directions of the Characters that the first character of their names is `'@'`.
223 | - [ ] **Implement** `ICONS_FOR_ALL_TEXTS` feature to use the `\I[id]` control character for everything like RM2K(3) did with glyphs ($a..$Z)
224 | - [ ] **Implement** `BITMAP_FONT_FEATURE_OPTIONS`:
225 | - [ ] **Define** `BITMAP_FONTS = [args_1, args_2, args_3]` option with `args_X` equal to `[name, *char_width, *char_height, *color_set, *nb_color_max, *shadow]`, for instance, `args_1` will be equal to `["Font"]` (The default font name)
226 | - [ ] **Define** `CURRENT_BMP_FONT`, `DEFAULT_COLOR_SET`, `DEFAULT_FONT_WIDTH`, `DEFAULT_FONT_HEIGHT`, `DEFAULT_SHADOW` options (the last three will replace `FONT_WIDTH`, `FONT_HEIGHT` and `SHADOW`)
227 | - [ ] **Define** `\F[id]` control character to change the BMP\_FONT in the middle of **any** text
228 | - [ ] **Extend** `LINE_HEIGHT` behaviour: will be defined by an integer (like now) or the array `[top_margin, bottom_margin]` instead.
229 | For instance, `LINE_HEIGHT` will be equal to `LINE_HEIGHT[0] + font[:height] + LINE_HEIGHT[1]`).
230 | - [ ] **Implement** RM2k(3)-like **transitions** features and methods that reproduce and extend all transitions behaviours from RM2k(3)! :D
231 | - [ ] **Implement** `OLD_RM_CURSOR` feature (use a second System/Window picture to make oldschool blink like RM2k(3) (graphical switch blinking)) - Will replace the actual `STOP_CURSOR_BLINKING`
232 | - [ ] **Develop** [orms-converter](https://github.com/RMEx/orms-converter)
233 | - [ ] **Sleep**
234 | - [ ] **Any suggestion? ...Bug report?** Feel free to [create an issue](https://github.com/RMEx/orms-converter/issues) or contact me [on Discord!](https://discord.gg/yRUZcdQ)
235 |
--------------------------------------------------------------------------------
/orms.rb:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | #==============================================================================
3 | # ** OLD_RM_STYLE v1.1.4
4 | #------------------------------------------------------------------------------
5 | # By Joke @biloumaster
6 | # GitHub: https://github.com/RMEx/OLD_RM_STYLE
7 | #------------------------------------------------------------------------------
8 | # Make a RM2K(3)-like game with RMVXAce!
9 | # (or the oldschool overkill game that you dreamed for a long time)
10 | # See the "ORMS_CONFIG" module below to see all the features and configure it!
11 | # Go on the GitHub page to learn more about the bitmap fonts and the features!
12 | #==============================================================================
13 |
14 | #==============================================================================
15 | # ** CONFIGURATION
16 | #==============================================================================
17 |
18 | unless Module.const_defined?(:ORMS_CONFIG)
19 |
20 | module ORMS_CONFIG
21 |
22 | # BITMAP_FONT_FEATURE:
23 | BITMAP_FONT = true # Use the bitmap font picture to draw texts if true
24 |
25 | # BITMAP_FONT_FEATURE_OPTIONS:
26 | FONT_WIDTH = 6 # See BMP Font character's width
27 | FONT_HEIGHT = 14 # See BMP Font character's height
28 | DOUBLE_FONT_SIZE = true # Double the BMP Font Size if true
29 | LINE_HEIGHT = 32 # Line height: VXAce: 24 2K(3): 32
30 | PADDING = 16 # Padding: VXAce: 12 2K(3): 16
31 | SHADOW = true # Draw text shadow using the last color in "Font_color.png"
32 | REWRITE_ALL_TEXTS = true # Rewrite Bitmap.draw_text instead of Window_Base.draw_text
33 |
34 | # BOX_FEATURES:
35 | OPAQUE_BOX = false # Opaque text box if true
36 | STOP_CURSOR_BLINKING = true # Stop cursor blinking if true
37 | OLDSCHOOL_CHOICE_LIST = true # RM2K(3)-like choice list like if true
38 |
39 | # SCREEN_FEATURES:
40 | OLD_RESOLUTION = false # Just set game resolution to 640*480 (to simulate RM2k(3)'s 320*240)
41 | TOGGLE_FULLSCREEN = :F4 # The shortcut (:F3..:F11) to toggle the fullscreen mode like RM2k(3)
42 | TOGGLE_WINDOW_MODE = :F5 # The shortcut (:F3..:F11) to toggle to TINY 1x WINDOW MODE like RM2k(3)
43 | # Re-define also the Fullscreen++ shortcuts if you use it too.
44 | # If you use Fullscreen++, place Fullscreen++ right before orms!
45 | #
46 | # => Set the shortcut to 0 if you don't want the feature
47 |
48 | PIXELATE_SCREEN = false # If you want fat pixels everywhere!
49 | # This feature is a bit greedy, but it tries to optimize itself with
50 | # a custom frame skipping method. This feature activate a custom FPS
51 | # display (F2) that shows the real FPS, counting the frame skipping.
52 |
53 | PIXELATION_SHORTCUT = :F6 # The shortcut (:F3..:F11) to activate/deactivate pixelation ingame.
54 | # Don't forget to tell the player he can use this shortcut!
55 | # An alternative is to use the "Orms.set(:pixelate_screen, false)" method
56 | #
57 | # => Set the shortcut to 0 if you don't want the feature
58 |
59 | # RESSOURCES_FEATURES:
60 | USE_OLD_RM_BACKDROP = false # Battlebacks1/2 auto-resized by two
61 | USE_OLD_RM_MONSTER = false # Battlers auto-resized by two
62 | USE_OLD_RM_PANORAMA = false # Parallaxes auto-resized by two
63 | USE_OLD_RM_PICTURE = false # Pictures auto-resized by two
64 | USE_OLD_RM_TITLE = false # Titles1/2 auto-resized by two
65 | USE_OLD_RM_CHARSET = false # Characters auto-resized by two
66 | BACKDROP_ALIGN_TOP = false # Align Battlebacks to top instead of center (for RM2K backdrops)
67 | KILL_CHARSET_SHIFT_Y = false # Does as if all "Characters" had "!" in their name
68 | OLD_CHARSET_DIRECTION = false # In VXAce's ressources, directions are "DOWN, LEFT, RIGHT, UP"
69 | # but in RM2k(3)'s ressources, it's "UP, RIGHT, DOWN, LEFT"
70 | # this fix allows you to use directly charsets from 2k(3)!
71 | # DESTROY_NEW_RM_FEATURE:
72 | DEACTIVATE_DASH = false # No dash when you press shift if true
73 |
74 | end
75 |
76 | end
77 |
78 | #==============================================================================
79 | # ** Additional methods for the user:
80 | #------------------------------------------------------------------------------
81 | # - Orms.set(feature, state) # Change the orms' features state when you want
82 | # (example: Orms.set(:bitmap_font, false))
83 | # - Orms.deactivate # Deactivate all orms' features when you want
84 | # - Orms.activate # Reactivate all orms' features when you want
85 | # - Orms.active? # Check if orms is active
86 | # - Orms.active?(feature) # Check if orms and the given feature are active
87 | # (example: Orms.active?(:pixelate_screen))
88 | #==============================================================================
89 |
90 | module Orms
91 | extend self
92 | #--------------------------------------------------------------------------
93 | # * Change the orms' features state when you want
94 | #--------------------------------------------------------------------------
95 | def set(feature, state)
96 | feature = feature.to_s.upcase.to_sym
97 | ORMS_CONFIG.const_set(feature, state)
98 | if Graphics.respond_to?(:orms_screen) && [feature, state] == [:PIXELATE_SCREEN, false]
99 | Graphics.orms_screen.dispose unless Graphics.orms_screen.nil?
100 | end
101 | if SceneManager.scene.is_a?(Scene_Map) || SceneManager.scene.is_a?(Scene_Battle)
102 | if [:BITMAP_FONT, :LINE_HEIGHT, :PADDING].include?(feature)
103 | SceneManager.scene.create_all_windows
104 | end
105 | end
106 | end
107 | #--------------------------------------------------------------------------
108 | # * Deactivate all orms' features when you want
109 | #--------------------------------------------------------------------------
110 | def deactivate
111 | @active = false
112 | if Graphics.respond_to?(:orms_screen) && Graphics.orms_screen
113 | Graphics.orms_screen.dispose
114 | end
115 | if SceneManager.scene.is_a?(Scene_Map) || SceneManager.scene.is_a?(Scene_Battle)
116 | SceneManager.scene.create_all_windows
117 | end
118 | end
119 | #--------------------------------------------------------------------------
120 | # * Reactivate all orms' features when you want
121 | #--------------------------------------------------------------------------
122 | def activate
123 | @active = true
124 | end
125 | #--------------------------------------------------------------------------
126 | # * Check if orms and the given feature are active
127 | #--------------------------------------------------------------------------
128 | def active?(feature = true)
129 | @active = true if @active.nil?
130 | if feature.is_a?(Symbol)
131 | feature = feature.upcase
132 | feature = ORMS_CONFIG.const_get(feature)
133 | end
134 | @active && feature
135 | end
136 | end
137 |
138 | #==============================================================================
139 | # ** BITMAP_FONT cache and USE_OLD_RM_*
140 | #------------------------------------------------------------------------------
141 | # BITMAP_FONT: Use the bitmap font picture to draw texts
142 | # USE_OLD_RM_*: See ORMS_CONFIG > RESSOURCES_FEATURES above
143 | #==============================================================================
144 |
145 | #==============================================================================
146 | # ** Cache
147 | #------------------------------------------------------------------------------
148 | # This module loads graphics, creates bitmap objects, and retains them.
149 | # Now it can double the size of bitmaps specified in ORMS_CONFIG at loading
150 | # and it generates and retains the BITMAP_FONT
151 | #==============================================================================
152 |
153 | module Cache
154 | #--------------------------------------------------------------------------
155 | # * Singleton
156 | #--------------------------------------------------------------------------
157 | class << self
158 | #--------------------------------------------------------------------------
159 | # * Generate Bitmap Font
160 | #--------------------------------------------------------------------------
161 | def generate_bitmap_font
162 | mask = Bitmap.new("Graphics/System/Font")
163 | color_set = Bitmap.new("Graphics/System/Font_color")
164 | bmp_font = Bitmap.new(mask.width, mask.height * 32)
165 | # draw shadow
166 | if ORMS_CONFIG::SHADOW
167 | shadow_color = color_set.get_pixel(127, 63)
168 | shadow = Bitmap.new(mask.width, mask.height)
169 | shadow.height.times do |y|
170 | shadow.width.times do |x|
171 | if mask.get_pixel(x, y).red == 255
172 | shadow.set_pixel(x, y, shadow_color)
173 | end
174 | end
175 | end
176 | 32.times do |i|
177 | bmp_font.blt(1, i * mask.height + 1, shadow, mask.rect)
178 | end
179 | end
180 | # draw font
181 | mask.height.times do |y|
182 | mask.width.times do |x|
183 | if mask.get_pixel(x, y).red == 255
184 | 32.times do |i|
185 | xc = i % 8 * 16 + x % ORMS_CONFIG::FONT_WIDTH
186 | yc = i / 8 * 16 + y
187 | bmp_font.set_pixel(x, y + i * mask.height, color_set.get_pixel(xc, yc))
188 | end
189 | end
190 | end
191 | end
192 | bmp_font
193 | end
194 | #--------------------------------------------------------------------------
195 | # * Get Bitmap Font
196 | #--------------------------------------------------------------------------
197 | def bitmap_font
198 | if @cache[:bitmap_font] && @cache[:bitmap_font].disposed?
199 | @cache[:bitmap_font] = generate_bitmap_font
200 | end
201 | @cache[:bitmap_font] ||= generate_bitmap_font
202 | end
203 | #--------------------------------------------------------------------------
204 | # * Load Bitmap
205 | #--------------------------------------------------------------------------
206 | alias_method :orms_load_bitmap, :load_bitmap
207 | def load_bitmap(*args)
208 | case args[0]
209 | when "Graphics/Battlebacks1/", "Graphics/Battlebacks2/"
210 | return load_2k_bitmap(*args) if ORMS_CONFIG::USE_OLD_RM_BACKDROP
211 | when "Graphics/Battlers/"
212 | return load_2k_bitmap(*args) if ORMS_CONFIG::USE_OLD_RM_MONSTER
213 | when "Graphics/Characters/"
214 | return load_2k_bitmap(*args) if ORMS_CONFIG::USE_OLD_RM_CHARSET
215 | when "Graphics/Parallaxes/"
216 | return load_2k_bitmap(*args) if ORMS_CONFIG::USE_OLD_RM_PANORAMA
217 | when "Graphics/Pictures/"
218 | return load_2k_bitmap(*args) if ORMS_CONFIG::USE_OLD_RM_PICTURE
219 | when "Graphics/Titles1/", "Graphics/Titles2/"
220 | return load_2k_bitmap(*args) if ORMS_CONFIG::USE_OLD_RM_TITLE
221 | end
222 | orms_load_bitmap(*args)
223 | end
224 | #--------------------------------------------------------------------------
225 | # * Load Bitmap to be resized by two
226 | #--------------------------------------------------------------------------
227 | def load_2k_bitmap(folder_name, filename, hue = 0)
228 | return load_bitmap(folder_name, filename, hue) unless Orms.active?
229 | @cache ||= {}
230 | if filename.empty?
231 | empty_bitmap
232 | elsif hue == 0
233 | normal_2k_bitmap(folder_name + filename)
234 | else
235 | hue_changed_2k_bitmap(folder_name + filename, hue)
236 | end
237 | end
238 | #--------------------------------------------------------------------------
239 | # * Create/Get Normal Bitmap resized by two
240 | #--------------------------------------------------------------------------
241 | def normal_2k_bitmap(path)
242 | unless include?(path)
243 | bmp = Bitmap.new(path)
244 | @cache[path] = Bitmap.new(bmp.width*2, bmp.height*2)
245 | @cache[path].stretch_blt(@cache[path].rect, bmp, bmp.rect)
246 | bmp.dispose
247 | end
248 | @cache[path]
249 | end
250 | #--------------------------------------------------------------------------
251 | # * Create/Get Hue-Changed Bitmap resized by two
252 | #--------------------------------------------------------------------------
253 | def hue_changed_2k_bitmap(path, hue)
254 | key = [path, hue]
255 | unless include?(key)
256 | bmp = Bitmap.new(path)
257 | bmp.hue_change(hue)
258 | @cache[key] = Bitmap.new(bmp.width*2, bmp.height*2)
259 | @cache[key].stretch_blt(@cache[key].rect, bmp, bmp.rect)
260 | bmp.dispose
261 | end
262 | @cache[key]
263 | end
264 | end
265 | end
266 |
267 | if ORMS_CONFIG::BACKDROP_ALIGN_TOP
268 | #==============================================================================
269 | # ** Spriteset_Battle
270 | #==============================================================================
271 |
272 | class Spriteset_Battle
273 | #--------------------------------------------------------------------------
274 | # * Move Sprite to Screen Center
275 | #--------------------------------------------------------------------------
276 | def center_sprite(sprite)
277 | sprite.ox = sprite.bitmap.width / 2
278 | sprite.x = Graphics.width / 2
279 | end
280 | end
281 | end
282 |
283 | #==============================================================================
284 | # ** BITMAP_FONT
285 | #------------------------------------------------------------------------------
286 | # Use the bitmap font picture to draw texts
287 | #==============================================================================
288 |
289 | #==============================================================================
290 | # ** ORMS_Bitmap_Font
291 | #------------------------------------------------------------------------------
292 | # This module writes texts using Cache.bitmap_font.
293 | # It extends the behaviour of Window_Base if REWRITE_ALL_TEXTS is FALSE
294 | # It extends the behaviour of Bitmap class if REWRITE_ALL_TEXTS is TRUE
295 | #==============================================================================
296 |
297 | module ORMS_Bitmap_Font
298 | #--------------------------------------------------------------------------
299 | # * Singleton
300 | #--------------------------------------------------------------------------
301 | class << self
302 | #--------------------------------------------------------------------------
303 | # * Included
304 | #--------------------------------------------------------------------------
305 | def included(base)
306 | base.class_eval do
307 | #--------------------------------------------------------------------------
308 | # * Get Text Size
309 | #--------------------------------------------------------------------------
310 | def text_size(str)
311 | return orms_text_size(str) unless Orms.active?(:bitmap_font)
312 | s = ORMS_CONFIG::DOUBLE_FONT_SIZE ? 2 : 1
313 | w = ORMS_CONFIG::FONT_WIDTH
314 | h = ORMS_CONFIG::FONT_HEIGHT
315 | return Rect.new(0, 0, s * w, s * h) unless str
316 | Rect.new(0, 0, s * w * str.length, s * h)
317 | end
318 | #--------------------------------------------------------------------------
319 | # * Draw Text
320 | #--------------------------------------------------------------------------
321 | def draw_text(*args)
322 | unless Orms.active?(:bitmap_font)
323 | args.pop if args.length == 4 || args.length == 7
324 | return orms_draw_text(*args)
325 | end
326 | if args.length.between?(2,4)
327 | x, y, width, text = args[0].x, args[0].y, args[0].width, args[1].to_s.clone
328 | align = args[2] || 0
329 | color_id = args[3] || @color_id || 0
330 | else
331 | x, y, width, text = args[0], args[1], args[2], args[4].to_s.clone
332 | align = args[5] || 0
333 | color_id = args[6] || @color_id || 0
334 | end
335 | if align == 1
336 | x = x + (width - text_size(text).width) / 2
337 | end
338 | if align == 2
339 | x = x + width - text_size(text).width
340 | end
341 | until text.empty?
342 | draw_char(text.slice!(0, 1), x, y, color_id)
343 | x += ORMS_CONFIG::FONT_WIDTH * (ORMS_CONFIG::DOUBLE_FONT_SIZE ? 2 : 1)
344 | end
345 | end
346 | #--------------------------------------------------------------------------
347 | # * Draw One Character
348 | #--------------------------------------------------------------------------
349 | def draw_char(char, x, y, color_id = 0)
350 | s = ORMS_CONFIG::DOUBLE_FONT_SIZE ? 2 : 1
351 | w = ORMS_CONFIG::FONT_WIDTH
352 | h = ORMS_CONFIG::FONT_HEIGHT
353 | bmp = Cache.bitmap_font
354 | char = 1 if char.ord > bmp.width / w - 1
355 | dest = Rect.new(x, y, w * s, h * s)
356 | src = Rect.new(char.ord * w, color_id * h, w, h)
357 | if ORMS_CONFIG::REWRITE_ALL_TEXTS
358 | stretch_blt(dest, bmp, src)
359 | else
360 | contents.stretch_blt(dest, bmp, src)
361 | end
362 | end
363 | end
364 | end
365 | end
366 | end
367 |
368 | #==============================================================================
369 | # ** ORMS_Bitmap
370 | #------------------------------------------------------------------------------
371 | # can draw with the bitmap font!
372 | #==============================================================================
373 |
374 | class ORMS_Bitmap < Bitmap
375 | alias_method :orms_draw_text, :draw_text
376 | alias_method :orms_text_size, :text_size
377 | include ORMS_Bitmap_Font
378 | end
379 |
380 | if ORMS_CONFIG::BITMAP_FONT
381 |
382 | #==============================================================================
383 | # ** Window_Base
384 | #==============================================================================
385 |
386 | class Window_Base
387 | #--------------------------------------------------------------------------
388 | # * Get Text Color
389 | #--------------------------------------------------------------------------
390 | def text_color(n)
391 | @color_id = n
392 | windowskin.get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8)
393 | end
394 | #--------------------------------------------------------------------------
395 | # * Draw Text
396 | #--------------------------------------------------------------------------
397 | alias_method :orms_draw_text, :draw_text
398 | def draw_text(*args)
399 | return orms_draw_text(*args) unless Orms.active?(:bitmap_font)
400 | args.push(0) if args.length == 2 || args.length == 5
401 | args.push(@color_id)
402 | contents.draw_text(*args)
403 | end
404 | #--------------------------------------------------------------------------
405 | # * Get Text Colors
406 | #--------------------------------------------------------------------------
407 | def system_color; text_color(6); end; # System
408 | def crisis_color; text_color(4); end; # Crisis
409 | def knockout_color; text_color(11); end; # Knock out
410 | def mp_cost_color; text_color(10); end; # MP cost
411 | def power_up_color; text_color(9); end; # Equipment power up
412 | def power_down_color; text_color(11); end; # Equipment power down
413 | def tp_cost_color; text_color(9); end; # TP cost
414 | #--------------------------------------------------------------------------
415 | # * Change Text Drawing Color
416 | #--------------------------------------------------------------------------
417 | alias_method :orms_change_color, :change_color
418 | def change_color(color, enabled = true)
419 | return orms_change_color(color, enabled) unless Orms.active?(:bitmap_font)
420 | contents.font.color.set(enabled ? color : text_color(3))
421 | end
422 | #--------------------------------------------------------------------------
423 | # * Calculate Line Height
424 | #--------------------------------------------------------------------------
425 | alias_method :orms_calc_line_height, :calc_line_height
426 | def calc_line_height(text, restore_font_size = true)
427 | unless Orms.active?(:bitmap_font)
428 | return orms_calc_line_height(text, restore_font_size)
429 | end
430 | line_height
431 | end
432 | #--------------------------------------------------------------------------
433 | # * Get Line Height
434 | #--------------------------------------------------------------------------
435 | alias_method :orms_line_height, :line_height
436 | def line_height
437 | return orms_line_height unless Orms.active?(:bitmap_font)
438 | ORMS_CONFIG::LINE_HEIGHT
439 | end
440 | end
441 |
442 | #==============================================================================
443 | # ** REWRITE ALL TEXTS or Window_Base only
444 | #==============================================================================
445 |
446 | if ORMS_CONFIG::REWRITE_ALL_TEXTS
447 | class Bitmap
448 | alias_method :orms_draw_text, :draw_text
449 | alias_method :orms_text_size, :text_size
450 | end
451 | Bitmap.send(:include, ORMS_Bitmap_Font)
452 | else
453 | Window_Base.send(:include, ORMS_Bitmap_Font)
454 | end
455 |
456 | #==============================================================================
457 | # ** Window_NameEdit
458 | #==============================================================================
459 |
460 | class Window_NameEdit
461 | #--------------------------------------------------------------------------
462 | # * Get Line Height
463 | #--------------------------------------------------------------------------
464 | def line_height
465 | 24
466 | end
467 | end
468 |
469 | #==============================================================================
470 | # ** Window_NameInput
471 | #==============================================================================
472 |
473 | class Window_NameInput
474 | #--------------------------------------------------------------------------
475 | # * Write "Pge" instead of "Page"
476 | #--------------------------------------------------------------------------
477 | LATIN1[88] = 'Nx'
478 | LATIN2[88] = 'Pr'
479 | #--------------------------------------------------------------------------
480 | # * Get Line Height
481 | #--------------------------------------------------------------------------
482 | def line_height
483 | 24
484 | end
485 | end
486 |
487 | #==============================================================================
488 | # ** Window_EquipStatus
489 | #==============================================================================
490 |
491 | class Window_EquipStatus
492 | #--------------------------------------------------------------------------
493 | # * Draw Right Arrow
494 | #--------------------------------------------------------------------------
495 | def draw_right_arrow(x, y)
496 | change_color(system_color)
497 | draw_text(x, y, 22, line_height, " >", 1)
498 | end
499 | end
500 |
501 | #==============================================================================
502 | # ** Window_Message
503 | #==============================================================================
504 |
505 | class Window_Message
506 | #--------------------------------------------------------------------------
507 | # * Draw Face Graphic
508 | #--------------------------------------------------------------------------
509 | alias_method :orms_draw_face, :draw_face
510 | def draw_face(*args)
511 | return orms_draw_face(*args) unless Orms.active?(:bitmap_font)
512 | args[2] = args[3] = (contents_height - 96) / 2
513 | orms_draw_face(*args)
514 | end
515 | #--------------------------------------------------------------------------
516 | # * Get New Line Position
517 | #--------------------------------------------------------------------------
518 | alias_method :orms_new_line_x, :new_line_x
519 | def new_line_x
520 | return orms_new_line_x unless Orms.active?(:bitmap_font)
521 | x = [96, height - standard_padding].max
522 | $game_message.face_name.empty? ? 0 : x
523 | end
524 | #--------------------------------------------------------------------------
525 | # * Get Standard Padding Size
526 | #--------------------------------------------------------------------------
527 | alias_method :orms_standard_padding, :standard_padding
528 | def standard_padding
529 | return orms_standard_padding unless Orms.active?(:bitmap_font)
530 | ORMS_CONFIG::PADDING
531 | end
532 | end
533 | class Window_ActorCommand
534 | alias_method :orms_standard_padding, :standard_padding
535 | def standard_padding
536 | return orms_standard_padding unless Orms.active?(:bitmap_font)
537 | ORMS_CONFIG::PADDING
538 | end
539 | end
540 | class Window_BattleStatus
541 | alias_method :orms_standard_padding, :standard_padding
542 | def standard_padding
543 | return orms_standard_padding unless Orms.active?(:bitmap_font)
544 | ORMS_CONFIG::PADDING
545 | end
546 | end
547 | class Window_BattleEnemy
548 | alias_method :orms_standard_padding, :standard_padding
549 | def standard_padding
550 | return orms_standard_padding unless Orms.active?(:bitmap_font)
551 | ORMS_CONFIG::PADDING
552 | end
553 | end
554 | class Window_PartyCommand
555 | alias_method :orms_standard_padding, :standard_padding
556 | def standard_padding
557 | return orms_standard_padding unless Orms.active?(:bitmap_font)
558 | ORMS_CONFIG::PADDING
559 | end
560 | end
561 |
562 | #==============================================================================
563 | # ** Window_MenuStatus
564 | #==============================================================================
565 |
566 | class Window_MenuStatus
567 | #--------------------------------------------------------------------------
568 | # * Draw Item
569 | #--------------------------------------------------------------------------
570 | alias_method :orms_draw_item, :draw_item
571 | def draw_item(index)
572 | return orms_draw_item(index) unless Orms.active?(:bitmap_font)
573 | actor = $game_party.members[index]
574 | enabled = $game_party.battle_members.include?(actor)
575 | rect = item_rect(index)
576 | draw_item_background(index)
577 | draw_actor_face(actor, rect.x + 1, rect.y + 1, enabled)
578 | draw_actor_simple_status(actor, rect.x + 108, rect.y)
579 | end
580 | end
581 |
582 | #==============================================================================
583 | # ** Window_TitleCommand
584 | #==============================================================================
585 |
586 | class Window_TitleCommand
587 | #--------------------------------------------------------------------------
588 | # * Get Window Width
589 | #--------------------------------------------------------------------------
590 | alias_method :orms_window_width, :window_width
591 | def window_width
592 | return orms_window_width unless Orms.active?(:bitmap_font)
593 | s = ORMS_CONFIG::DOUBLE_FONT_SIZE ? 2 : 1
594 | max = @list.map {|i| i[:name].length * ORMS_CONFIG::FONT_WIDTH * s}.max
595 | max + 2 * standard_padding + 8
596 | end
597 | #--------------------------------------------------------------------------
598 | # * Update Window Position
599 | #--------------------------------------------------------------------------
600 | def update_placement
601 | self.x = (Graphics.width - width) / 2
602 | self.y = 296 * Graphics.height / 480 #RM2k(3) style, OK?
603 | end
604 | end
605 |
606 | end
607 |
608 | #==============================================================================
609 | # ** OPAQUE_BOX
610 | #------------------------------------------------------------------------------
611 | # Opaque text box
612 | #==============================================================================
613 |
614 | if ORMS_CONFIG::OPAQUE_BOX
615 |
616 | #==============================================================================
617 | # ** Window_Base
618 | #==============================================================================
619 |
620 | class Window_Base
621 | #--------------------------------------------------------------------------
622 | # * Object Initialization
623 | #--------------------------------------------------------------------------
624 | alias_method :orms_opaque_initialize, :initialize
625 | def initialize(*args)
626 | orms_opaque_initialize(*args)
627 | self.back_opacity = 255 if Orms.active?(:opaque_box)
628 | end
629 | end
630 |
631 | end
632 |
633 | #==============================================================================
634 | # ** STOP_CURSOR_BLINKING
635 | #------------------------------------------------------------------------------
636 | # Stop cursor blinking
637 | #==============================================================================
638 |
639 | if ORMS_CONFIG::STOP_CURSOR_BLINKING
640 |
641 | #==============================================================================
642 | # ** Window_Selectable
643 | #==============================================================================
644 |
645 | class Window_Selectable
646 | #--------------------------------------------------------------------------
647 | # * The cursor's blink status
648 | #--------------------------------------------------------------------------
649 | alias_method :orms_active, :active
650 | def active
651 | return orms_active unless Orms.active?(:stop_cursor_blinking)
652 | @active
653 | end
654 | alias_method :orms_blink_active, :active=
655 | def active=(index)
656 | return orms_blink_active(index) unless Orms.active?(:stop_cursor_blinking)
657 | orms_blink_active(false)
658 | @active = index
659 | end
660 | end
661 |
662 | end
663 |
664 | #==============================================================================
665 | # ** OLDSCHOOL_CHOICE_LIST
666 | #------------------------------------------------------------------------------
667 | # RM2K(3)-like choice list like
668 | #==============================================================================
669 |
670 | if ORMS_CONFIG::OLDSCHOOL_CHOICE_LIST
671 |
672 | #==============================================================================
673 | # ** Window_Base
674 | #==============================================================================
675 |
676 | class Window_Base
677 | #--------------------------------------------------------------------------
678 | # * Public instance variables
679 | #--------------------------------------------------------------------------
680 | attr_accessor :line_number
681 | #--------------------------------------------------------------------------
682 | # * Object Initialization
683 | #--------------------------------------------------------------------------
684 | alias_method :orms_choice_initialize, :initialize
685 | def initialize(*args)
686 | orms_choice_initialize(*args)
687 | @line_number = 0
688 | end
689 | end
690 |
691 | #==============================================================================
692 | # ** Window_Message
693 | #==============================================================================
694 |
695 | class Window_Message
696 | #--------------------------------------------------------------------------
697 | # * New Page
698 | #--------------------------------------------------------------------------
699 | alias_method :orms_choice_new_page, :new_page
700 | def new_page(text, pos)
701 | orms_choice_new_page(text, pos)
702 | @line_number = text.split("\n").length
703 | end
704 | end
705 |
706 | #==============================================================================
707 | # ** Window_ChoiceList
708 | #==============================================================================
709 |
710 | class Window_ChoiceList
711 | #--------------------------------------------------------------------------
712 | # * Object Initialization
713 | #--------------------------------------------------------------------------
714 | alias_method :oldschool_choice_initialize, :initialize
715 | def initialize(message_window)
716 | oldschool_choice_initialize(message_window)
717 | if Orms.active?(:oldschool_choice_list)
718 | self.windowskin = Cache.system("Window").clone
719 | self.windowskin.fill_rect(Rect.new(0,0,168,64), Color.new(0,0,0,0))
720 | end
721 | end
722 | #--------------------------------------------------------------------------
723 | # * Start Input Processing
724 | #--------------------------------------------------------------------------
725 | alias_method :orms_start, :start
726 | def start
727 | if Orms.active?(:oldschool_choice_list)
728 | if @message_window.openness == 0
729 | @message_window.create_contents
730 | @message_window.line_number = 0
731 | @message_window.open
732 | end
733 | if (@message_window.line_number + $game_message.choices.size >
734 | @message_window.visible_line_number)
735 | @message_window.input_pause
736 | @message_window.new_page("", {x:0, y:0, new_x:0, height:0})
737 | end
738 | end
739 | orms_start
740 | end
741 | #--------------------------------------------------------------------------
742 | # * Update Window Position
743 | #--------------------------------------------------------------------------
744 | alias_method :orms_update_placement, :update_placement
745 | def update_placement
746 | orms_update_placement unless Orms.active?(:oldschool_choice_list)
747 | self.x = @message_window.new_line_x + 6
748 | self.y = @message_window.y + @message_window.line_number * @message_window.line_height
749 | self.width = @message_window.width - self.x - 10
750 | self.height = fitting_height($game_message.choices.size)
751 | self.viewport ||= Viewport.new
752 | self.viewport.z = 200
753 | end
754 | end
755 |
756 | end
757 |
758 | #==============================================================================
759 | # ** OLD_CHARSET_DIRECTION
760 | #------------------------------------------------------------------------------
761 | # In VXAce's ressources, directions are "DOWN, LEFT, RIGHT, UP"
762 | # but in RM2k(3)'s ressources, it's "UP, RIGHT, DOWN, LEFT"
763 | # this fix allows you to use directly charsets from 2k(3)!
764 | #==============================================================================
765 |
766 | if ORMS_CONFIG::OLD_CHARSET_DIRECTION
767 |
768 | #==============================================================================
769 | # ** Sprite_Character
770 | #==============================================================================
771 |
772 | class Sprite_Character
773 | #--------------------------------------------------------------------------
774 | # * Update Transfer Origin Rectangle
775 | #--------------------------------------------------------------------------
776 | alias_method :orms_update_src_rect, :update_src_rect
777 | def update_src_rect
778 | return orms_update_src_rect unless Orms.active?(:old_charset_direction)
779 | if @tile_id == 0
780 | direction = [2, 3, 1, 0][@character.direction / 2 - 1]
781 | index = @character.character_index
782 | pattern = @character.pattern < 3 ? @character.pattern : 1
783 | sx = (index % 4 * 3 + pattern) * @cw
784 | sy = (index / 4 * 4 + direction) * @ch
785 | self.src_rect.set(sx, sy, @cw, @ch)
786 | end
787 | end
788 | end
789 |
790 | #==============================================================================
791 | # ** Game_Event
792 | #==============================================================================
793 |
794 | class Game_Event
795 | #--------------------------------------------------------------------------
796 | # * Set Up Event Page Settings
797 | #--------------------------------------------------------------------------
798 | alias_method :orms_setup_page_setting, :setup_page_settings
799 | def setup_page_settings
800 | orms_setup_page_setting
801 | if Orms.active?(:old_charset_direction)
802 | @original_direction = @direction = [8, 6, 2, 4][@page.graphic.direction / 2 - 1]
803 | end
804 | end
805 | end
806 |
807 | end
808 |
809 | #==============================================================================
810 | # ** KILL_CHARSET_SHIFT_Y
811 | #------------------------------------------------------------------------------
812 | # Does as if all "Characters" had "!" in their name
813 | #==============================================================================
814 |
815 | if ORMS_CONFIG::KILL_CHARSET_SHIFT_Y
816 |
817 | class Game_CharacterBase
818 | alias_method :orms_shift_y, :shift_y
819 | def shift_y
820 | return orms_shift_y unless Orms.active?(:kill_charset_shift_y)
821 | 0
822 | end
823 | end
824 |
825 | end
826 |
827 | #==============================================================================
828 | # ** PIXELATE_SCREEN
829 | #------------------------------------------------------------------------------
830 | # If you want fat pixels everywhere
831 | #==============================================================================
832 |
833 | if ORMS_CONFIG::PIXELATE_SCREEN
834 |
835 | #==============================================================================
836 | # ** ORMS_FPS
837 | #------------------------------------------------------------------------------
838 | # Calculate the FPS of the RGSS processing and the screen refreshing
839 | #==============================================================================
840 |
841 | module ORMS_FPS
842 | extend self
843 | #--------------------------------------------------------------------------
844 | # * Public instance variables
845 | #--------------------------------------------------------------------------
846 | attr_reader :fps, :ups, :ups2, :visible
847 | attr_accessor :previous_time
848 | #--------------------------------------------------------------------------
849 | # * Update rate: Number of times the FPS is calculated per second
850 | #--------------------------------------------------------------------------
851 | UPDATE_RATE = 2.0
852 | #--------------------------------------------------------------------------
853 | # * Update
854 | #--------------------------------------------------------------------------
855 | def update
856 | update_ups
857 | update_ups2
858 | end
859 | #--------------------------------------------------------------------------
860 | # * Graphics.updates per second calculation
861 | #--------------------------------------------------------------------------
862 | def update_ups
863 | @frame_count ||= 0
864 | @frame_count += 1
865 | dt = Time.now - @previous_time
866 | if dt >= 1.0 / UPDATE_RATE
867 | @ups = (@frame_count / dt).round
868 | @ups = [@ups, Graphics.frame_rate + 10].min
869 | update_fps(dt)
870 | @frame_count = 0
871 | @previous_time = Time.now
872 | update_counter
873 | end
874 | end
875 | #--------------------------------------------------------------------------
876 | # * Graphics.updates real time frequency
877 | #--------------------------------------------------------------------------
878 | def update_ups2
879 | @previous_time2 ||= @previous_time
880 | dt = Time.now - @previous_time2
881 | if dt >= 1.0 / Graphics.frame_rate
882 | @ups2 = (1.0 / dt).round
883 | @previous_time2 = Time.now
884 | end
885 | end
886 | #--------------------------------------------------------------------------
887 | # * Pixelated frames per second
888 | #--------------------------------------------------------------------------
889 | def update_fps(dt)
890 | if Orms.active?(:pixelate_screen)
891 | sframe_count = Graphics.frame_counter || Graphics.frame_rate
892 | @fps = (sframe_count / dt).round
893 | else
894 | @fps = @ups
895 | end
896 | Graphics.frame_counter = 0
897 | end
898 | #--------------------------------------------------------------------------
899 | # * Initialize the displayed counter
900 | #--------------------------------------------------------------------------
901 | def initialize_counter
902 | @background = Sprite.new(Viewport.new(4, 4, 200, 30))
903 | @background.viewport.z = 600
904 | @background.bitmap = Bitmap.new(1, 1)
905 | @background.bitmap.set_pixel(0, 0, Color.new(0, 0, 0, 127))
906 | @counter = Sprite.new(@background.viewport)
907 | begin
908 | @counter.bitmap = ORMS_Bitmap.new(200, 30)
909 | rescue
910 | @counter.bitmap = Bitmap.new(200, 30)
911 | end
912 | @counter.x = 2
913 | @counter.y = -4
914 | @counter.z = 10
915 | end
916 | #--------------------------------------------------------------------------
917 | # * Update the displayed counter
918 | #--------------------------------------------------------------------------
919 | def update_counter
920 | @visible ||= false
921 | return unless @visible
922 | if @counter.nil? || @counter.disposed?
923 | @visible ? initialize_counter : return
924 | end
925 | text = [@ups, @fps].uniq
926 | size = @counter.bitmap.text_size(text.join("~"))
927 | size2 = @counter.bitmap.text_size(text[0].to_s) if text.length == 2
928 | @background.zoom_x = size.width + 4
929 | @background.zoom_y = size.height - 6
930 | @counter.bitmap.clear
931 | color = 9
932 | color = 4 if text[0] <= 30
933 | color = 11 if text[0] <= 15
934 | @counter.bitmap.draw_text(size, text[0].to_s, 0, color)
935 | if text.length == 2
936 | size.x = size2.width
937 | size.width -= size2.width
938 | @counter.bitmap.draw_text(size, "~" + text[1].to_s, 0, 3)
939 | end
940 | end
941 | #--------------------------------------------------------------------------
942 | # * Toggle the counter display
943 | #--------------------------------------------------------------------------
944 | def toggle_display
945 | initialize_counter if @counter.nil? || @counter.disposed?
946 | @visible = !@visible
947 | visible = @visible
948 | end
949 | def visible=(v)
950 | return if @counter.nil? || @counter.disposed?
951 | @counter.visible = @background.visible = v
952 | end
953 | end
954 |
955 | #==============================================================================
956 | # ** ORMS_MESSAGE
957 | #------------------------------------------------------------------------------
958 | # Display messages at top/right screen corner (used for "pixelation ON/OFF")
959 | #==============================================================================
960 |
961 | module ORMS_MESSAGE
962 | extend self
963 | #--------------------------------------------------------------------------
964 | # * Update the displayed message
965 | #--------------------------------------------------------------------------
966 | def update
967 | create_message_sprite if @message.nil? || @message.disposed?
968 | @timer ||= 0
969 | @message.opacity == 0 ? @timer = 0 : @timer += 1
970 | @message.opacity -= 20 if @timer > 30
971 | end
972 | #--------------------------------------------------------------------------
973 | # * Create the sprite
974 | #--------------------------------------------------------------------------
975 | def create_message_sprite
976 | @message = Sprite.new(Viewport.new(Graphics.width - 200, 4, 204, 30))
977 | @message.viewport.z = 600
978 | @message.x = -4
979 | @message.y = -2
980 | @message.z = 10
981 | end
982 | #--------------------------------------------------------------------------
983 | # * Display a message
984 | #--------------------------------------------------------------------------
985 | def display(text, color)
986 | @message.bitmap = get_message_bitmap(text, color)
987 | @message.opacity = 255
988 | end
989 | #--------------------------------------------------------------------------
990 | # * Get the Bitmap corresponding to the message and cache it
991 | #--------------------------------------------------------------------------
992 | def get_message_bitmap(text, color)
993 | @texts ||= Hash.new
994 | if @texts[text].nil? || @texts[text].is_a?(Bitmap) && @texts[text].disposed?
995 | begin
996 | @texts[text] = ORMS_Bitmap.new(200, 30)
997 | rescue
998 | @texts[text] = Bitmap.new(200, 30)
999 | end
1000 | draw_message(@texts[text], text, color)
1001 | end
1002 | @texts[text]
1003 | end
1004 | #--------------------------------------------------------------------------
1005 | # * Draw the message into the Bitmap
1006 | #--------------------------------------------------------------------------
1007 | def draw_message(bmp, text, color)
1008 | size = bmp.text_size(text)
1009 | size.x = 200 - 4 - size.width
1010 | size.width += 4
1011 | size.height += 4
1012 | rect = bmp.rect
1013 | rect.width -= 2
1014 | bmp.fill_rect(size, Color.new(0, 0, 0, 127))
1015 | bmp.draw_text(rect, text, 2, color)
1016 | end
1017 | #--------------------------------------------------------------------------
1018 | # * Hide/Show the message
1019 | #--------------------------------------------------------------------------
1020 | def visible=(v)
1021 | return if @message.nil? || @message.disposed?
1022 | @message.visible = v
1023 | end
1024 | end
1025 |
1026 | #==============================================================================
1027 | # ** Graphics
1028 | #==============================================================================
1029 |
1030 | class << Graphics
1031 | #--------------------------------------------------------------------------
1032 | # * Public instance variables
1033 | #--------------------------------------------------------------------------
1034 | attr_accessor :orms_screen, :frame_counter
1035 | #--------------------------------------------------------------------------
1036 | # * Update the screen display
1037 | #--------------------------------------------------------------------------
1038 | alias_method :orms_graphics_update, :update
1039 | def update
1040 | ORMS_FPS.previous_time ||= Time.now
1041 | @skip = ORMS_FPS.ups && ORMS_FPS.ups < (frame_rate - 10) && ORMS_FPS.ups2 < (frame_rate / 2)
1042 | unless @skip
1043 | if respond_to?(:zeus_fullscreen_update)
1044 | update_screen_display
1045 | release_alt if Disable_VX_Fullscreen and Input.trigger?(Input::ALT)
1046 | zeus_fullscreen_update
1047 | else
1048 | update_screen_display
1049 | orms_graphics_update
1050 | end
1051 | else
1052 | frame_reset
1053 | end
1054 | ORMS_FPS.update
1055 | ORMS_MESSAGE.update
1056 | end
1057 | #--------------------------------------------------------------------------
1058 | # * Dynamic frame skipping for performance issues
1059 | # Kill the default frame skipping while the RGSS FPS < 50
1060 | #--------------------------------------------------------------------------
1061 | def update_screen_display
1062 | return unless Orms.active?(:pixelate_screen)
1063 | @timer ||= 0
1064 | ups = ORMS_FPS.ups || frame_rate
1065 | ups = [ups, frame_rate].min
1066 | @timer = 0 if @timer >= (frame_rate.to_f / [ups, 20].max).round
1067 | if @timer == 0
1068 | pixelate_screen
1069 | @frame_counter ||= 0
1070 | @frame_counter += 1
1071 | end
1072 | @timer += 1
1073 | end
1074 | #--------------------------------------------------------------------------
1075 | # * Pixelate the screen
1076 | #--------------------------------------------------------------------------
1077 | def pixelate_screen
1078 | return unless Orms.active?(:pixelate_screen)
1079 | if respond_to?(:screen) && screen
1080 | esc = [screen.blur, screen.motion_blur, screen.pixelation, screen.zoom]
1081 | if esc && esc != [0, 0, 1, 100]
1082 | screen.update_filters
1083 | return @orms_screen && !@orms_screen.disposed? && @orms_screen.visible = false
1084 | else
1085 | @orms_screen && !@orms_screen.disposed? && @orms_screen.visible = true
1086 | end
1087 | end
1088 | w, h = Graphics.width / 2, Graphics.height / 2
1089 | if @orms_screen.nil? || @orms_screen.disposed?
1090 | @orms_screen = Sprite.new
1091 | @orms_screen.zoom_x = 2
1092 | @orms_screen.zoom_y = 2
1093 | @orms_screen.bitmap = Bitmap.new(w, h)
1094 | @orms_screen.viewport = Viewport.new
1095 | @orms_screen.viewport.z = 500
1096 | end
1097 | @orms_screen.visible = ORMS_FPS.visible = ORMS_MESSAGE.visible = false
1098 | snap = snap_to_bitmap
1099 | @orms_screen.bitmap.stretch_blt(Rect.new(0, 0, w, h), snap, snap.rect)
1100 | snap.dispose
1101 | @orms_screen.visible = ORMS_MESSAGE.visible = true
1102 | ORMS_FPS.visible = ORMS_FPS.visible
1103 | end
1104 | #--------------------------------------------------------------------------
1105 | # * Make a transition
1106 | #--------------------------------------------------------------------------
1107 | alias_method :orms_transition, :transition
1108 | def transition(*args)
1109 | pixelate_screen
1110 | orms_transition(*args)
1111 | end
1112 | end
1113 |
1114 | #==============================================================================
1115 | # ** Avoid missing graphical update after window close processing
1116 | #==============================================================================
1117 |
1118 | class Window_Base
1119 | #--------------------------------------------------------------------------
1120 | # * Update Close Processing
1121 | #--------------------------------------------------------------------------
1122 | alias_method :orms_update_close, :update_close
1123 | def update_close
1124 | orms_update_close
1125 | Graphics.pixelate_screen if close?
1126 | end
1127 | end
1128 |
1129 | end
1130 |
1131 | #==============================================================================
1132 | # ** TOGGLE_SCREEN_INPUT
1133 | #------------------------------------------------------------------------------
1134 | # RM2K(3)-like F4 and F5 input (TINY WINDOW WITH F5!!!)
1135 | #==============================================================================
1136 |
1137 | #==============================================================================
1138 | # ** Input
1139 | #==============================================================================
1140 |
1141 | module Input
1142 | class << self
1143 | alias_method :orms_input_update, :update
1144 | def update
1145 | orms_input_update
1146 | Toggle_Screen.check_input
1147 | end
1148 | end
1149 | end
1150 |
1151 | #==============================================================================
1152 | # ** Toggle Screen
1153 | #------------------------------------------------------------------------------
1154 | # The module that carries out screen mode switching.
1155 | #==============================================================================
1156 |
1157 | module Toggle_Screen
1158 | #--------------------------------------------------------------------------
1159 | # * Singleton
1160 | #--------------------------------------------------------------------------
1161 | class << self
1162 | #--------------------------------------------------------------------------
1163 | # * Public instance variables
1164 | #--------------------------------------------------------------------------
1165 | attr_reader :tiny_window
1166 | #--------------------------------------------------------------------------
1167 | # * Win32API methods
1168 | #--------------------------------------------------------------------------
1169 | SetWindowPos = Win32API.new 'user32', 'SetWindowPos', 'iiiiiii', 'i'
1170 | GetWindowRect = Win32API.new 'user32', 'GetWindowRect', 'ip', 'i'
1171 | GetClientRect = Win32API.new 'user32', 'GetClientRect', 'ip', 'i'
1172 | GetKeyState = Win32API.new 'user32', 'GetKeyState', 'p', 'i'
1173 | KeybdEvent = Win32API.new 'user32.dll', 'keybd_event', 'iill', 'v'
1174 | FindWindow = Win32API.new'user32', 'FindWindow', 'pp', 'i'
1175 | HWND = FindWindow.call 'RGSS Player', 0
1176 | #--------------------------------------------------------------------------
1177 | # * Get key code (:F5 => 0x74)
1178 | #--------------------------------------------------------------------------
1179 | def get_key_code(sym)
1180 | return 0 unless sym.is_a?(Symbol)
1181 | sym = sym.to_s.upcase
1182 | sym.slice!(0)
1183 | 0x6F + sym.to_i
1184 | end
1185 | #--------------------------------------------------------------------------
1186 | # * Initialize the given shortcuts
1187 | #--------------------------------------------------------------------------
1188 | def initialize_shortcuts
1189 | return if @tf_sc
1190 | @tf_sc ||= get_key_code(ORMS_CONFIG::TOGGLE_FULLSCREEN)
1191 | @tw_sc ||= get_key_code(ORMS_CONFIG::TOGGLE_WINDOW_MODE)
1192 | @ps_sc ||= get_key_code(ORMS_CONFIG::PIXELATION_SHORTCUT)
1193 | end
1194 | #--------------------------------------------------------------------------
1195 | # * Check keyboard state and toggle
1196 | #--------------------------------------------------------------------------
1197 | def check_input
1198 | initialize_shortcuts
1199 | # check_fullscreen_shortcut
1200 | if ![0,1].include?(GetKeyState.call(@tf_sc)) && Orms.active?(:toggle_fullscreen)
1201 | toggle_fullscreen unless @tf
1202 | @tf = true
1203 | else
1204 | @tf = false
1205 | end
1206 | # check_window_mode_shortcut
1207 | if ![0,1].include?(GetKeyState.call(@tw_sc)) && Orms.active?(:toggle_window_mode)
1208 | toggle_size unless @tw || @fullscreen
1209 | @tw = true
1210 | else
1211 | @tw = false
1212 | end
1213 | # check_pixelation_shortcut
1214 | if ![0,1].include?(GetKeyState.call(@ps_sc)) && Orms.active?(:pixelation_shortcut)
1215 | toggle_pixelation unless @ps
1216 | @ps = true
1217 | else
1218 | @ps = false
1219 | end
1220 | # check_fps_display_shortcut
1221 | if ![0,1].include?(GetKeyState.call(0x71)) && Module.const_defined?(:ORMS_FPS)
1222 | ORMS_FPS.toggle_display unless @fp
1223 | @fp = true
1224 | else
1225 | @fp = false
1226 | end
1227 | end
1228 | #--------------------------------------------------------------------------
1229 | # * Get the window rect
1230 | #--------------------------------------------------------------------------
1231 | def window_rect
1232 | GetWindowRect.call(HWND, wr = [0, 0, 0, 0].pack('l4'))
1233 | wr = wr.unpack('l4')
1234 | Rect.new(wr[0], wr[1], wr[2] - wr[0], wr[3] - wr[1])
1235 | end
1236 | #--------------------------------------------------------------------------
1237 | # * Get the dimensions of the window, excluding the frame
1238 | #--------------------------------------------------------------------------
1239 | def client_rect
1240 | GetClientRect.call(HWND, cr = [0, 0, 0, 0].pack('l4'))
1241 | cr = cr.unpack('l4')
1242 | Rect.new(*cr)
1243 | end
1244 | #--------------------------------------------------------------------------
1245 | # * Resize the game window (and stretch the content)
1246 | #--------------------------------------------------------------------------
1247 | def resize_window(w, h)
1248 | wr = window_rect
1249 | cr = client_rect
1250 | w += wr.width - cr.width
1251 | h += wr.height - cr.height
1252 | x = wr.x - (w - wr.width ) / 2
1253 | y = wr.y - (h - wr.height) / 2
1254 | SetWindowPos.call(HWND, 0, x, y, w, h, 0x0200)
1255 | end
1256 | #--------------------------------------------------------------------------
1257 | # * Toggle the size of the game window
1258 | #--------------------------------------------------------------------------
1259 | def toggle_size
1260 | w, h = Graphics.width, Graphics.height
1261 | @tiny_window ? resize_window(w, h) : resize_window(w / 2, h / 2)
1262 | @tiny_window = !@tiny_window
1263 | end
1264 | #--------------------------------------------------------------------------
1265 | # * Toggle to fullscreen (simulate fullscreen shortcut)
1266 | #--------------------------------------------------------------------------
1267 | def toggle_fullscreen
1268 | KeybdEvent.call 0xA4, 0, 0, 0
1269 | KeybdEvent.call 13, 0, 0, 0
1270 | KeybdEvent.call 13, 0, 2, 0
1271 | KeybdEvent.call 0xA4, 0, 2, 0
1272 | @fullscreen = !@fullscreen
1273 | end
1274 | #--------------------------------------------------------------------------
1275 | # * Toggle screen_pixelation ON/OFF
1276 | #--------------------------------------------------------------------------
1277 | def toggle_pixelation
1278 | return unless Module.const_defined?(:ORMS_MESSAGE)
1279 | if ORMS_CONFIG::PIXELATE_SCREEN
1280 | ORMS_MESSAGE.display("pixelation OFF", 11)
1281 | Orms.set(:pixelate_screen, false)
1282 | else
1283 | ORMS_MESSAGE.display("pixelation ON", 9)
1284 | Orms.set(:pixelate_screen, true)
1285 | end
1286 | end
1287 | end
1288 | end
1289 |
1290 | #==============================================================================
1291 | # ** OLD_RESOLUTION (for the slackers)
1292 | #------------------------------------------------------------------------------
1293 | # Just set game resolution to 640*480
1294 | #==============================================================================
1295 |
1296 | Graphics.resize_screen(640, 480) if ORMS_CONFIG::OLD_RESOLUTION
1297 |
1298 | #==============================================================================
1299 | # ** DEACTIVATE_DASH
1300 | #------------------------------------------------------------------------------
1301 | # No dash when you press shift
1302 | #==============================================================================
1303 |
1304 | if ORMS_CONFIG::DEACTIVATE_DASH
1305 |
1306 | #==============================================================================
1307 | # ** Game_Player
1308 | #==============================================================================
1309 |
1310 | class Game_Player
1311 | #--------------------------------------------------------------------------
1312 | # * Determine if Dashing
1313 | #--------------------------------------------------------------------------
1314 | alias_method :orms_dash?, :dash?
1315 | def dash?
1316 | !Orms.active?(:deactivate_dash) && orms_dash?
1317 | end
1318 | end
1319 |
1320 | end
1321 |
1322 | #==============================================================================
1323 | # ** Fullscreen++ (Zeus81) compatibility
1324 | #------------------------------------------------------------------------------
1325 | # Get Fullscreen++:
1326 | # https://forums.rpgmakerweb.com/index.php?threads/fullscreen.14081/
1327 | #==============================================================================
1328 |
1329 | if $imported && $imported[:Zeus_Fullscreen]
1330 | begin
1331 | class << Graphics
1332 | alias_method :zeus_save_fullscreen_settings, :save_fullscreen_settings
1333 | def save_fullscreen_settings
1334 | @half = @windowed_ratio = 1 if @windowed_ratio == 0.5
1335 | zeus_save_fullscreen_settings
1336 | @windowed_ratio = 0.5 if @half == 1
1337 | @half = 0
1338 | end
1339 | alias_method :zeus_set_ratio, :ratio=
1340 | def ratio=(r)
1341 | r = 0.5 if ratio == 0 unless fullscreen?
1342 | r = 1 if r == 1.5
1343 | zeus_set_ratio(r)
1344 | end
1345 | unless Module.const_defined?(:ORMS_MESSAGE)
1346 | def update
1347 | release_alt if Disable_VX_Fullscreen and Input.trigger?(Input::ALT)
1348 | zeus_fullscreen_update
1349 | end
1350 | end
1351 | end
1352 | module Toggle_Screen
1353 | def self.toggle_size
1354 | Graphics.toggle_ratio
1355 | end
1356 | def self.toggle_fullscreen
1357 | Graphics.toggle_fullscreen
1358 | end
1359 | end
1360 | rescue
1361 | end
1362 | end
1363 |
1364 | #==============================================================================
1365 | # ** RME (RMEx) ScreenEffects compatibility
1366 | #------------------------------------------------------------------------------
1367 | # Get RME:
1368 | # https://github.com/RMEx/RME
1369 | #==============================================================================
1370 |
1371 | if Module.const_defined?(:RME)
1372 | if ORMS_CONFIG::PIXELATE_SCREEN
1373 | module ScreenEffects
1374 | class Screen
1375 | def update
1376 | return if disposed?
1377 | update_transitions
1378 | if !SceneManager.scene_is?(Scene_Map) || [@blur, @motion_blur, @pixelation, @zoom] == [0, 0, 1, 100]
1379 | return self.visible = false
1380 | end
1381 | end
1382 | def update_filters
1383 | update_zoom_target
1384 | update_capture_rect
1385 | update_pixelation
1386 | update_bitmap
1387 | end
1388 | end
1389 | end
1390 | end
1391 | if ORMS_CONFIG::REWRITE_ALL_TEXTS
1392 | module Gui
1393 | module Components
1394 | class Text_Field
1395 | def create_sprite
1396 | @sprite = Sprite.new
1397 | @sprite.bitmap = Bitmap.new(1,1)
1398 | @sprite.bitmap.font = @font
1399 | @split_format = 640 / @sprite.bitmap.orms_text_size("W").width
1400 | end
1401 | def create_viewport
1402 | @h = @sprite.bitmap.orms_text_size("W").height
1403 | @viewport = Viewport.new(@x,@y,@w,@h)
1404 | @sprite.viewport = @viewport
1405 | end
1406 | def update_bitmap
1407 | text = value
1408 | text = " " if text.empty?
1409 | rect = @sprite.bitmap.orms_text_size(text)
1410 | @sprite.bitmap.dispose
1411 | @sprite.bitmap = Bitmap.new(rect.width, rect.height)
1412 | @sprite.bitmap.font = @font
1413 | last_x = 0
1414 | text.split_each(@split_format).each do |a_text|
1415 | rect = @sprite.bitmap.orms_text_size(a_text)
1416 | rect.x = last_x
1417 | @sprite.bitmap.orms_draw_text(rect, a_text)
1418 | last_x += rect.width
1419 | end
1420 | end
1421 | def update_cursor_pos
1422 | @cursor_timer = 0
1423 | pos = @text.virtual_position
1424 | if pos == 0
1425 | @cursor.x = 1
1426 | else
1427 | @cursor.x = @sprite.bitmap.orms_text_size(value[0...pos]).width
1428 | end
1429 | end
1430 | def update_selection_rect
1431 | pos = @text.selection_start
1432 | if pos == 0
1433 | @selection_rect.x = 1
1434 | else
1435 | @selection_rect.x = @sprite.bitmap.orms_text_size(value[0...pos]).width
1436 | end
1437 | delta = @cursor.x - @selection_rect.x
1438 | @selection_rect.zoom_x = delta.abs
1439 | @selection_rect.x += delta if delta < 0
1440 | end
1441 | def approach(a, x, memoa=a, memob=0)
1442 | bound = a.bound(0,value.length)
1443 | return bound if bound != a
1444 | b = @sprite.bitmap.orms_text_size(value[0...a]).width
1445 | return a if (b-x) == 0 || (b-x)==(x-memob)
1446 | return memoa if (b-x).abs > (memob-x).abs
1447 | approach(a + (0 <=> (b-x)), x, a, b)
1448 | end
1449 | end
1450 | end
1451 | class Label
1452 | def initialize_text(txt)
1453 | return unless @sprite_text
1454 | txt ||= ""
1455 | fon = @style[:font]
1456 | bmp = Bitmap.new(1,1)
1457 | bmp.font = fon
1458 | size = bmp.orms_text_size(txt)
1459 | @sprite_text.bitmap = Bitmap.new(size.width, size.height)
1460 | @sprite_text.bitmap.font = fon
1461 | @sprite_text.bitmap.orms_draw_text(size, txt)
1462 | @style[:width] = size.width
1463 | @style[:height] = size.height
1464 | end
1465 | end
1466 | end
1467 | end
1468 | end
1469 |
--------------------------------------------------------------------------------