Initial Android commit
This commit is contained in:
commit
1e2b80c13d
8521 changed files with 231475 additions and 0 deletions
798
scripts/SettingsMenu.gd
Normal file
798
scripts/SettingsMenu.gd
Normal file
|
@ -0,0 +1,798 @@
|
|||
extends Node
|
||||
|
||||
var windowSize;
|
||||
|
||||
signal BackFromSettings;
|
||||
signal ReturnToGame;
|
||||
signal ResolutionChanged;
|
||||
|
||||
onready var windowResolutions = get_node("VideoSettingsView/WindowResolutions/VBoxContainer");
|
||||
|
||||
onready var allSettingsView = get_node("AllSettingsView");
|
||||
onready var videoSettingsView = get_node("VideoSettingsView");
|
||||
onready var audioSettingsView = get_node("AudioSettingsView");
|
||||
onready var textSettingsView = get_node("TextSettingsView");
|
||||
onready var languageSettingsView = get_node("LanguageSettingsView");
|
||||
onready var twitchSettingsView = get_node("TwitchSettingsView");
|
||||
|
||||
|
||||
|
||||
|
||||
var windowResolutionsArray = [
|
||||
"640x360",
|
||||
"854x480",
|
||||
"1280x720",
|
||||
"1366x768",
|
||||
"1600x900",
|
||||
"1920x1080",
|
||||
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
onready var generalVolume = get_node("AudioSettingsView/GeneralVolumeSlider");
|
||||
onready var musicVolume = get_node("AudioSettingsView/MusicVolumeSlider");
|
||||
onready var dialogueVolume = get_node("AudioSettingsView/DialogueVolumeSlider");
|
||||
onready var effectsVolume = get_node("AudioSettingsView/EffectsVolumeSlider");
|
||||
|
||||
|
||||
var type;
|
||||
func setType(value:int):
|
||||
|
||||
|
||||
type = value;
|
||||
|
||||
if value == 0:
|
||||
$ReturnToGameButton.visible = false;
|
||||
$VideoSettingsView / ScalingMessage.visible = OS.get_screen_scale() != 1.0;
|
||||
else :
|
||||
$AllSettingsView / VideoButton.disabled = true;
|
||||
$AllSettingsView / LanguageButton.disabled = true;
|
||||
$BackToMenuButton.rect_global_position = Vector2(461, 545);
|
||||
|
||||
func _ready():
|
||||
|
||||
|
||||
windowSize = Vector2(1920, 1080)
|
||||
|
||||
SetButtonsHover();
|
||||
|
||||
BackToAllView();
|
||||
|
||||
CreateLanguages();
|
||||
|
||||
LoadLanguage();
|
||||
|
||||
LoadSettings();
|
||||
|
||||
func SetButtonsHover():
|
||||
var nodes = GetNodes();
|
||||
|
||||
for i in nodes:
|
||||
var node = get_node(i);
|
||||
if node is Button:
|
||||
if not node.is_connected("mouse_entered", self, "onButtonHoverOn"):
|
||||
node.connect("mouse_entered", self, "onButtonHoverOn", [node])
|
||||
if not node.is_connected("mouse_exited", self, "onButtonHoverOff"):
|
||||
node.connect("mouse_exited", self, "onButtonHoverOff", [node])
|
||||
|
||||
func onButtonHoverOn(button):
|
||||
if not button.disabled:
|
||||
button.get("custom_fonts/font").outline_color = Color(213, 55, 29, 255)
|
||||
|
||||
func onButtonHoverOff(button):
|
||||
button.get("custom_fonts/font").outline_color = Color(0, 0, 0, 255)
|
||||
|
||||
func BackToAllView():
|
||||
allSettingsView.visible = true;
|
||||
videoSettingsView.visible = false;
|
||||
audioSettingsView.visible = false;
|
||||
textSettingsView.visible = false;
|
||||
languageSettingsView.visible = false;
|
||||
twitchSettingsView.visible = false;
|
||||
|
||||
func CreateLanguages():
|
||||
var control = load("res://resources/customControls/LanguageSettign.tscn");
|
||||
var group = load("res://resources/customControls/CheckBoxGroups/LanguageGroup.tres")
|
||||
|
||||
var langs = LanguageLocalization.GetLanguages();
|
||||
|
||||
var lang = $LanguageSettingsView / InterfaceAndText / VBoxContainer;
|
||||
|
||||
|
||||
for i in langs:
|
||||
var langControl = control.instance();
|
||||
langControl.name = i.name;
|
||||
langControl.text = i.name;
|
||||
langControl.group = group
|
||||
langControl.connect("pressed", self, "_on_LanguageOption_item_selected", [i.locale])
|
||||
lang.add_child(langControl);
|
||||
|
||||
|
||||
var voice_group = load("res://resources/customControls/CheckBoxGroups/LanguageVoiceoverGroup.tres")
|
||||
var voice_langs = LanguageLocalization.GetVoiceLanguages();
|
||||
|
||||
var voice_lang = $LanguageSettingsView / Voiceover / VBoxContainer;
|
||||
|
||||
for i in voice_langs:
|
||||
var langControl = control.instance();
|
||||
langControl.name = i.name;
|
||||
langControl.text = i.name;
|
||||
langControl.group = voice_group;
|
||||
langControl.connect("pressed", self, "_on_VoiceLanguageOption_item_selected", [i.locale])
|
||||
voice_lang.add_child(langControl);
|
||||
|
||||
func LoadLanguage():
|
||||
var selectedLangageOptionIndex = LanguageLocalization.GetLanguageIndex();
|
||||
$LanguageSettingsView / InterfaceAndText / VBoxContainer.get_child(selectedLangageOptionIndex).pressed = true;
|
||||
|
||||
var selectedVoiceLangageIndex = LanguageLocalization.GetVoiceLanguageIndex();
|
||||
$LanguageSettingsView / Voiceover / VBoxContainer.get_child(selectedVoiceLangageIndex).pressed = true;
|
||||
|
||||
func LoadSettings():
|
||||
LoadTranlations();
|
||||
|
||||
LoadVideoSettings();
|
||||
|
||||
LoadAudioSettings();
|
||||
|
||||
LoadTextSettings();
|
||||
|
||||
LoadTwitchSettings();
|
||||
|
||||
func LoadTranlations():
|
||||
var settingsLocalization = LanguageLocalization.GetLocalization();
|
||||
for i in settingsLocalization:
|
||||
if "AudioSettingsView" in i:
|
||||
get_node(i).setName(settingsLocalization[i])
|
||||
elif "TextSettingsView/TextSpeedSlider" in i:
|
||||
get_node(i).setName(settingsLocalization[i])
|
||||
elif "TwitchSettingsView/TimerSlider" in i:
|
||||
get_node(i).setName(settingsLocalization[i])
|
||||
else :
|
||||
get_node(i).text = tr(settingsLocalization[i]);
|
||||
|
||||
func _on_LanguageOption_item_selected(languageLocale):
|
||||
LanguageLocalization.SetLanguages(languageLocale);
|
||||
|
||||
var voiceContainer = $LanguageSettingsView / Voiceover / VBoxContainer;
|
||||
if languageLocale == "en":
|
||||
voiceContainer.get_child(0).pressed = true;
|
||||
elif languageLocale == "ru":
|
||||
voiceContainer.get_child(1).pressed = true;
|
||||
SettingsSingleton.SetVoiceoverLanguage(languageLocale);
|
||||
|
||||
LoadTranlations()
|
||||
LoadLanguage();
|
||||
LoadVideoSettings();
|
||||
|
||||
func _on_VoiceLanguageOption_item_selected(languageLocale):
|
||||
SettingsSingleton.SetVoiceoverLanguage(languageLocale);
|
||||
|
||||
|
||||
|
||||
func LoadVideoSettings():
|
||||
var windowStates = $VideoSettingsView / WindowStates;
|
||||
|
||||
for i in windowStates.get_child_count():
|
||||
if not windowStates.get_child(i).is_connected("pressed", self, "_on_WindowState_item_selected"):
|
||||
windowStates.get_child(i).connect("pressed", self, "_on_WindowState_item_selected", [i]);
|
||||
|
||||
var stateOptionIndex = SettingsSingleton.GetCurrectWindowState();
|
||||
|
||||
windowStates.get_child(stateOptionIndex).pressed = true;
|
||||
ChangeWindowResolutionSettings();
|
||||
|
||||
ChangeWindowResolution();
|
||||
ChangeWindowState();
|
||||
|
||||
$VideoSettingsView / LowProcessor.pressed = SettingsSingleton.GetCurrectLowProcessor();
|
||||
$VideoSettingsView / SyncBackground.pressed = SettingsSingleton.GetAsyncBackgroundLoading();
|
||||
|
||||
ChangeLowProcessor();
|
||||
|
||||
func ChangeWindowResolutionSettings():
|
||||
var checkBoxGround = load("res://resources/customControls/CheckBoxGroups/WindowResolutionGroup.tres")
|
||||
|
||||
var noFocus = load("res://resources/Themes/EmptyFocusTheme.tres");
|
||||
|
||||
var isFullScreen = OS.is_window_fullscreen();
|
||||
|
||||
if is_instance_valid(windowResolutions):
|
||||
for i in windowResolutions.get_children():
|
||||
windowResolutions.remove_child(i);
|
||||
|
||||
var font = load("res://resources/fonts/SettingsFont.tres");
|
||||
var checked = load("res://resources/graphics/GUI/CheckBox/checked-20.webp");
|
||||
var unchecked = load("res://resources/graphics/GUI/CheckBox/unchecked-20.webp");
|
||||
|
||||
font = font.duplicate(true)
|
||||
font.size = 35;
|
||||
|
||||
|
||||
|
||||
var monitorSize = OS.get_screen_size();
|
||||
var currentWidth = monitorSize.x;
|
||||
|
||||
var strSize = str(monitorSize.x) + "x" + str(monitorSize.y);
|
||||
|
||||
if windowResolutionsArray.find(strSize) == - 1:
|
||||
var insertIndex = 0;
|
||||
for i in windowResolutionsArray:
|
||||
var width = int(i.split("x", true)[0]);
|
||||
if currentWidth > width:
|
||||
insertIndex += 1;
|
||||
else :break;
|
||||
|
||||
windowResolutionsArray.insert(insertIndex, strSize);
|
||||
|
||||
for i in windowResolutionsArray.size():
|
||||
var width = int(windowResolutionsArray[i].split("x", true)[0]);
|
||||
if currentWidth < width:
|
||||
continue;
|
||||
|
||||
var checkBox = CheckBox.new();
|
||||
checkBox.text = windowResolutionsArray[i];
|
||||
checkBox.rect_position = Vector2(0, 25 * i);
|
||||
checkBox.set_button_group(checkBoxGround)
|
||||
checkBox.add_font_override("font", font);
|
||||
checkBox.set("custom_styles/focus", noFocus);
|
||||
checkBox.set("custom_icons/radio_checked", checked);
|
||||
checkBox.set("custom_icons/radio_unchecked", unchecked);
|
||||
|
||||
checkBox.set("custom_icons/radio_checked_disabled", checked);
|
||||
checkBox.set("custom_icons/radio_unchecked_disabled", unchecked);
|
||||
|
||||
checkBox.connect("pressed", self, "_on_ScreenResolution_item_selected", [i])
|
||||
checkBox.disabled = isFullScreen;
|
||||
if is_instance_valid(windowResolutions):
|
||||
windowResolutions.add_child(checkBox);
|
||||
|
||||
strSize = str(OS.get_window_size().x) + "x" + str(OS.get_window_size().y);
|
||||
var index = windowResolutionsArray.find(strSize)
|
||||
if index != - 1 and is_instance_valid(windowResolutions):
|
||||
windowResolutions.get_child(index).pressed = true;
|
||||
|
||||
func _on_WindowState_item_selected(index):
|
||||
SettingsSingleton.SetCurrectWindowState(index);
|
||||
ChangeWindowState();
|
||||
ChangeWindowResolutionSettings();
|
||||
|
||||
func _on_ScreenResolution_item_selected(index):
|
||||
|
||||
var value = windowResolutionsArray[index];
|
||||
SettingsSingleton.SetCurrectScreenResolution(value);
|
||||
ChangeWindowResolution();
|
||||
ChangeWindowResolutionSettings();
|
||||
emit_signal("ResolutionChanged")
|
||||
|
||||
func ChangeWindowState():
|
||||
var state = SettingsSingleton.GetCurrectWindowState();
|
||||
if state == 0:
|
||||
if OS.is_window_fullscreen():
|
||||
OS.set_window_fullscreen(false);
|
||||
if OS.get_borderless_window():
|
||||
OS.set_borderless_window(false);
|
||||
ChangeWindowResolution();
|
||||
elif state == 1:
|
||||
if OS.is_window_fullscreen():
|
||||
OS.set_window_fullscreen(false);
|
||||
OS.set_borderless_window(true);
|
||||
ChangeWindowResolution();
|
||||
elif state == 2:
|
||||
OS.set_window_fullscreen(true);
|
||||
ChangeWindowResolution();
|
||||
UpdateResolutionButtons();
|
||||
else :
|
||||
return
|
||||
|
||||
func UpdateResolutionButtons():
|
||||
|
||||
var monitorSize = OS.get_real_window_size();
|
||||
var currentWidth = monitorSize.x;
|
||||
var strSize = str(monitorSize.x) + "x" + str(monitorSize.y);
|
||||
|
||||
if windowResolutionsArray.find(strSize) == - 1:
|
||||
var insertIndex = 0;
|
||||
for i in windowResolutionsArray:
|
||||
var width = int(i.split("x", true)[0]);
|
||||
if currentWidth > width:
|
||||
insertIndex += 1;
|
||||
else :break;
|
||||
|
||||
windowResolutionsArray.insert(insertIndex, strSize);
|
||||
|
||||
if strSize in windowResolutionsArray:
|
||||
var index = windowResolutionsArray.find(strSize);
|
||||
if is_instance_valid(windowResolutions):
|
||||
windowResolutions.get_child(index).pressed = true;
|
||||
|
||||
_on_ScreenResolution_item_selected(index)
|
||||
else :
|
||||
|
||||
var insertIndex = 0;
|
||||
|
||||
for i in windowResolutionsArray:
|
||||
var width = int(i.split("x", true)[0]);
|
||||
if currentWidth > width:
|
||||
insertIndex += 1;
|
||||
else :break;
|
||||
if is_instance_valid(windowResolutions):
|
||||
windowResolutions.get_child(insertIndex).pressed = true;
|
||||
_on_ScreenResolution_item_selected(insertIndex)
|
||||
|
||||
func ChangeWindowResolution():
|
||||
var resolution = SettingsSingleton.GetCurrectScreenResolution()
|
||||
var width = 0;
|
||||
var height = 0;
|
||||
if resolution != "-":
|
||||
var value = resolution.split("x", false, 1);
|
||||
width = int(value[0]);
|
||||
height = int(value[1]);
|
||||
else :
|
||||
var window = OS.get_real_window_size()
|
||||
width = window.x;
|
||||
height = window.y;
|
||||
OS.set_window_size(Vector2(width, height));
|
||||
|
||||
var screen_size = OS.get_screen_size();
|
||||
var window_size = OS.get_window_size();
|
||||
OS.set_window_position(screen_size * 0.5 - window_size * 0.5)
|
||||
|
||||
if SettingsSingleton.GetCurrectWindowState() == 0:
|
||||
if width == screen_size.x and height == screen_size.y:
|
||||
SettingsSingleton.SetCurrectWindowState(1);
|
||||
$VideoSettingsView / WindowStates / BorderlessCheck.pressed = true;
|
||||
OS.set_borderless_window(true);
|
||||
|
||||
func _on_LowProcessor_pressed():
|
||||
SettingsSingleton.SetCurrectLowProcessor($VideoSettingsView / LowProcessor.pressed);
|
||||
ChangeLowProcessor();
|
||||
|
||||
func ChangeLowProcessor():
|
||||
var value = SettingsSingleton.GetCurrectLowProcessor();
|
||||
OS.set_low_processor_usage_mode(value);
|
||||
|
||||
func _on_SyncBackground_pressed():
|
||||
SettingsSingleton.SetAsyncBackgroundLoading($VideoSettingsView / SyncBackground.pressed);
|
||||
|
||||
func SetVideoSettingsForMenu():
|
||||
ChangeWindowState();
|
||||
ChangeWindowResolution();
|
||||
ChangeLowProcessor();
|
||||
|
||||
|
||||
|
||||
func SetAudioSettingsForMenu():
|
||||
ChangeGeneralVolume(int(SettingsSingleton.GetGeneralVolumeLevel()))
|
||||
ChangeMusicVolume(int(SettingsSingleton.GetMusicVolumeLevel()))
|
||||
ChangeEffectsVolume(int(SettingsSingleton.GetEffectsVolumeLevel()))
|
||||
ChangeDialogueVolume(int(SettingsSingleton.GetDialogueVolumeLevel()))
|
||||
|
||||
func LoadAudioSettings():
|
||||
for i in $AudioSettingsView.get_children():
|
||||
i.resize();
|
||||
|
||||
generalVolume.setValue(SettingsSingleton.GetGeneralVolumeLevel())
|
||||
generalVolume.connect("value_changed", self, "_on_GeneralVolume_value_changed");
|
||||
|
||||
musicVolume.setValue(SettingsSingleton.GetMusicVolumeLevel());
|
||||
musicVolume.connect("value_changed", self, "_on_MusicVolume_value_changed");
|
||||
|
||||
dialogueVolume.setValue(SettingsSingleton.GetDialogueVolumeLevel());
|
||||
dialogueVolume.connect("value_changed", self, "_on_DialogueVolume_value_changed");
|
||||
|
||||
effectsVolume.setValue(SettingsSingleton.GetEffectsVolumeLevel());
|
||||
effectsVolume.connect("value_changed", self, "_on_EffectsVolume_value_changed");
|
||||
|
||||
func _on_GeneralVolume_value_changed(value):
|
||||
SettingsSingleton.SetGeneralVolumeLevel(value);
|
||||
ChangeGeneralVolume(value);
|
||||
|
||||
func ChangeGeneralVolume(value):
|
||||
value = float(value);
|
||||
if value <= 0:
|
||||
AudioServer.set_bus_mute(AudioServer.get_bus_index("Master"), true);
|
||||
else :
|
||||
if AudioServer.is_bus_mute(AudioServer.get_bus_index("Master")):
|
||||
AudioServer.set_bus_mute(AudioServer.get_bus_index("Master"), false);
|
||||
var dbValue:float = linear2db(value / 100);
|
||||
|
||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), dbValue);
|
||||
|
||||
func _on_MusicVolume_value_changed(value):
|
||||
SettingsSingleton.SetMusicVolumeLevel(value);
|
||||
ChangeMusicVolume(value);
|
||||
|
||||
func ChangeMusicVolume(value):
|
||||
value = float(value);
|
||||
|
||||
if value <= 0:
|
||||
AudioServer.set_bus_mute(AudioServer.get_bus_index("BGM"), true);
|
||||
else :
|
||||
if AudioServer.is_bus_mute(AudioServer.get_bus_index("BGM")):
|
||||
AudioServer.set_bus_mute(AudioServer.get_bus_index("BGM"), false);
|
||||
var dbValue:float = linear2db(value / 100);
|
||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("BGM"), dbValue);
|
||||
|
||||
func _on_DialogueVolume_value_changed(value):
|
||||
SettingsSingleton.SetDialogueVolumeLevel(value);
|
||||
ChangeDialogueVolume(value);
|
||||
|
||||
func ChangeDialogueVolume(value):
|
||||
value = float(value);
|
||||
|
||||
if value <= 0:
|
||||
AudioServer.set_bus_mute(AudioServer.get_bus_index("Dialogue"), true);
|
||||
else :
|
||||
if AudioServer.is_bus_mute(AudioServer.get_bus_index("Dialogue")):
|
||||
AudioServer.set_bus_mute(AudioServer.get_bus_index("Dialogue"), false);
|
||||
var dbValue:float = linear2db(value / 100);
|
||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Dialogue"), dbValue);
|
||||
|
||||
func _on_EffectsVolume_value_changed(value):
|
||||
SettingsSingleton.SetEffectsVolumeLevel(value);
|
||||
ChangeEffectsVolume(value);
|
||||
|
||||
func ChangeEffectsVolume(value):
|
||||
value = float(value);
|
||||
|
||||
if value <= 0:
|
||||
AudioServer.set_bus_mute(AudioServer.get_bus_index("SFX"), true);
|
||||
else :
|
||||
if AudioServer.is_bus_mute(AudioServer.get_bus_index("SFX")):
|
||||
AudioServer.set_bus_mute(AudioServer.get_bus_index("SFX"), false);
|
||||
var dbValue:float = linear2db(value / 100);
|
||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("SFX"), dbValue);
|
||||
|
||||
|
||||
func LoadTextSettings():
|
||||
$TextSettingsView / AutoReadCheck.pressed = SettingsSingleton.GetAutoRead();
|
||||
$TextSettingsView / SkipSeenCheck.pressed = SettingsSingleton.GetSkipSeen();
|
||||
|
||||
var slider = $TextSettingsView / TextSpeedSlider;
|
||||
|
||||
slider.resize();
|
||||
slider.get_node("TextureProgress").rect_position.x += 50;
|
||||
slider.get_node("TextureProgress").min_value = 1;
|
||||
slider.get_node("TextureProgress").max_value = 10;
|
||||
slider.setValue(SettingsSingleton.GetTextSpeed())
|
||||
if not slider.is_connected("value_changed", self, "_on_Text_Speed_value_changed"):
|
||||
slider.connect("value_changed", self, "_on_Text_Speed_value_changed");
|
||||
|
||||
$TextSettingsView / ThemeCheck.pressed = SettingsSingleton.GetDefaultTheme()
|
||||
|
||||
var pickers = [$TextSettingsView / CustomTheme / Back / BackPicker, $TextSettingsView / CustomTheme / Text / TextPicker];
|
||||
for i in pickers:
|
||||
if not i.is_connected("picker_created", self, "ColorPickerCreated"):
|
||||
i.connect("picker_created", self, "ColorPickerCreated", [i])
|
||||
|
||||
var bkColor:Color = Color(SettingsSingleton.GetBackgroundColor());
|
||||
var txColor:Color = Color(SettingsSingleton.GetTextColor());
|
||||
$TextSettingsView / CustomTheme / Back / BackPicker.color = bkColor;
|
||||
$TextSettingsView / CustomTheme / Text / TextPicker.color = txColor;
|
||||
$TextSettingsView / CustomTheme / Example / TextureRect.modulate = bkColor;
|
||||
$TextSettingsView / CustomTheme / Example / Label.set("custom_colors/font_color", txColor)
|
||||
|
||||
func _on_AutoPlayCheck_pressed():
|
||||
var switch = false;
|
||||
if $TextSettingsView / AutoReadCheck.pressed and $TextSettingsView / SkipSeenCheck.pressed:
|
||||
$TextSettingsView / SkipSeenCheck.pressed = false;
|
||||
SettingsSingleton.SetSkipSeen(false);
|
||||
switch = true;
|
||||
|
||||
SettingsSingleton.SetAutoRead($TextSettingsView / AutoReadCheck.pressed);
|
||||
|
||||
|
||||
var menuLayer = get_parent();
|
||||
if menuLayer.name == "MenuLayer":
|
||||
var backbuttons = menuLayer.get_parent().get_parent().get_node("BackButton");
|
||||
backbuttons.get_node("AutoReadButton").pressed = $TextSettingsView / AutoReadCheck.pressed;
|
||||
if switch:
|
||||
backbuttons.get_node("FastForwardButton").pressed = false;
|
||||
|
||||
func _on_SkipSeenCheck_pressed():
|
||||
var switch = false;
|
||||
if $TextSettingsView / SkipSeenCheck.pressed and $TextSettingsView / AutoReadCheck.pressed:
|
||||
$TextSettingsView / AutoReadCheck.pressed = false;
|
||||
SettingsSingleton.SetAutoRead(false);
|
||||
switch = true;
|
||||
|
||||
SettingsSingleton.SetSkipSeen($TextSettingsView / SkipSeenCheck.pressed);
|
||||
|
||||
|
||||
var menuLayer = get_parent();
|
||||
if menuLayer.name == "MenuLayer":
|
||||
var backbuttons = menuLayer.get_parent().get_parent().get_node("BackButton");
|
||||
backbuttons.get_node("FastForwardButton").pressed = $TextSettingsView / SkipSeenCheck.pressed;
|
||||
if switch:
|
||||
backbuttons.get_node("AutoReadButton").pressed = false;
|
||||
|
||||
func _on_ThemeCheck_toggled(_button_pressed):
|
||||
SettingsSingleton.SetDeafaultTheme($TextSettingsView / ThemeCheck.pressed)
|
||||
|
||||
var colorBack = Color.black
|
||||
var colorText = Color.white
|
||||
if not ($TextSettingsView / ThemeCheck.pressed):
|
||||
|
||||
|
||||
colorText = SettingsSingleton.GetTextColor()
|
||||
colorBack = SettingsSingleton.GetBackgroundColor()
|
||||
else :
|
||||
|
||||
|
||||
SettingsSingleton.SetBackgroundColor(colorBack.to_rgba32());
|
||||
SettingsSingleton.SetTextColor(colorText.to_rgba32());
|
||||
$TextSettingsView / CustomTheme / Back / BackPicker.color = colorBack;
|
||||
$TextSettingsView / CustomTheme / Text / TextPicker.color = colorText;
|
||||
|
||||
$TextSettingsView / CustomTheme / Example / TextureRect.modulate = colorBack;
|
||||
var label = $TextSettingsView / CustomTheme / Example / Label;
|
||||
label.set("custom_colors/font_color", colorText)
|
||||
|
||||
if get_tree().root.has_node("Root/Game"):
|
||||
var game = get_tree().root.get_node("Root/Game");
|
||||
game.get_child(0).get_node("DialogNode/TextBubble").ThemeColorChanged();
|
||||
game.get_child(0).get_node("DialogNode").UpdateButtonTheme();
|
||||
|
||||
func _on_Text_Speed_value_changed(value):
|
||||
SettingsSingleton.SetTextSpeed(value);
|
||||
|
||||
var game = get_tree().root.get_node("Root/Game");
|
||||
if game != null:
|
||||
game.get_child(0).get_node("DialogNode/TextBubble").SetNewTextSpeed(value);
|
||||
|
||||
|
||||
func ColorPickerCreated(picker:ColorPickerButton):
|
||||
VisualServer.canvas_item_set_z_index(picker.get_picker().get_canvas_item(), 100);
|
||||
var aa = picker.get_child(0).get_child(0);
|
||||
for i in aa.get_children():
|
||||
i.visible = false;
|
||||
|
||||
var mainPicker = aa.get_child(0);
|
||||
mainPicker.visible = true;
|
||||
mainPicker.rect_size = Vector2(300, 300)
|
||||
|
||||
|
||||
func _on_BackPicker_color_changed(color:Color):
|
||||
if $TextSettingsView / ThemeCheck.pressed:
|
||||
$TextSettingsView / ThemeCheck.pressed = false;
|
||||
|
||||
$TextSettingsView / CustomTheme / Example / TextureRect.modulate = color;
|
||||
SettingsSingleton.SetBackgroundColor(color.to_rgba32());
|
||||
|
||||
var game = get_tree().root.get_node("Root/Game")
|
||||
if game != null:
|
||||
game.get_child(0).get_node("DialogNode/TextBubble").ThemeColorChanged()
|
||||
game.get_child(0).get_node("DialogNode").UpdateButtonTheme()
|
||||
|
||||
func _on_TextPicker_color_changed(color):
|
||||
if $TextSettingsView / ThemeCheck.pressed:
|
||||
$TextSettingsView / ThemeCheck.pressed = false;
|
||||
|
||||
var label = $TextSettingsView / CustomTheme / Example / Label;
|
||||
label.set("custom_colors/font_color", color)
|
||||
SettingsSingleton.SetTextColor(color.to_rgba32());
|
||||
|
||||
var game = get_tree().root.get_node("Root/Game");
|
||||
if game != null:
|
||||
game.get_child(0).get_node("DialogNode/TextBubble").ThemeColorChanged()
|
||||
game.get_child(0).get_node("DialogNode").UpdateButtonTheme()
|
||||
|
||||
|
||||
|
||||
func LoadTwitchSettings():
|
||||
$TwitchSettingsView / TwitchCheck.pressed = SettingsSingleton.GetTwitchEnabled();
|
||||
|
||||
EnableTwitchSettings();
|
||||
|
||||
$TwitchSettingsView / ChannelBox.text = SettingsSingleton.GetTwitchChannel();
|
||||
|
||||
var slider = $TwitchSettingsView / TimerSlider;
|
||||
|
||||
slider.resize();
|
||||
slider.get_node("TextureProgress").min_value = 10;
|
||||
slider.get_node("TextureProgress").max_value = 120;
|
||||
slider.setValue(SettingsSingleton.GetTwitchTimer())
|
||||
if not slider.is_connected("value_changed", self, "_on_Timer_value_changed"):
|
||||
slider.connect("value_changed", self, "_on_Timer_value_changed");
|
||||
|
||||
func _on_TwitchCheck_pressed():
|
||||
SettingsSingleton.SetTwitchEnabled($TwitchSettingsView / TwitchCheck.pressed);
|
||||
EnableTwitchSettings();
|
||||
|
||||
func EnableTwitchSettings():
|
||||
var value = not $TwitchSettingsView / TwitchCheck.pressed;
|
||||
|
||||
$TwitchSettingsView / ChannelBox.readonly = value;
|
||||
$TwitchSettingsView / StatusContainer / CheckConnectionButton.disabled = value;
|
||||
|
||||
|
||||
func _on_ChannelBox_text_changed():
|
||||
var entryBox = $TwitchSettingsView / ChannelBox;
|
||||
SettingsSingleton.SetTwitchChannel(entryBox.text.to_lower());
|
||||
|
||||
func _on_Timer_value_changed(value):
|
||||
SettingsSingleton.SetTwitchTimer(value);
|
||||
|
||||
func _on_CheckConnectionButton_pressed():
|
||||
if $TwitchSettingsView / ChannelBox.text == "":
|
||||
return ;
|
||||
|
||||
var twicil = $TwitchSettingsView / TwiCIL;
|
||||
var timer:Timer = $TwitchSettingsView / TwitchCheckTimer;
|
||||
|
||||
if showTwitchTimer == true:
|
||||
twicil.Disconnect();
|
||||
if twicil.is_connected("message_recieved", self, "_on_test_message_recieved"):
|
||||
twicil.disconnect("message_recieved", self, "_on_test_message_recieved")
|
||||
showTwitchTimer = false;
|
||||
timer.stop()
|
||||
|
||||
$TwitchSettingsView / StatusContainer / TwitchTimer.text = "?"
|
||||
|
||||
var rnd = RandomNumberGenerator.new();
|
||||
rnd.randomize();
|
||||
var nick = str("justinfan", rnd.randi_range(10000, 99999));
|
||||
var client_id = ""
|
||||
var oauth = "oauth:"
|
||||
|
||||
if not twicil.IsConnected():
|
||||
twicil.connect_to_twitch_chat()
|
||||
yield (twicil, "ConnectedToTwitch");
|
||||
|
||||
if twicil.is_connected("DisconnectedFromTwitch", self, "_disconnected_from_twitch"):
|
||||
twicil.disconnect("DisconnectedFromTwitch", self, "_disconnected_from_twitch")
|
||||
|
||||
twicil.connect("DisconnectedFromTwitch", self, "_disconnected_from_twitch")
|
||||
|
||||
twicil.connect_to_channel(SettingsSingleton.GetTwitchChannel(), client_id, oauth, nick)
|
||||
|
||||
if twicil.is_connected("message_recieved", self, "_on_test_message_recieved"):
|
||||
twicil.disconnect("message_recieved", self, "_on_test_message_recieved")
|
||||
|
||||
twicil.connect("message_recieved", self, "_on_test_message_recieved")
|
||||
|
||||
timer.start(SettingsSingleton.GetTwitchTimer());
|
||||
showTwitchTimer = true;
|
||||
$TwitchSettingsView / TwitchStatus.visible = true;
|
||||
$TwitchSettingsView / StatusContainer / TwitchTimer.visible = true;
|
||||
|
||||
func _on_test_message_recieved(_user_name:String, _text:String, _emotes):
|
||||
var twicil = $TwitchSettingsView / TwiCIL;
|
||||
if twicil.is_connected("DisconnectedFromTwitch", self, "_disconnected_from_twitch"):
|
||||
twicil.disconnect("DisconnectedFromTwitch", self, "_disconnected_from_twitch")
|
||||
|
||||
showTwitchTimer = false;
|
||||
$TwitchSettingsView / StatusContainer / TwitchTimer.text = tr("ui_ok");
|
||||
$TwitchSettingsView / TwitchStatus.visible = false;
|
||||
$TwitchSettingsView / TwitchCheckTimer.stop();
|
||||
twicil.disconnect("message_recieved", self, "_on_test_message_recieved")
|
||||
twicil.Disconnect();
|
||||
|
||||
func _disconnected_from_twitch():
|
||||
$TwitchSettingsView / TwitchCheckTimer.stop();
|
||||
showTwitchTimer = false;
|
||||
$TwitchSettingsView / StatusContainer / TwitchTimer.text = "error"
|
||||
$TwitchSettingsView / TwitchStatus.visible = false;
|
||||
|
||||
var twicil = $TwitchSettingsView / TwiCIL;
|
||||
twicil.disconnect("message_recieved", self, "_on_test_message_recieved")
|
||||
twicil.Disconnect();
|
||||
|
||||
func _on_TwitchCheckTimer_timeout():
|
||||
var twicil = $TwitchSettingsView / TwiCIL;
|
||||
if twicil.is_connected("DisconnectedFromTwitch", self, "_disconnected_from_twitch"):
|
||||
twicil.disconnect("DisconnectedFromTwitch", self, "_disconnected_from_twitch")
|
||||
|
||||
showTwitchTimer = false;
|
||||
$TwitchSettingsView / StatusContainer / TwitchTimer.text = tr("ui_no_connection");
|
||||
$TwitchSettingsView / TwitchStatus.visible = false;
|
||||
|
||||
twicil.disconnect("message_recieved", self, "_on_test_message_recieved")
|
||||
twicil.Disconnect();
|
||||
|
||||
var showTwitchTimer = false;
|
||||
func _process(_delta):
|
||||
if showTwitchTimer:
|
||||
$TwitchSettingsView / StatusContainer / TwitchTimer.text = "%d" % $TwitchSettingsView / TwitchCheckTimer.time_left;
|
||||
|
||||
|
||||
func GetNodes():
|
||||
var nodes = [
|
||||
"BackToMenuButton",
|
||||
"ApplyButton",
|
||||
"ReturnToGameButton",
|
||||
"AllSettingsView/VideoButton",
|
||||
"AllSettingsView/AudioButton",
|
||||
"AllSettingsView/TextButton",
|
||||
"AllSettingsView/LanguageButton",
|
||||
"AllSettingsView/TwitchButton",
|
||||
"VideoSettingsView/WindowStates/WindowedCheck",
|
||||
"VideoSettingsView/WindowStates/BorderlessCheck",
|
||||
"VideoSettingsView/WindowStates/FullscreenCheck",
|
||||
"VideoSettingsView/WindowResolutionLabel",
|
||||
"VideoSettingsView/LowProcessor",
|
||||
"VideoSettingsView/SyncBackground",
|
||||
"AudioSettingsView/GeneralVolumeSlider",
|
||||
"AudioSettingsView/MusicVolumeSlider",
|
||||
"AudioSettingsView/DialogueVolumeSlider",
|
||||
"AudioSettingsView/EffectsVolumeSlider",
|
||||
"TextSettingsView/AutoReadCheck",
|
||||
"TextSettingsView/SkipSeenCheck",
|
||||
"TextSettingsView/ThemeCheck",
|
||||
"TwitchSettingsView/TwitchCheck",
|
||||
"TwitchSettingsView/StatusContainer/CheckConnectionButton",
|
||||
];
|
||||
|
||||
return nodes;
|
||||
|
||||
func _on_Settings_tree_exited():
|
||||
pass;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func RemoveHover():
|
||||
var nodes = GetNodes();
|
||||
for i in nodes:
|
||||
var node = get_node(i);
|
||||
if node is Button:
|
||||
onButtonHoverOff(node);
|
||||
|
||||
|
||||
|
||||
func _on_ReturnButton_pressed():
|
||||
BackToAllView();
|
||||
|
||||
func _on_ApplyButton_pressed():
|
||||
|
||||
SettingsSingleton.SaveSettings();
|
||||
|
||||
func _on_BackToMenuButton_pressed():
|
||||
RemoveHover()
|
||||
emit_signal("BackFromSettings");
|
||||
|
||||
func _on_ReturnToGameButton_pressed():
|
||||
RemoveHover()
|
||||
emit_signal("ReturnToGame");
|
||||
|
||||
func _on_VideoButton_pressed():
|
||||
videoSettingsView.visible = true;
|
||||
audioSettingsView.visible = false;
|
||||
textSettingsView.visible = false;
|
||||
languageSettingsView.visible = false;
|
||||
twitchSettingsView.visible = false;
|
||||
|
||||
func _on_AudioButton_pressed():
|
||||
videoSettingsView.visible = false;
|
||||
audioSettingsView.visible = true;
|
||||
textSettingsView.visible = false;
|
||||
languageSettingsView.visible = false;
|
||||
twitchSettingsView.visible = false;
|
||||
|
||||
func _on_TextButton_pressed():
|
||||
videoSettingsView.visible = false;
|
||||
audioSettingsView.visible = false;
|
||||
textSettingsView.visible = true;
|
||||
languageSettingsView.visible = false;
|
||||
twitchSettingsView.visible = false;
|
||||
|
||||
func _on_LanguageButton_pressed():
|
||||
videoSettingsView.visible = false;
|
||||
audioSettingsView.visible = false;
|
||||
textSettingsView.visible = false;
|
||||
languageSettingsView.visible = true;
|
||||
twitchSettingsView.visible = false;
|
||||
|
||||
func _on_TwitchButton_pressed():
|
||||
videoSettingsView.visible = false;
|
||||
audioSettingsView.visible = false;
|
||||
textSettingsView.visible = false;
|
||||
languageSettingsView.visible = false;
|
||||
twitchSettingsView.visible = true;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue