first commit, long overdue
deez
This commit is contained in:
commit
54b9012a47
79 changed files with 2516 additions and 0 deletions
171
01 - Menus/04 - Modules/modules_list.gd
Normal file
171
01 - Menus/04 - Modules/modules_list.gd
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
extends Control
|
||||
|
||||
var item # e.g. grondir
|
||||
var category # e.g. characters
|
||||
var module # e.g. trait
|
||||
var items = [] # e.g. ["Undergrounder","Tough"]
|
||||
|
||||
var ini
|
||||
|
||||
var config
|
||||
var item_filter = ""
|
||||
var suggestions
|
||||
var suggestion = ""
|
||||
var overview
|
||||
var rec_helper = []
|
||||
var selected = ""
|
||||
var items_list:Array = []
|
||||
|
||||
func _enter_tree() -> void:
|
||||
config = ConfigFile.new()
|
||||
config.load("res://02 - Configurations/campaign/categories.ini")
|
||||
rec_helper = config.get_value(category,"modules_list",[])
|
||||
items = []
|
||||
#print(str(category))
|
||||
#print(str(module))
|
||||
#print(str(items))
|
||||
custom_minimum_size.y = 512
|
||||
%filter.placeholder_text = "Filter " + module
|
||||
%new_item.text = "Add " + module
|
||||
%new_item_name.visible = false
|
||||
%suggestions_background.visible = false
|
||||
%new_item_suggestions.visible = false
|
||||
ini = "res://02 - Configurations/" + category + ".ini"
|
||||
list_items()
|
||||
|
||||
func list_items():
|
||||
config = ConfigFile.new()
|
||||
config.load(ini)
|
||||
print("modules_list:list_items:1 " + category)
|
||||
items = []
|
||||
%list.item_count = 0
|
||||
for i in rec_helper:
|
||||
print("")
|
||||
rec(i,category,item)
|
||||
#print(str(%list.item_count))
|
||||
pass
|
||||
|
||||
|
||||
func rec(i,conf,k):
|
||||
var conff = "res://02 - Configurations/" + conf + ".ini"
|
||||
config = ConfigFile.new()
|
||||
config.load(conff)
|
||||
print("modules_list:rec:1 conff = " + conff)
|
||||
print("modules_list:rec:2 sections = " + str(config.get_section_keys(k)))
|
||||
print("modules_list:rec:3 k = " + str(k))
|
||||
print("modules_list:rec:4 i = " + str(i))
|
||||
if config.get_section_keys(k).has(i):
|
||||
var m = config.get_value(k,i)
|
||||
print("modules_list:rec:5 " + (k) + " has " + str(m) + " as " + str(i))
|
||||
if module == i:
|
||||
print("modules_list:rec:6 " + str(items))
|
||||
for b in config.get_value(k,i,[]):
|
||||
print("modules_list:rec:10 " + str(b) + str(items))
|
||||
if not items.has(b) and b != "":
|
||||
items = items + [b]
|
||||
print("modules_list:rec:11 adding " + b + " to list")
|
||||
if item_filter == "":
|
||||
%list.add_item(str(b))
|
||||
%list.set_item_tooltip(%list.item_count - 1, k)
|
||||
if conf != category:
|
||||
%list.set_item_custom_bg_color(%list.item_count - 1,"black")
|
||||
elif item_filter.to_lower() in b.to_lower():
|
||||
%list.add_item(str(b))
|
||||
else:
|
||||
%list.item_count = %list.item_count -1
|
||||
print("modules_list:rec:12 " + i + " " + str(category))
|
||||
if i != category:
|
||||
print("modules_list:rec:7 " + str(rec_helper.slice(rec_helper.find(i),-1)))
|
||||
print("modules_list:rec:8 " + str(m))
|
||||
for o in rec_helper.slice(rec_helper.find(i),rec_helper.size()):
|
||||
print(str(o))
|
||||
for j in m:
|
||||
print("modules_list:rec:9 rec " + o + " - " + i + " - " + j)
|
||||
rec(o,i,j)
|
||||
|
||||
func _on_filter_text_changed(new_text: String) -> void:
|
||||
item_filter = new_text
|
||||
list_items()
|
||||
|
||||
func _on_new_item_button_up() -> void:
|
||||
%new_item_name.visible = true
|
||||
%suggestions_background.visible = true
|
||||
%new_item_suggestions.visible = true
|
||||
%new_item_name.grab_focus()
|
||||
list_suggestions()
|
||||
|
||||
|
||||
func _on_new_item_name_editing_toggled(toggled_on: bool) -> void:
|
||||
if !toggled_on:
|
||||
%new_item_name.text = ""
|
||||
%new_item_name.visible = false
|
||||
%suggestions_background.visible = false
|
||||
await get_tree().create_timer(0.001).timeout
|
||||
%new_item_suggestions.visible = false
|
||||
|
||||
|
||||
func list_suggestions():
|
||||
config = ConfigFile.new()
|
||||
config.load("res://02 - Configurations/" + module + ".ini")
|
||||
var i = 0
|
||||
suggestions = config.get_sections()
|
||||
#print(str(suggestions))
|
||||
%new_item_suggestions.item_count = suggestions.size()
|
||||
#print(str(%new_item_suggestions.item_count))
|
||||
for j in suggestions:
|
||||
if suggestion == "":
|
||||
%new_item_suggestions.set_item_text(i,str(j))
|
||||
i = i+1
|
||||
elif suggestion.to_lower() in j.to_lower():
|
||||
%new_item_suggestions.set_item_text(i,str(j))
|
||||
i = i+1
|
||||
#print(j)
|
||||
else:
|
||||
%new_item_suggestions.item_count = %new_item_suggestions.item_count -1
|
||||
#print(str(%list.item_count))
|
||||
pass
|
||||
|
||||
func _on_new_item_name_text_changed(new_text: String) -> void:
|
||||
suggestion = new_text
|
||||
list_suggestions()
|
||||
|
||||
|
||||
func _on_new_item_suggestions_item_selected(index: int) -> void:
|
||||
config = ConfigFile.new()
|
||||
config.load(ini)
|
||||
if not items.has(%new_item_suggestions.get_item_text(index)):
|
||||
print(str(items))
|
||||
var i = config.get_value(item,module,[]) + [%new_item_suggestions.get_item_text(index)]
|
||||
print(str(i))
|
||||
config.set_value(item,module,i)
|
||||
config.save(ini)
|
||||
list_items()
|
||||
|
||||
|
||||
func _on_list_item_selected(index: int) -> void:
|
||||
if overview:
|
||||
remove_child(overview)
|
||||
print(module)
|
||||
config = ConfigFile.new()
|
||||
config.load("res://02 - Configurations/campaign/categories.ini")
|
||||
var submodule = config.get_value(module,"module","")
|
||||
overview = load("res://01 - Menus/04 - Modules/modules_" + submodule + ".tscn").instantiate()
|
||||
overview.position.x = 448
|
||||
overview.scale.x = 0.8
|
||||
overview.scale.y = 0.8
|
||||
overview.category = module
|
||||
overview.item = %list.get_item_text(index)
|
||||
overview.mouse_filter = 2
|
||||
selected = %list.get_item_text(index)
|
||||
add_child(overview)
|
||||
|
||||
|
||||
func _on_delete_button_up() -> void:
|
||||
config = ConfigFile.new()
|
||||
config.load(ini)
|
||||
print(str(items))
|
||||
var j = config.get_value(category,item,[])
|
||||
j.remove_at(config.get_value(category,item,[]).find(selected))
|
||||
config.set_value(item,module,j)
|
||||
config.save(ini)
|
||||
list_items()
|
||||
Loading…
Add table
Add a link
Reference in a new issue