public override void Update() { if (this.open) { if (!UIMenu.globalUILock && (Input.Pressed("QUACK") || Keyboard.Pressed(Keys.Escape))) { new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._confirmMenu).Activate(); return; } if (Input.uiDevicesHaveChanged) { this.SwitchPlayerProfile(); Input.uiDevicesHaveChanged = false; } } if (this._controlBox.selection > 0 && this._controlBox.selection < 17) { if (!this._showingMenu && this.inputConfigType < this.inputMaps.Count && (this.inputMaps[this.inputConfigType].deviceName != "KEYBOARD P1" && this.inputMaps[this.inputConfigType].deviceName != "KEYBOARD P2")) { HUD.AddCornerControl(HUDCorner.BottomLeft, "STYLE@GRAB@"); this._showingMenu = true; } } else if (this._showingMenu) { HUD.CloseAllCorners(); this._showingMenu = false; } base.Update(); }
public override void Update() { if (!this.opened) { return; } this._textbox.Update(); if (this._textbox.confirmed) { this._textbox.confirmed = false; this.result = this._textbox.text; this.opened = false; Editor.skipFrame = true; Editor.PopFocus(); Editor.enteringText = false; } if (!Keyboard.Pressed(Keys.Escape) && Mouse.right != InputState.Pressed && !Input.Pressed("QUACK")) { return; } this.result = this._default; this.opened = false; Editor.PopFocus(); Editor.skipFrame = true; Editor.enteringText = false; }
public void Update(GameTime gt) { doLobbyStuff(); if (Level.current?.initialized != true) { return; } if (Level.current != prevLevel) { LevelChange(); } prevLevel = Level.current; var profiles = ActiveProfiles.Where(x => x.duck != null && x.team != null); foreach (var profile in profiles) { SpriteMap teamHat = profile?.team?.hat, previousHat = null; if (teamHat == null) { continue; } if (!pHats.TryGetValue(profile, out previousHat) || previousHat != teamHat) { HatChange(profile); } } pHats = profiles.ToDictionary(profile => profile, profile => profile?.team?.hat); DuckEvents.Update(); foreach (var kvp in ActiveReskins) { var duck = kvp.Key.duck; if (duck == null) { continue; } var skin = kvp.Value; skin.Update(duck); var persona = kvp.Key.persona; var hat = duck.hat as TeamHat; if (hat != null && hat.team == duck.team) { removeHat(duck); } if (persona.sprite.texture.textureName != "RESKIN" || Keyboard.Pressed(Keys.F6) || persona.sprite.texture.IsDisposed) { skin.Apply(duck); } } }
public override void Update() { if (!this.opened || this._dialog.opened || (this._deleteDialog.opened || this._overwriteDialog.opened) || this._opening) { this._opening = false; foreach (ContextMenu contextMenu in this._items) { contextMenu.disabled = true; } } else { bool flag = false; foreach (ContextMenu contextMenu in this._items) { contextMenu.disabled = false; if (!flag && contextMenu.hover) { flag = true; string str = ""; int startIndex = this._currentDirectory.IndexOf(this._rootFolder); if (startIndex != -1) { str = this._currentDirectory.Remove(startIndex, this._rootFolder.Length); } if (str != "" && !str.EndsWith("/")) { str += "/"; } if (str.StartsWith("/")) { str = str.Substring(1, str.Length - 1); } string path = str + contextMenu.data; if (this._prevPreviewPath != path) { if (path.EndsWith(".lev")) { if (this._preview == null || !(this._preview is RenderTarget2D)) { this._preview = (Tex2D) new RenderTarget2D(320, 200); } this._preview = (Tex2D)Content.GeneratePreview(path.Substring(0, path.Length - 4), this._preview as RenderTarget2D); } else if (path.EndsWith(".png")) { Texture2D texture2D = ContentPack.LoadTexture2D(this._currentDirectory + "/" + Path.GetFileName(path)); this._preview = texture2D == null ? Content.invalidTexture : (this._type != ContextFileType.Block && this._type != ContextFileType.Background && this._type != ContextFileType.Platform || texture2D.Width == 128 && texture2D.Height == 128 ? (this._type != ContextFileType.Parallax || texture2D.Width == 320 && texture2D.Height == 240 ? (this._type != ContextFileType.ArcadeStyle || texture2D.Width == 27 && texture2D.Height == 34 || texture2D.Width == 54 && texture2D.Height == 68 ? (Tex2D)texture2D : this._badArcade.texture) : this._badParallax.texture) : this._badTileset.texture); } else { this._previewSprite = (Sprite)null; this._prevPreviewPath = (string)null; } this._previewSprite = new Sprite(this._preview); if (this._type == ContextFileType.Block || this._type == ContextFileType.Background || (this._type == ContextFileType.Platform || this._type == ContextFileType.Parallax)) { this._previewSprite.scale = new Vec2(2f, 2f); } this._prevPreviewPath = path; } } } if (!flag && this._type == ContextFileType.ArcadeStyle) { this._preview = this._badArcade.texture; this._previewSprite = new Sprite(this._preview); this._prevPreviewPath = (string)null; } Editor.lockInput = (ContextMenu)this; base.Update(); this._scrollWait = Lerp.Float(this._scrollWait, 0.0f, 0.2f); if (this._dialog.result != null && this._dialog.result != "") { Editor current = Level.current as Editor; current._guid = Guid.NewGuid().ToString(); Editor.ResetWorkshopData(); current.DoSave(this._currentDirectory + "/" + this._dialog.result); this._dialog.result = ""; this.Close(); } if (!this._overwriteDialog.opened && this._doOverwriteDialog) { this._doOverwriteDialog = false; if (this._overwriteDialog.result) { (Level.current as Editor).DoSave(this._currentDirectory + "/" + this._overwriteName); this._overwriteDialog.result = false; this._overwriteName = ""; this.Close(); } } if (!this._deleteDialog.opened && this._doDeleteDialog) { this._doDeleteDialog = false; if (this._deleteDialog.result) { foreach (ContextMenu contextMenu in this._items) { if (contextMenu.hover) { Editor.Delete(this._currentDirectory + "/" + contextMenu.text); break; } } this.ClearItems(); this.SetDirectory(this._currentDirectory); } } if (Keyboard.Pressed(Keys.Escape) || Mouse.right == InputState.Pressed || Input.Pressed("QUACK")) { this.Close(); } if (!this._selectLevels && Input.Pressed("GRAB")) { this._deleteDialog.Open("CONFIRM DELETE"); Editor.lockInput = (ContextMenu)this._deleteDialog; this._doDeleteDialog = true; this._deleteDialog.result = false; } else { if (Input.Pressed("LEFT")) { this._selectedIndex -= this._maxItems; } else if (Input.Pressed("RIGHT")) { this._selectedIndex += this._maxItems; } this._selectedIndex = Maths.Clamp(this._selectedIndex, 0, this._items.Count - 1); if (this._items.Count <= this._maxItems) { return; } float num1 = 1f / (float)(this._items.Count - this._maxItems); if ((double)Mouse.scroll != 0.0) { this._scrollPosition += (float)Math.Sign(Mouse.scroll) * num1; if ((double)this._scrollPosition > 1.0) { this._scrollPosition = 1f; } if ((double)this._scrollPosition < 0.0) { this._scrollPosition = 0.0f; } } int num2 = (int)Math.Round(((double)(this._items.Count - this._maxItems) - 1.0) * (double)this._scrollPosition); int num3 = 0; int num4 = 0; for (int index = 0; index < this._items.Count; ++index) { if (this._items[index].hover) { num4 = index; break; } } if (Editor.gamepadMode) { if (num4 > num2 + this._maxItems) { this._scrollPosition += (float)(num4 - (num2 + this._maxItems)) * num1; } else if (num4 < num2) { this._scrollPosition -= (float)(num2 - num4) * num1; } } for (int index = 0; index < this._items.Count; ++index) { this._items[index].disabled = false; if (index < num2 || index > num2 + this._maxItems) { this._items[index].visible = false; this._items[index].hover = false; } else { ContextMenu contextMenu = this._items[index]; this._items[index].visible = true; this._items[index].position = new Vec2(this._items[index].position.x, (float)((double)this.y + 3.0 + (double)num3 * (double)this._items[index].itemSize.y)); ++num3; } } } } }
public override void Update() { if (this._testMode) { this._wait += Maths.IncFrameTimer(); if (Keyboard.Pressed(Keys.F5) || (double)this._wait > 0.1) { this._wait = 0.0f; try { this._tie = new SpriteMap((Tex2D)ContentPack.LoadTexture2D("tieTest.png"), 64, 64); this._tie.center = new Vec2(26f, 27f); } catch (Exception ex) { } } } DuckGame.Graphics.fadeAdd = Lerp.Float(DuckGame.Graphics.fadeAdd, 0.0f, 0.01f); if (Main.isDemo && this._skip && !this._firedSkipLogic) { this._firedSkipLogic = true; Vote.CloseVoting(); HUD.CloseAllCorners(); this.DoSkip(); } if ((double)DuckGame.Graphics.fade > 0.990000009536743 && !this._skip && Vote.Passed(VoteType.Skip)) { this._skip = true; } if (this._talker.finished || !HighlightLevel._cancelSkip && this._skip && !Main.isDemo) { this._done -= 0.04f; } DuckGame.Graphics.fade = Lerp.Float(DuckGame.Graphics.fade, (double)this._done < 0.0 ? 0.0f : 1f, 0.02f); if ((double)DuckGame.Graphics.fade < 0.00999999977648258 && (this._talker.finished || this._skip)) { if (this._endOfHighlights || this._skip) { Vote.CloseVoting(); Level.current = (Level) new RockScoreboard(RockScoreboard.returnLevel, ScoreBoardMode.ShowWinner, true); } else { Level.current = (Level) new HighlightPlayback(4); } } if (this._state == TVState.ShowPedestals) { this._waitZoom -= 0.008f; if ((double)this._waitZoom < 0.00999999977648258) { this._waitZoom = 0.0f; this._desiredState = TVState.ShowNewscaster; } } if (this._state == TVState.ShowHotness && this._hotness.ready) { this._talker.Resume(); } if (this._state == TVState.ShowInterview) { this._interviewWait -= 0.02f; if ((double)this._interviewWait < 0.0 && !this._askedQuestion) { this._talker.InsertLine(Script.winner() + "! To what do you attribute your success?", this._interviewIndex); this._talker.Resume(); this._askedQuestion = true; } } this._cameraOffset.x = Lerp.Float(this._cameraOffset.x, HighlightLevel._image != null ? 20f : 0.0f, 2f); this._talker.active = this._talker.visible = this._state != TVState.ShowPedestals; if (this._state == this._desiredState) { return; } this._talker.active = false; this._transition.PlaySwipe(); if (!this._transition.doTransition) { return; } this._state = this._desiredState; }
public override void DoUpdate() { this.lefpres = Mouse.left == InputState.Pressed; List <DCLine> dcLineList = (List <DCLine>)null; lock (DevConsole.debuggerLines) { dcLineList = DevConsole.debuggerLines; DevConsole.debuggerLines = new List <DCLine>(); } for (int index1 = 0; index1 < 4; ++index1) { if (index1 >= NetworkDebugger._instances.Count || !NetworkDebugger._instances[index1].active) { if (index1 <= NetworkDebugger._instances.Count) { int init = -1; InputProfile inputProfile1 = (InputProfile)null; foreach (InputProfile defaultProfile in InputProfile.defaultProfiles) { if (defaultProfile.Pressed("START")) { foreach (InputProfile inputProfile2 in NetworkDebugger.inputProfiles) { if (defaultProfile == inputProfile2) { break; } } for (int index2 = 0; index2 < 4; ++index2) { if (NetworkDebugger.inputProfiles[index2].name == "") { bool flag = false; foreach (NetDebugInterface netDebugInterface in NetworkDebugger._interfaces) { if (netDebugInterface.visible) { flag = true; break; } } if (!flag) { init = index1; inputProfile1 = defaultProfile; } NetworkDebugger.inputProfiles[index2] = defaultProfile; break; } } } } if (init != -1) { this.CreateInstance(init, false); NetworkDebugger._instances[index1].ipro = inputProfile1; } } } else { NetworkInstance instance = NetworkDebugger._instances[index1]; NetworkDebugger._networkDrawingIndex = index1; this.LockInstance(instance); float volume = SFX.volume; if (NetworkDebugger.Mute(NetworkDebugger._networkDrawingIndex)) { SFX.volume = 0.0f; } InputProfile.Update(); foreach (DCLine dcLine in dcLineList) { if (dcLine.threadIndex == index1) { DevConsole.core.lines.Enqueue(dcLine); } } DevConsole.Update(); Network.PreUpdate(); FireManager.Update(); Level.UpdateLevelChange(); Level.UpdateCurrentLevel(); MonoMain.UpdatePauseMenu(); int index2 = 0; foreach (NetDebugInterface netDebugInterface in NetworkDebugger._interfaces) { MonoMain.instance.IsMouseVisible = true; if (index2 == index1 && index2 < NetworkDebugger._instances.Count) { netDebugInterface.Update(NetworkDebugger._instances[index2].network); } ++index2; } Network.PostUpdate(); if (DuckNetwork.status == DuckNetStatus.Disconnected) { NetworkDebugger._instances[index1].active = false; foreach (Profile profile in NetworkDebugger._instances[index1].duckNetworkCore.profiles) { for (int index3 = 0; index3 < 4; ++index3) { if (NetworkDebugger.inputProfiles[index3] == profile.inputProfile || NetworkDebugger.inputProfiles[index3] == NetworkDebugger._instances[index1].ipro) { NetworkDebugger.inputProfiles[index3] = new InputProfile(); } } } } SFX.volume = volume; this.UnlockInstance(); } } if (!Keyboard.Pressed(Keys.F11)) { return; } foreach (NetworkInstance instance in NetworkDebugger._instances) { instance.network.core.ForcefulTermination(); } Network.activeNetwork.core.ForcefulTermination(); NetworkDebugger._instances.Clear(); NetworkDebugger.inputProfiles.Clear(); Level.current = (Level) new NetworkDebugger(); }
public override void Update() { if (this._pressWait > 0) { --this._pressWait; } if (this._editModMenu.open) { if (!UIMenu.globalUILock && (Input.Pressed("QUACK") || Keyboard.Pressed(Keys.Escape))) { this._editModMenu.Close(); this.Open(); return; } } else if (this.open) { if (this._transferItem != null && !this._needsUpdateNotes) { if (!this._transferring) { if (this._transferItem.result == SteamResult.OK) { WorkshopItemData dat = new WorkshopItemData(); if (this._selectedMod.configuration.workshopID == 0UL) { this._selectedMod.configuration.SetWorkshopID(this._transferItem.id); dat.name = this._selectedMod.configuration.displayName; dat.description = this._selectedMod.configuration.description; dat.visibility = RemoteStoragePublishedFileVisibility.Private; dat.tags = new List <string>(); dat.tags.Add("Mod"); } else { dat.changeNotes = this._updateTextBox.text; } string pathString = this._selectedMod.configuration.directory + "/content/"; DuckFile.CreatePath(pathString); string path1 = pathString + "screenshot.png"; if (!File.Exists(path1)) { File.Delete(path1); Tex2D screenshot = this._selectedMod.screenshot; Stream stream = (Stream)DuckFile.Create(path1); ((Texture2D)screenshot.nativeObject).SaveAsPng(stream, screenshot.width, screenshot.height); stream.Dispose(); } dat.previewPath = path1; string str = DuckFile.workshopDirectory + (object)this._transferItem.id + "/content"; if (Directory.Exists(str)) { Directory.Delete(str, true); } DuckFile.CreatePath(str); UIModManagement.DirectoryCopy(this._selectedMod.configuration.directory, str + "/" + this._selectedMod.configuration.name, true); if (Directory.Exists(str + this._selectedMod.configuration.name + "/build")) { Directory.Delete(str + this._selectedMod.configuration.name + "/build", true); } if (Directory.Exists(str + this._selectedMod.configuration.name + "/.vs")) { Directory.Delete(str + this._selectedMod.configuration.name + "/.vs", true); } if (File.Exists(str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.dll")) { string path2 = str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.dll"; File.SetAttributes(path2, FileAttributes.Normal); File.Delete(path2); } if (File.Exists(str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.hash")) { string path2 = str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.hash"; File.SetAttributes(path2, FileAttributes.Normal); File.Delete(path2); } dat.contentFolder = str; this._transferItem.ApplyWorkshopData(dat); if (this._transferItem.needsLegal) { Steam.ShowWorkshopLegalAgreement("312530"); } this._transferring = true; this._transferItem.ResetProcessing(); } } else if (this._transferItem.finishedProcessing) { Steam.OverlayOpenURL("http://steamcommunity.com/sharedfiles/filedetails/?id=" + (object)this._transferItem.id); Directory.Delete(DuckFile.workshopDirectory + (object)this._transferItem.id + "/", true); this._transferItem.ResetProcessing(); this._transferItem = (WorkshopItem)null; this._transferring = false; } base.Update(); return; } if (this._gamepadMode) { if (this._hoverIndex < 0) { this._hoverIndex = 0; } } else { this._hoverIndex = -1; for (int index = 0; index < this._maxModsToShow && this._scrollItemOffset + index < this._mods.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._transferItem != null) { if (this._updateTextBox != null) { Editor.hoverTextBox = false; this._updateTextBox.position = new Vec2((float)((double)this._box.x - (double)this._box.halfWidth + 16.0), (float)((double)this._box.y - (double)this._box.halfHeight + 48.0)); this._updateTextBox.size = new Vec2(this._box.width - 32f, this._box.height - 80f); this._updateTextBox._maxLines = (int)((double)this._updateTextBox.size.y / (double)this._fancyFont.characterHeight); this._updateTextBox.Update(); float stringWidth = DuckGame.Graphics.GetStringWidth(this._updateButtonText, scale: 2f); float height = DuckGame.Graphics.GetStringHeight(this._updateButtonText) * 2f; this._updateButton = new Rectangle(this._box.x - stringWidth / 2f, (float)((double)this._box.y + (double)this._box.halfHeight - 24.0), stringWidth, height); if (this._updateButton.Contains(Mouse.position) && Mouse.left == InputState.Pressed) { this._needsUpdateNotes = false; this._updateTextBox.LoseFocus(); } else if (Keyboard.Pressed(Keys.Escape)) { this._needsUpdateNotes = false; this._transferItem = (WorkshopItem)null; this._updateTextBox.LoseFocus(); new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._editModMenu).Activate(); return; } } } else if (this._hoverIndex != -1) { this._selectedMod = this._mods[this._hoverIndex]; if (Input.Pressed("SHOOT")) { if (this._selectedMod != null && this._selectedMod.configuration != null) { if (this._selectedMod.configuration.disabled) { this._selectedMod.configuration.Enable(); } else { this._selectedMod.configuration.Disable(); } this.modsChanged = true; SFX.Play("rockHitGround", 0.8f); } } else if (Input.Pressed("SELECT") && this._pressWait == 0 && this._gamepadMode || !this._gamepadMode && Mouse.left == InputState.Pressed) { if (this._selectedMod != null) { this._editModMenu.title = this._selectedMod.configuration.loaded ? "|YELLOW|" + this._selectedMod.configuration.displayName : "|YELLOW|" + this._selectedMod.configuration.name; this._editModMenu.Remove((UIComponent)this._deleteOrUnsubItem); this._editModMenu.Remove((UIComponent)this._uploadItem); this._editModMenu.Remove((UIComponent)this._visitItem); if (!this._selectedMod.configuration.isWorkshop && this._selectedMod.configuration.loaded) { this._uploadItem.text = this._selectedMod.configuration.workshopID == 0UL ? "UPLOAD" : "UPDATE"; this._editModMenu.Insert((UIComponent)this._uploadItem, 1, true); } if (!this._selectedMod.configuration.isWorkshop && !this._selectedMod.configuration.loaded) { this._deleteOrUnsubItem.text = "DELETE"; this._editModMenu.Insert((UIComponent)this._deleteOrUnsubItem, 1, true); } else if (this._selectedMod.configuration.isWorkshop) { this._deleteOrUnsubItem.text = "UNSUBSCRIBE"; this._editModMenu.Insert((UIComponent)this._deleteOrUnsubItem, 1, true); } if (this._selectedMod.configuration.isWorkshop) { this._editModMenu.Insert((UIComponent)this._visitItem, 1, true); } this._disableOrEnableItem.text = this._selectedMod.configuration.disabled ? "ENABLE" : "DISABLE"; this._editModMenu.dirty = true; SFX.Play("rockHitGround", 0.8f); new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._editModMenu).Activate(); return; } Steam.OverlayOpenURL("http://steamcommunity.com/workshop/browse/?appid=312530&searchtext=&childpublishedfileid=0&browsesort=trend§ion=readytouseitems&requiredtags%5B%5D=Mod"); } } else { this._selectedMod = (Mod)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._mods.Count - this._maxModsToShow) * (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._mods.Count - this._maxModsToShow)) { this._scrollItemOffset = Math.Max(0, this._mods.Count - this._maxModsToShow); } if (this._hoverIndex >= this._mods.Count) { this._hoverIndex = this._mods.Count - 1; } else if (this._hoverIndex >= this._scrollItemOffset + this._maxModsToShow) { this._scrollItemOffset += this._hoverIndex - (this._scrollItemOffset + this._maxModsToShow) + 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._mods.Count - this._maxModsToShow)); if (!Editor.hoverTextBox && !UIMenu.globalUILock && (Input.Pressed("QUACK") || Keyboard.Pressed(Keys.Escape))) { if (this.modsChanged) { this.Close(); MonoMain.pauseMenu = DuckNetwork.OpenModsRestartWindow(this._openOnClose); } else { new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._openOnClose).Activate(); } this.modsChanged = false; return; } } if (this._showingMenu) { HUD.CloseAllCorners(); this._showingMenu = false; } base.Update(); }
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(); }