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._doingPublish && this._currentItem != null) { if (!this._currentItem.finishedProcessing) { return; } if (this._uploading) { this._uploading = false; if (this._currentItem.needsLegal) { Steam.ShowWorkshopLegalAgreement("312530"); } this._upload.Close(); if (this._currentItem.result == SteamResult.OK) { this._notify.Open("Item published!"); } else { this._notify.Open("Failed (" + this._currentItem.result.ToString() + ")"); } this._doingPublish = false; } else if (this._currentItem.result == SteamResult.OK) { this._uploading = true; WorkshopItemData dat = new WorkshopItemData(); dat.name = this._nameBox.text; dat.description = this._descriptionBox.text; dat.visibility = RemoteStoragePublishedFileVisibility.Public; dat.tags = new List <string>(); if (this._levelType == LevelType.ArcadeMachine) { dat.tags.Add("Machine"); } else { dat.tags.Add("Map"); } dat.tags.Add(this._levelSize.ToString()); if (this._levelType != LevelType.Deathmatch) { dat.tags.Add(this._levelType.ToString()); } Editor.workshopName = dat.name; Editor.workshopDescription = dat.description; Editor.workshopAuthor = Steam.user.name; Editor.workshopID = this._currentItem.id; if (this._addDeathmatchTag) { dat.tags.Add("Deathmatch"); Editor.workshopLevelDeathmatchReady = true; } else if (this._addMachineTag) { dat.tags.Add("Arcade Machine"); Editor.workshopLevelDeathmatchReady = true; } else if (this._levelType == LevelType.Deathmatch) { dat.tags.Add("Strange"); } dat.tags.AddRange((IEnumerable <string>)Editor.workshopTags); if (this._extraTags != null && ((IEnumerable <string>) this._extraTags).Count <string>() > 0) { dat.tags.AddRange((IEnumerable <string>) this._extraTags); } (Level.current as Editor).Save(); this._workshopID = this._currentItem.id; string pathString1 = DuckFile.workshopDirectory + (object)this._workshopID + "/"; string pathString2 = DuckFile.workshopDirectory + (object)this._workshopID + "-preview/"; DuckFile.CreatePath(pathString1); DuckFile.CreatePath(pathString2); string withoutExtension = Path.GetFileNameWithoutExtension(this._filePath); string str = pathString1 + Path.GetFileName(this._filePath); if (File.Exists(str)) { File.Delete(str); } File.Copy(this._filePath, str); File.SetAttributes(this._filePath, FileAttributes.Normal); dat.contentFolder = pathString1; string path = pathString2 + withoutExtension + ".png"; if (File.Exists(path)) { File.Delete(path); } Stream stream = (Stream)DuckFile.Create(path); ((Texture2D)this._previewTarget.texture.nativeObject).SaveAsPng(stream, this._previewTarget.width, this._previewTarget.height); stream.Dispose(); dat.previewPath = path; this._currentItem.ApplyWorkshopData(dat); if (this._currentItem.needsLegal) { Steam.ShowWorkshopLegalAgreement("312530"); } this._upload.Open("Uploading...", this._currentItem); } else { this._notify.Open("Failed (" + this._currentItem.result.ToString() + ")"); this._doingPublish = false; } this._currentItem.ResetProcessing(); } else if (!this.opened || this._opening || (this._confirm.opened || this._upload.opened) || (this._deathmatchTest.opened || this._arcadeTest.opened || this._testSuccess.opened)) { if (this.opened) { Keyboard.keyString = ""; } this._opening = false; foreach (ContextMenu contextMenu in this._items) { contextMenu.disabled = true; } } else if (this._confirm.result) { if (this._levelType == LevelType.ArcadeMachine) { this._arcadeTest.Open("This machine can automatically show up in generated arcades, if you pass this validity test. You need to get the Developer trophy on all 3 challenges (oh boy)!"); } else { this._deathmatchTest.Open("In order to upload this map as a deathmatch level, all ducks need to be able to be eliminated. Do you want to launch the map and show that the map is functional? You don't have to do this, but the map won't show up with the DEATHMATCH tag without completing this test. If this is a challenge map, then don't worry about it!"); } this._confirm.result = false; } else if (this._testing) { Keyboard.keyString = ""; if (DeathmatchTestDialogue.success) { this._testSuccess.Open("Test success! The level can now be published as a deathmatch level!"); this._addDeathmatchTag = true; } else if (ArcadeTestDialogue.success) { if (this._arcadeTestIndex != 2) { ++this._arcadeTestIndex; ArcadeTestDialogue.success = false; ArcadeTestDialogue.currentEditor = Level.current as Editor; Level.current = this._arcadeTestIndex != 0 ? (this._arcadeTestIndex != 1 ? (Level) new ChallengeLevel(((Level.current as Editor).levelThings[0] as ArcadeMachine).challenge03Data, true) : (Level) new ChallengeLevel(((Level.current as Editor).levelThings[0] as ArcadeMachine).challenge02Data, true)) : (Level) new ChallengeLevel(((Level.current as Editor).levelThings[0] as ArcadeMachine).challenge01Data, true); this._testing = true; return; } this._testSuccess.Open("Test success! The arcade machine can now be published to the workshop!"); this._addMachineTag = true; } else if (DeathmatchTestDialogue.tooSlow) { this._notify.Open("Framerate too low!"); } else { this._notify.Open("Testing failed."); this._arcadeTestIndex = 0; } DeathmatchTestDialogue.success = false; ArcadeTestDialogue.success = false; this._testing = false; } else if (this._testSuccess.result) { this._doingPublish = true; if (this._currentItem == null) { this._currentItem = Steam.CreateItem(); } else { this._currentItem.SkipProcessing(); } this._testSuccess.result = false; } else if (this._deathmatchTest.result != -1) { if (this._deathmatchTest.result == 1) { this._doingPublish = true; if (this._currentItem == null) { this._currentItem = Steam.CreateItem(); } else { this._currentItem.SkipProcessing(); } } else if (this._deathmatchTest.result == 0) { DeathmatchTestDialogue.success = false; DeathmatchTestDialogue.currentEditor = Level.current as Editor; Level.current = (Level) new GameLevel(this._filePath, validityTest: true); this._testing = true; } this._deathmatchTest.result = -1; } else if (this._arcadeTest.result != -1) { if (this._arcadeTest.result == 1) { this._doingPublish = true; if (this._currentItem == null) { this._currentItem = Steam.CreateItem(); } else { this._currentItem.SkipProcessing(); } } else if (this._arcadeTest.result == 0) { ArcadeTestDialogue.success = false; ArcadeTestDialogue.currentEditor = Level.current as Editor; Level.current = (Level) new ChallengeLevel(((Level.current as Editor).levelThings[0] as ArcadeMachine).challenge01Data, true); this._testing = true; } this._arcadeTest.result = -1; } else { if (this._tagMenu != null) { return; } Vec2 vec2 = new Vec2((float)((double)this.layer.width / 2.0 - (double)this.width / 2.0) + this.hOffset, (float)((double)this.layer.height / 2.0 - (double)this.height / 2.0 - 15.0)) + new Vec2(7f, 276f); foreach (KeyValuePair <string, Vec2> tagPosition in this.tagPositions) { if ((double)Mouse.x > (double)tagPosition.Value.x && (double)Mouse.x < (double)tagPosition.Value.x + 8.0 && ((double)Mouse.y > (double)tagPosition.Value.y && (double)Mouse.y < (double)tagPosition.Value.y + 8.0) && Mouse.left == InputState.Pressed) { Editor.workshopTags.Remove(tagPosition.Key); return; } } if (this.tagPositions.Count != this._possibleTags.Count) { bool flag = false; if ((double)Mouse.x > (double)this._plusPosition.x && (double)Mouse.x < (double)this._plusPosition.x + 8.0 && ((double)Mouse.y > (double)this._plusPosition.y && (double)Mouse.y < (double)this._plusPosition.y + 8.0)) { flag = true; } if (flag && Mouse.left == InputState.Pressed) { ContextMenu contextMenu = new ContextMenu((IContextListener)this); contextMenu.x = this._plusPosition.x; contextMenu.y = this._plusPosition.y; contextMenu.root = true; contextMenu.depth = this.depth + 20; int num = 0; foreach (string possibleTag in this._possibleTags) { if (!Editor.workshopTags.Contains(possibleTag)) { contextMenu.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 40f }, text = possibleTag }); ++num; } } contextMenu.y -= (float)(num * 16 + 10); Level.Add((Thing)contextMenu); contextMenu.opened = true; contextMenu.closeOnRight = true; this._tagMenu = contextMenu; return; } } Editor.lockInput = (ContextMenu)this; this._descriptionBox.Update(); this._nameBox.Update(); this._acceptHover = false; this._cancelHover = false; if ((double)Mouse.x > (double)this._acceptPos.x && (double)Mouse.x < (double)this._acceptPos.x + (double)this._acceptSize.x && ((double)Mouse.y > (double)this._acceptPos.y && (double)Mouse.y < (double)this._acceptPos.y + (double)this._acceptSize.y)) { this._acceptHover = true; } if ((double)Mouse.x > (double)this._cancelPos.x && (double)Mouse.x < (double)this._cancelPos.x + (double)this._cancelSize.x && ((double)Mouse.y > (double)this._cancelPos.y && (double)Mouse.y < (double)this._cancelPos.y + (double)this._cancelSize.y)) { this._cancelHover = true; } if (this._acceptHover && Mouse.left == InputState.Pressed) { if (this._nameBox.text == "") { this._notify.Open("Please enter a name :("); } else { this._confirm.Open("Upload to workshop?"); } } if (this._cancelHover && Mouse.left == InputState.Pressed) { this.Close(); } base.Update(); } }