def start(self): if not general.is_layer_exist("font_bebas_neau"): general.message_box_ok( "Please Import Editor/Python/Scripts/text_writer/font_bebas_neau.lyr" ) else: return self.create_designer_text()
def create_variants(): try: io = IconObjectDB() except ValueError as val_err: general.message_box_ok(str(val_err)) return None general.clear_selection() general.select_object("icon_object_shot") # get the other items name mtl and brush item_filepaths = get_file_path_list(".xml", get_items_dir()) # overwrite the name mtl and brush icon_object_variants = [ { "name": get_item_name_from_xml(filepath), "brush": get_item_geometry_from_xml(filepath), "mtl": get_item_material_from_xml(filepath), "scale": general.get_scale("icon_object_shot"), "pos": general.get_position("icon_object_shot"), "rot": general.get_rotation("icon_object_shot"), } for filepath in item_filepaths ] # save it for icon_obj in icon_object_variants: io.insert_object(icon_obj, override=True)
def main(): cwd = os.getcwd() if "Steam" in cwd: general.message_box_ok("Remove your Hard link it is no longer needed") return "nothing" os.chdir("EI/Tools/Atlas/map") subprocess.call(["nw.exe"]) os.chdir(cwd)
def main(): level = Level() selected = level.selected if len(selected) == 0: general.message_box_ok("Please Select a mesh") return material = add_game_root_to_path(level.selected[0].material) brushes = find_brushes_with_material(material) print(add_cgfs(brushes))
def copy_xforms(): store = UserValues() selected = general.get_names_of_selected_objects()[0] if selected is None: general.message_box_ok("Please Select an object") rot = general.get_rotation(selected) pos = general.get_position(selected) scale = general.get_scale(selected) store.set("xforms", {"rot": rot, "pos": pos, "scale": scale})
def paste_xforms(): store = UserValues() selected = general.get_names_of_selected_objects()[0] if selected is None: general.message_box_ok("Please Select an object") xforms = store.get("xforms") general.set_position(selected, xforms['pos'][0], xforms['pos'][1], xforms['pos'][2]) general.set_rotation(selected, xforms['rot'][0], xforms['rot'][1], xforms['rot'][2]) general.set_scale(selected, xforms['scale'][0], xforms['scale'][1], xforms['scale'][2])
def get_set_xml_mtl(self): '''reads a file and gets and sets the top mtl and xml from it''' try: with open(self.icon_file_todo, 'r') as f: mtl, xml = f.readline().rstrip().split(',') self.xml = xml self.mtl = mtl except Exception as e: self.last_image = True general.message_box_ok('No More Icons Stop Clicking') self.rename_last_image()
def load(): try: io = IconObjectDB() except ValueError as val_err: general.message_box_ok(str(val_err)) return False brush = norm_path_for_ce(general.open_file_box(), maintain_casing=False) obj = io.get_obj_by_brush(brush) if obj is not None: add_to_scene(obj) else: add_to_scene(get_default_object(brush))
def load_by_name(): try: io = IconObjectDB() except ValueError as val_err: general.message_box_ok(str(val_err)) return False name = general.edit_box("Entity Classname") if not name: return False obj = io.get_obj_by_name(name) print(obj) if obj is not None: add_to_scene(obj) if obj is None: if general.message_box_yes_no("Does not Exist! \n Load By Brush?"): # load it by brush load()
def create_variants(): try: io = IconObjectDB() except ValueError as val_err: general.message_box_ok(str(val_err)) return None general.clear_selection() general.select_object("icon_object_shot") # get the other items name mtl and brush item_filepaths = get_file_path_list(".xml", get_items_dir()) # overwrite the name mtl and brush icon_object_variants = [{ "name": get_item_name_from_xml(filepath), "brush": get_item_geometry_from_xml(filepath), "mtl": get_item_material_from_xml(filepath), "scale": general.get_scale("icon_object_shot"), "pos": general.get_position("icon_object_shot"), "rot": general.get_rotation("icon_object_shot"), } for filepath in item_filepaths] # save it for icon_obj in icon_object_variants: io.insert_object(icon_obj, override=True)
def load_batch(_store): try: io = IconObjectDB() except ValueError as val_err: general.message_box_ok(str(val_err)) return False xml_path = store.get("todo")[0] name = get_item_name_from_xml(xml_path) if xml_path is not None: icon_object = io.get_obj_by_name(name) if icon_object: add_to_scene(icon_object) else: print('Inserting ' + name + 'to icon database') add_to_scene( get_default_object( get_item_geometry_from_xml(xml_path), mtl=get_item_material_from_xml(xml_path), name=name ) ) save(name) add_item_to_processed_list(xml_path, store)
def get_icon_object_in_scene(): try: store = UserValues() io = IconObjectDB() except ValueError as val_err: general.message_box_ok(str(val_err)) return None store_obj = store.get("current_icon_object") if store_obj: print('Returning Stored Object from User Values') print(store_obj) return store_obj # if we can't find a stored version try and find it if not store_obj: general.select_object("icon_object_shot") obj = io.get_obj_by_brush_and_mtl( lodtools.getselected().lower(), general.get_assigned_material("icon_object_shot"), ) if obj: return obj # object was not set in store and is not set in io_db return None
def load_by_xml(): try: io = IconObjectDB() except ValueError as val_err: general.message_box_ok(str(val_err)) return False xml_filepath = general.open_file_box() if not xml_filepath: return False entity_name = get_item_name_from_xml(xml_filepath) obj = io.get_obj_by_name(entity_name) if is_vehicle_skin(xml_filepath): vehicle_skin_name = get_skin_name(xml_filepath) base_item_name = get_vehicle_name_from_skin(xml_filepath) io_obj = ( io.get_obj_by_name(vehicle_skin_name) if io.get_obj_by_name(vehicle_skin_name) is not None else io.get_obj_by_name(base_item_name) ) tod = "12" if "tod" in io_obj: tod = io_obj["tod"] add_to_scene( get_default_object( io_obj["brush"], mtl=get_item_material_from_skin_xml(xml_filepath), name=vehicle_skin_name, pos=io_obj["pos"], rot=io_obj["rot"], scale=io_obj["scale"], tod=tod, ) ) return True # check if it's a skin file if it is grab the base item xml file and use that. if is_skin(xml_filepath): base_item_xml_path = get_base_item_xml_path(xml_filepath) base_item_name = get_item_name_from_xml(base_item_xml_path) io_obj = io.get_obj_by_name(base_item_name) tod = "12" if "tod" in io_obj: tod = io_obj["tod"] add_to_scene( get_default_object( io_obj["brush"], mtl=get_item_material_from_skin_xml(xml_filepath), name=entity_name, pos=io_obj["pos"], rot=io_obj["rot"], scale=io_obj["scale"], tod=tod, ) ) return True # if the object already exists grab it and add it to the scene if obj is not None: add_to_scene(obj) return True # add the object to the scene add_to_scene( get_default_object( get_item_geometry_from_xml(xml_filepath), mtl=get_item_material_from_xml(xml_filepath), name=entity_name, ) ) save(entity_name) return True
def check_if_text_layer_present(): if not general.is_layer_exist("font_bebas_neau"): general.message_box_ok( "Please Import Editor/Python/Scripts/text_writer/font_bebas_neau.lyr" ) return False
def save(name=False, overwrite=False, embellishment=None): """ Save an Icon Setup :return: string name of the entity class name """ # name of icon_object in icon_level.cry ico_obj = "icon_object_shot" store = UserValues() # the obj to insert obj = dict() # instantiate our iodb try: io = IconObjectDB() except ValueError as val_err: general.message_box_ok(str(val_err)) return None # clear the selection general.clear_selection() # get the info from the icon_object_shot obj["pos"] = general.get_position(ico_obj) obj["scale"] = general.get_scale(ico_obj) obj["rot"] = general.get_rotation(ico_obj) obj["mtl"] = general.get_assigned_material(ico_obj) obj["tod"] = general.get_cvar("e_timeOfDay") # get the brush by selecting the ico_obj general.select_object(ico_obj) obj["brush"] = lodtools.getselected().lower() general.clear_selection() stored = io.get_obj_by_brush_and_mtl(obj["brush"], obj["mtl"]) if embellishment: print("Saving Embellishments") obj["embellishment_48"] = embellishment["embellishment_48"] obj["embellishment_200"] = embellishment["embellishment_200"] obj["embellishment_2048"] = embellishment["embellishment_2048"] if "embellishment_under" in embellishment.keys(): obj["embellishment_under"] = True else: icon_obj = store.get("current_icon_object") if icon_obj: keys = icon_obj.keys() if "embellishment_under" in keys: obj["embellishment_under"] = True if "embellishment_48" in keys: obj["embellishment_48"] = icon_obj["embellishment_48"] if "embellishment_200" in keys: obj["embellishment_200"] = icon_obj["embellishment_200"] if "embellishment_2048" in keys: obj["embellishment_2048"] = icon_obj["embellishment_2048"] if name: obj["name"] = name elif stored: obj["name"] = stored["name"] if not general.message_box_yes_no(str("Save " + stored["name"] + "?")): obj["name"] = general.edit_box("Entity ClassName") else: overwrite = True else: obj["name"] = general.edit_box("Entity ClassName") if io.insert_object(obj) is False: if overwrite: io.insert_object(obj, override=True) else: if general.message_box_yes_no("Overwrite?"): io.insert_object(obj, override=True) print("Storing Item into UserValues") store.set("current_icon_object", obj) return obj["name"]