Skip to content

Commit

Permalink
temp: fix: utils
Browse files Browse the repository at this point in the history
  • Loading branch information
akorzunin committed Aug 21, 2024
1 parent bd87595 commit bbe007d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 21 deletions.
12 changes: 10 additions & 2 deletions src/components/Utils.gd
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
extends RefCounted
class_name Utils

static var main_scene_name: String = ProjectSettings.get_setting("application/run/main_scene")

## Only works in scene level script
static func is_main_scene(_self) -> bool:
if _self.get_parent() == _self.get_tree().root \
and ProjectSettings.get_setting("application/run/main_scene") == _self.scene_file_path:
and main_scene_name == _self.scene_file_path:
return true
return false

static func get_main_scene(_self: Node) -> Node:
for i in _self.get_tree().root.get_children():
if i.name == main_scene_name:
return i
return

## Returns current main scene name
static func main_scene(_self) -> String:
# Globals always loads first so index of main scene is 1
var node = _self.get_tree().root.get_child(1)
var node = get_main_scene(_self)
if not node:
return ''
return node.name
Expand Down
3 changes: 3 additions & 0 deletions src/components/colors/TwColors.gd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
extends RefCounted
class_name TwColors

# scraped from https://tailwindcss.com/docs/customizing-colors

const tw = {
Expand Down
3 changes: 2 additions & 1 deletion src/globals.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends Node
class_name Globals

const theme = preload("res://src/themes/BaseTheme.gd").T
const theme = preload("res://src/themes/TwTheme.gd").T
const tw = preload('res://src/components/colors/TwColors.gd').tw
# Default values for whole project
var D = {
Expand All @@ -12,4 +12,5 @@ var settings := {}

# global signals
enum FontType {HEX, EMOJI}
@warning_ignore("unused_signal")
signal font_changed(new_font: FontType)
18 changes: 0 additions & 18 deletions src/themes/BaseTheme.gd

This file was deleted.

19 changes: 19 additions & 0 deletions src/themes/TwTheme.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
extends RefCounted
class_name TwTheme

const T = {
base_color = TwColors.tw.blue._800,
bg_color_menu = TwColors.tw.sky._200,
bg_color_loop = TwColors.tw.sky._400,
figure_variants = {
top_left = TwColors.tw.blue._700,
top_right = TwColors.tw.green._700,
bot_left = TwColors.tw.sky._700,
bot_right = TwColors.tw.orange._700,
bot_mid = TwColors.tw.violet._700,
mid_mid = TwColors.tw.cyan._700,
mid_left = TwColors.tw.amber._700,
mid_right = TwColors.tw.teal._700,
default = TwColors.tw.sky._500,
},
}

0 comments on commit bbe007d

Please sign in to comment.