Initial Android commit
This commit is contained in:
commit
1e2b80c13d
8521 changed files with 231475 additions and 0 deletions
137
scripts/AlternativeChoices/AlternativeChoiceBase.gd
Normal file
137
scripts/AlternativeChoices/AlternativeChoiceBase.gd
Normal file
|
@ -0,0 +1,137 @@
|
|||
extends Node2D
|
||||
|
||||
enum CursorState{Normal, Walk, Talk, Press, Crash};
|
||||
|
||||
onready var root;
|
||||
|
||||
signal endOfChoice;
|
||||
|
||||
var localization = [];
|
||||
var cursorStates = [];
|
||||
|
||||
var isHovering;
|
||||
|
||||
var setLabelsPosition:bool = true;
|
||||
|
||||
onready var arrowCursor = preload("res://resources/cursors/arrow2.webp");
|
||||
onready var dialogCursor = preload("res://resources/cursors/dialog2.webp");
|
||||
onready var zoomCursor = preload("res://resources/cursors/magnifier2.webp");
|
||||
onready var walkCursor = preload("res://resources/cursors/man2.webp");
|
||||
|
||||
onready var crashCursor = preload("res://resources/cursors/crash_cursor.webp");
|
||||
|
||||
func _ready():
|
||||
root = get_tree().root.get_node("Root");
|
||||
|
||||
SetCursorStates();
|
||||
Localization();
|
||||
SetLabels();
|
||||
SetHover();
|
||||
CheckForVariables();
|
||||
|
||||
func Localization():
|
||||
pass
|
||||
|
||||
func SetCursorStates():
|
||||
pass
|
||||
|
||||
func SetLabels():
|
||||
var buttons = $SpriteButtons.get_children();
|
||||
var labels = $Labels.get_children();
|
||||
|
||||
for i in labels.size():
|
||||
var label = labels[i];
|
||||
label.text = tr(localization[i]).trim_suffix(".");
|
||||
|
||||
if setLabelsPosition:
|
||||
label.connect("resized", self, "labelResized", [label, buttons[i]]);
|
||||
|
||||
func labelResized(label, button):
|
||||
var center = button.rect_position + button.rect_size * button.rect_scale / 2.0;
|
||||
label.rect_position = center - label.rect_size / 2.0;
|
||||
AdjustLabels();
|
||||
|
||||
func AdjustLabels():
|
||||
pass
|
||||
|
||||
func SetHover():
|
||||
var buttons = $SpriteButtons.get_children();
|
||||
var labels = $Labels.get_children();
|
||||
|
||||
PreventCursorCrash();
|
||||
|
||||
for i in buttons.size():
|
||||
var button = buttons[i];
|
||||
button.connect("mouse_entered", self, "onButtonHoverOn_sprite", [button, labels[i], cursorStates[i]]);
|
||||
button.connect("mouse_exited", self, "onButtonHoverOff_sprite", [button, labels[i]]);
|
||||
|
||||
|
||||
func PreventCursorCrash():
|
||||
for i in 5:
|
||||
cursorStates.push_back(CursorState.Crash)
|
||||
|
||||
func onButtonHoverOn_sprite(button, label, cursorState):
|
||||
if not (root.isMenuVisible or root.isSaveLoadVisible):
|
||||
UpdateCursor(cursorState);
|
||||
button.material.set_shader_param("mixing", 0.15);
|
||||
label.visible = true;
|
||||
isHovering = true;
|
||||
|
||||
func onButtonHoverOff_sprite(button, label):
|
||||
if not (root.isMenuVisible or root.isSaveLoadVisible):
|
||||
UpdateCursor(CursorState.Normal);
|
||||
button.material.set_shader_param("mixing", 0.0);
|
||||
label.visible = false;
|
||||
isHovering = false;
|
||||
|
||||
func UpdateCursor(state:int):
|
||||
match state:
|
||||
CursorState.Normal:
|
||||
Input.set_custom_mouse_cursor(arrowCursor)
|
||||
CursorState.Talk:
|
||||
Input.set_custom_mouse_cursor(dialogCursor, Input.CURSOR_ARROW, Vector2(19, 19))
|
||||
CursorState.Walk:
|
||||
Input.set_custom_mouse_cursor(walkCursor, Input.CURSOR_ARROW, Vector2(19, 19))
|
||||
CursorState.Press:
|
||||
Input.set_custom_mouse_cursor(zoomCursor, Input.CURSOR_ARROW, Vector2(19, 19))
|
||||
CursorState.Crash:
|
||||
Input.set_custom_mouse_cursor(crashCursor, Input.CURSOR_ARROW, Vector2(19, 19))
|
||||
|
||||
func CheckForVariables():
|
||||
pass;
|
||||
|
||||
func End():
|
||||
UpdateCursor(CursorState.Normal);
|
||||
emit_signal("endOfChoice");
|
||||
|
||||
func CheckHover()->bool:
|
||||
return not (get_tree().root.get_node("Root").isMenuVisible or get_tree().root.get_node("Root").isSaveLoadVisible)
|
||||
|
||||
var shaderValue = 0.0;
|
||||
var tempDelta = 0.0;
|
||||
var isRising;
|
||||
|
||||
func _process(delta):
|
||||
if isHovering:
|
||||
return ;
|
||||
|
||||
tempDelta += delta;
|
||||
if tempDelta > 0.2:
|
||||
tempDelta = 0;
|
||||
|
||||
if shaderValue <= - 0.05:
|
||||
isRising = true
|
||||
|
||||
if shaderValue >= 0.13:
|
||||
isRising = false;
|
||||
|
||||
if isRising:
|
||||
shaderValue += 0.01;
|
||||
else :
|
||||
shaderValue -= 0.01;
|
||||
|
||||
var buttons = $SpriteButtons.get_children();
|
||||
for i in buttons:
|
||||
i.material.set_shader_param("mixing", shaderValue);
|
||||
else :
|
||||
tempDelta += delta;
|
Loading…
Add table
Add a link
Reference in a new issue