Initial Android commit

This commit is contained in:
OleSTEEP 2024-11-10 03:34:28 +03:00
commit 1e2b80c13d
8521 changed files with 231475 additions and 0 deletions

View file

@ -0,0 +1,60 @@
extends Control
signal value_changed(value);
var mouseInSlider;
var scaleX;
func setName(name):
$Label.text = tr(name)
func resize():
var size = SettingsSingleton.GetCurrectScreenResolutionVector2()
var font = $Label.get_font("font");
var fontSize = round(0.0708 * size.y - 6.3) / 1.2 / 1.5;
var outline = int(0.00555556 * size.y - 1) / 1.2 / 1.5;
font.size = fontSize;
font.outline_size = outline;
font.outline_color = Color(0, 0, 0)
$Label.add_font_override("font", font);
$ValueLabel.add_font_override("font", font);
var labelSize = font.get_string_size("Dialogue");
$Label.rect_size = Vector2(labelSize.x, labelSize.y);
$TextureProgress.rect_position = Vector2(labelSize.x * 1.1, labelSize.y * 0.3);
scaleX = 100 * size.x / 1000 / 500;
$TextureProgress.rect_scale = Vector2(scaleX, 1);
$ValueLabel.rect_position = Vector2($TextureProgress.rect_position.x + $TextureProgress.rect_size.x * scaleX, $ValueLabel.rect_position.y)
func setValue(value):
$TextureProgress.value = float(value);
$ValueLabel.text = str(value);
func _input(_event):
if mouseInSlider and Input.is_mouse_button_pressed(BUTTON_LEFT):
setSlider()
func setSlider():
var slider = $TextureProgress
slider.value = ratioInBody() * slider.max_value;
emit_signal("value_changed", slider.value);
$ValueLabel.text = str(slider.value);
func ratioInBody():
var slider = $TextureProgress
var posClicked = get_local_mouse_position() - slider.rect_position;
var ratio = posClicked.x / slider.rect_size.x * (1 / (scaleX * 0.8));
if ratio > 1.0:
ratio = 1.0
elif ratio < 0.0:
ratio = 0.0;
return ratio;
func _on_TextureProgress_mouse_entered():
mouseInSlider = true
func _on_TextureProgress_mouse_exited():
mouseInSlider = false