# This is the landing and splash screen for the app, where the user can pick their path.
# There are options for Sandbox, Puzzle Mode, or Instructions if they would like.

# CITATION: https://www.cs.cmu.edu/~112/notes/notes-animations-part3.html#subclassingModalApp 
from cmu_112_graphics import *
import random, requests, bs4, json

class SplashScreenMode(Mode):
    def appStarted(mode):
        # CITATION: This is the background photo
        url = 'https://i.pinimg.com/originals/fe/f7/2f/fef72f73f4f961b4ed6f8e4bb093eb1b.jpg'
        mode.appIcon = mode.loadImage(url)
        mode.appIcon2 = mode.scaleImage(mode.appIcon, 4.5/10)
        # CITATION: https://cooltext.com/Logo-Design-Gold-Outline
        # This was how I created and imported my title font lol
        mode.appTitle = mode.loadImage('splashscreentitle.png')
    
    def mousePressed(mode, event):
        # clicking Sandbox Mode box
        if ((mode.width/4-100) <= event.x <= (mode.width/4+50)) and ((mode.height/2+50) <= event.y <= (mode.height/2+100)):
            mode.app.setActiveMode(mode.app.sandboxMode)
        # clicking Puzzle Mode box
        elif ((mode.width/4-100) <= event.x <= (mode.width/4+50)) and ((3*mode.height/4) <= event.y <= (3*mode.height/4+50)):
            mode.app.setActiveMode(mode.app.puzzleMode)
        # clicking Instructions box
        elif ((3*mode.width/4-50) <= event.x <= (3*mode.width/4+100)) and ((mode.height/2+50) <= event.y <= (mode.height/2+100)):
            mode.app.setActiveMode(mode.app.instructions)
        # clicking Credits box
        elif ((3*mode.width/4-50) <= event.x <= (3*mode.width/4+100)) and ((3*mode.height/4) <= event.y <= (3*mode.height/4+50)):
            mode.app.setActiveMode(mode.app.credits)
        # elif ((mode.width/2-75) <= event.x <= (mode.width/2+75)) and ((9*mode.height/10) <= event.y <= (9*mode.height/10+50)):
            # mode.app.setActiveMode(mode.app.aiChatbot)

    def redrawAll(mode, canvas):
        canvas.create_image(mode.width/2, mode.height/2, image=ImageTk.PhotoImage(mode.appIcon2))
        # canvas.create_text(mode.width/2, mode.height/2-250, text='𝕎𝕚𝕥 𝕠𝕟 𝕎𝕖𝕝𝕝𝕟𝕖𝕤𝕤', font='Calibri 40 bold')
        canvas.create_image(mode.width/2, mode.height/2 - 250, image=ImageTk.PhotoImage(mode.appTitle))
        # Sandbox Mode (top left box)
        canvas.create_rectangle(mode.width/4-100, mode.height/2+50, mode.width/4+50, mode.height/2+100, fill='white')
        canvas.create_text(mode.width/4-25, mode.height/2+75, text='Sandbox Mode', font='Calibri 15 bold')
        # Puzzle Mode (bottom left box)
        canvas.create_rectangle(mode.width/4-100, 3*mode.height/4, mode.width/4+50, 3*mode.height/4+50, fill='white')
        canvas.create_text(mode.width/4-25, 3*mode.height/4+25, text='Puzzle Mode', font='Calibri 15 bold')
        # Instructions (top right box)
        canvas.create_rectangle(3*mode.width/4-50, mode.height/2+50, 3*mode.width/4+100, mode.height/2+100, fill='white')
        canvas.create_text(3*mode.width/4+25, mode.height/2+75, text='Instructions', font='Calibri 15 bold')
        # Credits (bottom right box)
        canvas.create_rectangle(3*mode.width/4-50, 3*mode.height/4, 3*mode.width/4+100, 3*mode.height/4+50, fill='white')
        canvas.create_text(3*mode.width/4+25, 3*mode.height/4+25, text='Credits', font='Calibri 15 bold')
        # AI Chatbot
        # canvas.create_rectangle(mode.width/2-75, 9*mode.height/10, mode.width/2+75, 9*mode.height/10+50, fill='white')
        # canvas.create_text(mode.width/2, 9*mode.height/10+25, text='AI Chatbot', font='Calibri 15 bold')
