def on_custom_texture(self, event): # Let the user choose a file from the shared textures mangled_shared_dir = format.mangle_path( "wc:export/textures" ) directory = guisettings.Repository.getsettingvalue( guisettings.ID_BrowserPath_SharedMaterial ) if directory == "": directory = mangled_shared_dir dlg = wx.FileDialog( self, message="Choose an image file", defaultDir = directory, wildcard="Image files (*.dds)|*.dds", style=wx.OPEN ) if dlg.ShowModal() == wx.ID_OK: mangled_path = format.mangle_path( dlg.GetPath() ) if not mangled_path.startswith( mangled_shared_dir ): msg = "You should choose a texture file from the" \ " directory 'wc:export/textures' or below." cjr.show_error_message(msg) else: self.set_custom_texture( format.get_relative_path( mangled_shared_dir, mangled_path ) ) # Record last directory directory = format.get_directory(mangled_path) guisettings.Repository.setsettingvalue( guisettings.ID_BrowserPath_SharedMaterial, directory ) dlg.Destroy()
def on_custom_texture(self, event): # Let the user choose a file from the shared textures mangled_shared_dir = format.mangle_path("wc:export/textures") directory = guisettings.Repository.getsettingvalue( guisettings.ID_BrowserPath_SharedMaterial) if directory == "": directory = mangled_shared_dir dlg = wx.FileDialog(self, message="Choose an image file", defaultDir=directory, wildcard="Image files (*.dds)|*.dds", style=wx.OPEN) if dlg.ShowModal() == wx.ID_OK: mangled_path = format.mangle_path(dlg.GetPath()) if not mangled_path.startswith(mangled_shared_dir): msg = "You should choose a texture file from the" \ " directory 'wc:export/textures' or below." cjr.show_error_message(msg) else: self.set_custom_texture( format.get_relative_path(mangled_shared_dir, mangled_path)) # Record last directory directory = format.get_directory(mangled_path) guisettings.Repository.setsettingvalue( guisettings.ID_BrowserPath_SharedMaterial, directory) dlg.Destroy()
def on_texture(self, event): # Let the user choose a file among the shared textures mangled_shared_dir = format.mangle_path( "wc:export/textures" ) dir = cfg.Repository.getsettingvalue( cfg.ID_BrowserPath_SharedMaterial ) if dir == "": dir = mangled_shared_dir dlg = wx.FileDialog( self, message="Choose an image file", defaultDir = dir, wildcard="Image files (*.dds)|*.dds", style=wx.OPEN ) if dlg.ShowModal() == wx.ID_OK: mangled_path = format.mangle_path( dlg.GetPath() ) if not mangled_path.startswith( mangled_shared_dir ): wx.MessageBox("You should choose a texture file from the" \ " directory 'wc:export/textures' or below.", "Conjurer", style=wx.ICON_ERROR) else: self.button_texture.SetLabel( format.get_relative_path( mangled_shared_dir, mangled_path ) ) # Record last directory dir = format.get_directory( mangled_path ) cfg.Repository.setsettingvalue( cfg.ID_BrowserPath_SharedMaterial, dir ) dlg.Destroy()
def on_choose_shared_texture(self, event): # let the user choose a file among the shared textures mangled_shared_dir = format.mangle_path(self.get_shared_path()) target_dir = guisettings.Repository.getsettingvalue( guisettings.ID_BrowserPath_SharedMaterial) if target_dir == "": target_dir = mangled_shared_dir dlg = wx.FileDialog(self.window, message="Choose an image file", defaultDir=target_dir, wildcard="Image files (*.dds)|*.dds", style=wx.OPEN) if dlg.ShowModal() == wx.ID_OK: mangled_path = format.mangle_path(dlg.GetPath()) if not mangled_path.startswith(mangled_shared_dir): cjr.show_error_message( "You should choose a texture file from the " \ "'%s' directory ' or below." % self.get_shared_path() ) else: self.button_shared_texture.SetLabel( format.get_relative_path(mangled_shared_dir, mangled_path)) self.radio_shared_texture.Enable(True) self.radio_local_texture.SetValue(False) self.radio_shared_texture.SetValue(True) # Record last directory target_dir = format.get_directory(mangled_path) guisettings.Repository.setsettingvalue( guisettings.ID_BrowserPath_SharedMaterial, target_dir) dlg.Destroy()
def on_resource(self, event): # Let the user choose a file mangled_dir = format.mangle_path(self.location) dlg = wx.FileDialog( self, message="Choose a sound file", defaultDir=mangled_dir, wildcard="WAV files (*.wav)|*.wav|OGG files (*.ogg)|*.ogg", style=wx.OPEN) if dlg.ShowModal() == wx.ID_OK: path_string = dlg.GetPath() if not self.__is_valid_resource_name(path_string): msg = "You must choose a sound file from %s" % self.location cjr.show_error_message(msg) else: self.set_resource( format.get_relative_path( self.__get_mangled_sound_root_dir(), format.mangle_path(path_string))) dlg.Destroy()
def on_choose_shared_texture(self, event): # let the user choose a file among the shared textures mangled_shared_dir = format.mangle_path( self.get_shared_path() ) target_dir = guisettings.Repository.getsettingvalue( guisettings.ID_BrowserPath_SharedMaterial ) if target_dir == "": target_dir = mangled_shared_dir dlg = wx.FileDialog( self.window, message="Choose an image file", defaultDir = target_dir, wildcard="Image files (*.dds)|*.dds", style=wx.OPEN ) if dlg.ShowModal() == wx.ID_OK: mangled_path = format.mangle_path( dlg.GetPath() ) if not mangled_path.startswith( mangled_shared_dir ): cjr.show_error_message( "You should choose a texture file from the " \ "'%s' directory ' or below." % self.get_shared_path() ) else: self.button_shared_texture.SetLabel( format.get_relative_path( mangled_shared_dir, mangled_path ) ) self.radio_shared_texture.Enable(True) self.radio_local_texture.SetValue(False) self.radio_shared_texture.SetValue(True) # Record last directory target_dir = format.get_directory( mangled_path ) guisettings.Repository.setsettingvalue( guisettings.ID_BrowserPath_SharedMaterial, target_dir ) dlg.Destroy()
def on_resource(self, event): # Let the user choose a file mangled_dir = format.mangle_path(self.location) dlg = wx.FileDialog( self, message="Choose a sound file", defaultDir = mangled_dir, wildcard="WAV files (*.wav)|*.wav|OGG files (*.ogg)|*.ogg", style=wx.OPEN ) if dlg.ShowModal() == wx.ID_OK: path_string = dlg.GetPath() if not self.__is_valid_resource_name(path_string): msg = "You must choose a sound file from %s" % self.location cjr.show_error_message(msg) else: self.set_resource( format.get_relative_path( self.__get_mangled_sound_root_dir(), format.mangle_path(path_string) ) ) dlg.Destroy()
def __set_properties(self): # default projection self.choice_projection.SetSelection(0) # allowed UV size values outdoor = app.get_outdoor() min_value = 0.25 self.max_uvsize = outdoor.getheightmap().getgridscale() * \ (outdoor.getblocksize() - 1) while min_value <= self.max_uvsize: self.choice_u.Append( str(min_value) ) self.choice_v.Append( str(min_value) ) min_value = min_value * 2 # valid texture files self.__update_combo_local_texture() # default texture files self.button_shared_texture.SetLabel( "dds/ground/cesped_test_terrain.dds" ) if self.combo_local_texture.GetCount() == 0: self.radio_local_texture.Enable(False) else: self.combo_local_texture.SetSelection(0) self.radio_local_texture.SetValue(False) self.radio_shared_texture.SetValue(True) # default UV size self.choice_u.SetValue("1.0") self.choice_v.SetValue("1.0") # align texture box fields by setting all labels to longest length format.align_labels([ self.radio_local_texture, self.radio_shared_texture, self.label_u, self.label_projection ]) # valid game materials self.__update_game_materials_choicer() # current settings if self.layer_ctrl is not None: self.text_name.SetValue( self.layer_ctrl.get_layer_name() ) mangled_path = format.mangle_path( self.layer_ctrl.get_texture_filename() ) mangled_local_dir = format.mangle_path( self.get_textures_path() ) mangled_shared_dir = format.mangle_path( self.get_shared_path() ) if mangled_path.startswith( mangled_local_dir ): self.combo_local_texture.SetStringSelection( format.get_relative_path( mangled_local_dir, mangled_path ) ) self.radio_shared_texture.SetValue(False) self.radio_local_texture.SetValue(True) else: self.button_shared_texture.SetLabel( format.get_relative_path( mangled_shared_dir, mangled_path ) ) self.radio_local_texture.SetValue(False) self.radio_shared_texture.SetValue(True) uv_scale = self.layer_ctrl.get_uv_scale() self.choice_u.SetValue( str( self.uvscale2size(uv_scale[0]) ) ) self.choice_v.SetValue( str( self.uvscale2size(uv_scale[1]) ) ) self.choice_projection.SetSelection( self.layer_ctrl.get_projection() ) color = self.layer_ctrl.get_color_mask().Get() self.color_sel.set_value(color)
def __set_properties(self): # default projection self.choice_projection.SetSelection(0) # allowed UV size values outdoor = app.get_outdoor() min_value = 0.25 self.max_uvsize = outdoor.getheightmap().getgridscale() * \ (outdoor.getblocksize() - 1) while min_value <= self.max_uvsize: self.choice_u.Append(str(min_value)) self.choice_v.Append(str(min_value)) min_value = min_value * 2 # valid texture files self.__update_combo_local_texture() # default texture files self.button_shared_texture.SetLabel( "dds/ground/cesped_test_terrain.dds") if self.combo_local_texture.GetCount() == 0: self.radio_local_texture.Enable(False) else: self.combo_local_texture.SetSelection(0) self.radio_local_texture.SetValue(False) self.radio_shared_texture.SetValue(True) # default UV size self.choice_u.SetValue("1.0") self.choice_v.SetValue("1.0") # align texture box fields by setting all labels to longest length format.align_labels([ self.radio_local_texture, self.radio_shared_texture, self.label_u, self.label_projection ]) # valid game materials self.__update_game_materials_choicer() # current settings if self.layer_ctrl is not None: self.text_name.SetValue(self.layer_ctrl.get_layer_name()) mangled_path = format.mangle_path( self.layer_ctrl.get_texture_filename()) mangled_local_dir = format.mangle_path(self.get_textures_path()) mangled_shared_dir = format.mangle_path(self.get_shared_path()) if mangled_path.startswith(mangled_local_dir): self.combo_local_texture.SetStringSelection( format.get_relative_path(mangled_local_dir, mangled_path)) self.radio_shared_texture.SetValue(False) self.radio_local_texture.SetValue(True) else: self.button_shared_texture.SetLabel( format.get_relative_path(mangled_shared_dir, mangled_path)) self.radio_local_texture.SetValue(False) self.radio_shared_texture.SetValue(True) uv_scale = self.layer_ctrl.get_uv_scale() self.choice_u.SetValue(str(self.uvscale2size(uv_scale[0]))) self.choice_v.SetValue(str(self.uvscale2size(uv_scale[1]))) self.choice_projection.SetSelection( self.layer_ctrl.get_projection()) color = self.layer_ctrl.get_color_mask().Get() self.color_sel.set_value(color)