Пример #1
0
def copy_file(source_file, target_directory):
    """
    Copy a file into a directory.
    
    If there's already another file with the same name in the target directory
    the user is asked to enter a new file name, overwrite the existing one or
    just cancel the operation.
    
    Return true if the file has been copied, false otherwise.
    """
    src = servers.get_file_server().manglepath(str(source_file))
    dir_name = servers.get_file_server().manglepath(str(target_directory))
    target = format.append_to_path(dir_name, format.get_name(src))
    while os.path.exists(target):
        result = cjr.confirm_yes_no(
                        None,
                        "A file called '%s' already exists.\n\n" \
                            "Do you want to rename the new file?\n" \
                            "(answering 'no' will overwrite the old one)"\
                            % format.get_name(src)
                        )
        if result == wx.ID_YES:
            dlg = wx.TextEntryDialog(None, "New file name:", "Conjurer",
                                     format.get_name(target))
            if dlg.ShowModal() == wx.ID_OK and dlg.GetValue() != "":
                target = format.append_to_path(dir, dlg.GetValue())
        elif result == wx.ID_NO:
            break
        else:
            return False
    shutil.copy(src, target)
    return True
Пример #2
0
def mangle_path(path):
    """Same as Nebula mangle path, but giving paths without the special
    directories '.' and '..'"""
    # Remove assigns
    path = servers.get_file_server().manglepath( str(path) )
    # Remove parent special directories
    path = os.path.abspath( path )
    # Convert path to Nebula format (slashes instead of backslashes)
    path = servers.get_file_server().manglepath( str(path) )
    # Convert drive letter to lowercase
    if len(path) > 1:
        if path[1] == ':':
            path = path[:1].lower() + path[1:]
    return path
Пример #3
0
def mangle_path(path):
    """Same as Nebula mangle path, but giving paths without the special
    directories '.' and '..'"""
    # Remove assigns
    path = servers.get_file_server().manglepath(str(path))
    # Remove parent special directories
    path = os.path.abspath(path)
    # Convert path to Nebula format (slashes instead of backslashes)
    path = servers.get_file_server().manglepath(str(path))
    # Convert drive letter to lowercase
    if len(path) > 1:
        if path[1] == ':':
            path = path[:1].lower() + path[1:]
    return path
Пример #4
0
    def __init__(self,
                 parent,
                 style,
                 label1,
                 label2,
                 directory,
                 extensions,
                 default_file="",
                 autoextension=True,
                 import_button=True,
                 excluded_files=[]):
        if style == NEW:
            title = "Choose a %s name" % label1
        elif style == OPEN:
            title = "Choose a %s to open" % label1
        elif style == SAVE:
            title = "Save %s as..." % label1
        elif style == DELETE:
            title = "Choose a %s to delete" % label1
        else:
            title = "Choose a %s" % label1
        wx.Dialog.__init__(self,
                           parent,
                           title=title,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
        self.style = style
        self.undirectory = directory
        self.directory = servers.get_file_server().manglepath(str(directory))
        self.extensions = extensions
        self.autoextension = autoextension and len(extensions) == 1
        self.import_button = import_button

        self.list_files = wx.ListBox(self,
                                     -1,
                                     choices=get_file_list(
                                         self.directory,
                                         self.extensions,
                                         self.autoextension,
                                         excluded_files=excluded_files))
        if self.style == NEW or self.style == SAVE:
            self.label_file = wx.StaticText(self, -1, "%s name" % label2)
            self.text_file = wx.TextCtrl(self, -1, default_file)
        elif self.style != DELETE and self.import_button:
            self.button_import = wx.Button(self, -1, "&Import a %s" % label1)
        if self.style == NEW:
            ok_caption = "&New"
        elif self.style == OPEN:
            ok_caption = "&Open"
        elif self.style == SAVE:
            ok_caption = "&Save"
        elif self.style == DELETE:
            ok_caption = "&Delete"
        else:
            ok_caption = "&OK"
        self.button_ok = wx.Button(self, -1, ok_caption)
        self.button_cancel = wx.Button(self, wx.ID_CANCEL, "&Cancel")

        self.__set_properties()
        self.__do_layout()
        self.__bind_events()
Пример #5
0
 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()
Пример #6
0
 def __init__(self, *args, **kwds):
     kwds["style"] = wx.DEFAULT_DIALOG_STYLE
     wx.Dialog.__init__(self, *args, **kwds)
     self.bitmap_logo = wx.StaticBitmap(
                                 self, 
                                 -1,
                                 wx.Bitmap(
                                     servers.get_file_server().manglepath(
                                         "outgui:images/logo.jpg"
                                         ), 
                                     wx.BITMAP_TYPE_ANY
                                     ),
                                 style=wx.SUNKEN_BORDER
                                 )
     self.label_app = wx.StaticText(self, -1, "Application name")
     self.label_conjurer = wx.StaticText(self, -1, "Conjurer")
     self.label_version = wx.StaticText(self, -1, "Release version")
     self.label_number = wx.StaticText(self, -1, "")
     self.label_copyright = wx.StaticText(
                                     self, 
                                     -1, 
                                     "(c) 2007 Conjurer Services, S.A."
                                     )
     self.list_info = wx.ListCtrl(
                             self, 
                             -1, 
                             style=wx.LC_REPORT|wx.LC_NO_HEADER
                             )
     self.button_ok = wx.Button(self, wx.ID_CANCEL, "&OK")
     
     self.__set_properties()
     self.__do_layout()
     self.__bind_events()
Пример #7
0
 def __get_layers_path(self):
     levelmanager = servers.get_level_manager()
     level = levelmanager.getcurrentlevelobject()
     layers_path = guisettings.Repository.getsettingvalue(
         guisettings.ID_PresetsPath) + '/layermanager_' + level.getname(
         ) + '.n2'
     return servers.get_file_server().manglepath(str(layers_path))
Пример #8
0
 def on_toggle_temporary_mode(self, event):
     """Toggle working in temporary mode"""
     cjr.show_information_message(
         "When the 'wc' assign becomes and assign group let\n" \
         "carles.ros know it and he will enable this feature."
         )
     return
     temp_path = guisettings.Repository.getsettingvalue(
         guisettings.ID_TemporaryWorkingPath)
     temp_path = servers.get_file_server().manglepath(str(temp_path))
     fileserver = servers.get_file_server()
     if event.IsChecked():
         fileserver.setassigngroup2('wc', str(temp_path), str(self.wc_path))
     else:
         fileserver.setassigngroup2('wc', str(self.wc_path),
                                    str(self.wc_path))
Пример #9
0
    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()
Пример #10
0
    def set_properties(self):
        # images
        fileserver = servers.get_file_server()
        self.tog_lock.SetBitmapLabel(
            wx.Bitmap(fileserver.manglepath("outgui:images/tools/lock.bmp"),
                      wx.BITMAP_TYPE_ANY))
        self.tog_lock.SetBitmapSelected(
            wx.Bitmap(
                fileserver.manglepath("outgui:images/tools/lockhighlight.bmp"),
                wx.BITMAP_TYPE_ANY))
        self.tog_lock.SetUseFocusIndicator(False)
        self.tog_hide.SetBitmapLabel(
            wx.Bitmap(fileserver.manglepath("outgui:images/tools/show.bmp"),
                      wx.BITMAP_TYPE_ANY))
        self.tog_hide.SetBitmapSelected(
            wx.Bitmap(fileserver.manglepath("outgui:images/tools/hide.bmp"),
                      wx.BITMAP_TYPE_ANY))
        self.tog_hide.SetUseFocusIndicator(False)

        # layer state
        self.tog_lock.SetToggle(self.is_layer_locked())
        self.tog_hide.SetToggle(not self.is_layer_active())
        self.update_label_from_layer()

        self.Show()
        self.Refresh()
Пример #11
0
    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()
Пример #12
0
 def on_custom_image(self, event):
     # Ask for an image file
     dlg = imgdlg.ImageFileDialog(self, style=wx.OPEN | wx.CHANGE_DIR)
     if dlg.ShowModal() == wx.ID_OK:
         self.bitmap_path = dlg.GetPath()
         self.bitmap_button.SetBitmapLabel(wx.Bitmap(servers.get_file_server().manglepath(str(self.bitmap_path))))
     dlg.Destroy()
Пример #13
0
    def __init__(self, needs_render_window ):
        """Constructor.

        Initializes the application main window and restores the previous run.
        """
        wx.MDIParentFrame.__init__(
            self, 
            None, 
            -1, 
            "Conjurer GUI",
            size = (1024, 768)
            )
        # window icon
        file_server = servers.get_file_server()
        icon_path = file_server.manglepath("outgui:images/conjurer.ico")
        self.SetIcon( wx.Icon(icon_path, wx.BITMAP_TYPE_ICO) )

        # Let the InGUI know that the OutGUI is open
        pynebula.new('nroot', '/editor/outguiisopened')

        self.quit_without_saving = False
        self.quit_requested = False

        # create a render window if required
        if needs_render_window:
            self.render_window = renderwindow.CreateWindow(self)
            parent_hwnd_env = pynebula.new('nenv','/sys/env/hwnd')
            parent_hwnd_env.seti(self.render_window.GetPanelHandle())
        else:
            self.render_window = None

        # preparing repository
        nebulaguisettings.Repository

        # toggable window manager
        self.togwinmgr = togwin.ToggableWindowMgr(self)

        # menu bar
        self.__menubar = menubar.MenuBar(self)
        self.__menubar.create()
        self.SetMenuBar(self.__menubar)

        # status bar
        self.__statusbar = statusbar.StatusBar(self)
        self.__statusbar.create()
        self.SetStatusBar(self.__statusbar)

        # tool bar
        self.__toolbar = toolbar.ToolBar(self)
        self.__toolbar.create()
        self.SetToolBar(self.__toolbar)
        self.__toolbar.Realize()
        # events
        self.Bind(wx.EVT_CLOSE, self.on_close_window)
        self.Bind(nh.EVT_CONJURER_HELP, self.on_conjurer_help)

        # TODO: Delete when found a direct way to know the mouse position
        self.__mouse_position = wx.Point(0, 0)
        self.__toolbar.Bind(wx.EVT_LEFT_UP, self.__on_left_click)
Пример #14
0
    def __init__(self, parent, id, root, name, show_strings=False):
        nohtree.NOHTree.__init__(
            self, 
            parent, 
            id, 
            root, 
            style=wx.TR_HAS_BUTTONS|wx.TR_EDIT_LABELS
            )
        self.parent = parent
        self.name = name
        self.show_strings = show_strings
        self.drag_type = "move"
        self.current = None

        fileserver = servers.get_file_server()

        root_img = self.image_list.Add(
                            wx.Bitmap(
                                fileserver.manglepath(
                                    "outgui:images/tools/browser.bmp"
                                    ),
                                wx.BITMAP_TYPE_ANY
                                )
                            )

        self.SetImageList(self.image_list)

        # add image to root item
        self.SetItemImage(self.root, root_img, wx.TreeItemIcon_Normal)

        self.Expand(self.GetRootItem())
        self.SelectItem(self.GetRootItem())

        general_lib_path = fileserver.manglepath(
                                    "wc:libs/grimoire/general.n2"
                                    )
        # dictionary for storage library file paths
        self.files = { 'general': [general_lib_path, False] } 

        # tree events
        self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.on_item_expanding, self)
        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_sel_changed, self)
        self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.on_begin_edit, self)
        self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.on_end_edit, self)
        self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.on_begin_drag, self)
        self.Bind(wx.EVT_TREE_END_DRAG, self.on_end_drag, self)

        # global events
        self.Bind(wx.EVT_RIGHT_DOWN, self.on_ms_right_down, self)
        self.Bind(wx.EVT_KEY_DOWN, self.on_key_down, self)
        self.Bind(wx.EVT_KEY_UP, self.on_key_up, self)
        self.Bind(wx.EVT_LEFT_DCLICK, self.on_left_dclick, self)
        
        self.selection_changed_callback = None
        
        # this control is a target for drop strings

        drop_target = StringDropTarget(self)
        self.SetDropTarget(drop_target)
Пример #15
0
 def on_custom_image(self, event):
     # Ask for an image file
     dlg = imgdlg.ImageFileDialog(self, style=wx.OPEN|wx.CHANGE_DIR)
     if dlg.ShowModal() == wx.ID_OK:
         self.bitmap_path = dlg.GetPath()
         self.bitmap_button.SetBitmapLabel( wx.Bitmap(
             servers.get_file_server().manglepath(str(self.bitmap_path))) )
     dlg.Destroy()
Пример #16
0
 def __update_texture_thumbnail(self, material):
     size = guisettings.Repository.getsettingvalue(
                 guisettings.ID_Thumbnail_TerrainMaterial 
                 )
     tex_path = servers.get_file_server().manglepath(
         material.gettexturethumbnail(size) )
     self.bitmap_texture.SetBitmap( wx.Bitmap(tex_path) )
     os.remove( tex_path )
Пример #17
0
 def on_zoom_texture(self, event):
     material = self.__get_material()
     tex_path = servers.get_file_server().manglepath(
         material.gettexturethumbnail(0) )
     dlg = imagepreview.PreviewDialog( app.get_top_window(self), tex_path,
         self.get_texture_filename() )
     dlg.Show()
     os.remove( tex_path )
Пример #18
0
 def __get_layers_path(self):
     levelmanager = servers.get_level_manager()
     level = levelmanager.getcurrentlevelobject()
     layers_path = guisettings.Repository.getsettingvalue(
                             guisettings.ID_PresetsPath
                             ) + '/layermanager_' + level.getname() + '.n2'
     return servers.get_file_server().manglepath(
         str(layers_path) 
         )
Пример #19
0
    def __init__(self, needs_render_window):
        """Constructor.

        Initializes the application main window and restores the previous run.
        """
        wx.MDIParentFrame.__init__(self,
                                   None,
                                   -1,
                                   "Conjurer GUI",
                                   size=(1024, 768))
        # window icon
        file_server = servers.get_file_server()
        icon_path = file_server.manglepath("outgui:images/conjurer.ico")
        self.SetIcon(wx.Icon(icon_path, wx.BITMAP_TYPE_ICO))

        # Let the InGUI know that the OutGUI is open
        pynebula.new('nroot', '/editor/outguiisopened')

        self.quit_without_saving = False
        self.quit_requested = False

        # create a render window if required
        if needs_render_window:
            self.render_window = renderwindow.CreateWindow(self)
            parent_hwnd_env = pynebula.new('nenv', '/sys/env/hwnd')
            parent_hwnd_env.seti(self.render_window.GetPanelHandle())
        else:
            self.render_window = None

        # preparing repository
        nebulaguisettings.Repository

        # toggable window manager
        self.togwinmgr = togwin.ToggableWindowMgr(self)

        # menu bar
        self.__menubar = menubar.MenuBar(self)
        self.__menubar.create()
        self.SetMenuBar(self.__menubar)

        # status bar
        self.__statusbar = statusbar.StatusBar(self)
        self.__statusbar.create()
        self.SetStatusBar(self.__statusbar)

        # tool bar
        self.__toolbar = toolbar.ToolBar(self)
        self.__toolbar.create()
        self.SetToolBar(self.__toolbar)
        self.__toolbar.Realize()
        # events
        self.Bind(wx.EVT_CLOSE, self.on_close_window)
        self.Bind(nh.EVT_CONJURER_HELP, self.on_conjurer_help)

        # TODO: Delete when found a direct way to know the mouse position
        self.__mouse_position = wx.Point(0, 0)
        self.__toolbar.Bind(wx.EVT_LEFT_UP, self.__on_left_click)
Пример #20
0
 def save(self):
     library = app.get_libraries()
     root_path = servers.get_file_server().manglepath("wc:libs/grimoire/")
     library = library.gethead() # first library
     # save all grimoire libraries
     while library is not None:
         if library.getname() != 'natives':
             save_path = root_path + '/' + library.getname() + '.n2'
             library.saveas(save_path)
         library = library.getsucc() # next library
Пример #21
0
 def save(self):
     library = app.get_libraries()
     root_path = servers.get_file_server().manglepath("wc:libs/grimoire/")
     library = library.gethead()  # first library
     # save all grimoire libraries
     while library is not None:
         if library.getname() != 'natives':
             save_path = root_path + '/' + library.getname() + '.n2'
             library.saveas(save_path)
         library = library.getsucc()  # next library
Пример #22
0
def create_class(name, parent_name, library_path):

    name = name.capitalize()  # valid name for a class
    entity_server = servers.get_entity_class_server()

    if not entity_server.checkclassname(name):
        cjr.show_error_message("'%s' is not a valid name for a class" % (name))
        return False

    if entity_server.getentityclass(name) is not None:
        cjr.show_error_message("A class called '%s' already exists" % (name))
        return False

    #Get the class for the given parent class name, checking that it is valid
    parent_class = entity_server.getentityclass(parent_name)
    if parent_class is None:
        cjr.show_error_message(
            "The new class cannot derive from '%s' "\
                "because it does not exist" % (parent_name)
            )
        return False

    new_class = entity_server.newentityclass(parent_class, name)
    new_class.setclasskeyint("ParticleSystem", 1)
    new_class.setasseteditable(True)
    new_class.setbbox(0.0, 0.5, 0.0, 0.5, 0.5, 0.5)

    asset_path = 'wc:export/assets/%s' % name
    file_server = servers.get_file_server()
    if (not file_server.makepath(asset_path)):
        return False
    new_class.setresourcefile(asset_path)

    scene_path = asset_path + '/scene'
    if (not file_server.makepath(scene_path)):
        return False
    materials_path = asset_path + '/materials'
    if (not file_server.makepath(materials_path)):
        return False

    # create the root node
    root_node_path = scene_path + '/' + name
    root_node = pynebula.new('ntransformnode', root_node_path)
    result = root_node.saveas(root_node_path + '.n2')
    if not result:
        return False

    library = pynebula.lookup(library_path)
    library.appendstring(name)

    # Mark the library as dirty
    app.get_libraries().setobjectdirty(True)

    return True
Пример #23
0
    def refresh(self):
        """
        Rebuild toolbar

        For all custom scripts defined in the script manager a tool button
        (either image button or text button) if added to the toolbar if that
        script has been marked to be shown in the toolbar by the user.
        """
        # Remove old custom tools
        for key in self.custom_tools.keys():
            button = self.custom_tools[key]['button']
            if button is None:
                self.Unbind(wx.EVT_MENU, id=key)
            else:
                self.Unbind(wx.EVT_BUTTON, button)
                button.Destroy()
            self.custom_tools[key]['button'] = None
            self.DeleteTool(key)
        self.custom_tools = {}

        # Add tool buttons for custom tools
        fileserver = servers.get_file_server()
        scripts = guisettings.Repository.getsettingvalue(
            guisettings.ID_ScriptList)
        for i in range(len(scripts)):
            script = scripts[i]
            tool_id = wx.NewId()
            self.custom_tools[tool_id] = {'index': i, 'button': None}

            # Tool
            if script['show button']:
                if script['button type'] == 'image':
                    # Add image button (normal toolbar tool)
                    self.AddLabelTool(
                        tool_id, script['description'],
                        wx.Bitmap(
                            fileserver.manglepath(str(script['button image'])),
                            wx.BITMAP_TYPE_ANY), wx.NullBitmap, wx.ITEM_NORMAL,
                        script['tooltip text'], script['statusbar text'])
                    self.Bind(wx.EVT_MENU, self.on_custom_tool, id=tool_id)
                else:
                    # Add text button
                    button = wx.Button(self,
                                       tool_id,
                                       script['button text'],
                                       style=wx.BU_EXACTFIT)
                    self.AddControl(button)
                    button.SetToolTip(wx.ToolTip(script['tooltip text']))
                    self.Bind(wx.EVT_BUTTON, self.on_custom_tool, button)
                    self.custom_tools[tool_id]['button'] = button

        # Refresh toolbar
        self.Realize()
Пример #24
0
 def __init__(self, parent, style, label1, label2, directory,
              default_dir=""):
     if style == NEW:
         title = "Choose a %s name" % label1
     elif style == OPEN:
         title = "Choose a %s to open" % label1
     elif style == SAVE:
         title = "Save %s as..." % label1
     elif style == DELETE:
         title = "Choose a %s to delete" % label1
     else:
         title = "Choose a %s" % label1
     wx.Dialog.__init__(
         self, 
         parent, 
         title=title,
         style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER
         )
     self.style = style
     self.directory = servers.get_file_server().manglepath( str(directory) )
     
     self.list_files = wx.ListBox(
                             self, 
                             -1,
                             choices = get_directory_list(self.directory)
                             )
     if self.style == NEW or self.style == SAVE:
         self.label_file = wx.StaticText(
                                 self, 
                                 -1, 
                                 "%s name" % label2
                                 )
         self.text_file = wx.TextCtrl(
                                 self, 
                                 -1, 
                                 default_dir
                                 )
     if self.style == NEW:
         ok_caption = "&New"
     elif self.style == OPEN:
         ok_caption = "&Open"
     elif self.style == SAVE:
         ok_caption = "&Save"
     elif self.style == DELETE:
         ok_caption = "&Delete"
     else:
         ok_caption = "&OK"
     self.button_ok = wx.Button(self, -1, ok_caption)
     self.button_cancel = wx.Button(self, wx.ID_CANCEL, "&Cancel")
     
     self.__set_properties()
     self.__do_layout()
     self.__bind_events()
Пример #25
0
 def expand_sublists(self, item):
     if self.IsExpanded(item):
         # This event can happen twice in the self.Expand call
         return
     obj = self.GetPyData(item)
     node = obj.gethead()
     fileserver = servers.get_file_server()
     self.libidx = self.image_list.Add(
         wx.Bitmap(fileserver.manglepath("outgui:images/tools/new.bmp"),
                   wx.BITMAP_TYPE_ANY))
     while node != None:
         obj = pynebula.lookup(node.getfullname())
         new_item = self.AppendItem(item, obj.getname(), -1, -1,
                                    wx.TreeItemData(obj))
         if self.is_library(new_item):
             self.SetItemImage(new_item, self.libidx,
                               wx.TreeItemIcon_Normal)
             self.SetItemImage(new_item, self.libidx,
                               wx.TreeItemIcon_Selected)
             self.SetItemImage(new_item, self.libidx,
                               wx.TreeItemIcon_Expanded)
         elif self.GetItemText(
                 self.get_root_library(new_item)
         ) == 'natives' and servers.get_kernel_server().isclassnative(
                 str(self.GetItemText(new_item))):
             self.SetItemImage(new_item, self.fldridxnative,
                               wx.TreeItemIcon_Normal)
             self.SetItemImage(new_item, self.fldropenidxnative,
                               wx.TreeItemIcon_Selected)
             self.SetItemImage(new_item, self.fldropenidxnative,
                               wx.TreeItemIcon_Expanded)
         elif self.GetItemText(
                 self.get_root_library(new_item)
         ) == 'natives' and not servers.get_kernel_server().isclassnative(
                 str(self.GetItemText(new_item))):
             self.SetItemImage(new_item, self.fldridxuser,
                               wx.TreeItemIcon_Normal)
             self.SetItemImage(new_item, self.fldropenidxuser,
                               wx.TreeItemIcon_Selected)
             self.SetItemImage(new_item, self.fldropenidxuser,
                               wx.TreeItemIcon_Expanded)
         else:
             self.SetItemImage(new_item, self.fldridxnormal,
                               wx.TreeItemIcon_Normal)
             self.SetItemImage(new_item, self.fldropenidxnormal,
                               wx.TreeItemIcon_Selected)
             self.SetItemImage(new_item, self.fldropenidxnormal,
                               wx.TreeItemIcon_Expanded)
         if obj.gethead() != None:
             self.SetItemHasChildren(new_item, True)
         node = obj.getsucc()
         self.SortChildren(item)
Пример #26
0
def copy_file(source_file, target_directory):
    """
    Copy a file into a directory.
    
    If there's already another file with the same name in the target directory
    the user is asked to enter a new file name, overwrite the existing one or
    just cancel the operation.
    
    Return true if the file has been copied, false otherwise.
    """
    src = servers.get_file_server().manglepath( str(source_file) )
    dir_name = servers.get_file_server().manglepath( str(target_directory) )
    target = format.append_to_path(
                    dir_name, 
                    format.get_name(src) 
                    )
    while os.path.exists( target ):
        result = cjr.confirm_yes_no(
                        None,
                        "A file called '%s' already exists.\n\n" \
                            "Do you want to rename the new file?\n" \
                            "(answering 'no' will overwrite the old one)"\
                            % format.get_name(src) 
                        )
        if result == wx.ID_YES:
            dlg = wx.TextEntryDialog(
                        None, 
                        "New file name:", 
                        "Conjurer",
                        format.get_name(target)
                        )
            if dlg.ShowModal() == wx.ID_OK and dlg.GetValue() != "":
                target = format.append_to_path( dir, dlg.GetValue() )
        elif result == wx.ID_NO:
            break
        else:
            return False
    shutil.copy(src, target)
    return True
Пример #27
0
 def on_preset_image(self, event):
     # Ask to select an image among the preset ones
     dlg = imgdlg.ImagesDialog(self, "Choose an image",
         "outgui:images/tools", image_size=wx.Size(16,16),
         scale_images=False)
     if dlg.ShowModal() == wx.ID_OK:
         if dlg.get_path() != "":
             self.bitmap_path = dlg.get_path()
             self.bitmap_button.SetBitmapLabel( wx.Bitmap(
                 servers.get_file_server().manglepath(
                 str(self.bitmap_path))) )
             self.bitmap_button.Refresh()
     dlg.Destroy()
Пример #28
0
 def __set_properties(self):
     # browse supported images from directory
     fileserver = servers.get_file_server()
     filenames = os.listdir( fileserver.manglepath(str(self.images_dir)) )
     dir = fileserver.manglepath(str(self.images_dir)) + "/"
     for filename in filenames:
         if not filename.startswith("."):
             path = dir + filename
             try:
                 if wx.Image.CanRead(path):
                     self.imgbox.append_image(wx.Bitmap(path), path)
             except:
                 pass
Пример #29
0
 def on_preset_image(self, event):
     # Ask to select an image among the preset ones
     dlg = imgdlg.ImagesDialog(
         self, "Choose an image", "outgui:images/tools", image_size=wx.Size(16, 16), scale_images=False
     )
     if dlg.ShowModal() == wx.ID_OK:
         if dlg.get_path() != "":
             self.bitmap_path = dlg.get_path()
             self.bitmap_button.SetBitmapLabel(
                 wx.Bitmap(servers.get_file_server().manglepath(str(self.bitmap_path)))
             )
             self.bitmap_button.Refresh()
     dlg.Destroy()
Пример #30
0
 def __set_properties(self):
     # browse supported images from directory
     fileserver = servers.get_file_server()
     filenames = os.listdir(fileserver.manglepath(str(self.images_dir)))
     dir = fileserver.manglepath(str(self.images_dir)) + "/"
     for filename in filenames:
         if not filename.startswith("."):
             path = dir + filename
             try:
                 if wx.Image.CanRead(path):
                     self.imgbox.append_image(wx.Bitmap(path), path)
             except:
                 pass
Пример #31
0
    def refresh(self):
        """
        Rebuild toolbar

        For all custom scripts defined in the script manager a tool button
        (either image button or text button) if added to the toolbar if that
        script has been marked to be shown in the toolbar by the user.
        """
        # Remove old custom tools
        for key in self.custom_tools.keys():
            button = self.custom_tools[key]['button']
            if button is None:
                self.Unbind(wx.EVT_MENU, id=key)
            else:
                self.Unbind(wx.EVT_BUTTON, button)
                button.Destroy()
            self.custom_tools[key]['button'] = None
            self.DeleteTool(key)
        self.custom_tools = {}

        # Add tool buttons for custom tools
        fileserver = servers.get_file_server()
        scripts = guisettings.Repository.getsettingvalue(
                        guisettings.ID_ScriptList
                        )
        for i in range(len(scripts)):
            script = scripts[i]
            tool_id = wx.NewId()
            self.custom_tools[tool_id] = {'index': i, 'button': None}

            # Tool
            if script['show button']:
                if script['button type'] == 'image':
                    # Add image button (normal toolbar tool)
                    self.AddLabelTool(tool_id, script['description'],
                        wx.Bitmap(fileserver.manglepath(
                        str(script['button image'])), wx.BITMAP_TYPE_ANY),
                        wx.NullBitmap, wx.ITEM_NORMAL, script['tooltip text'],
                        script['statusbar text'])
                    self.Bind(wx.EVT_MENU, self.on_custom_tool, id=tool_id)
                else:
                    # Add text button
                    button = wx.Button(self, tool_id, script['button text'],
                        style=wx.BU_EXACTFIT)
                    self.AddControl(button)
                    button.SetToolTip(wx.ToolTip(script['tooltip text']))
                    self.Bind(wx.EVT_BUTTON, self.on_custom_tool, button)
                    self.custom_tools[tool_id]['button'] = button

        # Refresh toolbar
        self.Realize()
Пример #32
0
 def __set_properties(self):
     # set layout images
     layouts = [
         "outgui:images/layouts/00.bmp", "outgui:images/layouts/01.bmp",
         "outgui:images/layouts/02.bmp", "outgui:images/layouts/03.bmp",
         "outgui:images/layouts/04.bmp", "outgui:images/layouts/05.bmp",
         "outgui:images/layouts/06.bmp", "outgui:images/layouts/07.bmp",
         "outgui:images/layouts/08.bmp"
     ]
     fileserver = servers.get_file_server()
     for layout in layouts:
         path = fileserver.manglepath(layout)
         bmp = wx.Bitmap(path, wx.BITMAP_TYPE_ANY)
         self.imgbox_layouts.append_image(bmp)
Пример #33
0
    def __init__(self, parent, id, root, name, show_strings=False):
        nohtree.NOHTree.__init__(self,
                                 parent,
                                 id,
                                 root,
                                 style=wx.TR_HAS_BUTTONS | wx.TR_EDIT_LABELS)
        self.parent = parent
        self.name = name
        self.show_strings = show_strings
        self.drag_type = "move"
        self.current = None

        fileserver = servers.get_file_server()

        root_img = self.image_list.Add(
            wx.Bitmap(fileserver.manglepath("outgui:images/tools/browser.bmp"),
                      wx.BITMAP_TYPE_ANY))

        self.SetImageList(self.image_list)

        # add image to root item
        self.SetItemImage(self.root, root_img, wx.TreeItemIcon_Normal)

        self.Expand(self.GetRootItem())
        self.SelectItem(self.GetRootItem())

        general_lib_path = fileserver.manglepath("wc:libs/grimoire/general.n2")
        # dictionary for storage library file paths
        self.files = {'general': [general_lib_path, False]}

        # tree events
        self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.on_item_expanding, self)
        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_sel_changed, self)
        self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.on_begin_edit, self)
        self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.on_end_edit, self)
        self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.on_begin_drag, self)
        self.Bind(wx.EVT_TREE_END_DRAG, self.on_end_drag, self)

        # global events
        self.Bind(wx.EVT_RIGHT_DOWN, self.on_ms_right_down, self)
        self.Bind(wx.EVT_KEY_DOWN, self.on_key_down, self)
        self.Bind(wx.EVT_KEY_UP, self.on_key_up, self)
        self.Bind(wx.EVT_LEFT_DCLICK, self.on_left_dclick, self)

        self.selection_changed_callback = None

        # this control is a target for drop strings

        drop_target = StringDropTarget(self)
        self.SetDropTarget(drop_target)
Пример #34
0
 def toggle_axis_transform(self, local):
     # Second bitmap for a check tool is used different in wxPython than
     # its C counterpart. In Python is used when the tool is disabled and
     # in C when pushed, the desired behaviour here. So this function
     # simulates the C behaviour.
     self.ToggleTool(viewcmds.ID_LocalTransform, local)
     tool = self.FindById(viewcmds.ID_LocalTransform)
     if local:
         bmp_filename = "local_axis.bmp"
     else:
         bmp_filename = "world_axis.bmp"
     tool.SetNormalBitmap(
         wx.Bitmap(servers.get_file_server().manglepath(
             "outgui:images/tools/%s" % bmp_filename)))
Пример #35
0
    def set_properties(self):
        # images
        fileserver = servers.get_file_server()
        self.tog_lock.SetBitmapLabel(
            wx.Bitmap(
                fileserver.manglepath(
                    "outgui:images/tools/lock.bmp"
                    ), 
                wx.BITMAP_TYPE_ANY
                ) 
            )
        self.tog_lock.SetBitmapSelected(
            wx.Bitmap(
                fileserver.manglepath(
                    "outgui:images/tools/lockhighlight.bmp"
                    ), 
                wx.BITMAP_TYPE_ANY
                )
            )
        self.tog_lock.SetUseFocusIndicator(False)
        self.tog_hide.SetBitmapLabel(
            wx.Bitmap(
                fileserver.manglepath(
                    "outgui:images/tools/show.bmp"
                    ), 
                wx.BITMAP_TYPE_ANY
                )
            )
        self.tog_hide.SetBitmapSelected(
            wx.Bitmap(
                fileserver.manglepath(
                    "outgui:images/tools/hide.bmp"
                    ), 
                wx.BITMAP_TYPE_ANY
                )
            )
        self.tog_hide.SetUseFocusIndicator(False)
        
        # layer state
        self.tog_lock.SetToggle(
            self.is_layer_locked() 
            )
        self.tog_hide.SetToggle(
            not self.is_layer_active()
            )
        self.update_label_from_layer()

        self.Show()
        self.Refresh()
Пример #36
0
 def on_toggle_temporary_mode(self, event):
     """Toggle working in temporary mode"""
     cjr.show_information_message(
         "When the 'wc' assign becomes and assign group let\n" \
         "carles.ros know it and he will enable this feature."
         )
     return
     temp_path = guisettings.Repository.getsettingvalue(
                         guisettings.ID_TemporaryWorkingPath 
                         )
     temp_path = servers.get_file_server().manglepath( str(temp_path) )
     fileserver = servers.get_file_server()
     if event.IsChecked():
         fileserver.setassigngroup2(
             'wc', 
             str(temp_path), 
             str(self.wc_path)
             )
     else:
         fileserver.setassigngroup2(
             'wc', 
             str(self.wc_path), 
             str(self.wc_path)
             )
Пример #37
0
    def load_files(self, files):
        self.files = files
        general_lib_path = servers.get_file_server().manglepath(
            "wc:libs/grimoire/general.n2")
        self.files['general'] = [general_lib_path, False]

        trash = []
        for key, file in files.iteritems():
            file_name = file[0].replace('\\\\', '/')
            self.load(file_name)

        # Delete libraries that failed on load (maybe It was deleted from disk)
        #for element in trash:
        #    del element

        self.expand_tree(self.GetItemText(self.GetRootItem()))
Пример #38
0
    def __init__(self,
                 parent,
                 style,
                 label1,
                 label2,
                 directory,
                 default_dir=""):
        if style == NEW:
            title = "Choose a %s name" % label1
        elif style == OPEN:
            title = "Choose a %s to open" % label1
        elif style == SAVE:
            title = "Save %s as..." % label1
        elif style == DELETE:
            title = "Choose a %s to delete" % label1
        else:
            title = "Choose a %s" % label1
        wx.Dialog.__init__(self,
                           parent,
                           title=title,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
        self.style = style
        self.directory = servers.get_file_server().manglepath(str(directory))

        self.list_files = wx.ListBox(self,
                                     -1,
                                     choices=get_directory_list(
                                         self.directory))
        if self.style == NEW or self.style == SAVE:
            self.label_file = wx.StaticText(self, -1, "%s name" % label2)
            self.text_file = wx.TextCtrl(self, -1, default_dir)
        if self.style == NEW:
            ok_caption = "&New"
        elif self.style == OPEN:
            ok_caption = "&Open"
        elif self.style == SAVE:
            ok_caption = "&Save"
        elif self.style == DELETE:
            ok_caption = "&Delete"
        else:
            ok_caption = "&OK"
        self.button_ok = wx.Button(self, -1, ok_caption)
        self.button_cancel = wx.Button(self, wx.ID_CANCEL, "&Cancel")

        self.__set_properties()
        self.__do_layout()
        self.__bind_events()
Пример #39
0
    def load_files (self, files):
        self.files = files
        general_lib_path = servers.get_file_server().manglepath(
                                    "wc:libs/grimoire/general.n2"
                                    )
        self.files['general'] = [general_lib_path, False]

        trash = []
        for key, file in files.iteritems():
            file_name = file[0].replace('\\\\', '/')
            self.load(file_name)

        # Delete libraries that failed on load (maybe It was deleted from disk)
        #for element in trash:
        #    del element

        self.expand_tree(self.GetItemText(self.GetRootItem()))
Пример #40
0
def get_file_list(directory, extensions, autoextension=True, recursive=False,
    excluded_files=[]):
    """
    Return a sequence of the files of the given directory.
    
    The file extension is removed if autoextension is set to True and only one
    file extension is given.
    
    Only the relative path to the given directory is returned for each file,
    not its full path.
    """
    gui_names = []
    mangled_dir = servers.get_file_server().manglepath( str(directory) )
    try:
        filenames = os.listdir( mangled_dir )
    except:
        return []
    for filename in filenames:
        if filename.startswith("."):
            # skip special directories/files
            continue
        file_path = format.append_to_path( mangled_dir, filename )
        if os.path.isdir( file_path ):
            if recursive:
                # recurse directories
                subnames = get_file_list(
                                    file_path, 
                                    extensions, 
                                    autoextension, 
                                    recursive
                                    )
                for name in subnames:
                    gui_names.append( filename + "/" + name )
        else:
            # add the file if its extension matches one of the desired options
            for extension in extensions:
                try:
                    excluded_files.index( filename )
                except:
                    if filename.endswith( "." + extension ):
                        if autoextension:
                            gui_names.append( filename[:-len("."+extension)] )
                        else:
                            gui_names.append( filename )
    return gui_names
Пример #41
0
 def toggle_axis_transform(self, local):
     # Second bitmap for a check tool is used different in wxPython than
     # its C counterpart. In Python is used when the tool is disabled and
     # in C when pushed, the desired behaviour here. So this function
     # simulates the C behaviour.
     self.ToggleTool( viewcmds.ID_LocalTransform, local )
     tool = self.FindById( viewcmds.ID_LocalTransform )
     if local:
         bmp_filename = "local_axis.bmp"
     else:
         bmp_filename = "world_axis.bmp"
     tool.SetNormalBitmap(
         wx.Bitmap(
             servers.get_file_server().manglepath(
                 "outgui:images/tools/%s" % bmp_filename
                 )
             )
         )
Пример #42
0
def get_directory_list(directory):
    """
    Return a sequence of the directories within the given directory.
    
    Only the relative path to the given directory is returned for each file,
    not its full path.
    """
    gui_names = []
    mangled_dir = servers.get_file_server().manglepath( str(directory) )
    filenames = os.listdir( mangled_dir )
    for filename in filenames:
        if filename.startswith("."):
            # skip special directories/files
            continue
        file_path = format.append_to_path( mangled_dir, filename )
        if os.path.isdir( file_path ):
            gui_names.append( filename )
    return gui_names
Пример #43
0
 def __set_properties(self):
     # set layout images
     layouts = [
         "outgui:images/layouts/00.bmp",
         "outgui:images/layouts/01.bmp",
         "outgui:images/layouts/02.bmp",
         "outgui:images/layouts/03.bmp",
         "outgui:images/layouts/04.bmp",
         "outgui:images/layouts/05.bmp",
         "outgui:images/layouts/06.bmp",
         "outgui:images/layouts/07.bmp",
         "outgui:images/layouts/08.bmp"
         ]
     fileserver = servers.get_file_server()
     for layout in layouts:
         path = fileserver.manglepath(layout)
         bmp = wx.Bitmap(path, wx.BITMAP_TYPE_ANY)
         self.imgbox_layouts.append_image(bmp)
Пример #44
0
def get_directory_list(directory):
    """
    Return a sequence of the directories within the given directory.
    
    Only the relative path to the given directory is returned for each file,
    not its full path.
    """
    gui_names = []
    mangled_dir = servers.get_file_server().manglepath(str(directory))
    filenames = os.listdir(mangled_dir)
    for filename in filenames:
        if filename.startswith("."):
            # skip special directories/files
            continue
        file_path = format.append_to_path(mangled_dir, filename)
        if os.path.isdir(file_path):
            gui_names.append(filename)
    return gui_names
Пример #45
0
def get_file_list(directory,
                  extensions,
                  autoextension=True,
                  recursive=False,
                  excluded_files=[]):
    """
    Return a sequence of the files of the given directory.
    
    The file extension is removed if autoextension is set to True and only one
    file extension is given.
    
    Only the relative path to the given directory is returned for each file,
    not its full path.
    """
    gui_names = []
    mangled_dir = servers.get_file_server().manglepath(str(directory))
    try:
        filenames = os.listdir(mangled_dir)
    except:
        return []
    for filename in filenames:
        if filename.startswith("."):
            # skip special directories/files
            continue
        file_path = format.append_to_path(mangled_dir, filename)
        if os.path.isdir(file_path):
            if recursive:
                # recurse directories
                subnames = get_file_list(file_path, extensions, autoextension,
                                         recursive)
                for name in subnames:
                    gui_names.append(filename + "/" + name)
        else:
            # add the file if its extension matches one of the desired options
            for extension in extensions:
                try:
                    excluded_files.index(filename)
                except:
                    if filename.endswith("." + extension):
                        if autoextension:
                            gui_names.append(filename[:-len("." + extension)])
                        else:
                            gui_names.append(filename)
    return gui_names
Пример #46
0
 def __set_properties(self):
     # images
     fileserver = servers.get_file_server()
     self.tog_lock.SetBitmapLabel(
         wx.Bitmap(
             fileserver.manglepath("outgui:images/tools/lock.bmp"), 
             wx.BITMAP_TYPE_ANY
             ) 
         )
     self.tog_lock.SetUseFocusIndicator(False)
     self.tog_show.SetBitmapLabel(
         wx.Bitmap(
             fileserver.manglepath("outgui:images/tools/show.bmp"), 
             wx.BITMAP_TYPE_ANY
             ) 
         )
     self.tog_show.SetUseFocusIndicator(False)
     self.tog_texture.SetBitmapLabel(
         wx.Bitmap(
             fileserver.manglepath("outgui:images/tools/texture.bmp"), 
             wx.BITMAP_TYPE_ANY
             )
         )
     self.tog_texture.SetUseFocusIndicator(False)
     self.btn_zoom.SetBitmapLabel(
         wx.Bitmap(
             fileserver.manglepath("outgui:images/tools/zoom.bmp"), 
             wx.BITMAP_TYPE_ANY
             ) 
         )
     self.btn_zoom.SetUseFocusIndicator(False)
     
     # layer state
     material = self.__get_material()
     self.tog_lock.SetToggle(False)
     self.tog_show.SetToggle(True)
     self.tog_texture.SetToggle(True)
     self.__update_texture_thumbnail(material)
     self.label_name.SetLabel( material.getlabel() )
     self.color_sel.SetColour(
         format.unit_rgb_2_byte_rgb( material.getmaskcolor() )
         )
Пример #47
0
    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()
Пример #48
0
 def refresh(self):
     """Rebuild the menu"""
     # Remove old menu items
     for key in self.custom_scripts.keys():
         self.unbind_function(key)
         self.Delete(key)
     self.custom_scripts = {}
     
     # Add all custom scripts
     fileserver = servers.get_file_server()
     scripts = cfg.Repository.getsettingvalue(cfg.ID_ScriptList)
     for i in range(len(scripts)):
         script = scripts[i]
         menu_id = wx.NewId()
         self.custom_scripts[menu_id] = i
         menu_text = script['description']
         if script['shortcut'] != "":
             menu_text = menu_text + "\t" + script['shortcut']
         self.Append(menu_id, menu_text)
         self.bind_function(menu_id, self.on_custom_script)
Пример #49
0
    def __init__(self, parent, script):
        wx.Dialog.__init__(self, parent, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
        self.script = script

        self.label_sizer_staticbox = wx.StaticBox(self, -1, "Label")
        self.help_sizer_staticbox = wx.StaticBox(self, -1, "Help (only for image buttons)")
        self.button_sizer_staticbox = wx.StaticBox(self, -1, "Button")
        self.script_sizer_staticbox = wx.StaticBox(self, -1, "Script")
        self.label_desc = wx.StaticText(self, -1, "Description:")
        self.text_desc = wx.TextCtrl(self, -1, "")
        self.label_file = wx.StaticText(self, -1, "File:")
        self.text_file = wx.TextCtrl(self, -1, "")
        self.button_file = wx.Button(self, -1, "Chose a file...")
        self.text_info = wx.TextCtrl(
            self,
            -1,
            "A Python script can access to the 'script.custom_data' variable to store any desired custom data. This data will persist between executions, but only if the script is ran from the script manager or from its tool button/menu item (not from other sources, like running it from the script editor).",
            style=wx.TE_MULTILINE | wx.TE_READONLY,
        )
        self.label_shortcut = wx.StaticText(self, -1, "Shortcut:")
        self.text_shortcut = wx.TextCtrl(self, -1, "")
        self.checkbox_button = wx.CheckBox(self, -1, "Show in toolbar")
        self.radio_image = wx.RadioButton(self, -1, "Image button:", style=wx.RB_GROUP)
        self.bitmap_path = script["button image"]
        self.bitmap_button = wx.BitmapButton(
            self, -1, wx.Bitmap(servers.get_file_server().manglepath(str(self.bitmap_path)), wx.BITMAP_TYPE_ANY)
        )
        self.button_preset_image = wx.Button(self, -1, "Preset image...")
        self.button_custom_image = wx.Button(self, -1, "Custom image...")
        self.radio_text = wx.RadioButton(self, -1, "Text button:")
        self.text_label = wx.TextCtrl(self, -1, "")
        self.label_tooltip = wx.StaticText(self, -1, "Tool tip text:")
        self.text_tooltip = wx.TextCtrl(self, -1, "")
        self.label_statusbar = wx.StaticText(self, -1, "Status bar text:")
        self.text_statusbar = wx.TextCtrl(self, -1, "")
        self.button_ok = wx.Button(self, -1, "&OK")
        self.button_cancel = wx.Button(self, -1, "&Cancel")

        self.__set_properties()
        self.__do_layout()
        self.__bind_events()
Пример #50
0
 def set_default_icons(self):
     image_size = (16, 16)
     self.image_list = wx.ImageList(image_size[0], image_size[1])
     self.fldridxnormal = self.image_list.Add(
         wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, image_size))
     self.fldropenidxnormal = self.image_list.Add(
         wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER,
                                  image_size))
     file_server = servers.get_file_server()
     bitmap_path = file_server.manglepath(
         "outgui:images/tools/blue_folder_close.bmp")
     self.fldridxnative = self.image_list.Add(wx.Bitmap(bitmap_path))
     bitmap_path = file_server.manglepath(
         "outgui:images/tools/blue_folder_open.bmp")
     self.fldropenidxnative = self.image_list.Add(wx.Bitmap(bitmap_path))
     bitmap_path = file_server.manglepath(
         "outgui:images/tools/green_folder_close.bmp")
     self.fldridxuser = self.image_list.Add(wx.Bitmap(bitmap_path))
     bitmap_path = file_server.manglepath(
         "outgui:images/tools/green_folder_open.bmp")
     self.fldropenidxuser = self.image_list.Add(wx.Bitmap(bitmap_path))
     self.SetImageList(self.image_list)
Пример #51
0
 def set_default_icons (self):
     image_size = (16, 16)
     self.image_list = wx.ImageList(
                             image_size[0], 
                             image_size[1]
                             )
     self.fldridxnormal = self.image_list.Add(
                                 wx.ArtProvider_GetBitmap(
                                     wx.ART_FOLDER,
                                     wx.ART_OTHER, 
                                     image_size
                                     )
                                 )
     self.fldropenidxnormal = self.image_list.Add(
                                         wx.ArtProvider_GetBitmap(
                                             wx.ART_FILE_OPEN,
                                             wx.ART_OTHER, 
                                             image_size
                                             )
                                         )
     file_server = servers.get_file_server()
     bitmap_path = file_server.manglepath(
                             "outgui:images/tools/blue_folder_close.bmp"
                             )
     self.fldridxnative = self.image_list.Add( wx.Bitmap(bitmap_path) )
     bitmap_path = file_server.manglepath(
                             "outgui:images/tools/blue_folder_open.bmp"
                             )
     self.fldropenidxnative = self.image_list.Add( wx.Bitmap(bitmap_path) )
     bitmap_path = file_server.manglepath(
                             "outgui:images/tools/green_folder_close.bmp"
                             )
     self.fldridxuser = self.image_list.Add( wx.Bitmap(bitmap_path) )
     bitmap_path = file_server.manglepath(
                             "outgui:images/tools/green_folder_open.bmp"
                             )
     self.fldropenidxuser = self.image_list.Add( wx.Bitmap(bitmap_path) )
     self.SetImageList(self.image_list)
Пример #52
0
def CreateAsset(name, textureName):
    fileServer = servers.get_file_server()
    assetPath = 'wc:export/assets/' + name
    transformNOH = '/lib/scene/' + name
    particleNOH = transformNOH + '/pemiter_0_0'

    rootNode = pynebula.new('ntransformnode', transformNOH)
    particleNode = pynebula.new('nparticleshapenode', particleNOH)
    setDefualtOptions(particleNode, textureName)
    #save shapeNode
    if (not fileServer.makepath(assetPath)):
        return None, ""
    if (not fileServer.makepath(assetPath + '/scene')):
        return None, ""
    if (not fileServer.makepath(assetPath + '/materials')):
        return None, ""

    if (not rootNode.saveas(assetPath + '/scene/' + name + '.n2')):
        return None, ""

    #pynebula.delete(rootNode.getfullname())
    #rootNode = 0
    return particleNode, assetPath
Пример #53
0
def CreateAsset( name , textureName ):
    fileServer =  servers.get_file_server()
    assetPath = 'wc:export/assets/' + name
    transformNOH = '/lib/scene/' + name
    particleNOH =  transformNOH + '/pemiter_0_0'
    
    rootNode = pynebula.new( 'ntransformnode' , transformNOH )
    particleNode = pynebula.new( 'nparticleshapenode' , particleNOH )
    setDefualtOptions( particleNode , textureName )
    #save shapeNode
    if ( not fileServer.makepath( assetPath ) ):
        return None, "" 
    if ( not fileServer.makepath( assetPath + '/scene' ) ):
        return None , "" 
    if ( not fileServer.makepath( assetPath + '/materials' ) ):
        return None, "" 
        
    if ( not rootNode.saveas( assetPath +'/scene/' + name + '.n2' ) ):
        return None,""
        
    #pynebula.delete(rootNode.getfullname())
    #rootNode = 0
    return particleNode , assetPath 
Пример #54
0
 def __init__(self, parent, script):
     wx.Dialog.__init__(self, parent,
         style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
     self.script = script
     
     self.label_sizer_staticbox = wx.StaticBox(self, -1, "Label")
     self.help_sizer_staticbox = wx.StaticBox(self, -1, "Help (only for image buttons)")
     self.button_sizer_staticbox = wx.StaticBox(self, -1, "Button")
     self.script_sizer_staticbox = wx.StaticBox(self, -1, "Script")
     self.label_desc = wx.StaticText(self, -1, "Description:")
     self.text_desc = wx.TextCtrl(self, -1, "")
     self.label_file = wx.StaticText(self, -1, "File:")
     self.text_file = wx.TextCtrl(self, -1, "")
     self.button_file = wx.Button(self, -1, "Chose a file...")
     self.text_info = wx.TextCtrl(self, -1, "A Python script can access to the 'script.custom_data' variable to store any desired custom data. This data will persist between executions, but only if the script is ran from the script manager or from its tool button/menu item (not from other sources, like running it from the script editor).", style=wx.TE_MULTILINE|wx.TE_READONLY)
     self.label_shortcut = wx.StaticText(self, -1, "Shortcut:")
     self.text_shortcut = wx.TextCtrl(self, -1, "")
     self.checkbox_button = wx.CheckBox(self, -1, "Show in toolbar")
     self.radio_image = wx.RadioButton(self, -1, "Image button:", style=wx.RB_GROUP)
     self.bitmap_path = script['button image']
     self.bitmap_button = wx.BitmapButton(self, -1, wx.Bitmap(
         servers.get_file_server().manglepath(str(self.bitmap_path)),
         wx.BITMAP_TYPE_ANY))
     self.button_preset_image = wx.Button(self, -1, "Preset image...")
     self.button_custom_image = wx.Button(self, -1, "Custom image...")
     self.radio_text = wx.RadioButton(self, -1, "Text button:")
     self.text_label = wx.TextCtrl(self, -1, "")
     self.label_tooltip = wx.StaticText(self, -1, "Tool tip text:")
     self.text_tooltip = wx.TextCtrl(self, -1, "")
     self.label_statusbar = wx.StaticText(self, -1, "Status bar text:")
     self.text_statusbar = wx.TextCtrl(self, -1, "")
     self.button_ok = wx.Button(self, -1, "&OK")
     self.button_cancel = wx.Button(self, -1, "&Cancel")
     
     self.__set_properties()
     self.__do_layout()
     self.__bind_events()
Пример #55
0
 def expand_sublists (self, item):
     if self.IsExpanded(item):
         # This event can happen twice in the self.Expand call
         return
     obj = self.GetPyData(item)
     node = obj.gethead()
     fileserver = servers.get_file_server()
     self.libidx = self.image_list.Add(
                         wx.Bitmap(
                             fileserver.manglepath(
                                 "outgui:images/tools/new.bmp"
                                 ),
                         wx.BITMAP_TYPE_ANY
                         )
                     )
     while node != None:
         obj = pynebula.lookup(node.getfullname())
         new_item = self.AppendItem(
                             item, 
                             obj.getname(), 
                             -1, 
                             -1,
                             wx.TreeItemData(obj)
                             )
         if self.is_library(new_item):
             self.SetItemImage(
                 new_item, self.libidx, wx.TreeItemIcon_Normal
                 )
             self.SetItemImage(
                 new_item, self.libidx, wx.TreeItemIcon_Selected
                 )
             self.SetItemImage(
                 new_item, self.libidx, wx.TreeItemIcon_Expanded
                 )
         elif self.GetItemText(self.get_root_library(new_item)) == 'natives' and servers.get_kernel_server().isclassnative(str(self.GetItemText(new_item))):
             self.SetItemImage(
                 new_item, self.fldridxnative, wx.TreeItemIcon_Normal
                 )
             self.SetItemImage(
                 new_item, self.fldropenidxnative, wx.TreeItemIcon_Selected
                 )
             self.SetItemImage(
                 new_item, self.fldropenidxnative, wx.TreeItemIcon_Expanded
                 )
         elif self.GetItemText(self.get_root_library(new_item)) == 'natives' and not servers.get_kernel_server().isclassnative(str(self.GetItemText(new_item))):
             self.SetItemImage(
                 new_item, self.fldridxuser, wx.TreeItemIcon_Normal
                 )
             self.SetItemImage(
                 new_item, self.fldropenidxuser, wx.TreeItemIcon_Selected
                 )
             self.SetItemImage(
                 new_item, self.fldropenidxuser, wx.TreeItemIcon_Expanded
                 )
         else:
             self.SetItemImage(
                 new_item, self.fldridxnormal, wx.TreeItemIcon_Normal
                 )
             self.SetItemImage(
                 new_item, self.fldropenidxnormal, wx.TreeItemIcon_Selected
             )
             self.SetItemImage(
                 new_item, self.fldropenidxnormal, wx.TreeItemIcon_Expanded
                 )
         if obj.gethead() != None:
             self.SetItemHasChildren(new_item, True)
         node = obj.getsucc()
         self.SortChildren(item)
Пример #56
0
 def restore(self, data_list):
     # set brush and tool images
     # load images only once to speed things up
     if not self.restored:
         # brushes
         fileserver = servers.get_file_server()
         brushes_nb = self.terrain.paintbrushcount()
         for i in range(brushes_nb):
             path = self.terrain.getpaintbrushthumbnail(i)
             path = fileserver.manglepath(path)
             bmp = wx.Bitmap(path, wx.BITMAP_TYPE_ANY)
             if self.terrain.issizeablepaintbrush(i):
                 img_name = 'Resizable'
             else:
                 img_name = str( self.terrain.getpaintbrushsizebyindex(i) )
             self.imgbox_brushes.append_image(bmp, name=img_name)
         
         # tools
         tool_names = ['Raise', 'Flatten', 'Slope', 'Smooth', 'Noise',
             'Paint', 'Grass', 'Hole']
         for name in tool_names:
             path = "outgui:images/terrain/%s.bmp" % name.lower()
             path = format.mangle_path( path )
             bmp = wx.Bitmap(path)
             self.imgbox_tools.append_image( bmp, name=name )
         
         self.restored = True
     
     # restore brush size range
     data = data_list[0]
     min_value = 1
     if data.has_key('brush min size'):
         min_value = data['brush min size']
     max_value = 20
     if data.has_key('brush max size'):
         max_value = data['brush max size']
     self.slider_size.set_range(min_value, max_value )
     self.button_range.SetLabel(
         "[%s,%s]" % (min_value, max_value)
         )
     
     # restore conjurer terrain object
     self.terrain.selectpaintbrush( data['selected brush'] )
     size = data['brush size']
     if size < min_value:
         size = min_value
     elif size > max_value:
         size = max_value
     self.choicebook_tool.set_tools_brush_size( size )
     
     # restore controls
     if self.terrain.getselectedpaintbrush() != wx.NOT_FOUND:
         self.imgbox_brushes.set_selection(
             self.terrain.getselectedpaintbrush() 
             )
         selection_index = self.imgbox_brushes.get_selection()
         self.enable_disable_brush_size_range(
             self.terrain.issizeablepaintbrush(
                 selection_index
                 )
             )    
     self.slider_size.set_value( self.terrain.getpaintbrushsize() )
     self.imgbox_tools.set_selection( self.terrain.getselectedtool() )
     
     # restore children
     self.choicebook_tool.restore( data['tools'] )