Example #1
0
 def set_sound_volume(self, value):
     self.sound_volume = value / 100.0
     if pybass:
         pybass.BASS_SetVolume(self.sound_volume)
     #~ print(self.config.get_float('sound_volume', 1.0), self.sound_volume)
     #~ if self.config.get_float('sound_volume', 1.0) != self.sound_volume:
     self.config.set('sound_volume', self.sound_volume)
Example #2
0
 def __init__(self, *args, **kwargs):
     self.config_file_name = kwargs.pop('config_file_name', 'randomiz.ini')
     self.config = config(file_name=self.config_file_name)
     self.time_delay = self.config.get_int('time_delay', 2)
     self.play_sound = self.config.get_bool('play_sound', True)
     self.texture_from_file = self.config.get_bool('texture_from_file',
                                                   False)
     self.sound_volume = self.config.get_float('sound_volume', 1.0)
     self.sound_file = self.config.get('sound_file', 'media//sound.mod')
     self.bass_handle = None
     self.sound_playing = False
     self.menu_options = None
     if pybass:
         if pybass.BASS_Init(-1, 44100, 0, 0, 0):
             pybass.BASS_SetVolume(self.sound_volume)
             if os.path.isfile(self.sound_file):
                 self.bass_handle = pybass.BASS_MusicLoad(
                     False, self.sound_file, 0, 0,
                     pybass.BASS_MUSIC_PRESCAN | pybass.BASS_SAMPLE_LOOP, 0)
                 if self.play_sound:
                     self.sound_play()
     self.device_type = self.config.get_int('device_type', EDT_OPENGL)
     self.window_size = dimension2du(
         self.config.get_int('window_width', 640),
         self.config.get_int('window_height', 480))
     self.device = createDevice(self.device_type, self.window_size)
     self.menu_device_types = {}
     self.help_dialog = None
     self.fog_enable = self.config.get_bool('fog_enable', True)
     self.fog_color = SColor(
         *self.config.get('fog_color', (0, 255, 255, 255)))
     self.fog_type = self.config.get_int('fog_type', EFT_FOG_LINEAR)
     self.fog_start = self.config.get_float('fog_start', 500.0)
     self.fog_end = self.config.get_float('fog_end', 1000.0)
     self.fog_density = self.config.get_float('fog_density', 0.01)
     self.fog_pixel = self.config.get_bool('fog_pixel', False)
     self.fog_range = self.config.get_bool('fog_range', False)
     # random volume variable
     self.tile_count = randint(10, 50)
     # len tile
     self.tile_len = 100
     self.results = 0
Example #3
0
 def event_volume_slider(self, event):
     pybass.BASS_SetVolume(event.GetPosition() / 100.0)
Example #4
0
 def set_sound_volume(self, value):
     self.sound_volume = value / 100.0
     if pybass:
         pybass.BASS_SetVolume(self.sound_volume)
     self.config.set('sound_volume', self.sound_volume)
Example #5
0
 def __init__(self, *args, **kwargs):
     global pybass, pyespeak
     self.config_file_name = kwargs.pop('config_file_name', 'entrain.ini')
     self.config = config(file_name=self.config_file_name)
     self.time_delay = self.config.get_int('time_delay', 5)
     self.play_sound = self.config.get_bool('play_sound', True)
     self.sound_volume = self.config.get_float('sound_volume', 0.5)
     self.music_file = self.config.get('music_file',
                                       'music//Ranger_Song.s3m')
     self.svg_directory = self.config.get('svg_dir', 'svg_data')
     if not os.path.isdir(self.svg_directory):
         self.svg_directory = ''
     self.bass_handle = None
     self.sound_playing = False
     self.menu_options = None
     if pybass:
         if pybass.BASS_Init(-1, 44100, 0, 0, 0):
             pybass.BASS_SetVolume(self.sound_volume)
             if os.path.isfile(self.music_file):
                 self.bass_handle = pybass.BASS_MusicLoad(
                     False, self.music_file, 0, 0,
                     pybass.BASS_MUSIC_PRESCAN | pybass.BASS_SAMPLE_LOOP, 0)
                 if self.play_sound:
                     self.sound_play()
         else:
             pybass = None
     self.voice_rate = self.config.get_int('voice_rate', 150)
     self.voice_pitch = self.config.get_int('voice_pitch', 50)
     if pyespeak:
         if pyespeak.espeak_Initialize(pyespeak.AUDIO_OUTPUT_SYNCH_PLAYBACK,
                                       0, '.',
                                       0) == pyespeak.EE_INTERNAL_ERROR:
             pyespeak = None
         else:
             pyespeak.espeak_SetVoiceByName('default')
             pyespeak.espeak_SetParameter(pyespeak.espeakRATE,
                                          self.voice_rate, 0)
             pyespeak.espeak_SetParameter(pyespeak.espeakPITCH,
                                          self.voice_pitch, 0)
     default_driver_type = EDT_SOFTWARE
     if 'win' in sys.platform:
         default_driver_type = EDT_DIRECT3D9
     elif 'linux' in sys.platform:
         default_driver_type = EDT_OPENGL
     self.device_parameters = SIrrlichtCreationParameters()
     self.device_parameters.DriverType = self.config.get_int(
         'driver_type', default_driver_type)
     self.device_parameters.WindowSize = dimension2du(
         self.config.get_int('window_width', 640),
         self.config.get_int('window_height', 480))
     self.device_parameters.AntiAlias = self.config.get_int('anti_alias', 2)
     self.device_parameters.WithAlphaChannel = self.config.get_bool(
         'with_alpha_channel', True)
     self.device = createDeviceEx(self.device_parameters)
     self.menu_driver_types = {}
     self.help_dialog = None
     self.good_results = 0
     self.bad_results = 0
     #~ self.button_repeat_voice = None
     self.voice_on = self.config.get_bool('voice_on', True)
     self.font_size = self.config.get_int('font_size', 32)
     self.font_file = self.replace_env_vars(
         self.config.get('font_file', '@SYSTEMROOT@/Fonts/arial.ttf'))
     self.gui_font_size = self.config.get_int('gui_font_size', 24)
     self.gui_font_file = self.replace_env_vars(
         self.config.get('gui_font_file', '@SYSTEMROOT@/Fonts/arial.ttf'))
     self.svg_image = None
Example #6
0
        font_ext = '.ttf'
        font_path = os.environ['SYSTEMROOT'] + '/Fonts/'
        font_file = font_path + 'arial' + font_ext
        gui_font = CGUITTFont(guienv, font_file, 12)
        if not gui_font:
            gui_font = guienv.getBuiltInFont()

        skin = guienv.getSkin()
        skin.setFont(gui_font)
        gui_font.drop()
        menu_height = skin.getSize(EGDS_MENU_HEIGHT)

        if pybass:
            if pybass.BASS_Init(-1, 44100, 0, 0, 0):
                pybass.BASS_SetVolume(sound_volume)
                if os.path.isfile(sound_file):
                    bass_handle = pybass.BASS_MusicLoad(
                        False, sound_file, 0, 0,
                        pybass.BASS_MUSIC_PRESCAN | pybass.BASS_SAMPLE_LOOP, 0)
                    if play_sound:
                        sound_play()

        menu_options = None

        menu = guienv.addMenu()
        menu.addItem(_('File'), -1, True, True)
        menu.addItem(_('Options'), -1, True, True)
        menu.addItem(_('Help'), -1, True, True)

        submenu = menu.getSubMenu(0)