Esempio n. 1
0
    def __init__(self, engine):
        self.engine = engine
        self.actors = []
        self.camera = Camera()
        self.world = None
        self.space = None
        self.time = 0.0
        self.actors = []
        self.players = self.engine.world.getPlayers()
        self.controls = engine.input.controls

        # for simplification of theme writing
        self.fontDict = self.engine.data.fontDict
        self.geometry = self.engine.view.geometry[2:4]
        self.fontScreenBottom = self.engine.data.fontScreenBottom
        self.aspectRatio = self.engine.view.aspectRatio
        self.drawStarScore = self.engine.drawStarScore
Esempio n. 2
0
File: Scene.py Progetto: htvu/fofix
    def __init__(self, engine):
        self.engine = engine
        self.actors = []
        self.camera = Camera()
        self.world = None
        self.space = None
        self.time = 0.0
        self.actors = []
        self.players = self.engine.world.getPlayers()
        self.controls = engine.input.controls

        # for simplification of theme writing
        self.fontDict = self.engine.data.fontDict
        self.geometry = self.engine.view.geometry[2:4]
        self.fontScreenBottom = self.engine.data.fontScreenBottom
        self.aspectRatio = self.engine.view.aspectRatio
        self.drawStarScore = self.engine.drawStarScore
Esempio n. 3
0
class Scene(BackgroundLayer, KeyListener):
    def __init__(self, engine):
        self.engine = engine
        self.actors = []
        self.camera = Camera()
        self.world = None
        self.space = None
        self.time = 0.0
        self.actors = []
        self.players = self.engine.world.getPlayers()
        self.controls = engine.input.controls

        # for simplification of theme writing
        self.fontDict = self.engine.data.fontDict
        self.geometry = self.engine.view.geometry[2:4]
        self.fontScreenBottom = self.engine.data.fontScreenBottom
        self.aspectRatio = self.engine.view.aspectRatio
        self.drawStarScore = self.engine.drawStarScore

    def addPlayer(self, player):
        self.players.append(player)

    def removePlayer(self, player):
        self.players.remove(player)

    def run(self, ticks):
        self.time += ticks / 50.0

    def shown(self):
        self.engine.input.addKeyListener(self)

    def hidden(self):
        self.engine.input.removeKeyListener(self)

    def keyPressed(self, key, unicode):
        c = self.controls.keyPressed(key)
        if c:
            return True
        return False

    def keyReleased(self, key):
        c = self.controls.keyReleased(key)
        if c:
            return True
        return False

    def render3D(self):
        pass

    def render(self, visibility, topMost):
        # render the scene
        try:
            glMatrixMode(GL_PROJECTION)
            glPushMatrix()
            glLoadIdentity()
            gluPerspective(60, self.engine.view.aspectRatio, 0.1, 1000)
            glMatrixMode(GL_MODELVIEW)
            glLoadIdentity()

            glPushMatrix()
            self.camera.apply()

            self.render3D()
        finally:
            glPopMatrix()
            glMatrixMode(GL_PROJECTION)
            glPopMatrix()
            glMatrixMode(GL_MODELVIEW)
Esempio n. 4
0
    def __init__(self, engine, libraryName = None, songName = None):
        Scene.__init__(self, engine)

        self.engine.world.sceneName = "SongChoosingScene"

        song.updateSongDatabase(self.engine)

        self.wizardStarted = False
        self.libraryName   = libraryName
        self.songName      = songName
        if not self.libraryName:
            self.libraryName = self.engine.config.get("setlist", "selected_library")
            if not self.libraryName:
                self.libraryName = song.DEFAULT_LIBRARY
        if not self.songName:
            self.songName = self.engine.config.get("setlist", "selected_song")
        self.gameMode = self.engine.world.gameMode
        self.careerMode = (self.gameMode == CAREER)
        self.practiceMode = (self.gameMode == PRACTICE)
        self.gameMode2p = self.engine.world.multiMode
        self.autoPreview = not self.engine.config.get("audio", "disable_preview")
        self.sortOrder   = self.engine.config.get("game", "sort_order")
        self.tut = self.engine.world.tutorial
        self.playerList  = self.players

        self.gameStarted = False

        self.gamePlayers = len(self.playerList)
        self.parts = [None for i in self.playerList]
        self.diffs = [None for i in self.playerList]

        self.time       = 0
        self.lastTime   = 0
        self.mode       = 0
        self.moreInfo   = False
        self.moreInfoTime = 0
        self.miniLobbyTime = 0
        self.selected   = 0
        self.camera     = Camera()
        self.cameraOffset = 0.0
        self.song       = None
        self.songLoader = None
        self.loaded     = False
        text            = _("Initializing Setlist...")
        if self.engine.cmdPlay == 2:
            text = _("Checking Command-Line Settings...")
        elif len(self.engine.world.songQueue) > 0:
            text = _("Checking Setlist Settings...")
        elif len(self.engine.world.songQueue) == 0:
            self.engine.world.playingQueue = False
        self.splash     = Dialogs.showLoadingSplashScreen(self.engine, text)
        self.items      = []
        self.cmdPlay    = False
        self.queued     = True

        self.loadStartTime = time.time()

        if self.tut == True:
            self.library = self.engine.tutorialFolder
        else:
            self.library    = os.path.join(self.engine.config.get("setlist", "base_library"), self.libraryName)
            if not os.path.isdir(self.engine.resource.fileName(self.library)):
                self.library = self.engine.resource.fileName(os.path.join(self.engine.config.get("setlist", "base_library"), song.DEFAULT_LIBRARY))

        self.searchText = ""

        #user configurables and input management
        self.listingMode       = 0     #with libraries or List All
        self.preloadSongLabels = False
        self.showCareerTiers   = 1+(self.careerMode and 1 or 0) #0-Never; 1-Career Only; 2-Always
        self.scrolling        = 0
        self.scrollDelay      = self.engine.config.get("game", "scroll_delay")
        self.scrollRate       = self.engine.config.get("game", "scroll_rate")
        self.scrollTime       = 0
        self.scroller         = [lambda: None, self.scrollUp, self.scrollDown]
        self.scoreDifficulty  = song.difficulties[self.engine.config.get("game", "songlist_difficulty")]
        self.scorePart        = song.parts[self.engine.config.get("game", "songlist_instrument")]
        self.sortOrder        = self.engine.config.get("game", "sort_order")
        self.queueFormat      = self.engine.config.get("game", "queue_format")
        self.queueOrder       = self.engine.config.get("game", "queue_order")
        self.queueParts       = self.engine.config.get("game", "queue_parts")
        self.queueDiffs       = self.engine.config.get("game", "queue_diff")
        self.nilShowNextScore = self.engine.config.get("songlist",  "nil_show_next_score")

        #theme information
        self.themename = self.engine.data.themeLabel
        self.theme = self.engine.data.theme

        #theme configurables
        self.setlistStyle      = self.engine.theme.setlist.setlistStyle    #0 = Normal; 1 = List; 2 = Circular
        self.headerSkip        = self.engine.theme.setlist.headerSkip      #items taken up by header (non-static only)
        self.footerSkip        = self.engine.theme.setlist.footerSkip      #items taken up by footer (non-static only)
        self.itemSize          = self.engine.theme.setlist.itemSize        #delta (X, Y) (0..1) for each item (non-static only)
        self.labelType         = self.engine.theme.setlist.labelType       #Album covers (0) or CD labels (1)
        self.labelDistance     = self.engine.theme.setlist.labelDistance   #number of labels away to preload
        self.showMoreLabels    = self.engine.theme.setlist.showMoreLabels  #whether or not additional unselected labels are rendered on-screen
        self.texturedLabels    = self.engine.theme.setlist.texturedLabels  #render the art as a texture?
        self.itemsPerPage      = self.engine.theme.setlist.itemsPerPage    #number of items to show on screen
        self.followItemPos     = (self.itemsPerPage+1)/2
        self.showLockedSongs   = self.engine.theme.setlist.showLockedSongs #whether or not to even show locked songs
        self.showSortTiers     = self.engine.theme.setlist.showSortTiers   #whether or not to show sorting tiers - career tiers take precedence.
        self.selectTiers       = self.engine.theme.setlist.selectTiers     #whether or not tiers should be selectable as a quick setlist.

        if self.engine.cmdPlay == 2:
            self.songName = Config.get("setlist", "selected_song")
            self.libraryName = Config.get("setlist", "selected_library")
            self.cmdPlay = self.checkCmdPlay()
            if self.cmdPlay:
                Dialogs.hideLoadingSplashScreen(self.engine, self.splash)
                return
        elif len(self.engine.world.songQueue) > 0:
            Dialogs.hideLoadingSplashScreen(self.engine, self.splash)
            return

        #variables for setlist management (Not that this is necessary here - just to see what exists.)
        self.songLoader       = None #preview handling
        self.tiersPresent     = False
        self.startingSelected = self.songName
        self.selectedIndex    = 0
        self.selectedItem     = None
        self.selectedOffset   = 0.0
        self.previewDelay     = 1000
        self.previewLoaded    = False
        self.itemRenderAngles = [0.0]
        self.itemLabels       = [None]
        self.xPos             = 0
        self.yPos             = 0
        self.pos              = 0

        self.infoPage         = 0

        self.menu_force_reload   = False
        self.menu_text_color     = (1, 1, 1)
        self.menu_selected_color = (.66, .66, 0)
        self.menu_text_pos       = (.2, .31)
        self.menu = Menu(self.engine, [ConfigChoice(self.engine, self.engine.config, "game", "queue_format", autoApply = True),
                                       ConfigChoice(self.engine, self.engine.config, "game", "queue_order", autoApply = True),
                                       ConfigChoice(self.engine, self.engine.config, "game", "queue_parts", autoApply = True),
                                       ConfigChoice(self.engine, self.engine.config, "game", "queue_diff", autoApply = True),
                                       ActiveConfigChoice(self.engine, self.engine.config, "game", "sort_order", onChange = self.forceReload),
                                       ActiveConfigChoice(self.engine, self.engine.config, "game", "sort_direction", onChange = self.forceReload),
                                       ActiveConfigChoice(self.engine, self.engine.config, "game", "songlist_instrument", onChange = self.forceReload),
                                       ActiveConfigChoice(self.engine, self.engine.config, "game", "songlist_difficulty", onChange = self.forceReload),
                                       ], name = "setlist", fadeScreen = False, onClose = self.resetQueueVars, font = self.engine.data.pauseFont, \
                         pos = self.menu_text_pos, textColor = self.menu_text_color, selectedColor = self.menu_selected_color)

        #now, load the first library
        self.loadLibrary()

        #load the images
        self.loadImages()
Esempio n. 5
0
File: Scene.py Progetto: htvu/fofix
class Scene(BackgroundLayer, KeyListener):
    def __init__(self, engine):
        self.engine = engine
        self.actors = []
        self.camera = Camera()
        self.world = None
        self.space = None
        self.time = 0.0
        self.actors = []
        self.players = self.engine.world.getPlayers()
        self.controls = engine.input.controls

        # for simplification of theme writing
        self.fontDict = self.engine.data.fontDict
        self.geometry = self.engine.view.geometry[2:4]
        self.fontScreenBottom = self.engine.data.fontScreenBottom
        self.aspectRatio = self.engine.view.aspectRatio
        self.drawStarScore = self.engine.drawStarScore

    def addPlayer(self, player):
        self.players.append(player)

    def removePlayer(self, player):
        self.players.remove(player)

    def run(self, ticks):
        self.time += ticks / 50.0

    def shown(self):
        self.engine.input.addKeyListener(self)

    def hidden(self):
        self.engine.input.removeKeyListener(self)

    def keyPressed(self, key, unicode):
        c = self.controls.keyPressed(key)
        if c:
            return True
        return False

    def keyReleased(self, key):
        c = self.controls.keyReleased(key)
        if c:
            return True
        return False

    def render3D(self):
        pass

    def render(self, visibility, topMost):
        # render the scene
        try:
            glMatrixMode(GL_PROJECTION)
            glPushMatrix()
            glLoadIdentity()
            gluPerspective(60, self.engine.view.aspectRatio, 0.1, 1000)
            glMatrixMode(GL_MODELVIEW)
            glLoadIdentity()

            glPushMatrix()
            self.camera.apply()

            self.render3D()
        finally:
            glPopMatrix()
            glMatrixMode(GL_PROJECTION)
            glPopMatrix()
            glMatrixMode(GL_MODELVIEW)