Initial Android commit
This commit is contained in:
commit
1e2b80c13d
8521 changed files with 231475 additions and 0 deletions
174
scripts/InGameLoadSave.gd
Normal file
174
scripts/InGameLoadSave.gd
Normal file
|
@ -0,0 +1,174 @@
|
|||
extends Control
|
||||
|
||||
enum InGameType{
|
||||
Load = 0,
|
||||
Save = 1
|
||||
};
|
||||
|
||||
var slotScene = preload("res://resources/customControls/SaveSlot.tscn");
|
||||
|
||||
var type:int;
|
||||
|
||||
func _ready():
|
||||
Init()
|
||||
|
||||
func Init():
|
||||
|
||||
var paginationContainer = $ButtonsContainer / Pagination;
|
||||
for i in paginationContainer.get_child_count():
|
||||
var btn:Button = paginationContainer.get_child(i);
|
||||
btn.connect("pressed", self, "CreateSlots", [i]);
|
||||
|
||||
|
||||
var backButton = $ButtonsContainer / HBoxContainer / BackToMenu;
|
||||
backButton.text = tr("ui_back_to_game");
|
||||
|
||||
|
||||
var autosave = $ButtonsContainer / HBoxContainer / LoadAutoSave;
|
||||
autosave.text = tr("ui_load_autosave");
|
||||
|
||||
|
||||
$Overwrite / RichTextLabel.bbcode_text = tr("ui_are_you_sure");
|
||||
$Overwrite / ButtonYES.text = tr("ui_yes");
|
||||
$Overwrite / ButtonNO.text = tr("ui_no");
|
||||
|
||||
|
||||
var buttons = [$Overwrite / ButtonYES, $Overwrite / ButtonNO, $ButtonsContainer / HBoxContainer / BackToMenu, $ButtonsContainer / HBoxContainer / LoadAutoSave]
|
||||
|
||||
for i in buttons:
|
||||
i.connect("mouse_entered", self, "_on_button_mouse_entered", [i]);
|
||||
i.connect("mouse_exited", self, "_on_button_mouse_exited", [i]);
|
||||
|
||||
|
||||
func CreateSlots(pageNumber:int):
|
||||
|
||||
var slotsContainer = $LoadGame / VBoxContainer;
|
||||
for i in slotsContainer.get_children():
|
||||
slotsContainer.remove_child(i);
|
||||
|
||||
var slotIndex = pageNumber * 8;
|
||||
|
||||
var slotLocalization = tr("ui_slot")
|
||||
|
||||
for i in 2:
|
||||
var hContainer = HBoxContainer.new();
|
||||
|
||||
hContainer.set("custom_constants/separation", 448);
|
||||
|
||||
for j in 4:
|
||||
slotIndex += 1;
|
||||
var slot = slotScene.instance();
|
||||
var slotname = str("slot", slotIndex);
|
||||
slot.ResizeForInGame();
|
||||
slot.Init(str(slotIndex), str(slotLocalization, " ", slotIndex));
|
||||
if type == InGameType.Load:
|
||||
slot.connect("SlotNameClicked", self, "_LoadSlotPressed", [slotname]);
|
||||
slot.CheckIfDisabled();
|
||||
else :
|
||||
slot.connect("SlotNameClicked", self, "_SaveSlotPressed", [slotname]);
|
||||
slot.Enable();
|
||||
hContainer.add_child(slot);
|
||||
|
||||
slotsContainer.add_child(hContainer);
|
||||
|
||||
|
||||
var paginationContainer = $ButtonsContainer / Pagination;
|
||||
for i in paginationContainer.get_child_count():
|
||||
var button = paginationContainer.get_child(i);
|
||||
if i == pageNumber:
|
||||
button.disabled = true;
|
||||
button._on_Button_mouse_entered();
|
||||
else :
|
||||
button.disabled = false;
|
||||
button._on_Button_mouse_exited();
|
||||
|
||||
func LoadPressed():
|
||||
type = InGameType.Load;
|
||||
$LoadGame / Label.text = tr("ui_ingame_loading");
|
||||
|
||||
$Overwrite.visible = false;
|
||||
$ButtonsContainer / HBoxContainer / LoadAutoSave.visible = true;
|
||||
$LoadGame.visible = true;
|
||||
|
||||
CreateSlots(0);
|
||||
|
||||
func SavePressed():
|
||||
type = InGameType.Save;
|
||||
$LoadGame / Label.text = tr("ui_ingame_saving");
|
||||
|
||||
$Overwrite.visible = false;
|
||||
$ButtonsContainer / HBoxContainer / LoadAutoSave.visible = false;
|
||||
|
||||
$LoadGame.visible = true;
|
||||
|
||||
CreateSlots(0);
|
||||
|
||||
var overwriteSlotName
|
||||
|
||||
func _SaveSlotPressed(slotName):
|
||||
|
||||
var isOverWrite = OverWritesSave(slotName)
|
||||
if not isOverWrite:
|
||||
SaveSlot(slotName);
|
||||
else :
|
||||
overwriteSlotName = slotName;
|
||||
|
||||
$LoadGame.visible = false;
|
||||
$Overwrite.visible = true;
|
||||
|
||||
|
||||
func SaveSlot(slotName):
|
||||
Dialogic.save(slotName)
|
||||
get_parent().get_parent().get_parent().BackFromSaveLoad()
|
||||
var timer = get_tree().create_timer(0.2);
|
||||
yield (timer, "timeout")
|
||||
SceneManagerSingleton.TakeScreenShot(slotName)
|
||||
|
||||
func _LoadSlotPressed(slotName):
|
||||
|
||||
var dialogic = get_tree().root.get_node("Root/Game").get_child(0).get_node("DialogNode")
|
||||
if dialogic.isFastForwarding:
|
||||
SettingsSingleton.SetSkipSeen(true);
|
||||
if dialogic.isAutoRead:
|
||||
SettingsSingleton.SetAutoRead(true);
|
||||
|
||||
var gameNode = get_tree().root.get_node("Root")
|
||||
gameNode.LoadFromGame(slotName)
|
||||
|
||||
func _on_LoadAutoSave_pressed():
|
||||
var gameNode = get_tree().root.get_node("Root")
|
||||
gameNode.LoadFromGame("AutosaveCasual")
|
||||
|
||||
_on_button_mouse_exited($ButtonsContainer / HBoxContainer / LoadAutoSave);
|
||||
|
||||
func _on_BackToMenu_pressed():
|
||||
$Overwrite.visible = false;
|
||||
get_parent().get_parent().get_parent().BackFromSaveLoad()
|
||||
|
||||
_on_button_mouse_exited($ButtonsContainer / HBoxContainer / BackToMenu);
|
||||
|
||||
func OverWritesSave(slotName:String)->bool:
|
||||
var directory = Directory.new();
|
||||
var folderName = str(OS.get_user_data_dir(), "/dialogic/", slotName);
|
||||
return directory.dir_exists(folderName);
|
||||
|
||||
func _on_ButtonYES_pressed():
|
||||
$LoadGame.visible = true;
|
||||
$Overwrite.visible = false;
|
||||
SaveSlot(overwriteSlotName)
|
||||
|
||||
_on_button_mouse_exited($Overwrite / ButtonYES);
|
||||
|
||||
func _on_ButtonNO_pressed():
|
||||
$LoadGame.visible = true;
|
||||
$Overwrite.visible = false;
|
||||
|
||||
_on_button_mouse_exited($Overwrite / ButtonNO);
|
||||
|
||||
func _on_button_mouse_entered(button):
|
||||
button.get("custom_fonts/font").outline_color = Color(213, 55, 29, 255)
|
||||
button.set("custom_colors/font_color", Color(0, 0, 0, 255))
|
||||
|
||||
func _on_button_mouse_exited(button):
|
||||
button.get("custom_fonts/font").outline_color = Color(0, 0, 0, 255)
|
||||
button.set("custom_colors/font_color", Color(213, 55, 29, 255));
|
Loading…
Add table
Add a link
Reference in a new issue