rgss_db 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/COPYING.md +674 -0
- data/README.md +347 -0
- data/bin/rgss-db +4 -0
- data/bin/rgssdb +4 -0
- data/lib/rgss_db/app.rb +928 -0
- data/lib/rgss_db/controller/data_manager.rb +557 -0
- data/lib/rgss_db/model/data_file.rb +516 -0
- data/lib/rgss_db/model/data_file_factory.rb +94 -0
- data/lib/rgss_db/model/debug.rb +199 -0
- data/lib/rgss_db/model/errors.rb +17 -0
- data/lib/rgss_db/model/mixins/jsonable.rb +35 -0
- data/lib/rgss_db/model/mixins/jsonable_constructor.rb +40 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rgss/color.rb +72 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rgss/rect.rb +70 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rgss/table.rb +99 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rgss/tone.rb +72 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rgss.rb +11 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/actor.rb +44 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/animation.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/animation_frame.rb +20 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/animation_timing.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/area.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/armor.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/audio_file.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/base_item.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/bgm.rb +36 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/bgs.rb +36 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/class.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/class_learning.rb +20 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/common_event.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/enemy.rb +44 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/enemy_action.rb +29 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/enemy_drop_item.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/event.rb +36 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/event_command.rb +19 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/event_page.rb +32 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/event_page_condition.rb +34 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/event_page_graphic.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/item.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/map.rb +47 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/map_info.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/me.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/move_command.rb +18 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/move_route.rb +20 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/se.rb +21 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/skill.rb +22 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/state.rb +47 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/system.rb +43 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/system_terms.rb +53 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/system_test_battler.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/system_vehicle.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/troop.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/troop_member.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/troop_page.rb +21 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/troop_page_condition.rb +33 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/usable_item.rb +87 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg/weapon.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx/rpg.rb +59 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rgss/color.rb +72 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rgss/rect.rb +70 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rgss/table.rb +99 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rgss/tone.rb +72 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rgss.rb +11 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/actor.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/animation.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/animation_frame.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/animation_timing.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/armor.rb +20 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/audio_file.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/base_item.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/base_item_feature.rb +29 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/bgm.rb +43 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/bgs.rb +43 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/class.rb +37 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/class_learning.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/common_event.rb +33 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/enemy.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/enemy_action.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/enemy_drop_item.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/equip_item.rb +19 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/event.rb +36 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/event_command.rb +19 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/event_page.rb +35 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/event_page_condition.rb +40 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/event_page_graphic.rb +31 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/item.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/map.rb +58 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/map_encounter.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/map_info.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/me.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/move_command.rb +17 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/move_route.rb +19 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/se.rb +21 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/skill.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/state.rb +34 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/system.rb +62 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/system_terms.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/system_test_battler.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/system_vehicle.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/tileset.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/troop.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/troop_member.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/troop_page.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/troop_page_condition.rb +39 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item.rb +84 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_damage.rb +56 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/usable_item_effect.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg/weapon.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/vx_ace/rpg.rb +66 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rgss/color.rb +72 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rgss/rect.rb +70 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rgss/table.rb +99 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rgss/tone.rb +72 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rgss.rb +11 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/actor.rb +44 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/animation.rb +28 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/animation_frame.rb +20 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/animation_timing.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/armor.rb +37 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/audio_file.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/class.rb +28 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/class_learning.rb +20 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/common_event.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/enemy.rb +47 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/enemy_action.rb +28 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/event.rb +36 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/event_command.rb +19 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/event_page.rb +32 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/event_page_condition.rb +30 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/event_page_graphic.rb +27 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/item.rb +48 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/map.rb +39 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/map_info.rb +26 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/move_command.rb +18 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/move_route.rb +19 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/skill.rb +47 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/state.rb +51 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/system.rb +56 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/system_test_battler.rb +25 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/system_words.rb +39 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/tileset.rb +39 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/troop.rb +24 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/troop_member.rb +23 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/troop_page.rb +21 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/troop_page_condition.rb +32 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg/weapon.rb +38 -0
- data/lib/rgss_db/model/rpg_maker_data/xp/rpg.rb +52 -0
- data/lib/rgss_db/model/strings.rb +607 -0
- data/lib/rgss_db/model/utilities.rb +90 -0
- data/lib/rgss_db/version.rb +7 -0
- data/lib/rgss_db/view/app_cli.rb +449 -0
- data/lib/rgss_db.rb +41 -0
- data/sig/rgss_db.rbs +5221 -0
- metadata +496 -0
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RgssDb
|
|
4
|
+
#
|
|
5
|
+
# Application strings module
|
|
6
|
+
#
|
|
7
|
+
module Strings
|
|
8
|
+
#
|
|
9
|
+
# Application information CLI strings
|
|
10
|
+
#
|
|
11
|
+
module StrAppEntryPoint
|
|
12
|
+
# Message shown when the app call is invalid
|
|
13
|
+
# @return [String]
|
|
14
|
+
CLI_INVALID_CALL_MSG = <<~INVALID_CALL
|
|
15
|
+
Please provide a RPG Maker database directory!
|
|
16
|
+
Use 'rgss-db --help' to get more information
|
|
17
|
+
INVALID_CALL
|
|
18
|
+
|
|
19
|
+
# App version message
|
|
20
|
+
#
|
|
21
|
+
# String contains a "%s" flag to insert the app version
|
|
22
|
+
# @return [String]
|
|
23
|
+
CLI_VERSION = "rgss-db version %s installed"
|
|
24
|
+
|
|
25
|
+
# App banner contents
|
|
26
|
+
# @return [String]
|
|
27
|
+
CLI_BANNER = <<~BANNER
|
|
28
|
+
SYNOPSIS
|
|
29
|
+
rgss-db is a tool for developers to export and/or import the database files of a game made in RPG Maker
|
|
30
|
+
|
|
31
|
+
This tool works on any RPG Maker editor based on RGSS:
|
|
32
|
+
- RPG Maker XP
|
|
33
|
+
- RPG Maker VX
|
|
34
|
+
- RPG Maker VX Ace
|
|
35
|
+
|
|
36
|
+
USAGE
|
|
37
|
+
rgss-db data_directory [options]
|
|
38
|
+
|
|
39
|
+
DESCRIPTION
|
|
40
|
+
You can simply use this tool by calling the rgss-db command and supplying a RPG Maker data path:
|
|
41
|
+
# Opens the current directory
|
|
42
|
+
rgss-db .
|
|
43
|
+
|
|
44
|
+
The path needs to be the data folder where all binary database files are stored, otherwise the app won't work
|
|
45
|
+
|
|
46
|
+
This will open the application's menu where you can manually perform the desired action.
|
|
47
|
+
|
|
48
|
+
The application has a number of options that allow you to customize the behavior and output, for example:
|
|
49
|
+
# You can set the application's debug mode with the following option
|
|
50
|
+
# A log file will be created inside the application's working directory
|
|
51
|
+
rgss-db . --debug 0 # Disables debug functionality (default)
|
|
52
|
+
rgss-db . --debug 1 # Enables debug error level
|
|
53
|
+
rgss-db . --debug 2 # Enables debug warning level
|
|
54
|
+
rgss-db . --debug 3 # Enables debug info level
|
|
55
|
+
|
|
56
|
+
# You can disable the automatic backup creation with the flag
|
|
57
|
+
rgss-db . --no-backup
|
|
58
|
+
|
|
59
|
+
# Sets the application's working directory (used for exporting and importing)
|
|
60
|
+
rgss-db . -d "./custom_path/from/the data folder"
|
|
61
|
+
|
|
62
|
+
# Sets the application's file format (used for exporting and importing)
|
|
63
|
+
rgss-db . -t json
|
|
64
|
+
rgss-db . -t yaml
|
|
65
|
+
rgss-db . -t binary # Auto. selects the appropiate binary format
|
|
66
|
+
|
|
67
|
+
# Sets a list of data files that will be affected by the action
|
|
68
|
+
# If not provided, it will consider all data files
|
|
69
|
+
rgss-db . -f Items.rvdata2 Weapons.rvdata2 Map001.rvdata2 # Selects "Items", "Weapons" and "Map001" files
|
|
70
|
+
|
|
71
|
+
# Sets a list of objects that will be affected by an action (per data file)
|
|
72
|
+
# This option only works for data files that supports this behavior (Actors, Items, States...)
|
|
73
|
+
# The ids that you can provide match the IDs in the database.
|
|
74
|
+
# If not provided it will consider all objects
|
|
75
|
+
rgss-db . -f Items.rvdata2 -i 10 122 # This will consider the items with ID: 10 and 122
|
|
76
|
+
|
|
77
|
+
# You can also set the list for each data file (if there is more than one)
|
|
78
|
+
# The object IDs list parameter can be repeated for each data file specified
|
|
79
|
+
rgss-db . -f Actors.rvdata2 Items.rvdata2 -i 10 -i 200 300 # 10 for Actors, 200 and 300 for Items
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
You can skip the application's CLI menu completely if you supply a supported action.
|
|
83
|
+
|
|
84
|
+
The application will start and perform the action, using the given files and object IDs (if any) and close itself when the action finishes
|
|
85
|
+
|
|
86
|
+
These are the possible actions:
|
|
87
|
+
- export: Exports RPG Maker database
|
|
88
|
+
- export_custom: Exports specific objects from the RPG Maker database
|
|
89
|
+
- import: Imports external data into the RPG Maker database
|
|
90
|
+
- import_custom: Imports custom external data into the RPG Maker database (merge)
|
|
91
|
+
|
|
92
|
+
Here's a few examples with the action option using the default application directory:
|
|
93
|
+
# Opens the current directory and export all data
|
|
94
|
+
rgss-db . -a export
|
|
95
|
+
|
|
96
|
+
# Opens the current directory and import all data
|
|
97
|
+
rgss-db . -a import
|
|
98
|
+
|
|
99
|
+
# Opens the current directory and export only the Items file
|
|
100
|
+
rgss-db . -a export -f Items.rvdata2
|
|
101
|
+
|
|
102
|
+
# Opens the current directory and export only the object with ID: 100 from the Items file
|
|
103
|
+
rgss-db . -a export_custom -f Items.rvdata2 -i 100
|
|
104
|
+
|
|
105
|
+
# Opens the current directory and export only the object with ID: 100 from the Items file to a JSON file
|
|
106
|
+
rgss-db . -a export_custom -f Items.rvdata2 -i 100 -t json
|
|
107
|
+
|
|
108
|
+
OPTIONS
|
|
109
|
+
BANNER
|
|
110
|
+
|
|
111
|
+
# App option back up mode info
|
|
112
|
+
# @return [String]
|
|
113
|
+
CLI_OPTION_BACK_UP = "Sets the back up mode"
|
|
114
|
+
|
|
115
|
+
# App option debug mode info
|
|
116
|
+
# @return [String]
|
|
117
|
+
CLI_OPTION_DEBUG_MODE = "Sets the debug mode"
|
|
118
|
+
|
|
119
|
+
# App option working directory info
|
|
120
|
+
# @return [String]
|
|
121
|
+
CLI_OPTION_WORKING_DIR = "Sets the working directory"
|
|
122
|
+
|
|
123
|
+
# App option action info
|
|
124
|
+
# @return [String]
|
|
125
|
+
CLI_OPTION_ACTION = "Sets the action to perform"
|
|
126
|
+
|
|
127
|
+
# App option file format type info
|
|
128
|
+
# @return [String]
|
|
129
|
+
CLI_OPTION_FORMAT_TYPE = "Specifies the file format type to use"
|
|
130
|
+
|
|
131
|
+
# App option file entries info
|
|
132
|
+
# @return [String]
|
|
133
|
+
CLI_OPTION_FILE_ENTRIES = "Sets a list of files affected by the action"
|
|
134
|
+
|
|
135
|
+
# App option object IDs info
|
|
136
|
+
# @return [String]
|
|
137
|
+
CLI_OPTION_IDS = "Sets a list of object IDs that will be affected per file"
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
#
|
|
141
|
+
# Application information strings
|
|
142
|
+
#
|
|
143
|
+
module StrAppInfo
|
|
144
|
+
# Invalid RPG Maker version label
|
|
145
|
+
# @return [String]
|
|
146
|
+
VERSION_INVALID_LABEL = "Unknown"
|
|
147
|
+
|
|
148
|
+
# Text as a warning when a RPG Maker version is not detected
|
|
149
|
+
# @return [String]
|
|
150
|
+
VERSION_INVALID_TEXT = <<~EOF
|
|
151
|
+
It was not possible to detect a valid RPG Maker version in the given directory!
|
|
152
|
+
|
|
153
|
+
The detected version of RPG Maker determines which type of database is imported
|
|
154
|
+
|
|
155
|
+
If the version is unknown, it means that the RPG Maker version could not be resolved, either because
|
|
156
|
+
there are no database files in the given path or because there are files from two versions of the engine
|
|
157
|
+
(such as Items.rvdata2 and Items.rxdata), therefore the correct RPG Maker version cannot be determined
|
|
158
|
+
|
|
159
|
+
This is because the app cannot work with different versions of RPG Maker data files at the same time
|
|
160
|
+
|
|
161
|
+
Some database classes have the same name but different definitions, which could result in data corruption
|
|
162
|
+
|
|
163
|
+
You should exit and fix the problems before interacting further with the database
|
|
164
|
+
EOF
|
|
165
|
+
|
|
166
|
+
# Application information data folder text
|
|
167
|
+
#
|
|
168
|
+
# String contains a "%s" flag to insert the data folder
|
|
169
|
+
# @return [String]
|
|
170
|
+
DATA_FOLDER = "RPG Maker Data Folder: %s"
|
|
171
|
+
|
|
172
|
+
# Application information RPG Maker version text
|
|
173
|
+
# @return [String]
|
|
174
|
+
#
|
|
175
|
+
# String contains a "%s" flag to insert the version
|
|
176
|
+
# @return [String]
|
|
177
|
+
RPG_VERSION = "RPG Maker Version: %s"
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
#
|
|
181
|
+
# Strings used in user prompts
|
|
182
|
+
#
|
|
183
|
+
module StrPrompts
|
|
184
|
+
# Text shown when a prompt operation finishes successfully
|
|
185
|
+
# @return [String]
|
|
186
|
+
SUCCESS_TEXT = "Operation finished!"
|
|
187
|
+
|
|
188
|
+
# Text shown when a prompt is stopped or cancelled
|
|
189
|
+
# @return [String]
|
|
190
|
+
CANCEL_TEXT = "Cancelling operation..."
|
|
191
|
+
|
|
192
|
+
# Text shown on the spinner prompt when the task is completed
|
|
193
|
+
# @return [String]
|
|
194
|
+
SPINNER_TASK_COMPLETED_TEXT = "Done!"
|
|
195
|
+
|
|
196
|
+
# Text shown on the pause prompt when requesting the user to press any key
|
|
197
|
+
# @return [String]
|
|
198
|
+
PAUSE_ANY_KEYS = "Press any key to continue..."
|
|
199
|
+
|
|
200
|
+
# Text shown on the pause prompt when requesting the user to press any key with a timeout
|
|
201
|
+
# @return [String]
|
|
202
|
+
PAUSE_ANY_KEYS_TIMEOUT = "Press any key to continue... (resumes automatically in :countdown seconds)"
|
|
203
|
+
|
|
204
|
+
# Text shown on the pause prompt when requesting the user to press specific keys
|
|
205
|
+
#
|
|
206
|
+
# String contains a "%s" flag to insert the list of keys
|
|
207
|
+
# @return [String]
|
|
208
|
+
PAUSE_KEYS = "Press %s to continue..."
|
|
209
|
+
|
|
210
|
+
# Text shown on the pause prompt when requesting the user to press specific keys with a timeout
|
|
211
|
+
#
|
|
212
|
+
# String contains a "%s" flag to insert the list of keys
|
|
213
|
+
# @return [String]
|
|
214
|
+
PAUSE_KEYS_TIMEOUT = "Press %s to continue... (resumes automatically in :countdown seconds)"
|
|
215
|
+
|
|
216
|
+
# Text shown on the confirmation prompt
|
|
217
|
+
# @return [String]
|
|
218
|
+
CONFIRM_INPUT_TEXT = "Are you sure you want to continue?"
|
|
219
|
+
|
|
220
|
+
# Text shown on the select and multi select prompts
|
|
221
|
+
# @return [String]
|
|
222
|
+
SELECT_INPUT_TEXT = "What would you like to do?"
|
|
223
|
+
|
|
224
|
+
# Text that could be used as a tip message for ask prompts
|
|
225
|
+
# @return [String]
|
|
226
|
+
ASK_TIP_TEXT = <<~EOF
|
|
227
|
+
Press ENTER to submit the current input
|
|
228
|
+
|
|
229
|
+
The option may have a default value between parentheses that will be used
|
|
230
|
+
if the input is left empty.
|
|
231
|
+
EOF
|
|
232
|
+
|
|
233
|
+
# Text that could be used as a fail message when an ask prompt fails validation
|
|
234
|
+
# @return [String]
|
|
235
|
+
ASK_VALIDATION_FAIL_TEXT = "The input is invalid!"
|
|
236
|
+
|
|
237
|
+
# Text that could be used as a tip message for select prompts
|
|
238
|
+
# @return [String]
|
|
239
|
+
SELECT_TIP_TEXT = <<~EOF
|
|
240
|
+
Press ↑/↓ arrows to move the cursor
|
|
241
|
+
Use SPACE or ENTER to select the current item
|
|
242
|
+
EOF
|
|
243
|
+
|
|
244
|
+
# Text that could be used as a tip message for multi select prompts
|
|
245
|
+
# @return [String]
|
|
246
|
+
MULTI_SELECT_TIP_TEXT = <<~EOF
|
|
247
|
+
Press ↑/↓ arrows to move the cursor
|
|
248
|
+
Use SPACE to select the current item
|
|
249
|
+
Press CTRL + A and to select all items available
|
|
250
|
+
You can also use CTRL + R to revert the current selection
|
|
251
|
+
Press ENTER to finish selection
|
|
252
|
+
EOF
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
#
|
|
256
|
+
# Menu strings
|
|
257
|
+
#
|
|
258
|
+
# This module contains menu options shown on the screen
|
|
259
|
+
#
|
|
260
|
+
module StrMenu
|
|
261
|
+
# App menu option that represents the main menu
|
|
262
|
+
# @return [String]
|
|
263
|
+
APP_MENU_MAIN_MENU = "Main Menu"
|
|
264
|
+
|
|
265
|
+
# App menu option to go to the actions menu
|
|
266
|
+
# @return [String]
|
|
267
|
+
APP_MENU_ACTIONS = "Perform Actions"
|
|
268
|
+
|
|
269
|
+
# App menu option for export command
|
|
270
|
+
# @return [String]
|
|
271
|
+
APP_MENU_ACTIONS_EXPORT = "Export RPG Maker Data Files"
|
|
272
|
+
|
|
273
|
+
# App menu option for export custom command
|
|
274
|
+
# @return [String]
|
|
275
|
+
APP_MENU_ACTIONS_EXPORT_CUSTOM = "Export RPG Maker Data Files (Custom)"
|
|
276
|
+
|
|
277
|
+
# App menu option for import command
|
|
278
|
+
# @return [String]
|
|
279
|
+
APP_MENU_ACTIONS_IMPORT = "Import External Data Into RPG Maker"
|
|
280
|
+
|
|
281
|
+
# App menu option for import custom command
|
|
282
|
+
# @return [String]
|
|
283
|
+
APP_MENU_ACTIONS_IMPORT_CUSTOM = "Import External Data Into RPG Maker (Custom)"
|
|
284
|
+
|
|
285
|
+
# App menu option to go to app options menu
|
|
286
|
+
# @return [String]
|
|
287
|
+
APP_MENU_OPTIONS = "Check and Modify Options"
|
|
288
|
+
|
|
289
|
+
# App menu option to set the output file format type
|
|
290
|
+
# @return [String]
|
|
291
|
+
APP_MENU_OPTIONS_SET_FORMAT_TYPE = "Set Type of File Format"
|
|
292
|
+
|
|
293
|
+
# App menu option to set the working directory
|
|
294
|
+
# @return [String]
|
|
295
|
+
APP_MENU_OPTIONS_SET_WORKING_DIR = "Set Working Directory"
|
|
296
|
+
|
|
297
|
+
# App menu option to select a list of file entries
|
|
298
|
+
# @return [String]
|
|
299
|
+
APP_MENU_OPTIONS_SET_ENTRIES = "Set File Entries List"
|
|
300
|
+
|
|
301
|
+
# App menu option to select a list of object IDs
|
|
302
|
+
# @return [String]
|
|
303
|
+
APP_MENU_OPTIONS_SET_IDS = "Set Object IDs List"
|
|
304
|
+
|
|
305
|
+
# App menu option to show the values of the current options (pretty format)
|
|
306
|
+
# @return [String]
|
|
307
|
+
APP_MENU_OPTIONS_SHOW_OPTIONS_PRETTY = "Show Options (Pretty)"
|
|
308
|
+
|
|
309
|
+
# App menu option to show the values of the current options (raw format)
|
|
310
|
+
# @return [String]
|
|
311
|
+
APP_MENU_OPTIONS_SHOW_OPTIONS_RAW = "Show Options (Raw)"
|
|
312
|
+
|
|
313
|
+
# App menu option for exiting command
|
|
314
|
+
# @return [String]
|
|
315
|
+
APP_MENU_EXIT = "Exit"
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
#
|
|
319
|
+
# Menu contents strings
|
|
320
|
+
#
|
|
321
|
+
# This module contains the contents for each menu
|
|
322
|
+
#
|
|
323
|
+
module StrMenuContents
|
|
324
|
+
# Main menu information contents
|
|
325
|
+
# @return [String]
|
|
326
|
+
APP_MENU_MAIN_MENU_TEXT_INFO = <<~EOF
|
|
327
|
+
This is the main menu of RGSS Database
|
|
328
|
+
|
|
329
|
+
You can use the first option to perform any action on the current RPG Maker database
|
|
330
|
+
|
|
331
|
+
You are also able to see and tweak the application's settings
|
|
332
|
+
EOF
|
|
333
|
+
|
|
334
|
+
# Actions menu information contents
|
|
335
|
+
# @return [String]
|
|
336
|
+
APP_MENU_ACTIONS_TEXT_INFO = <<~EOF
|
|
337
|
+
In this menu you can perform export and import operations on the current RPG Maker database
|
|
338
|
+
|
|
339
|
+
You can do the following operations:
|
|
340
|
+
- Export: Exports all RPG Maker database data into external files
|
|
341
|
+
- Export (Custom): Exports specific objects from the RPG Maker database
|
|
342
|
+
- Import: Imports all external data into the RPG Maker database
|
|
343
|
+
- Import (Custom): Imports specific objects ino the RPG Maker database
|
|
344
|
+
EOF
|
|
345
|
+
|
|
346
|
+
# Options menu information contents
|
|
347
|
+
# @return [String]
|
|
348
|
+
APP_MENU_OPTIONS_TEXT_INFO = <<~EOF
|
|
349
|
+
In this menu you can change the application's option values
|
|
350
|
+
|
|
351
|
+
You are also able to show the current value of each option in a table
|
|
352
|
+
EOF
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
#
|
|
356
|
+
# Submenu strings
|
|
357
|
+
#
|
|
358
|
+
# This module contains strings used in submenus
|
|
359
|
+
#
|
|
360
|
+
module StrSubMenu
|
|
361
|
+
# Text shown on the exit submenu
|
|
362
|
+
# @return [String]
|
|
363
|
+
EXIT_TEXT = "Exiting..."
|
|
364
|
+
|
|
365
|
+
# Text shown on the export submenu as an information message
|
|
366
|
+
# @return [String]
|
|
367
|
+
EXPORT_TEXT = <<~EOF
|
|
368
|
+
Choose the data files you want to export from the list of files below
|
|
369
|
+
|
|
370
|
+
All data files selected will be exported to the choosen file format
|
|
371
|
+
|
|
372
|
+
If you want to cancel this action do not select any data file
|
|
373
|
+
EOF
|
|
374
|
+
|
|
375
|
+
# Text shown on the export submenu when loading data files
|
|
376
|
+
# @return [String]
|
|
377
|
+
EXPORT_LOAD_FILES_TEXT = "Loading RPG Maker database files..."
|
|
378
|
+
|
|
379
|
+
# Text shown as an error when the application failed to detect RPG Maker database files
|
|
380
|
+
# @return [String]
|
|
381
|
+
EXPORT_LOAD_ERROR_TEXT = "No valid RPG Maker database files detected inside the data folder!"
|
|
382
|
+
|
|
383
|
+
# Text shown when the user does not select any data files from the export files list
|
|
384
|
+
# @return [String]
|
|
385
|
+
EXPORT_NO_FILES_ERROR_TEXT = "No data files were selected from the list!"
|
|
386
|
+
|
|
387
|
+
# Text shown on the export custom submenu as an information message
|
|
388
|
+
# @return [String]
|
|
389
|
+
EXPORT_CUSTOM_TEXT = <<~EOF
|
|
390
|
+
Choose the data files you want to export from the list of files below
|
|
391
|
+
|
|
392
|
+
You can only select data files that allows object selection.
|
|
393
|
+
If you wish to export a data file that does not appear here
|
|
394
|
+
try the other export action.
|
|
395
|
+
|
|
396
|
+
Keep in mind that if you do not select any object from the list or skip the
|
|
397
|
+
selection process all objects will be considered for the export operation
|
|
398
|
+
|
|
399
|
+
If you want to cancel this action do not select any data file
|
|
400
|
+
EOF
|
|
401
|
+
|
|
402
|
+
# Text shown when asking the user whether they want to select specific objects from a data file or not
|
|
403
|
+
#
|
|
404
|
+
# String contains a "%s" flag to insert the data file name
|
|
405
|
+
# @return [String]
|
|
406
|
+
EXPORT_CUSTOM_SELECT_OBJ_ID_TEXT = "Do you wish to select specific objects from '%s'?"
|
|
407
|
+
|
|
408
|
+
# Text shown when the application is exporting a data file
|
|
409
|
+
#
|
|
410
|
+
# String contains a "%s" flag to insert the data file name
|
|
411
|
+
# @return [String]
|
|
412
|
+
EXPORT_ACTION_TEXT = "Exporting data file '%s'..."
|
|
413
|
+
|
|
414
|
+
# Text shown when the application is exporting a custom data file
|
|
415
|
+
#
|
|
416
|
+
# String contains a "%s" flag to insert the data file name
|
|
417
|
+
# @return [String]
|
|
418
|
+
EXPORT_CUSTOM_ACTION_TEXT = "Exporting custom data file '%s'..."
|
|
419
|
+
|
|
420
|
+
# Text shown on the import submenu as an information message
|
|
421
|
+
# @return [String]
|
|
422
|
+
IMPORT_TEXT = <<~EOF
|
|
423
|
+
Choose the data files you want to import from the list of files below
|
|
424
|
+
When importing data, all objects are auto. considered for the operation
|
|
425
|
+
|
|
426
|
+
A backup of the original database file will be created for each data file
|
|
427
|
+
You can disable this behavior by disabling backups when running the application
|
|
428
|
+
|
|
429
|
+
If you want to cancel this action do not select any data file
|
|
430
|
+
EOF
|
|
431
|
+
|
|
432
|
+
# Text shown on the import submenu when loading data files
|
|
433
|
+
# @return [String]
|
|
434
|
+
IMPORT_LOAD_FILES_TEXT = "Loading extracted data files..."
|
|
435
|
+
|
|
436
|
+
# Text shown as an error when the application failed to detect external data files
|
|
437
|
+
# @return [String]
|
|
438
|
+
IMPORT_LOAD_ERROR_TEXT = "No valid extracted data file detected on the application's folder!"
|
|
439
|
+
|
|
440
|
+
# Text shown when the user does not select any data files from the import files list
|
|
441
|
+
# @return [String]
|
|
442
|
+
IMPORT_NO_FILES_ERROR_TEXT = "No data files were selected from the list!"
|
|
443
|
+
|
|
444
|
+
# Text shown on the import custom submenu as an information message
|
|
445
|
+
# @return [String]
|
|
446
|
+
IMPORT_CUSTOM_TEXT = <<~EOF
|
|
447
|
+
Choose which custom data files you want to import from the list of files below
|
|
448
|
+
|
|
449
|
+
The data files selected will be merged into their appropiate RPG Maker database file
|
|
450
|
+
|
|
451
|
+
New objects will be appended at the end of the list of objects to avoid problems
|
|
452
|
+
|
|
453
|
+
You should make sure that any reference to other database files that the new object
|
|
454
|
+
imported has, exists within the RPG Maker database.
|
|
455
|
+
|
|
456
|
+
A backup of the original database file will be created for each data file
|
|
457
|
+
You can disable this behavior by disabling backups when running the application
|
|
458
|
+
|
|
459
|
+
If you want to cancel this action do not select any data file
|
|
460
|
+
EOF
|
|
461
|
+
|
|
462
|
+
# Text shown on the import custom submenu when loading data files
|
|
463
|
+
# @return [String]
|
|
464
|
+
IMPORT_CUSTOM_LOAD_FILES_TEXT = "Loading custom extracted data files..."
|
|
465
|
+
|
|
466
|
+
# Text shown when the application is importing a data file
|
|
467
|
+
#
|
|
468
|
+
# String contains a "%s" flag to insert the data file name
|
|
469
|
+
# @return [String]
|
|
470
|
+
IMPORT_ACTION_TEXT = "Importing data file '%s'..."
|
|
471
|
+
|
|
472
|
+
# Text shown when the application is importing a custom data file
|
|
473
|
+
#
|
|
474
|
+
# String contains a "%s" flag to insert the data file name
|
|
475
|
+
# @return [String]
|
|
476
|
+
IMPORT_CUSTOM_ACTION_TEXT = "Importing custom data file '%s'..."
|
|
477
|
+
|
|
478
|
+
# Text shown on the set format type submenu as an information message
|
|
479
|
+
# @return [String]
|
|
480
|
+
SET_FORMAT_TYPE_TEXT = <<~EOF
|
|
481
|
+
You can set the type of file format the application will use below
|
|
482
|
+
|
|
483
|
+
The choosen file format will be used when exporting data files
|
|
484
|
+
|
|
485
|
+
If using binary, RPG Maker files will automatically use the appropiate binary file type
|
|
486
|
+
EOF
|
|
487
|
+
|
|
488
|
+
# Text shown on the set format type submenu when updating the file format type
|
|
489
|
+
#
|
|
490
|
+
# String contains a "%s" flag to insert the type of file format
|
|
491
|
+
# @return [String]
|
|
492
|
+
SET_FORMAT_TYPE_UPDATE_TEXT = "Type of file format updated to: '%s'"
|
|
493
|
+
|
|
494
|
+
# Text shown on the set app working directory submenu as an information message
|
|
495
|
+
# @return [String]
|
|
496
|
+
SET_WORKING_DIR_TEXT = <<~EOF
|
|
497
|
+
You can set the application's working directory to the desired one below
|
|
498
|
+
|
|
499
|
+
The path can be either an absolute or relative path to the RPG Maker data folder
|
|
500
|
+
|
|
501
|
+
Keep in mind that the app will overwrite any files inside of the working directory!
|
|
502
|
+
EOF
|
|
503
|
+
|
|
504
|
+
# Text shown when asking the user to set the app working directory
|
|
505
|
+
# @return [String]
|
|
506
|
+
SET_WORKING_DIR_ASK_TEXT = "Type the working directory"
|
|
507
|
+
|
|
508
|
+
# Text shown when the working directory validation fails
|
|
509
|
+
SET_WORKING_DIR_ASK_FAIL_TEXT = "The path contains invalid characters!"
|
|
510
|
+
|
|
511
|
+
# Text shown on the set working directory submenu when updating the working directory
|
|
512
|
+
#
|
|
513
|
+
# String contains a "%s" flag to insert the new working directory
|
|
514
|
+
#
|
|
515
|
+
# String contains a "%s" flag to insert the application working directory
|
|
516
|
+
# @return [String]
|
|
517
|
+
SET_WORKING_DIR_UPDATE_TEXT = "Application working directory updated to: '%s'"
|
|
518
|
+
|
|
519
|
+
# Tip text shown on the set file entries submenu as an information message
|
|
520
|
+
# @return [String]
|
|
521
|
+
SET_ENTRIES_TEXT = <<~EOF
|
|
522
|
+
You can set a list of file entries that will be pre-selected when performing an action
|
|
523
|
+
|
|
524
|
+
Keep in mind that if a file entry is deleted it will be removed from the object ID list too!
|
|
525
|
+
|
|
526
|
+
You must type all entries separated by commas!
|
|
527
|
+
EOF
|
|
528
|
+
|
|
529
|
+
# Text shown when asking the user to set the list of file entries
|
|
530
|
+
# @return [String]
|
|
531
|
+
SET_ENTRIES_ASK_TEXT = "Type the list of file entries"
|
|
532
|
+
|
|
533
|
+
# Text shown when asking the user to set the list of file entries
|
|
534
|
+
#
|
|
535
|
+
# String contains a "%s" flag to insert the file entries
|
|
536
|
+
# @return [String]
|
|
537
|
+
SET_ENTRIES_UPDATE_TEXT = "File entries updated to: '%s'"
|
|
538
|
+
|
|
539
|
+
# Tip text shown on the set object IDs submenu as an information message
|
|
540
|
+
# @return [String]
|
|
541
|
+
SET_IDS_TEXT = <<~EOF
|
|
542
|
+
You can set a list of IDs that will be selected for each file entry
|
|
543
|
+
|
|
544
|
+
You must type all ID values separated by commas!
|
|
545
|
+
EOF
|
|
546
|
+
|
|
547
|
+
# Text shown when the user does not have any file entry to select object IDs from
|
|
548
|
+
# @return [String]
|
|
549
|
+
SET_IDS_NO_FILES_ERROR_TEXT = "No file entries available to select from!"
|
|
550
|
+
|
|
551
|
+
# Text shown when the user does not select any file entries from the files list
|
|
552
|
+
# @return [String]
|
|
553
|
+
SET_IDS_NO_FILES_SELECTED_ERROR_TEXT = "No file entries were selected from the list!"
|
|
554
|
+
|
|
555
|
+
# Text shown when asking the user for the list of object IDs to select for a file entry
|
|
556
|
+
#
|
|
557
|
+
# String contains a "%s" flag to insert the file entry
|
|
558
|
+
# @return [String]
|
|
559
|
+
SET_IDS_ASK_IDS_TEXT = "Type the list of object IDs for '%s':"
|
|
560
|
+
|
|
561
|
+
# Text shown when updating the list of object IDs for a file entry
|
|
562
|
+
#
|
|
563
|
+
# String contains a "%s" flag to insert the hash of file entries and object IDs
|
|
564
|
+
# @return [String]
|
|
565
|
+
SET_IDS_UPDATE_TEXT = "List of object IDs updated to: '%s'"
|
|
566
|
+
|
|
567
|
+
# Text shown on the show options submenu in the raw mode
|
|
568
|
+
# @return [String]
|
|
569
|
+
SHOW_OPTIONS_RAW_TEXT = <<~EOF
|
|
570
|
+
All options will be shown below, note that not all options are relevant to the user
|
|
571
|
+
EOF
|
|
572
|
+
|
|
573
|
+
# Text shown on the show options submenu in the pretty mode
|
|
574
|
+
# @return [String]
|
|
575
|
+
SHOW_OPTIONS_PRETTY_TEXT = <<~EOF
|
|
576
|
+
All options will be shown below, note that not all options are relevant to the user
|
|
577
|
+
|
|
578
|
+
In case the table is unreadable, use the raw mode
|
|
579
|
+
EOF
|
|
580
|
+
|
|
581
|
+
# Column 1 text shown on the show options submenu
|
|
582
|
+
# @return [String]
|
|
583
|
+
SHOW_OPTIONS_COLUMN_1 = "Option ID"
|
|
584
|
+
|
|
585
|
+
# Column 2 text shown on the show options submenu
|
|
586
|
+
# @return [String]
|
|
587
|
+
SHOW_OPTIONS_COLUMN_2 = "Option Value"
|
|
588
|
+
end
|
|
589
|
+
|
|
590
|
+
#
|
|
591
|
+
# Other strings module
|
|
592
|
+
#
|
|
593
|
+
module StrOthers
|
|
594
|
+
# Information frame box label
|
|
595
|
+
# @return [String]
|
|
596
|
+
INFO_FRAME_LABEL = "ℹ️ Information"
|
|
597
|
+
|
|
598
|
+
# Warning frame box label
|
|
599
|
+
# @return [String]
|
|
600
|
+
WARN_FRAME_LABEL = "⚠️ Warning"
|
|
601
|
+
|
|
602
|
+
# Error frame box label
|
|
603
|
+
# @return [String]
|
|
604
|
+
ERRO_FRAME_LABEL = "🅾️ Error"
|
|
605
|
+
end
|
|
606
|
+
end
|
|
607
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RgssDb
|
|
4
|
+
#
|
|
5
|
+
# Utilities module
|
|
6
|
+
#
|
|
7
|
+
module Utilities
|
|
8
|
+
# Regular expression of invalid characters or sequence of characters
|
|
9
|
+
# @return [Regexp]
|
|
10
|
+
INVALID_CHARACTERS = /[:*?"<>|]|(\bCON\b|\bPRN\b|\bAUX\b|\bNUL\b|\bCOM[1-9]\b|\bLPT[1-9]\b)/i
|
|
11
|
+
|
|
12
|
+
#
|
|
13
|
+
# Gets the list of the default (pre-selected) indexes for a TTY selection menu
|
|
14
|
+
#
|
|
15
|
+
# If a block is given, it will be used to evaluate the index selection
|
|
16
|
+
#
|
|
17
|
+
# The block receives the following parameters ``[Object, Integer, Object]``:
|
|
18
|
+
# - The first one is the current menu option being evaluated
|
|
19
|
+
# - The second one is the index of the menu option being evaluated
|
|
20
|
+
# - The third argument iterates through each user option
|
|
21
|
+
#
|
|
22
|
+
# If the block ever returns ``true`` for the current menu option, its index will be saved
|
|
23
|
+
#
|
|
24
|
+
# If no block is given, it will use ``Array#include?`` to check if either the menu option or the menu index exists
|
|
25
|
+
# in the options user list
|
|
26
|
+
#
|
|
27
|
+
# The following flags can be used to alter the behavior:
|
|
28
|
+
# - all_if_empty: Select all options if the user's options list is empty
|
|
29
|
+
#
|
|
30
|
+
# @param options_menu [Array] Menu options list
|
|
31
|
+
# @param options_user [Array] List of user selected options
|
|
32
|
+
# @param all_if_empty [Boolean] Whether to select all options if the user array is empty
|
|
33
|
+
# @param block [Proc] Evaluation callback
|
|
34
|
+
#
|
|
35
|
+
# @return [Array<Integer>]
|
|
36
|
+
#
|
|
37
|
+
# @yieldparam [Object]
|
|
38
|
+
# @yieldparam [Integer]
|
|
39
|
+
# @yieldparam [Object]
|
|
40
|
+
#
|
|
41
|
+
def self.menu_default_indexes(options_menu, options_user, all_if_empty: false, &block)
|
|
42
|
+
# Checks if user's options list is empty (and populate it with all indexes if allowed)
|
|
43
|
+
return (1..options_menu.size).to_a if options_user.empty? && all_if_empty
|
|
44
|
+
return [] if options_user.empty?
|
|
45
|
+
|
|
46
|
+
# Process the menu options list normally
|
|
47
|
+
options_indexes = []
|
|
48
|
+
if block_given?
|
|
49
|
+
options_menu.each_with_index do |menu_option, index|
|
|
50
|
+
menu_index = index + 1
|
|
51
|
+
options_indexes << menu_index if options_user.any? { |opt_user| yield menu_option, menu_index, opt_user }
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
options_menu.each_with_index do |menu_option, index|
|
|
55
|
+
menu_index = index + 1
|
|
56
|
+
options_indexes << menu_index if options_user.include?(menu_option) || options_user.include?(menu_index)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
options_indexes
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
#
|
|
63
|
+
# Validates the path
|
|
64
|
+
#
|
|
65
|
+
# Returns a ``MatchData`` if the path is invalid, otherwise ``nil``
|
|
66
|
+
#
|
|
67
|
+
# The ``MatchData`` object contains the invalid characters
|
|
68
|
+
#
|
|
69
|
+
# @param path [String] Path
|
|
70
|
+
#
|
|
71
|
+
# @return [MatchData]
|
|
72
|
+
#
|
|
73
|
+
def self.validate_path(path)
|
|
74
|
+
path.to_s.match(INVALID_CHARACTERS)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
#
|
|
78
|
+
# Checks whether the path is valid or not
|
|
79
|
+
#
|
|
80
|
+
# Returns ``true`` if the path is valid, otherwise ``false``
|
|
81
|
+
#
|
|
82
|
+
# @param path [String] Path
|
|
83
|
+
#
|
|
84
|
+
# @return [Boolean]
|
|
85
|
+
#
|
|
86
|
+
def self.valid_path?(path)
|
|
87
|
+
validate_path(path).nil?
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|