mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
(GameRes): added resource aliases.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
//! \date Wed Sep 16 22:51:11 2015
|
//! \date Wed Sep 16 22:51:11 2015
|
||||||
//! \brief game resources formats catalog class.
|
//! \brief game resources formats catalog class.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2014-2015 by morkt
|
// Copyright (C) 2014-2018 by morkt
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to
|
// of this software and associated documentation files (the "Software"), to
|
||||||
@@ -106,10 +106,12 @@ namespace GameRes
|
|||||||
AddResourceImpl (m_arc_formats, container);
|
AddResourceImpl (m_arc_formats, container);
|
||||||
AddResourceImpl (m_audio_formats, container);
|
AddResourceImpl (m_audio_formats, container);
|
||||||
AddResourceImpl (m_script_formats, container);
|
AddResourceImpl (m_script_formats, container);
|
||||||
|
|
||||||
|
AddAliases (container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddResourceImpl (IEnumerable<IResource> formats, CompositionContainer container)
|
private void AddResourceImpl (IEnumerable<IResource> formats, ICompositionService container)
|
||||||
{
|
{
|
||||||
foreach (var impl in formats)
|
foreach (var impl in formats)
|
||||||
{
|
{
|
||||||
@@ -134,6 +136,35 @@ namespace GameRes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddAliases (ExportProvider provider)
|
||||||
|
{
|
||||||
|
foreach (var alias in provider.GetExports<ResourceAlias, IResourceAliasMetadata>())
|
||||||
|
{
|
||||||
|
var metadata = alias.Metadata;
|
||||||
|
IEnumerable<IResource> target_list;
|
||||||
|
if (string.IsNullOrEmpty (metadata.Type))
|
||||||
|
target_list = Formats;
|
||||||
|
else if ("archive" == metadata.Type)
|
||||||
|
target_list = ArcFormats;
|
||||||
|
else if ("image" == metadata.Type)
|
||||||
|
target_list = ImageFormats;
|
||||||
|
else if ("audio" == metadata.Type)
|
||||||
|
target_list = AudioFormats;
|
||||||
|
else if ("script" == metadata.Type)
|
||||||
|
target_list = ScriptFormats;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
var ext = metadata.Extension;
|
||||||
|
var target = metadata.Target;
|
||||||
|
if (!string.IsNullOrEmpty (ext) && !string.IsNullOrEmpty (target))
|
||||||
|
{
|
||||||
|
var target_res = target_list.FirstOrDefault (f => f.Tag == target);
|
||||||
|
if (target_res != null)
|
||||||
|
m_extension_map.Add (ext.ToUpperInvariant(), target_res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void UpgradeSettings ()
|
public void UpgradeSettings ()
|
||||||
{
|
{
|
||||||
if (Properties.Settings.Default.UpgradeRequired)
|
if (Properties.Settings.Default.UpgradeRequired)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
//! \date Mon Jun 30 20:12:13 2014
|
//! \date Mon Jun 30 20:12:13 2014
|
||||||
//! \brief game resources browser.
|
//! \brief game resources browser.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2014-2015 by morkt
|
// Copyright (C) 2014-2018 by morkt
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to
|
// of this software and associated documentation files (the "Software"), to
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using GameRes.Strings;
|
using GameRes.Strings;
|
||||||
|
|
||||||
namespace GameRes
|
namespace GameRes
|
||||||
@@ -179,6 +180,21 @@ namespace GameRes
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class ResourceAlias
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Link filename extension to specific resource.
|
||||||
|
/// </summary>
|
||||||
|
public interface IResourceAliasMetadata
|
||||||
|
{
|
||||||
|
string Extension { get; }
|
||||||
|
string Target { get; }
|
||||||
|
[DefaultValue(null)]
|
||||||
|
string Type { get; }
|
||||||
|
}
|
||||||
|
|
||||||
public delegate void ParametersRequestEventHandler (object sender, ParametersRequestEventArgs e);
|
public delegate void ParametersRequestEventHandler (object sender, ParametersRequestEventArgs e);
|
||||||
|
|
||||||
public class ParametersRequestEventArgs : EventArgs
|
public class ParametersRequestEventArgs : EventArgs
|
||||||
|
|||||||
Reference in New Issue
Block a user