import Animation
import Event
import Images
import Objects.Block
import Objects.Pea
import Physics.OdePhysics
import PathFinding.GateAndLink.Graph
import Scene
from Constants import *
from UserInterface.Button import *
from UserInterface.Tool import *
from UserInterface.Score import *
from UserInterface.Timer import *
import UserInterface.Scroll

def newButton(image, yPos, tool):
    return ToolButton(image, tool, (725, yPos), 47, 47)

class BasicLevel:
    def __init__(self, userInterface):
        self.userInterface = userInterface
        
        self.score = self.createScoreWidget()
        self.timer = self.createTimerWidget()
        self.nodeGraph = self.createNodeGraph()
        self.physicsManager = self.createPhysicsManager()
        self.scene = self.createScene()
        self.buttonPanel = self.createToolPanel()
        self.scene.addPea(Objects.Pea.Pea((0, 600), self.nodeGraph, self.physicsManager))
        self.scene.addPea(Objects.Pea.Pea((100, 600), self.nodeGraph, self.physicsManager))
        self.scene.addPea(Objects.Pea.Pea((200, 600), self.nodeGraph, self.physicsManager))
#        self.scene.addPea(Objects.Pea.Pea((300, 600), self.nodeGraph, self.physicsManager))
#        self.scene.addPea(Objects.Pea.Pea((400, 600), self.nodeGraph, self.physicsManager))
        
        
    def render(self, screen):
        screen.blit(Images.images["Background"], (0,0))
        UserInterface.Scroll.globalViewPort.blit(screen, Images.images["Plate"], Coordinates.pixelPosToOdePos((5, 520)))
        self.scene.render(screen)
        self.userInterface.render(screen)
        
    def dispose(self):
        self.scene.dispose()
        self.buttonPanel.dispose()
        self.timer.dispose()
        self.score.dispose()
        
    def createScene(self):
        scene = Scene.Scene(self.nodeGraph, self.physicsManager)
        self.userInterface.setScene(scene)
        return scene

    def createPhysicsManager(self):
        physicsManager = Physics.OdePhysics.OdePhysicsManager()
        Animation.animations.append(physicsManager)
        return physicsManager
    
    def createNodeGraph(self):
        nodeGraph = PathFinding.GateAndLink.Graph.NodeGraph(BLOCKS_WIDE, Coordinates.pixelsToOde(SCREEN_HEIGHT - 60))
        return nodeGraph
    
    def createToolPanel(self):
        buttonPanel = ButtonPanel((720, 10))
        self.userInterface.addActiveWidget(buttonPanel)
        buttonPanel.addListener(self.userInterface)
        yStart = 15
        spacing = 50
        for button in (newButton("Delete", yStart, DeleteTool(self.scene)),
                        newButton("Gel", yStart + spacing, GelBlockTool(self.scene)),
                        newButton("Normal", yStart + spacing*2, NormalBlockTool(self.scene)),
                        newButton("LeftRamp", yStart + spacing*3, LeftRampTool(self.scene)),
                        newButton("RightRamp", yStart + spacing*4, RightRampTool(self.scene)),
                        newButton("Spring", yStart + spacing*5, SpringTool(self.scene))
                        ):
            buttonPanel.addButton(button)
        return buttonPanel
    
    def createScoreWidget(self):
        score = Score((300, 10))
        Animation.animations.append(score)
        self.userInterface.addPassiveWidget(score)
        return score
    
    def createTimerWidget(self):
        timer = Timer((600, 10))
        Animation.animations.append(timer)
        self.userInterface.addPassiveWidget(timer)
        return timer
    
        
5f7d7579cf9914b7609d7e920c4e4f2aaa13089a
<mask token>


class BasicLevel:
    <mask token>

    def render(self, screen):
        screen.blit(Images.images['Background'], (0, 0))
        UserInterface.Scroll.globalViewPort.blit(screen, Images.images[
            'Plate'], Coordinates.pixelPosToOdePos((5, 520)))
        self.scene.render(screen)
        self.userInterface.render(screen)

    def dispose(self):
        self.scene.dispose()
        self.buttonPanel.dispose()
        self.timer.dispose()
        self.score.dispose()

    def createScene(self):
        scene = Scene.Scene(self.nodeGraph, self.physicsManager)
        self.userInterface.setScene(scene)
        return scene
    <mask token>

    def createNodeGraph(self):
        nodeGraph = PathFinding.GateAndLink.Graph.NodeGraph(BLOCKS_WIDE,
            Coordinates.pixelsToOde(SCREEN_HEIGHT - 60))
        return nodeGraph

    def createToolPanel(self):
        buttonPanel = ButtonPanel((720, 10))
        self.userInterface.addActiveWidget(buttonPanel)
        buttonPanel.addListener(self.userInterface)
        yStart = 15
        spacing = 50
        for button in (newButton('Delete', yStart, DeleteTool(self.scene)),
            newButton('Gel', yStart + spacing, GelBlockTool(self.scene)),
            newButton('Normal', yStart + spacing * 2, NormalBlockTool(self.
            scene)), newButton('LeftRamp', yStart + spacing * 3,
            LeftRampTool(self.scene)), newButton('RightRamp', yStart + 
            spacing * 4, RightRampTool(self.scene)), newButton('Spring', 
            yStart + spacing * 5, SpringTool(self.scene))):
            buttonPanel.addButton(button)
        return buttonPanel
    <mask token>

    def createTimerWidget(self):
        timer = Timer((600, 10))
        Animation.animations.append(timer)
        self.userInterface.addPassiveWidget(timer)
        return timer

<mask token>


class BasicLevel:
    <mask token>

    def render(self, screen):
        screen.blit(Images.images['Background'], (0, 0))
        UserInterface.Scroll.globalViewPort.blit(screen, Images.images[
            'Plate'], Coordinates.pixelPosToOdePos((5, 520)))
        self.scene.render(screen)
        self.userInterface.render(screen)

    def dispose(self):
        self.scene.dispose()
        self.buttonPanel.dispose()
        self.timer.dispose()
        self.score.dispose()

    def createScene(self):
        scene = Scene.Scene(self.nodeGraph, self.physicsManager)
        self.userInterface.setScene(scene)
        return scene
    <mask token>

    def createNodeGraph(self):
        nodeGraph = PathFinding.GateAndLink.Graph.NodeGraph(BLOCKS_WIDE,
            Coordinates.pixelsToOde(SCREEN_HEIGHT - 60))
        return nodeGraph

    def createToolPanel(self):
        buttonPanel = ButtonPanel((720, 10))
        self.userInterface.addActiveWidget(buttonPanel)
        buttonPanel.addListener(self.userInterface)
        yStart = 15
        spacing = 50
        for button in (newButton('Delete', yStart, DeleteTool(self.scene)),
            newButton('Gel', yStart + spacing, GelBlockTool(self.scene)),
            newButton('Normal', yStart + spacing * 2, NormalBlockTool(self.
            scene)), newButton('LeftRamp', yStart + spacing * 3,
            LeftRampTool(self.scene)), newButton('RightRamp', yStart + 
            spacing * 4, RightRampTool(self.scene)), newButton('Spring', 
            yStart + spacing * 5, SpringTool(self.scene))):
            buttonPanel.addButton(button)
        return buttonPanel

    def createScoreWidget(self):
        score = Score((300, 10))
        Animation.animations.append(score)
        self.userInterface.addPassiveWidget(score)
        return score

    def createTimerWidget(self):
        timer = Timer((600, 10))
        Animation.animations.append(timer)
        self.userInterface.addPassiveWidget(timer)
        return timer

<mask token>


class BasicLevel:

    def __init__(self, userInterface):
        self.userInterface = userInterface
        self.score = self.createScoreWidget()
        self.timer = self.createTimerWidget()
        self.nodeGraph = self.createNodeGraph()
        self.physicsManager = self.createPhysicsManager()
        self.scene = self.createScene()
        self.buttonPanel = self.createToolPanel()
        self.scene.addPea(Objects.Pea.Pea((0, 600), self.nodeGraph, self.
            physicsManager))
        self.scene.addPea(Objects.Pea.Pea((100, 600), self.nodeGraph, self.
            physicsManager))
        self.scene.addPea(Objects.Pea.Pea((200, 600), self.nodeGraph, self.
            physicsManager))

    def render(self, screen):
        screen.blit(Images.images['Background'], (0, 0))
        UserInterface.Scroll.globalViewPort.blit(screen, Images.images[
            'Plate'], Coordinates.pixelPosToOdePos((5, 520)))
        self.scene.render(screen)
        self.userInterface.render(screen)

    def dispose(self):
        self.scene.dispose()
        self.buttonPanel.dispose()
        self.timer.dispose()
        self.score.dispose()

    def createScene(self):
        scene = Scene.Scene(self.nodeGraph, self.physicsManager)
        self.userInterface.setScene(scene)
        return scene

    def createPhysicsManager(self):
        physicsManager = Physics.OdePhysics.OdePhysicsManager()
        Animation.animations.append(physicsManager)
        return physicsManager

    def createNodeGraph(self):
        nodeGraph = PathFinding.GateAndLink.Graph.NodeGraph(BLOCKS_WIDE,
            Coordinates.pixelsToOde(SCREEN_HEIGHT - 60))
        return nodeGraph

    def createToolPanel(self):
        buttonPanel = ButtonPanel((720, 10))
        self.userInterface.addActiveWidget(buttonPanel)
        buttonPanel.addListener(self.userInterface)
        yStart = 15
        spacing = 50
        for button in (newButton('Delete', yStart, DeleteTool(self.scene)),
            newButton('Gel', yStart + spacing, GelBlockTool(self.scene)),
            newButton('Normal', yStart + spacing * 2, NormalBlockTool(self.
            scene)), newButton('LeftRamp', yStart + spacing * 3,
            LeftRampTool(self.scene)), newButton('RightRamp', yStart + 
            spacing * 4, RightRampTool(self.scene)), newButton('Spring', 
            yStart + spacing * 5, SpringTool(self.scene))):
            buttonPanel.addButton(button)
        return buttonPanel

    def createScoreWidget(self):
        score = Score((300, 10))
        Animation.animations.append(score)
        self.userInterface.addPassiveWidget(score)
        return score

    def createTimerWidget(self):
        timer = Timer((600, 10))
        Animation.animations.append(timer)
        self.userInterface.addPassiveWidget(timer)
        return timer

<mask token>


def newButton(image, yPos, tool):
    return ToolButton(image, tool, (725, yPos), 47, 47)


class BasicLevel:

    def __init__(self, userInterface):
        self.userInterface = userInterface
        self.score = self.createScoreWidget()
        self.timer = self.createTimerWidget()
        self.nodeGraph = self.createNodeGraph()
        self.physicsManager = self.createPhysicsManager()
        self.scene = self.createScene()
        self.buttonPanel = self.createToolPanel()
        self.scene.addPea(Objects.Pea.Pea((0, 600), self.nodeGraph, self.
            physicsManager))
        self.scene.addPea(Objects.Pea.Pea((100, 600), self.nodeGraph, self.
            physicsManager))
        self.scene.addPea(Objects.Pea.Pea((200, 600), self.nodeGraph, self.
            physicsManager))

    def render(self, screen):
        screen.blit(Images.images['Background'], (0, 0))
        UserInterface.Scroll.globalViewPort.blit(screen, Images.images[
            'Plate'], Coordinates.pixelPosToOdePos((5, 520)))
        self.scene.render(screen)
        self.userInterface.render(screen)

    def dispose(self):
        self.scene.dispose()
        self.buttonPanel.dispose()
        self.timer.dispose()
        self.score.dispose()

    def createScene(self):
        scene = Scene.Scene(self.nodeGraph, self.physicsManager)
        self.userInterface.setScene(scene)
        return scene

    def createPhysicsManager(self):
        physicsManager = Physics.OdePhysics.OdePhysicsManager()
        Animation.animations.append(physicsManager)
        return physicsManager

    def createNodeGraph(self):
        nodeGraph = PathFinding.GateAndLink.Graph.NodeGraph(BLOCKS_WIDE,
            Coordinates.pixelsToOde(SCREEN_HEIGHT - 60))
        return nodeGraph

    def createToolPanel(self):
        buttonPanel = ButtonPanel((720, 10))
        self.userInterface.addActiveWidget(buttonPanel)
        buttonPanel.addListener(self.userInterface)
        yStart = 15
        spacing = 50
        for button in (newButton('Delete', yStart, DeleteTool(self.scene)),
            newButton('Gel', yStart + spacing, GelBlockTool(self.scene)),
            newButton('Normal', yStart + spacing * 2, NormalBlockTool(self.
            scene)), newButton('LeftRamp', yStart + spacing * 3,
            LeftRampTool(self.scene)), newButton('RightRamp', yStart + 
            spacing * 4, RightRampTool(self.scene)), newButton('Spring', 
            yStart + spacing * 5, SpringTool(self.scene))):
            buttonPanel.addButton(button)
        return buttonPanel

    def createScoreWidget(self):
        score = Score((300, 10))
        Animation.animations.append(score)
        self.userInterface.addPassiveWidget(score)
        return score

    def createTimerWidget(self):
        timer = Timer((600, 10))
        Animation.animations.append(timer)
        self.userInterface.addPassiveWidget(timer)
        return timer

import Animation
import Event
import Images
import Objects.Block
import Objects.Pea
import Physics.OdePhysics
import PathFinding.GateAndLink.Graph
import Scene
from Constants import *
from UserInterface.Button import *
from UserInterface.Tool import *
from UserInterface.Score import *
from UserInterface.Timer import *
import UserInterface.Scroll

def newButton(image, yPos, tool):
    return ToolButton(image, tool, (725, yPos), 47, 47)

class BasicLevel:
    def __init__(self, userInterface):
        self.userInterface = userInterface
        
        self.score = self.createScoreWidget()
        self.timer = self.createTimerWidget()
        self.nodeGraph = self.createNodeGraph()
        self.physicsManager = self.createPhysicsManager()
        self.scene = self.createScene()
        self.buttonPanel = self.createToolPanel()
        self.scene.addPea(Objects.Pea.Pea((0, 600), self.nodeGraph, self.physicsManager))
        self.scene.addPea(Objects.Pea.Pea((100, 600), self.nodeGraph, self.physicsManager))
        self.scene.addPea(Objects.Pea.Pea((200, 600), self.nodeGraph, self.physicsManager))
#        self.scene.addPea(Objects.Pea.Pea((300, 600), self.nodeGraph, self.physicsManager))
#        self.scene.addPea(Objects.Pea.Pea((400, 600), self.nodeGraph, self.physicsManager))
        
        
    def render(self, screen):
        screen.blit(Images.images["Background"], (0,0))
        UserInterface.Scroll.globalViewPort.blit(screen, Images.images["Plate"], Coordinates.pixelPosToOdePos((5, 520)))
        self.scene.render(screen)
        self.userInterface.render(screen)
        
    def dispose(self):
        self.scene.dispose()
        self.buttonPanel.dispose()
        self.timer.dispose()
        self.score.dispose()
        
    def createScene(self):
        scene = Scene.Scene(self.nodeGraph, self.physicsManager)
        self.userInterface.setScene(scene)
        return scene

    def createPhysicsManager(self):
        physicsManager = Physics.OdePhysics.OdePhysicsManager()
        Animation.animations.append(physicsManager)
        return physicsManager
    
    def createNodeGraph(self):
        nodeGraph = PathFinding.GateAndLink.Graph.NodeGraph(BLOCKS_WIDE, Coordinates.pixelsToOde(SCREEN_HEIGHT - 60))
        return nodeGraph
    
    def createToolPanel(self):
        buttonPanel = ButtonPanel((720, 10))
        self.userInterface.addActiveWidget(buttonPanel)
        buttonPanel.addListener(self.userInterface)
        yStart = 15
        spacing = 50
        for button in (newButton("Delete", yStart, DeleteTool(self.scene)),
                        newButton("Gel", yStart + spacing, GelBlockTool(self.scene)),
                        newButton("Normal", yStart + spacing*2, NormalBlockTool(self.scene)),
                        newButton("LeftRamp", yStart + spacing*3, LeftRampTool(self.scene)),
                        newButton("RightRamp", yStart + spacing*4, RightRampTool(self.scene)),
                        newButton("Spring", yStart + spacing*5, SpringTool(self.scene))
                        ):
            buttonPanel.addButton(button)
        return buttonPanel
    
    def createScoreWidget(self):
        score = Score((300, 10))
        Animation.animations.append(score)
        self.userInterface.addPassiveWidget(score)
        return score
    
    def createTimerWidget(self):
        timer = Timer((600, 10))
        Animation.animations.append(timer)
        self.userInterface.addPassiveWidget(timer)
        return timer
    
        