diff --git a/addons/laia_highlighter/plugin.cfg b/addons/laia_highlighter/plugin.cfg new file mode 100644 index 0000000..fc0bffb --- /dev/null +++ b/addons/laia_highlighter/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="Laia Highlighter" +description="A highlighter to highting laia scripting files" +author="Ategon" +version="v1.0.0" +script="plugin.gd" diff --git a/addons/laia_highlighter/plugin.gd b/addons/laia_highlighter/plugin.gd new file mode 100644 index 0000000..03061d2 --- /dev/null +++ b/addons/laia_highlighter/plugin.gd @@ -0,0 +1,81 @@ +@tool +extends EditorPlugin + + +var dialogue_highlighter:DialogueHighlighter + + +func _enter_tree() -> void: + dialogue_highlighter = DialogueHighlighter.new() + var script_editor = EditorInterface.get_script_editor() + print(script_editor) + print(dialogue_highlighter) + script_editor.register_syntax_highlighter(dialogue_highlighter) + print(script_editor.get_current_script()) + print(script_editor.get_open_scripts()) + script_editor.goto_line(20) + + +func _exit_tree() -> void: + if is_instance_valid(dialogue_highlighter): + var script_editor = EditorInterface.get_script_editor() + script_editor.unregister_syntax_highlighter(dialogue_highlighter) + dialogue_highlighter = null + + +class DialogueHighlighter extends EditorSyntaxHighlighter: + func _get_name() -> String: + return "Laia" + + func _get_supported_languages() -> PackedStringArray: + return ["TextFile"] + + func _get_line_syntax_highlighting(line: int) -> Dictionary: + var color_map = {} + var text_editor = get_text_edit() + var str = text_editor.get_line(line) + + # Comment + if str.strip_edges().begins_with("#"): + color_map[0] = { "color": Color.WEB_GRAY } + return color_map + + # Key + var regex3 = RegEx.new() + regex3.compile("([a-zA-Z0-9_]+:).*") + var result3 = regex3.search(str) + + if result3: + color_map[result3.get_start(1)] = { "color": Color.SEA_GREEN } + color_map[result3.get_end(1)] = { "color": Color.WHITE } + + # Array + var regex = RegEx.new() + regex.compile("([a-zA-Z0-9_\\-])+\\[\\]") + var result = regex.search(str) + + if result: + color_map[result.get_start()] = { "color": Color.CYAN } + color_map[result.get_end(1)] = { "color": Color.LIGHT_CYAN } + + # Enum + var regex4 = RegEx.new() + regex4.compile("[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)") + var result4 = regex4.search(str) + + if result4: + color_map[result4.get_start()] = { "color": Color.ORANGE } + color_map[result4.get_start(1)] = { "color": Color.ORANGE_RED } + color_map[result4.get_end()] = { "color": Color.WHITE } + + # Color + var regex2 = RegEx.new() + regex2.compile("#[a-zA-Z0-9]+") + var result2 = regex2.search(str) + + if result2: + color_map[result2.get_start()] = { "color": Color(result2.get_string()) } + + + + return color_map diff --git a/buildings/Building.tscn b/buildings/Building.tscn new file mode 100644 index 0000000..394fec1 --- /dev/null +++ b/buildings/Building.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://daicnavgi0gpo"] + +[ext_resource type="Script" path="res://buildings/building.gd" id="1_db3yd"] + +[node name="Building" type="Node2D"] +script = ExtResource("1_db3yd") + +[node name="Sprite2D" type="Sprite2D" parent="."] diff --git a/buildings/building.gd b/buildings/building.gd new file mode 100644 index 0000000..9a08ebe --- /dev/null +++ b/buildings/building.gd @@ -0,0 +1,12 @@ +extends Node2D + +@onready var sprite_2d: Sprite2D = $Sprite2D + +var key +@onready var data = Data.data.buildings[key] +#@onready var image = Data.data.images[key] + +func _ready() -> void: + #sprite_2d.texture = image + + pass diff --git a/main.gd b/main.gd new file mode 100644 index 0000000..e251cf8 --- /dev/null +++ b/main.gd @@ -0,0 +1 @@ +extends Node2D diff --git a/parts/buildings/stoneminer.txt b/parts/buildings/stoneminer.txt new file mode 100644 index 0000000..154e29f --- /dev/null +++ b/parts/buildings/stoneminer.txt @@ -0,0 +1 @@ +name: Stone Miner diff --git a/parts/buildings/woodcutter.txt b/parts/buildings/woodcutter.txt new file mode 100644 index 0000000..462ece3 --- /dev/null +++ b/parts/buildings/woodcutter.txt @@ -0,0 +1 @@ +name: Woodcutter diff --git a/parts/globals.txt b/parts/globals.txt index eade4d8..aeeeeef 100644 --- a/parts/globals.txt +++ b/parts/globals.txt @@ -1 +1,15 @@ time_to_flood_change: 5 +flood_levels[] + 0 + 1 + 0 + 2 + 1 + 3 + 1 + 0 + 2 + 1 + 4 + 2 + 5 diff --git a/project.godot b/project.godot index c9232da..4950c22 100644 --- a/project.godot +++ b/project.godot @@ -30,6 +30,10 @@ window/size/viewport_width=640 window/size/viewport_height=360 window/stretch/mode="canvas_items" +[editor_plugins] + +enabled=PackedStringArray("res://addons/laia_highlighter/plugin.cfg") + [input] lclick={ diff --git a/StormManager.tscn b/storm/StormManager.tscn similarity index 62% rename from StormManager.tscn rename to storm/StormManager.tscn index f4721f0..5461bd1 100644 --- a/StormManager.tscn +++ b/storm/StormManager.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://n2lpy72tkyc8"] -[ext_resource type="Script" path="res://storm_manager.gd" id="1_wwjtb"] +[ext_resource type="Script" path="res://storm/storm_manager.gd" id="1_wwjtb"] [node name="StormManager" type="Node"] script = ExtResource("1_wwjtb") diff --git a/storm_manager.gd b/storm/storm_manager.gd similarity index 68% rename from storm_manager.gd rename to storm/storm_manager.gd index 61cc8ce..e959e95 100644 --- a/storm_manager.gd +++ b/storm/storm_manager.gd @@ -2,26 +2,10 @@ extends Node @onready var globals = Data.data.globals - var game_time = 0 var last_flood_time = 0 var current_flood_state = 0 -var flood_levels = [ - 0, - 1, - 0, - 2, - 1, - 3, - 1, - 0, - 2, - 1, - 4, - 2, - 5 -] func _process(delta: float) -> void: game_time += delta @@ -30,4 +14,4 @@ func _process(delta: float) -> void: last_flood_time += globals.time_to_flood_change current_flood_state += 1 - Persister.persist_data("flood_level", flood_levels[current_flood_state]) + Persister.persist_data("flood_level", globals.flood_levels[current_flood_state])