-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.rb
167 lines (158 loc) · 6.73 KB
/
setup.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#==============================================================================
# ** TDD Plugins Module - Setup File
#------------------------------------------------------------------------------
# Description
# ===========
# This file holds references to other scripts to be loaded, including
# order information, etc.
#==============================================================================
#==================+
# Folder structure |
#==================+
# The first thing we want to do is set up our folder structure. We do this by
# creating a hash. An explanation can be found below this structure
#------------------------------------------------------------------------------
plugins = {
"lib" => {
"misc" => {},
"util" => {
exclude: ["print_backtrace"]
},
},
"config" => {
order: ["module_IB", :rest],
exclude: ["original_levels", "original_levels_clean", "original_levels_new"]
},
"src" => {
"modules" => {
"movement" => {
order: ["movement", "keyboard_movement", "zig_zag_movement", :rest]
},
"powerup" => {},
# exclude: ["game_entity"]
},
exclude: ["old"],
"level" => {},
"screen" => {},
"ship" => {
order: ["ship", :rest]
},
"enemy" => {},
"player" => {},
"weapon" => {
order: ["weapon", :rest]
},
"bullet" => {},
"spawner" => {
"phase" => {},
order: ["spawner", :rest]
},
"powerup"=> {
order: ["power_up", :rest]
}
}
}
# Folder structure explanation |
#==============================+
# Hashes are key/value pairs of data. The way this is used for the Plugin
# Framework is relatively simple. A string ("string text") denotes a subfolder
# in the Plugin Framework root folder. This is a folder that resides in
# <Your Project/Data>. In the demo project, this folder is
# <Plugin Test/Data/Plugins>
#
# If you look at the first line within the plugins hash, it looks like this:
#
# "Global Settings" => {},
# "Global Settings" refers to the folder with the same name within the
# Plugins folder. The arrow (=>) sets the value to an empty hash ({}) in this
# example. We do this because folders can have options applied to them, like
# ordering the scripts files within them, and nested folders. Let's look at the
# next folder definition for an example.
#
# ------------------------------.
# "Example 1" => { |
# "classes" => {}, |
# "modules" => { |
# exclude: ["exclude me"] |
# } |
# }, |
# ------------------------------'
#
# Here we see that within the folder "Example 1", we nest two sub-folders:
# "classes" and "modules". "classes" is the defined as earlier with no options,
# while "smodules" has an option called exclude:
# exclude: is a symbol; it could also be written as :exclude =>
# in the example above, but exclude: is simply shorthand for that.
# The exclude: option takes an array (a comma separated list of values inside
# [] brackets) of file which you do not wish to load. This can be very useful
# if you're debugging your game, so that you don't have to go in and delete the
# script file, or comment it out in any way.
#
# ------------------------------.
# "Example 2" => { |
# order: [ |
# "data", |
# :rest, |
# "insert last" |
# ] |
# }, |
# ------------------------------'
#
# In this third example, we introduce a new option called order:
# Similar to exclude:, this is an array that can hold a list of files within
# that given folder which you prefer to load in a set order; all files not
# listed will be loaded alphabetically after the listed files.
# However, for added configurability, you can use a symbol titled :rest within
# this list of files, and what this will do is make sure that all files listed
# above it are loaded in the given order first, then all files listed below it
# listed in the given order, and remaining files loaded alphabetically in
# between (the "rest" of the files, hence :rest).
# This might seem very complicated, but it's a useful feature. Often there are
# scripts that must be loaded after all other scripts that affect the same
# functionality. The same goes for scripts needed to be loaded before all other
# scripts. This way, you can make sure that order is retained for such scripts,
# but without having to type all the files in between that are inconsequential
# to ordering. This is one of the headaches of the built-in script editor that
# spurred me to create this framework.
#
# ------------------------------.
# "Example 3" => { |
# "sub 1" => { |
# "sub 2" => {} |
# } |
# } |
# ------------------------------'
#
# In the last example, we nest a subfolder ("sub 2") within another subfolder
# ("sub 1") beneath the "Example 3" folder, this time with no options.
#==============================================================================
#=======================+
# Configuration of path |
#=======================+
# The following should be set to the folder within your project's Data folder
# where the plugin folders and plugin framework resides. The below value is
# default and where it's placed in the Plugins Framework demo project.
# You don't specify your project's folder name nor the data folder; only the
# subfolder. "Plugins" is therefore actually "Your Project/Data/Plugins".
ROOT_PATH = "ignition-boost"
#======================================+
# Loading the Plugins Framework module |
#======================================+
# We then load the plugins module file so that we can use the Plugins module.
# This should not be changed.
load_script "Data/#{ROOT_PATH}/plugins_module.rb" # Do not edit
#============================================+
# Setting up and starting the Plugins module |
#============================================+
# We tell the plugins module where the root path is (the folder where these
# files resist within your project's Data folder, specified earlier). This is
# necessary because we need absolute paths if we encrypt our game later on.
Plugins.root_path = ROOT_PATH
# We then load the folder structure we made earlier using the
# load_recursive method
Plugins.load_recursive(plugins)
# Then we package all plugin scripts into a single scripts.rb file. This is
# also necessary for this to work when we encrypt our game.
Plugins.package
# Finally we load the packaged scripts.rb file into Ace.
load_script("Data/#{ROOT_PATH}/target/target.rb")