Initial Android commit
This commit is contained in:
commit
1e2b80c13d
8521 changed files with 231475 additions and 0 deletions
24
scripts/CustomControls/BirdsWrapper.gd
Normal file
24
scripts/CustomControls/BirdsWrapper.gd
Normal file
|
@ -0,0 +1,24 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
onready var timer = $Timer;
|
||||
onready var player = $AnimationPlayer;
|
||||
onready var birdAnimation = $BirdsAnimation / BirdsAnimation;
|
||||
onready var animationContainer = $BirdsAnimation;
|
||||
|
||||
func Init():
|
||||
player.play("BirdsAnimation");
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(_anim_name):
|
||||
animationContainer.position.x = - 135;
|
||||
birdAnimation.frame = 0;
|
||||
timer.start(55);
|
||||
|
||||
func _on_Timer_timeout():
|
||||
player.play("BirdsAnimation");
|
117
scripts/CustomControls/Cat.gd
Normal file
117
scripts/CustomControls/Cat.gd
Normal file
|
@ -0,0 +1,117 @@
|
|||
extends Node2D
|
||||
|
||||
var catState;
|
||||
var stopCatTime = 0;
|
||||
|
||||
onready var dialogNode;
|
||||
onready var anglyCatSound = load("res://resources/audio/sfx/cat_tail_angry.ogg");
|
||||
onready var meowCatSound = load("res://resources/audio/sfx/cat_meows.ogg");
|
||||
|
||||
var meows = [[0.0, 1.53], [2.47, 3.72], [4.75, 6.39], [8.07, 9.75], [11.82, 13.12], [14.31, 16.13],
|
||||
[18.87, 20.3], [21.99, 23.45], [25.09, 26.7], [27.15, 29.27], [30.6, 31.93]];
|
||||
|
||||
func Init(zIndex:int, state:int):
|
||||
z_index = zIndex;
|
||||
catState = state;
|
||||
|
||||
match state:
|
||||
1:
|
||||
$catTexture.texture = load("res://resources/graphics/backgrounds/cat/1_1.webp");
|
||||
$pawTexture.texture = load("res://resources/graphics/backgrounds/cat/1_2.webp");
|
||||
$pawTexture.visible = true;
|
||||
|
||||
$Tail.rect_position = Vector2(220, 40);
|
||||
$Tail.rect_size = Vector2(80, 80);
|
||||
2:
|
||||
$catTexture.texture = load("res://resources/graphics/backgrounds/cat/2.webp");
|
||||
|
||||
$Tail.rect_position = Vector2(80, 40);
|
||||
$Tail.rect_size = Vector2(100, 80);
|
||||
3:
|
||||
$catTexture.texture = load("res://resources/graphics/backgrounds/cat/3.webp");
|
||||
|
||||
$Tail.rect_position = Vector2(100, 200);
|
||||
$Tail.rect_size = Vector2(140, 150);
|
||||
4:
|
||||
$catTexture.texture = load("res://resources/graphics/backgrounds/cat/4.webp");
|
||||
|
||||
$Tail.rect_position = Vector2(280, 20);
|
||||
$Tail.rect_size = Vector2(120, 180);
|
||||
10:
|
||||
catState = 4;
|
||||
$catTexture.texture = load("res://resources/graphics/backgrounds/cat/10.webp");
|
||||
|
||||
$Tail.rect_position = Vector2(280, 20);
|
||||
$Tail.rect_size = Vector2(120, 180);
|
||||
|
||||
5:
|
||||
$catTexture.texture = load("res://resources/graphics/backgrounds/cat/5.webp");
|
||||
|
||||
$Tail.rect_position = Vector2(100, 200);
|
||||
$Tail.rect_size = Vector2(150, 140);
|
||||
6:
|
||||
$catTexture.texture = load("res://resources/graphics/backgrounds/cat/6.webp");
|
||||
|
||||
$Tail.rect_position = Vector2(220, 140);
|
||||
$Tail.rect_size = Vector2(150, 140);
|
||||
7:
|
||||
$catTexture.texture = load("res://resources/graphics/backgrounds/cat/7.webp");
|
||||
|
||||
$Tail.rect_position = Vector2(0, 60);
|
||||
$Tail.rect_size = Vector2(150, 50);
|
||||
8:
|
||||
$catTexture.texture = load("res://resources/graphics/backgrounds/cat/8.webp");
|
||||
|
||||
$Tail.rect_position = Vector2(10, 60);
|
||||
$Tail.rect_size = Vector2(100, 60);
|
||||
9:
|
||||
$catTexture.texture = load("res://resources/graphics/backgrounds/cat/9.webp");
|
||||
|
||||
$Tail.rect_position = Vector2(10, 300);
|
||||
$Tail.rect_size = Vector2(200, 160);
|
||||
|
||||
dialogNode = get_tree().root.get_node("Root/Game").get_child(0).get_node("DialogNode");
|
||||
|
||||
func _on_catTexture_resized():
|
||||
$Body.rect_size = $catTexture.rect_size;
|
||||
|
||||
func Scale(scaleValue:float):
|
||||
yield (get_tree().create_timer(0.1), "timeout");
|
||||
scale = Vector2(scaleValue, scaleValue);
|
||||
|
||||
func _on_Cat_mouse_entered():
|
||||
if get_tree().root.get_node("Root/Game").get_child_count() != 0:
|
||||
dialogNode.catOnHover = true;
|
||||
|
||||
func _on_Cat_mouse_exited():
|
||||
if get_tree().root.get_node("Root/Game").get_child_count() != 0:
|
||||
dialogNode.catOnHover = false;
|
||||
|
||||
func _on_Body_pressed():
|
||||
CatPressed();
|
||||
|
||||
$CatStreamPlayer.stream = meowCatSound;
|
||||
var meowTime = meows[rand_range(0, meows.size() - 1)];
|
||||
stopCatTime = meowTime[1];
|
||||
$CatStreamPlayer.play(meowTime[0]);
|
||||
|
||||
func _on_Tail_pressed():
|
||||
CatPressed();
|
||||
|
||||
$CatStreamPlayer.stream = anglyCatSound;
|
||||
stopCatTime = 1.28;
|
||||
$CatStreamPlayer.play();
|
||||
|
||||
func CatPressed():
|
||||
var number = ProgressAchievementsSingleton.AddCat(catState);
|
||||
|
||||
# if number != - 1:
|
||||
# if number == 9:
|
||||
# Steam.set_achievement("Cat_Progress")
|
||||
# else :
|
||||
# var _res = Steam.user_stats.indicate_achievement_progress("Cat_Progress", number, 9)
|
||||
var _res = false;
|
||||
|
||||
func _process(_delta):
|
||||
if ($CatStreamPlayer.playing and $CatStreamPlayer.get_playback_position() >= stopCatTime):
|
||||
$CatStreamPlayer.stop()
|
32
scripts/CustomControls/ChangeKarma/ChangeKarma.gd
Normal file
32
scripts/CustomControls/ChangeKarma/ChangeKarma.gd
Normal file
|
@ -0,0 +1,32 @@
|
|||
extends HBoxContainer
|
||||
|
||||
signal Deleted;
|
||||
|
||||
var defaultFont = null;
|
||||
|
||||
func SetName(charName:String, color:String):
|
||||
if charName == tr("ui_name_black"):
|
||||
var font = $Name.get("custom_fonts/normal_font").duplicate();
|
||||
font.outline_color = Color(1, 1, 1, 1);
|
||||
font.outline_size = 1;
|
||||
$Name.set("custom_fonts/normal_font", font);
|
||||
|
||||
defaultFont = $Attitude.get("custom_fonts/normal_font");
|
||||
|
||||
$Name.bbcode_text = str("[color=", color, "] ", charName, "[/color]");
|
||||
$Name.rect_min_size = Vector2(Resize(str(" ", charName)), 50);
|
||||
|
||||
func SetAttitude(attribute:String):
|
||||
$Attitude.bbcode_text = attribute;
|
||||
$Attitude.rect_min_size = Vector2(Resize(attribute), 50);
|
||||
|
||||
func Resize(temp:String)->float:
|
||||
return defaultFont.get_string_size(temp).x;
|
||||
|
||||
func StartAppearing():
|
||||
self_modulate = Color(1, 1, 1, 1);
|
||||
$AnimationPlayer.play("ChangeKarmaAnimation");
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(_anim_name):
|
||||
emit_signal("Deleted");
|
||||
queue_free();
|
68
scripts/CustomControls/ChangeKarma/ChangeKarmaContainer.gd
Normal file
68
scripts/CustomControls/ChangeKarma/ChangeKarmaContainer.gd
Normal file
|
@ -0,0 +1,68 @@
|
|||
extends Control
|
||||
|
||||
onready var textScene = preload("res://resources/customControls/ChangeKarma/ChangeKarma.tscn");
|
||||
|
||||
var linesAmount:int = 0;
|
||||
|
||||
func AddText(event, charStructure):
|
||||
var locale = TranslationServer.get_locale();
|
||||
|
||||
var charName = tr(charStructure["charName"]);
|
||||
var color = charStructure["color"];
|
||||
|
||||
var sex:bool = charStructure["sex"];
|
||||
|
||||
var changedKarmaText = "";
|
||||
match locale:
|
||||
"en":
|
||||
if sex:
|
||||
changedKarmaText = "changes his attitude";
|
||||
else :
|
||||
changedKarmaText = "changes her attitude";
|
||||
"ja":
|
||||
|
||||
|
||||
|
||||
changedKarmaText = "が関係を";
|
||||
_:
|
||||
changedKarmaText = tr("ui_karma_changes_attitude");
|
||||
|
||||
var value = str(event["operation"], event["set_value"]);
|
||||
|
||||
if event["operation"] == "=":
|
||||
match locale:
|
||||
"en":
|
||||
value = str("to ", event["set_value"])
|
||||
"ru":
|
||||
value = str("на ", event["set_value"]);
|
||||
"uk":
|
||||
value = str("до ", event["set_value"]);
|
||||
"ja":
|
||||
value = str(event["set_value"]);
|
||||
_:
|
||||
pass;
|
||||
|
||||
var attribute:String = "";
|
||||
match locale:
|
||||
"ja":
|
||||
|
||||
attribute = str(" ", changedKarmaText, value, "変えます。");
|
||||
_:
|
||||
attribute = str(" ", changedKarmaText, " ", value);
|
||||
|
||||
var inst = textScene.instance();
|
||||
inst.SetName(charName, color);
|
||||
inst.SetAttitude(attribute);
|
||||
add_child(inst);
|
||||
linesAmount += 1;
|
||||
inst.StartAppearing();
|
||||
var _t = inst.connect("Deleted", self, "LineDeleted", [inst]);
|
||||
|
||||
func LineDeleted(line):
|
||||
Resize();
|
||||
line.disconnect("Deleted", self, "LineDeleted");
|
||||
|
||||
|
||||
func Resize():
|
||||
linesAmount -= 1;
|
||||
rect_size = Vector2(600, linesAmount * 50);
|
18
scripts/CustomControls/DialogicVarControl.gd
Normal file
18
scripts/CustomControls/DialogicVarControl.gd
Normal file
|
@ -0,0 +1,18 @@
|
|||
extends Control
|
||||
|
||||
func Place(index:int):
|
||||
rect_position = Vector2(0, index * 42)
|
||||
rect_size = Vector2(750, 40)
|
||||
$Label.rect_size = Vector2(200, 40)
|
||||
$Label.rect_position = Vector2(0, 0);
|
||||
$TextEdit.rect_size = Vector2(200, 40)
|
||||
$TextEdit.rect_position = Vector2(450, 0);
|
||||
|
||||
func Init(variableName:String):
|
||||
$Label.text = variableName;
|
||||
$TextEdit.text = Dialogic.get_variable(variableName);
|
||||
|
||||
func SaveVariable():
|
||||
var varName = $Label.text;
|
||||
var varValue = $TextEdit.text;
|
||||
Dialogic.set_variable(varName, varValue);
|
|
@ -0,0 +1,53 @@
|
|||
extends Button
|
||||
|
||||
onready var ExplanationControl = preload("res://resources/customControls/DifficultySelector/Explanation.tscn");
|
||||
onready var NormalBackground = preload("res://resources/graphics/GUI/Menu/Difficulties/normal_background.webp");
|
||||
onready var HardBackground = preload("res://resources/graphics/GUI/Menu/Difficulties/hard_background.webp");
|
||||
|
||||
|
||||
|
||||
func Init(type:String):
|
||||
if type == "Normal":
|
||||
InitNormal();
|
||||
elif type == "Hard":
|
||||
InitHard();
|
||||
|
||||
var normalExplanations = [
|
||||
"ui_difficulty_normal_explanation_1",
|
||||
"ui_difficulty_normal_explanation_2",
|
||||
"ui_difficulty_normal_explanation_3",
|
||||
"ui_difficulty_normal_explanation_4",
|
||||
];
|
||||
|
||||
func InitNormal():
|
||||
$Background.texture = NormalBackground;
|
||||
$Header.text = tr("ui_difficulty_normal_header");
|
||||
$Title.text = tr("ui_difficulty_normal_title");
|
||||
for i in normalExplanations:
|
||||
var control = ExplanationControl.instance();
|
||||
control.Init(i);
|
||||
$Explanations.add_child(control);
|
||||
|
||||
|
||||
var hardExplanations = [
|
||||
"ui_difficulty_hard_explanation_1",
|
||||
"ui_difficulty_hard_explanation_2",
|
||||
"ui_difficulty_hard_explanation_3",
|
||||
"ui_difficulty_hard_explanation_4",
|
||||
];
|
||||
|
||||
func InitHard():
|
||||
$Background.texture = HardBackground;
|
||||
$Header.text = tr("ui_difficulty_hard_header");
|
||||
$Title.text = tr("ui_difficulty_hard_title");
|
||||
for i in hardExplanations:
|
||||
var control = ExplanationControl.instance();
|
||||
control.Init(i);
|
||||
$Explanations.add_child(control);
|
||||
|
||||
|
||||
func _on_Control_mouse_entered():
|
||||
$Background.modulate.a = 0.85;
|
||||
|
||||
func _on_Control_mouse_exited():
|
||||
$Background.modulate.a = 1;
|
4
scripts/CustomControls/DifficultySelector/Explanation.gd
Normal file
4
scripts/CustomControls/DifficultySelector/Explanation.gd
Normal file
|
@ -0,0 +1,4 @@
|
|||
extends HBoxContainer
|
||||
|
||||
func Init(text:String):
|
||||
$Label.text = tr(text);
|
74
scripts/CustomControls/GalleryBackground.gd
Normal file
74
scripts/CustomControls/GalleryBackground.gd
Normal file
|
@ -0,0 +1,74 @@
|
|||
extends Control
|
||||
|
||||
signal galleryPressed;
|
||||
|
||||
var unlocked;
|
||||
var sceneName;
|
||||
var path;
|
||||
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
func Init(content, type):
|
||||
sceneName = content["name"]
|
||||
|
||||
if content.has("multi"):
|
||||
var multi = content["multi"];
|
||||
|
||||
for i in multi:
|
||||
if GallerySingleton.HaveImage(i):
|
||||
unlocked = true;
|
||||
$TextureRect.texture = load(str("res://resources/graphics/Gallery/Images/", i, ".webp"));
|
||||
$TextureRect.material = $TextureRect.material.duplicate()
|
||||
return ;
|
||||
|
||||
unlocked = false;
|
||||
$TextureRect.texture = load("res://resources/graphics/Gallery/locked.webp")
|
||||
return ;
|
||||
|
||||
if content.has("multiB"):
|
||||
var multi = content["multiB"];
|
||||
|
||||
for i in multi:
|
||||
if GallerySingleton.HaveBackground(i):
|
||||
unlocked = true;
|
||||
$TextureRect.texture = load(str("res://resources/graphics/Gallery/Backgrounds/", i, ".webp"));
|
||||
$TextureRect.material = $TextureRect.material.duplicate()
|
||||
return ;
|
||||
|
||||
unlocked = false;
|
||||
$TextureRect.texture = load("res://resources/graphics/Gallery/locked.webp")
|
||||
return
|
||||
|
||||
if type == "background":
|
||||
unlocked = GallerySingleton.HaveBackground(sceneName);
|
||||
else :
|
||||
unlocked = GallerySingleton.HaveImage(sceneName);
|
||||
|
||||
if unlocked:
|
||||
path = content["path"];
|
||||
$TextureRect.texture = load(path);
|
||||
$TextureRect.material = $TextureRect.material.duplicate()
|
||||
else :
|
||||
$TextureRect.texture = load("res://resources/graphics/Gallery/locked.webp")
|
||||
|
||||
func setShaderOn():
|
||||
if unlocked:
|
||||
$TextureRect.material.set_shader_param("mixing", 0.15);
|
||||
|
||||
func setShaderOff():
|
||||
if unlocked:
|
||||
$TextureRect.material.set_shader_param("mixing", 0.0);
|
||||
|
||||
func _on_ResizeTimer_timeout():
|
||||
var scale = 288.0 / $TextureRect.rect_size.x * 1.0;
|
||||
$TextureRect.rect_scale = Vector2(scale, scale);
|
||||
|
||||
func _on_Control_gui_input(event):
|
||||
if not unlocked:
|
||||
return ;
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == BUTTON_LEFT and event.pressed:
|
||||
emit_signal("galleryPressed")
|
39
scripts/CustomControls/GalleryMusicPlayer.gd
Normal file
39
scripts/CustomControls/GalleryMusicPlayer.gd
Normal file
|
@ -0,0 +1,39 @@
|
|||
extends Control
|
||||
|
||||
onready var playIcon = preload("res://resources/graphics/GUI/Gallery/Play.webp")
|
||||
onready var stopIcon = preload("res://resources/graphics/GUI/Gallery/Stop.webp")
|
||||
|
||||
var musicPath;
|
||||
var unlocked;
|
||||
var state = false;
|
||||
signal PlayerStarted;
|
||||
|
||||
func Init(object, index:int):
|
||||
state = false
|
||||
var name = object["name"];
|
||||
unlocked = GallerySingleton.HaveMusic(name)
|
||||
if unlocked:
|
||||
$Label.text = str("%02d" % index, " ", name);
|
||||
musicPath = object["path"];
|
||||
else :
|
||||
$Label.text = tr("ui_gallery_locked");
|
||||
|
||||
func _on_Button_pressed():
|
||||
if not unlocked:
|
||||
return ;
|
||||
state = not state;
|
||||
DrawButtonIcon();
|
||||
emit_signal("PlayerStarted");
|
||||
|
||||
func DrawButtonIcon():
|
||||
if state:
|
||||
$Button.icon = stopIcon;
|
||||
else :
|
||||
$Button.icon = playIcon;
|
||||
|
||||
func GetAudioStream()->AudioStream:
|
||||
if not ResourceLoader.exists(musicPath):
|
||||
return null
|
||||
|
||||
var stream = load(musicPath);
|
||||
return stream;
|
16
scripts/CustomControls/GalleryPaginationButton.gd
Normal file
16
scripts/CustomControls/GalleryPaginationButton.gd
Normal file
|
@ -0,0 +1,16 @@
|
|||
extends Button
|
||||
|
||||
func _ready():
|
||||
var font = self.get_font("font");
|
||||
self.add_font_override("font", font.duplicate())
|
||||
|
||||
func _on_Button_mouse_entered():
|
||||
(self as Button).get("custom_fonts/font").outline_color = Color(213, 55, 29, 255)
|
||||
|
||||
func _on_Button_mouse_exited():
|
||||
if not self.disabled:
|
||||
(self as Button).get("custom_fonts/font").outline_color = Color(0, 0, 0, 255)
|
||||
|
||||
func _on_Button_pressed():
|
||||
(self as Button).get("custom_fonts/font").outline_color = Color(255, 255, 255, 255)
|
||||
|
15
scripts/CustomControls/GalleryStateButton.gd
Normal file
15
scripts/CustomControls/GalleryStateButton.gd
Normal file
|
@ -0,0 +1,15 @@
|
|||
extends Button
|
||||
|
||||
func _ready():
|
||||
var font = self.get_font("font");
|
||||
self.add_font_override("font", font.duplicate())
|
||||
|
||||
func _on_Button_mouse_entered():
|
||||
(self as Button).get("custom_fonts/font").outline_color = Color(213, 55, 29, 255)
|
||||
|
||||
func _on_Button_mouse_exited():
|
||||
(self as Button).get("custom_fonts/font").outline_color = Color(0, 0, 0, 255)
|
||||
|
||||
func _on_Button_pressed():
|
||||
if self.pressed:
|
||||
(self as Button).get("custom_fonts/font").outline_color = Color(255, 255, 255, 255)
|
74
scripts/CustomControls/Lightning.gd
Normal file
74
scripts/CustomControls/Lightning.gd
Normal file
|
@ -0,0 +1,74 @@
|
|||
extends Node2D
|
||||
|
||||
var state;
|
||||
var playerReference:AudioStreamPlayer;
|
||||
|
||||
var scenePath;
|
||||
var imagesLoaded;
|
||||
|
||||
func _ready():
|
||||
pass;
|
||||
|
||||
func Init(number:int, audioPlayer:AudioStreamPlayer):
|
||||
state = number;
|
||||
playerReference = audioPlayer;
|
||||
|
||||
imagesLoaded = false;
|
||||
|
||||
var _temp = SceneLoader.connect("on_scene_loaded", self, "ImagesLoaded");
|
||||
scenePath = str("res://resources/customControls/Lightning/Lightning", number, ".tscn");
|
||||
if not ResourceLoader.exists(scenePath):
|
||||
OS.alert("МОЛНИИ НЕТ!!!");
|
||||
SceneLoader.load_scene(scenePath)
|
||||
|
||||
func SetPosition(pos:Vector2, _scale:Vector2):
|
||||
yield (get_tree().create_timer(0.1), "timeout");
|
||||
position = pos;
|
||||
scale = _scale;
|
||||
|
||||
|
||||
func ImagesLoaded(obj):
|
||||
if obj.path != scenePath:
|
||||
return ;
|
||||
|
||||
add_child(obj.instance);
|
||||
obj.instance.connect("animation_finished", self, "_on_Animation_animation_finished");
|
||||
imagesLoaded = true;
|
||||
SceneLoader.disconnect("on_scene_loaded", self, "ImagesLoaded");
|
||||
|
||||
func StartAnimation():
|
||||
if not has_node("Animation"):
|
||||
return ;
|
||||
|
||||
var sprite:AnimatedSprite = $Animation;
|
||||
|
||||
if sprite.is_playing():
|
||||
return ;
|
||||
|
||||
sprite.visible = true;
|
||||
sprite.frame = 0;
|
||||
|
||||
sprite.play("default");
|
||||
|
||||
func _process(_delta):
|
||||
if not imagesLoaded:
|
||||
return ;
|
||||
|
||||
if playerReference == null:
|
||||
return
|
||||
|
||||
var time = playerReference.get_playback_position();
|
||||
|
||||
match playerReference.stream.resource_path:
|
||||
"res://resources/audio/sfx/Rain Loop.ogg":
|
||||
if time >= 2.4 and time <= 2.5:
|
||||
StartAnimation();
|
||||
"res://resources/audio/sfx/Mayak_night.ogg":
|
||||
if time >= 3.1 and time <= 3.2:
|
||||
StartAnimation();
|
||||
_:
|
||||
pass;
|
||||
|
||||
func _on_Animation_animation_finished():
|
||||
if has_node("Animation"):
|
||||
$Animation.visible = false;
|
108
scripts/CustomControls/SaveSlot.gd
Normal file
108
scripts/CustomControls/SaveSlot.gd
Normal file
|
@ -0,0 +1,108 @@
|
|||
extends Control
|
||||
|
||||
signal SlotNameClicked;
|
||||
|
||||
var imagesFolder = OS.get_user_data_dir() + "/slotImages/";
|
||||
var slotNumber;
|
||||
var width = 1920 * 3.0 / 10.0;
|
||||
var height = 1080 * 3.0 / 10.0;
|
||||
|
||||
var isDisabled;
|
||||
|
||||
var thread;
|
||||
|
||||
func Init(slotnumber:String, slotName:String):
|
||||
|
||||
$SlotName.text = slotName;
|
||||
|
||||
|
||||
slotNumber = slotnumber;
|
||||
thread = Thread.new();
|
||||
thread.start(self, "UpdateImage");
|
||||
|
||||
|
||||
var font = $SlotName.get_font("font").duplicate();
|
||||
$SlotName.add_font_override("font", font);
|
||||
|
||||
|
||||
|
||||
func CheckIfDisabled():
|
||||
var folderName;
|
||||
match slotNumber:
|
||||
"AutosaveNormal":
|
||||
folderName = OS.get_user_data_dir() + "/dialogic/AutosaveNormal";
|
||||
"AutosaveCasual":
|
||||
folderName = OS.get_user_data_dir() + "/dialogic/AutosaveCasual";
|
||||
_:
|
||||
folderName = OS.get_user_data_dir() + "/dialogic/slot" + slotNumber;
|
||||
|
||||
var directory = Directory.new();
|
||||
if not directory.dir_exists(folderName):
|
||||
Disable();
|
||||
|
||||
func ResizeForInGame():
|
||||
width = 384;
|
||||
height = 216;
|
||||
rect_size = Vector2(width, height);
|
||||
$SlotName.rect_size = Vector2(width, height);
|
||||
|
||||
$Date.rect_size.x = width;
|
||||
$Date.rect_position.y = height - 56;
|
||||
$Date.get_font("font").size = 38;
|
||||
|
||||
|
||||
func Disable():
|
||||
isDisabled = true;
|
||||
$SlotName.set("custom_colors/font_color", Color(0.6, 0.6, 0.6, 255))
|
||||
|
||||
func Enable():
|
||||
isDisabled = false;
|
||||
|
||||
func UpdateImage():
|
||||
var imagePath = str(imagesFolder, slotNumber, ".png");
|
||||
var file = File.new();
|
||||
if file.file_exists(imagePath):
|
||||
|
||||
var dateTime = OS.get_datetime_from_unix_time(file.get_modified_time(imagePath));
|
||||
var utcDiff = OS.get_datetime(false).hour - OS.get_datetime(true).hour;
|
||||
|
||||
if utcDiff + dateTime.hour >= 24:
|
||||
dateTime.day += 1;
|
||||
dateTime.hour = utcDiff + dateTime.hour - 24;
|
||||
elif utcDiff + dateTime.hour < 0:
|
||||
dateTime.day -= 1;
|
||||
dateTime.hour = utcDiff + dateTime.hour + 24;
|
||||
|
||||
var strDate = "%1d.%02d.%02d %02d:%02d" % [dateTime.day, dateTime.month, dateTime.year, dateTime.hour + utcDiff, dateTime.minute]
|
||||
$Date.text = str(strDate);
|
||||
|
||||
|
||||
var image = Image.new()
|
||||
image.load(imagePath)
|
||||
image.flip_y()
|
||||
var t = ImageTexture.new()
|
||||
t.create_from_image(image)
|
||||
|
||||
$SlotImage.texture_normal = t;
|
||||
|
||||
var scaleValue = width / 1920.0;
|
||||
$SlotImage.rect_scale = Vector2(scaleValue, scaleValue);
|
||||
else :
|
||||
$SlotImage.rect_size = Vector2(width, height);
|
||||
|
||||
func _on_SlotImage_button_up():
|
||||
if not isDisabled:
|
||||
emit_signal("SlotNameClicked");
|
||||
|
||||
func _on_SlotImage_mouse_entered():
|
||||
if not isDisabled:
|
||||
$SlotName.get("custom_fonts/font").outline_color = Color(213, 55, 29, 255)
|
||||
$SlotName.set("custom_colors/font_color", Color(0, 0, 0, 255))
|
||||
|
||||
func _on_SlotImage_mouse_exited():
|
||||
if not isDisabled:
|
||||
$SlotName.get("custom_fonts/font").outline_color = Color(0, 0, 0, 255)
|
||||
$SlotName.set("custom_colors/font_color", Color(213, 55, 29, 255));
|
||||
|
||||
func _exit_tree():
|
||||
thread.wait_to_finish();
|
159
scripts/CustomControls/Twitch/TwitchPoll.gd
Normal file
159
scripts/CustomControls/Twitch/TwitchPoll.gd
Normal file
|
@ -0,0 +1,159 @@
|
|||
extends Node2D
|
||||
|
||||
var client_id = ""
|
||||
var oauth = "oauth:"
|
||||
|
||||
onready var twicil = get_node("TwiCIL");
|
||||
|
||||
onready var label = $TimerLabel;
|
||||
|
||||
onready var PollItem = preload("res://resources/customControls/Twitch/TwitchPollItem.tscn");
|
||||
|
||||
var voted_users:Array = [];
|
||||
var votes = {};
|
||||
|
||||
var timeToVote:int;
|
||||
|
||||
var numOfChoices:int;
|
||||
|
||||
var isPolling:bool;
|
||||
|
||||
var inited:bool;
|
||||
|
||||
func _ready():
|
||||
isPolling = false;
|
||||
inited = false;
|
||||
|
||||
func Clear():
|
||||
for i in $VBoxContainer.get_children():
|
||||
$VBoxContainer.remove_child(i);
|
||||
voted_users.clear();
|
||||
votes.clear();
|
||||
|
||||
func Init(amount:int):
|
||||
inited = true;
|
||||
|
||||
var nick = CreateNickname();
|
||||
var channelName = SettingsSingleton.GetTwitchChannel();
|
||||
|
||||
|
||||
var attemps = 0;
|
||||
while true:
|
||||
attemps += 1;
|
||||
|
||||
var _temp = twicil.connect_to_twitch_chat()
|
||||
yield (twicil, "ConnectedToTwitch");
|
||||
|
||||
if attemps == 4:
|
||||
print("TWITCH CONNECTION KAPETS")
|
||||
return
|
||||
|
||||
if twicil.IsConnected():
|
||||
break;
|
||||
|
||||
twicil.connect_to_channel(channelName, client_id, oauth, nick)
|
||||
|
||||
$SizeTimer.start(0.01);
|
||||
|
||||
Clear();
|
||||
numOfChoices = amount;
|
||||
for i in amount:
|
||||
votes[i + 1] = 0;
|
||||
var pollItem = PollItem.instance();
|
||||
$VBoxContainer.add_child(pollItem);
|
||||
|
||||
if not twicil.is_connected("message_recieved", self, "_on_message_recieved"):
|
||||
twicil.connect("message_recieved", self, "_on_message_recieved")
|
||||
|
||||
func StartTimer():
|
||||
if not inited:
|
||||
Disconnect();
|
||||
return ;
|
||||
|
||||
z_index = 10;
|
||||
visible = true;
|
||||
isPolling = true;
|
||||
$Timer.start(SettingsSingleton.GetTwitchTimer());
|
||||
|
||||
func Disconnect():
|
||||
visible = false;
|
||||
isPolling = false;
|
||||
Clear();
|
||||
if twicil.is_connected("message_recieved", self, "_on_message_recieved"):
|
||||
twicil.disconnect("message_recieved", self, "_on_message_recieved")
|
||||
twicil.Disconnect();
|
||||
label.text = "";
|
||||
|
||||
inited = false;
|
||||
|
||||
const messageCap:int = 5;
|
||||
|
||||
func _on_message_recieved(user_name:String, text:String, _emotes)->void :
|
||||
if user_name in voted_users:
|
||||
return ;
|
||||
|
||||
if text.length() > messageCap:
|
||||
text = text.left(messageCap)
|
||||
|
||||
var number = int(text);
|
||||
|
||||
if not votes.has(number):
|
||||
return ;
|
||||
|
||||
votes[number] += 1
|
||||
voted_users.push_back(user_name)
|
||||
|
||||
$VBoxContainer.get_child(number - 1).AddVote(user_name);
|
||||
|
||||
func _process(_delta):
|
||||
if not isPolling:
|
||||
return ;
|
||||
var timer = $Timer;
|
||||
if timer.time_left < 6.0:
|
||||
label.set("custom_colors/font_color", Color(0.78, 0, 0, 1))
|
||||
else :
|
||||
label.set("custom_colors/font_color", Color(0.75, 0.75, 0.75, 1))
|
||||
|
||||
label.text = "%d" % $Timer.time_left;
|
||||
|
||||
func CreateNickname()->String:
|
||||
var rnd = RandomNumberGenerator.new();
|
||||
rnd.randomize();
|
||||
var nick = str("justinfan", rnd.randi_range(10000, 99999));
|
||||
return nick;
|
||||
|
||||
func Result()->int:
|
||||
var candidates = [];
|
||||
|
||||
var values = votes.values();
|
||||
values.sort();
|
||||
var maxValue = values.max();
|
||||
|
||||
for i in votes.keys():
|
||||
if votes[i] == maxValue:
|
||||
candidates.push_back(i);
|
||||
|
||||
if candidates.size() > 1:
|
||||
candidates.shuffle()
|
||||
|
||||
return candidates[0];
|
||||
|
||||
func StopTimerInMenu():
|
||||
if not isPolling:
|
||||
return
|
||||
|
||||
if $Timer.is_stopped():
|
||||
return
|
||||
z_index = 0;
|
||||
$Timer.set_paused(true)
|
||||
|
||||
func ResumeTimerInMenu():
|
||||
if not isPolling:
|
||||
return
|
||||
|
||||
if $Timer.paused:
|
||||
z_index = 10;
|
||||
$Timer.set_paused(false)
|
||||
|
||||
func AppearTimer():
|
||||
visible = isPolling;
|
12
scripts/CustomControls/Twitch/TwitchPollItem.gd
Normal file
12
scripts/CustomControls/Twitch/TwitchPollItem.gd
Normal file
|
@ -0,0 +1,12 @@
|
|||
extends Control
|
||||
|
||||
var count:int;
|
||||
|
||||
func _ready():
|
||||
count = 0;
|
||||
|
||||
func AddVote(nickname:String):
|
||||
count += 1;
|
||||
$Count.text = str(count);
|
||||
|
||||
$Nickname.text = nickname;
|
60
scripts/CustomControls/VolumeSlider.gd
Normal file
60
scripts/CustomControls/VolumeSlider.gd
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue