Beispiel #1
0
 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();
 }