Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

import os 

import subprocess 

 

from lutris.runners.runner import Runner 

 

 

# pylint: disable=C0103 

class sdlmame(Runner): 

    """Runs arcade games with SDLMame""" 

    def __init__(self, settings=None): 

        """ Mame initialization """ 

        super(sdlmame, self).__init__() 

        self.executable = "mame" 

        self.platform = "Arcade" 

        self.game_options = [ 

            { 

                "option": "main_file", 

                "type": "file", 

                "label": "Rom file" 

            } 

        ] 

        self.runner_options = [ 

            { 

                "option": "windowed", 

                "type": "bool", 

                "label": "Windowed" 

            } 

        ] 

        self.settings = settings 

 

    def play(self): 

        """ Launch the game. """ 

        settings = self.settings 

        fullscreen = True 

        rompath = os.path.dirname(settings["game"]["main_file"]) 

        rom = os.path.basename(settings["game"]["main_file"]) 

        mameconfigdir = os.path.join(os.path.expanduser("~"), ".mame") 

        if "sdlmame" in settings.config: 

            if "windowed" in settings["sdlmame"]: 

                fullscreen = not settings["sdlmame"]["windowed"] 

        if not os.path.exists(os.path.join(mameconfigdir, "mame.ini")): 

            try: 

                os.makedirs(mameconfigdir) 

            except OSError: 

                pass 

            os.chdir(mameconfigdir) 

            subprocess.Popen([self.executable, "-createconfig"], 

                             stdout=subprocess.PIPE) 

            os.chdir(rompath) 

        options = [] 

        if not fullscreen: 

            options.append("-window") 

        return {'command': [self.executable, 

                            "-inipath", mameconfigdir, 

                            "-skip_gameinfo", 

                            "-rompath", "\"%s\"" % rompath, 

                            "\"%s\"" % rom] + options}