40 lines
1.5 KiB
GDScript
40 lines
1.5 KiB
GDScript
extends LineEdit
|
|
|
|
static var styles = [[null, null], [null, null]]
|
|
static var init_done: = false
|
|
|
|
|
|
func _init() -> void:
|
|
if not init_done:
|
|
init_done = true
|
|
var style_0_light = get_theme_stylebox('normal')
|
|
var style_1_light = get_theme_stylebox('read_only')
|
|
|
|
style_0_light.bg_color = Color(0.12, 0.12, 0.12)
|
|
style_1_light.bg_color = Color(0.12, 0.12, 0.12)
|
|
styles[1][0] = style_0_light
|
|
styles[1][1] = style_1_light
|
|
|
|
var style_0_dark = style_0_light.duplicate(true)
|
|
var style_1_dark = style_1_light.duplicate(true)
|
|
|
|
style_0_light.bg_color = Color.GRAY
|
|
style_1_light.bg_color = Color.GRAY
|
|
styles[0][0] = style_0_dark
|
|
styles[0][1] = style_1_dark
|
|
ProjectSettings.connect('settings_changed', apply_colors)
|
|
apply_colors()
|
|
|
|
|
|
func apply_colors():
|
|
if ProjectSettings.get_setting('application/config/%s' % 'Цвет темы программы', false):
|
|
add_theme_color_override('font_color', Color.BLACK)
|
|
add_theme_color_override('font_uneditable_color', Color.BLACK)
|
|
add_theme_stylebox_override('normal', styles[1][0])
|
|
add_theme_stylebox_override('read_only', styles[1][1])
|
|
else:
|
|
add_theme_color_override('font_color', Color(1.0, 0.596, 0.4))
|
|
add_theme_color_override('font_uneditable_color', Color(1.0, 0.596, 0.4))
|
|
add_theme_stylebox_override('normal', styles[0][0])
|
|
add_theme_stylebox_override('read_only', styles[0][1])
|