Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
myin142 committed Oct 20, 2023
1 parent 7a49219 commit d35f533
Show file tree
Hide file tree
Showing 14 changed files with 382 additions and 237 deletions.
14 changes: 11 additions & 3 deletions godot/addons/debug/Env.gd
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
extends Node

var log_level = Logger.Level.DEBUG
var version = "dev" : set = _set_version
var _logger = Logger.new("Env")
var log_level := Logger.Level.DEBUG
var version := "dev" : set = _set_version
var _logger := Logger.new("Env")
var _demo := false

func _ready():
if is_prod():
log_level = Logger.Level.INFO

_logger.info("Running version %s on %s" % [version, OS.get_name()])

func _set_version(v: String) -> void:
if v == "": return
version = v

if is_prod():
_demo = true # TODO: steam

func is_prod() -> bool:
return version != "dev"

func is_web() -> bool:
return OS.has_feature("web")

func is_demo() -> bool:
return _demo
216 changes: 0 additions & 216 deletions godot/addons/godot-css-theme/ArgumentParser.gd

This file was deleted.

10 changes: 10 additions & 0 deletions godot/addons/godot-css-theme/CSSParser.gd
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,19 @@ func parse_text(content: String, path: String):
result[class_group][actual_tag] = value
else:
result[""][tag] = value

_copy_global_node_to_all_tags(result)

return Stylesheet.new(result, path)

func _copy_global_node_to_all_tags(result):
if ThemeApplier.GLOBAL_NODE in result[""]:
var global = result[""][ThemeApplier.GLOBAL_NODE]
for tag in result:
if tag == "": continue

result[tag][ThemeApplier.GLOBAL_NODE] = global

func _find_index_for_class_in_array(arr):
for i in range(0, arr.size()):
if "." in arr[i]:
Expand Down
4 changes: 2 additions & 2 deletions godot/addons/godot-css-theme/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2022 myin142
Copyright (c) 2021-2023 myin142

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
12 changes: 10 additions & 2 deletions godot/addons/godot-css-theme/ThemeApplier.gd
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,21 @@ func _apply_to_theme(theme: Theme, stylesheet: Stylesheet, class_group: String)
print("Set const for %s: %s" % [type, _value])
elif property == FONT_SIZE_PROPERTY:
var _value = _create_value(stylesheet, value)
theme.default_font_size = _value
if node_type == GLOBAL_NODE:
theme.default_font_size = _value
else:
var type := _parse_type("--fonts-", property)
theme.set_font_size(type, node_type, _value)
if _debug:
print("Set font size: %s" % _value)
elif property == FONT_PROPERTY:
var url := stylesheet.resolve_url(value)
if url:
theme.default_font = load(url)
if node_type == GLOBAL_NODE:
theme.default_font = load(url)
else:
var type := _parse_type("--fonts-", property)
theme.set_font(type, node_type, load(url))
else:
print("Invalid url %s for class %s" % [value, node_type])
elif property.begins_with("--icons-"):
Expand Down
16 changes: 11 additions & 5 deletions godot/addons/godot-css-theme/convert.gd
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
class_name CSSConvert
extends SceneTree


Expand All @@ -9,15 +10,22 @@ func _init():
var debug = options.exists("debug")
print("Debug: ", debug)

var parser = CSSParser.new()

var css_file = options.get_value("input")
var output = options.get_value("output")

convert_css(css_file, output, debug)

quit()

static func convert_css(css_file, output, debug = false):
var parser = CSSParser.new()

if debug:
print("Parsing Stylesheet")

var stylesheet = parser.parse(css_file)
if not stylesheet:
quit(1)
return

if debug:
Expand All @@ -33,7 +41,7 @@ func _init():

if debug:
print("Creating theme")
var output = options.get_value("output")

if not output:
var last_slash = Options.find_last(css_file, "/")
var file_name = css_file.substr(last_slash + 1)
Expand All @@ -56,5 +64,3 @@ func _init():
print("Failed to save theme %s" % err)
else:
print("Saved theme %s to %s" % [theme_name, theme_output])

quit()
9 changes: 9 additions & 0 deletions godot/addons/godot-css-theme/editor/EditorButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@tool
extends BaseButton

var unfocus_color = Color("999999")

func _ready():
modulate = unfocus_color
mouse_entered.connect(func(): modulate = Color.WHITE)
mouse_exited.connect(func(): modulate = unfocus_color)
Loading

0 comments on commit d35f533

Please sign in to comment.