Skip to content

Commit

Permalink
Initial working game
Browse files Browse the repository at this point in the history
  • Loading branch information
d10sfan committed Jan 5, 2024
0 parents commit 9ddfbce
Show file tree
Hide file tree
Showing 79 changed files with 10,073 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Godot 4+ specific ignores
.godot/
16 changes: 16 additions & 0 deletions addons/material-design-icons/examples/LabelWithIcons.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@tool
extends RichTextLabel

@export_multiline
var text_with_icons : String:
set(value):
if !Engine.is_editor_hint():
await ready
_text_with_icons = value
bbcode_enabled = true
text = MaterialIconsDB.prase_icons(value)

get:
return _text_with_icons

var _text_with_icons : String
47 changes: 47 additions & 0 deletions addons/material-design-icons/examples/Test.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[gd_scene load_steps=5 format=3 uid="uid://dkr5smdig8tv4"]

[ext_resource type="FontFile" uid="uid://bbfeoo2kuf30n" path="res://addons/material-design-icons/fonts/material_design_icons.ttf" id="1_fqgpp"]
[ext_resource type="Script" path="res://addons/material-design-icons/nodes/MaterialButton.gd" id="2_l3c8x"]
[ext_resource type="Script" path="res://addons/material-design-icons/nodes/MaterialIcon.gd" id="3_87ldj"]
[ext_resource type="Script" path="res://addons/material-design-icons/examples/LabelWithIcons.gd" id="4_lf58l"]

[node name="Test" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="MaterialButton" type="Button" parent="."]
layout_mode = 2
offset_right = 94.0
offset_bottom = 131.0
theme_override_fonts/font = ExtResource("1_fqgpp")
theme_override_font_sizes/font_size = 86
text = "󰌀"
script = ExtResource("2_l3c8x")
icon_name = "microsoft-internet-explorer"
icon_size = 86

[node name="MaterialIcon" type="Label" parent="."]
layout_mode = 2
offset_left = 98.0
offset_right = 226.0
offset_bottom = 131.0
theme_override_fonts/font = ExtResource("1_fqgpp")
theme_override_font_sizes/font_size = 128
text = "󰢚"
script = ExtResource("3_87ldj")
icon_name = "alien"
icon_size = 128

[node name="LabelWithIcons" type="RichTextLabel" parent="."]
layout_mode = 2
offset_top = 135.0
offset_right = 273.0
offset_bottom = 268.0
bbcode_enabled = true
text = "Text with Icons: [font=res://addons/material-design-icons/fonts/material_design_icons.ttf]󰴑[/font] Second icon: [font=res://addons/material-design-icons/fonts/material_design_icons.ttf]󰀫[/font]"
script = ExtResource("4_lf58l")
text_with_icons = "Text with Icons: [icon:format-textbox] Second icon: [icon:alpha]"
20 changes: 20 additions & 0 deletions addons/material-design-icons/fonts/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Pictogrammers Free License
--------------------------

This icon collection is released as free, open source, and GPL friendly by
the [Pictogrammers](http://pictogrammers.com/) icon group. You may use it
for commercial projects, open source projects, or anything really.

# Icons: Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
Some of the icons are redistributed under the Apache 2.0 license. All other
icons are either redistributed under their respective licenses or are
distributed under the Apache 2.0 license.

# Fonts: Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
All web and desktop fonts are distributed under the Apache 2.0 license. Web
and desktop fonts contain some icons that are redistributed under the Apache
2.0 license. All other icons are either redistributed under their respective
licenses or are distributed under the Apache 2.0 license.

# Code: MIT (https://opensource.org/licenses/MIT)
The MIT license applies to all non-font and non-icon files.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[remap]

importer="font_data_dynamic"
type="FontFile"
uid="uid://dyn8i4h6xkx00"
path="res://.godot/imported/material_design_icons.ttf-1579ec5c9b2eaab41f326c3a8f2d91c2.fontdata"

[deps]

source_file="res://addons/material-design-icons/fonts/material_design_icons.ttf"
dest_files=["res://.godot/imported/material_design_icons.ttf-1579ec5c9b2eaab41f326c3a8f2d91c2.fontdata"]

[params]

Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}
77 changes: 77 additions & 0 deletions addons/material-design-icons/icon_finder/IconFinder.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[gd_scene load_steps=3 format=3 uid="uid://bni8w3a3pcbwn"]

[ext_resource type="Script" path="res://addons/material-design-icons/icon_finder/icon_finder.gd" id="1_nv02s"]
[ext_resource type="FontFile" uid="uid://bbfeoo2kuf30n" path="res://addons/material-design-icons/fonts/material_design_icons.ttf" id="4_xlv7e"]

[node name="IconFinder" type="Window" node_paths=PackedStringArray("icons_text", "notify_label", "search_line_edit", "size_slider", "size_label")]
title = "Icon Finder"
initial_position = 2
size = Vector2i(775, 400)
unresizable = true
script = ExtResource("1_nv02s")
icons_text = NodePath("Panel/VBoxContainer/RichTextLabel")
notify_label = NodePath("Panel/VBoxContainer/Notify")
search_line_edit = NodePath("Panel/VBoxContainer/Search")
size_slider = NodePath("Panel/VBoxContainer/SliderContainer/HSlider")
size_label = NodePath("Panel/VBoxContainer/SliderContainer/LabelSize")

[node name="Panel" type="Panel" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3

[node name="VBoxContainer" type="VBoxContainer" parent="Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3

[node name="Search" type="LineEdit" parent="Panel/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
placeholder_text = "Search"
caret_blink = true
caret_blink_interval = 0.5

[node name="Notify" type="Label" parent="Panel/VBoxContainer"]
visible = false
layout_mode = 2
text = "Icon-x was copied to clipboard."

[node name="SliderContainer" type="HBoxContainer" parent="Panel/VBoxContainer"]
layout_mode = 2

[node name="Label" type="Label" parent="Panel/VBoxContainer/SliderContainer"]
layout_mode = 2
text = "Size preview"

[node name="HSlider" type="HSlider" parent="Panel/VBoxContainer/SliderContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
min_value = 16.0
max_value = 128.0
value = 24.0

[node name="LabelSize" type="Label" parent="Panel/VBoxContainer/SliderContainer"]
layout_mode = 2
text = "24"

[node name="RichTextLabel" type="RichTextLabel" parent="Panel/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
tooltip_text = "click on icon to copy its name to clipboard"
theme_override_colors/table_border = Color(1, 1, 1, 1)
theme_override_fonts/normal_font = ExtResource("4_xlv7e")
theme_override_font_sizes/normal_font_size = 24
bbcode_enabled = true
meta_underlined = false
82 changes: 82 additions & 0 deletions addons/material-design-icons/icon_finder/icon_finder.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
@tool
extends Window

@export
@onready var icons_text : RichTextLabel

@export_range(0.1, 1, 0.01)
var fill_scale_x : float = 0.8

@export
@onready var notify_label : Label

@export
@onready var search_line_edit : LineEdit

@export
@onready var size_slider : HSlider

@export
@onready var size_label : Label

func _ready():
notify_label.hide()
search_line_edit.text_changed.connect(update_table)
icons_text.meta_clicked.connect(_on_meta)
icons_text.set_meta_underline(false)
icons_text.tooltip_text = "click on icon to copy its name to clipboard"
close_requested.connect(hide)
size_slider.value_changed.connect(update_icons_size)
about_to_popup.connect(update_table)

func _on_visibility_changed():
if is_visible():
update_icons_size(size_slider.value)

func update_icons_size(value:int):
size_label.text = str(value)
icons_text.set("theme_override_font_sizes/normal_font_size", value)
update_table(search_line_edit.text)

func update_table(filter := ""):
var table = "[table={columns}, {inline_align}]"
table = table.format({
"columns": int ((size.x * fill_scale_x) / size_slider.value) ,
"inline_align": INLINE_ALIGNMENT_CENTER
})

for key in MaterialIconsDB.icons:
if filter:
if not (filter.to_lower() in key):
continue

var link := "[url={link}]{text}[/url]"
var text := MaterialIconsDB.get_icon_char(key)
link = link.format({
"link": key,
"text": text
})

var cell := "[cell]{link}[/cell]"
table += cell.format({"link": link})

table += "[/table]"
icons_text.parse_bbcode(table)

func _on_meta(link:String):
DisplayServer.clipboard_set(link)
notify_label.text = "Copied to Clipboard: " + link
notify_label.show()

var t := get_tree().create_tween()
t.tween_property(
notify_label, "modulate",
Color.GREEN, 1
)
t.chain().tween_property(
notify_label, "modulate",
Color.TRANSPARENT, 1
)
await t.finished
notify_label.hide()

64 changes: 64 additions & 0 deletions addons/material-design-icons/icons/icons.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
@tool
extends Node

const json_path := "res://addons/material-design-icons/icons/icons.json"
const font_path := "res://addons/material-design-icons/fonts/material_design_icons.ttf"
@onready var font := preload(font_path) as FontFile
var icons := {}

func _ready():
var content = get_file_content(json_path)
var json := JSON.new()

if json.parse(content) == OK:
init_icons_dictionaries(json.data)

func get_file_content(path:String) -> String:
var file := FileAccess.open(path, FileAccess.READ)
var content := ""

if file.get_error() == OK:
content = file.get_as_text()
file.close()

return content

func init_icons_dictionaries(dict:Dictionary):
icons = {}
for icon in dict:
var hex: String = dict[icon].to_lower()
var value: int = ("0x"+ hex).hex_to_int()
icons[icon] = value

func get_icon_code(id:String) -> int:
if id in icons:
return icons[id]

push_warning("Icon '%s' not found." % id)
return 0

func get_icon_name(char:int) -> String:
for icon in icons:
if icons[icon] == char:
return icon

push_warning("Icon with char '%s' not found." % char)
return ""

func get_icon_char(id:String) -> String:
return char(get_icon_code(id))

func prase_icons(text:String) -> String:
# take replace [icon] to [font=MaterialIcons]icon_char[/font]
var regex = RegEx.new()
regex.compile("\\[icon:(.*?)\\]")
var x = regex.search(text)
while x != null:
var icon = x.get_string(1)
var char = get_icon_char(icon)
var r = "[font={font}]{char}[/font]"
r = r.format({"font":font.resource_path, "char": char})
text = text.replace(x.get_string(), r)
x = regex.search(text, x.get_end())

return text
Loading

0 comments on commit 9ddfbce

Please sign in to comment.