using Roy;
using SGModule.DataStorage;
using SGModule.NetKit;

public static partial class DataMgr {
    public static void InitPreferences(string jsonStr) {
        DataManager.Instance.AddSaveCallback(CloudDataSaver.UpdateData);
        var loginModel = LoginKit.Instance.LoginModel;

        // Debug.Log($"barry init Preferences-----0--{loginModel.uid}--{userID}");
        if (loginModel.NewPlayer || loginModel.Uid != UserID.Value) {
            // Debug.Log($"barry init Preferences----1---");

            DataManager.Instance.ClearAllData();
            UserID.Value = loginModel.Uid;
        }

        // ObjectExtensionsTest.AsTestRun();

        // Debug.Log($"barry init Preferences----2---{jsomnStr}");
        DataManager.Instance.ImportFromJson(jsonStr, loginModel.PlayDataVer);

        // UserCoreMgr.Instance.LoadItemData();
        // ItemManager.GetInstance.LoadItemData();
    }
}
