Esempio n. 1
0
 public void StoreData(String file, Godot.Collections.Dictionary save)
 {
     Godot.File databaseFile = new Godot.File();
     databaseFile.Open("res://databases/" + file + ".json", Godot.File.ModeFlags.Write);
     databaseFile.StoreString(JSON.Print(save));
     databaseFile.Close();
 }
Esempio n. 2
0
 public void saveDBParams()
 {
     Godot.File file = new Godot.File();
     try{
         file.OpenEncryptedWithPass("user://dbFile.dat", File.ModeFlags.Write, OS.GetUniqueId());
         //file.Open("user://dbFile.dat",File.ModeFlags.Write);
         file.StoreString(database.GetConnectionString());
         file.Close();
     }
     catch {}
 }
    public void _on_Save_pressed()
    {
        var playerName = GetNode <TextEdit>("TextEdit").Text;
        var saveGame   = new Godot.File();

        if (saveGame.FileExists(SCORE_FILE_PATH))
        {
            saveGame.Open("user://score.save", Godot.File.ModeFlags.ReadWrite);
            string[] content = saveGame.GetAsText().Split("\n");

            //sprawdza czy gracz już istnieje na liście
            //jeśli znajdzie gracza i nowy wynik jest lepszy to go nadpisuje
            for (int i = 0; i < content.Length; i++)
            {
                string[] separated = content[i].Split(':');
                if (separated[0] == playerName)
                {
                    found = true;
                    if (uint.Parse(separated[1]) < uint.Parse(score))
                    {
                        content[i] = $"{playerName}:{score}";
                        saveGame.StoreString($"{string.Join("\n", content)}");
                        break;
                    }
                }
            }
            if (!found)
            {
                saveGame.StoreString($"{string.Join("\n", content)}\n{playerName}:{(score != "" ? score : "0")}");
            }
        }
        else
        {
            saveGame.Open("user://score.save", Godot.File.ModeFlags.Write);
            saveGame.StoreString($"{playerName}:{(score != "" ? score : "0")}");
        }
        saveGame.Close();

        GetTree().ChangeScene("res://scene/TitleScreen.tscn");
    }
Esempio n. 4
0
    public void save_state_to_file(Godot.File file)
    {
        if (story == null)
        {
            PushNullStoryError();
            return;
        }

        if (file.IsOpen())
        {
            file.StoreString(get_state());
        }
    }
Esempio n. 5
0
    public void save_settings()
    {
        var file = new Godot.File();

        file.Open(_save_path, File.ModeFlags.Write);
        var data = new Dictionary();

        data["render_distance"] = render_distance;
        data["fog_enabled"]     = fog_enabled;
        String text = JSON.Print(data);

        file.StoreString(text);
        file.Close();
    }