first commit, long overdue
deez
This commit is contained in:
commit
54b9012a47
79 changed files with 2516 additions and 0 deletions
117
01 - Menus/05 - Campaign Manager/item_helper.gd
Normal file
117
01 - Menus/05 - Campaign Manager/item_helper.gd
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
extends Control
|
||||
|
||||
var item
|
||||
var config
|
||||
var name_
|
||||
var name_self
|
||||
var module
|
||||
var modules_list
|
||||
var main_menu_entry = ""
|
||||
|
||||
func _enter_tree() -> void:
|
||||
config = ConfigFile.new()
|
||||
config.load("res://02 - Configurations/campaign/categories.ini")
|
||||
name_ = config.get_value(item,"name","")
|
||||
name_self = config.get_value(item,"name_self","")
|
||||
modules_list = config.get_value(item,"modules_list",[])
|
||||
%item.text = item
|
||||
%name.text = name_
|
||||
%name_self.text = name_self
|
||||
%add_new_select.visible = false
|
||||
%module.add_item("")
|
||||
%module.add_item(%item.text)
|
||||
print("item_helper:_enter_tree: item_helper for " + item)
|
||||
var modules:Array = [""]
|
||||
var select_module = 0
|
||||
for i in config.get_sections():
|
||||
print("item_helper:_enter_tree:i populating %add_new_select with " + i)
|
||||
%add_new_select.add_item(i)
|
||||
var k = config.get_value(i,"module","")
|
||||
if k == %item.text: # select item 1 when module has same name as item
|
||||
print("item_helper:_enter_tree: selecting " + k)
|
||||
select_module = 1
|
||||
elif k != "": # proceed only if module is set
|
||||
if not modules.has(k): # don't duplicate entries
|
||||
print("item_helper:_enter_tree:2 " + str(k) + " into " + str(modules))
|
||||
modules = modules + [config.get_value(i,"module","")]
|
||||
%module.add_item(k)
|
||||
|
||||
if k == config.get_value(item,"module",""):
|
||||
print("item_helper:_enter_tree:3 selecting " + k + " for " + str(i))
|
||||
select_module = modules.find(k) + 1
|
||||
%module.select(select_module)
|
||||
config = ConfigFile.new()
|
||||
config.load("res://02 - Configurations/campaign/main_menu.ini")
|
||||
var h = 1
|
||||
for i in config.get_sections():
|
||||
%categories.add_item(config.get_value(i,"name",""))
|
||||
%categories.set_item_tooltip(%categories.item_count - 1,i)
|
||||
if config.get_value(i,"items",[]).has(item):
|
||||
%categories.select(h)
|
||||
h = h + 1
|
||||
config = ConfigFile.new()
|
||||
config.load("res://02 - Configurations/campaign/categories.ini")
|
||||
var j:float = modules_list.size()
|
||||
if j != 0:
|
||||
%modules_list.max_columns = j
|
||||
%modules_list.fixed_column_width = %modules_list.size.x/(1.1*j) - (j *8)
|
||||
for i in modules_list:
|
||||
print("item_helper:_enter_tree:1 " + i)
|
||||
%modules_list.add_item(i)
|
||||
|
||||
func save():
|
||||
if %item.text != "":
|
||||
config = ConfigFile.new()
|
||||
config.load("res://02 - Configurations/campaign/categories.ini")
|
||||
item = %item.text
|
||||
config.set_value(item,"name",%name.text)
|
||||
config.set_value(item,"name_self",%name_self.text)
|
||||
config.set_value(item,"module",%module.text)
|
||||
var j = []
|
||||
for i in %modules_list.item_count:
|
||||
j = j + [%modules_list.get_item_text(i)]
|
||||
config.set_value(item,"modules_list",j)
|
||||
print("item_helper:save:1 saving " + item)
|
||||
config.save("res://02 - Configurations/campaign/categories.ini")
|
||||
|
||||
|
||||
config = ConfigFile.new()
|
||||
config.load("res://02 - Configurations/campaign/main_menu.ini")
|
||||
if not config.get_value(main_menu_entry,"items",[]).has(item) and main_menu_entry != "":
|
||||
print("item_helper:save:2 " + item + " not in " + str(config.get_value(main_menu_entry,"items",[])))
|
||||
config.set_value(main_menu_entry,"items",config.get_value(main_menu_entry,"items",[]) + [item])
|
||||
config.save("res://02 - Configurations/campaign/main_menu.ini")
|
||||
|
||||
|
||||
|
||||
func _on_modules_list_item_selected(index: int) -> void:
|
||||
print("item_helper:_on_modules_list_item_selected:2 remove " + %modules_list.get_item_text(index))
|
||||
%modules_list.remove_item(index)
|
||||
|
||||
|
||||
func _on_add_new_item_selected(index: int) -> void:
|
||||
%modules_list.add_item(%add_new_select.get_item_text(index))
|
||||
var j:float = %modules_list.item_count
|
||||
%modules_list.max_columns = j
|
||||
%modules_list.fixed_column_width = %modules_list.size.x/(1.1*j) - (j *8)
|
||||
%add_new_select.visible = false
|
||||
|
||||
func _on_module_item_selected(index: int) -> void:
|
||||
module = %module.get_item_text(index)
|
||||
|
||||
|
||||
func _on_add_new_button_up() -> void:
|
||||
print("item_helper:_on_add_new_button_up:1 Add new")
|
||||
%add_new_select.visible = true
|
||||
|
||||
func _on_add_new_select_focus_exited() -> void:
|
||||
%add_new_select.visible = false
|
||||
|
||||
|
||||
func _on_item_text_changed(new_text: String) -> void:
|
||||
%module.set_item_text(1,new_text)
|
||||
|
||||
|
||||
func _on_categories_item_selected(index: int) -> void:
|
||||
main_menu_entry = %categories.get_item_tooltip(index)
|
||||
print("item_helper:_on_categories_item_selected:1 " + str(main_menu_entry))
|
||||
Loading…
Add table
Add a link
Reference in a new issue