lib/cyberarm_engine/ui/theme.rb in cyberarm_engine-0.8.1 vs lib/cyberarm_engine/ui/theme.rb in cyberarm_engine-0.9.0
- old
+ new
@@ -24,13 +24,29 @@
data.each do |key, value|
hash.merge!(data)
end
end
- hash.merge(options)
+ deep_merge(hash, options)
end
+ # Derived from Rails Hash#deep_merge!
+ # Enables passing partial themes through Element options without issue
+ def deep_merge(original, intergrate, &block)
+ hash = original.merge(intergrate) do |key, this_val, other_val|
+ if this_val.is_a?(Hash) && other_val.is_a?(Hash)
+ deep_merge(this_val, other_val, &block)
+ elsif block_given?
+ block.call(key, this_val, other_val)
+ else
+ other_val
+ end
+ end
+
+ return hash
+ end
+
THEME = {
Element: {
x: 0,
y: 0,
z: 30,
@@ -72,11 +88,11 @@
caret_width: 2,
caret_color: Gosu::Color::WHITE,
caret_interval: 500,
},
- Image: {
+ Image: { # < Element
retro: false
},
Label: { # < Element
text_size: 28,
@@ -86,9 +102,18 @@
padding: 2
},
ToggleButton: { # < Button
checkmark: "√"
+ },
+
+ Progress: { # < Element
+ width: 250,
+ height: 36,
+ background: 0xff111111,
+ fraction_background: [0xffc75e61, 0xffe26623],
+ border_thickness: 4,
+ border_color: [0xffd59674, 0xffff8746]
}
}.freeze
end
-end
\ No newline at end of file
+end