Skip to content

Commit

Permalink
notices
Browse files Browse the repository at this point in the history
  • Loading branch information
face-hh committed Mar 20, 2024
1 parent 3b43301 commit 564535a
Show file tree
Hide file tree
Showing 13 changed files with 370 additions and 25 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,19 @@ GriddyCode allows you to extend its functionality via **Lua**.

## Where?
To open the folder with Lua scripts, go to:
<<<<<<< Updated upstream
- Windows: `%APPDATA%\Godot\app_userdata\Bussin GriddyCode`
- macOS: `~/Library/Application Support/Bussin GriddyCode`
- Linux: `~/.local/share/godot/app_userdata/Bussin GriddyCode`

*Note: the paths are not accurate, we recommend you manually search for GriddyCode in the AppData of your OS.*
=======
- Windows: `%APPDATA%\Bussin GriddyCode`
- macOS: `~/Library/Application Support/Bussin GriddyCode`
- Linux: `~/.local/share/Bussin GriddyCode`

*Note: since the paths might change, we recommend you manually search for GriddyCode in the AppData of your OS.*
>>>>>>> Stashed changes
## How?
You may see the folders **"langs"** and **"themes"**.
Expand All @@ -64,7 +72,11 @@ To extend the functionality of GriddyCode for a specific **file extension**, cre
| `detect_functions(content: String) -> Array[String]` | `detect_functions("const test = 3; function main() {}; async init() => { main() }")` | Called by GriddyCode upon input. Results are showed in the autocomplete feature. | This must be provided by the Lua script. It must return an array of strings (i.e. ["main", "init"]). |
| `detect_variables(content: String) -> Array[String]` | `detect_variables("const test = 3;")` | Called by GriddyCode upon input. Results are showed in the autocomplete feature. | This must be provided by the Lua script. It must return an array of strings (i.e. ["test"]). |

<<<<<<< Updated upstream
*Note: to provide reserved variables/functions (i.e. `Math`/`parseInt()` in JS) you can have them already set up in the array you return. GriddyCode will handle the rest!*
=======
*Note: to provide reserved variables/functions (i.e. `Math`/`parseInt()` in JS) you can have them as preset values in the array you return. GriddyCode will handle the rest!*
>>>>>>> Stashed changes
### Themes
#### Introduction
To add a theme, create a file in the **"themes"** folder with any name. (i.e. "dracula.lua"). You will be able to choose it within GriddyCode.
Expand All @@ -76,14 +88,22 @@ To add a theme, create a file in the **"themes"** folder with any name. (i.e. "d
| `set_gui(property: String, new_color: String)` | `set_gui("background_color", "#ff00ff")` | This method is dedicated to the overall GUI aspect of GriddyCode. | Available properties: `background_color`, `current_line_color`, `selection_color`, `font_color`, `word_highlighted_color`, `selection_background_color`. Properties except `background_color`, if not provided, will be set to a slightly modified version of `background_color`. Although possible, we don't recommend you rely on those & instead set all the values. |

*Note: if the HEX you input is invalid, it will default to #ff0000 (red)*
<<<<<<< Updated upstream
## Publishing
If you want to use a theme/plugin for **yourself**, you can put it into your [AppData](#where).

If you want to **submit** a theme/plugin, open a pull request adding it to `Lua/Plugins` or `Lua/Themes` respectively. If merged, it will be included in the next build.
=======

# Known issues
## Visual bugs
- The `CheckButton` node for each `setting` scene doesn't change with the theme. This affects light themes specifically.
>>>>>>> Stashed changes
# Contributions
Contributions are heavily appreciated, whether it's for adding Lua plugins, themes, safely exposing more features to Lua, or adding features directly to GriddyCode!

<<<<<<< Updated upstream
## Notice
- You will need to install the [Godot Engine](https://godotengine.org/) to run your proposed change & make sure it runs flawlessly.
- You don't have to submit executables.
Expand All @@ -103,3 +123,13 @@ Contributions are heavily appreciated, whether it's for adding Lua plugins, them
- `CTRL` + `P` to open a **quick file picker**, similar to [VSCode](https://code.visualstudio.com/docs/editor/editingevolved#:~:text=Quick%20file%20navigation,-Tip%3A%20You%20can&text=VS%20Code%20provides%20two%20powerful,release%20Ctrl%20to%20open%20it.).
- Selecting a setting with the property "shader" *should* disable previously-enabled settings with "shader".
- The `CheckButton` node for each `setting` scene doesn't change with the theme. This affects light themes specifically.
=======
Stuff we are currently looking for: (this doesn't mean you can't contribute with other stuff!)
- `CTRL` + `P` to open a **quick file picker**, similar to [VSCode](https://code.visualstudio.com/docs/editor/editingevolved#:~:text=Quick%20file%20navigation,-Tip%3A%20You%20can&text=VS%20Code%20provides%20two%20powerful,release%20Ctrl%20to%20open%20it.)
- An option in the settings menu (`CTRL` + `,`) to change the font!
- Making the cat jumping video in the settings menu fade in/out along the actual menu. Currently it ignores the transition
- Heavy cleanup of `settings.gd`!
- The file picker (`CTRL` + `O`) stores the position of the selected item even after entering/exiting a directory. However, if the directory's file size is lower than it, it will disappear until you move it up. This can be fixed by setting its selected item to the last item if it exceeds dirs.size()

Please note that creating a Pull Request to fix these features does *not* guarantee its merge. Please don't open a Pull Request unless you are confident you've done a good job.
>>>>>>> Stashed changes
7 changes: 2 additions & 5 deletions Scenes/comment.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[gd_scene load_steps=6 format=3 uid="uid://bp8qdakc47pva"]
[gd_scene load_steps=5 format=3 uid="uid://bp8qdakc47pva"]

[ext_resource type="Shader" path="res://Shaders/circle_mask.gdshader" id="1_1jr08"]
[ext_resource type="Script" path="res://Scripts/comment.gd" id="1_b8ga8"]
[ext_resource type="Texture2D" uid="uid://dqsmye2lux7vl" path="res://Icons/Comments/quincetart10.png" id="3_gt38f"]
[ext_resource type="FontFile" uid="uid://d1v66naqhhggj" path="res://Fonts/FiraCode-Regular.ttf" id="3_r26eh"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_gok1n"]
shader = ExtResource("1_1jr08")
Expand Down Expand Up @@ -31,7 +30,6 @@ offset_left = 212.245
offset_top = 18.295
offset_right = 1112.24
offset_bottom = 918.295
theme_override_fonts/normal_font = ExtResource("3_r26eh")
theme_override_font_sizes/normal_font_size = 41
bbcode_enabled = true
text = "kgpoakgp3 3d"
Expand All @@ -43,9 +41,8 @@ offset_top = 85.0
offset_right = 5682.0
offset_bottom = 7405.0
scale = Vector2(0.075, 0.075)
theme_override_fonts/normal_font = ExtResource("3_r26eh")
theme_override_font_sizes/normal_font_size = 300
bbcode_enabled = true
text = "This is a placeholder. If you are seeing this:
1. Your extension does not provide comments.
2. GriddyCode failed to properly load."
2. GriddyCode failed to properly load. 🔥"
19 changes: 8 additions & 11 deletions Scenes/editor.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[gd_scene load_steps=21 format=3 uid="uid://bj6s526sep4xw"]
[gd_scene load_steps=20 format=3 uid="uid://bj6s526sep4xw"]

[ext_resource type="FontFile" uid="uid://drrhlpxmc4pq4" path="res://Fonts/FiraCode-VariableFont_wght.ttf" id="1_cd7xi"]
[ext_resource type="Script" path="res://Scripts/file_manager.gd" id="1_x00ag"]
[ext_resource type="Script" path="res://Scripts/settings.gd" id="2_7x3ll"]
[ext_resource type="FontFile" uid="uid://d1v66naqhhggj" path="res://Fonts/FiraCode-Regular.ttf" id="2_wpuu1"]
[ext_resource type="Theme" uid="uid://daiset8sjhqyc" path="res://theme.tres" id="2_bh428"]
[ext_resource type="PackedScene" uid="uid://dk43uvvc3j228" path="res://Scenes/settings_list.tscn" id="5_6usn0"]
[ext_resource type="Script" path="res://Scripts/file_dialog.gd" id="5_bhd70"]
[ext_resource type="PackedScene" uid="uid://c2gyvklbna1ss" path="res://Scenes/theme_chooser.tscn" id="6_10xx2"]
Expand Down Expand Up @@ -54,10 +53,10 @@ color = Color(0, 0, 0, 1)
unique_name_in_owner = true
offset_right = 2044.0
offset_bottom = 44630.0
theme = ExtResource("2_bh428")
theme_override_colors/background_color = Color(0, 0, 0, 1)
theme_override_colors/current_line_color = Color(0.168627, 0.168627, 0.168627, 1)
theme_override_colors/caret_color = Color(0.321569, 0.545098, 1, 1)
theme_override_fonts/font = ExtResource("2_wpuu1")
theme_override_font_sizes/font_size = 0
text = "function getRandomColor() {
const letters = '0123456789ABCDEF';
Expand Down Expand Up @@ -118,10 +117,9 @@ anchor_bottom = 1.0
offset_left = -492.0
offset_top = 119.0
offset_right = -30.0
offset_bottom = 749.0
offset_bottom = 8889.0
grow_horizontal = 2
grow_vertical = 0
theme_override_fonts/normal_font = ExtResource("2_wpuu1")
text = "gpake
gka
ekga
Expand All @@ -148,7 +146,6 @@ offset_top = 112.0
offset_right = 3336.0
offset_bottom = 2112.0
scale = Vector2(0.235, 0.235)
theme_override_fonts/normal_font = ExtResource("1_cd7xi")
theme_override_font_sizes/normal_font_size = 376
bbcode_enabled = true
text = "Greetings!"
Expand All @@ -159,7 +156,6 @@ offset_top = 244.0
offset_right = 3341.0
offset_bottom = 2244.0
scale = Vector2(0.235, 0.235)
theme_override_fonts/normal_font = ExtResource("1_cd7xi")
theme_override_font_sizes/normal_font_size = 146
bbcode_enabled = true
text = "You're currently using [color=#c9daf8]Bussin[/color] [color=#85c6ff]GriddyCode[/color]"
Expand All @@ -170,7 +166,6 @@ offset_top = 380.0
offset_right = 3341.0
offset_bottom = 2380.0
scale = Vector2(0.235, 0.235)
theme_override_fonts/normal_font = ExtResource("1_cd7xi")
theme_override_font_sizes/normal_font_size = 106
bbcode_enabled = true
text = "To get started, please choose a file."
Expand Down Expand Up @@ -220,7 +215,6 @@ offset_top = 28.0
offset_right = 4821.0
offset_bottom = 1219.0
scale = Vector2(0.235, 0.235)
theme_override_fonts/normal_font = ExtResource("1_cd7xi")
theme_override_font_sizes/normal_font_size = 376
bbcode_enabled = true
text = "[color=#c9daf8]Bussin[/color] [color=#85c6ff]GriddyCode[/color]"
Expand All @@ -231,7 +225,6 @@ offset_top = 165.0
offset_right = 6395.0
offset_bottom = 4616.0
scale = Vector2(0.235, 0.235)
theme_override_fonts/normal_font = ExtResource("1_cd7xi")
theme_override_font_sizes/normal_font_size = 121
bbcode_enabled = true
text = "Created by [url=https://youtube.com/facedevstuff][color=#b4a7d6]Face[/color][/url] & the contributors at [url=https://github.com/face-hh/griddycode][color=#b4a7d6]GitHub[/color][/url]
Expand Down Expand Up @@ -304,6 +297,10 @@ offset_top = 2.0
offset_right = 772.0
offset_bottom = 2.0

[node name="CanvasLayer" type="CanvasLayer" parent="."]
offset = Vector2(100, 129.5)
transform = Transform2D(1, 0, 0, 1, 100, 129.5)

[connection signal="caret_changed" from="Code" to="Code" method="_on_caret_changed"]
[connection signal="code_completion_requested" from="Code" to="Code" method="_on_code_completion_requested"]
[connection signal="gui_input" from="Code" to="Code" method="_on_gui_input"]
Expand Down
35 changes: 35 additions & 0 deletions Scenes/notice.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[gd_scene load_steps=4 format=3 uid="uid://c8njeludg1ajk"]

[ext_resource type="Script" path="res://Scripts/notice.gd" id="1_dlyuf"]
[ext_resource type="Shader" path="res://Shaders/border_radius.gdshader" id="1_m2ntv"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_in2wo"]
shader = ExtResource("1_m2ntv")
shader_parameter/radius = 1.0
shader_parameter/animate = false
shader_parameter/square_scale = 0.07

[node name="Notice" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_dlyuf")

[node name="ColorRect" type="ColorRect" parent="."]
material = SubResource("ShaderMaterial_in2wo")
layout_mode = 0
offset_right = 487.0
offset_bottom = 88.0
color = Color(0.101961, 0.101961, 0.101961, 1)

[node name="RichTextLabel" type="RichTextLabel" parent="."]
layout_mode = 0
offset_left = 9.0
offset_top = 10.0
offset_right = 491.0
offset_bottom = 124.0
bbcode_enabled = true
text = "[color=yellow]WARNING[/color]: This file isn’t supported. Highlighting, autocomplete and comments won’t work properly."
5 changes: 1 addition & 4 deletions Scenes/setting.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[gd_scene load_steps=4 format=3 uid="uid://cshkyynl6dffr"]

[ext_resource type="FontFile" uid="uid://d1v66naqhhggj" path="res://Fonts/FiraCode-Regular.ttf" id="1_t6bjo"]
[gd_scene load_steps=3 format=3 uid="uid://cshkyynl6dffr"]

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_wffyp"]

Expand All @@ -19,7 +17,6 @@ offset_top = 3.0
offset_right = 1315.0
offset_bottom = 131.0
scale = Vector2(0.235, 0.235)
theme_override_fonts/normal_font = ExtResource("1_t6bjo")
theme_override_font_sizes/normal_font_size = 66
bbcode_enabled = true
text = "Scroll Speed"
Expand Down
3 changes: 1 addition & 2 deletions Scripts/file_dialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ var files: Array[String]
var zoom: Vector2;

var active: bool = false;

signal ui_close

func change_dir(path) -> void:
Expand All @@ -31,7 +30,7 @@ func change_dir(path) -> void:
%Cam.focus_on(gp(), zoom)

func setup() -> void:
active = false
active = true
change_dir(editor.current_dir)

update_ui()
Expand Down
18 changes: 17 additions & 1 deletion Scripts/file_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ extends Node2D

@onready var Code: CodeEdit = %Code;
@onready var file_dialog = %FileDialog
@onready var canvas_layer: CanvasLayer = $CanvasLayer
const NOTICE = preload("res://Scenes/notice.tscn")

var current_file: String;
var current_dir: String = "/";

func _ready():
if (OS.get_name() == "Windows"):
current_dir = "C:/"
print(current_dir)

inject_lua()
check_for_reserved()

Expand All @@ -27,6 +29,7 @@ func _ready():
if !current_file:
Code.toggle(%FileDialog)
%Intro.show()
warn("Welcome to [color=#c9daf8]Bussin[/color] [color=#85c6ff]GriddyCode[/color]! Please select a file, then press CTRL + I to get started! :D")

func check_for_reserved() -> void:
var folders = ["langs", "themes"]
Expand Down Expand Up @@ -61,6 +64,17 @@ func copy_if_not_exist(user_path: String, res_path: String, file: String) -> voi
if !exists:
DirAccess.copy_absolute(current_path, path)

func warn(notice: String) -> void:
var node = NOTICE.instantiate()

canvas_layer.add_child(node)

node.set_notice(notice)

get_tree().create_timer(3).timeout.connect(func():
node.queue_free()
)

func open_file(path: String) -> void:
var src = Fs._load(path)

Expand Down Expand Up @@ -136,6 +150,8 @@ func load_game():
LuaSingleton.settings.remove_at(index)
LuaSingleton.settings.append(dic);

LuaSingleton.settings = node_data["settings"]

LuaSingleton.on_settings_change.emit()

func _on_auto_save_timer_timeout():
Expand Down
4 changes: 4 additions & 0 deletions Scripts/lua_singleton.gd
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ var comments: Array = []
const SUNLIGHT = preload("res://Shaders/sunlight.gdshader")
const VHS_AND_CRT = preload("res://Shaders/vhs_and_crt.gdshader")

@onready var editor: FileManager = $/root/Editor;
@onready var code: CodeEdit = $/root/Editor/Code;
@onready var world_environment: WorldEnvironment = $/root/Editor/WorldEnvironment
@onready var shader_layer: ColorRect = $/root/Editor/ShaderLayer
Expand Down Expand Up @@ -339,6 +340,7 @@ func setup_extension(extension):

var err: LuaError = lua.do_file("user://langs/" + extension + ".lua")
if err is LuaError:
editor.warn("[color=yellow]WARNING[/color]: This file isn’t supported. Highlighting, autocomplete, comments and other features won’t work properly.")
print("ERROR %d: %s" % [err.type, err.message])
return

Expand All @@ -352,6 +354,8 @@ func setup_theme(given_theme: String) -> void:

var theme_err: LuaError = theme_lua.do_file("user://themes/" + given_theme + ".lua")
if theme_err is LuaError:
editor.warn("[color=yellow]WARNING[/color]: Failed to load theme: " + theme_err.message)

print("ERROR %d: %s" % [theme_err.type, theme_err.message])
return

Expand Down
5 changes: 5 additions & 0 deletions Scripts/notice.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends Control
@onready var rich_text_label: RichTextLabel = $RichTextLabel

func set_notice(notice: String) -> void:
rich_text_label.text = notice
Loading

0 comments on commit 564535a

Please sign in to comment.