]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Editor/Common/DCSS.gd
Updated export config options
[wolf-seeking-sheep.git] / addons / dialogic / Editor / Common / DCSS.gd
1 @tool
2 class_name DCSS
3
4 static func inline(style: Dictionary) -> StyleBoxFlat:
5         var scale: float = DialogicUtil.get_editor_scale()
6         var s := StyleBoxFlat.new()
7         for property in style.keys():
8                 match property:
9                         'border-left':
10                                 s.set('border_width_left', style[property] * scale)
11                         'border-radius':
12                                 var radius: float = style[property] * scale
13                                 s.set('corner_radius_top_left', radius)
14                                 s.set('corner_radius_top_right', radius)
15                                 s.set('corner_radius_bottom_left', radius)
16                                 s.set('corner_radius_bottom_right', radius)
17                         'background':
18                                 if typeof(style[property]) == TYPE_STRING and style[property] == "none":
19                                         s.set('draw_center', false)
20                                 else:
21                                         s.set('bg_color', style[property])
22                         'border':
23                                 var width: float = style[property] * scale
24                                 s.set('border_width_left', width)
25                                 s.set('border_width_right', width)
26                                 s.set('border_width_top', width)
27                                 s.set('border_width_bottom', width)
28                         'border-color':
29                                 s.set('border_color', style[property])
30                         'padding':
31                                 var value_v: float = 0.0
32                                 var value_h: float = 0.0
33                                 if style[property] is int:
34                                         value_v = style[property] * scale
35                                         value_h = value_v
36                                 else:
37                                         value_v = style[property][0] * scale
38                                         value_h = style[property][1] * scale
39                                 s.set('content_margin_top', value_v)
40                                 s.set('content_margin_bottom', value_v)
41                                 s.set('content_margin_left', value_h)
42                                 s.set('content_margin_right', value_h)
43                         'padding-right':
44                                 s.set('content_margin_right', style[property] * scale)
45                         'padding-left':
46                                 s.set('content_margin_left', style[property] * scale)
47         return s