Skip to content

Commit

Permalink
Fix merge patch generation for unlockables and repository
Browse files Browse the repository at this point in the history
  • Loading branch information
atampy25 committed Aug 6, 2024
1 parent 5063375 commit 0c5ead2
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 137 deletions.
6 changes: 3 additions & 3 deletions src-tauri/src/editor_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use anyhow::{anyhow, Context, Error, Result};
use debounced::debounced;
use fn_error_context::context;
use futures_util::{stream::SplitSink, SinkExt, StreamExt};
use hitman_commons::metadata::ResourceID;
use hitman_commons::metadata::RuntimeID;
use indexmap::IndexMap;
use quickentity_rs::{
convert_qn_property_value_to_rt, convert_rt_property_value_to_qn,
Expand Down Expand Up @@ -831,7 +831,7 @@ impl EditorConnection {
}) => json!({
"id": entity_ref,
"source": "game",
"tblu": ResourceID::from_any(&scene)?.to_string()
"tblu": RuntimeID::from_any(&scene)?.to_string()
}),

Ref::Short(Some(entity_id)) => json!({
Expand Down Expand Up @@ -867,7 +867,7 @@ impl EditorConnection {
}) => Some(json!({
"id": entity_ref,
"source": "game",
"tblu": ResourceID::from_any(&scene)?.to_string()
"tblu": RuntimeID::from_any(&scene)?.to_string()
})),

Ref::Short(Some(entity_id)) => Some(json!({
Expand Down
63 changes: 27 additions & 36 deletions src-tauri/src/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use fn_error_context::context;
use hashbrown::HashMap;
use hitman_commons::game::GameVersion;
use hitman_commons::hash_list::HashList;
use hitman_commons::metadata::{ResourceID, ResourceType};
use hitman_commons::metadata::{ResourceType, RuntimeID};
use hitman_commons::rpkg_tool::RpkgResourceMeta;
use indexmap::IndexMap;
use itertools::Itertools;
Expand Down Expand Up @@ -573,7 +573,7 @@ pub fn check_local_references_exist(sub_entity: &SubEntity, entity: &Entity) ->

pub fn get_ref_decoration(
game_files: &PartitionManager,
cached_entities: &DashMap<ResourceID, Entity>,
cached_entities: &DashMap<RuntimeID, Entity>,
game_version: GameVersion,
hash_list: &HashList,
entity: &Entity,
Expand All @@ -591,7 +591,7 @@ pub fn get_ref_decoration(
cached_entities,
game_version,
hash_list,
ResourceID::from_any(reference.external_scene.as_ref().expect("Not a local reference")).ok()?
RuntimeID::from_any(reference.external_scene.as_ref().expect("Not a local reference")).ok()?
)
.ok()?
.entities
Expand All @@ -611,7 +611,7 @@ pub fn get_line_decoration(
game_files: &PartitionManager,
game_version: GameVersion,
tonytools_hash_list: &tonytools::hashlist::HashList,
line: ResourceID
line: RuntimeID
) -> Result<Option<String>> {
let (res_meta, res_data) = extract_latest_resource(game_files, line)?;

Expand Down Expand Up @@ -689,7 +689,7 @@ pub fn get_line_decoration(
#[context("Couldn't get decorations for sub-entity {}", sub_entity.name)]
pub fn get_decorations(
game_files: &PartitionManager,
cached_entities: &DashMap<ResourceID, Entity>,
cached_entities: &DashMap<RuntimeID, Entity>,
repository: &[RepositoryItem],
hash_list: &HashList,
game_version: GameVersion,
Expand All @@ -712,15 +712,15 @@ pub fn get_decorations(

// Hint decoration for unknown paths
if sub_entity.factory.starts_with('0') {
if let Some(entry) = hash_list.entries.get(&ResourceID::from_str(&sub_entity.factory)?) {
if let Some(entry) = hash_list.entries.get(&RuntimeID::from_str(&sub_entity.factory)?) {
if let Some(hint) = entry.hint.as_ref() {
decorations.push((sub_entity.factory.to_owned(), hint.to_owned()));
}
}
}

if sub_entity.blueprint.starts_with('0') {
if let Some(entry) = hash_list.entries.get(&ResourceID::from_str(&sub_entity.blueprint)?) {
if let Some(entry) = hash_list.entries.get(&RuntimeID::from_str(&sub_entity.blueprint)?) {
if let Some(hint) = entry.hint.as_ref() {
decorations.push((sub_entity.blueprint.to_owned(), hint.to_owned()));
}
Expand Down Expand Up @@ -783,19 +783,16 @@ pub fn get_decorations(
property_data.value.as_str().unwrap_or_default()
};

if let Some(entry) = hash_list.entries.get(&ResourceID::from_any(res)?)
if let Some(entry) = hash_list.entries.get(&RuntimeID::from_any(res)?)
&& entry.resource_type == "LINE"
{
if let Some(decoration) = get_line_decoration(
game_files,
game_version,
tonytools_hash_list,
ResourceID::from_any(res)?
)? {
if let Some(decoration) =
get_line_decoration(game_files, game_version, tonytools_hash_list, RuntimeID::from_any(res)?)?
{
decorations.push((res.to_owned(), decoration));
}
} else if res.starts_with('0') {
if let Some(entry) = hash_list.entries.get(&ResourceID::from_str(res)?) {
if let Some(entry) = hash_list.entries.get(&RuntimeID::from_str(res)?) {
if let Some(hint) = entry.hint.as_ref() {
decorations.push((res.to_owned(), hint.to_owned()));
}
Expand All @@ -814,19 +811,16 @@ pub fn get_decorations(
val.as_str().unwrap_or_default()
};

if let Some(entry) = hash_list.entries.get(&ResourceID::from_any(res)?)
if let Some(entry) = hash_list.entries.get(&RuntimeID::from_any(res)?)
&& entry.resource_type == "LINE"
{
if let Some(decoration) = get_line_decoration(
game_files,
game_version,
tonytools_hash_list,
ResourceID::from_any(res)?
)? {
if let Some(decoration) =
get_line_decoration(game_files, game_version, tonytools_hash_list, RuntimeID::from_any(res)?)?
{
decorations.push((res.to_owned(), decoration));
}
} else if res.starts_with('0') {
if let Some(entry) = hash_list.entries.get(&ResourceID::from_str(res)?) {
if let Some(entry) = hash_list.entries.get(&RuntimeID::from_str(res)?) {
if let Some(hint) = entry.hint.as_ref() {
decorations.push((res.to_owned(), hint.to_owned()));
}
Expand Down Expand Up @@ -898,19 +892,16 @@ pub fn get_decorations(
property_data.value.as_str().unwrap_or_default()
};

if let Some(entry) = hash_list.entries.get(&ResourceID::from_any(res)?)
if let Some(entry) = hash_list.entries.get(&RuntimeID::from_any(res)?)
&& entry.resource_type == "LINE"
{
if let Some(decoration) = get_line_decoration(
game_files,
game_version,
tonytools_hash_list,
ResourceID::from_any(res)?
)? {
if let Some(decoration) =
get_line_decoration(game_files, game_version, tonytools_hash_list, RuntimeID::from_any(res)?)?
{
decorations.push((res.to_owned(), decoration));
}
} else if res.starts_with('0') {
if let Some(entry) = hash_list.entries.get(&ResourceID::from_str(res)?) {
if let Some(entry) = hash_list.entries.get(&RuntimeID::from_str(res)?) {
if let Some(hint) = entry.hint.as_ref() {
decorations.push((res.to_owned(), hint.to_owned()));
}
Expand All @@ -929,19 +920,19 @@ pub fn get_decorations(
val.as_str().unwrap_or_default()
};

if let Some(entry) = hash_list.entries.get(&ResourceID::from_any(res)?)
if let Some(entry) = hash_list.entries.get(&RuntimeID::from_any(res)?)
&& entry.resource_type == "LINE"
{
if let Some(decoration) = get_line_decoration(
game_files,
game_version,
tonytools_hash_list,
ResourceID::from_any(res)?
RuntimeID::from_any(res)?
)? {
decorations.push((res.to_owned(), decoration));
}
} else if res.starts_with('0') {
if let Some(entry) = hash_list.entries.get(&ResourceID::from_str(res)?) {
if let Some(entry) = hash_list.entries.get(&RuntimeID::from_str(res)?) {
if let Some(hint) = entry.hint.as_ref() {
decorations.push((res.to_owned(), hint.to_owned()));
}
Expand Down Expand Up @@ -1083,11 +1074,11 @@ pub fn get_decorations(

if hash_list
.entries
.get(&ResourceID::from_any(&sub_entity.factory)?)
.get(&RuntimeID::from_any(&sub_entity.factory)?)
.map(|entry| entry.resource_type == "MATT")
.unwrap_or(false)
{
if let Some(mati) = extract_latest_metadata(game_files, ResourceID::from_any(&sub_entity.factory)?)?
if let Some(mati) = extract_latest_metadata(game_files, RuntimeID::from_any(&sub_entity.factory)?)?
.core_info
.references
.into_iter()
Expand Down
8 changes: 4 additions & 4 deletions src-tauri/src/event_handling/content_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::{anyhow, Context, Result};
use arc_swap::ArcSwap;
use fn_error_context::context;
use hashbrown::{HashMap, HashSet};
use hitman_commons::{game::GameVersion, metadata::ResourceID, rpkg_tool::RpkgResourceMeta};
use hitman_commons::{game::GameVersion, metadata::RuntimeID, rpkg_tool::RpkgResourceMeta};
use hitman_formats::ores::{parse_hashes_ores, parse_json_ores};
use itertools::Itertools;
use quickentity_rs::convert_to_qn;
Expand Down Expand Up @@ -465,7 +465,7 @@ pub fn start_content_search(

let (locr_meta, locr_data) = extract_latest_resource(
game_files,
ResourceID::from_str(&res_meta.hash_reference_data.first()?.hash).ok()?
RuntimeID::from_str(&res_meta.hash_reference_data.first()?.hash).ok()?
)
.ok()?;

Expand Down Expand Up @@ -598,13 +598,13 @@ pub fn start_content_search(
.map(|hash| {
let filetype = hash_list
.entries
.get(&ResourceID::from_str(&hash).expect("Invalid ID added to matching array"))
.get(&RuntimeID::from_str(&hash).expect("Invalid ID added to matching array"))
.map(|x| x.resource_type.into())
.unwrap_or("".into());

let path = hash_list
.entries
.get(&ResourceID::from_str(&hash).expect("Invalid ID added to matching array"))
.get(&RuntimeID::from_str(&hash).expect("Invalid ID added to matching array"))
.and_then(|x| x.path.as_ref().or(x.hint.as_ref()).cloned());

(hash, filetype, path)
Expand Down
10 changes: 5 additions & 5 deletions src-tauri/src/event_handling/entity/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fs;

use anyhow::{anyhow, Context, Result};
use fn_error_context::context;
use hitman_commons::metadata::ResourceID;
use hitman_commons::metadata::RuntimeID;
use serde_json::to_vec;
use tauri::{AppHandle, Manager};
use tauri_plugin_aptabase::EventTracker;
Expand Down Expand Up @@ -81,7 +81,7 @@ pub async fn handle(app: &AppHandle, event: EntityMetadataEvent) -> Result<()> {
} => {
let mut is_patch_editor = false;

if factory_hash != ResourceID::from_any(&factory_hash)?.to_string() {
if factory_hash != RuntimeID::from_any(&factory_hash)?.to_string() {
if let Some(project) = app_state.project.load().as_ref() {
let mut settings = (*project.settings.load_full()).to_owned();
settings.custom_paths.push(factory_hash.to_owned());
Expand Down Expand Up @@ -118,7 +118,7 @@ pub async fn handle(app: &AppHandle, event: EntityMetadataEvent) -> Result<()> {
)?;
}

factory_hash = ResourceID::from_any(&factory_hash)?.to_string();
factory_hash = RuntimeID::from_any(&factory_hash)?.to_string();

send_request(
app,
Expand Down Expand Up @@ -190,7 +190,7 @@ pub async fn handle(app: &AppHandle, event: EntityMetadataEvent) -> Result<()> {
} => {
let mut is_patch_editor = false;

if blueprint_hash != ResourceID::from_any(&blueprint_hash)?.to_string() {
if blueprint_hash != RuntimeID::from_any(&blueprint_hash)?.to_string() {
if let Some(project) = app_state.project.load().as_ref() {
let mut settings = (*project.settings.load_full()).to_owned();
settings.custom_paths.push(blueprint_hash.to_owned());
Expand Down Expand Up @@ -227,7 +227,7 @@ pub async fn handle(app: &AppHandle, event: EntityMetadataEvent) -> Result<()> {
)?;
}

blueprint_hash = ResourceID::from_any(&blueprint_hash)?.to_string();
blueprint_hash = RuntimeID::from_any(&blueprint_hash)?.to_string();

send_request(
app,
Expand Down
10 changes: 5 additions & 5 deletions src-tauri/src/event_handling/entity/monaco.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{anyhow, Context, Result};
use arc_swap::ArcSwap;
use fn_error_context::context;
use hashbrown::HashSet;
use hitman_commons::metadata::ResourceID;
use hitman_commons::metadata::RuntimeID;
use log::debug;
use quickentity_rs::qn_structs::Ref;

Expand Down Expand Up @@ -131,7 +131,7 @@ pub async fn handle(app: &AppHandle, event: EntityMonacoEvent) -> Result<()> {

EntityMonacoEvent::OpenResourceOverview { resource, .. } => {
if let Some(resource_reverse_dependencies) = app_state.resource_reverse_dependencies.load().as_ref() {
let resource = ResourceID::from_any(&resource)?;
let resource = RuntimeID::from_any(&resource)?;

if resource_reverse_dependencies.contains_key(&resource) {
let id = Uuid::new_v4();
Expand Down Expand Up @@ -205,7 +205,7 @@ pub async fn update_content(app: &AppHandle, editor_id: Uuid, entity_id: String,

if sub_entity != previous {
if let Some(hash_list) = app_state.hash_list.load().as_ref() {
if let Some(entry) = hash_list.entries.get(&ResourceID::from_any(&sub_entity.factory)?) {
if let Some(entry) = hash_list.entries.get(&RuntimeID::from_any(&sub_entity.factory)?) {
if !is_valid_entity_factory(entry.resource_type) {
send_request(
app,
Expand All @@ -223,7 +223,7 @@ pub async fn update_content(app: &AppHandle, editor_id: Uuid, entity_id: String,
}
}

if let Some(entry) = hash_list.entries.get(&ResourceID::from_any(&sub_entity.blueprint)?) {
if let Some(entry) = hash_list.entries.get(&RuntimeID::from_any(&sub_entity.blueprint)?) {
if !is_valid_entity_blueprint(entry.resource_type) {
send_request(
app,
Expand Down Expand Up @@ -498,7 +498,7 @@ pub async fn open_factory(app: &AppHandle, factory: String) -> Result<()> {
&& let Some(hash_list) = app_state.hash_list.load().as_ref()
&& let Some(game_files) = app_state.game_files.load().as_deref()
{
let factory = ResourceID::from_any(&factory)?;
let factory = RuntimeID::from_any(&factory)?;

if let Ok((filetype, _, _)) = extract_latest_overview_info(game_files, factory) {
if filetype == "TEMP" {
Expand Down
8 changes: 4 additions & 4 deletions src-tauri/src/event_handling/entity/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use arboard::Clipboard;
use arc_swap::ArcSwap;
use fn_error_context::context;
use hashbrown::{HashMap, HashSet};
use hitman_commons::{game::GameVersion, metadata::ResourceID};
use hitman_commons::{game::GameVersion, metadata::RuntimeID};
use hitman_formats::wwev::WwiseEvent;
use indexmap::IndexMap;
use itertools::Itertools;
Expand Down Expand Up @@ -1658,7 +1658,7 @@ pub async fn help_menu(app: &AppHandle, editor_id: Uuid, entity_id: String) -> R

let (properties, pins) = if hash_list
.entries
.get(&ResourceID::from_any(&sub_entity.factory)?)
.get(&RuntimeID::from_any(&sub_entity.factory)?)
.map(|entry| entry.resource_type == "TEMP")
.unwrap_or(false)
{
Expand All @@ -1667,7 +1667,7 @@ pub async fn help_menu(app: &AppHandle, editor_id: Uuid, entity_id: String) -> R
&app_state.cached_entities,
game_version,
hash_list,
ResourceID::from_any(&sub_entity.factory)?
RuntimeID::from_any(&sub_entity.factory)?
)?;

(
Expand Down Expand Up @@ -1775,7 +1775,7 @@ pub async fn add_game_browser_item(
app: &AppHandle,
editor_id: Uuid,
parent_id: String,
file: ResourceID
file: RuntimeID
) -> Result<()> {
let app_settings = app.state::<ArcSwap<AppSettings>>();
let app_state = app.state::<AppState>();
Expand Down
Loading

0 comments on commit 0c5ead2

Please sign in to comment.