public unsafe static List <WorkshopItem> GetAllWorkshopItems() { if (!_initialized) { return(new List <WorkshopItem>()); } // FIXME: This seems wrong, but the original basically just does this. PublishedFileId_t[] tmp = new PublishedFileId_t[GetNumWorkshopItems()]; SteamUGC.GetSubscribedItems(tmp, (uint)tmp.Length); List <WorkshopItem> list = _.GetList(tmp.Length, i => WorkshopItem.GetItem(tmp[i].m_PublishedFileId)); RequestWorkshopInfo(list); return(list); }
public static void SubscribeAndRestart() { foreach (Mod allMod in (IEnumerable <Mod>)ModLoader.allMods) { allMod.configuration.disabled = true; } if (ConnectionError.joinLobby != null) { UIServerBrowser._selectedLobby = new UIServerBrowser.LobbyData(); UIServerBrowser._selectedLobby.lobby = ConnectionError.joinLobby; string lobbyData = ConnectionError.joinLobby.GetLobbyData("mods"); if (lobbyData != null && lobbyData != "") { string str1 = lobbyData; char[] chArray = new char[1] { '|' }; foreach (string str2 in str1.Split(chArray)) { if (str2 != "LOCAL") { WorkshopItem workshopItem = WorkshopItem.GetItem(Convert.ToUInt64(str2)); UIServerBrowser._selectedLobby.workshopItems.Add(workshopItem); } } } } using (List <WorkshopItem> .Enumerator enumerator = UIServerBrowser._selectedLobby.workshopItems.GetEnumerator()) { while (enumerator.MoveNext()) { WorkshopItem w = enumerator.Current; Mod mod = ModLoader.allMods.FirstOrDefault <Mod>((Func <Mod, bool>)(x => (long)x.configuration.workshopID == (long)w.id)); if (mod != null) { mod.configuration.disabled = false; } Steam.WorkshopSubscribe(w.id); } } Program.commandLine = Program.commandLine + " -downloadmods +connect_lobby " + (object)UIServerBrowser._selectedLobby.lobby.id; ModLoader.DisabledModsChanged(); ModLoader.RestartGame(); }
private unsafe static void OnSendQueryUGCRequest(SteamUGCQueryCompleted_t result, bool ioFailure) { if (!_initialized) { return; } for (uint i = 0; i < result.m_unNumResultsReturned; i++) { SteamUGCDetails_t details; if (SteamUGC.GetQueryUGCResult(result.m_handle, i, out details)) { WorkshopItem item = WorkshopItem.GetItem(details.m_nPublishedFileId.m_PublishedFileId); if (item != null) { WorkshopItemData workshopItemData = new WorkshopItemData(); SteamUGC.GetQueryUGCPreviewURL(result.m_handle, i, out workshopItemData.previewPath, 256); workshopItemData.description = details.m_rgchDescription; workshopItemData.votesUp = (int)details.m_unVotesUp; item.SetDetails(details.m_pchFileName, workshopItemData); } } } SteamUGC.ReleaseQueryUGCRequest(result.m_handle); }
private unsafe void OnSteamUGCQueryCompleted(SteamUGCQueryCompleted_t queryCompleted, bool ioFailure) { UGCQueryHandle_t handle = queryCompleted.m_handle; if (_handle.m_UGCQueryHandle == 0 || ioFailure) { goto Finish; } numResultsTotal = queryCompleted.m_unTotalMatchingResults; uint results = queryCompleted.m_unNumResultsReturned; if (results == 0 || fetchedData == WorkshopQueryData.TotalOnly) { goto Finish; } numResultsFetched += results; for (uint resulti = 0; resulti < results; resulti++) { WorkshopQueryResult result = new WorkshopQueryResult(); SteamUGC.GetQueryUGCPreviewURL(handle, resulti, out result.previewURL, 260); SteamUGCDetails_t ugcDetails; SteamUGC.GetQueryUGCResult(queryCompleted.m_handle, resulti, out ugcDetails); WorkshopQueryResultDetails resultDetails = result.details = new WorkshopQueryResultDetails(); resultDetails.acceptedForUse = ugcDetails.m_bAcceptedForUse; resultDetails.banned = ugcDetails.m_bBanned; resultDetails.title = ugcDetails.m_rgchTitle; resultDetails.description = ugcDetails.m_rgchDescription; resultDetails.steamIDOwner = ugcDetails.m_ulSteamIDOwner; resultDetails.score = ugcDetails.m_flScore; resultDetails.visibility = ugcDetails.m_eVisibility; resultDetails.votesDown = ugcDetails.m_unVotesDown; resultDetails.votesUp = ugcDetails.m_unVotesUp; resultDetails.tags = ugcDetails.m_rgchTags.Split(','); resultDetails.tagsTruncated = ugcDetails.m_bTagsTruncated; resultDetails.timeAddedToUserList = ugcDetails.m_rtimeAddedToUserList; resultDetails.timeCreated = ugcDetails.m_rtimeCreated; resultDetails.timeUpdated = ugcDetails.m_rtimeUpdated; resultDetails.file = ugcDetails.m_hFile.m_UGCHandle; resultDetails.fileName = ugcDetails.m_pchFileName; resultDetails.fileSize = ugcDetails.m_nFileSize; resultDetails.fileType = ugcDetails.m_eFileType; resultDetails.numChildren = ugcDetails.m_unNumChildren; resultDetails.previewFile = ugcDetails.m_hPreviewFile.m_UGCHandle; resultDetails.previewFileSize = ugcDetails.m_nPreviewFileSize; resultDetails.URL = ugcDetails.m_rgchURL; resultDetails.publishedFile = WorkshopItem.GetItem(ugcDetails.m_nPublishedFileId); resultDetails.result = ugcDetails.m_eResult; if ((fetchedData & WorkshopQueryData.Children) != 0) { PublishedFileId_t[] children = new PublishedFileId_t[resultDetails.numChildren]; if (SteamUGC.GetQueryUGCChildren(handle, resulti, children, (uint)children.Length)) { result.fileList = _.GetArray(children, id => WorkshopItem.GetItem(id)); } } if ((fetchedData & WorkshopQueryData.Metadata) != 0) { SteamUGC.GetQueryUGCMetadata(handle, resulti, out result.metadata, 260); } if ((fetchedData & WorkshopQueryData.AdditionalPreviews) != 0) { WorkshopQueryResultAdditionalPreview[] previews = result.additionalPreviews = new WorkshopQueryResultAdditionalPreview[SteamUGC.GetQueryUGCNumAdditionalPreviews(handle, resulti)]; for (uint previewi = 0; previewi < previews.Length; previewi++) { string url; string name; EItemPreviewType type; if (SteamUGC.GetQueryUGCAdditionalPreview(handle, resulti, previewi, out url, 260, out name, 260, out type)) { previews[previewi] = new WorkshopQueryResultAdditionalPreview(type == EItemPreviewType.k_EItemPreviewType_Image, url); } } } if ((fetchedData & WorkshopQueryData.Statistics) != 0) { uint[] stats = result.statistics = new uint[8]; for (WorkshopResultStatistic stat = WorkshopResultStatistic.NumSubscriptions; (int)stat < stats.Length; stat++) { ulong val; if (SteamUGC.GetQueryUGCStatistic(handle, resulti, (EItemStatistic)stat, out val)) { stats[(int)stat] = (uint)val; } } } ResultFetched?.Invoke(this, result); } if (numResultsFetched != numResultsTotal && !justOnePage) { Destroy(); page++; Create(); Request(); return; } Finish: QueryFinished?.Invoke(this); }
public override void Update() { if (this.open) { if (this._doLobbySearch && this._lobbies.Count == 0) { this._lobbies.Clear(); this._doLobbySearch = false; Steam.SearchForLobby((User)null); } if (!this._doLobbySearch && this._lobbies.Count == 0 && Steam.lobbySearchComplete) { int lobbiesFound = Steam.lobbiesFound; List <WorkshopItem> items = new List <WorkshopItem>(); for (int index = 0; index < lobbiesFound; ++index) { Lobby searchLobbyAtIndex = Steam.GetSearchLobbyAtIndex(index); UIServerBrowser.LobbyData lobbyData1 = new UIServerBrowser.LobbyData(); lobbyData1.lobby = searchLobbyAtIndex; string str1 = searchLobbyAtIndex.GetLobbyData("name"); if (str1 == null || str1 == "") { str1 = "DG Lobby"; } lobbyData1.name = str1; lobbyData1.modHash = searchLobbyAtIndex.GetLobbyData("modhash"); lobbyData1.requiredWins = searchLobbyAtIndex.GetLobbyData("requiredwins"); lobbyData1.restsEvery = searchLobbyAtIndex.GetLobbyData("restsevery"); lobbyData1.wallMode = searchLobbyAtIndex.GetLobbyData("wallmode"); lobbyData1.customLevels = searchLobbyAtIndex.GetLobbyData("customLevels"); lobbyData1.version = searchLobbyAtIndex.GetLobbyData("version"); lobbyData1.started = searchLobbyAtIndex.GetLobbyData("started"); lobbyData1.type = searchLobbyAtIndex.GetLobbyData("type"); lobbyData1.numSlots = searchLobbyAtIndex.GetLobbyData("numSlots"); string lobbyData2 = searchLobbyAtIndex.GetLobbyData("mods"); if (lobbyData2 != null && lobbyData2 != "") { string str2 = lobbyData2; char[] chArray = new char[1] { '|' }; foreach (string str3 in str2.Split(chArray)) { if (str3 == "LOCAL") { lobbyData1.hasLocalMods = true; } else { WorkshopItem workshopItem = WorkshopItem.GetItem(Convert.ToUInt64(str3)); items.Add(workshopItem); lobbyData1.workshopItems.Add(workshopItem); } } } lobbyData1.maxPlayers = searchLobbyAtIndex.GetLobbyData("maxplayers"); this._lobbies.Add(lobbyData1); } if (items.Count > 0) { Steam.RequestWorkshopInfo(items); } this._doLobbySearch = true; } } if (this._pressWait > 0) { --this._pressWait; } if (this._downloadModsMenu.open) { this._downloadModsMenu.DoUpdate(); if (!UIMenu.globalUILock && (Input.Pressed("QUACK") || Keyboard.Pressed(Keys.Escape))) { this._downloadModsMenu.Close(); this.Open(); return; } } else if (this.open) { if (this._gamepadMode) { if (this._hoverIndex < 0) { this._hoverIndex = 0; } } else { this._hoverIndex = -1; for (int index = 0; index < this._maxLobbiesToShow && this._scrollItemOffset + index < this._lobbies.Count; ++index) { if (new Rectangle((float)(int)(this._box.x - this._box.halfWidth), (float)(int)(this._box.y - this._box.halfHeight + (float)(36 * index)), (float)((int)this._box.width - 14), 36f).Contains(Mouse.position)) { this._hoverIndex = this._scrollItemOffset + index; break; } } } if (this._hoverIndex != -1) { if (Input.Pressed("SHOOT")) { this.RefreshLobbySearch(); SFX.Play("rockHitGround", 0.8f); } if (this._lobbies.Count > 0) { UIServerBrowser._selectedLobby = this._lobbies[this._hoverIndex]; if (Input.Pressed("SELECT") && this._pressWait == 0 && this._gamepadMode || !this._gamepadMode && Mouse.left == InputState.Pressed) { if (!UIServerBrowser._selectedLobby.canJoin) { SFX.Play("consoleError"); } else { SFX.Play("consoleSelect"); if (UIServerBrowser._selectedLobby.workshopItems.Count == 0 || UIServerBrowser._selectedLobby.hasFirstMod && UIServerBrowser._selectedLobby.hasRestOfMods) { MonoMain.pauseMenu = (UIComponent)null; MonoMain.closeMenuUpdate.Clear(); Level.current = (Level) new JoinServer(UIServerBrowser._selectedLobby.lobby.id); return; } new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._downloadModsMenu).Activate(); } } } } else { UIServerBrowser._selectedLobby = (UIServerBrowser.LobbyData)null; } if (this._gamepadMode) { this._draggingScrollbar = false; if (Input.Pressed("DOWN")) { ++this._hoverIndex; } else if (Input.Pressed("UP")) { --this._hoverIndex; } if (Input.Pressed("STRAFE")) { this._hoverIndex -= 10; } else if (Input.Pressed("RAGDOLL")) { this._hoverIndex += 10; } if (this._hoverIndex < 0) { this._hoverIndex = 0; } if ((double)(this._oldPos - Mouse.positionScreen).lengthSq > 200.0) { this._gamepadMode = false; } } else { if (!this._draggingScrollbar) { if (Mouse.left == InputState.Pressed && this.ScrollBarBox().Contains(Mouse.position)) { this._draggingScrollbar = true; this._oldPos = Mouse.position; } if ((double)Mouse.scroll > 0.0) { this._scrollItemOffset += 5; this._hoverIndex += 5; } else if ((double)Mouse.scroll < 0.0) { this._scrollItemOffset -= 5; this._hoverIndex -= 5; if (this._hoverIndex < 0) { this._hoverIndex = 0; } } } else if (Mouse.left != InputState.Down) { this._draggingScrollbar = false; } else { Vec2 vec2 = Mouse.position - this._oldPos; this._oldPos = Mouse.position; this.scrollBarOffset += (int)vec2.y; if (this.scrollBarOffset > this.scrollBarScrollableHeight) { this.scrollBarOffset = this.scrollBarScrollableHeight; } else if (this.scrollBarOffset < 0) { this.scrollBarOffset = 0; } this._scrollItemOffset = (int)((double)(this._lobbies.Count - this._maxLobbiesToShow) * (double)((float)this.scrollBarOffset / (float)this.scrollBarScrollableHeight)); } if (Input.Pressed("ANY")) { this._gamepadMode = true; this._oldPos = Mouse.positionScreen; } } if (this._scrollItemOffset < 0) { this._scrollItemOffset = 0; } else if (this._scrollItemOffset > Math.Max(0, this._lobbies.Count - this._maxLobbiesToShow)) { this._scrollItemOffset = Math.Max(0, this._lobbies.Count - this._maxLobbiesToShow); } if (this._hoverIndex >= this._lobbies.Count) { this._hoverIndex = this._lobbies.Count - 1; } else if (this._hoverIndex >= this._scrollItemOffset + this._maxLobbiesToShow) { this._scrollItemOffset += this._hoverIndex - (this._scrollItemOffset + this._maxLobbiesToShow) + 1; } else if (this._hoverIndex >= 0 && this._hoverIndex < this._scrollItemOffset) { this._scrollItemOffset -= this._scrollItemOffset - this._hoverIndex; } this.scrollBarOffset = this._scrollItemOffset == 0 ? 0 : (int)Lerp.FloatSmooth(0.0f, (float)this.scrollBarScrollableHeight, (float)this._scrollItemOffset / (float)(this._lobbies.Count - this._maxLobbiesToShow)); if (!Editor.hoverTextBox && !UIMenu.globalUILock && (Input.Pressed("QUACK") || Keyboard.Pressed(Keys.Escape))) { new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._openOnClose).Activate(); return; } } if (this._showingMenu) { HUD.CloseAllCorners(); this._showingMenu = false; } base.Update(); }