x12 windowing system
This commit is contained in:
parent
e16b468e23
commit
e6ab1fb39a
60 changed files with 701 additions and 877 deletions
|
|
@ -8,7 +8,7 @@ var item_proper_names = []
|
|||
var categories
|
||||
var pixel_x
|
||||
var pixel_y
|
||||
var ui_scale = 1
|
||||
var ui_scale
|
||||
|
||||
func _enter_tree() -> void:
|
||||
conf_mm = ConfigFile.new()
|
||||
|
|
@ -17,13 +17,6 @@ func _enter_tree() -> void:
|
|||
conf_cat.load("res://02 - Configurations/campaign/categories.ini")
|
||||
print("main_menu:_enter_tree:1 " + str(conf_mm.get_sections()))
|
||||
categories = []
|
||||
pixel_x = get_viewport_rect().size[0]
|
||||
pixel_y = get_viewport_rect().size[1]
|
||||
if pixel_x + pixel_y > 2900:
|
||||
ui_scale = 1
|
||||
else:
|
||||
ui_scale = 0.7
|
||||
print("main_menu:_enter_tree:2 " + str(pixel_x) + " " + str(pixel_y))
|
||||
for i in conf_mm.get_sections():
|
||||
categories = categories + [i]
|
||||
|
||||
|
|
@ -50,7 +43,7 @@ func item_selected(k,tab):
|
|||
print("main_menu:select_category:2 " + str(item_names))
|
||||
menu_item.category = item_names[item_proper_names.find(tab.get_item_text(k))]
|
||||
add_child(menu_item)
|
||||
menu_item.set_menu_items(pixel_x,pixel_y,ui_scale)
|
||||
menu_item.set_menu_items()
|
||||
|
||||
func remove_tabs(tab):
|
||||
remove_child.call_deferred(tab)
|
||||
|
|
@ -59,38 +52,41 @@ func _on_exit_button_up() -> void:
|
|||
get_tree().quit()
|
||||
|
||||
func set_menu_items():
|
||||
print("main_menu:set_menu_items:1 " + str(pixel_x) + " " + str(pixel_y))
|
||||
%scroll.size.y = pixel_y - (256 * ui_scale)
|
||||
%scroll.position.y = 128 * ui_scale
|
||||
%campaign_manager.position.y = pixel_y - 192 * ui_scale
|
||||
%exit.position.y = pixel_y - 96 * ui_scale
|
||||
ui_scale = 1
|
||||
if get_viewport_rect().size[0] + get_viewport_rect().size[1] < 3000:
|
||||
ui_scale = 0.7
|
||||
pixel_x = get_viewport_rect().size[0] / ui_scale
|
||||
pixel_y = get_viewport_rect().size[1] / ui_scale
|
||||
$".".scale = Vector2(ui_scale,ui_scale)
|
||||
#print("main_menu:set_menu_items:1 " + str(pixel_x) + " " + str(pixel_y))
|
||||
%scroll.size.y = pixel_y - (320 )
|
||||
%scroll.position.y = 128
|
||||
%campaign_manager.position.y = pixel_y - 192
|
||||
%exit.position.y = pixel_y - 96
|
||||
%ui_main_menu.size.y = pixel_y
|
||||
%ui_background.size.y = pixel_y
|
||||
%ui_background.size.x = pixel_x
|
||||
if pixel_x < pixel_y: #mobile
|
||||
%ui_main_menu.size.x = pixel_x
|
||||
for i in [%scroll,%exit,%campaign_manager]:
|
||||
i.scale = Vector2(ui_scale,ui_scale)
|
||||
i.size.x = pixel_x/ui_scale - 128
|
||||
i.position.x = 64*ui_scale
|
||||
i.size.x = pixel_x - 128
|
||||
i.position.x = 64
|
||||
else:
|
||||
%ui_main_menu.size.x = 512.0 * ui_scale
|
||||
%ui_main_menu.size.x = 512.0
|
||||
for i in [%scroll,%exit,%campaign_manager]:
|
||||
i.scale = Vector2(ui_scale,ui_scale)
|
||||
i.size.x = 448
|
||||
i.position.x = 32 * ui_scale
|
||||
|
||||
i.position.x = 32
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if pixel_x != get_viewport_rect().size[0] or pixel_y != get_viewport_rect().size[1]:
|
||||
pixel_x = get_viewport_rect().size[0]
|
||||
pixel_y = get_viewport_rect().size[1]
|
||||
if pixel_x + pixel_y > 3000:
|
||||
ui_scale = 1
|
||||
else:
|
||||
ui_scale = 1
|
||||
if get_viewport_rect().size[0] + get_viewport_rect().size[1] < 3000:
|
||||
ui_scale = 0.7
|
||||
pixel_x = get_viewport_rect().size[0] / ui_scale
|
||||
pixel_y = get_viewport_rect().size[1] / ui_scale
|
||||
if menu_item:
|
||||
menu_item.set_menu_items(pixel_x,pixel_y,ui_scale)
|
||||
menu_item.set_menu_items()
|
||||
set_menu_items()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,99 +0,0 @@
|
|||
extends Node2D
|
||||
|
||||
var menu_item
|
||||
var conf_mm
|
||||
var conf_cat
|
||||
var item_names = []
|
||||
var item_proper_names = []
|
||||
var categories
|
||||
var pixel_x
|
||||
var pixel_y
|
||||
var ui_scale = 1
|
||||
|
||||
func _enter_tree() -> void:
|
||||
conf_mm = ConfigFile.new()
|
||||
conf_mm.load("res://02 - Configurations/campaign/main_menu.ini")
|
||||
conf_cat = ConfigFile.new()
|
||||
conf_cat.load("res://02 - Configurations/campaign/categories.ini")
|
||||
print("main_menu:_enter_tree:1 " + str(conf_mm.get_sections()))
|
||||
categories = []
|
||||
pixel_x = get_viewport_rect().size[0]
|
||||
pixel_y = get_viewport_rect().size[1]
|
||||
if pixel_x + pixel_y > 2900:
|
||||
ui_scale = 1
|
||||
else:
|
||||
ui_scale = 0.7
|
||||
print("main_menu:_enter_tree:2 " + str(pixel_x) + " " + str(pixel_y))
|
||||
for i in conf_mm.get_sections():
|
||||
categories = categories + [i]
|
||||
|
||||
for i in categories:
|
||||
#print(i)
|
||||
var button = OptionButton.new()
|
||||
button.text = conf_mm.get_value(i,"name")
|
||||
button.name = i
|
||||
button.custom_minimum_size = Vector2(320,64)
|
||||
button.connect("item_selected",self.item_selected.bind(button))
|
||||
button.allow_reselect = true
|
||||
print("main_menu:_enter_tree:3 " + str(conf_mm.get_sections()))
|
||||
for j in conf_mm.get_value(button.name,"items",[]):
|
||||
item_names = item_names + [j]
|
||||
item_proper_names = item_proper_names + [conf_cat.get_value(j,"name","")]
|
||||
print("main_menu:_enter_tree:3 ")
|
||||
button.add_item(conf_cat.get_value(j,"name",""))
|
||||
%container.add_child(button)
|
||||
set_menu_items()
|
||||
|
||||
func item_selected(k,tab):
|
||||
print("main_menu:select_category:1 " + str(tab.get_item_text(k)))
|
||||
menu_item = load("res://01 - Menus/02 - Selector/selector.tscn").instantiate()
|
||||
print("main_menu:select_category:2 " + str(item_names))
|
||||
menu_item.category = item_names[item_proper_names.find(tab.get_item_text(k))]
|
||||
add_child(menu_item)
|
||||
remove_child.call_deferred(tab)
|
||||
|
||||
func remove_tabs(tab):
|
||||
remove_child.call_deferred(tab)
|
||||
|
||||
func _on_exit_button_up() -> void:
|
||||
get_tree().quit()
|
||||
|
||||
func set_menu_items():
|
||||
print("main_menu:set_menu_items:1 " + str(pixel_x) + " " + str(pixel_y))
|
||||
%scroll.size.y = pixel_y - (400 * ui_scale)
|
||||
%scroll.position.y = 128 * ui_scale
|
||||
%campaign_manager.position.y = pixel_y - 192 * ui_scale
|
||||
%exit.position.y = pixel_y - 96 * ui_scale
|
||||
%ui_main_menu.size.y = pixel_y
|
||||
%ui_background.size.y = pixel_y
|
||||
%ui_background.size.x = pixel_x
|
||||
if pixel_x < pixel_y: #mobile
|
||||
%ui_main_menu.size.x = pixel_x
|
||||
for i in [%scroll,%exit,%campaign_manager]:
|
||||
i.scale = Vector2(ui_scale,ui_scale)
|
||||
i.size.x = (pixel_x)/ui_scale -128
|
||||
i.position.x = 64
|
||||
else:
|
||||
%ui_main_menu.size.x = 512.0 * ui_scale
|
||||
for i in [%scroll,%exit,%campaign_manager]:
|
||||
i.scale = Vector2(ui_scale,ui_scale)
|
||||
i.size.x = 448
|
||||
i.position.x = 32 * ui_scale
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if pixel_x != get_viewport_rect().size[0] or pixel_y != get_viewport_rect().size[1]:
|
||||
pixel_x = get_viewport_rect().size[0]
|
||||
pixel_y = get_viewport_rect().size[1]
|
||||
if pixel_x + pixel_y > 3000:
|
||||
ui_scale = 1
|
||||
else:
|
||||
ui_scale = 0.7
|
||||
if menu_item:
|
||||
menu_item.set_menu_items(pixel_x,pixel_y,ui_scale)
|
||||
set_menu_items()
|
||||
|
||||
|
||||
func _on_campaign_manager_button_up() -> void:
|
||||
var cm = load("res://01 - Menus/05 - Campaign Manager/campaign_manager.tscn").instantiate()
|
||||
add_child(cm)
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://4isse2tc5gjs
|
||||
|
|
@ -27,10 +27,10 @@ text = "Exit"
|
|||
|
||||
[node name="campaign_manager" type="Button" parent="."]
|
||||
unique_name_in_owner = true
|
||||
offset_left = 96.0
|
||||
offset_top = 1184.0
|
||||
offset_right = 416.0
|
||||
offset_bottom = 1248.0
|
||||
offset_left = 88.0
|
||||
offset_top = 1176.0
|
||||
offset_right = 408.0
|
||||
offset_bottom = 1240.0
|
||||
text = "Campaign Manager"
|
||||
|
||||
[node name="scroll" type="ScrollContainer" parent="."]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue