From 864235b3222563dceace6e8981cba6e7145585f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sven=20G=2E=20Bro=CC=88nstrup?= <broenstrup@spom.net>
Date: Sun, 19 Dec 2021 19:14:12 +0100
Subject: [PATCH] Added bell properties

---
 lib/Properties.hs | 40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

diff --git a/lib/Properties.hs b/lib/Properties.hs
index 4a16927..7fc58c9 100644
--- a/lib/Properties.hs
+++ b/lib/Properties.hs
@@ -295,8 +295,27 @@ checkObjectProperty obj p@(Property name _) = case name of
         suggest "set \"soundRadius\" to a limit the door sound to a certain area\"."
 
     suggestProperty "door"
+
+  -- | these properties are used by the extended script to allow doors
+  "bell" -> do
+    isBool p
+    unless (objectType obj == "variable") $
+      complain "Bell variables must be of type \"variable\""
+    when (null (objectName obj) || objectName obj == Just mempty) $
+      complain "Bell variables objects must have a name given"
+  "bellSound" -> do
+    isString p
+
+    unwrapURI (Proxy @"audio") p
+      (dependsOn . Link)
+      (dependsOn . Local)
+
+    suggestProperty "bell"
+
+  -- | Applies to doors and bells as well
   "soundRadius" -> do
     isInt p
+    -- requireAnyProperty "door" "bell"
 
 
   _ -> warn $ "unknown object property " <> prettyprint name <> "."
@@ -451,19 +470,32 @@ checkTileLayerProperty p@(Property name _value) = case name of
       requireProperty "zone"
     "autoOpen" -> do
       isBool p
-      requireProperty "zone"
+      requireProperty "doorVariable"
     "autoClose" -> do
       isBool p
-      requireProperty "zone"
+      requireProperty "doorVariable"
     "code" -> do
       isString p
-      requireProperty "zone"
+      requireProperty "doorVariable"
     "openTriggerMessage" -> do
       isString p
-      requireProperty "zone"
+      requireProperty "doorVariable"
     "closeTriggerMessage" -> do
+      isString p
+      requireProperty "doorVariable"
+
+    -- | these properties are used by the extended script to allow bells
+
+    "bellVariable" -> do
       isString p
       requireProperty "zone"
+    "bellButtonText" -> do
+      isString p
+      requireProperty "bellVariable"
+    "bellPopup" -> do
+      isString p
+      requireProperty "bellVariable"
+
 
     -- name on tile layer unsupported
     "name" -> isUnsupported
-- 
GitLab