Exemple #1
0
    internal static void OnFileSharedEvent(object sender, EventArgs args)
    {
        SteamFileItem item = (SteamFileItem)sender;

        if (!item._SendToServer)
        {
            return;
        }
        if (null != PlayerNetwork.mainPlayer)
        {
            VCIsoData da = new VCIsoData();
            da.Import(item._Data, new VCIsoOption(false));
            var components = from component in da.m_Components
                             where VCUtils.IsSeat(component.m_Type)
                             select(int) component.m_Type;
            if (components.Count() > 0)
            {
                NetworkManager.SyncServer(EPacketType.PT_Common_WorkshopShared, item.FileID, item.RealFileName, item.HashCode, item._free, item.instanceId, true, components.ToArray());
            }
            else
            {
                NetworkManager.SyncServer(EPacketType.PT_Common_WorkshopShared, item.FileID, item.RealFileName, item.HashCode, item._free, item.instanceId, false);
            }
        }


        string fielName = VCConfig.s_CreationNetCachePath + item.HashCode.ToString("X").PadLeft(16, '0') + VCConfig.s_CreationNetCacheFileExt;

        using (FileStream fs = new FileStream(fielName, FileMode.Create, FileAccess.Write, FileShare.Read))
        {
            fs.Write(item._Data, 0, item._Data.Length);
        }

        _SteamItems[item.HashCode] = item.FileName;
    }
Exemple #2
0
    internal static void OnFilePublishEvent(object sender, EventArgs args)
    {
        SteamFileItem item = (SteamFileItem)sender;

        if (item != null)
        {
            UIWorkShopCtrl.PublishFinishCellBack(item.ID, item.PublishID, item.HashCode);
        }
    }
Exemple #3
0
 public static void SendCacheIso(ulong hash)
 {
     if (SendIsoCacheMgr.ContainsKey(hash))
     {
         SendIsoCache  iso  = SendIsoCacheMgr[hash];
         SteamFileItem item = new SteamFileItem(iso.callBackSteamUploadResult, iso.name, iso.desc, iso.preData, iso.data, iso.hash, iso.tags, iso.bPublish, iso.sendToServer, iso.id, 0, true);
         item.StartSend();
         RemoveIsoCache(iso);
     }
 }
Exemple #4
0
    internal static void SendFile(SteamUploadEventHandler callBackSteamUploadResult, string name, string desc, byte[] preData, byte[] data, string[] tags, bool sendToServer = true, int id = -1, ulong fileId = 0, bool free = false)
    {
        ulong hash = CRC64.Compute(data);
        bool  ret  = false;

        try
        {
            if (string.IsNullOrEmpty(name))
            {
                VCEMsgBox.Show(VCEMsgBoxType.EXPORT_EMPTY_NAME);
                LogManager.Error("File name cannot be null.");
                return;
            }
            if (!SteamUser.BLoggedOn())
            {
                LogManager.Error("log back in steam...");
                return;
            }

            bool bPublish = !sendToServer;
            if (SteamRemoteStorage.FileExists(hash.ToString() + "_preview"))
            {            //file exist,don't publish it;
            }

            if (!SteamRemoteStorage.IsCloudEnabledForAccount())
            {
                throw new Exception("Account cloud disabled.");
            }

            if (!SteamRemoteStorage.IsCloudEnabledForApp())
            {
                throw new Exception("App cloud disabled.");
            }
            if (!bPublish)
            {
                SteamFileItem item = new SteamFileItem(callBackSteamUploadResult, name, desc, preData, data, hash, tags, bPublish, sendToServer, id, fileId, free);
                item.StartSend();
            }
            else
            {
                SendIsoCache iso = new SendIsoCache();
                iso.id           = id;
                iso.hash         = hash;
                iso.name         = name;
                iso.preData      = preData;
                iso.sendToServer = sendToServer;
                iso.tags         = tags;
                iso.data         = data;
                iso.desc         = desc;
                iso.callBackSteamUploadResult = callBackSteamUploadResult;
                iso.bPublish = bPublish;
                if (AddToIsoCache(iso))
                {
                    LobbyInterface.LobbyRPC(ELobbyMsgType.UploadISO, hash, SteamMgr.steamId.m_SteamID);
                }
                else
                {
                    return;
                }
            }

            VCEMsgBox.Show(VCEMsgBoxType.EXPORT_NETWORK);
            ret = true;
        }
        catch (Exception e)
        {
            VCEMsgBox.Show(VCEMsgBoxType.EXPORT_NETWORK_FAILED);
            Debug.LogWarning("workshop error :" + e.Message);
            ToolTipsMgr.ShowText(e.Message);
        }
        finally
        {
            if (!ret && callBackSteamUploadResult != null)
            {
                callBackSteamUploadResult(id, false, hash);
            }
        }
    }