Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 67 additions & 1 deletion cwxml/ymap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from abc import ABC as AbstractClass, abstractmethod
from typing import Union, Type
from xml.etree import ElementTree as ET
from ..sollumz_properties import SollumzGame
from .element import (
AttributeProperty,
ElementProperty,
Expand All @@ -18,13 +19,19 @@
Vector4Property,
)

current_game = SollumzGame.GTA

class YMAP:

file_extension = ".ymap.xml"

@staticmethod
def from_xml_file(filepath):
global current_game
if ".rsc" in filepath:
current_game = SollumzGame.RDR
else:
current_game = SollumzGame.GTA
return CMapData.from_xml_file(filepath)

@staticmethod
Expand Down Expand Up @@ -344,6 +351,51 @@ def __init__(self):
self.max_z_offset = ValueProperty("maxZOffset")
self.object_hash = ValueProperty("objectHash")
self.flags = ValueProperty("flags")


class StepInstance(ElementTree):
tag_name = "Item"

def __init__(self):
super().__init__()
self.position = VectorProperty("position")
self.width = ValueProperty("width")
self.depth = ValueProperty("depth")
self.height = ValueProperty("height")
self.forward = VectorProperty("forward")
self.right = VectorProperty("right")


class StepInstanceList(ListProperty):
list_type = StepInstance
tag_name = "steps"
item_type = "qbgDfAA_0xA15F529D"

def __init__(self, tag_name=None, value=None):
super().__init__(tag_name, value)
self.item_type = AttributeProperty("itemType", self.item_type)

@staticmethod
def from_xml(element: ET.Element):
new = StepInstanceList()
for child in element.iter():
if len(child.attrib) <= 0:
step = StepInstance
new.value.append(step.from_xml(child))

return new


class ExtensionStairs(Extension):
type = "CExtensionDefStairs"

def __init__(self):
super().__init__()
self.bottom = VectorProperty("bottom")
self.top = VectorProperty("top")
self.bound_min = VectorProperty("boundMin")
self.bound_max = VectorProperty("boundMax")
self.steps = StepInstanceList()


class ExtensionsList(ListProperty):
Expand Down Expand Up @@ -382,6 +434,8 @@ def get_extension_xml_class_from_type(ext_type: str) -> Union[Type[Extension], N
return ExtensionProcObject
elif ext_type == ExtensionScriptEntityId.type:
return ExtensionScriptEntityId
elif ext_type == ExtensionStairs.type:
return ExtensionStairs

return None

Expand Down Expand Up @@ -431,10 +485,22 @@ def __init__(self):
self.tint_value = ValueProperty("tintValue", 0)


class EntityRDR(Entity):
def __init__(self):
super().__init__()
self.blend_age_layer = ValueProperty("blendAgeLayer", 0)
self.blend_age_dirt = ValueProperty("blendAgeDirt", 0)


class EntityList(ListPropertyRequired):
list_type = Entity
tag_name = "entities"

def __init__(self, current_game):
if current_game == SollumzGame.RDR:
self.list_type = Entity
super().__init__()


class ContainerLodsList(ElementTree):
"""This is not used by GTA5 but added for completion"""
Expand Down Expand Up @@ -636,7 +702,7 @@ def __init__(self):
self.streaming_extents_max = VectorProperty("streamingExtentsMax")
self.entities_extents_min = VectorProperty("entitiesExtentsMin")
self.entities_extents_max = VectorProperty("entitiesExtentsMax")
self.entities = EntityList()
self.entities = EntityList(current_game)
self.container_lods = ContainerLodsList()
self.box_occluders = BoxOccludersList()
self.occlude_models = OccludeModelsList()
Expand Down
6 changes: 3 additions & 3 deletions cwxml/ytyp.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self):
self.extensions = ExtensionsList()
if current_game == SollumzGame.RDR:
self.guid = ValueProperty("guid")
self.unknown_1 = TextProperty("iypiqkia_0x07d164a8")
self.unknown_1 = TextProperty("zqNiUDA_0x07D164A8")

class TimeArchetype(BaseArchetype):
def __init__(self):
Expand Down Expand Up @@ -260,7 +260,7 @@ def __init__(self):
super().__init__()
self.name = TextProperty("name")
self.locations = LocationsBuffer()
self.entities = EntityList()
self.entities = EntityList(current_game)


class EntitySetsList(ListProperty):
Expand Down Expand Up @@ -298,7 +298,7 @@ def __init__(self):
super().__init__()
self.type = AttributeProperty("type", "CMloArchetypeDef")
self.mlo_flags = ValueProperty("mloFlags")
self.entities = EntityList()
self.entities = EntityList(current_game)
self.rooms = RoomsList()
self.portals = PortalsList()
self.entity_sets = EntitySetsList()
Expand Down
18 changes: 16 additions & 2 deletions sollumz_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import ast
from typing import Any
from .sollumz_properties import SollumType
from .sollumz_properties import SollumType, SollumzGame, items_from_enums
from configparser import ConfigParser
from typing import Optional

Expand Down Expand Up @@ -363,6 +363,14 @@ class SollumzAddonPreferences(bpy.types.AddonPreferences):
update=_save_preferences
)

default_game: bpy.props.EnumProperty(
items=items_from_enums(SollumzGame),
name="Default game:",
description="Sets the game with which Blender will start",
default=SollumzGame.GTA,
update=_save_preferences
)

shared_textures_directories: CollectionProperty(
name="Shared Textures",
type=SzSharedTexturesDirectory,
Expand Down Expand Up @@ -390,6 +398,7 @@ def draw(self, context):
layout.prop(self, "extra_color_swatches")
layout.prop(self, "sollumz_icon_header")
layout.prop(self, "use_text_name_as_mat_name")
layout.prop(self, "default_game")

from .sollumz_ui import draw_list_with_add_remove
layout.separator()
Expand Down Expand Up @@ -463,7 +472,12 @@ def _apply_preferences(data_block: bpy.types.ID, config: ConfigParser, section:
continue

value_str = config.get(section, key)
value = ast.literal_eval(value_str)

#it crashes for enum
if key == "default_game":
value = value_str
else:
value = ast.literal_eval(value_str)

if key == "shared_textures_directories":
# Special case to handle CollectionProperty
Expand Down
11 changes: 9 additions & 2 deletions sollumz_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,11 @@ class EntityProperties:
artificial_ambient_occlusion: bpy.props.FloatProperty(
name="Artificial Ambient Occlusion", default=255)
tint_value: bpy.props.FloatProperty(name="Tint Value")
#RDR
blend_age_layer: bpy.props.FloatProperty(
name="Blend Age Layer", default=255)
blend_age_dirt: bpy.props.FloatProperty(
name="Blend Age Dirt", default=255)


class ObjectEntityProperties(bpy.types.PropertyGroup, EntityProperties):
Expand All @@ -621,17 +626,19 @@ def updateSceneSollumzGame(self, context):
context.scene.sollum_collision_material_game_type = context.scene.sollum_game_type

def register():
from .sollumz_preferences import get_addon_preferences
preferences = get_addon_preferences(bpy.context)
bpy.types.Object.sollum_game_type = bpy.props.EnumProperty(
items=items_from_enums(SollumzGame),
name="Sollumz Game",
default=SollumzGame.GTA,
default=preferences.default_game,
options={"HIDDEN"}
)

bpy.types.Scene.sollum_game_type = bpy.props.EnumProperty(
items=items_from_enums(SollumzGame),
name="Sollumz Game",
default=SollumzGame.GTA,
default=preferences.default_game,
options={"HIDDEN"},
update=updateSceneSollumzGame
)
Expand Down
1 change: 1 addition & 0 deletions tests/test_obj_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def test_obj_as_vertices_only():
"../ytyp/gizmos/models/SpawnPoint.obj",
"../ytyp/gizmos/models/SpawnPointOverride.obj",
"../ytyp/gizmos/models/WindDisturbance.obj",
"../ytyp/gizmos/models/Stair.obj",
))
def test_obj_read_sollumz_builtin_asset(obj_relative_file_path: str):
obj_path = Path(__file__).parent.joinpath(obj_relative_file_path)
Expand Down
12 changes: 12 additions & 0 deletions ybn/flag_presets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
<Flags1>cf_map_type_horse, cf_cover_type, cf_map_type_mover, cf_map_type_vehicle, cf_map_type_weapon</Flags1>
<Flags2>cf_vehicle_non_bvh_type, cf_vehicle_bvh_type, cf_ped_type, cf_ragdoll_type, cf_horse_type, cf_horse_ragdoll_type, cf_object_type, cf_plant_type, cf_projectile_type, cf_explosion_type, cf_forklift_forks_type, cf_weapon_test, cf_camera_test, cf_ai_test, cf_script_test, cf_wheel_test, cf_glass_type</Flags2>
</Item>
<Item name="Horse Avoidance" game="sollumz_rdr3">
<Flags1>cf_horse_avoidance</Flags1>
<Flags2>cf_horse_type, cf_horse_ragdoll_type, cf_ai_test</Flags2>
</Item>
<Item name="Stair plane" game="sollumz_rdr3">
<Flags1>cf_stair_slope_type</Flags1>
<Flags2>cf_ped_type, cf_horse_type, cf_weapon_test, cf_camera_test, cf_ai_test, cf_script_test, cf_wheel_test</Flags2>
</Item>
<Item name="River Type" game="sollumz_rdr3">
<Flags1>cf_river_type</Flags1>
<Flags2>cf_weapon_test, cf_camera_test, cf_ai_test, cf_script_test, cf_wheel_test</Flags2>
</Item>
<Item name="General 2">
<Flags1>map_animal, map_cover, map_dynamic, map_vehicle</Flags1>
<Flags2>vehicle_not_bvh, vehicle_bvh, ped, ragdoll, animal, animal_ragdoll, object, plant, projectile, explosion, forklift_forks, test_weapon, test_camera, test_ai, test_script, test_vehicle_wheel, glass</Flags2>
Expand Down
22 changes: 16 additions & 6 deletions ybn/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ class SOLLUMZ_OT_delete_flag_preset(SOLLUMZ_OT_base, bpy.types.Operator):
"Stair plane",
"Stair mesh",
"Deep surface",
"Horse Avoidance",
"River Type",
]

def run(self, context):
Expand Down Expand Up @@ -430,6 +432,8 @@ def run(self, context):
flag_preset = FlagPreset()
flag_preset.name = self.name

flag_preset.game = obj.sollum_game_type

for prop in dir(obj.composite_flags1):
value = getattr(obj.composite_flags1, prop)
if value is True:
Expand Down Expand Up @@ -472,11 +476,13 @@ def run(self, context):
preset = flag_presets.presets[index]

if obj.sollum_game_type == SollumzGame.RDR:
preset = flag_presets.presets[1]
if not preset or preset.game != obj.sollum_game_type:
preset = flag_presets.presets[1]
flags_class = RDRBoundFlags
type_flags, include_flags = obj.type_flags, obj.include_flags
else:
preset = flag_presets.presets[0]
if not preset or preset.game != obj.sollum_game_type:
preset = flag_presets.presets[0]
flags_class = BoundFlags
type_flags, include_flags = obj.composite_flags1, obj.composite_flags2

Expand All @@ -486,7 +492,6 @@ def run(self, context):

type_flags[flag_name] = flag_in_preset1
include_flags[flag_name] = flag_in_preset2
include_flags[flag_name] = flag_in_preset2

tag_redraw(context)
self.message(
Expand Down Expand Up @@ -514,9 +519,14 @@ def run(self, context):
return False

if aobj.sollum_type in BOUND_TYPES:
for flag_name in BoundFlags.__annotations__.keys():
aobj.composite_flags1[flag_name] = False
aobj.composite_flags2[flag_name] = False
if aobj.sollum_game_type == SollumzGame.RDR:
for flag_name in RDRBoundFlags.__annotations__.keys():
aobj.type_flags[flag_name] = False
aobj.include_flags[flag_name] = False
else:
for flag_name in BoundFlags.__annotations__.keys():
aobj.composite_flags1[flag_name] = False
aobj.composite_flags2[flag_name] = False

tag_redraw(context)

Expand Down
Loading