Skip to content

Commit

Permalink
schema fixes / formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
toasterparty committed Aug 1, 2024
1 parent 39b2043 commit 2609723
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 90 deletions.
10 changes: 5 additions & 5 deletions schema/randomprime.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@
"type": "boolean",
"default": true
},
"noHud": {
"description": "If true, removes many hud elements",
"type": "boolean",
"default": false
},
"trilogyDiscPath": {
"description": "The filepath to a Trilogy ISO to restore the intended Flaahgra music.",
"type": "string"
Expand Down Expand Up @@ -925,11 +930,6 @@
"type": "string",
"default": null
},
"noHud": {
"description": "If true, removes many hud elements",
"type": "boolean",
"default": false
},
"artifactHints": {
"description": "The hint provided to the player when scanning the respective Artifact's totem in Artifact Temple. Supports color modification with &push and &pop delimiters. If left unspecified, defaults to humorous hints which include the room name of the corresponding artifact.",
"type": "object",
Expand Down
76 changes: 49 additions & 27 deletions src/add_modify_obj_patches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ use crate::{
mlvl_wrapper,
patch_config::{
ActorKeyFrameConfig, ActorRotateConfig, BlockConfig, BombSlotConfig, CameraConfig,
CameraHintTriggerConfig, CameraFilterKeyframeConfig, CameraWaypointConfig, ControllerActionConfig,
CounterConfig, DamageType, FogConfig, GenericTexture, HudmemoConfig, LockOnPoint, NewCameraHintConfig,
PlatformConfig, PlatformType, PlayerActorConfig, PlayerHintConfig, RelayConfig, SpawnPointConfig,
SpecialFunctionConfig, StreamedAudioConfig, SwitchConfig, TimerConfig, TriggerConfig,
WaterConfig, WaypointConfig, WorldLightFaderConfig,
CameraFilterKeyframeConfig, CameraHintTriggerConfig, CameraWaypointConfig,
ControllerActionConfig, CounterConfig, DamageType, FogConfig, GenericTexture,
HudmemoConfig, LockOnPoint, NewCameraHintConfig, PlatformConfig, PlatformType,
PlayerActorConfig, PlayerHintConfig, RelayConfig, SpawnPointConfig, SpecialFunctionConfig,
StreamedAudioConfig, SwitchConfig, TimerConfig, TriggerConfig, WaterConfig, WaypointConfig,
WorldLightFaderConfig,
},
patcher::PatcherState,
patches::{string_to_cstr, WaterType},
Expand Down Expand Up @@ -1938,15 +1939,20 @@ pub fn patch_add_new_camera_hint(
hint_distance_selection: config.hint_distance_selection.unwrap_or(false) as u8,
hint_distance_self_pos: config.hint_distance_self_pos.unwrap_or(false) as u8,
control_interpolation: config.control_interpolation.unwrap_or(false) as u8,
sinusoidal_interpolation: config.sinusoidal_interpolation.unwrap_or(false) as u8,
sinusoidal_interpolation_hintless: config.sinusoidal_interpolation_hintless.unwrap_or(false) as u8,
sinusoidal_interpolation: config.sinusoidal_interpolation.unwrap_or(false)
as u8,
sinusoidal_interpolation_hintless: config
.sinusoidal_interpolation_hintless
.unwrap_or(false) as u8,
clamp_velocity: config.clamp_velocity.unwrap_or(false) as u8,
skip_cinematic: config.skip_cinematic.unwrap_or(false) as u8,
no_elevation_interp: config.no_elevation_interp.unwrap_or(false) as u8,
direct_elevation: config.direct_elevation.unwrap_or(false) as u8,
override_look_dir: config.override_look_dir.unwrap_or(false) as u8,
no_elevation_vel_clamp: config.no_elevation_vel_clamp.unwrap_or(false) as u8,
calculate_transform_from_prev_cam: config.calculate_transform_from_prev_cam.unwrap_or(false) as u8,
calculate_transform_from_prev_cam: config
.calculate_transform_from_prev_cam
.unwrap_or(false) as u8,
no_spline: config.no_spline.unwrap_or(false) as u8,
unknown21: config.unknown1.unwrap_or(false) as u8,
unknown22: config.unknown2.unwrap_or(false) as u8,
Expand Down Expand Up @@ -1976,7 +1982,10 @@ pub fn patch_add_new_camera_hint(
.into(),
chase_look_at_offset: structs::scly_props::structs::BoolVec3 {
override_flags: config.override_chase_look_at_offset.unwrap_or(false) as u8,
value: config.chase_look_at_offset.unwrap_or([0.0, 0.0, 0.0]).into(),
value: config
.chase_look_at_offset
.unwrap_or([0.0, 0.0, 0.0])
.into(),
}
.into(),

Expand Down Expand Up @@ -2062,19 +2071,26 @@ pub fn patch_add_new_camera_hint(
property_data.camera_hint_params.look_at_ball = look_at_ball as u8
}
if let Some(hint_distance_selection) = config.hint_distance_selection {
property_data.camera_hint_params.hint_distance_selection = hint_distance_selection as u8
property_data.camera_hint_params.hint_distance_selection =
hint_distance_selection as u8
}
if let Some(hint_distance_self_pos) = config.hint_distance_self_pos {
property_data.camera_hint_params.hint_distance_self_pos = hint_distance_self_pos as u8
property_data.camera_hint_params.hint_distance_self_pos =
hint_distance_self_pos as u8
}
if let Some(control_interpolation) = config.control_interpolation {
property_data.camera_hint_params.control_interpolation = control_interpolation as u8
}
if let Some(sinusoidal_interpolation) = config.sinusoidal_interpolation {
property_data.camera_hint_params.sinusoidal_interpolation = sinusoidal_interpolation as u8
property_data.camera_hint_params.sinusoidal_interpolation =
sinusoidal_interpolation as u8
}
if let Some(sinusoidal_interpolation_hintless) = config.sinusoidal_interpolation_hintless {
property_data.camera_hint_params.sinusoidal_interpolation_hintless = sinusoidal_interpolation_hintless as u8
if let Some(sinusoidal_interpolation_hintless) =
config.sinusoidal_interpolation_hintless
{
property_data
.camera_hint_params
.sinusoidal_interpolation_hintless = sinusoidal_interpolation_hintless as u8
}
if let Some(clamp_velocity) = config.clamp_velocity {
property_data.camera_hint_params.clamp_velocity = clamp_velocity as u8
Expand All @@ -2092,10 +2108,15 @@ pub fn patch_add_new_camera_hint(
property_data.camera_hint_params.override_look_dir = override_look_dir as u8
}
if let Some(no_elevation_vel_clamp) = config.no_elevation_vel_clamp {
property_data.camera_hint_params.no_elevation_vel_clamp = no_elevation_vel_clamp as u8
property_data.camera_hint_params.no_elevation_vel_clamp =
no_elevation_vel_clamp as u8
}
if let Some(calculate_transform_from_prev_cam) = config.calculate_transform_from_prev_cam {
property_data.camera_hint_params.calculate_transform_from_prev_cam = calculate_transform_from_prev_cam as u8
if let Some(calculate_transform_from_prev_cam) =
config.calculate_transform_from_prev_cam
{
property_data
.camera_hint_params
.calculate_transform_from_prev_cam = calculate_transform_from_prev_cam as u8
}
if let Some(no_spline) = config.no_spline {
property_data.camera_hint_params.no_spline = no_spline as u8
Expand Down Expand Up @@ -2131,7 +2152,8 @@ pub fn patch_add_new_camera_hint(
property_data.look_at_offset.value = look_at_offset.into()
}
if let Some(override_chase_look_at_offset) = config.override_chase_look_at_offset {
property_data.chase_look_at_offset.override_flags = override_chase_look_at_offset as u8
property_data.chase_look_at_offset.override_flags =
override_chase_look_at_offset as u8
}
if let Some(chase_look_at_offset) = config.chase_look_at_offset {
property_data.chase_look_at_offset.value = chase_look_at_offset.into()
Expand Down Expand Up @@ -2187,14 +2209,7 @@ pub fn patch_add_new_camera_hint(
};
}

add_edit_obj_helper!(
area,
Some(config.id),
config.layer,
CameraHint,
new,
update
);
add_edit_obj_helper!(area, Some(config.id), config.layer, CameraHint, new, update);
}

pub fn patch_add_camera_hint_trigger(
Expand Down Expand Up @@ -2241,7 +2256,14 @@ pub fn patch_add_camera_hint_trigger(
};
}

add_edit_obj_helper!(area, config.id, config.layer, CameraHintTrigger, new, update);
add_edit_obj_helper!(
area,
config.id,
config.layer,
CameraHintTrigger,
new,
update
);
}

pub fn patch_add_platform<'r>(
Expand Down
36 changes: 23 additions & 13 deletions src/patch_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ pub enum EBallCameraBehaviour {
HintFixedTransform,
PathCameraDesiredPos, // Unused
PathCamera,
SpindleCamera
SpindleCamera,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down Expand Up @@ -914,7 +914,6 @@ pub struct CameraHintTriggerConfig {
pub deactivate_on_exit: Option<bool>,
}


#[allow(non_camel_case_types)]
#[derive(Debug, Serialize, Deserialize, Copy, Clone, Eq, PartialEq)]
#[repr(u32)]
Expand Down Expand Up @@ -2534,13 +2533,9 @@ impl PatchConfigPrivate {
};

let spring_ball_item = {
match self
.game_config
.spring_ball_item
.as_deref()
{
match self.game_config.spring_ball_item.as_deref() {
Some(s) => PickupType::from_str(s),
None => PickupType::MorphBallBomb
None => PickupType::MorphBallBomb,
}
};

Expand Down Expand Up @@ -2575,10 +2570,22 @@ impl PatchConfigPrivate {
.game_config
.phazon_elite_without_dynamo
.unwrap_or(!force_vanilla_layout),
main_plaza_door: self.game_config.main_plaza_door.unwrap_or(!force_vanilla_layout),
backwards_labs: self.game_config.backwards_labs.unwrap_or(!force_vanilla_layout),
backwards_frigate: self.game_config.backwards_frigate.unwrap_or(!force_vanilla_layout),
backwards_upper_mines: self.game_config.backwards_upper_mines.unwrap_or(!force_vanilla_layout),
main_plaza_door: self
.game_config
.main_plaza_door
.unwrap_or(!force_vanilla_layout),
backwards_labs: self
.game_config
.backwards_labs
.unwrap_or(!force_vanilla_layout),
backwards_frigate: self
.game_config
.backwards_frigate
.unwrap_or(!force_vanilla_layout),
backwards_upper_mines: self
.game_config
.backwards_upper_mines
.unwrap_or(!force_vanilla_layout),
backwards_lower_mines: self.game_config.backwards_lower_mines.unwrap_or(false),
patch_power_conduits: self.game_config.patch_power_conduits.unwrap_or(false),
remove_mine_security_station_locks: self
Expand All @@ -2598,7 +2605,10 @@ impl PatchConfigPrivate {
.hall_of_the_elders_bomb_slot_covers,
automatic_crash_screen: self.preferences.automatic_crash_screen.unwrap_or(true),
visible_bounding_box: self.preferences.visible_bounding_box.unwrap_or(false),
door_destination_scans: self.preferences.door_destination_scans.unwrap_or(!force_vanilla_layout),
door_destination_scans: self
.preferences
.door_destination_scans
.unwrap_or(!force_vanilla_layout),
no_hud: self.preferences.no_hud.unwrap_or(false),
artifact_hint_behavior,
flaahgra_music_files,
Expand Down
71 changes: 28 additions & 43 deletions src/patches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use crate::{
CtwkConfig, CutsceneMode, DifficultyBehavior, DoorConfig, DoorOpenMode, FogConfig,
GameBanner, GenericTexture, HallOfTheEldersBombSlotCoversConfig, IsoFormat, LevelConfig,
PatchConfig, PhazonDamageModifier, PickupConfig, PlatformConfig, PlatformType, RoomConfig,
RunMode, SpecialFunctionType, SuitDamageReduction, Version, Visor, TimerConfig
RunMode, SpecialFunctionType, SuitDamageReduction, TimerConfig, Version, Visor,
},
patcher::{PatcherState, PrimePatcher},
pickup_meta::{
Expand Down Expand Up @@ -11211,11 +11211,11 @@ fn patch_dol(
_spring_ball_item_condition_patch.encoded_bytes()
} else {
let _spring_ball_item_condition_patch = ppcasm!(new_text_section_end, {
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
});
_spring_ball_item_condition_patch.encoded_bytes()
};
Expand Down Expand Up @@ -16314,30 +16314,22 @@ fn build_and_run_patches<'r>(
start_immediately: Some(true),

layer: None,
max_random_add: None,
max_random_add: None,
};

patcher.add_scly_patch(
res.into(),
move |ps, area| {
patch_add_timer(ps, area, timer_config.clone())
},
);

let connections = vec![
ConnectionConfig {
sender_id: timer_id,
state: ConnectionState::ZERO,
target_id: dock_id,
message: ConnectionMsg::INCREMENT,
}
];
patcher.add_scly_patch(
res.into(),
move |ps, area| {
patch_add_connections(ps, area, &connections)
},
);

patcher.add_scly_patch(res.into(), move |ps, area| {
patch_add_timer(ps, area, timer_config.clone())
});

let connections = vec![ConnectionConfig {
sender_id: timer_id,
state: ConnectionState::ZERO,
target_id: dock_id,
message: ConnectionMsg::INCREMENT,
}];
patcher.add_scly_patch(res.into(), move |ps, area| {
patch_add_connections(ps, area, &connections)
});
}
}
}
Expand Down Expand Up @@ -16389,7 +16381,7 @@ fn build_and_run_patches<'r>(
// this is a hack because something is getting messed up with the MREA objects if this patch never gets used
let remove_otrs = config.qol_cosmetic
&& !(config.shuffle_pickup_position
&& room_info.room_id.to_u32() == 0x40C548E9);
&& room_info.room_id.to_u32() == 0x40C548E9);

patcher.add_scly_patch(
(pak_name.as_bytes(), room_info.room_id.to_u32()),
Expand Down Expand Up @@ -16687,7 +16679,8 @@ fn build_and_run_patches<'r>(
}
}

if let Some(camera_filter_keyframes) = room.camera_filter_keyframes.as_ref() {
if let Some(camera_filter_keyframes) = room.camera_filter_keyframes.as_ref()
{
for config in camera_filter_keyframes {
patcher.add_scly_patch(
(pak_name.as_bytes(), room_info.room_id.to_u32()),
Expand Down Expand Up @@ -16720,7 +16713,6 @@ fn build_and_run_patches<'r>(
}
}


if room.streamed_audios.is_some() {
for config in room.streamed_audios.as_ref().unwrap() {
patcher.add_scly_patch(
Expand Down Expand Up @@ -17210,7 +17202,7 @@ fn build_and_run_patches<'r>(
scan.position,
scan.rotation.unwrap_or(0.0),
scan.layer,
scan.actor_id
scan.actor_id,
)
},
);
Expand Down Expand Up @@ -17710,17 +17702,10 @@ fn build_and_run_patches<'r>(
});

if config.no_hud {
for res in vec![
resource_info!("FRME_CombatHud.FRME"),
for res in [resource_info!("FRME_CombatHud.FRME"),
resource_info!("FRME_BallHud.FRME"),
resource_info!("FRME_ScanHud.FRME"),
// resource_info!("FRME_Helmet.FRME"),
// resource_info!("FRME_BaseHud.FRME"),
] {
patcher.add_resource_patch(
res.into(),
patch_no_hud,
);
resource_info!("FRME_ScanHud.FRME")] {
patcher.add_resource_patch(res.into(), patch_no_hud);
}
}

Expand Down
2 changes: 1 addition & 1 deletion structs/src/scly_props/camera_hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use auto_struct_macros::auto_struct;
use reader_writer::{generic_array::GenericArray, typenum::U3, CStr};

use crate::{
scly_props::structs::{CameraHintParameters, BoolFloat, BoolVec3},
scly_props::structs::{BoolFloat, BoolVec3, CameraHintParameters},
SclyPropertyData,
};

Expand Down
2 changes: 1 addition & 1 deletion structs/src/scly_props/water.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ impl<'r> SclyPropertyData for Water<'r> {
fn impl_set_damage_infos(&mut self, x: Vec<DamageInfo>) {
self.damage_info = x[0];
}
}
}

0 comments on commit 2609723

Please sign in to comment.