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

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

# -*- coding:Utf-8 -*- 

############################################################################### 

## Lutris 

## 

## Copyright (C) 2009 Mathieu Comandon strycore@gmail.com 

## 

## This program is free software; you can redistribute it and/or modify 

## it under the terms of the GNU General Public License as published by 

## the Free Software Foundation; either version 3 of the License, or 

## (at your option) any later version. 

## 

## This program is distributed in the hope that it will be useful, 

## but WITHOUT ANY WARRANTY; without even the implied warranty of 

## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 

## GNU General Public License for more details. 

## 

## You should have received a copy of the GNU General Public License 

## along with this program; if not, write to the Free Software 

## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 

############################################################################### 

 

""" Runner for point and click adventure games. """ 

 

import os 

import subprocess 

 

from lutris import settings 

from lutris.util.system import find_executable 

from lutris.runners.runner import Runner 

 

SCUMMVM_CONFIG_FILE = os.path.join(os.path.expanduser("~"), ".scummvmrc") 

 

 

# pylint: disable=C0103 

class scummvm(Runner): 

    """Runs LucasArts games based on the Scumm engine""" 

    def __init__(self, settings=None): 

        super(scummvm, self).__init__() 

        self.executable = "scummvm" 

        self.package = "scummvm" 

        self.platform = "LucasArts point and click games" 

        self.game_options = [ 

            { 

                'option': 'game_id', 

                'type': 'string', 

                'label': "Game identifier" 

            }, 

            { 

                'option': 'path', 

                'type': 'directory_chooser', 

                'label': "Path for the game" 

            } 

        ] 

        scaler_modes = [ 

            ("2x", "2x"), 

            ("3x", "3x"), 

            ("2xsai", "2xsai"), 

            ("advmame2x", "advmame2x"), 

            ("advmame3x", "advmame3x"), 

            ("dotmatrix", "dotmatrix"), 

            ("hq2x", "hq2x"), 

            ("hq3x", "hq3x"), 

            ("normal", "normal"), 

            ("super2xsai", "super2xsai"), 

            ("supereagle", "supereagle"), 

            ("tv2x", "tv2x") 

        ] 

        self.runner_options = [ 

            { 

                "option": "windowed", 

                "label": "Windowed", 

                "type": "bool" 

            }, 

            { 

                "option": "gfx-mode", 

                "label": "Graphics scaler", 

                "type": "one_choice", 

                "choices": scaler_modes 

            } 

        ] 

        self.settings = settings 

 

    def install(self): 

        self.download_and_extract("scummvm.x86.tar.gz") 

 

    def is_installed(self): 

        return bool(self.get_executable()) 

 

    def get_executable(self): 

        scummvm_path = os.path.join(settings.DATA_DIR, 

                                    'runners/scummvm/scummvm') 

        if not os.path.exists(scummvm_path): 

            return find_executable("scummvm") 

        else: 

            return scummvm_path 

 

    def get_game_path(self): 

        return self.settings['game']['path'] 

 

    def play(self): 

        """Run ScummVM game""" 

        gfxmode = "--gfx-mode=normal" 

        fullscreen = "-f"  # -F for windowed 

        config = self.settings.config 

        if "scummvm" in self.settings.config: 

            if "windowed" in config["scummvm"]: 

                if self.settings.config["scummvm"]["windowed"] is True: 

                    fullscreen = "-F" 

            if "gfx-mode" in self.settings.config["scummvm"]: 

                mode = self.settings.config["scummvm"]["gfx-mode"] 

                gfxmode = "--gfx-mode=%s" % mode 

        game = self.settings["game"]["game_id"] 

 

        launch_info = {'command': [ 

            self.get_executable(), 

            "--path=\"%s\"" % self.settings['game']['path'], 

            fullscreen, gfxmode, game 

        ]} 

 

        lib_dir = os.path.join(settings.DATA_DIR, 'runners/scummvm/lib') 

        if os.path.exists(lib_dir): 

            launch_info['ld_library_path'] = lib_dir 

 

        return launch_info 

 

    def get_game_list(self): 

        """ Return the entire list of games supported by ScummVM """ 

        scumm_output = subprocess.Popen( 

            ["scummvm", "-z"], stdout=subprocess.PIPE 

        ).communicate()[0] 

        game_list = str.split(scumm_output, "\n") 

        game_array = [] 

        game_list_start = False 

        for game in game_list: 

            if game_list_start: 

                if len(game) > 1: 

                    dir_limit = game.index(" ") 

                else: 

                    dir_limit = None 

                if dir_limit is not None: 

                    game_dir = game[0:dir_limit] 

                    game_name = game[dir_limit + 1:len(game)].strip() 

                    game_array.append([game_dir, game_name]) 

            # The actual list is below a separator 

            if game.startswith("-----"): 

                game_list_start = True 

        return game_array