Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GW2 Styled Windows In Burrito #103

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 158 additions & 0 deletions GW2Menu.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
tool
extends Control

#export var button_0_icon: Texture = null setget button_0_icon_setget
#export var button_0_hover: Texture = null setget button_0_hover_setget
#export var button_0_text: String = "" setget button_0_text_setget
#export var button_1_icon: Texture = null setget button_1_icon_setget
export var selected_icon: int = 0 setget selected_icon_setget

func selected_icon_setget(new):
selected_icon = new
update_selected()

export(Array, Texture) var button_textures setget button_textures_setget
export(Array, Texture) var button_hover_textures setget button_hover_textures_setget
export(Array, String) var button_text setget button_text_setget

func button_textures_setget(new):
print("Button Textures Setget")
button_textures=new
icon_data_change()
func button_hover_textures_setget(new):
button_hover_textures = new
icon_data_change()
func button_text_setget(new):
button_text = new
icon_data_change()


const button_top_offset = 74
const button_sequential_offset = 44
const button_left_offset = 1
const button_width = 41
const button_height = 41


func _ready():
print("Ready")
icon_data_change()

func _process(delta):
if dragging:
var mouse_location = get_viewport().get_mouse_position()
self.rect_position = mouse_location - origin

################################################################################
# get_default
#
# A helper function to get a value from an array at an index that might not
# exist in the array. If the index does not exist then the default is returned
# instead.
################################################################################
func get_default(array: Array, index: int, default):
if (index < 0):
return default
if (index >= array.size()):
return default
return array[index]

################################################################################
# icon_data_change
#
# A function to re-render all of the left icon buttons based on which ones are
# present in the export variables. This recreates the entire button nodes.
################################################################################
func icon_data_change():
var buttons_elem: Control = $Buttons

# Exit early if buttons_elem is not initalized
if buttons_elem == null:
return
print("Setting Up Nodes")

for child in buttons_elem.get_children():
child.queue_free()

var max_size = [
button_textures.size(),
button_hover_textures.size(),
button_text.size()
].max()

# A blank texture to use as the default
var default_texture: Texture

for i in max_size:

var button_texture: Texture = get_default(button_textures, i, default_texture)
var button_hover_texture: Texture = get_default(button_hover_textures, i, default_texture)

var button := TextureButton.new()
# Make sure the button image is centered
button.expand = true
button.stretch_mode = TextureButton.STRETCH_KEEP_CENTERED

button.texture_normal = button_texture
button.texture_hover = button_hover_texture
button.rect_position = Vector2(button_left_offset, button_top_offset + button_sequential_offset*i)
button.rect_size = Vector2(button_width, button_height)

buttons_elem.add_child(
button
)

button.connect("pressed", self, "_menu_button_press", [i])

################################################################################
# _menu_button_press
#
# whenever one of the lefthand generated menu buttons is clicked by the user
# this function is called.
################################################################################
func _menu_button_press(index):
self.selected_icon = index


func update_selected():
var background_elem: TextureRect = $Background
var selection_elem: TextureRect = $Selection
var divider_elem: TextureRect = $Divider
var subtitle_elem: RichTextLabel = $SubTitle


# Exit early if at least one of the nodes is not initialized
if (
background_elem == null
|| selection_elem == null
|| divider_elem == null
|| subtitle_elem == null
):
return

background_elem.material.set_shader_param("selected_start", 0.074 + 0.0562 * selected_icon)
background_elem.material.set_shader_param("selected_end", 0.131 + 0.0562 * selected_icon)

divider_elem.material.set_shader_param("selected_start", 0.074 + 0.0562 * selected_icon)
divider_elem.material.set_shader_param("selected_end", 0.131 + 0.0562 * selected_icon)

selection_elem.rect_position.y = 44 + 44 * selected_icon

subtitle_elem.text = get_default(button_text, selected_icon, "")

################################################################################
# Dragging start/stop logic
# the actual movement logic of the window dragging is handled in _process
var dragging = false
var origin: Vector2 = Vector2(0, 0)
# Start Dragging
func _on_TitleBar_button_down():
dragging = true
origin = get_viewport().get_mouse_position() - self.rect_position
# Stop Dragging
func _on_TitleBar_button_up():
dragging = false

# Hide the window
func _on_CloseButton_pressed():
self.hide()
89 changes: 89 additions & 0 deletions gw2_theme.tres

Large diffs are not rendered by default.

198 changes: 198 additions & 0 deletions gw2_window.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
[gd_scene load_steps=20 format=2]

[ext_resource path="res://ui_elements/gw2_ui/button-exit.png" type="Texture" id=1]
[ext_resource path="res://ui_elements/gw2_ui/emblem.png" type="Texture" id=2]
[ext_resource path="res://ui_elements/gw2_ui/titlebar-inactive.png" type="Texture" id=3]
[ext_resource path="res://ui_elements/gw2_ui/window-topright-active.png" type="Texture" id=4]
[ext_resource path="res://ui_elements/gw2_ui/background.png" type="Texture" id=5]
[ext_resource path="res://ui_elements/gw2_ui/button-exit-active.png" type="Texture" id=6]
[ext_resource path="res://ui_elements/gw2_ui/bottom-right.png" type="Texture" id=7]
[ext_resource path="res://ui_elements/gw2_ui/menu_background.gdshader" type="Shader" id=8]
[ext_resource path="res://ui_elements/gw2_ui/divider.png" type="Texture" id=9]
[ext_resource path="res://ui_elements/gw2_ui/menomoni_title.tres" type="DynamicFont" id=10]
[ext_resource path="res://ui_elements/gw2_ui/title.png" type="Texture" id=12]
[ext_resource path="res://ui_elements/gw2_ui/157109.png" type="Texture" id=13]
[ext_resource path="res://GW2Menu.gd" type="Script" id=14]
[ext_resource path="res://ui_elements/gw2_ui/157110.png" type="Texture" id=15]
[ext_resource path="res://ui_elements/gw2_ui/titlebar-active.png" type="Texture" id=16]
[ext_resource path="res://ui_elements/gw2_ui/selection.png" type="Texture" id=18]

[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 8 )
shader_param/left_fade_end = 0.0
shader_param/left_fade_start = 0.071
shader_param/left_edge_end = 0.034
shader_param/left_edge_start = 0.071
shader_param/selected_start = 0.074
shader_param/selected_end = 0.131

[sub_resource type="Shader" id=3]
code = "// NOTE: Shader automatically converted from Godot Engine 3.4.4.stable's CanvasItemMaterial.
shader_type canvas_item;
render_mode blend_mix;

uniform float selected_start: hint_range(0.0, 1.0) = 0.074;
uniform float selected_end: hint_range(0.0, 1.0) = 0.131;

void fragment() {
vec4 color = texture(TEXTURE, UV);

if (UV.y > selected_start && UV.y < selected_end) {
color.a=0.0;
}


COLOR=color;
}
"

[sub_resource type="ShaderMaterial" id=4]
shader = SubResource( 3 )
shader_param/selected_start = 0.074
shader_param/selected_end = 0.131

[node name="Control" type="Control"]
margin_right = 40.0
margin_bottom = 40.0

[node name="GW2Menu" type="Control" parent="."]
margin_right = 1019.0
margin_bottom = 766.0
script = ExtResource( 14 )
__meta__ = {
"_edit_lock_": true
}
button_textures = [ ExtResource( 13 ), ExtResource( 13 ), ExtResource( 13 ), ExtResource( 13 ), ExtResource( 13 ), ExtResource( 13 ), ExtResource( 13 ), ExtResource( 13 ) ]
button_hover_textures = [ ExtResource( 15 ), ExtResource( 15 ), ExtResource( 15 ), ExtResource( 15 ), ExtResource( 15 ), ExtResource( 15 ), ExtResource( 15 ), ExtResource( 15 ) ]
button_text = [ "Open Markers", "Save Markers", "Show Hide Markers", "Edit Markers", "Range Indicators", "Settings", "Super Secret Settings", "Exit Burrito" ]

[node name="Background" type="TextureRect" parent="GW2Menu"]
material = SubResource( 2 )
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -38.0
margin_top = 14.0
margin_right = 78.0
margin_bottom = 30.0
texture = ExtResource( 5 )
expand = true
__meta__ = {
"_edit_lock_": true
}

[node name="TitleBar" type="TextureButton" parent="GW2Menu"]
margin_left = 0.122452
margin_top = -8.69907
margin_right = 1024.12
margin_bottom = 55.3009
texture_normal = ExtResource( 3 )
texture_hover = ExtResource( 16 )
__meta__ = {
"_edit_lock_": true
}

[node name="BottomRightCorner" type="TextureRect" parent="GW2Menu"]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -124.882
margin_top = -124.659
margin_right = 3.11816
margin_bottom = 3.34082
texture = ExtResource( 7 )
__meta__ = {
"_edit_lock_": true
}

[node name="TopRightTitlebar" type="TextureRect" parent="GW2Menu"]
anchor_left = 1.0
anchor_right = 1.0
margin_left = -107.23
margin_top = -7.73858
margin_right = 20.77
margin_bottom = 56.2614
mouse_filter = 2
texture = ExtResource( 4 )
__meta__ = {
"_edit_lock_": true
}

[node name="CloseButton" type="TextureButton" parent="GW2Menu"]
anchor_left = 1.0
anchor_right = 1.0
margin_left = -39.0
margin_top = 7.0
margin_right = -7.0
margin_bottom = 39.0
texture_normal = ExtResource( 1 )
texture_pressed = ExtResource( 6 )
texture_hover = ExtResource( 6 )
__meta__ = {
"_edit_lock_": true
}

[node name="Icon" type="TextureRect" parent="GW2Menu"]
margin_left = -26.7068
margin_top = -30.0703
margin_right = 101.293
margin_bottom = 97.9296
mouse_filter = 2
texture = ExtResource( 2 )
__meta__ = {
"_edit_lock_": true
}

[node name="SubTitle" type="RichTextLabel" parent="GW2Menu"]
margin_left = 180.722
margin_top = 13.133
margin_right = 331.722
margin_bottom = 38.133
mouse_filter = 2
custom_fonts/normal_font = ExtResource( 10 )
text = "Open Markers"
__meta__ = {
"_edit_lock_": true
}

[node name="Title" type="TextureRect" parent="GW2Menu"]
margin_left = 76.7665
margin_top = 12.7493
margin_right = 158.767
margin_bottom = 52.7493
mouse_filter = 2
texture = ExtResource( 12 )
__meta__ = {
"_edit_lock_": true
}

[node name="Divider" type="TextureRect" parent="GW2Menu"]
material = SubResource( 4 )
margin_left = 27.425
margin_top = 14.0
margin_right = 59.425
margin_bottom = 794.0
mouse_filter = 2
texture = ExtResource( 9 )
__meta__ = {
"_edit_lock_": true
}

[node name="Selection" type="TextureRect" parent="GW2Menu"]
margin_left = -58.0
margin_top = 44.0
margin_right = 43.0
margin_bottom = 144.0
texture = ExtResource( 18 )
__meta__ = {
"_edit_lock_": true
}

[node name="Buttons" type="Control" parent="GW2Menu"]
__meta__ = {
"_edit_lock_": true
}

[connection signal="button_down" from="GW2Menu/TitleBar" to="GW2Menu" method="_on_TitleBar_button_down"]
[connection signal="button_up" from="GW2Menu/TitleBar" to="GW2Menu" method="_on_TitleBar_button_up"]
[connection signal="pressed" from="GW2Menu/CloseButton" to="GW2Menu" method="_on_CloseButton_pressed"]
Binary file added ui_elements/gw2_ui/157109.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions ui_elements/gw2_ui/157109.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/157109.png-9c2abf0387e3e562211734299b78c2ff.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://ui_elements/gw2_ui/157109.png"
dest_files=[ "res://.import/157109.png-9c2abf0387e3e562211734299b78c2ff.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Binary file added ui_elements/gw2_ui/157110.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading