From f3f8c4affac978368e77089bc0b36ecf55dfad6e Mon Sep 17 00:00:00 2001 From: ritankar56 Date: Mon, 2 Oct 2023 20:40:36 +0530 Subject: [PATCH] Issue #1 #2 #3 #4 #5 #7, Ritankar Das, fixed given issues --- screenLayout/sitea_screen.kv | 27 ++++++++++++++------------- screens/doors.py | 25 ++++++++++++++++++++++--- screens/siteA.py | 8 ++++++-- screens/spawn.py | 2 +- 4 files changed, 43 insertions(+), 19 deletions(-) diff --git a/screenLayout/sitea_screen.kv b/screenLayout/sitea_screen.kv index 188812c..079cd8f 100644 --- a/screenLayout/sitea_screen.kv +++ b/screenLayout/sitea_screen.kv @@ -44,8 +44,10 @@ size_hint: None,None size: dp(80), dp(80) pos: dp(261), dp(347) - disabled: True - + disabled: True if splash_bg_after.opacity == 1 else False + on_press: + root.change_img(self, 2) + root.check_product(self, 2) @@ -100,26 +102,25 @@ center_y: self.parent.top - 10 Button: - id: 5 + id: 5 # Corrected button ID text: "Ω" font_size: "65sp" - color: 255,255,255 + color: 255, 255, 255 halign: 'center' valign: 'bottom' - background_color: 255,255,255 - size_hint: None,None + background_color: 255, 255, 255 + size_hint: None, None size: dp(80), dp(80) pos: dp(261), dp(242) disabled: True if splash_bg_after.opacity == 1 else False on_press: - root.change_img(self, 4) - root.check_product(self, 4) - + root.change_img(self, 5) # Corrected button ID + root.check_product(self, 5) # Corrected button ID Image: - id: 5 + id: 5 # Corrected button ID source: 'assets/img/symbols/off.png' center_x: self.parent.center_x - center_y: self.parent.top - 10 + center_y: self.parent.top - 10 Button: id: 6 @@ -222,10 +223,10 @@ # Initialize return button to map window Button: - size_hint: None,None + size_hint: None, None size: dp(60), dp(60) pos: dp(12), dp(523) - background_color: 0,0,0,0 + background_color: 0, 0, 0, 0 on_press: root.manager.current = 'map' Image: diff --git a/screens/doors.py b/screens/doors.py index f75985c..e0b09bb 100644 --- a/screens/doors.py +++ b/screens/doors.py @@ -1,33 +1,52 @@ +# Import necessary modules and classes from kivy.lang import Builder from kivy.uix.screenmanager import Screen from kivy.core.audio import SoundLoader +# Import functions from another module from .screen_check import passcode, set_doors +# Load the Kivy layout file for the DoorsScreen Builder.load_file('screenLayout/doors_screen.kv') + +# Load a sound file for later use sound = SoundLoader.load('assets/audio/doors_roger.wav') + +# Define a class named DoorsScreen that inherits from the Screen class class DoorsScreen(Screen): + # Initialize a class variable 'verified' to False verified = False + # Function to increment the value of a label def increment_value(self, label_index): - if(int(label_index.text) == 5): + if int(label_index.text) == 9: label_index.text = "0" else: label_index.text = f"{int(label_index.text) + 1}" + # Call the 'verify' method to check if the passcode is correct DoorsScreen.verify(self) + # Function to decrement the value of a label def decrement_value(self, label_index): - if(int(label_index.text) == 0): + if int(label_index.text) == 0: label_index.text = "5" else: label_index.text = f"{int(label_index.text) - 1}" + # Call the 'verify' method to check if the passcode is correct DoorsScreen.verify(self) + # Function to verify the passcode def verify(self): + # Concatenate the values of four labels to form a passcode and compare it with the stored passcode code = passcode == int(self.ids.label_1.text + self.ids.label_2.text + self.ids.label_3.text + self.ids.label_4.text) + # Check if the passcode is correct and the screen hasn't been verified yet if not DoorsScreen.verified and code: + # Mark the screen as verified DoorsScreen.verified = True + # Make changes to the UI by changing the opacity of certain elements self.ids.splash_bg.opacity = 0 self.ids.splash_bg_after.opacity = 1 + # Call the 'set_doors' function to perform additional actions set_doors() - sound.play() \ No newline at end of file + # Play the loaded sound + sound.play() diff --git a/screens/siteA.py b/screens/siteA.py index b310bca..079fbde 100644 --- a/screens/siteA.py +++ b/screens/siteA.py @@ -15,10 +15,14 @@ def show_overlay(self): # Updating the window state after correct combination self.ids.splash_bg_after.opacity = 1 self.pressed_buttons = [] - def change_img(self, button, idOG): # Toggle the button states to on(green)/off(grey) on press + def change_img(self, button, idOG): idOG_dynamic = f"{idOG}" widget = getattr(self.ids, idOG_dynamic, None) - widget.source = "assets/img/symbols/off.png" if widget.source == "assets/img/symbols/off.png" else "assets/img/symbols/off.png" + + if widget.source == "assets/img/symbols/off.png": + widget.source = "assets/img/symbols/on.png" # Change to the green button image + else: + widget.source = "assets/img/symbols/off.png" # Change to the grey button image def check_product(self, instance, id): # Check for correct code combination button_id = id diff --git a/screens/spawn.py b/screens/spawn.py index f770ff0..5762717 100644 --- a/screens/spawn.py +++ b/screens/spawn.py @@ -10,7 +10,7 @@ class SpawnScreen(Screen): verified = False def slider_val_change(self): - if not SpawnScreen.verified and ((self.ids.slide1.value < slider[0]+5) and (self.ids.slide1.value > slider[0]-5 )) and ((self.ids.slide2.value < slider[2]+5)and ( self.ids.slide2.value > slider[2]-5 )) and ((self.ids.slide3.value < slider[2]+5) and (self.ids.slide3.value > slider[2]-5 )): + if not SpawnScreen.verified and ((self.ids.slide1.value < slider[0]+5) and (self.ids.slide1.value > slider[0]-5 )) and ((self.ids.slide2.value < slider[1]+5)and ( self.ids.slide2.value > slider[1]-5 )) and ((self.ids.slide3.value < slider[2]+5) and (self.ids.slide3.value > slider[2]-5 )): SpawnScreen.verified = True self.ids.splash_bg.opacity = 0 self.ids.splash_bg_after.opacity = 1