From 9e711e7d771aa21b72a4c08249b6430380e3b206 Mon Sep 17 00:00:00 2001 From: Marco Benzi Date: Sun, 23 Jun 2019 19:28:32 +0200 Subject: [PATCH] Fixed menus now being disabled when game hasnt started --- TetraVex/AppDelegate.swift | 13 +++++++++++++ TetraVex/Base.lproj/Main.storyboard | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/TetraVex/AppDelegate.swift b/TetraVex/AppDelegate.swift index 654835b..f6dd928 100644 --- a/TetraVex/AppDelegate.swift +++ b/TetraVex/AppDelegate.swift @@ -14,6 +14,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { var currentGameModel : TVGameModel = TVGameModel() var currentGamePieces : [[TVPieceModel]]? + var gameStarted: Bool = false var optionMenu: NSMenuItem? { return NSApplication.shared.mainMenu? @@ -185,6 +186,18 @@ class AppDelegate: NSObject, NSApplicationDelegate { pv.solvedBoard = currentGamePieces pv.newBoard(currentGameModel.boardWidth, height: currentGameModel.boardHeight) + gameStarted = true } +} +//MARK: - Menu validation +extension AppDelegate: NSMenuItemValidation { + func validateMenuItem(_ menuItem: NSMenuItem) -> Bool { + if !gameStarted { + if 10...36 ~= menuItem.tag { + return false + } + } + return true + } } diff --git a/TetraVex/Base.lproj/Main.storyboard b/TetraVex/Base.lproj/Main.storyboard index 876268f..da4bc3d 100644 --- a/TetraVex/Base.lproj/Main.storyboard +++ b/TetraVex/Base.lproj/Main.storyboard @@ -99,31 +99,31 @@ - + - + - + - + - + @@ -136,31 +136,31 @@ - + - + - + - + - + @@ -170,19 +170,19 @@ - + - + - +