Fix list object

This commit is contained in:
VAILLANT Jeremy
2021-05-15 20:40:16 +02:00
parent 890931faa8
commit 367ee388da
6 changed files with 72 additions and 12 deletions
Binary file not shown.
+11
View File
@@ -3,6 +3,7 @@ extends "res://db/MBase.gd"
var m_value = { "id": null, "value": null } var m_value = { "id": null, "value": null }
var m_lock = { "id": null, "value": null } var m_lock = { "id": null, "value": null }
var m_label = null var m_label = null
var m_label_id = null
var m_tick_reference = { "id": null, "value": null } var m_tick_reference = { "id": null, "value": null }
var m_key = null var m_key = null
var m_level = null var m_level = null
@@ -17,6 +18,7 @@ func _init(row_index):
m_value["value"] = _get_value(datas) m_value["value"] = _get_value(datas)
m_lock["value"] = _get_lock(datas) m_lock["value"] = _get_lock(datas)
m_label = _get_label(datas) m_label = _get_label(datas)
m_label_id = _get_label_id(datas)
m_tick_reference["value"] = _get_tick_reference(datas) m_tick_reference["value"] = _get_tick_reference(datas)
m_mesh = _get_mesh(datas) m_mesh = _get_mesh(datas)
@@ -35,6 +37,12 @@ func search_keys():
func key(): func key():
return m_key return m_key
func label():
return m_label
func label_id():
return m_label_id
func lock(): func lock():
return m_lock["value"] return m_lock["value"]
@@ -74,6 +82,9 @@ func _get_lock_id(index):
func _get_label(datas): func _get_label(datas):
return _get_data(datas, 2) as String return _get_data(datas, 2) as String
func _get_label_id(datas):
return _get_data(datas, 7) as String
func _get_tick_reference(datas): func _get_tick_reference(datas):
return _get_data(datas, 3) as int return _get_data(datas, 3) as int
+14 -10
View File
@@ -12,22 +12,27 @@
[node name="Control" type="MarginContainer"] [node name="Control" type="MarginContainer"]
anchor_left = 1.0 anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 0.5 anchor_bottom = 1.0
margin_left = -196.0
grow_horizontal = 0 grow_horizontal = 0
grow_vertical = 2 grow_vertical = 2
size_flags_vertical = 4 rect_min_size = Vector2( 196, 900 )
size_flags_vertical = 3
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="ListContainer" type="VBoxContainer" parent="."] [node name="ListContainer" type="VBoxContainer" parent="."]
margin_right = 196.0 margin_right = 196.0
margin_bottom = 341.0 margin_bottom = 900.0
rect_min_size = Vector2( 196, 900 )
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = -10 custom_constants/separation = -10
[node name="TextureButtonFirst" type="TextureButton" parent="ListContainer"] [node name="TextureButtonFirst" type="TextureButton" parent="ListContainer"]
visible = false
margin_right = 196.0 margin_right = 196.0
margin_bottom = 81.0 margin_bottom = 81.0
texture_normal = ExtResource( 2 ) texture_normal = ExtResource( 2 )
@@ -46,9 +51,9 @@ __meta__ = {
} }
[node name="TextureButtonMiddle" type="TextureButton" parent="ListContainer"] [node name="TextureButtonMiddle" type="TextureButton" parent="ListContainer"]
margin_top = 71.0 visible = false
margin_right = 196.0 margin_right = 196.0
margin_bottom = 152.0 margin_bottom = 81.0
texture_normal = ExtResource( 4 ) texture_normal = ExtResource( 4 )
texture_hover = ExtResource( 7 ) texture_hover = ExtResource( 7 )
texture_focused = ExtResource( 7 ) texture_focused = ExtResource( 7 )
@@ -65,9 +70,9 @@ __meta__ = {
} }
[node name="TextureButtonLast" type="TextureButton" parent="ListContainer"] [node name="TextureButtonLast" type="TextureButton" parent="ListContainer"]
margin_top = 142.0 visible = false
margin_right = 196.0 margin_right = 196.0
margin_bottom = 223.0 margin_bottom = 81.0
texture_normal = ExtResource( 3 ) texture_normal = ExtResource( 3 )
texture_hover = ExtResource( 9 ) texture_hover = ExtResource( 9 )
texture_focused = ExtResource( 9 ) texture_focused = ExtResource( 9 )
@@ -85,9 +90,8 @@ __meta__ = {
} }
[node name="HBoxContainer" type="HBoxContainer" parent="ListContainer"] [node name="HBoxContainer" type="HBoxContainer" parent="ListContainer"]
margin_top = 213.0
margin_right = 196.0 margin_right = 196.0
margin_bottom = 341.0 margin_bottom = 128.0
alignment = 1 alignment = 1
[node name="TextureButtonIndice" type="TextureButton" parent="ListContainer/HBoxContainer"] [node name="TextureButtonIndice" type="TextureButton" parent="ListContainer/HBoxContainer"]
+6 -1
View File
@@ -119,10 +119,15 @@ func _load_meshes():
if scene_detail.key() != null: if scene_detail.key() != null:
meshes[scene_detail.key()] = scene_detail meshes[scene_detail.key()] = scene_detail
# _display_label(scene_detail)
for key in meshes: for key in meshes:
meshes[key].search_keys() meshes[key].search_keys()
"""
func _display_label(scene):
print("[meshes#key] : "+scene.label())
$ListObjects/ListContainer/TextureButton.set_text(scene.label())
"""
func _input(event): func _input(event):
if event is InputEventMouseButton or event is InputEventScreenTouch: if event is InputEventMouseButton or event is InputEventScreenTouch:
var camera = $"Main Camera" var camera = $"Main Camera"
+39
View File
@@ -1,6 +1,45 @@
extends "res://scenes/levels/levels.gd" extends "res://scenes/levels/levels.gd"
export (PackedScene) var object_first = load("res://scenes/UI/list_ho/ObjectListFirst.tscn")
export (PackedScene) var object_std = load("res://scenes/UI/list_ho/ObjectListStd.tscn")
export (PackedScene) var object_last = load("res://scenes/UI/list_ho/ObjectListLast.tscn")
onready var label_id = null
onready var last_btn = null
func _ready():
print(meshes)
var counter = 0
var scene = null
for key in meshes:
scene = meshes[key]
_create_button_info(scene, counter)
label_id = scene.label_id()
counter = +1
# Back to main scene # Back to main scene
func _on_TextureButton_pressed(): func _on_TextureButton_pressed():
print("[levels#_on_TextureButton_pressed] quit to menu") print("[levels#_on_TextureButton_pressed] quit to menu")
Global.goto_scene("res://scenes/main.tscn") Global.goto_scene("res://scenes/main.tscn")
func _create_button_info(scene, counter):
var btn = null
if counter == 0:
print("[warCraft#_create_button_info] ["+String(counter)+"] use first")
btn = object_first.instance()
elif counter == meshes.size() - 1:
btn = object_last.instance()
print("[warCraft#_create_button_info] ["+String(counter)+"] use last")
else:
btn = object_std.instance()
print("[warCraft#_create_button_info] ["+String(counter)+"] use standar")
if label_id != null and label_id == scene.label_id():
# $ListObjects/ListContainer.add_child(btn)
last_btn.get_node("Label").set_text(last_btn.get_node("Label").text + " X")
else:
$ListObjects/ListContainer.add_child(btn)
btn.get_node("Label").set_text(scene.label())
last_btn = btn
+2 -1
View File
@@ -270,7 +270,7 @@ cell_center_y = false
cell_center_z = false cell_center_z = false
baked_meshes = [ SubResource( 4 ) ] baked_meshes = [ SubResource( 4 ) ]
data = { data = {
"cells": PoolIntArray( 0, 0, 3, 65531, 0, 3, 65532, 0, 3, 65533, 0, 3, 65534, 0, 3, 65535, 0, 3, 0, 1, 3, 65531, 1, 3, 65532, 1, 3, 65533, 1, 3, 65534, 1, 3, 65535, 1, 3, 0, 2, 3, 65531, 2, 3, 65532, 2, 3, 65533, 2, 3, 65534, 2, 3, 65535, 2, 3, 0, 65533, 3, 65532, 65533, 3, 65533, 65533, 3, 65534, 65533, 3, 65535, 65533, 3, 0, 65534, 3, 65531, 65534, 3, 65532, 65534, 3, 65533, 65534, 3, 65534, 65534, 3, 65535, 65534, 3, 0, 65535, 3, 65531, 65535, 3, 65532, 65535, 3, 65533, 65535, 3, 65534, 65535, 3, 65535, 65535, 3 ) "cells": PoolIntArray( 0, 0, 3, 65531, 0, 3, 65532, 0, 3, 65533, 0, 536870915, 65534, 0, 3, 65535, 0, 3, 0, 1, 3, 65531, 1, 3, 65532, 1, 3, 65533, 1, 3, 65534, 1, 3, 65535, 1, 3, 0, 2, 3, 65531, 2, 3, 65532, 2, 3, 65533, 2, 3, 65534, 2, 3, 65535, 2, 3, 0, 65533, 3, 65532, 65533, 3, 65533, 65533, 3, 65534, 65533, 3, 65535, 65533, 3, 0, 65534, 3, 65531, 65534, 3, 65532, 65534, 3, 65533, 65534, 3, 65534, 65534, 3, 65535, 65534, 3, 0, 65535, 3, 65531, 65535, 3, 65532, 65535, -1610612733, 65533, 65535, -1610612733, 65534, 65535, 536870915, 65535, 65535, 3 )
} }
__meta__ = { __meta__ = {
"_editor_clip_": 0, "_editor_clip_": 0,
@@ -743,4 +743,5 @@ shape = SubResource( 18 )
[connection signal="pressed" from="Quit/TextureButton" to="." method="_on_TextureButton_pressed"] [connection signal="pressed" from="Quit/TextureButton" to="." method="_on_TextureButton_pressed"]
[editable path="ListObjects"]
[editable path="Quit"] [editable path="Quit"]