gamefic-sdk 1.7.0 → 2.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 +5 -5
- data/bin/gamefic +16 -0
- data/lib/gamefic-sdk.rb +4 -24
- data/lib/gamefic-sdk/diagram.rb +205 -0
- data/lib/gamefic-sdk/scaffold.rb +54 -0
- data/lib/gamefic-sdk/server.rb +81 -65
- data/lib/gamefic-sdk/shell.rb +22 -129
- data/lib/gamefic-sdk/tasks.rb +40 -0
- data/lib/gamefic-sdk/tasks/common.rb +21 -0
- data/lib/gamefic-sdk/tasks/ruby.rb +99 -0
- data/lib/gamefic-sdk/tasks/web.rb +82 -0
- data/lib/gamefic-sdk/version.rb +5 -5
- metadata +123 -139
- data/bin/gfk +0 -6
- data/html/core/engine.js +0 -114
- data/html/core/jquery.js +0 -5
- data/html/core/jquery.modal.css +0 -44
- data/html/core/jquery.modal.js +0 -225
- data/html/core/js.cookie.js +0 -137
- data/html/sinatra/engine.js +0 -65
- data/html/skins/hypertext/compass.png +0 -0
- data/html/skins/hypertext/index.html +0 -149
- data/html/skins/hypertext/style.css +0 -74
- data/html/skins/minimal/index.html.erb +0 -22
- data/html/skins/minimal/index.rb +0 -4
- data/html/skins/minimal/play.js +0 -36
- data/html/skins/minimal/style.css +0 -8
- data/html/skins/multimedia/close.png +0 -0
- data/html/skins/multimedia/index.html +0 -179
- data/html/skins/multimedia/mobile.css +0 -10
- data/html/skins/multimedia/spinner.gif +0 -0
- data/html/skins/multimedia/style.css +0 -186
- data/html/skins/standard/index.html.erb +0 -22
- data/html/skins/standard/index.rb +0 -4
- data/html/skins/standard/play.js +0 -18
- data/html/skins/standard/style.css +0 -73
- data/lib/gamefic-sdk/build.rb +0 -30
- data/lib/gamefic-sdk/config.rb +0 -126
- data/lib/gamefic-sdk/debug.rb +0 -4
- data/lib/gamefic-sdk/debug/action.rb +0 -30
- data/lib/gamefic-sdk/debug/plot.rb +0 -23
- data/lib/gamefic-sdk/platform.rb +0 -22
- data/lib/gamefic-sdk/platform/base.rb +0 -68
- data/lib/gamefic-sdk/platform/gfic.rb +0 -27
- data/lib/gamefic-sdk/platform/sinatra.rb +0 -98
- data/lib/gamefic-sdk/platform/web.rb +0 -176
- data/lib/gamefic-sdk/platform/web/app_config.rb +0 -81
- data/lib/gamefic-sdk/platform/web/engine.rb +0 -44
- data/lib/gamefic-sdk/platform/web/user.rb +0 -19
- data/lib/gamefic-sdk/shell/init.rb +0 -83
- data/lib/gamefic-sdk/shell/test.rb +0 -32
- data/scripts/save-restore-undo.plot.rb +0 -25
- data/scripts/snapshots.plot.rb +0 -16
- data/scripts/standard.plot.rb +0 -10
- data/scripts/standard/actions.plot.rb +0 -13
- data/scripts/standard/actions/drop.plot.rb +0 -19
- data/scripts/standard/actions/enter.plot.rb +0 -19
- data/scripts/standard/actions/go.plot.rb +0 -48
- data/scripts/standard/actions/insert.plot.rb +0 -37
- data/scripts/standard/actions/inventory.plot.rb +0 -9
- data/scripts/standard/actions/leave.plot.rb +0 -30
- data/scripts/standard/actions/look.plot.rb +0 -108
- data/scripts/standard/actions/nil.plot.rb +0 -36
- data/scripts/standard/actions/place.plot.rb +0 -41
- data/scripts/standard/actions/quit.plot.rb +0 -11
- data/scripts/standard/actions/take.plot.rb +0 -31
- data/scripts/standard/actions/talk.plot.rb +0 -27
- data/scripts/standard/actions/wait.plot.rb +0 -3
- data/scripts/standard/clothing.plot.rb +0 -4
- data/scripts/standard/clothing/actions.plot.rb +0 -4
- data/scripts/standard/clothing/actions/doff.plot.rb +0 -12
- data/scripts/standard/clothing/actions/drop.plot.rb +0 -8
- data/scripts/standard/clothing/actions/inventory.plot.rb +0 -14
- data/scripts/standard/clothing/actions/wear.plot.rb +0 -20
- data/scripts/standard/clothing/entities.plot.rb +0 -7
- data/scripts/standard/clothing/entities/clothing.plot.rb +0 -5
- data/scripts/standard/clothing/entities/coat.plot.rb +0 -3
- data/scripts/standard/clothing/entities/gloves.plot.rb +0 -3
- data/scripts/standard/clothing/entities/hat.plot.rb +0 -3
- data/scripts/standard/clothing/entities/pants.plot.rb +0 -3
- data/scripts/standard/clothing/entities/shirt.plot.rb +0 -3
- data/scripts/standard/clothing/entities/shoes.plot.rb +0 -3
- data/scripts/standard/container.plot.rb +0 -28
- data/scripts/standard/container/actions.plot.rb +0 -0
- data/scripts/standard/container/entities.plot.rb +0 -5
- data/scripts/standard/direction.plot.rb +0 -55
- data/scripts/standard/edible.plot.rb +0 -21
- data/scripts/standard/entities.plot.rb +0 -12
- data/scripts/standard/entities/character.plot.rb +0 -10
- data/scripts/standard/entities/fixture.plot.rb +0 -3
- data/scripts/standard/entities/item.plot.rb +0 -3
- data/scripts/standard/entities/portal.plot.rb +0 -44
- data/scripts/standard/entities/receptacle.plot.rb +0 -3
- data/scripts/standard/entities/room.plot.rb +0 -57
- data/scripts/standard/entities/rubble.plot.rb +0 -11
- data/scripts/standard/entities/scenery.plot.rb +0 -3
- data/scripts/standard/entities/supporter.plot.rb +0 -7
- data/scripts/standard/entities/thing.plot.rb +0 -7
- data/scripts/standard/give.plot.rb +0 -27
- data/scripts/standard/lockable.plot.rb +0 -79
- data/scripts/standard/modules.plot.rb +0 -9
- data/scripts/standard/modules/attachable.plot.rb +0 -12
- data/scripts/standard/modules/auto_takes.plot.rb +0 -50
- data/scripts/standard/modules/enterable.plot.rb +0 -15
- data/scripts/standard/modules/explicit_exits.plot.rb +0 -15
- data/scripts/standard/modules/itemizable.plot.rb +0 -18
- data/scripts/standard/modules/locale_description.plot.rb +0 -20
- data/scripts/standard/modules/parent-room.plot.rb +0 -9
- data/scripts/standard/modules/portable.plot.rb +0 -11
- data/scripts/standard/modules/use.plot.rb +0 -51
- data/scripts/standard/openable.plot.rb +0 -43
- data/scripts/standard/pathfinder.plot.rb +0 -65
- data/scripts/standard/queries.plot.rb +0 -21
- data/scripts/standard/test.plot.rb +0 -10
- data/scripts/undo.plot.rb +0 -13
data/lib/gamefic-sdk/debug.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require 'gamefic'
|
|
2
|
-
|
|
3
|
-
module Gamefic::Sdk
|
|
4
|
-
module Debug
|
|
5
|
-
class Action < Gamefic::Action
|
|
6
|
-
attr_reader :source_location
|
|
7
|
-
def initialize(command, *queries, &proc)
|
|
8
|
-
super
|
|
9
|
-
@executed = false
|
|
10
|
-
caller.each { |c|
|
|
11
|
-
if c.end_with?(":in `stage'")
|
|
12
|
-
@source_location = c[0..-12]
|
|
13
|
-
break
|
|
14
|
-
end
|
|
15
|
-
}
|
|
16
|
-
end
|
|
17
|
-
def execute *args
|
|
18
|
-
super
|
|
19
|
-
@executed = true
|
|
20
|
-
end
|
|
21
|
-
def executed?
|
|
22
|
-
@executed
|
|
23
|
-
end
|
|
24
|
-
def standard?
|
|
25
|
-
return false if source_location.nil?
|
|
26
|
-
source_location.start_with?(Gamefic::Sdk::GLOBAL_IMPORT_PATH)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require 'gamefic'
|
|
2
|
-
|
|
3
|
-
module Gamefic::Sdk::Debug
|
|
4
|
-
class Plot < Gamefic::Plot
|
|
5
|
-
attr_reader :main_dir
|
|
6
|
-
def post_initialize
|
|
7
|
-
meta :debug, Query::Text.new(/^unused$/) do |actor, text|
|
|
8
|
-
unused = []
|
|
9
|
-
actions.each { |a|
|
|
10
|
-
if !a.standard? and !a.executed?
|
|
11
|
-
unused.push "#{a.verb}:#{a.source_location}"
|
|
12
|
-
end
|
|
13
|
-
}
|
|
14
|
-
actor.tell "#{unused.join("\r\n")}"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
def action(command, *queries, &proc)
|
|
18
|
-
act = Gamefic::Sdk::Debug::Action.new(command, *queries, &proc)
|
|
19
|
-
playbook.send :add_action, act
|
|
20
|
-
act
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
data/lib/gamefic-sdk/platform.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Gamefic::Sdk
|
|
2
|
-
|
|
3
|
-
module Platform
|
|
4
|
-
autoload :Base, 'gamefic-sdk/platform/base'
|
|
5
|
-
autoload :Gfic, 'gamefic-sdk/platform/gfic'
|
|
6
|
-
autoload :Web, 'gamefic-sdk/platform/web'
|
|
7
|
-
autoload :Sinatra, 'gamefic-sdk/platform/sinatra'
|
|
8
|
-
|
|
9
|
-
#def self.load directory, platform
|
|
10
|
-
# config_file = File.join(directory, 'config.yaml')
|
|
11
|
-
#end
|
|
12
|
-
|
|
13
|
-
def self.load config, name
|
|
14
|
-
target = config.targets[name]
|
|
15
|
-
raise ArgumentError.new("Config does not have a target '#{name}'") if target.nil?
|
|
16
|
-
cls = Gamefic::Sdk::Platform.const_get(target['platform'])
|
|
17
|
-
raise ArgumentError.new("Platform '#{target['platform']}' not found") if target.nil?
|
|
18
|
-
cls.new(config: config, target: target.merge('name' => name))
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
require 'gamefic-sdk'
|
|
2
|
-
require 'gamefic-sdk/debug/plot'
|
|
3
|
-
#require 'gamefic-sdk/plot_config'
|
|
4
|
-
require 'pathname'
|
|
5
|
-
|
|
6
|
-
module Gamefic::Sdk
|
|
7
|
-
class Platform::Base
|
|
8
|
-
# @return [Gamefic::Sdk::Config]
|
|
9
|
-
attr_reader :config
|
|
10
|
-
|
|
11
|
-
# @return [Hash]
|
|
12
|
-
attr_reader :target
|
|
13
|
-
|
|
14
|
-
#def initialize config, name = nil
|
|
15
|
-
def initialize config: Gamefic::Sdk::Config.new, target: {}
|
|
16
|
-
#@source_dir = source_dir
|
|
17
|
-
#@name = name
|
|
18
|
-
#@config = config
|
|
19
|
-
#@config.freeze
|
|
20
|
-
@config = config
|
|
21
|
-
@target = target
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def name
|
|
25
|
-
@name ||= (target['name'] || self.class.to_s.split('::').last.downcase)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def build_target
|
|
29
|
-
@build_target ||= File.join(config.build_path, name)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def release_target
|
|
33
|
-
@release_target ||= File.join(config.release_path, name)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# @return [Gamefic::Plot]
|
|
37
|
-
def plot
|
|
38
|
-
if @plot.nil?
|
|
39
|
-
paths = [config.script_path, config.import_path, Gamefic::Sdk::GLOBAL_SCRIPT_PATH]
|
|
40
|
-
# @todo: Should really use Gamefic::Sdk::Debug::Plot or just Gamfic::Plot?
|
|
41
|
-
@plot = Gamefic::Sdk::Debug::Plot.new(Gamefic::Source::File.new(*paths))
|
|
42
|
-
@plot.script 'main'
|
|
43
|
-
end
|
|
44
|
-
@plot
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def build
|
|
48
|
-
# Platforms need to build/compile the deployment here.
|
|
49
|
-
raise "The base Platform class does not have a build method"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def clean
|
|
53
|
-
puts "Nothing to do for this platform."
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# Get a hash of build metadata.
|
|
57
|
-
#
|
|
58
|
-
# @return [Hash]
|
|
59
|
-
def metadata
|
|
60
|
-
hash = {}
|
|
61
|
-
hash[:uuid] = config.uuid
|
|
62
|
-
hash[:gamefic_version] = "#{Gamefic::VERSION}"
|
|
63
|
-
hash[:sdk_version] = "#{Gamefic::Sdk::VERSION}"
|
|
64
|
-
hash[:build_date] = "#{DateTime.now}"
|
|
65
|
-
hash
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require 'zip'
|
|
2
|
-
require 'tempfile'
|
|
3
|
-
require 'yaml'
|
|
4
|
-
|
|
5
|
-
module Gamefic::Sdk
|
|
6
|
-
|
|
7
|
-
class Platform::Gfic < Platform::Base
|
|
8
|
-
def build
|
|
9
|
-
FileUtils.rm filename if File.file?(filename)
|
|
10
|
-
FileUtils.mkdir_p release_target
|
|
11
|
-
Zip::File.open(filename, Zip::File::CREATE) do |zipfile|
|
|
12
|
-
plot.imported_scripts.each { |script|
|
|
13
|
-
zipfile.add File.join('scripts', "#{script.path}.plot.rb"), script.absolute_path
|
|
14
|
-
}
|
|
15
|
-
Tempfile.open('metadata.yaml') do |file|
|
|
16
|
-
file.puts metadata.to_yaml
|
|
17
|
-
zipfile.add "metadata.yaml", file.path
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def filename
|
|
23
|
-
@filename ||= File.join(release_target, (target['filename'] || 'game.gfic'))
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
require 'gamefic'
|
|
2
|
-
require 'gamefic-sdk'
|
|
3
|
-
|
|
4
|
-
module Gamefic::Sdk
|
|
5
|
-
|
|
6
|
-
class Platform::Sinatra < Platform::Web
|
|
7
|
-
autoload :AppConfig, 'gamefic-sdk/platform/web/app_config'
|
|
8
|
-
|
|
9
|
-
def build
|
|
10
|
-
STDERR.puts "Building for Sinatra"
|
|
11
|
-
FileUtils.mkdir_p release_target
|
|
12
|
-
copy_html_files
|
|
13
|
-
render_index
|
|
14
|
-
copy_assets
|
|
15
|
-
copy_media
|
|
16
|
-
FileUtils.cp_r File.join(Gamefic::Sdk::HTML_TEMPLATE_PATH, 'sinatra', 'engine.js'), File.join(release_target, 'core', 'engine.js')
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
#def clean
|
|
20
|
-
# FileUtils.remove_entry_secure config['build_path'] if File.exist?(config['build_path'])
|
|
21
|
-
# FileUtils.mkdir_p config['build_path']
|
|
22
|
-
# puts "#{config['build_path']} cleaned."
|
|
23
|
-
#end
|
|
24
|
-
|
|
25
|
-
def app_config
|
|
26
|
-
@app_config ||= AppConfig.new config.source_dir, config, ["core/engine.js"]
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
private
|
|
30
|
-
|
|
31
|
-
def resolve filename, paths
|
|
32
|
-
absolute = nil
|
|
33
|
-
paths.each { |path|
|
|
34
|
-
if File.file?("#{path}/#{filename}")
|
|
35
|
-
absolute = File.join(path, filename)
|
|
36
|
-
break
|
|
37
|
-
end
|
|
38
|
-
}
|
|
39
|
-
raise "#{filename} not found" if absolute.nil?
|
|
40
|
-
absolute
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# Copy everything in source except config and template
|
|
44
|
-
def copy_html_files
|
|
45
|
-
Dir.entries(app_config.html_dir).each { |entry|
|
|
46
|
-
if entry != 'index.rb' and entry != 'index.html.erb' and entry != '.' and entry != '..'
|
|
47
|
-
FileUtils.mkdir_p release_target + '/' + File.dirname(entry)
|
|
48
|
-
FileUtils.cp_r "#{app_config.html_dir}/#{entry}", "#{release_target}/#{entry}"
|
|
49
|
-
end
|
|
50
|
-
}
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def render_index
|
|
54
|
-
# Render index
|
|
55
|
-
File.open(release_target + "/index.html", "w") do |file|
|
|
56
|
-
file << app_config.render
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def copy_assets
|
|
61
|
-
paths = app_config.resource_paths
|
|
62
|
-
paths.push build_target
|
|
63
|
-
app_config.javascripts.each { |js|
|
|
64
|
-
absolute = resolve(js, paths)
|
|
65
|
-
FileUtils.mkdir_p release_target + "/" + File.dirname(js)
|
|
66
|
-
FileUtils.cp_r absolute, release_target + "/" + js
|
|
67
|
-
}
|
|
68
|
-
app_config.stylesheets.each { |css|
|
|
69
|
-
absolute = resolve(css, paths)
|
|
70
|
-
FileUtils.mkdir_p release_target + "/" + File.dirname(css)
|
|
71
|
-
FileUtils.cp_r absolute, release_target + "/" + css
|
|
72
|
-
}
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
=begin
|
|
76
|
-
def copy_media
|
|
77
|
-
# Copy media
|
|
78
|
-
pc = PlotConfig.new "#{source_dir}/config.yaml"
|
|
79
|
-
pc.media_paths.each { |path|
|
|
80
|
-
if File.directory?(path)
|
|
81
|
-
FileUtils.mkdir_p release_target + "/media"
|
|
82
|
-
Dir.entries(path).each { |entry|
|
|
83
|
-
if entry != '.' and entry != '..'
|
|
84
|
-
FileUtils.mkdir_p release_target + "/media/" + File.dirname(entry)
|
|
85
|
-
FileUtils.cp_r path + "/" + entry, release_target + "/media/" + entry
|
|
86
|
-
end
|
|
87
|
-
}
|
|
88
|
-
end
|
|
89
|
-
}
|
|
90
|
-
end
|
|
91
|
-
=end
|
|
92
|
-
|
|
93
|
-
def metadata_code
|
|
94
|
-
"\nGameficOpal.static_plot.metadata = JSON.parse('#{metadata.to_json}')"
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
end
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
require 'gamefic'
|
|
2
|
-
require 'gamefic-sdk'
|
|
3
|
-
require 'opal'
|
|
4
|
-
require 'uglifier'
|
|
5
|
-
|
|
6
|
-
module Gamefic::Sdk
|
|
7
|
-
|
|
8
|
-
class Platform::Web < Platform::Base
|
|
9
|
-
autoload :AppConfig, 'gamefic-sdk/platform/web/app_config'
|
|
10
|
-
|
|
11
|
-
def app_config
|
|
12
|
-
@app_config ||= AppConfig.new config.source_dir, config, ["core/opal.js", "core/gamefic.js", "core/static.js", "core/scripts.js", "core/engine.js"]
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def build
|
|
16
|
-
FileUtils.mkdir_p release_target
|
|
17
|
-
FileUtils.mkdir_p build_target
|
|
18
|
-
copy_html_files
|
|
19
|
-
build_opal_js
|
|
20
|
-
build_gamefic_js
|
|
21
|
-
build_static_js
|
|
22
|
-
build_scripts_js
|
|
23
|
-
render_index
|
|
24
|
-
copy_assets
|
|
25
|
-
copy_media
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def clean
|
|
29
|
-
FileUtils.remove_entry_secure build_target if File.exist?(build_target)
|
|
30
|
-
puts "#{name} cleaned."
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def html_dir
|
|
34
|
-
if @html_dir.nil?
|
|
35
|
-
local_dir = (target['html'] ? target['html'] : 'html')
|
|
36
|
-
@html_dir = Pathname.new(config.source_dir).join(local_dir).to_s
|
|
37
|
-
@html_dir = nil unless Dir.exist?(@html_dir)
|
|
38
|
-
if @html_dir.nil?
|
|
39
|
-
@html_dir = File.join(Gamefic::Sdk::HTML_TEMPLATE_PATH, 'skins', 'standard')
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
@html_dir
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
private
|
|
46
|
-
|
|
47
|
-
def resolve filename, paths
|
|
48
|
-
absolute = nil
|
|
49
|
-
paths.each { |path|
|
|
50
|
-
if File.file?("#{path}/#{filename}")
|
|
51
|
-
absolute = File.join(path, filename)
|
|
52
|
-
break
|
|
53
|
-
end
|
|
54
|
-
}
|
|
55
|
-
raise "#{filename} not found" if absolute.nil?
|
|
56
|
-
absolute
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# Copy everything in source except config and template
|
|
60
|
-
def copy_html_files
|
|
61
|
-
#Dir.entries(app_config.html_dir).each { |entry|
|
|
62
|
-
Dir.entries(html_dir).each { |entry|
|
|
63
|
-
if entry != 'index.rb' and entry != 'index.html.erb' and entry != '.' and entry != '..'
|
|
64
|
-
FileUtils.mkdir_p release_target + '/' + File.dirname(entry)
|
|
65
|
-
FileUtils.cp_r "#{app_config.html_dir}/#{entry}", "#{release_target}/#{entry}"
|
|
66
|
-
end
|
|
67
|
-
}
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def build_opal_js
|
|
71
|
-
# Make sure core exists in build directory
|
|
72
|
-
FileUtils.mkdir_p build_target + "/core"
|
|
73
|
-
# Opal core
|
|
74
|
-
if !File.exist?(build_target + "/core/opal.js")
|
|
75
|
-
File.open(build_target + "/core/opal.js", "w") do |file|
|
|
76
|
-
file << Uglifier.compile(
|
|
77
|
-
Opal::Builder.build('opal').to_s + "\n" + Opal::Builder.build('json').to_s + "\n" + Opal::Builder.build('native').to_s
|
|
78
|
-
)
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def build_gamefic_js
|
|
84
|
-
# Gamefic core
|
|
85
|
-
Opal.use_gem 'gamefic'
|
|
86
|
-
if !File.exist?(build_target + "/core/gamefic.js")
|
|
87
|
-
File.open(build_target + "/core/gamefic.js", "w") do |file|
|
|
88
|
-
file << Uglifier.compile(Opal::Builder.build('gamefic').to_s)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def build_static_js
|
|
94
|
-
Opal.append_path Gamefic::Sdk::LIB_PATH
|
|
95
|
-
if !File.exist?(build_target + "/core/static.js")
|
|
96
|
-
File.open(build_target + "/core/static.js", "w") do |file|
|
|
97
|
-
file << Uglifier.compile(
|
|
98
|
-
Opal::Builder.build('gamefic-sdk/platform/web/engine').to_s + "\n" + Opal::Builder.build('gamefic-sdk/platform/web/user').to_s
|
|
99
|
-
)
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def build_scripts_js
|
|
105
|
-
File.open("#{build_target}/scripts.rb", 'w') do |file|
|
|
106
|
-
#file << "def Module.const_missing sym\n"
|
|
107
|
-
#file << "puts 'From Object to Gamefic'\n"
|
|
108
|
-
#file << "Gamefic.const_get sym\n"
|
|
109
|
-
#file << "end\n"
|
|
110
|
-
file << "module Gamefic\n"
|
|
111
|
-
file << "$scripts = {}\n"
|
|
112
|
-
plot.imported_scripts.each { |script|
|
|
113
|
-
file << "$scripts['#{script.path}'] = proc {\n"
|
|
114
|
-
file << script.read
|
|
115
|
-
file << "\n}\n"
|
|
116
|
-
}
|
|
117
|
-
file << "$source = Gamefic::Source::Text.new($scripts)\n"
|
|
118
|
-
file << "$plot = Gamefic::Plot.new($source)\n"
|
|
119
|
-
file << "$plot.script 'main'\n"
|
|
120
|
-
file << "$engine = Gamefic::Engine::Web.new($plot)\n"
|
|
121
|
-
file << "end\n"
|
|
122
|
-
file << "$plot.stage do\n"
|
|
123
|
-
file << "def self.const_missing sym\n"
|
|
124
|
-
file << "Gamefic.const_get sym\n"
|
|
125
|
-
file << "end\n"
|
|
126
|
-
file << "end\n"
|
|
127
|
-
#file << "def $plot.theater.const_missing sym\n"
|
|
128
|
-
#file << 'puts "Trying to get #{sym} from object"' + "\n"
|
|
129
|
-
#file << "Object.const_get sym\n"
|
|
130
|
-
#file << "end\n"
|
|
131
|
-
end
|
|
132
|
-
Opal.append_path build_target
|
|
133
|
-
File.open(build_target + "/core/scripts.js", 'w') do |file|
|
|
134
|
-
file << Uglifier.compile(Opal::Builder.build('scripts').to_s)
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
def render_index
|
|
139
|
-
# Render index
|
|
140
|
-
File.open(release_target + "/index.html", "w") do |file|
|
|
141
|
-
file << app_config.render
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def copy_assets
|
|
146
|
-
paths = app_config.resource_paths
|
|
147
|
-
paths.push build_target
|
|
148
|
-
app_config.javascripts.each { |js|
|
|
149
|
-
absolute = resolve(js, paths)
|
|
150
|
-
FileUtils.mkdir_p release_target + "/" + File.dirname(js)
|
|
151
|
-
FileUtils.cp_r absolute, release_target + "/" + js
|
|
152
|
-
}
|
|
153
|
-
app_config.stylesheets.each { |css|
|
|
154
|
-
absolute = resolve(css, paths)
|
|
155
|
-
FileUtils.mkdir_p release_target + "/" + File.dirname(css)
|
|
156
|
-
FileUtils.cp_r absolute, release_target + "/" + css
|
|
157
|
-
}
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def copy_media
|
|
161
|
-
FileUtils.mkdir_p release_target + "/media"
|
|
162
|
-
return unless File.directory?(config.media_path)
|
|
163
|
-
Dir.entries(config.media_path).each { |entry|
|
|
164
|
-
if entry != '.' and entry != '..'
|
|
165
|
-
FileUtils.mkdir_p release_target + "/media/" + File.dirname(entry)
|
|
166
|
-
FileUtils.cp_r config.media_path + "/" + entry, release_target + "/media/" + entry
|
|
167
|
-
end
|
|
168
|
-
}
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
def metadata_code
|
|
172
|
-
"\nGameficOpal.static_plot.metadata = JSON.parse('#{metadata.to_json}')"
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
end
|