设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 104|回复: 0

[转载发布] [VX Ace] CSCA Toast Manager (fix)

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-8-3 08:34:28 | 显示全部楼层 |阅读模式
    CSCA Toast Manager (fix)
    Автор: Casper Gaming (+ edits from Phileas)
    Версия: 1.1.2 (14.07.2020)
    Type: Window_Base modification
    The original

    Casper Gaming is a good script that allows you to display pop-up messages (toasts). However, the text in it is rendered primitively (maker tags do not work: \c, \i...), and the toast window appears approximately in the same place as the dialog box at the bottom. Of course, it turned out to be very easy to move the window to the left corner and change its size, but I had to tinker with parsing the text.

    What's the result:
    * the script shows a toast at the command in the upper left corner of the screen;
    * now you can work with toast like a maker's message (with tags, icons, etc.);
    * by default, the toast has the appearance of a dialog message;
    * the window position and size settings can be easily changed in the code;
    * the toast window stretches to the size of the text if the text does not fit into the window (the minimum size of the toast is a third of the game window, but this can be changed).

    Spoiler: code
    First, install the CSCA engine in the project:
    Spoiler: CSCA Core Script
                    Code:       
    1. =begin
    2. CSCA Core Script
    3. version: 1.0.7
    4. Created by: Casper Gaming (http://www.caspergaming.com/)
    5. Scripts that REQUIRE this script to work:
    6. CSCA Colosseum
    7. CSCA Dungeon Tools
    8. CSCA Achievements
    9. CSCA Encyclopedia
    10. CSCA Treasure Maps
    11. CSCA Menu MOD
    12. CSCA SaveFile Plus
    13. CSCA Vehicle System
    14. CSCA Sidequests
    15. CSCA Professions
    16. Version History:
    17. 1.0.1 - Adds CSCA_Item class, used by scripts to get information about an item.
    18. 1.0.2 - Adds CSCA_Fish class, used by Vehicle System to get fishing data.
    19. 1.0.3 - Adds Window_HorzCommand fix to allow unlimited horizontal commands.
    20. 1.0.4 - Adds CSCA_Core class, used for csca script data that needs to be saved.
    21. 1.0.5 - Adds shorter access to variables/switches in Event script command.
    22. 1.0.6 - Adds troubleshooting error/warning reports.
    23. 1.0.7 - Adds vowel detection for strings.
    24. COMPATIBILITY
    25. PLACE THIS SCRIPT ABOVE ALL OTHER CSCA SCRIPTS!
    26. Compatible only for VXAce.
    27. IMPORTANT: ALL CSCA Scripts should be compatible with each other unless
    28. otherwise noted.
    29. FFEATURES
    30. This script includes classes and functions used by other CSCA Scripts.
    31. SETUP
    32. Plug n play. Make sure this script is ABOVE all other CSCA Scripts.
    33. CREDIT and TERMS:
    34. Please visit http://www.caspergaming.com/dev/terms_of_use/ for terms of use and
    35. credit guidelines
    36. =end
    37. $imported = {} if $imported.nil?
    38. $imported["CSCA-Core"] = true
    39. #==============================================================================
    40. # ** DataManager
    41. #------------------------------------------------------------------------------
    42. # Handles csca class data.
    43. # Aliases: make_save_contents, create_game_objects, extract_save_contents
    44. #==============================================================================
    45. module DataManager
    46.   #--------------------------------------------------------------------------
    47.   # alias method
    48.   #--------------------------------------------------------------------------
    49.   class <<self; alias csca_core_create_game_objects create_game_objects; end
    50.   def self.create_game_objects
    51.     csca_core_create_game_objects
    52.     $csca = CSCA_Core.new
    53.   end
    54.   #--------------------------------------------------------------------------
    55.   # overwrite method
    56.   #--------------------------------------------------------------------------
    57.   class <<self; alias csca_core_save_contents make_save_contents; end
    58.   def self.make_save_contents
    59.     contents = csca_core_save_contents
    60.     contents[:csca] = $csca
    61.     contents
    62.   end
    63.   #--------------------------------------------------------------------------
    64.   # alias method
    65.   #--------------------------------------------------------------------------
    66.   class <<self; alias csca_core_extract_save_contents extract_save_contents; end
    67.   def self.extract_save_contents(contents)
    68.     csca_core_extract_save_contents(contents)
    69.     $csca = contents[:csca]
    70.   end
    71. end
    72. #==============================================================================
    73. # ** CSCA_Window_Header
    74. #------------------------------------------------------------------------------
    75. # This window displays the header window, used by many CSCA Scripts.
    76. #==============================================================================
    77. class CSCA_Window_Header < Window_Base
    78.   #--------------------------------------------------------------------------
    79.   # Object Initialization
    80.   #--------------------------------------------------------------------------
    81.   def initialize(x, y, width = Graphics.width, height = line_height*2, text)
    82.     super(x, y, width, height)
    83.     refresh(text)
    84.   end
    85.   #--------------------------------------------------------------------------
    86.   # Refresh
    87.   #--------------------------------------------------------------------------
    88.   def refresh(text)
    89.     contents.clear
    90.     draw_text(0, 0, contents.width, line_height, text, 1)
    91.   end
    92. end
    93. #==============================================================================
    94. # ** Game_Map
    95. #------------------------------------------------------------------------------
    96. # Easy csca access to the map's note.
    97. #==============================================================================
    98. class Game_Map
    99.   #--------------------------------------------------------------------------
    100.   # Get Map Note
    101.   #--------------------------------------------------------------------------
    102.   def csca_map_note; @map.note; end
    103. end
    104. #==============================================================================
    105. # ** Window_HorzCommand
    106. #------------------------------------------------------------------------------
    107. # Allow unlimited horizontal commands.
    108. # Overwrites: top_col=
    109. #==============================================================================
    110. class Window_HorzCommand < Window_Command
    111.   #--------------------------------------------------------------------------
    112.   # Overwrite Method
    113.   #--------------------------------------------------------------------------
    114.   def top_col=(col)
    115.     col = 0 if col < 0
    116.     self.ox = col * (item_width + spacing)
    117.   end
    118. end
    119. #==============================================================================
    120. # ** Game_Interpreter
    121. #------------------------------------------------------------------------------
    122. #  Shorter access to variables and switches.
    123. #==============================================================================
    124. class Game_Interpreter
    125.   #--------------------------------------------------------------------------
    126.   # Get variables
    127.   #--------------------------------------------------------------------------
    128.   def csca_v(var)
    129.     $game_variables[var]
    130.   end
    131.   #--------------------------------------------------------------------------
    132.   # Get switches
    133.   #--------------------------------------------------------------------------
    134.   def csca_s(swi)
    135.     $game_switches[swi]
    136.   end
    137. end
    138. #==============================================================================
    139. # ** CSCA_Item
    140. #------------------------------------------------------------------------------
    141. # CSCA Items, used as rewards/wagers in various scripts.
    142. #==============================================================================
    143. class CSCA_Item
    144.   attr_reader :id
    145.   attr_reader :amount
    146.   attr_reader :type
    147.   #--------------------------------------------------------------------------
    148.   # Initialize
    149.   #--------------------------------------------------------------------------
    150.   def initialize(amount,id,type)
    151.     @id = id
    152.     @amount = amount
    153.     @type = type
    154.   end
    155. end
    156. #==============================================================================
    157. # ** CSCA_Fish
    158. #------------------------------------------------------------------------------
    159. # CSCA Fish, used to specify data about fish.
    160. #==============================================================================
    161. class CSCA_Fish
    162.   attr_reader :item_id
    163.   attr_reader :water_type
    164.   attr_reader :weight
    165.   attr_reader :region
    166.   #--------------------------------------------------------------------------
    167.   # Initialize
    168.   #--------------------------------------------------------------------------
    169.   def initialize(id, water, weight, region = 0)
    170.     @item_id = id
    171.     @water_type = water
    172.     @weight = weight
    173.     @region = region
    174.   end
    175. end
    176. #==============================================================================
    177. # ** CSCA_Core
    178. #------------------------------------------------------------------------------
    179. # Used to provide global methods for csca scripts. Data is included in save.
    180. #==============================================================================
    181. class CSCA_Core
    182.   #--------------------------------------------------------------------------
    183.   # Initialize
    184.   #--------------------------------------------------------------------------
    185.   def initialize
    186.   end
    187.   #--------------------------------------------------------------------------
    188.   # Report wrong setup
    189.   #--------------------------------------------------------------------------
    190.   def report_error(error, script, suggestion, warning = false)
    191.     string1 = warning ? "Warning: " : "Error: "
    192.     msgbox(string1 + error + "\nOccurred in: " + script + "\nRecommended fix: " + suggestion)
    193.   end
    194.   #--------------------------------------------------------------------------
    195.   # Split number into millions, thousands, hundreds
    196.   #--------------------------------------------------------------------------
    197.   def split_number(start)
    198.     number = []
    199.     number[0] = start / 1000 / 1000
    200.     number[1] = start / 1000 % 1000
    201.     number[2] = start % 1000
    202.     return number
    203.   end
    204.   #--------------------------------------------------------------------------
    205.   # Split number into hours, minutes, seconds
    206.   #--------------------------------------------------------------------------
    207.   def split_playtime(start)
    208.     number = []
    209.     number[0] = start / 60 / 60
    210.     number[1] = start / 60 % 60
    211.     number[2] = start % 60
    212.     return number
    213.   end
    214.   #--------------------------------------------------------------------------
    215.   # Determine if letter is a vowel or not
    216.   #--------------------------------------------------------------------------
    217.   def is_a_vowel(letter, space = false)
    218.     letter.upcase
    219.     return letter == "A" || letter == "E" || letter == "I" || letter == "O" || letter == "U" || (letter == "X" && space == true)
    220.   end
    221. end
    复制代码


    Below the engine code, install the toast manager code (at your own risk, you can change the window settings in lines 86-90):
    Spoiler: CSCA Toast Manager[quote]                Code:       
    1. =begin
    2. CSCA Toast Manager
    3. version: 1.1.3 (03.08.2020)
    4. Created by: Casper Gaming and Philes (Oleg Olegovich)
    5. Compatibility:
    6. Made for RPGVXAce
    7. IMPORTANT: ALL CSCA Scripts should be compatible with each other unless
    8. otherwise noted.
    9. Requires CSCA Core Script v1.0.4+
    10. Suggested order: Paste below CSCA Core script, but above all other CSCA Scripts.
    11. FFEATURES
    12. Creates an easy-to-use toast system. Mainly a scripting tool, but you can create
    13. and call your own basic toasts as well. More information on how to do so in the
    14. script call section below.
    15. SETUP
    16. Set up required. Instructions below.
    17. Scripters: it is recommended to alias and add your custom display codes in the
    18. refresh method of CSCA_Window_Toast. If relying on this script to display toasts
    19. in your own script, please link to original CSCA Toast Manager script topic on
    20. rpgmakervxace.net
    21. ================================================== ==============================
    22. UPDATES:
    23. Version 1.0.0
    24. -Original Script
    25. Version 1.1.0
    26. -Toasts now global (not confined to the map scene). Certain scenes are excluded.
    27. Version 1.1.1
    28. -Toasts now have a z value of 1000.
    29. ================================================== ==============================
    30. CREDIT and TERMS:
    31. Please visit http://www.caspergaming.com/dev/terms_of_use/ for terms of use and
    32. credit guidelines
    33. =end
    34. module CSCA
    35. module TOASTS
    36. #================================================= =============================
    37. # ** Important Script Calls
    38. #================================================= =============================
    39. # bt_reserve_toast(text1, text2)
    40. # Reserves a toast with 2 lines of centered text on it.
    41. # text1 is the first line, text2 is the second line.
    42. #================================================= =============================
    43. # ** Begin Setup
    44. #================================================= =============================
    45. SHOW_COUNT = 160 # Amount of frames to show each toast. Recommended 160.
    46. FADE_SPEED = 16 # Speed of fade in/out. Recommended 16.
    47. #================================================= =============================
    48. # ** End Setup
    49. #================================================= =============================
    50. end
    51. end
    52. $imported = {} if $imported.nil?
    53. $imported["CSCA-ToastManager"] = true
    54. #================================================= =============================
    55. # ** Game_Interpreter
    56. #------------------------------------------------------------------------------
    57. # Adds basic toast reservation method for non-scripters
    58. #================================================= =============================
    59. class Game_Interpreter
    60. #--------------------------------------------------------------------------
    61. # Basic Text toast reservation, creates a toast with 2 lines of text.
    62. #--------------------------------------------------------------------------
    63. def bt_reserve_toast(text1, text2)
    64. $csca.reserve_toast([:csca_bt, text1, text2])
    65. end
    66. end
    67. #================================================= =============================
    68. # ** CSCA_Window_Toast
    69. #------------------------------------------------------------------------------
    70. # This window handles toast data.
    71. #================================================= =============================
    72. class CSCA_Window_Toast < Window_Base
    73. attr_reader :show_count
    74. attr_reader :toast_gone
    75. #--------------------------------------------------------------------------
    76. # Object Initialization
    77. #--------------------------------------------------------------------------
    78. def initialize(order)
    79. # Координаты левого верхнего угла тоста:
    80. x = 0
    81. y = 0
    82. # Базовые высота и ширина тоста:
    83. height = line_height * 3
    84. width = Graphics.width / 3
    85. super(x, y, width, height)
    86. self.opacity = 0
    87. self.contents_opacity = 0
    88. self.z = 1000
    89. @show_count = 0
    90. @toast_gone = true
    91. end
    92. #def contents_width
    93. # return [Graphics.width / 3 - 24, self.width - 24].max
    94. #end
    95. #--------------------------------------------------------------------------
    96. # Get order height modifier
    97. #--------------------------------------------------------------------------
    98. def get_order_modifier(order)
    99. return case order
    100. when :bottom; 6
    101. when :middle; 3
    102. when :top; 0
    103. end
    104. end
    105. #--------------------------------------------------------------------------
    106. # Frame Update
    107. #--------------------------------------------------------------------------
    108. def update
    109. super
    110. if @show_count > 0
    111. update_fadein
    112. @show_count -= 1
    113. else
    114. update_fadeout unless @toast_gone
    115. end
    116. end
    117. #--------------------------------------------------------------------------
    118. # Update Fadein
    119. #--------------------------------------------------------------------------
    120. def update_fadein
    121. self.opacity += CSCA::TOASTS::FADE_SPEED
    122. self.contents_opacity += CSCA::TOASTS::FADE_SPEED
    123. end
    124. #--------------------------------------------------------------------------
    125. # Update Fadeout
    126. #--------------------------------------------------------------------------
    127. def update_fadeout
    128. self.opacity -= CSCA::TOASTS::FADE_SPEED
    129. self.contents_opacity -= CSCA::TOASTS::FADE_SPEED
    130. @toast_gone = true if self.opacity <= 0 && self.contents_opacity <= 0
    131. end
    132. #--------------------------------------------------------------------------
    133. # Writer method
    134. #--------------------------------------------------------------------------
    135. def show_count=(amount)
    136. @show_count = amount
    137. @toast_gone = false
    138. end
    139. #--------------------------------------------------------------------------
    140. # Refresh
    141. #--------------------------------------------------------------------------
    142. def refresh(params)
    143. contents.clear
    144. if params[0] == :csca_bt
    145. draw_text_ex(standard_padding, 0, params[1])
    146. draw_text_ex(standard_padding, line_height, params[2])
    147. end
    148. end
    149. end
    150. #================================================= =============================
    151. # ** CSCA_Core
    152. #------------------------------------------------------------------------------
    153. # Handles toast data.
    154. #Aliases: initialize
    155. #================================================= =============================
    156. class CSCA_Core
    157. attr_reader :toasts
    158. #--------------------------------------------------------------------------
    159. # Alias Method; object initialization
    160. #--------------------------------------------------------------------------
    161. alias :csca_toast_init :initialize
    162. def initialize
    163. csca_toast_init
    164. @toasts = []
    165. end
    166. #--------------------------------------------------------------------------
    167. # Reserve Toast for display
    168. #--------------------------------------------------------------------------
    169. def reserve_toast(params)
    170. return if SceneManager.no_toast_scene?
    171. @toasts.push(params)
    172. end
    173. end
    174. #================================================= =============================
    175. # ** SceneManager
    176. #------------------------------------------------------------------------------
    177. # Determines if the scene creates toasts.
    178. #================================================= =============================
    179. module SceneManager
    180. #--------------------------------------------------------------------------
    181. # Don't create toasts?
    182. #--------------------------------------------------------------------------
    183. def self.no_toast_scene?
    184. scene_is?(Scene_Title) || scene_is?(Scene_Gameover) || scene_is?(Scene_Debug) ||
    185. scene_is?(Scene_File) || scene_is?(Scene_Save) || scene_is?(Scene_Load) ||
    186. scene_is?(Scene_End) || scene_is?(Scene_Name)
    187. end
    188. end
    189. #================================================= =============================
    190. # ** Scene_Map
    191. #------------------------------------------------------------------------------
    192. # Handles display of toasts
    193. #Aliases: create_all_windows, update
    194. #================================================= =============================
    195. class Scene_Base
    196. #--------------------------------------------------------------------------
    197. # Alias Method; Create All Windows
    198. #--------------------------------------------------------------------------
    199. alias :csca_create_toast_windows :start
    200. def start
    201. csca_create_toast_windows
    202. create_toast_windows unless SceneManager.no_toast_scene?
    203. end
    204. #--------------------------------------------------------------------------
    205. # Alias Method; Frame Update
    206. #--------------------------------------------------------------------------
    207. alias :csca_toast_update :update
    208. def update
    209. csca_toast_update
    210. update_toasts
    211. end
    212. #--------------------------------------------------------------------------
    213. # Create Toast Windows
    214. #--------------------------------------------------------------------------
    215. def create_toast_windows
    216. @toast_bottom = CSCA_Window_Toast.new(:bottom)
    217. @toast_middle = CSCA_Window_Toast.new(:middle)
    218. @toast_top = CSCA_Window_Toast.new(:top)
    219. @toast_list = [@toast_bottom, @toast_middle, @toast_top]
    220. @toast_bottom.viewport = @viewport
    221. @toast_middle.viewport = @viewport
    222. @toast_top.viewport = @viewport
    223. end
    224. #--------------------------------------------------------------------------
    225. # Update Toast Display
    226. #--------------------------------------------------------------------------
    227. def update_toasts
    228. $csca.toasts.each do |params|
    229. break if params.nil? || no_toast_possible?
    230. create_toast(params)
    231. end
    232. end
    233. #--------------------------------------------------------------------------
    234. # Check if all 3 toasts in use
    235. #--------------------------------------------------------------------------
    236. def no_toast_possible?
    237. return !@toast_bottom.toast_gone && !@toast_middle.toast_gone && !@toast_top.toast_gone
    238. end
    239. #--------------------------------------------------------------------------
    240. # Create Toast
    241. #--------------------------------------------------------------------------
    242. def count_width(params)
    243. width = Graphics.width / 3
    244. @str0 = ""
    245. @str1 = ""
    246. if params[0] == :csca_bt
    247. @str0 = params[1].gsub(/\\[^inpvg]\[\d{0,3}\]/) { "" }
    248. @str0.gsub!(/\\i\[\d{0,3}\]/) { " " }
    249. @str0.gsub!(/\\n\[(\d{0,3})\]/) { actor_name($1.to_i) }
    250. @str0.gsub!(/\\p\[(\d{0,3})\]/) { party_member_name($1.to_i) }
    251. @str0.gsub!(/\\v\[(\d+)\]/) { $game_variables[$1.to_i] }
    252. @str0.gsub!(/\eG/i) { Vocab::currency_unit }
    253. width = [(@toast_bottom.text_size(@str0)).width + 12, width].max
    254. @str1 = params[2].gsub(/\\[^inpvg]\[\d{0,3}\]/) { "" }
    255. @str1.gsub!(/\\i\[\d{0,3}\]/) { " " }
    256. @str1.gsub!(/\\n\[(\d{0,3})\]/) { actor_name($1.to_i) }
    257. @str1.gsub!(/\\p\[(\d{0,3})\]/) { party_member_name($1.to_i) }
    258. @str1.gsub!(/\\v\[(\d+)\]/) { $game_variables[$1.to_i] }
    259. @str1.gsub!(/\eG/i) { Vocab::currency_unit }
    260. width = [(@toast_bottom.text_size(@str1)).width + 12, width].max
    261. end
    262. @toast_list[0].width = @toast_list[1].width = @toast_list[2].width = width
    263. @toast_list[0].contents = @toast_list[1].contents = @toast_list[2].contents = Bitmap.new(@toast_list[0].contents_width, @toast_list[0].contents_height)
    264. end
    265. def create_toast(params)
    266. $csca.toasts.delete(params)
    267. count_width(params)
    268. for toast in @toast_list.each
    269. if toast.toast_gone
    270. toast.refresh(params)
    271. toast.show_count = CSCA::TOASTS::SHOW_COUNT
    272. break
    273. end
    274. end
    275. end
    276. end
    复制代码


    To use it, in the event, call the following script:
                    Code:       
    1. bt_reserve_toast('<строка>', '<ещё одна строка>')
    复制代码
    [/quote]


    Spoiler:  screenshots




    本贴来自国际rpgmaker官方论坛作者:Phileas处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/vx-ace-csca-toast-manager-fix.158535/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 07:18 , Processed in 0.108668 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表