public void PositionItems() { int num1 = 0; int num2 = 0; foreach (LSItem lsItem in this._items) { if (num1 >= this._topIndex + this._maxItems || num1 < this._topIndex) { lsItem.visible = false; ++num1; } else { lsItem.visible = true; lsItem.x = this._leftPos; lsItem.y = this._topPos + (float)(num2 * 10); if (num1 == this._selectedItem) { lsItem.selected = true; this._selectedLevel = lsItem; } else { lsItem.selected = false; } ++num1; ++num2; } } }
public void SetCurrentFolder(string folder) { this._currentDirectory = folder; HUD.CloseCorner(HUDCorner.TopRight); if (this._currentDirectory == this._rootDirectory) { this._selectedItem = 0; HUD.AddCornerControl(HUDCorner.TopRight, "@START@Done"); HUD.AddCornerControl(HUDCorner.TopRight, "@GRAB@Delete"); } else { this._selectedItem = 1; HUD.AddCornerControl(HUDCorner.TopRight, "@START@Done @QUACK@Back"); HUD.AddCornerControl(HUDCorner.TopRight, "@GRAB@Delete"); } this._topIndex = 0; this._items.Clear(); if (this._currentDirectory != this._rootDirectory) { this.AddItem(new LSItem(0.0f, 0.0f, this, "../")); } else if (Steam.GetNumWorkshopItems() > 0) { this.AddItem(new LSItem(0.0f, 0.0f, this, "@WORKSHOP@", true)); } if (folder.EndsWith(".play")) { foreach (string PATH in LSItem.GetLevelsInside(this, folder)) { this.AddItem(new LSItem(0.0f, 0.0f, this, PATH)); } this.PositionItems(); } else if (folder == "@WORKSHOP@") { foreach (string PATH in LSItem.GetLevelsInside(this, folder)) { this.AddItem(new LSItem(0.0f, 0.0f, this, PATH)); } this.PositionItems(); } else { string[] directories = DuckFile.GetDirectories(folder); string[] files = DuckFile.GetFiles(folder); foreach (string PATH in directories) { this.AddItem(new LSItem(0.0f, 0.0f, this, PATH)); } List <string> stringList = new List <string>(); foreach (string str in files) { string file = str; if (Path.GetExtension(file) == ".lev" && this._filters.TrueForAll((Predicate <IFilterLSItems>)(a => a.Filter(file)))) { stringList.Add(file); } else if (Path.GetExtension(file) == ".play") { this.AddItem(new LSItem(0.0f, 0.0f, this, file)); } } foreach (string PATH in stringList) { this.AddItem(new LSItem(0.0f, 0.0f, this, PATH)); } this.PositionItems(); } }
public override void Update() { HUD.CloseCorner(HUDCorner.TopLeft); this._dialog.DoUpdate(); if (this._dialog.opened) { return; } Editor.lockInput = (ContextMenu)null; if (this._dialog.result != null && this._dialog.result != "") { string result = this._dialog.result; LevelPlaylist levelPlaylist = new LevelPlaylist(); levelPlaylist.levels.AddRange((IEnumerable <string>)Editor.activatedLevels); XDocument doc = new XDocument(); doc.Add((object)levelPlaylist.Serialize()); DuckFile.SaveXDocument(doc, DuckFile.levelDirectory + result + ".play"); this.SetCurrentFolder(this._rootDirectory); this._dialog.result = (string)null; } else { if (this._selectedLevel == null) { this._exiting = true; } if (Editor.activatedLevels.Count > 0) { if (!this.showPlaylistOption) { this.showPlaylistOption = true; HUD.AddCornerControl(HUDCorner.BottomLeft, "@RAGDOLL@NEW PLAYLIST"); } } else if (this.showPlaylistOption) { this.showPlaylistOption = false; HUD.CloseCorner(HUDCorner.BottomLeft); } if (this._deleteFile.value) { foreach (string str in this._selectedLevel.levelsInside) { Editor.activatedLevels.Remove(str); } Editor.activatedLevels.Remove(this._selectedLevel.path); if (this._selectedLevel.itemType == LSItemType.Folder) { DuckFile.DeleteFolder(DuckFile.levelDirectory + this._selectedLevel.path); } else if (this._selectedLevel.itemType == LSItemType.Playlist) { DuckFile.Delete(DuckFile.levelDirectory + this._selectedLevel.path); } else { DuckFile.Delete(DuckFile.levelDirectory + this._selectedLevel.path + ".lev"); } Thread.Sleep(100); this.SetCurrentFolder(this._currentDirectory); this._deleteFile.value = false; } if (this._exiting) { HUD.CloseAllCorners(); Graphics.fade = Lerp.Float(Graphics.fade, 0.0f, 0.04f); if ((double)Graphics.fade >= 0.00999999977648258) { return; } this.isClosed = true; } else { Graphics.fade = Lerp.Float(Graphics.fade, 1f, 0.04f); if (Input.Pressed("UP")) { if (this._selectedItem > 0) { --this._selectedItem; } if (this._selectedItem < this._topIndex) { this._topIndex = this._selectedItem; } } else if (Input.Pressed("DOWN")) { if (this._selectedItem < this._items.Count <LSItem>() - 1) { ++this._selectedItem; } if (this._selectedItem >= this._topIndex + this._maxItems) { this._topIndex = this._selectedItem + 1 - this._maxItems; } } else if (Input.Pressed("LEFT")) { this._selectedItem -= this._maxItems - 1; if (this._selectedItem < 0) { this._selectedItem = 0; } if (this._selectedItem < this._topIndex) { this._topIndex = this._selectedItem; } } else if (Input.Pressed("RIGHT")) { this._selectedItem += this._maxItems - 1; if (this._selectedItem > this._items.Count <LSItem>() - 1) { this._selectedItem = this._items.Count <LSItem>() - 1; } if (this._selectedItem >= this._topIndex + this._maxItems) { this._topIndex = this._selectedItem + 1 - this._maxItems; } } else if (Input.Pressed("SHOOT")) { if (this._selectedLevel.itemType != LSItemType.UpFolder) { if (this._selectedLevel.itemType == LSItemType.Folder || this._selectedLevel.itemType == LSItemType.Playlist || this._selectedLevel.itemType == LSItemType.Workshop) { if (!this._selectedLevel.enabled) { this._selectedLevel.enabled = true; this._selectedLevel.partiallyEnabled = false; Editor.activatedLevels.AddRange((IEnumerable <string>) this._selectedLevel.levelsInside); } else { this._selectedLevel.enabled = false; this._selectedLevel.partiallyEnabled = false; foreach (string str in this._selectedLevel.levelsInside) { Editor.activatedLevels.Remove(str); } } } else if (Editor.activatedLevels.Contains(this._selectedLevel.path)) { Editor.activatedLevels.Remove(this._selectedLevel.path); } else { Editor.activatedLevels.Add(this._selectedLevel.path); } } } else if (Input.Pressed("SELECT")) { if (this._selectedLevel.itemType == LSItemType.Workshop) { this.SetCurrentFolder(this._selectedLevel.path); } else if (this._selectedLevel.itemType == LSItemType.Folder || this._selectedLevel.itemType == LSItemType.Playlist) { this.SetCurrentFolder(this._rootDirectory + this._selectedLevel.path); } else if (this._selectedLevel.itemType == LSItemType.UpFolder) { this.FolderUp(); } } else if (Input.Pressed("QUACK")) { if (this._currentDirectory != this._rootDirectory) { this.FolderUp(); } } else if (Input.Pressed("START")) { this._exiting = true; } else if (Input.Pressed("RAGDOLL")) { this._dialog.Open("New Playlist..."); Editor.lockInput = (ContextMenu)this._dialog; } else if (Input.Pressed("GRAB") && MonoMain.pauseMenu != this._confirmMenu && (this._selectedLevel.itemType != LSItemType.UpFolder && this._selectedLevel.itemType != LSItemType.Workshop)) { LevelSelect._skipCompanionOpening = true; MonoMain.pauseMenu = (UIComponent)this._confirmMenu; this._confirmMenu.Open(); SFX.Play("pause", 0.6f); } this.PositionItems(); if (this._selectedLevel != this._lastSelection) { if (this._lastSelection == null || this._selectedLevel.itemType != this._lastSelection.itemType) { HUD.CloseCorner(HUDCorner.BottomRight); if (this._selectedLevel.itemType == LSItemType.UpFolder) { HUD.AddCornerControl(HUDCorner.BottomRight, "@SELECT@Return"); } else if (this._selectedLevel.itemType == LSItemType.Folder || this._selectedLevel.itemType == LSItemType.Playlist || this._selectedLevel.itemType == LSItemType.Workshop) { HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@Toggle"); HUD.AddCornerControl(HUDCorner.BottomRight, "@SELECT@Open"); } else { HUD.AddCornerControl(HUDCorner.BottomRight, "@SHOOT@Toggle"); } } this._lastSelection = this._selectedLevel; } if (this._selectedLevel != this._previewItem) { if (this._selectedLevel.itemType == LSItemType.Level) { this._preview = Content.GeneratePreview(this._selectedLevel.path); this._previewSprite = this._preview == null ? (Sprite)null : new Sprite(this._preview, 0.0f, 0.0f); } else { this._previewSprite = (Sprite)null; } this._previewItem = this._selectedLevel; } foreach (Thing thing in this._items) { thing.Update(); } } } }
public void AddItem(LSItem item) => this._items.Add(item);