Ejemplo n.º 1
0
    def __init__(self, screen, suspend):
        print("Main Menu Init")
        self.screen = screen
        self.suspend = suspend
        self.banderole = pygame.Surface((self.config["screenWidth"], 80),
                                        pygame.SRCALPHA)

        self.header = Header.Header(24)

        res = ResumeHandler.getResumeFile()
        if (res != None and res["mainIndex"] != None and res["main"] != None):
            self.currentIndex = res["mainIndex"]

            if ("useSelection" in self.config["mainMenu"][self.currentIndex]
                    and
                    self.config["mainMenu"][self.currentIndex]["useSelection"]
                    != None):
                if (self.config["mainMenu"][self.currentIndex]["useSelection"]
                        == True):
                    self.openSelection(
                        self.config["mainMenu"][self.currentIndex])
                else:
                    ResumeHandler.clearResume()

            else:
                self.openSelection(self.config["mainMenu"][self.currentIndex])

        else:
            if ("firstStart" in self.config and self.config["firstStart"]):
                self.overlay = InfoOverlay.InfoOverlay("theme/info.png",
                                                       self.infoCallback)

        self.loadSystemImages()
Ejemplo n.º 2
0
    def selectionCallback(self, selection):      
        self.subComponent = None

        if(selection is not None):
            self.entryList[self.currentIndex]["options"]["selection"] = selection
            ResumeHandler.setLastSelectedLine(self.currentIndex)
            self.callback(self.entryList[self.currentIndex]["options"])
Ejemplo n.º 3
0
 def onSelect(self):
     if(len(self.entryList) > 0):            
         if("selector" in self.entryList[self.currentIndex]["options"] and self.entryList[self.currentIndex]["options"]["selector"]):              
             self.openSelection()
         else:
             ResumeHandler.setLastSelectedLine(self.currentIndex)
             self.callback(self.entryList[self.currentIndex]["options"])                    
Ejemplo n.º 4
0
    def onSelect(self):
        if(len(self.entryList) == 0):
            self.callback(None)
            return

        if(self.entryList[self.currentIndex]["isFolder"]):
            self.loadFolder(self.entryList[self.currentIndex])
        else:
            ResumeHandler.setLastSelectedLine(self.currentIndex)
            ResumeHandler.setLastPath(os.path.normpath(self.currentPath + "/"))
            self.callback(os.path.normpath(self.currentPath + "/" + self.entryList[self.currentIndex]["name"]))
Ejemplo n.º 5
0
    def openSelection(self, current):
        print("Opening selection")
        ResumeHandler.setLastUsedMain(current, self.currentIndex)

        if (current["type"] == "emulator"):
            print("Opening emulator file selection")
            options = {}
            options["textColor"] = (55, 55, 55)
            options["background"] = current["background"]
            options["useSidebar"] = True

            if ("description" in current):
                options["description"] = current["description"]

            if ("folderIcon" in current):
                options["folderIcon"] = current["folderIcon"]

            if ("previews" in current):
                options["previews"] = current["previews"]

            if ("fileFilter" in current):
                options["fileFilter"] = current["fileFilter"]

            self.subComponent = FileChooser.FileChooser(
                self.screen, current["name"], current["selectionPath"], False,
                options, self.emulatorCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "select")],
                                   (255, 255, 255))
            self.subComponent.setFooter(footer)

        if (current["type"] == "native"):
            print("Opening native selection")
            options = {}
            options["background"] = current["background"]
            options["useSidebar"] = True
            self.subComponent = NativeAppList.NativeAppList(
                self.screen, current["name"], current["data"], options,
                self.nativeCallback)
            if ("allowEdit" in self.config["options"]
                    and self.config["options"]["allowEdit"]):
                footer = Footer.Footer(
                    [("theme/direction.png", "select")],
                    [("theme/b_button.png", "back"),
                     ("theme/a_button.png", "select"),
                     ("theme/select_button.png", "options")], (255, 255, 255))
            else:
                footer = Footer.Footer([("theme/direction.png", "select")],
                                       [("theme/b_button.png", "back"),
                                        ("theme/a_button.png", "select")],
                                       (255, 255, 255))
            self.subComponent.setFooter(footer)
Ejemplo n.º 6
0
    def handleEvents(self, events):
        for event in events:
            if event.type == pygame.KEYDOWN:
                self.keyDown = True

                if (not len(self.entryList) <= 1):
                    self.preview_final = None

                if event.key == Keys.DINGOO_BUTTON_UP:
                    if (not len(self.entryList) <= 1):
                        self.up()
                        self.onChange()
                        RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_DOWN:
                    if (not len(self.entryList) <= 1):
                        self.down()
                        self.onChange()
                        RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_L:
                    self.up(self.maxListEntries)
                    self.onChange()
                    RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_R:
                    self.down(self.maxListEntries)
                    self.onChange()
                    RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_A:
                    self.onSelect()
                    RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_B:
                    ResumeHandler.clearResume()
                    self.onExit()
                    RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_Y:
                    self.toggleSidebar(not self.useSidebar)
                    RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_X:
                    self.previewEnabled = not self.previewEnabled
                    RenderControl.setDirty()
            if event.type == pygame.KEYUP:
                self.keyDown = False
                self.preview_final = self.previewPath

                self.anim = None
                self.image = None

                self.renderAnim = False
                TaskHandler.removePeriodicTask(self.animTask)
                self.animTask = TaskHandler.addPeriodicTask(
                    1000, self.onShowAnim, 1000)
                RenderControl.setDirty()
Ejemplo n.º 7
0
def runNative(config):
    ResumeHandler.storeResume()
    cmd = config["cmd"] if "cmd" in config else None

    if (cmd == None or not os.path.isfile(cmd)):
        print("cmd needs to be set to an existing executable")
        return

    print("Platform is: " + platform.processor())

    if (platform.processor() == ""):
        runNativeMIPS(cmd, config)
    else:
        runNativeHost(cmd, config)
Ejemplo n.º 8
0
    def __init__(self, screen, titel, data, options, callback):
        AbstractList.AbstractList.__init__(self, screen, titel, options)

        self.options = options
        self.callback = callback
        self.data = data

        self.yFolderOffset = (self.listEntryHeight -
                              self.folderIcon.get_height()) / 2
        self.xFolderOffset = (self.listEntryHeight -
                              self.folderIcon.get_width()) / 2

        self.yFileOffset = (self.listEntryHeight -
                            self.fileIcon.get_height()) / 2
        self.xFileOffset = (self.listEntryHeight -
                            self.fileIcon.get_width()) / 2

        self.initList()

        res = ResumeHandler.getResumeFile()

        if (res != None and res["line"] != None
                and ("type" in options and options["type"] != "lastPlayed"
                     and options["type"] != "favourites")):
            self.setSelection(res["line"])
            self.onChange()

            if (not self.currentSelection == None):
                self.previewPath = self.currentSelection["preview"]
                self.preview_final = self.previewPath

            RenderControl.setDirty()

        AbstractList.AbstractList.updatePreview(self)
        self.onChange()
Ejemplo n.º 9
0
def runEmu(config, rom):
    ResumeHandler.storeResume()
    name = config["name"]
    workdir = config["workingDir"] if "workingDir" in config else None
    cmd = config["cmd"] if "workingDir" in config else None

    if (cmd == None or not os.path.isfile(cmd)):
        print("cmd needs to be set to an existing executable")
        return

    print("Platform is: " + platform.processor())
    if (workdir == None and not cmd == None):
        workdir = os.path.abspath(os.path.join(cmd, os.pardir))

    if (platform.processor() == ""):
        runEmuMIPS(name, cmd, workdir, config, rom)
    else:
        runEmuHost(name, cmd, workdir, config, rom)
Ejemplo n.º 10
0
    def handleEvents(self, events):
        for event in events:
            if event.type == pygame.KEYDOWN:
                self.keyDown = True

                if (not len(self.entryList) <= 1):
                    self.preview_final = None

                if event.key == Keys.DINGOO_BUTTON_UP:
                    if (not len(self.entryList) <= 1):
                        self.up()
                        self.onChange()
                        RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_DOWN:
                    if (not len(self.entryList) <= 1):
                        self.down()
                        self.onChange()
                        RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_L:
                    self.up(self.maxListEntries)
                    self.onChange()
                    RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_R:
                    self.down(self.maxListEntries)
                    self.onChange()
                    RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_A:
                    self.onSelect()
                    RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_B:
                    ResumeHandler.clearResume()
                    self.onExit()
                    RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_Y:
                    self.toggleSidebar(not self.useSidebar)
                    RenderControl.setDirty()
                if event.key == Keys.DINGOO_BUTTON_X:
                    self.previewEnabled = not self.previewEnabled
                    RenderControl.setDirty()
            if event.type == pygame.KEYUP:
                self.keyDown = False
                self.preview_final = self.previewPath
                RenderControl.setDirty()
Ejemplo n.º 11
0
    def __init__(self, screen, titel, initialPath, selectFolder, options,
                 callback):
        AbstractList.AbstractList.__init__(self, screen, titel, options)

        if (initialPath == None or initialPath == "/"):
            initialPath = "/"

        self.getExistingParent(initialPath)

        if (os.path.exists(initialPath) and not os.path.isfile(initialPath)):
            self.currentPath = initialPath
        else:
            self.currentPath = self.getExistingParent(initialPath)

        if ("directPreview" in self.options and self.options["directPreview"]):
            self.previewEnabled = True

        if ("previews" in self.options and self.options["previews"] != None
                and os.path.exists(self.options["previews"])):
            self.previewEnabled = True

        self.currentSelection = initialPath
        self.initialPath = initialPath
        self.selectFolder = selectFolder
        self.callback = callback

        self.yFolderOffset = (self.listEntryHeight -
                              self.folderIcon.get_height()) / 2
        self.xFolderOffset = (self.listEntryHeight -
                              self.folderIcon.get_width()) / 2 + 2

        self.yFileOffset = 0

        self.res = ResumeHandler.getResumeFile()
        if (self.res != None and self.res["path"] != None):
            self.currentSelection = self.res["path"]
            self.currentPath = self.res["path"]
            self.initialPath = self.res["path"]

        self.initList()

        if (self.res != None and self.res["line"] != None):
            self.setInitialSelection(self.res["line"])
        else:
            if (os.path.isfile(initialPath) and self.fileList is not None):
                name = ntpath.basename(initialPath)
                index = self.fileList.index(name)
                if (index != -1):
                    self.setInitialSelection(index + 1)

        if (initialPath == None or initialPath == "/"):
            self.moveFolderUp()
Ejemplo n.º 12
0
    def __init__(self, screen, titel, initialPath, selectFolder, options,
                 callback):
        AbstractList.AbstractList.__init__(self, screen, titel, options)

        print("Opening selection with options: " + str(options))

        if (initialPath == None or initialPath == "/"):
            initialPath = "/"

        self.getExistingParent(initialPath)

        if (os.path.exists(initialPath) and not os.path.isfile(initialPath)):
            self.currentPath = initialPath
        else:
            self.currentPath = self.getExistingParent(initialPath)

        if ("directPreview" in self.options and self.options["directPreview"]):
            self.previewEnabled = True

        if ("previews" in self.options and self.options["previews"] != None
                and os.path.exists(self.options["previews"])):
            self.previewEnabled = True

        self.currentSelection = initialPath
        self.initialPath = initialPath
        self.selectFolder = selectFolder
        self.callback = callback

        #tint folder icon in text color
        self.folderIcon = self.folderIcon.convert_alpha().copy()
        self.folderIcon.fill(self.textColor, None, pygame.BLEND_RGBA_MULT)

        self.yFolderOffset = (self.listEntryHeight -
                              self.folderIcon.get_height()) / 2
        self.xFolderOffset = (self.listEntryHeight -
                              self.folderIcon.get_width()) / 2 + 2

        self.yFileOffset = 0

        self.res = ResumeHandler.getResumeFile()
        if (self.res != None and self.res["path"] != None):
            self.currentSelection = self.res["path"]
            self.currentPath = self.res["path"]
            self.initialPath = self.res["path"]

        self.initList()

        if (initialPath == None or initialPath == "/"):
            self.moveFolderUp()

        self.onChange()
Ejemplo n.º 13
0
    def openSelection(self, current):
        print("Opening selection")
        ResumeHandler.setLastUsedMain(current, self.currentIndex)

        options = Theme.getSelectionOptions()

        if (current["type"] == "emulator"):

            if ("useSelection" in current
                    and current["useSelection"] == False):
                print("Running emulator directly")
                self.emulatorCallback("", Keys.DINGOO_BUTTON_A, False)
                return

            print("Opening emulator file selection")

            options["entry"] = self.config["mainMenu"][self.currentIndex]
            options["background"] = current["background"]
            options["useSidebar"] = True
            options["useGamelist"] = current[
                "useGamelist"] if "useGamelist" in current else False

            options["backgroundColor"] = Theme.getColor(
                "selection/backgroundColor", (255, 255, 255, 160))

            if ("description" in current):
                options["description"] = current["description"]

            if ("folderIcon" in current):
                options["folderIcon"] = current["folderIcon"]

            if ("previews" in current):
                options["previews"] = current["previews"]

            if ("fileFilter" in current):
                options["fileFilter"] = current["fileFilter"]

            if ("useFileFilter" in current):
                options["useFileFilter"] = current["useFileFilter"]

            if ("limitSelection" in current):
                options["limitSelection"] = current["limitSelection"]

            if ("hideFolders" in current):
                options["hideFolders"] = current["hideFolders"]

            options["selectionPath"] = current["selectionPath"]

            self.subComponent = FileChooser.FileChooser(
                self.screen, current["name"], current["selectionPath"], False,
                options, self.emulatorCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/start_button.png", "Open with"),
                                    ("theme/a_button.png", "select")],
                                   options["footerFontColor"],
                                   options["footerColor"])
            self.subComponent.setFooter(footer)

        if (current["type"] == "native"):
            print("Opening native selection")

            options["background"] = current["background"]
            options["useSidebar"] = True

            if ("linkPath" in current):
                options["linkPath"] = current["linkPath"]

            self.subComponent = NativeAppList.NativeAppList(
                self.screen, current["name"], current["data"], options,
                self.nativeCallback)
            if ("allowEdit" in self.config["options"]
                    and self.config["options"]["allowEdit"]):
                footer = Footer.Footer(
                    [("theme/direction.png", "select")],
                    [("theme/b_button.png", "back"),
                     ("theme/a_button.png", "select"),
                     ("theme/select_button.png", "options")],
                    options["footerFontColor"], options["footerColor"])
            else:
                footer = Footer.Footer([("theme/direction.png", "select")],
                                       [("theme/b_button.png", "back"),
                                        ("theme/a_button.png", "select")],
                                       options["footerFontColor"],
                                       options["footerFontColor"])
            self.subComponent.setFooter(footer)

        if (current["type"] == "lastPlayed"
                or current["type"] == "favourites"):
            print("Opening customList selection")

            options["background"] = current["background"]
            options["useSidebar"] = True
            options["type"] = current["type"]

            options["backgroundColor"] = Theme.getColor(
                "selection/backgroundColor", (255, 255, 255, 160))

            self.subComponent = NativeAppList.NativeAppList(
                self.screen, current["name"], current["data"], options,
                self.customListCallback)
            footer = Footer.Footer([("theme/direction.png", "select")],
                                   [("theme/b_button.png", "back"),
                                    ("theme/a_button.png", "select")],
                                   options["footerFontColor"],
                                   options["footerColor"])
            self.subComponent.setFooter(footer)