mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-04-24 07:16:48 -05:00
Added RenameImages project to deal with file naming convention from pokesprite.
This commit is contained in:
parent
403546ce9a
commit
6c4101aedb
11
RenameImages/App.config
Normal file
11
RenameImages/App.config
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<connectionStrings>
|
||||
<add name="pkmnFoundationsConnectionString"
|
||||
connectionString="Server=localhost;Database=gts;User ID=gts;Password=gts;Pooling=true;charset=utf8;Allow User Variables=True"
|
||||
providerName="MySql.Data.MySqlClient" />
|
||||
</connectionStrings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
|
||||
</startup>
|
||||
</configuration>
|
||||
109
RenameImages/Program.cs
Normal file
109
RenameImages/Program.cs
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
using PkmnFoundations.Data;
|
||||
using PkmnFoundations.Pokedex;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace RenameImages
|
||||
{
|
||||
/// <summary>
|
||||
/// Renames images obtained from Pokesprite. https://github.com/msikma/pokesprite
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
string path;
|
||||
char slash = Path.DirectorySeparatorChar;
|
||||
ConnectionStringSettings css;
|
||||
|
||||
if (args.Length < 1) path = "." + slash + "pkmn-sm";
|
||||
else path = args[0];
|
||||
|
||||
if (path.Contains('?'))
|
||||
{
|
||||
Console.WriteLine("h e l p");
|
||||
return;
|
||||
}
|
||||
|
||||
while (path.Length > 0 && (path[path.Length - 1] == '/' || path[path.Length - 1] == '\\'))
|
||||
{
|
||||
path = path.Substring(0, path.Length - 1);
|
||||
}
|
||||
path = path + slash;
|
||||
|
||||
if (args.Length < 3)
|
||||
css = ConfigurationManager.ConnectionStrings["pkmnFoundationsConnectionString"];
|
||||
else
|
||||
css = new ConnectionStringSettings("", args[1], args[2]);
|
||||
|
||||
Database db = Database.CreateInstance(css);
|
||||
Pokedex pokedex = new Pokedex(db, false);
|
||||
|
||||
foreach (var pair in pokedex.Forms)
|
||||
{
|
||||
Form form = pair.Value;
|
||||
Species species = form.Species;
|
||||
StringBuilder speciesNameBuilder = new StringBuilder(species.Name["EN"].ToLowerInvariant());
|
||||
speciesNameBuilder.Replace("\'", "");
|
||||
speciesNameBuilder.Replace(".", "");
|
||||
speciesNameBuilder.Replace("♀", "-f");
|
||||
speciesNameBuilder.Replace("♂", "-m");
|
||||
speciesNameBuilder.Replace('é', 'e');
|
||||
speciesNameBuilder.Replace(' ', '-');
|
||||
string speciesName = speciesNameBuilder.ToString();
|
||||
|
||||
// xxx: This is incorrect for Vivillon, Pumpkaboo, and Gourgeist, because their suffixless form is not form 0.
|
||||
string oldFilename = (form.Value == 0)
|
||||
? String.Format("{0}.png", speciesName)
|
||||
: String.Format("{0}-{1}.png", speciesName, form.Suffix);
|
||||
|
||||
string newFilename = (form.Suffix.Trim().Length == 0)
|
||||
? String.Format("{0}.png", species.NationalDex)
|
||||
: String.Format("{0}-{1}.png", species.NationalDex, form.Suffix);
|
||||
|
||||
try
|
||||
{
|
||||
File.Move(path + oldFilename, path + newFilename);
|
||||
Console.Write("{0} {1}", oldFilename, newFilename);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Write(ex.Message);
|
||||
}
|
||||
|
||||
if (form.Value == 0 && form.Suffix.Trim().Length != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
string speciesFilename = String.Format("{0}.png", species.NationalDex);
|
||||
File.Copy(path + newFilename, path + speciesFilename);
|
||||
Console.Write(" {0}", speciesFilename);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.Write(ex.Message);
|
||||
}
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
private static string NormalizeFilename(string filename, string path)
|
||||
{
|
||||
if (filename.Length >= path.Length)
|
||||
{
|
||||
string pathPart = filename.Substring(0, path.Length);
|
||||
if (pathPart == path) filename = filename.Substring(path.Length);
|
||||
}
|
||||
return filename.ToLowerInvariant().Trim();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
36
RenameImages/Properties/AssemblyInfo.cs
Normal file
36
RenameImages/Properties/AssemblyInfo.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("RenameImages")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("RenameImages")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("d8787475-2d21-4e60-9320-13fa55c979ac")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
58
RenameImages/RenameImages.csproj
Normal file
58
RenameImages/RenameImages.csproj
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{D8787475-2D21-4E60-9320-13FA55C979AC}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>RenameImages</RootNamespace>
|
||||
<AssemblyName>RenameImages</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\library\Library.csproj">
|
||||
<Project>{408efc7e-c6b0-4160-8628-2679e34385ce}</Project>
|
||||
<Name>Library</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32126.315
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library", "library\Library.csproj", "{408EFC7E-C6B0-4160-8628-2679E34385CE}"
|
||||
EndProject
|
||||
|
|
@ -27,6 +27,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MakeBaseStatTables", "MakeB
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "web", "web\web.csproj", "{3DE4D97F-57A8-4324-B5B8-164B45E2DF9A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenameImages", "RenameImages\RenameImages.csproj", "{D8787475-2D21-4E60-9320-13FA55C979AC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -157,8 +159,23 @@ Global
|
|||
{3DE4D97F-57A8-4324-B5B8-164B45E2DF9A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{3DE4D97F-57A8-4324-B5B8-164B45E2DF9A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{3DE4D97F-57A8-4324-B5B8-164B45E2DF9A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{D8787475-2D21-4E60-9320-13FA55C979AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D8787475-2D21-4E60-9320-13FA55C979AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D8787475-2D21-4E60-9320-13FA55C979AC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{D8787475-2D21-4E60-9320-13FA55C979AC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{D8787475-2D21-4E60-9320-13FA55C979AC}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{D8787475-2D21-4E60-9320-13FA55C979AC}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{D8787475-2D21-4E60-9320-13FA55C979AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D8787475-2D21-4E60-9320-13FA55C979AC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D8787475-2D21-4E60-9320-13FA55C979AC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{D8787475-2D21-4E60-9320-13FA55C979AC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{D8787475-2D21-4E60-9320-13FA55C979AC}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{D8787475-2D21-4E60-9320-13FA55C979AC}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {B86878C4-9F17-469B-B51C-4CB1030489AA}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user