def on_create_and_attach_entity(self, event): # Show a grimoire browser to let the user choose an entity class dlg = grimoire.create_dialog( self ) ok = dlg.ShowModal() == wx.ID_OK class_name = dlg.GetTitle() dlg.Destroy() if not ok: return # Create an instance of the selected class # position (1, 1, 1) is used just to pass the spatial search cell check # it is not important, since the attachment is always linked to the entity pos entity = servers.get_world_interface().newentity( str(class_name), 1, 1, 1 ) if entity is None: cjr.show_error_message( "Unknown error.\nCouldn't create an instance of" \ "the entity class '" + class_name + "'." ) return # Attach the new entity to the selected slot self.__attach_entity_to_current_slot( entity )
def check_string_subtypes(subtype, param_name, label): if subtype is not "": if "asset" == subtype: directory = mangle_path("wc:export/assets") + "\\" element = pg.wxFileProperty(param_name, label, directory) elif "texture" == subtype: directory = mangle_path("wc:export/textures") + "\\" element = pg.wxFileProperty(param_name, label, directory) elif "shader" == subtype: directory = mangle_path("wc:export/shader") + "\\" element = pg.wxFileProperty(param_name, label, directory) elif "file" == subtype: directory = mangle_path("wc:") element = pg.wxFileProperty(param_name, label, directory) elif "directory" == subtype: directory = mangle_path("home:") element = pg.wxDirProperty(param_name, label, directory) elif "entityobject" == subtype: element = pg.wxStringCallBackProperty(param_name, label, '') dlg = browser.create_dialog(True, "/sys/nobject/nentityobject") element.SetCallBackDialog(dlg) elif "nroot" == subtype: element = pg.wxStringCallBackProperty(param_name, label, '') dlg = browser.create_dialog(True, "/") element.SetCallBackDialog(dlg) elif "entityclass" == subtype: element = pg.wxStringCallBackProperty(param_name, label, '') dlg = grimoire.create_dialog(True) element.SetCallBackDialog(dlg) elif "nobjectclass" == subtype: element = pg.wxStringCallBackProperty(param_name, label, '') dlg = entitybrowser.create_dialog(self) element.SetCallBackDialog(dlg) else: # No subtype element = pg.wxStringProperty(param_name, label, '') return element
def check_string_subtypes(subtype, param_name, label): if subtype is not "": if "asset" == subtype: directory = mangle_path("wc:export/assets") + "\\" element = pg.wxFileProperty(param_name, label, directory) elif "texture" == subtype: directory = mangle_path("wc:export/textures") + "\\" element = pg.wxFileProperty(param_name, label, directory) elif "shader" == subtype: directory = mangle_path("wc:export/shader") + "\\" element = pg.wxFileProperty(param_name, label, directory) elif "file" == subtype: directory = mangle_path("wc:") element = pg.wxFileProperty(param_name, label, directory) elif "directory" == subtype: directory = mangle_path("home:") element = pg.wxDirProperty(param_name, label, directory) elif "entityobject" == subtype: element = pg.wxStringCallBackProperty(param_name, label, '' ) dlg = browser.create_dialog(True, "/sys/nobject/nentityobject") element.SetCallBackDialog(dlg) elif "nroot" == subtype: element = pg.wxStringCallBackProperty(param_name, label, '' ) dlg = browser.create_dialog(True, "/") element.SetCallBackDialog(dlg) elif "entityclass" == subtype: element = pg.wxStringCallBackProperty(param_name, label, '' ) dlg = grimoire.create_dialog(True) element.SetCallBackDialog(dlg) elif "nobjectclass" == subtype: element = pg.wxStringCallBackProperty(param_name, label, '' ) dlg = entitybrowser.create_dialog(self) element.SetCallBackDialog(dlg) else: # No subtype element = pg.wxStringProperty(param_name, label, '') return element
def on_create_and_plug_entity(self, event): # Show a grimoire browser to let the user choose an entity class dlg = grimoire.create_dialog(self) ok = dlg.ShowModal() == wx.ID_OK class_name = dlg.GetTitle() dlg.Destroy() if not ok: return # Create an instance of the selected class # position (1, 1, 1) is used just to pass the spatial search cell check # it is not important, since the plug is always linked to the entity pos entity = servers.get_world_interface().newentity( str(class_name), 1, 1, 1) if entity is None: cjr.show_error_message( "Unknown error.\nCouldn't create an instance of" \ "the entity class '" + class_name + "'." ) return # Plug the new entity to the selected slot self.__plug_entity_to_current_slot(entity)
def on_new_brush(self, event): # Ask for a brush class try: wx.BeginBusyCursor() dlg = grimoire.create_dialog( self, True ) finally: wx.EndBusyCursor() if dlg.ShowModal() == wx.ID_OK: name = dlg.GetTitle() if name != "": brush_name = str(name) # Validate name if self.list_brushes.FindString(brush_name) != wx.NOT_FOUND: cjr.show_error_message( "There is already a grass brush for the '%s' class." \ % brush_name ) else: # Add new brush new_brush = self.material.creategrowthbrush(brush_name) # We need to update the brush list # since the indexing may have changed self.__update_brushes_list() dlg.Destroy()
def __get_subtype_property(self, subtype, name, label): if "asset" == subtype: directory = servers.get_file_server().manglepath("wc:export/assets") + "\\" prop = pg.wxFileProperty(name, label, directory) elif "texture" == subtype: directory = servers.get_file_server().manglepath("wc:export/textures") + "\\" prop = pg.wxFileProperty(name, label, directory) elif "image" == subtype: directory = servers.get_file_server().manglepath("wc:export/textures") + "\\" prop = pg.wxAdvImageFileProperty(name, label) elif "shader" == subtype: directory = servers.get_file_server().manglepath("wc:export/shader") + "\\" prop = pg.wxFileProperty(name, label, directory) elif "file" == subtype: directory = servers.get_file_server().manglepath("wc:") prop = pg.wxFileProperty(name, label, directory) elif "material" == subtype: prop = pg.wxStringCallBackProperty(name, label, '') dlg = nodelibdlg.NodeLibDialog( self, nodelibdlg.SELECT, 'material', 'Material', "/usr/materials") prop.SetCallBackDialog(dlg) elif "directory" == subtype: directory = servers.get_file_server().manglepath("home:") prop = pg.wxDirProperty(name, label, directory) elif "entityobjectclass" == subtype: prop = pg.wxStringCallBackProperty(name, label, '' ) dlg = objbrowserwindow.create_dialog( self, True, "/sys/nobject/nentityobject" ) prop.SetCallBackDialog(dlg) prop = pg.wxStringProperty(name, label, '') elif "nroot" == subtype: prop = pg.wxStringCallBackProperty(name, label, '' ) dlg = objbrowserwindow.create_dialog( self, True, "/" ) prop.SetCallBackDialog(dlg) elif "entityclass" == subtype: prop = pg.wxStringCallBackProperty(name, label, '' ) dlg = grimoire.create_dialog(self, True) prop.SetCallBackDialog(dlg) elif "entityobject" == subtype: prop = pg.wxStringCallBackProperty(name, label, '' ) dlg = entitybrowser.create_dialog(self) prop.SetCallBackDialog(dlg) elif "musicsample" == subtype: prop = pg.wxStringCallBackProperty(name, label, '' ) dlg = musictabledlg.dialog_for_music_sample_selection(self) prop.SetCallBackDialog(dlg) elif "musicmood" == subtype: prop = pg.wxStringCallBackProperty(name, label, '' ) dlg = musictabledlg.dialog_for_music_mood_selection(self) prop.SetCallBackDialog(dlg) elif "musicstyle" == subtype: prop = pg.wxStringCallBackProperty(name, label, '' ) dlg = musictabledlg.dialog_for_music_style_selection(self) prop.SetCallBackDialog(dlg) else: print "Bad subtype" prop = pg.wxStringProperty(name, label, '') return prop