limelight 0.2.1-java → 0.3.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/bin/ll.bat +1 -1
  2. data/lib/i4jruntime.jar +0 -0
  3. data/lib/junit-4.4.jar +0 -0
  4. data/lib/limelight.jar +0 -0
  5. data/lib/limelight/animation.rb +3 -3
  6. data/lib/limelight/builtin/players.rb +2 -1
  7. data/lib/limelight/builtin/players/combo_box.rb +8 -2
  8. data/lib/limelight/builtin/players/image.rb +47 -0
  9. data/lib/limelight/builtin/styles.rb +1 -1
  10. data/lib/limelight/casting_director.rb +70 -39
  11. data/lib/limelight/commands/command.rb +150 -0
  12. data/lib/limelight/commands/create_command.rb +79 -0
  13. data/lib/limelight/commands/freeze_command.rb +113 -0
  14. data/lib/limelight/commands/open_command.rb +49 -0
  15. data/lib/limelight/commands/pack_command.rb +45 -0
  16. data/lib/limelight/dsl/build_exception.rb +51 -0
  17. data/lib/limelight/dsl/menu_bar.rb +71 -0
  18. data/lib/limelight/dsl/production_builder.rb +71 -0
  19. data/lib/limelight/dsl/prop_builder.rb +155 -0
  20. data/lib/limelight/dsl/stage_builder.rb +105 -0
  21. data/lib/limelight/dsl/styles_builder.rb +134 -0
  22. data/lib/limelight/file_loader.rb +46 -0
  23. data/lib/limelight/gems.rb +45 -0
  24. data/lib/limelight/java_couplings.rb +7 -2
  25. data/lib/limelight/java_util.rb +2 -15
  26. data/lib/limelight/main.rb +7 -5
  27. data/lib/limelight/producer.rb +87 -66
  28. data/lib/limelight/production.rb +42 -4
  29. data/lib/limelight/prop.rb +84 -70
  30. data/lib/limelight/scene.rb +75 -20
  31. data/lib/limelight/specs/spec_helper.rb +58 -0
  32. data/lib/limelight/stage.rb +11 -6
  33. data/lib/limelight/string.rb +35 -0
  34. data/lib/limelight/studio.rb +29 -0
  35. data/lib/limelight/templates/production_templater.rb +42 -0
  36. data/lib/limelight/templates/scene_templater.rb +41 -0
  37. data/lib/limelight/templates/sources/freezing/limelight_init.rb.template +5 -0
  38. data/lib/limelight/templates/sources/production/init.rb.template +15 -0
  39. data/lib/limelight/templates/sources/production/production.rb.template +9 -0
  40. data/lib/limelight/templates/sources/production/stages.rb.template +17 -0
  41. data/lib/limelight/templates/sources/production/styles.rb.template +12 -0
  42. data/lib/limelight/templates/sources/scene/props.rb.template +6 -0
  43. data/lib/limelight/templates/sources/scene/styles.rb.template +18 -0
  44. data/lib/limelight/templates/templater.rb +128 -0
  45. data/lib/limelight/templates/templater_logger.rb +36 -0
  46. data/lib/limelight/theater.rb +21 -7
  47. data/lib/limelight/util.rb +22 -6
  48. data/lib/limelight/version.rb +2 -2
  49. data/productions/examples/8thlight.com/styles.rb +1 -1
  50. data/productions/examples/langstons_ant/html_javascript/ant.html +1 -1
  51. data/productions/examples/langstons_ant/init.rb +1 -0
  52. data/productions/examples/langstons_ant/players/log.rb +2 -2
  53. data/productions/examples/langstons_ant/players/world.rb +0 -26
  54. data/productions/examples/sandbox.llp +0 -0
  55. data/productions/examples/sandbox/click_me/players/chromaton.rb +10 -4
  56. data/productions/examples/sandbox/floaters/players/floater.rb +4 -2
  57. data/productions/examples/sandbox/gradients/players/spinner.rb +5 -1
  58. data/productions/examples/sandbox/gradients/players/teaser.rb +2 -2
  59. data/productions/examples/sandbox/gradients/players/wave.rb +2 -2
  60. data/productions/examples/sandbox/gradients/players/waves.rb +2 -2
  61. data/productions/examples/sandbox/header.rb +1 -0
  62. data/productions/examples/sandbox/images/logo.png +0 -0
  63. data/productions/examples/sandbox/images_scene/props.rb +25 -0
  64. data/productions/examples/sandbox/images_scene/styles.rb +30 -0
  65. data/productions/examples/sandbox/inputs/styles.rb +1 -1
  66. data/productions/examples/sandbox/scrolling/props.rb +12 -12
  67. data/productions/examples/sandbox/teaser/players/fader.rb +2 -8
  68. data/productions/stage_composer/inspector/styles.rb +2 -2
  69. data/productions/startup/styles.rb +2 -2
  70. data/spec/builtin/players/button_spec.rb +0 -1
  71. data/spec/builtin/players/image_spec.rb +41 -0
  72. data/spec/casting_director_spec.rb +114 -44
  73. data/spec/commands/command_spec.rb +18 -0
  74. data/spec/commands/create_command_spec.rb +74 -0
  75. data/spec/commands/freeze_command_spec.rb +59 -0
  76. data/spec/commands/open_command_spec.rb +30 -0
  77. data/spec/commands/pack_command_spec.rb +23 -0
  78. data/spec/dsl/production_builder_spec.rb +46 -0
  79. data/spec/{prop_builder_spec.rb → dsl/prop_builder_spec.rb} +80 -24
  80. data/spec/{stage_builder_spec.rb → dsl/stage_builder_spec.rb} +4 -4
  81. data/spec/{styles_builder_spec.rb → dsl/styles_builder_spec.rb} +6 -6
  82. data/spec/{loaders/file_loader_spec.rb → file_loader_spec.rb} +4 -4
  83. data/spec/gems_spec.rb +83 -0
  84. data/spec/java_util_spec.rb +1 -17
  85. data/spec/main_spec.rb +17 -0
  86. data/spec/producer_spec.rb +89 -79
  87. data/spec/production_spec.rb +28 -3
  88. data/spec/prop_spec.rb +82 -16
  89. data/spec/scene_spec.rb +73 -3
  90. data/spec/spec_helper.rb +37 -1
  91. data/spec/stage_spec.rb +10 -1
  92. data/spec/string_spec.rb +35 -0
  93. data/spec/studio_spec.rb +14 -0
  94. data/spec/styles_spec.rb +14 -0
  95. data/spec/templates/production_templater_spec.rb +44 -0
  96. data/spec/templates/scene_templater_spec.rb +25 -0
  97. data/spec/templates/templater_logger_spec.rb +38 -0
  98. data/spec/templates/templater_spec.rb +104 -0
  99. data/spec/theater_spec.rb +12 -21
  100. metadata +75 -23
  101. data/bin/icons/splash.png +0 -0
  102. data/lib/limelight/build_exception.rb +0 -48
  103. data/lib/limelight/commands.rb +0 -52
  104. data/lib/limelight/loaders/file_scene_loader.rb +0 -49
  105. data/lib/limelight/menu_bar.rb +0 -68
  106. data/lib/limelight/production_builder.rb +0 -66
  107. data/lib/limelight/prop_builder.rb +0 -119
  108. data/lib/limelight/stage_builder.rb +0 -103
  109. data/lib/limelight/styles_builder.rb +0 -131
  110. data/spec/commands_spec.rb +0 -34
  111. data/spec/production_builder_spec.rb +0 -48
@@ -0,0 +1,105 @@
1
+ #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require 'limelight/stage'
5
+ require 'limelight/limelight_exception'
6
+
7
+ module Limelight
8
+
9
+ # A trigger to build/configure Stage objects using the StageBuilder DSL.
10
+ #
11
+ # See Limelight::Stagesbuilder, Limelight::Stagebuilder
12
+ #
13
+ def self.build_stages(theater, &block)
14
+ builder = DSL::StagesBuilder.new(theater)
15
+ builder.instance_eval(&block) if block
16
+ return builder.__stages__
17
+ end
18
+
19
+ module DSL
20
+
21
+ # The basis of the DSL for building Stage objects.
22
+ #
23
+ # stage "inspector" do
24
+ # default_scene "inspector"
25
+ # title "Limelight Composer Inspector"
26
+ # location [0, 0]
27
+ # size [300, 800]
28
+ # end
29
+ #
30
+ # stage "viewer" do
31
+ # title "Limelight Composer Viewer"
32
+ # location [350, 0]
33
+ # size [800, 800]
34
+ # end
35
+ #
36
+ # In this example above, two stages are created for the production. One is named 'inspector' and the other is named
37
+ # 'viewer'. 'inspector' has a default scene that will be loaded on startup. 'viewer' will not contain any scene
38
+ # on startup. Using the DSL, each stage can be configured to set the title, location, size, or any other attribute
39
+ # of a stage.
40
+ #
41
+ # See Limelight::Stage
42
+ #
43
+ class StagesBuilder
44
+
45
+ Limelight::Util.lobotomize(self)
46
+
47
+ attr_reader :__stages__
48
+
49
+ # Constructs a new StagesBuilder. A Theater object is required as a parameter. Each stages created will belong
50
+ # to the Theater passed in.
51
+ #
52
+ def initialize(theater)
53
+ @__theater__ = theater
54
+ @__stages__ = []
55
+ end
56
+
57
+ # Creates a new stage with the provided name. The block will contain StageBuilder DSL to configure the stage.
58
+ #
59
+ def stage(name, &block)
60
+ stage_builder = StageBuilder.new(@__theater__, name)
61
+ stage_builder.instance_eval(&block) if block
62
+ @__stages__ << stage_builder.__stage__
63
+ end
64
+
65
+ end
66
+
67
+ # The basis of the DSL for configuring a Stage object.
68
+ #
69
+ class StageBuilder
70
+
71
+ Limelight::Util.lobotomize(self)
72
+
73
+ attr_reader :__stage__
74
+
75
+ def initialize(theater, name) #:nodoc:
76
+ if theater[name]
77
+ @__stage__ = theater[name]
78
+ else
79
+ @__stage__ = theater.add_stage(name)
80
+ end
81
+ end
82
+
83
+ # Specifies the scene that will be displayed on the stage upon opening of the production.
84
+ #
85
+ def default_scene(scene_name)
86
+ @__stage__.default_scene = scene_name
87
+ end
88
+
89
+ def method_missing(sym, value) #:nodoc:
90
+ setter_sym = "#{sym}=".to_s
91
+ raise StageBuilderException.new(sym) if !@__stage__.respond_to?(setter_sym)
92
+ @__stage__.send(setter_sym, value)
93
+ end
94
+ end
95
+
96
+ # Exception thrown by StageBuilder in the event of an invalid configuration.
97
+ #
98
+ class StageBuilderException < LimelightException
99
+ def initialize(name)
100
+ super("'#{name}' is not a valid stage property")
101
+ end
102
+ end
103
+
104
+ end
105
+ end
@@ -0,0 +1,134 @@
1
+ #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+ require 'limelight/util'
4
+
5
+ module Limelight
6
+
7
+ # A trigger to define Style objects using the StyleBuilder DSL.
8
+ #
9
+ # See Limelight::Stylesbuilder, Limelight::Stylebuilder
10
+ #
11
+ def self.build_styles(style_hash = nil, &block)
12
+ builder = DSL::StylesBuilder.new(style_hash)
13
+ builder.instance_eval(&block) if block
14
+ return builder.__styles__
15
+ end
16
+
17
+ module DSL
18
+
19
+ # The basis of the DSL for building Style objects.
20
+ #
21
+ # Sample StyleBuilder DSL
22
+ #
23
+ # sandbox {
24
+ # width "100%"
25
+ # height "100%"
26
+ # vertical_alignment :top
27
+ # }
28
+ #
29
+ # sample {
30
+ # width 320
31
+ # height 320
32
+ # gradient :on
33
+ # }
34
+ #
35
+ # spinner {
36
+ # extends :sample
37
+ # background_color :green
38
+ # secondary_background_color :blue
39
+ # gradient_angle 0
40
+ # gradient_penetration 100
41
+ # }
42
+ #
43
+ # This exmple builds three styles: sandbox, sample, spinner. Within each style block, the individual attributes of
44
+ # the style may be set.
45
+ #
46
+ # See Limelight::Styles
47
+ #
48
+ class StylesBuilder
49
+
50
+ Limelight::Util.lobotomize(self)
51
+
52
+ attr_reader :__styles__
53
+
54
+ def initialize(style_hash = nil)
55
+ @__styles__ = style_hash || {}
56
+ end
57
+
58
+ def method_missing(sym, &block) #:nodoc:
59
+ __add_style__(sym.to_s, &block)
60
+ end
61
+
62
+ def __add_style__(name, &block) #:nodoc:
63
+ builder = StyleBuilder.new(name, self)
64
+ builder.instance_eval(&block) if block
65
+ @__styles__[name] = builder.__style__
66
+ end
67
+ end
68
+
69
+ # The basis of the DSL for defining a Style object.
70
+ #
71
+ class StyleBuilder
72
+
73
+ Limelight::Util.lobotomize(self)
74
+
75
+ attr_reader :__style__ #:nodoc:
76
+
77
+ def initialize(name, styles_builder, options = {}) #:nodoc:
78
+ @__name = name
79
+ @__styles_builder = styles_builder
80
+ @__style__ = @__styles_builder.__styles__[name] || Styles::RichStyle.new
81
+ end
82
+
83
+ # Used to define a hover style. Hover styles are appiled when the mouse passed over a prop using the specified style.
84
+ #
85
+ # spinner {
86
+ # width 50
87
+ # height 50
88
+ # hover {
89
+ # text_color :white
90
+ # }
91
+ # }
92
+ #
93
+ # The text color of props using the 'spinner' style will become white when the mouse hovers over them.
94
+ #
95
+ def hover(&block)
96
+ @__styles_builder.__add_style__("#{@__name}.hover", &block)
97
+ end
98
+
99
+ # Styles may extend other styles.
100
+ #
101
+ # base {
102
+ # background_color :red
103
+ # }
104
+ #
105
+ # cell {
106
+ # extends :base
107
+ # text_color :black
108
+ # }
109
+ #
110
+ # The 'cell' style now has all attributes defined in 'base'. Therefore any prop using the 'cell' style
111
+ # will have a red background. Styles may override attributes aquired through extension.
112
+ #
113
+ def extends(*style_names)
114
+ style_names.each do |style_name|
115
+ extension = @__styles_builder.__styles__[style_name.to_s]
116
+ raise StyleBuilderException.new("Can't extend missing style: '#{style_name}'") if extension.nil?
117
+ @__style__.add_extension(extension)
118
+ end
119
+ end
120
+
121
+ def method_missing(sym, value) #:nodoc:
122
+ setter_sym = "#{sym}=".to_s
123
+ raise StyleBuilderException.new("'#{sym}' is not a valid style") if !@__style__.respond_to?(setter_sym)
124
+ @__style__.send(setter_sym, value.to_s)
125
+ end
126
+ end
127
+
128
+ # Exception thrown by StyleBuilder when an error is encountered.
129
+ #
130
+ class StyleBuilderException < Exception
131
+ end
132
+
133
+ end
134
+ end
@@ -0,0 +1,46 @@
1
+ #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ module Limelight
5
+
6
+ class FileLoader #:nodoc:
7
+
8
+ include ResourceLoader
9
+
10
+ attr_reader :root
11
+
12
+ def self.for_root(root)
13
+ loader = new
14
+ loader.reset_on_root(root)
15
+ return loader
16
+ end
17
+
18
+ def reset_on_root(root)
19
+ @root = File.expand_path(root)
20
+ end
21
+
22
+ def path_to(path)
23
+ if (path == File.expand_path(path))
24
+ return path
25
+ else
26
+ return File.expand_path(File.join(@root, path))
27
+ end
28
+ end
29
+
30
+ def exists?(path)
31
+ return File.exists?(path_to(path))
32
+ end
33
+
34
+ alias :pathTo :path_to
35
+
36
+ def load(path)
37
+ file_to_load = path_to(path)
38
+ raise LimelightException.new("File not found: #{file_to_load}") if not File.exists?(file_to_load)
39
+ return IO.read(file_to_load)
40
+ end
41
+
42
+ alias :read :load
43
+
44
+ end
45
+
46
+ end
@@ -0,0 +1,45 @@
1
+ module Limelight
2
+ module Gems
3
+
4
+ class << self
5
+
6
+ attr_accessor :current_production
7
+
8
+ def load_path
9
+ @load_path = $: if @load_path.nil?
10
+ return @load_path
11
+ end
12
+
13
+ def install(gem_name, paths)
14
+ stack = paths.dup
15
+ while !stack.empty?
16
+ load_path.unshift File.join(current_production.gems_directory, gem_name, stack.pop)
17
+ end
18
+ end
19
+
20
+ def install_gems_in_production(production)
21
+ self.current_production = production
22
+
23
+ gems_dir = current_production.gems_directory
24
+ if File.exists?(gems_dir) && File.directory?(gems_dir)
25
+ gems = Dir.entries(gems_dir).select { |dir| dir != "." && dir != ".." }
26
+ gems.sort!
27
+ gems.reverse!
28
+ gems.each do |gem_name|
29
+ init_file = File.join(gems_dir, gem_name, 'limelight_init.rb')
30
+ if File.exists?(init_file)
31
+ load init_file
32
+ else
33
+ puts "WARNING: Frozen gem (#{gem_name}) is missing limelight_init.rb file."
34
+ end
35
+ end
36
+ end
37
+
38
+ self.current_production = nil
39
+ end
40
+
41
+ end
42
+
43
+
44
+ end
45
+ end
@@ -4,9 +4,12 @@
4
4
  module Limelight #:nodoc:
5
5
 
6
6
  Main = Java::limelight.Main
7
- SceneLoader = Java::limelight.SceneLoader
7
+ ResourceLoader = Java::limelight.ResourceLoader
8
8
  Context = Java::limelight.Context
9
- AnimationTask = Java::limelight.AnimationTask
9
+
10
+ module Background
11
+ Animation = Java::limelight.background.Animation
12
+ end
10
13
 
11
14
  module Styles #:nodoc:
12
15
  Style = Java::limelight.styles.Style
@@ -26,6 +29,7 @@ module Limelight #:nodoc:
26
29
  module Model #:nodoc:
27
30
  Frame = Java::limelight.ui.model.Frame
28
31
  Panel = Java::limelight.ui.model.PropPanel
32
+ ImagePanel = Java::limelight.ui.model.ImagePanel
29
33
 
30
34
  module Inputs #:nodoc:
31
35
  ButtonPanel = Java::limelight.ui.model.inputs.ButtonPanel
@@ -42,6 +46,7 @@ module Limelight #:nodoc:
42
46
  Prop = Java::limelight.ui.api.Prop
43
47
  Stage = Java::limelight.ui.api.Stage
44
48
  Theater = Java::limelight.ui.api.Theater
49
+ Studio = Java::limelight.ui.api.Studio
45
50
  end
46
51
 
47
52
  module Painting #:nodoc:
@@ -1,6 +1,8 @@
1
1
  #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
+ require 'limelight/string'
5
+
4
6
  class Class
5
7
 
6
8
  # Class level method to creates Java style getters.
@@ -44,19 +46,4 @@ class Class
44
46
  end
45
47
 
46
48
  end
47
-
48
- class String
49
-
50
- # Converts Ruby style names to Java style camal case.
51
- #
52
- # "four_score".camalized # => "FourScore"
53
- # "and_seven_years".camalized(:lower) # => "andSevenYears"
54
- #
55
- def camalized(starting_case = :upper)
56
- value = self.downcase.gsub(/[_| ]([a-z])/) { |match| match[-1..-1].upcase }
57
- value = value[0..0].upcase + value[1..-1] if starting_case == :upper
58
- return value
59
- end
60
-
61
- end
62
49
 
@@ -1,7 +1,7 @@
1
1
  #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
- require 'limelight/commands'
4
+ require 'limelight/commands/command'
5
5
 
6
6
  module Limelight
7
7
 
@@ -81,7 +81,7 @@ module Limelight
81
81
  #
82
82
  def run(args)
83
83
  command_name = args.shift
84
- command = Commands::COMMANDS[command_name]
84
+ command = Commands[command_name]
85
85
  if command
86
86
  command.new.run(args)
87
87
  else
@@ -92,12 +92,14 @@ module Limelight
92
92
  # Prints the usage of the limelight command.
93
93
  #
94
94
  def usage
95
+ puts ""
95
96
  puts "Usage: limelight <command> [options] [params]"
96
- puts "commands:"
97
- Commands::COMMANDS.keys.sort.each do |key|
98
- command = Commands::COMMANDS[key]
97
+ puts " commands:"
98
+ Commands::LISTING.keys.sort.each do |key|
99
+ command = Commands[key]
99
100
  puts "\t#{key}\t\t#{command.description}"
100
101
  end
102
+ exit -1
101
103
  end
102
104
  end
103
105
 
@@ -1,16 +1,17 @@
1
1
  #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
- require 'limelight/loaders/file_scene_loader'
5
- require 'limelight/prop_builder'
6
- require 'limelight/styles_builder'
7
- require 'limelight/stage_builder'
8
- require 'limelight/production_builder'
4
+ require 'limelight/file_loader'
5
+ require 'limelight/dsl/prop_builder'
6
+ require 'limelight/dsl/styles_builder'
7
+ require 'limelight/dsl/stage_builder'
8
+ require 'limelight/dsl/production_builder'
9
9
  require 'limelight/casting_director'
10
10
  require 'limelight/stage'
11
- require 'limelight/build_exception'
11
+ require 'limelight/dsl/build_exception'
12
12
  require 'limelight/theater'
13
13
  require 'limelight/production'
14
+ require 'limelight/gems'
14
15
 
15
16
  module Limelight
16
17
 
@@ -27,7 +28,7 @@ module Limelight
27
28
  producer = new(production_name)
28
29
  producer.open
29
30
  end
30
-
31
+
31
32
  attr_reader :loader, :theater, :production
32
33
  attr_writer :builtin_styles
33
34
 
@@ -35,12 +36,16 @@ module Limelight
35
36
  # You may also provide an existing Production for which this Producer will interact.
36
37
  #
37
38
  def initialize(root_path, theater=nil, production=nil)
38
- if(root_path[-4..-1] == ".llp")
39
+ if (root_path[-4..-1] == ".lll")
40
+ url = IO.read(root_path).strip
41
+ root_path = Limelight::Context.instance.downloader.download(url).absolute_path
42
+ end
43
+ if (root_path[-4..-1] == ".llp")
39
44
  root_path = unpack_production(root_path)
40
45
  end
41
- @loader = Loaders::FileSceneLoader.for_root(root_path)
46
+ @production = production || Production.new(root_path)
47
+ @loader = @production.root
42
48
  @theater = theater.nil? ? Theater.new : theater
43
- @production = production
44
49
  end
45
50
 
46
51
  # Returns the CastingDirector for this Production.
@@ -50,40 +55,52 @@ module Limelight
50
55
  return @casting_director
51
56
  end
52
57
 
53
- # Opens the Production specified during construction. If the file 'init.rb' exists in the root directory of the
54
- # Production, it will be loaded before anything else.
58
+ # Loads the Production without opening it. The Production will be created into memory with all it's stages
55
59
  #
56
- def open()
60
+ def load(options = {})
57
61
  establish_production
58
- Kernel.load(@loader.path_to("init.rb")) if @loader.exists?("init.rb")
59
- if @loader.exists?("stages.rb")
60
- load_stages.each { |stage| open_scene(stage.default_scene, stage) }
62
+ Gems.install_gems_in_production(@production)
63
+ Kernel.load(@production.init_file) if ( !options[:ignore_init] && File.exists?(@production.init_file) )
64
+ load_stages if File.exists?(@production.stages_file)
65
+ end
66
+
67
+ # Opens the Production.
68
+ #
69
+ def open()
70
+ load
71
+ if @theater.has_stages?
72
+ @theater.stages.each { |stage| open_scene(stage.default_scene, stage) if stage.default_scene }
61
73
  else
62
- open_scene('.', @theater.default_stage)
74
+ open_scene(:root, @theater.default_stage)
63
75
  end
64
76
  @casting_director = nil
65
77
  end
66
78
 
67
79
  # Opens the specified Scene onto the Spcified Stage.
68
80
  #
69
- def open_scene(path, stage)
70
- styles = load_styles(path)
71
- merge_with_root_styles(styles)
81
+ def open_scene(name, stage)
82
+ path = @production.scene_directory(name)
83
+ scene_name = File.basename(path)
84
+ scene = load_props(:production => @production, :casting_director => casting_director, :path => path, :name => scene_name)
72
85
 
73
- scene = load_props(path, :styles => styles, :production => @production, :casting_director => casting_director, :loader => @loader, :path => path)
86
+ styles = load_styles(scene)
87
+ merge_with_root_styles(styles)
88
+ scene.styles = styles
74
89
 
75
90
  stage.open(scene)
91
+ return scene
76
92
  end
77
93
 
78
94
  # Loads the 'stages.rb' file and configures all the Stages in the Production.
79
95
  #
80
96
  def load_stages
81
- content = @loader.load("stages.rb")
97
+ stages_file = @production.stages_file
98
+ content = IO.read(stages_file)
82
99
  stages = Limelight.build_stages(@theater) do
83
100
  begin
84
101
  eval content
85
102
  rescue Exception => e
86
- raise BuildException.new("stages.rb", content, e)
103
+ raise DSL::BuildException.new(stages_file, content, e)
87
104
  end
88
105
  end
89
106
  return stages
@@ -91,33 +108,34 @@ module Limelight
91
108
 
92
109
  # Loads of the 'props.rb' file for a particular Scene and creates all the Prop objects and Scene.
93
110
  #
94
- def load_props(path, options = {})
95
- return Scene.new(options) if path.nil?
96
- filename = File.join(path, "props.rb")
97
- content = @loader.exists?(filename) ? @loader.load(filename) : ""
98
- options[:build_loader] = @loader
99
- return Limelight.build_scene(options) do
100
- begin
101
- eval content
102
- rescue Exception => e
103
- raise BuildException.new(filename, content, e)
111
+ def load_props(options = {})
112
+ scene = Scene.new(options)
113
+ if File.exists?(scene.props_file)
114
+ content = IO.read(scene.props_file)
115
+ options[:build_loader] = @production.root
116
+ return Limelight.build_scene(scene, options) do
117
+ begin
118
+ eval content
119
+ rescue Exception => e
120
+ raise DSL::BuildException.new(scene.props_file, content, e)
121
+ end
104
122
  end
123
+ else
124
+ return scene
105
125
  end
106
126
  end
107
127
 
108
128
  # Loads the specified 'styles.rb' file and created a Hash of Styles.
109
129
  #
110
- def load_styles(path)
130
+ def load_styles(context)
111
131
  styles = builtin_styles
112
- return styles if path.nil?
113
- filename = File.join(path, "styles.rb")
114
- return styles if not @loader.exists?(filename)
115
- content = @loader.load(filename)
132
+ return styles if not File.exists?(context.styles_file)
133
+ content = IO.read(context.styles_file)
116
134
  return Limelight.build_styles(styles) do
117
135
  begin
118
136
  eval content
119
137
  rescue Exception => e
120
- raise BuildException.new(filename, content, e)
138
+ raise DSL::BuildException.new(context.styles_file, content, e)
121
139
  end
122
140
  end
123
141
  end
@@ -125,49 +143,39 @@ module Limelight
125
143
  # Loads the 'production.rb' file if it exists and configures the Production.
126
144
  #
127
145
  def establish_production
128
- return if @production
129
- if @loader.exists?("production.rb")
130
- content = @loader.load("production.rb")
131
- @production = Limelight.build_production(self, @theater) do
146
+ @production.producer = self
147
+ @production.theater = @theater
148
+
149
+ if @production.root.exists?("production.rb")
150
+ content = @production.root.load("production.rb")
151
+ @production = Limelight.build_production(@production) do
132
152
  begin
133
153
  eval content
134
154
  rescue Exception => e
135
- raise BuildException.new("production.rb", content, e)
155
+ raise DSL::BuildException.new("production.rb", content, e)
136
156
  end
137
157
  end
138
- else
139
- @production = Production.new(self, @theater)
140
- end
158
+ end
159
+
141
160
  end
142
161
 
143
162
  # A production with multiple Scenes may have a 'styles.rb' file in the root directory. This is called the
144
163
  # root_style. This method loads the root_styles, if they haven't already been loaded, and returns them.
145
164
  #
146
165
  def root_styles
147
- return @root_syles if @root_syles
148
- if @loader.exists?('styles.rb')
149
- @root_styles = load_styles('.')
166
+ return @root_syles if @root_syles
167
+ if File.exists?(@production.styles_file)
168
+ @root_styles = load_styles(@production)
150
169
  else
151
170
  @root_styles = {}
152
171
  end
153
172
  return @root_styles
154
173
  end
155
-
156
- private ###############################################
157
-
158
- def merge_with_root_styles(styles)
159
- root_styles.each_pair do |key, value|
160
- styles[key] = value if !styles.has_key?(key)
161
- end
162
- end
163
-
164
- def unpack_production(production_name)
165
- packer = Limelight::Util::Packer.new()
166
- return packer.unpack(production_name)
167
- end
168
174
 
175
+ # Returns a hash of all the built-in Limglight Styles
176
+ #
169
177
  def builtin_styles
170
- return @builtin_styles if @builtin_styles
178
+ return @builtin_styles.dup if @builtin_styles
171
179
  builtin_styles_file = File.join($LIMELIGHT_LIB, "limelight", "builtin", "styles.rb")
172
180
  content = IO.read(builtin_styles_file)
173
181
  @builtin_styles = Limelight.build_styles do
@@ -177,9 +185,22 @@ module Limelight
177
185
  raise BuildException.new(filename, content, e)
178
186
  end
179
187
  end
180
- return @builtin_styles
188
+ return @builtin_styles.dup
189
+ end
190
+
191
+ private ###############################################
192
+
193
+ def merge_with_root_styles(styles)
194
+ root_styles.each_pair do |key, value|
195
+ styles[key] = value if !styles.has_key?(key)
196
+ end
197
+ end
198
+
199
+ def unpack_production(production_name)
200
+ packer = Limelight::Util::Packer.new()
201
+ return packer.unpack(production_name)
181
202
  end
182
203
 
183
204
  end
184
-
205
+
185
206
  end