public void ButtonPressed(ToolbarButton button) { SFX.Play("highClick", 0.3f); ContextMenu contextMenu1 = (ContextMenu)null; Vec2 vec2 = new Vec2(2f, 21f); if (button == this._newButton) { this.Closed(); this._newMenu = new ContextMenu((IContextListener)this, hasToproot: true, topRoot: button.position); this._newMenu.x = this.position.x - vec2.x; this._newMenu.y = this.position.y + vec2.y; this._newMenu.root = true; this._newMenu.depth = this.depth + 10; this.Selected(); this._newMenu.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 60f }, text = "NEW" }); this._newMenu.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 60f }, text = "NEW ONLINE" }); ContextMenu contextMenu2 = new ContextMenu((IContextListener)this); contextMenu2.itemSize.x = 60f; contextMenu2.text = "ARCADE"; contextMenu2.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 60f }, text = "NEW ARCADE" }); contextMenu2.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 60f }, text = "NEW CHALLENGE" }); contextMenu2.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 60f }, text = "NEW ARCADE MACHINE" }); this._newMenu.AddItem(contextMenu2); this._newMenu.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 60f }, text = "CANCEL" }); Level.Add((Thing)this._newMenu); this._newMenu.opened = true; contextMenu1 = this._newMenu; } if (button == this._saveButton) { this.Closed(); this._saveMenu = new ContextMenu((IContextListener)this, hasToproot: true, topRoot: button.position); this._saveMenu.x = this.position.x - vec2.x; this._saveMenu.y = this.position.y + vec2.y; this._saveMenu.root = true; this._saveMenu.depth = this.depth + 10; this.Selected(); this._saveMenu.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 60f }, text = "SAVE" }); this._saveMenu.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 60f }, text = "SAVE AS" }); Level.Add((Thing)this._saveMenu); this._saveMenu.opened = true; contextMenu1 = this._saveMenu; } if (button == this._gridButton) { this.Closed(); this._gridMenu = new ContextMenu((IContextListener)this, hasToproot: true, topRoot: button.position); this._gridMenu.x = this.position.x - vec2.x; this._gridMenu.y = this.position.y + vec2.y; this._gridMenu.root = true; this._gridMenu.depth = this.depth + 10; this.Selected(); this._gridMenu.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 60f }, text = "8x8" }); this._gridMenu.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 60f }, text = "16x16" }); this._gridMenu.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 60f }, text = "32x32" }); Level.Add((Thing)this._gridMenu); this._gridMenu.opened = true; contextMenu1 = this._gridMenu; } if (button == this._loadButton) { Editor current = Level.current as Editor; current.Load(); current.CloseMenu(); } if (button == this._steamButton) { Editor current = Level.current as Editor; current.SteamUpload(); current.CloseMenu(); } if (button == this._playButton) { (Level.current as Editor).Play(); } if (button == this._quitButton) { this.Closed(); this._quitMenu = new ContextMenu((IContextListener)this, hasToproot: true, topRoot: button.position); this._quitMenu.x = this.position.x - vec2.x; this._quitMenu.y = this.position.y + vec2.y; this._quitMenu.root = true; this._quitMenu.depth = this.depth + 10; this.Selected(); this._quitMenu.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 60f }, text = "QUIT" }); this._quitMenu.AddItem(new ContextMenu((IContextListener)this) { itemSize = { x = 60f }, text = "CANCEL" }); Level.Add((Thing)this._quitMenu); this._quitMenu.opened = true; contextMenu1 = this._quitMenu; } if (contextMenu1 == null || (double)contextMenu1.y + (double)contextMenu1.menuSize.y <= (double)Layer.HUD.camera.height - 4.0) { return; } float y = contextMenu1.y; contextMenu1.y = Layer.HUD.camera.height - 4f - contextMenu1.menuSize.y; contextMenu1._toprootPosition.y += contextMenu1.y - y; if (this.owner is ContextMenu owner) { owner._openedOffset = 0.0f; owner.y = contextMenu1.y - 16f - owner.menuSize.y; owner.PositionItems(); } contextMenu1.PositionItems(); }
public override void Selected(ContextMenu item) { if (item.text == "ARCADE") { base.Selected(item); } else { if (item.text == "CANCEL") { (Level.current as Editor).CloseMenu(); } if (item.text == "NEW") { Editor current = Level.current as Editor; current.ClearEverything(); current.saveName = ""; Editor.onlineMode = false; current.CloseMenu(); } if (item.text == "NEW ONLINE") { Editor current = Level.current as Editor; current.ClearEverything(); current.saveName = ""; Editor.onlineMode = true; current.CloseMenu(); } if (item.text == "SAVE") { Editor current = Level.current as Editor; current.Save(); current.CloseMenu(); } if (item.text == "SAVE AS") { Editor current = Level.current as Editor; current.SaveAs(); current.CloseMenu(); } if (item.text == "8x8") { Editor current = Level.current as Editor; current.cellSize = 8f; current.CloseMenu(); } if (item.text == "16x16") { Editor current = Level.current as Editor; current.cellSize = 16f; current.CloseMenu(); } if (item.text == "32x32") { Editor current = Level.current as Editor; current.cellSize = 32f; current.CloseMenu(); } if (!(item.text == "QUIT")) { return; } Editor current1 = Level.current as Editor; current1.Quit(); current1.CloseMenu(); } }
public ContextToolbarItem(ContextMenu owner) : base((IContextListener)owner) { }