mirror of
https://git.femboyfinancial.jp/james/lipsync.git
synced 2024-12-03 14:42:00 -08:00
152 lines
4.9 KiB
Java
152 lines
4.9 KiB
Java
|
/*
|
|||
|
* VsqMetaText/Common.cs
|
|||
|
* Copyright (c) 2008 kbinani
|
|||
|
*
|
|||
|
* This file is part of Boare.Lib.Vsq.
|
|||
|
*
|
|||
|
* Boare.Lib.Vsq is free software; you can redistribute it and/or
|
|||
|
* modify it under the terms of the BSD License.
|
|||
|
*
|
|||
|
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
|
|||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|||
|
*/
|
|||
|
/*using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Text;
|
|||
|
using System.IO;
|
|||
|
using System.Drawing;*/
|
|||
|
|
|||
|
package com.boare.vsq;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// vsq<73>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̃<EFBFBD><CC83>^<5E>e<EFBFBD>L<EFBFBD>X<EFBFBD>g<EFBFBD><67>[Common]<5D>Z<EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ɋL<C98B>^<5E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>e<EFBFBD><65><EFBFBD><EFBFBD><EFBFBD>舵<EFBFBD><E888B5>
|
|||
|
/// </summary>
|
|||
|
public class VsqCommon implements Cloneable {
|
|||
|
public String Version;
|
|||
|
public String Name;
|
|||
|
public String Color;
|
|||
|
public int DynamicsMode;
|
|||
|
public int PlayMode;
|
|||
|
|
|||
|
public Object clone() {
|
|||
|
String[] spl = Color.Split( ",".ToCharArray(), 3 );
|
|||
|
int r = Integer.parseInt( spl[0] );
|
|||
|
int g = Integer.parseInt( spl[1] );
|
|||
|
int b = Integer.parseInt( spl[2] );
|
|||
|
System.Drawing.Color color = System.Drawing.Color.FromArgb( r, g, b );
|
|||
|
VsqCommon res = new VsqCommon( Name, color, DynamicsMode, PlayMode );
|
|||
|
res.Version = Version;
|
|||
|
return res;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20>e<EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>[<5B>^<5E><><EFBFBD>w<EFBFBD>肵<EFBFBD><E882B5><EFBFBD>R<EFBFBD><52><EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD>N<EFBFBD>^
|
|||
|
/// </summary>
|
|||
|
/// <param name="name"><3E>g<EFBFBD><67><EFBFBD>b<EFBFBD>N<EFBFBD><4E></param>
|
|||
|
/// <param name="color">Color<6F>l<EFBFBD>i<EFBFBD>Ӗ<EFBFBD><D396>͕s<CD95><73><EFBFBD>j</param>
|
|||
|
/// <param name="dynamics_mode">DynamicsMode<64>i<EFBFBD>f<EFBFBD>t<EFBFBD>H<EFBFBD><48><EFBFBD>g<EFBFBD><67>1<EFBFBD>j</param>
|
|||
|
/// <param name="play_mode">PlayMode<64>i<EFBFBD>f<EFBFBD>t<EFBFBD>H<EFBFBD><48><EFBFBD>g<EFBFBD><67>1<EFBFBD>j</param>
|
|||
|
public VsqCommon( string name, Color color, int dynamics_mode, int play_mode ) {
|
|||
|
this.Version = "DSB301";
|
|||
|
this.Name = name;
|
|||
|
this.Color = color.R + "," + color.G + "," + color.B;
|
|||
|
this.DynamicsMode = dynamics_mode;
|
|||
|
this.PlayMode = play_mode;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// MetaText<78>̃e<CC83>L<EFBFBD>X<EFBFBD>g<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̃R<CC83><52><EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD>N<EFBFBD>^
|
|||
|
/// </summary>
|
|||
|
/// <param name="sr"><3E>ǂݍ<C782><DD8D>ރe<DE83>L<EFBFBD>X<EFBFBD>g<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43></param>
|
|||
|
/// <param name="last_line"><3E>ǂݍ<C782><DD8D>Ō<F182BE8D><C58C>̍s<CC8D><73><EFBFBD>Ԃ<EFBFBD><D482><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
public VsqCommon( TextMemoryStream sr, ref string last_line ) {
|
|||
|
Version = "";
|
|||
|
Name = "";
|
|||
|
Color = "0,0,0";
|
|||
|
DynamicsMode = 0;
|
|||
|
PlayMode = 0;
|
|||
|
last_line = sr.ReadLine();
|
|||
|
string[] spl;
|
|||
|
while ( !last_line.StartsWith( "[" ) ) {
|
|||
|
spl = last_line.Split( new char[] { '=' } );
|
|||
|
switch ( spl[0] ) {
|
|||
|
case "Version":
|
|||
|
this.Version = spl[1];
|
|||
|
break;
|
|||
|
case "Name":
|
|||
|
this.Name = spl[1];
|
|||
|
break;
|
|||
|
case "Color":
|
|||
|
this.Color = spl[1];
|
|||
|
break;
|
|||
|
case "DynamicsMode":
|
|||
|
this.DynamicsMode = Integer.parseInt( spl[1] );
|
|||
|
break;
|
|||
|
case "PlayMode":
|
|||
|
this.PlayMode = Integer.parseInt( spl[1] );
|
|||
|
break;
|
|||
|
}
|
|||
|
if ( sr.Peek() < 0 ) {
|
|||
|
break;
|
|||
|
}
|
|||
|
last_line = sr.ReadLine();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20>C<EFBFBD><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD>̓<EFBFBD><CC93>e<EFBFBD><65><EFBFBD>e<EFBFBD>L<EFBFBD>X<EFBFBD>g<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>ɏo<C98F>͂<EFBFBD><CD82>܂<EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <param name="sw"><3E>o<EFBFBD>͐<EFBFBD></param>
|
|||
|
public void write( TextMemoryStream sw ) {
|
|||
|
sw.WriteLine( "[Common]" );
|
|||
|
sw.WriteLine( "Version=" + Version );
|
|||
|
sw.WriteLine( "Name=" + Name );
|
|||
|
sw.WriteLine( "Color=" + Color );
|
|||
|
sw.WriteLine( "DynamicsMode=" + DynamicsMode );
|
|||
|
sw.WriteLine( "PlayMode=" + PlayMode );
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// VsqCommon<6F>\<5C><><EFBFBD>̂<EFBFBD><CC82>\<5C>z<EFBFBD><7A><EFBFBD><EFBFBD><EFBFBD>e<EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD>s<EFBFBD><73><EFBFBD>܂<EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <returns><3E>e<EFBFBD>X<EFBFBD>g<EFBFBD>ɐ<EFBFBD><C990><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>true<75>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD>łȂ<C582><C882><EFBFBD><EFBFBD><EFBFBD>false</returns>
|
|||
|
public static bool test() {
|
|||
|
string fpath = Path.GetTempFileName();
|
|||
|
StreamWriter sw = new StreamWriter( fpath, false, Encoding.Unicode );
|
|||
|
sw.WriteLine( "Version=DSB301" );
|
|||
|
sw.WriteLine( "Name=Voice1" );
|
|||
|
sw.WriteLine( "Color=181,162,123" );
|
|||
|
sw.WriteLine( "DynamicsMode=1" );
|
|||
|
sw.WriteLine( "PlayMode=1" );
|
|||
|
sw.WriteLine( "[Master]" );
|
|||
|
sw.Close();
|
|||
|
|
|||
|
VsqCommon vsqCommon;
|
|||
|
string last_line = "";
|
|||
|
using ( TextMemoryStream sr = new TextMemoryStream( fpath, Encoding.Unicode ) ) {
|
|||
|
vsqCommon = new VsqCommon( sr, ref last_line );
|
|||
|
}
|
|||
|
|
|||
|
bool result;
|
|||
|
if ( vsqCommon.Version == "DSB301" &&
|
|||
|
vsqCommon.Name == "Voice1" &&
|
|||
|
vsqCommon.Color == "181,162,123" &&
|
|||
|
vsqCommon.DynamicsMode == 1 &&
|
|||
|
vsqCommon.PlayMode == 1 &&
|
|||
|
last_line == "[Master]" ) {
|
|||
|
result = true;
|
|||
|
} else {
|
|||
|
result = false;
|
|||
|
}
|
|||
|
|
|||
|
File.Delete( fpath );
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
}
|