-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d347e95
commit 228fd84
Showing
7 changed files
with
197 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
tool | ||
extends Control | ||
class_name LevelChecker | ||
|
||
var options = [] | ||
|
||
var parserNameToken = "" | ||
var parserNameTokenLine = 0 | ||
var parserFindings = [] | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
_on_UpdateList_button_up() | ||
|
||
|
||
func createFinding(token: String, findLine: int, findLineText: String): | ||
parserFindings.append({"token": token, "findLine": findLine, "findLineText": findLineText}) | ||
|
||
|
||
func interpretLine(idx: int, line: String): | ||
if line.begins_with("[node name="): | ||
#New Token found - Replace old | ||
line = line.right(12) | ||
var end = line.find("\"",0) | ||
line = line.substr(0, end) | ||
parserNameToken = line | ||
parserNameTokenLine = idx | ||
elif line.begins_with("position"): | ||
#Parse Position | ||
if line.find(".", 20) != -1: | ||
#Found | ||
createFinding(parserNameToken, idx, line.right(20).trim_suffix(")")) | ||
|
||
func updateFindings(): | ||
$OptionButton/TextEdit.text = "" | ||
for line in parserFindings: | ||
$OptionButton/TextEdit.text += str(line.findLine) + ": " + line.token + " -> " + line.findLineText + "\n" | ||
|
||
|
||
func _on_Scan_button_up(): | ||
parserFindings = [] | ||
var activeFileId = $OptionButton.selected | ||
var file = File.new() | ||
file.open("res://Src/Levels/" + options[activeFileId], File.READ) | ||
|
||
var lineIdx = 1 | ||
while not file.eof_reached(): | ||
interpretLine(lineIdx, file.get_line()) | ||
lineIdx += 1 | ||
|
||
file.close() | ||
updateFindings() | ||
|
||
|
||
func _on_UpdateList_button_up(): | ||
var dir = Directory.new() | ||
|
||
if dir.open("res://Src/Levels/") == OK: | ||
$OptionButton.clear() | ||
options = [] | ||
|
||
dir.list_dir_begin(true) | ||
var file_name = dir.get_next() | ||
while file_name != "": | ||
if not dir.current_is_dir(): | ||
if file_name.get_extension() == "tscn": | ||
options.append(file_name) | ||
$OptionButton.add_item(file_name, options.size() - 1) | ||
file_name = dir.get_next() | ||
dir.close() | ||
|
||
func _on_FixFindings_button_up(): | ||
pass # Replace with function body. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
[gd_scene load_steps=2 format=2] | ||
|
||
[ext_resource path="res://addons/LevelChecker/LevelChecker.gd" type="Script" id=1] | ||
|
||
[node name="LevelChecker" type="WindowDialog"] | ||
margin_left = 8.0 | ||
margin_top = 24.0 | ||
margin_right = 648.0 | ||
margin_bottom = 504.0 | ||
script = ExtResource( 1 ) | ||
|
||
[node name="Panel" type="Panel" parent="."] | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} | ||
|
||
[node name="Label" type="Label" parent="."] | ||
margin_left = 24.0 | ||
margin_top = 16.0 | ||
margin_right = 64.0 | ||
margin_bottom = 47.0 | ||
text = "Pixel Position Scan | ||
" | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} | ||
|
||
[node name="OptionButton" type="OptionButton" parent="."] | ||
margin_left = 24.0 | ||
margin_top = 40.0 | ||
margin_right = 296.0 | ||
margin_bottom = 64.0 | ||
text = "HQ_Level.tscn" | ||
items = [ "HQ_Level.tscn", null, false, 0, null, "Level1.tscn", null, false, 1, null, "Level10.tscn", null, false, 2, null, "Level18.tscn", null, false, 3, null, "Level19.tscn", null, false, 4, null, "Level2.tscn", null, false, 5, null, "Level3.tscn", null, false, 6, null, "Level4.tscn", null, false, 7, null, "Level5.tscn", null, false, 8, null, "Level6.tscn", null, false, 9, null, "Level7.tscn", null, false, 10, null, "Level8.tscn", null, false, 11, null, "Level9.tscn", null, false, 12, null, "LevelX.tscn", null, false, 13, null, "TestLevel.tscn", null, false, 14, null ] | ||
selected = 0 | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} | ||
|
||
[node name="Scan" type="Button" parent="OptionButton"] | ||
margin_left = 400.0 | ||
margin_right = 448.0 | ||
margin_bottom = 24.0 | ||
text = "Scan Selected" | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} | ||
|
||
[node name="UpdateList" type="Button" parent="OptionButton"] | ||
margin_left = 280.0 | ||
margin_right = 383.0 | ||
margin_bottom = 24.0 | ||
text = "Update List" | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} | ||
|
||
[node name="FixFindings" type="Button" parent="OptionButton"] | ||
margin_left = 512.0 | ||
margin_right = 560.0 | ||
margin_bottom = 24.0 | ||
text = "Fix Findings" | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} | ||
|
||
[node name="TextEdit" type="TextEdit" parent="OptionButton"] | ||
margin_top = 32.0 | ||
margin_right = 600.0 | ||
margin_bottom = 280.0 | ||
[connection signal="button_up" from="OptionButton/Scan" to="." method="_on_Scan_button_up"] | ||
[connection signal="button_up" from="OptionButton/UpdateList" to="." method="_on_UpdateList_button_up"] | ||
[connection signal="button_up" from="OptionButton/FixFindings" to="." method="_on_FixFindings_button_up"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
tool | ||
extends EditorPlugin | ||
class_name LevelCheckerPlugin | ||
|
||
signal editor_visible | ||
|
||
const editor_scn: PackedScene = preload("res://addons/LevelChecker/LevelChecker.tscn") | ||
var editor: Control = editor_scn.instance() | ||
|
||
|
||
func _enter_tree() -> void: | ||
add_tool_menu_item("LevelChecker", self, "_callback") | ||
|
||
|
||
func _exit_tree() -> void: | ||
remove_tool_menu_item("LevelChecker") | ||
editor.free() | ||
|
||
|
||
func _callback(_u): | ||
print("callback") | ||
add_child(editor) | ||
editor.popup() | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[plugin] | ||
|
||
name="LevelChecker" | ||
description="LevelChecker Tool" | ||
author="mago" | ||
version="1.0" | ||
script="LevelCheckerPlugin.gd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters