Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
andanteyk committed May 7, 2017
2 parents 589a238 + 2fb74bd commit df61bf5
Show file tree
Hide file tree
Showing 15 changed files with 340 additions and 162 deletions.
87 changes: 57 additions & 30 deletions ElectronicObserver/Data/ShipDataMaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -564,36 +565,6 @@ public bool IsAbyssalShip {
get { return ShipID > 1500; }
}

/// <summary>
/// 深海棲艦のクラス
/// 0=その他, 1=通常, 2=elite, 3=flagship, 4=改flagship|後期型, 5=後期型elite, 6=後期型flagship
/// </summary>
public int AbyssalShipClass {
get {
if ( !IsAbyssalShip )
return 0;

else if ( Name.Contains( "後期型" ) ) {
if ( NameReading == "flagship" )
return 6;
else if ( NameReading == "elite" )
return 5;
else
return 4;

} else if ( Name.Contains( "改" ) && NameReading == "flagship" )
return 4;
else if ( NameReading == "flagship" )
return 3;
else if ( NameReading == "elite" )
return 2;
else if ( NameReading == "" ||
NameReading == "-" )
return 1;
else
return 0;
}
}

/// <summary>
/// クラスも含めた艦名
Expand Down Expand Up @@ -651,6 +622,62 @@ private ShipParameterRecord.ShipParameterElement GetParameterElement() {



private static readonly Color[] ShipNameColors = new Color[] {
Color.FromArgb( 0x00, 0x00, 0x00 ),
Color.FromArgb( 0xFF, 0x00, 0x00 ),
Color.FromArgb( 0xFF, 0x88, 0x00 ),
Color.FromArgb( 0x00, 0x66, 0x00 ),
Color.FromArgb( 0x88, 0x00, 0x00 ),
Color.FromArgb( 0x00, 0x88, 0xFF ),
Color.FromArgb( 0x00, 0x00, 0xFF ),
};

public Color GetShipNameColor() {

if ( !IsAbyssalShip ) {
return SystemColors.ControlText;
}

bool isLateModel = Name.Contains( "後期型" );
bool isRemodeled = Name.Contains( "改" );
bool isDestroyed = Name.EndsWith( "-壊" );
bool isDemon = Name.EndsWith( "鬼" );
bool isPrincess = Name.EndsWith( "姫" );
bool isWaterDemon = Name.EndsWith( "水鬼" );
bool isWaterPrincess = Name.EndsWith( "水姫" );
bool isElite = NameReading == "elite";
bool isFlagship = NameReading == "flagship";


if ( isDestroyed )
return Color.FromArgb( 0xFF, 0x00, 0xFF );

else if ( isWaterPrincess )
return ShipNameColors[6];
else if ( isWaterDemon )
return ShipNameColors[5];
else if ( isPrincess )
return ShipNameColors[4];
else if ( isDemon )
return ShipNameColors[3];
else {

int tier;

if ( isFlagship )
tier = 2;
else if ( isElite )
tier = 1;
else
tier = 0;

if ( isLateModel || isRemodeled )
tier += 3;

return ShipNameColors[tier];
}
}


public ShipDataMaster() {
RemodelBeforeShipID = 0;
Expand Down
1 change: 1 addition & 0 deletions ElectronicObserver/ElectronicObserver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
<Compile Include="Observer\kcsapi\api_req_sortie\airbattle.cs" />
<Compile Include="Observer\kcsapi\api_req_sortie\ld_airbattle.cs" />
<Compile Include="Resource\Record\ResourceRecord.cs" />
<Compile Include="Resource\SwfHelper.cs" />
<Compile Include="Utility\Data\RecordHash.cs" />
<Compile Include="Utility\FleetImageGenerator.cs" />
<Compile Include="Utility\SyncBGMPlayer.cs" />
Expand Down
2 changes: 1 addition & 1 deletion ElectronicObserver/Other/Information/apilist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ api_start2 :艦娘・装備固有データその他
api_id :カテゴリID(艦船のstypeに対応)
api_sortno :並べ替え順
api_name :艦種名(英語は図鑑内での表示)
1=海防艦 Escort Ship
1=海防艦 Escort
2=駆逐艦 Destroyer
3=軽巡洋艦 Light Cruiser
4=重雷装巡洋艦 Torpedo Cruiser
Expand Down
101 changes: 101 additions & 0 deletions ElectronicObserver/Resource/SwfHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using SwfExtractor;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ElectronicObserver.Resource {


public static class SwfHelper {

// 各種画像リソースのサイズ
public static readonly Size ShipBannerSize = new Size( 160, 40 );
public static readonly Size ShipCardSize = new Size( 218, 300 );
public static readonly Size ShipCutinSize = new Size( 665, 121 );
public static readonly Size ShipNameSize = new Size( 436, 63 );
public static readonly Size ShipSupplySize = new Size( 474, 47 );

/// <summary>
/// 各種画像リソースの CharacterID
/// </summary>
public enum ShipResourceCharacterID {
BannerNormal = 1,
BannerDamaged = 3,
CardNormal = 5,
CardDamaged = 7,
CutinNormal = 21,
CutinDamaged = 23,
Name = 25,
SupplyNormal = 27,
SupplyDamaged = 29,
}


/// <summary>
/// 現在使用可能な画像リソースファイルへのパスを取得します。
/// </summary>
public static string GetResourcePath( string relativePath, string resourceName ) {
return Directory.GetFiles( Utility.Configuration.Config.Connection.SaveDataPath + @"\" + relativePath, "*.swf", System.IO.SearchOption.TopDirectoryOnly )
.Where( path => path.Contains( resourceName ) ).LastOrDefault();
}

/// <summary>
/// 現在使用可能な艦船画像リソースファイルへのパスを取得します。
/// </summary>
public static string GetShipResourcePath( string resourceName ) {
return GetResourcePath( @"resources\swf\ships\", resourceName );
}


/// <summary>
/// 艦船画像リソースファイルが存在するかを調べます。
/// </summary>
public static bool HasShipSwfImage( string resourceName ) {
return GetShipResourcePath( resourceName ) != null;
}


/// <summary>
/// 艦船画像を swf ファイルから読み込みます。
/// </summary>
/// <param name="resourceName">艦船のリソース名(ファイル名)。</param>
/// <param name="characterID">描画する画像の CharacterID 。</param>
/// <returns>成功した場合は対象の Bitmap オブジェクト、失敗した場合は null を返します。</returns>
public static Bitmap GetShipSwfImage( string resourceName, int characterID ) {
try {

string shipSwfPath = GetShipResourcePath( resourceName );

if ( shipSwfPath != null ) {

var shipSwf = new SwfParser();
shipSwf.Parse( shipSwfPath );

var imgtag = shipSwf.FindTags<SwfExtractor.Tags.ImageTag>().FirstOrDefault( t => t.CharacterID == characterID );
return imgtag.ExtractImage();
}

return null;
} catch ( Exception ) {
return null;
}
}

/// <summary>
/// 艦船画像を swf ファイルから読み込みます。
/// </summary>
/// <param name="resourceName">艦船のリソース名(ファイル名)。</param>
/// <param name="characterID">描画する画像の CharacterID 。</param>
/// <returns>成功した場合は対象の Bitmap オブジェクト、失敗した場合は null を返します。</returns>
public static Bitmap GetShipSwfImage( string resourceName, ShipResourceCharacterID characterID ) {
return GetShipSwfImage( resourceName, (int)characterID );
}


}

}
1 change: 1 addition & 0 deletions ElectronicObserver/Utility/Data/Calculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,7 @@ public static bool IsAircraft( int equipmentID, bool containsRecon, bool contain
public static bool CanAttackSubmarine( ShipData ship ) {

switch ( ship.MasterShip.ShipType ) {
case 1: //海防
case 2: //駆逐
case 3: //軽巡
case 4: //雷巡
Expand Down
Loading

0 comments on commit df61bf5

Please sign in to comment.