def _setup_random_map_selection(self, widget):
		seed_string_field = widget.findChild(name='seed_string_field')
		seed_string_field.capture(self._on_random_map_parameter_changed)
		seed_string_field.text = generate_random_seed(seed_string_field.text)

		map_size_slider = widget.findChild(name='map_size_slider')
		def on_map_size_slider_change():
			widget.findChild(name='map_size_lbl').text = _('Map size:') + u' ' + \
				unicode(self.map_sizes[int(map_size_slider.value)])
			horizons.globals.fife.set_uh_setting("RandomMapSize", map_size_slider.value)
			horizons.globals.fife.save_settings()
			self._on_random_map_parameter_changed()
		map_size_slider.capture(on_map_size_slider_change)
		map_size_slider.value = horizons.globals.fife.get_uh_setting("RandomMapSize")

		water_percent_slider = widget.findChild(name='water_percent_slider')
		def on_water_percent_slider_change():
			widget.findChild(name='water_percent_lbl').text = _('Water:') + u' ' + \
				unicode(self.water_percents[int(water_percent_slider.value)]) + u'%'
			horizons.globals.fife.set_uh_setting("RandomMapWaterPercent", water_percent_slider.value)
			horizons.globals.fife.save_settings()
			self._on_random_map_parameter_changed()
		water_percent_slider.capture(on_water_percent_slider_change)
		water_percent_slider.value = horizons.globals.fife.get_uh_setting("RandomMapWaterPercent")

		max_island_size_slider = widget.findChild(name='max_island_size_slider')
		def on_max_island_size_slider_change():
			widget.findChild(name='max_island_size_lbl').text = _('Max island size:') + u' ' + \
				unicode(self.island_sizes[int(max_island_size_slider.value)])
			horizons.globals.fife.set_uh_setting("RandomMapMaxIslandSize", max_island_size_slider.value)
			horizons.globals.fife.save_settings()
			self._on_random_map_parameter_changed()
		max_island_size_slider.capture(on_max_island_size_slider_change)
		max_island_size_slider.value = horizons.globals.fife.get_uh_setting("RandomMapMaxIslandSize")

		preferred_island_size_slider = widget.findChild(name='preferred_island_size_slider')
		def on_preferred_island_size_slider_change():
			widget.findChild(name='preferred_island_size_lbl').text = _('Preferred island size:') + u' ' + \
				unicode(self.island_sizes[int(preferred_island_size_slider.value)])
			horizons.globals.fife.set_uh_setting("RandomMapPreferredIslandSize", preferred_island_size_slider.value)
			horizons.globals.fife.save_settings()
			self._on_random_map_parameter_changed()
		preferred_island_size_slider.capture(on_preferred_island_size_slider_change)
		preferred_island_size_slider.value = horizons.globals.fife.get_uh_setting("RandomMapPreferredIslandSize")

		island_size_deviation_slider = widget.findChild(name='island_size_deviation_slider')
		def on_island_size_deviation_slider_change():
			widget.findChild(name='island_size_deviation_lbl').text = _('Island size deviation:') + u' ' + \
				unicode(self.island_size_deviations[int(island_size_deviation_slider.value)])
			horizons.globals.fife.set_uh_setting("RandomMapIslandSizeDeviation", island_size_deviation_slider.value)
			horizons.globals.fife.save_settings()
			self._on_random_map_parameter_changed()
		island_size_deviation_slider.capture(on_island_size_deviation_slider_change)
		island_size_deviation_slider.value = horizons.globals.fife.get_uh_setting("RandomMapIslandSizeDeviation")

		on_map_size_slider_change()
		on_water_percent_slider_change()
		on_max_island_size_slider_change()
		on_preferred_island_size_slider_change()
		on_island_size_deviation_slider_change()
Exemple #2
0
	def _setup_random_map_selection(self, widget):
		seed_string_field = widget.findChild(name='seed_string_field')
		seed_string_field.capture(self._on_random_map_parameter_changed)
		seed_string_field.text = generate_random_seed(seed_string_field.text)

		map_size_slider = widget.findChild(name='map_size_slider')
		def on_map_size_slider_change():
			widget.findChild(name='map_size_lbl').text = _('Map size:') + u' ' + \
				unicode(self.map_sizes[int(map_size_slider.value)])
			horizons.globals.fife.set_uh_setting("RandomMapSize", map_size_slider.value)
			horizons.globals.fife.save_settings()
			self._on_random_map_parameter_changed()
		map_size_slider.capture(on_map_size_slider_change)
		map_size_slider.value = horizons.globals.fife.get_uh_setting("RandomMapSize")

		water_percent_slider = widget.findChild(name='water_percent_slider')
		def on_water_percent_slider_change():
			widget.findChild(name='water_percent_lbl').text = _('Water:') + u' ' + \
				unicode(self.water_percents[int(water_percent_slider.value)]) + u'%'
			horizons.globals.fife.set_uh_setting("RandomMapWaterPercent", water_percent_slider.value)
			horizons.globals.fife.save_settings()
			self._on_random_map_parameter_changed()
		water_percent_slider.capture(on_water_percent_slider_change)
		water_percent_slider.value = horizons.globals.fife.get_uh_setting("RandomMapWaterPercent")

		max_island_size_slider = widget.findChild(name='max_island_size_slider')
		def on_max_island_size_slider_change():
			widget.findChild(name='max_island_size_lbl').text = _('Max island size:') + u' ' + \
				unicode(self.island_sizes[int(max_island_size_slider.value)])
			horizons.globals.fife.set_uh_setting("RandomMapMaxIslandSize", max_island_size_slider.value)
			horizons.globals.fife.save_settings()
			self._on_random_map_parameter_changed()
		max_island_size_slider.capture(on_max_island_size_slider_change)
		max_island_size_slider.value = horizons.globals.fife.get_uh_setting("RandomMapMaxIslandSize")

		preferred_island_size_slider = widget.findChild(name='preferred_island_size_slider')
		def on_preferred_island_size_slider_change():
			widget.findChild(name='preferred_island_size_lbl').text = _('Preferred island size:') + u' ' + \
				unicode(self.island_sizes[int(preferred_island_size_slider.value)])
			horizons.globals.fife.set_uh_setting("RandomMapPreferredIslandSize", preferred_island_size_slider.value)
			horizons.globals.fife.save_settings()
			self._on_random_map_parameter_changed()
		preferred_island_size_slider.capture(on_preferred_island_size_slider_change)
		preferred_island_size_slider.value = horizons.globals.fife.get_uh_setting("RandomMapPreferredIslandSize")

		island_size_deviation_slider = widget.findChild(name='island_size_deviation_slider')
		def on_island_size_deviation_slider_change():
			widget.findChild(name='island_size_deviation_lbl').text = _('Island size deviation:') + u' ' + \
				unicode(self.island_size_deviations[int(island_size_deviation_slider.value)])
			horizons.globals.fife.set_uh_setting("RandomMapIslandSizeDeviation", island_size_deviation_slider.value)
			horizons.globals.fife.save_settings()
			self._on_random_map_parameter_changed()
		island_size_deviation_slider.capture(on_island_size_deviation_slider_change)
		island_size_deviation_slider.value = horizons.globals.fife.get_uh_setting("RandomMapIslandSizeDeviation")

		on_map_size_slider_change()
		on_water_percent_slider_change()
		on_max_island_size_slider_change()
		on_preferred_island_size_slider_change()
		on_island_size_deviation_slider_change()
Exemple #3
0
    def show(self):
        seed_string_field = self._gui.findChild(name='seed_string_field')
        seed_string_field.capture(self._on_random_parameter_changed)
        seed_string_field.text = generate_random_seed(seed_string_field.text)

        parameters = (
            ('map_size', self.map_sizes, _('Map size:'), 'RandomMapSize'),
            ('water_percent', self.water_percents, _('Water:'),
             'RandomMapWaterPercent'),
            ('max_island_size', self.island_sizes, _('Max island size:'),
             'RandomMapMaxIslandSize'),
            ('preferred_island_size', self.island_sizes,
             _('Preferred island size:'), 'RandomMapPreferredIslandSize'),
            ('island_size_deviation', self.island_size_deviations,
             _('Island size deviation:'), 'RandomMapIslandSizeDeviation'),
        )

        for param, __, __, setting_name in parameters:
            self._map_parameters[param] = horizons.globals.fife.get_uh_setting(
                setting_name)

        def make_on_change(param, values, text, setting_name):
            # When a slider is changed, update the value displayed in the label, save the value
            # in the settings and store the value in self._map_parameters
            def on_change():
                slider = self._gui.findChild(name=param + '_slider')
                self._gui.findChild(name=param +
                                    '_lbl').text = text + u' ' + unicode(
                                        values[int(slider.value)])
                horizons.globals.fife.set_uh_setting(setting_name,
                                                     slider.value)
                horizons.globals.fife.save_settings()
                self._on_random_parameter_changed()
                self._map_parameters[param] = values[int(slider.value)]

            return on_change

        for param, values, text, setting_name in parameters:
            slider = self._gui.findChild(name=param + '_slider')
            on_change = make_on_change(param, values, text, setting_name)
            slider.capture(on_change)
            slider.value = horizons.globals.fife.get_uh_setting(setting_name)
            on_change()

        self._gui.findChild(name='game_settings_box').addChild(
            self._game_settings.get_widget())
        self._game_settings.show()
        self._aidata.show()
	def show(self):
		seed_string_field = self._gui.findChild(name='seed_string_field')
		seed_string_field.capture(self._on_random_parameter_changed)
		seed_string_field.text = generate_random_seed(seed_string_field.text)

		parameters = (
			('map_size', self.map_sizes, _('Map size:'), 'RandomMapSize'),
			('water_percent', self.water_percents, _('Water:'), 'RandomMapWaterPercent'),
			('max_island_size', self.island_sizes, _('Max island size:'), 'RandomMapMaxIslandSize'),
			('preferred_island_size', self.island_sizes, _('Preferred island size:'), 'RandomMapPreferredIslandSize'),
			('island_size_deviation', self.island_size_deviations, _('Island size deviation:'), 'RandomMapIslandSizeDeviation'),
		)

		for param, __, __, setting_name in parameters:
			self._map_parameters[param] = horizons.globals.fife.get_uh_setting(setting_name)

		def make_on_change(param, values, text, setting_name):
			# When a slider is changed, update the value displayed in the label, save the value
			# in the settings and store the value in self._map_parameters
			def on_change():
				slider = self._gui.findChild(name=param + '_slider')
				self._gui.findChild(name=param + '_lbl').text = text + u' ' + unicode(values[int(slider.value)])
				horizons.globals.fife.set_uh_setting(setting_name, slider.value)
				horizons.globals.fife.save_settings()
				self._on_random_parameter_changed()
				self._map_parameters[param] = values[int(slider.value)]
			return on_change

		for param, values, text, setting_name in parameters:
			slider = self._gui.findChild(name=param + '_slider')
			on_change = make_on_change(param, values, text, setting_name)
			slider.capture(on_change)
			slider.value = horizons.globals.fife.get_uh_setting(setting_name)
			on_change()

		self._gui.findChild(name='game_settings_box').addChild(self._game_settings.get_widget())
		self._game_settings.show()
		self._aidata.show()
	def _on_preview_click(self, event, drag):
		seed_string_field = self._gui.findChild(name='seed_string_field')
		seed_string_field.text = generate_random_seed(seed_string_field.text)
		self._on_random_parameter_changed()
 def _on_preview_click(self, event, drag):
     seed_string_field = self._gui.findChild(name='seed_string_field')
     seed_string_field.text = generate_random_seed(seed_string_field.text)
     self._on_random_parameter_changed()
 def on_click(event, drag):
     seed_string_field = self.current.findChild(
         name='seed_string_field')
     seed_string_field.text = generate_random_seed(
         seed_string_field.text)
     self._on_random_map_parameter_changed()
		def on_click(event, drag):
			seed_string_field = self.current.findChild(name='seed_string_field')
			seed_string_field.text = generate_random_seed(seed_string_field.text)
			self._on_random_map_parameter_changed()