56 lines
2.1 KiB
GDScript
56 lines
2.1 KiB
GDScript
extends Node
|
|
|
|
class Checker extends Control:
|
|
func _draw() -> void:
|
|
for y in range(0,int(size.y),12):
|
|
for x in range(0,int(size.x),12):
|
|
var tint := Color("25323e") if (x/12+y/12)%2 == 0 else Color("17222e")
|
|
draw_rect(Rect2(x,y,12,12),tint)
|
|
|
|
func _ready() -> void:
|
|
var layer := CanvasLayer.new()
|
|
add_child(layer)
|
|
var root := ColorRect.new()
|
|
root.color = Color("08111d")
|
|
root.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
layer.add_child(root)
|
|
var title := Label.new()
|
|
title.text = "UZBROJENIE · IKONY BEZ TŁA"
|
|
title.position = Vector2(38,20)
|
|
title.add_theme_font_size_override("font_size",24)
|
|
root.add_child(title)
|
|
var generator := preload("res://scripts/items/item_generator.gd")
|
|
var lab := preload("res://scripts/planets/laboratory.gd")
|
|
var definitions: Array = generator.DEFINITIONS.duplicate()
|
|
for id in lab.IDS:
|
|
if lab.definition(id) not in definitions: definitions.append(lab.definition(id))
|
|
var index := 0
|
|
for definition in definitions:
|
|
if definition.category != ItemDefinition.Category.WEAPON: continue
|
|
var tile := VBoxContainer.new()
|
|
tile.position = Vector2(38+(index%4)*304,72+(index/4)*206)
|
|
tile.size = Vector2(286,194)
|
|
root.add_child(tile)
|
|
var checker := Checker.new()
|
|
checker.custom_minimum_size = Vector2(286,164)
|
|
tile.add_child(checker)
|
|
var icon := TextureRect.new()
|
|
icon.texture = definition.icon
|
|
icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
|
icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
|
icon.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS
|
|
checker.add_child(icon)
|
|
icon.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
var label := Label.new()
|
|
label.text = definition.display_name
|
|
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
label.add_theme_font_size_override("font_size",14)
|
|
tile.add_child(label)
|
|
index += 1
|
|
for frame in 6: await get_tree().process_frame
|
|
await RenderingServer.frame_post_draw
|
|
assert(get_viewport().get_texture().get_image().save_png("res://artifacts/weapon_icons_transparent.png") == OK)
|
|
print("WEAPON_ICONS_PREVIEW: PASS")
|
|
get_tree().quit()
|