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_import_texture(self, event): target_dir = guisettings.Repository.getsettingvalue( guisettings.ID_BrowserPath_LocalMaterial ) if target_dir == "": target_dir = servers.get_file_server().manglepath( "textures:" ) 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: if filedlg.copy_file( dlg.GetPath(), self.get_textures_path() ): self.__update_combo_local_texture() # Record last directory target_dir = format.get_directory( dlg.GetPath() ) guisettings.Repository.setsettingvalue( guisettings.ID_BrowserPath_LocalMaterial, target_dir ) dlg.Destroy()
def on_open(self, event): """Open a file dialog and load the selected file""" # IMPORTANT: Update these ids if wildcard changes ID_Script = 0 wildcard = "Script files (*.lua,*.py)|*.lua;*.py" dir_name = guisettings.Repository.getsettingvalue( guisettings.ID_BrowserPath_File) dlg = wx.FileDialog(self.get_frame(), message="Choose a file", defaultDir=dir_name, wildcard=wildcard, style=wx.OPEN) if dlg.ShowModal() == wx.ID_OK: index = dlg.GetFilterIndex() if index == ID_Script: self.__open_script(dlg.GetPath()) # Record last directory last_dir = format.get_directory(dlg.GetPath()) guisettings.Repository.setsettingvalue( guisettings.ID_BrowserPath_File, last_dir) 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_export_heightmap(self, evt): """ Show a file browser and export the heightmap with the entered file name """ target_directory = guisettings.Repository.getsettingvalue( guisettings.ID_BrowserPath_Heightmap) dlg = wx.FileDialog( self.get_frame(), message="Save heightmap as", defaultDir=target_directory, wildcard="BMP image (*.bmp)|*.bmp|" \ "TGA image (*.tga)|*.tga|" \ "jpeg image (*.jpg)|*.jpg|" \ "PNG image (*.png)|*.png|" \ "dds image (*.dds)|*.dds|" \ "PPM image(*.ppm)|*.ppm|" \ "DIB image (*.dib)|*.dib|" \ "PFM image (*.pfm)|*.pfm|" | "Any file (*.*)|*.*", style=wx.SAVE|wx.OVERWRITE_PROMPT ) dlg.SetFilterIndex(1) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() path = servers.get_file_server().manglepath(str(path)) trn.get_terrain_module().exportheightmap(str(path)) # Record last directory last_directory = format.get_directory(path) guisettings.Repository.setsettingvalue( guisettings.ID_BrowserPath_Heightmap, last_directory) dlg.Destroy()
def on_export_heightmap(self, evt): """ Show a file browser and export the heightmap with the entered file name """ target_directory = guisettings.Repository.getsettingvalue( guisettings.ID_BrowserPath_Heightmap ) dlg = wx.FileDialog( self.get_frame(), message="Save heightmap as", defaultDir=target_directory, wildcard="BMP image (*.bmp)|*.bmp|" \ "TGA image (*.tga)|*.tga|" \ "jpeg image (*.jpg)|*.jpg|" \ "PNG image (*.png)|*.png|" \ "dds image (*.dds)|*.dds|" \ "PPM image(*.ppm)|*.ppm|" \ "DIB image (*.dib)|*.dib|" \ "PFM image (*.pfm)|*.pfm|" | "Any file (*.*)|*.*", style=wx.SAVE|wx.OVERWRITE_PROMPT ) dlg.SetFilterIndex(1) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() path = servers.get_file_server().manglepath( str(path) ) trn.get_terrain_module().exportheightmap( str(path) ) # Record last directory last_directory = format.get_directory( path ) guisettings.Repository.setsettingvalue( guisettings.ID_BrowserPath_Heightmap, last_directory ) dlg.Destroy()
def on_import_heightmap(self, evt): """Show a file browser and import the selected heightmap""" source_directory = guisettings.Repository.getsettingvalue( guisettings.ID_BrowserPath_Heightmap ) dlg = wx.FileDialog( self.get_frame(), message="Choose a heightmap file to import", defaultDir=source_directory, wildcard="Image files (*.bmp,*.tga,*.jpg,*.jpeg,*.png," \ "*.dds,*.ppm,*.dib,*.pfm,*.*)|*.bmp;*.tga;" \ "*.jpg;*.jpeg;*.png;*.dds;*.ppm;*.dib;*.pfm;*.*", style=wx.OPEN ) if dlg.ShowModal() == wx.ID_OK: trn.get_terrain_module().importheightmap( str( dlg.GetPath() ) ) # Record last directory last_directory = format.get_directory( dlg.GetPath() ) guisettings.Repository.setsettingvalue( guisettings.ID_BrowserPath_Heightmap, last_directory ) dlg.Destroy()
def on_open(self, event): """Open a file dialog and load the selected file""" # IMPORTANT: Update these ids if wildcard changes ID_Script = 0 wildcard = "Script files (*.lua,*.py)|*.lua;*.py" dir_name = guisettings.Repository.getsettingvalue( guisettings.ID_BrowserPath_File ) dlg = wx.FileDialog( self.get_frame(), message="Choose a file", defaultDir=dir_name, wildcard=wildcard, style=wx.OPEN ) if dlg.ShowModal() == wx.ID_OK: index = dlg.GetFilterIndex() if index == ID_Script: self.__open_script( dlg.GetPath() ) # Record last directory last_dir = format.get_directory( dlg.GetPath() ) guisettings.Repository.setsettingvalue( guisettings.ID_BrowserPath_File, last_dir ) dlg.Destroy()
def on_import_texture(self, event): target_dir = guisettings.Repository.getsettingvalue( guisettings.ID_BrowserPath_LocalMaterial) if target_dir == "": target_dir = servers.get_file_server().manglepath("textures:") 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: if filedlg.copy_file(dlg.GetPath(), self.get_textures_path()): self.__update_combo_local_texture() # Record last directory target_dir = format.get_directory(dlg.GetPath()) guisettings.Repository.setsettingvalue( guisettings.ID_BrowserPath_LocalMaterial, target_dir) dlg.Destroy()
def on_import_heightmap(self, evt): """Show a file browser and import the selected heightmap""" source_directory = guisettings.Repository.getsettingvalue( guisettings.ID_BrowserPath_Heightmap) dlg = wx.FileDialog( self.get_frame(), message="Choose a heightmap file to import", defaultDir=source_directory, wildcard="Image files (*.bmp,*.tga,*.jpg,*.jpeg,*.png," \ "*.dds,*.ppm,*.dib,*.pfm,*.*)|*.bmp;*.tga;" \ "*.jpg;*.jpeg;*.png;*.dds;*.ppm;*.dib;*.pfm;*.*", style=wx.OPEN ) if dlg.ShowModal() == wx.ID_OK: trn.get_terrain_module().importheightmap(str(dlg.GetPath())) # Record last directory last_directory = format.get_directory(dlg.GetPath()) guisettings.Repository.setsettingvalue( guisettings.ID_BrowserPath_Heightmap, last_directory) 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()