1
0
mirror of synced 2024-11-23 23:21:06 +01:00
This commit is contained in:
0auBSQ 2024-07-26 21:39:38 +09:00
parent 756a9370b0
commit 6ca0743f50
11 changed files with 1178 additions and 1445 deletions

View File

@ -1,24 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Diagnostics;
using System.Drawing;
using SampleFramework;
using Silk.NET.Maths;
using Silk.NET.OpenGLES;
using SkiaSharp;
using Point = System.Drawing.Point;
using Rectangle = System.Drawing.Rectangle;
using RectangleF = System.Drawing.RectangleF;
using Point = System.Drawing.Point;
using Color = System.Drawing.Color;
using SampleFramework;
using Silk.NET.OpenGLES;
namespace FDK
{
public class CTexture : IDisposable
{
namespace FDK {
public class CTexture : IDisposable {
/// <summary>
/// バッファの集まり
/// </summary>
@ -76,8 +66,7 @@ namespace FDK
/// <summary>
/// 描画に使用する共通のバッファを作成
/// </summary>
public static void Init()
{
public static void Init() {
//シェーダーを作成、実際のコードはCreateShaderProgramWithShaderを見てください
ShaderProgram = ShaderHelper.CreateShaderProgramFromSource(
@"#version 100
@ -160,18 +149,15 @@ namespace FDK
};
VBO = Game.Gl.GenBuffer(); //頂点バッファを作る
Game.Gl.BindBuffer(BufferTargetARB.ArrayBuffer, VBO); //頂点バッファをバインドをする
unsafe
{
fixed (float* data = vertices)
{
unsafe {
fixed (float* data = vertices) {
Game.Gl.BufferData(BufferTargetARB.ArrayBuffer, (nuint)(vertices.Length * sizeof(float)), data, BufferUsageARB.StaticDraw); //VRAMに頂点データを送る
}
}
uint locationPosition = (uint)Game.Gl.GetAttribLocation(ShaderProgram, "aPosition");
Game.Gl.EnableVertexAttribArray(locationPosition); //layout (location = 0)を使用可能に
unsafe
{
unsafe {
Game.Gl.VertexAttribPointer(locationPosition, 3, VertexAttribPointerType.Float, false, 3 * sizeof(float), (void*)0); //float3個で一つのxyzの塊として頂点を作る
}
//-----
@ -190,10 +176,8 @@ namespace FDK
2, 1, 3
};
IndicesCount = (uint)indices.Length; //数を登録する
unsafe
{
fixed (uint* data = indices)
{
unsafe {
fixed (uint* data = indices) {
Game.Gl.BufferData(BufferTargetARB.ElementArrayBuffer, (nuint)(indices.Length * sizeof(uint)), data, BufferUsageARB.StaticDraw); //VRAMに送る
}
}
@ -210,18 +194,15 @@ namespace FDK
0.0f, 1.0f,
1.0f, 1.0f,
};
unsafe
{
fixed (float* data = uvs)
{
unsafe {
fixed (float* data = uvs) {
Game.Gl.BufferData(BufferTargetARB.ArrayBuffer, (nuint)(uvs.Length * sizeof(float)), data, BufferUsageARB.StaticDraw);
}
}
uint locationUV = (uint)Game.Gl.GetAttribLocation(ShaderProgram, "aUV");
Game.Gl.EnableVertexAttribArray(locationUV);
unsafe
{
unsafe {
Game.Gl.VertexAttribPointer(locationUV, 2, VertexAttribPointerType.Float, false, 2 * sizeof(float), (void*)0);
}
//-----
@ -239,8 +220,7 @@ namespace FDK
/// <summary>
/// 描画に使用する共通のバッファを解放
/// </summary>
public static void Terminate()
{
public static void Terminate() {
//ちゃんとバッファは解放すること
Game.Gl.DeleteVertexArray(VAO);
Game.Gl.DeleteBuffer(VBO);
@ -250,65 +230,49 @@ namespace FDK
}
// プロパティ
public bool b加算合成
{
public bool b加算合成 {
get;
set;
}
public bool b乗算合成
{
public bool b乗算合成 {
get;
set;
}
public bool b減算合成
{
public bool b減算合成 {
get;
set;
}
public bool bスクリーン合成
{
public bool bスクリーン合成 {
get;
set;
}
public float fZ軸中心回転
{
public float fZ軸中心回転 {
get;
set;
}
public float fZRotation
{
public float fZRotation {
get => fZ軸中心回転;
set { fZ軸中心回転 = value; }
}
public int Opacity
{
get
{
public int Opacity {
get {
return this._opacity;
}
set
{
if (value < 0)
{
set {
if (value < 0) {
this._opacity = 0;
}
else if (value > 0xff)
{
} else if (value > 0xff) {
this._opacity = 0xff;
}
else
{
} else {
this._opacity = value;
}
}
}
public Size szTextureSize
{
public Size szTextureSize {
get;
private set;
}
public Size sz画像サイズ
{
public Size sz画像サイズ {
get;
protected set;
}
@ -329,8 +293,7 @@ namespace FDK
// コンストラクタ
public CTexture()
{
public CTexture() {
this.sz画像サイズ = new Size(0, 0);
this.szTextureSize = new Size(0, 0);
this._opacity = 0xff;
@ -340,8 +303,7 @@ namespace FDK
// this._txData = null;
}
public CTexture(CTexture tx)
{
public CTexture(CTexture tx) {
this.sz画像サイズ = tx.sz画像サイズ;
this.szTextureSize = tx.szTextureSize;
this._opacity = tx._opacity;
@ -352,18 +314,15 @@ namespace FDK
// this._txData = null;
}
public void UpdateTexture(CTexture texture, int n幅, int n高さ)
{
public void UpdateTexture(CTexture texture, int n幅, int n高さ) {
Texture_ = texture.Texture_;
this.sz画像サイズ = new Size(n幅, n高さ);
this.szTextureSize = this.t指定されたサイズを超えない最適なテクスチャサイズを返す(this.sz画像サイズ);
this.rc全画像 = new Rectangle(0, 0, this.sz画像サイズ.Width, this.sz画像サイズ.Height);
}
public void UpdateTexture(IntPtr texture, int width, int height, PixelFormat rgbaType)
{
unsafe
{
public void UpdateTexture(IntPtr texture, int width, int height, PixelFormat rgbaType) {
unsafe {
Game.Gl.DeleteTexture(Texture_); //解放
void* data = texture.ToPointer();
Texture_ = GenTexture(data, (uint)width, (uint)height, rgbaType);
@ -385,30 +344,22 @@ namespace FDK
/// <param name="format">テクスチャのフォーマット。</param>
/// <exception cref="CTextureCreateFailedException">テクスチャの作成に失敗しました。</exception>
public CTexture(SKBitmap bitmap)
: this()
{
try
{
: this() {
try {
MakeTexture(bitmap, false);
}
catch (Exception e)
{
} catch (Exception e) {
this.Dispose();
throw new CTextureCreateFailedException("ビットマップからのテクスチャの生成に失敗しました。", e);
}
}
public CTexture(int n幅, int n高さ)
: this()
{
try
{
: this() {
try {
this.sz画像サイズ = new Size(n幅, n高さ);
this.szTextureSize = this.t指定されたサイズを超えない最適なテクスチャサイズを返す(this.sz画像サイズ);
this.rc全画像 = new Rectangle(0, 0, this.sz画像サイズ.Width, this.sz画像サイズ.Height);
}
catch
{
} catch {
this.Dispose();
throw new CTextureCreateFailedException(string.Format("テクスチャの生成に失敗しました。\n({0}x{1}, {2})", n幅, n高さ));
}
@ -428,12 +379,10 @@ namespace FDK
/// <param name="pool">テクスチャの管理方法。</param>
/// <exception cref="CTextureCreateFailedException">テクスチャの作成に失敗しました。</exception>
public CTexture(string strファイル名, bool b黒を透過する)
: this()
{
: this() {
MakeTexture(strファイル名, b黒を透過する);
}
public void MakeTexture(string strファイル名, bool b黒を透過する)
{
public void MakeTexture(string strファイル名, bool b黒を透過する) {
if (!File.Exists(strファイル名)) // #27122 2012.1.13 from: ImageInformation では FileNotFound 例外は返ってこないので、ここで自分でチェックする。わかりやすいログのために。
throw new FileNotFoundException(string.Format("ファイルが存在しません。\n[{0}]", strファイル名));
@ -443,13 +392,11 @@ namespace FDK
}
public CTexture(SKBitmap bitmap, bool b黒を透過する)
: this()
{
: this() {
MakeTexture(bitmap, b黒を透過する);
}
private unsafe uint GenTexture(void* data, uint width, uint height, PixelFormat pixelFormat)
{
private unsafe uint GenTexture(void* data, uint width, uint height, PixelFormat pixelFormat) {
//テクスチャハンドルの作成-----
uint handle = Game.Gl.GenTexture();
Game.Gl.BindTexture(TextureTarget.Texture2D, handle);
@ -469,37 +416,26 @@ namespace FDK
return handle;
}
public void MakeTexture(SKBitmap bitmap, bool b黒を透過する)
{
try
{
if (bitmap == null)
{
public void MakeTexture(SKBitmap bitmap, bool b黒を透過する) {
try {
if (bitmap == null) {
bitmap = new SKBitmap(10, 10);
}
unsafe
{
fixed (void* data = bitmap.Pixels)
{
if (Thread.CurrentThread.ManagedThreadId == Game.MainThreadID)
{
unsafe {
fixed (void* data = bitmap.Pixels) {
if (Thread.CurrentThread.ManagedThreadId == Game.MainThreadID) {
Texture_ = GenTexture(data, (uint)bitmap.Width, (uint)bitmap.Height, PixelFormat.Bgra);
}
else
{
} else {
SKBitmap bm = bitmap.Copy();
Action createInstance = () =>
{
fixed (void* data2 = bitmap.Pixels)
{
Action createInstance = () => {
fixed (void* data2 = bitmap.Pixels) {
Texture_ = GenTexture(data2, (uint)bitmap.Width, (uint)bitmap.Height, PixelFormat.Bgra);
}
bm.Dispose();
};
Game.AsyncActions.Add(createInstance);
while (Game.AsyncActions.Contains(createInstance))
{
while (Game.AsyncActions.Contains(createInstance)) {
}
}
@ -509,17 +445,14 @@ namespace FDK
this.sz画像サイズ = new Size(bitmap.Width, bitmap.Height);
this.rc全画像 = new Rectangle(0, 0, this.sz画像サイズ.Width, this.sz画像サイズ.Height);
this.szTextureSize = this.t指定されたサイズを超えない最適なテクスチャサイズを返す(this.sz画像サイズ);
}
catch
{
} catch {
this.Dispose();
// throw new CTextureCreateFailedException( string.Format( "テクスチャの生成に失敗しました。\n{0}", strファイル名 ) );
throw new CTextureCreateFailedException(string.Format("テクスチャの生成に失敗しました。\n"));
}
}
public void tSetScale(float x, float y)
{
public void tSetScale(float x, float y) {
vcScaleRatio.X = x;
vcScaleRatio.Y = y;
}
@ -528,145 +461,112 @@ namespace FDK
// 2016.11.10 kairera0467 拡張
// Rectangleを使う場合、座標調整のためにテクスチャサイズの値をそのまま使うとまずいことになるため、Rectragleから幅を取得して調整をする。
public void t2D中心基準描画(int x, int y)
{
public void t2D中心基準描画(int x, int y) {
this.t2D描画(x - (this.szTextureSize.Width / 2), y - (this.szTextureSize.Height / 2), 1f, this.rc全画像);
}
public void t2D中心基準描画Mirrored(int x, int y)
{
public void t2D中心基準描画Mirrored(int x, int y) {
this.t2D左右反転描画(x - (this.szTextureSize.Width / 2), y - (this.szTextureSize.Height / 2), 1f, this.rc全画像);
}
public void t2D中心基準描画Mirrored(float x, float y)
{
public void t2D中心基準描画Mirrored(float x, float y) {
this.t2D左右反転描画(x - (this.szTextureSize.Width / 2), y - (this.szTextureSize.Height / 2), 1f, this.rc全画像);
}
public void t2D中心基準描画(int x, int y, Rectangle rc画像内の描画領域)
{
public void t2D中心基準描画(int x, int y, Rectangle rc画像内の描画領域) {
this.t2D描画(x - (rc画像内の描画領域.Width / 2), y - (rc画像内の描画領域.Height / 2), 1f, rc画像内の描画領域);
}
public void t2D中心基準描画(float x, float y)
{
public void t2D中心基準描画(float x, float y) {
this.t2D描画((int)x - (this.szTextureSize.Width / 2), (int)y - (this.szTextureSize.Height / 2), 1f, this.rc全画像);
}
public void t2D中心基準描画(float x, float y, Rectangle rc画像内の描画領域)
{
public void t2D中心基準描画(float x, float y, Rectangle rc画像内の描画領域) {
this.t2D描画((int)x - (rc画像内の描画領域.Width / 2), (int)y - (rc画像内の描画領域.Height / 2), 1.0f, rc画像内の描画領域);
}
public void t2D中心基準描画(float x, float y, float depth, Rectangle rc画像内の描画領域)
{
public void t2D中心基準描画(float x, float y, float depth, Rectangle rc画像内の描画領域) {
this.t2D描画((int)x - (rc画像内の描画領域.Width / 2), (int)y - (rc画像内の描画領域.Height / 2), depth, rc画像内の描画領域);
}
// 下を基準にして描画する(拡大率考慮)メソッドを追加。 (AioiLight)
public void t2D拡大率考慮下基準描画(int x, int y)
{
public void t2D拡大率考慮下基準描画(int x, int y) {
this.t2D描画(x, y - (szTextureSize.Height * this.vcScaleRatio.Y), 1f, this.rc全画像);
}
public void t2D拡大率考慮下基準描画(int x, int y, Rectangle rc画像内の描画領域)
{
public void t2D拡大率考慮下基準描画(int x, int y, Rectangle rc画像内の描画領域) {
this.t2D描画(x, y - (rc画像内の描画領域.Height * this.vcScaleRatio.Y), 1f, rc画像内の描画領域);
}
public void t2D拡大率考慮下中心基準描画(int x, int y)
{
public void t2D拡大率考慮下中心基準描画(int x, int y) {
this.t2D描画(x - (this.szTextureSize.Width / 2 * this.vcScaleRatio.X), y - (szTextureSize.Height * this.vcScaleRatio.Y), 1f, this.rc全画像);
}
public void t2D拡大率考慮下中心基準描画Mirrored(int x, int y)
{
public void t2D拡大率考慮下中心基準描画Mirrored(int x, int y) {
this.t2D左右反転描画(x - (this.szTextureSize.Width / 2 * this.vcScaleRatio.X), y - (szTextureSize.Height * this.vcScaleRatio.Y), 1f, this.rc全画像);
}
public void t2D拡大率考慮下中心基準描画Mirrored(float x, float y)
{
public void t2D拡大率考慮下中心基準描画Mirrored(float x, float y) {
this.t2D左右反転描画(x - (this.szTextureSize.Width / 2 * this.vcScaleRatio.X), y - (szTextureSize.Height * this.vcScaleRatio.Y), 1f, this.rc全画像);
}
public void t2D拡大率考慮下基準描画(float x, float y)
{
public void t2D拡大率考慮下基準描画(float x, float y) {
this.t2D描画(x, y - (szTextureSize.Height * this.vcScaleRatio.Y), 1f, this.rc全画像);
}
public void t2D拡大率考慮下基準描画(float x, float y, RectangleF rc画像内の描画領域)
{
public void t2D拡大率考慮下基準描画(float x, float y, RectangleF rc画像内の描画領域) {
this.t2D描画(x, y - (rc画像内の描画領域.Height * this.vcScaleRatio.Y), 1f, rc画像内の描画領域);
}
public void t2D拡大率考慮下中心基準描画(float x, float y)
{
public void t2D拡大率考慮下中心基準描画(float x, float y) {
this.t2D拡大率考慮下中心基準描画((int)x, (int)y);
}
public void t2D拡大率考慮下中心基準描画(int x, int y, Rectangle rc画像内の描画領域)
{
public void t2D拡大率考慮下中心基準描画(int x, int y, Rectangle rc画像内の描画領域) {
this.t2D描画(x - ((rc画像内の描画領域.Width / 2)), y - (rc画像内の描画領域.Height * this.vcScaleRatio.Y), 1f, rc画像内の描画領域);
}
public void t2D拡大率考慮下中心基準描画(float x, float y, Rectangle rc画像内の描画領域)
{
public void t2D拡大率考慮下中心基準描画(float x, float y, Rectangle rc画像内の描画領域) {
this.t2D拡大率考慮下中心基準描画((int)x, (int)y, rc画像内の描画領域);
}
public void t2D下中央基準描画(int x, int y)
{
public void t2D下中央基準描画(int x, int y) {
this.t2D描画(x - (this.szTextureSize.Width / 2), y - (szTextureSize.Height), this.rc全画像);
}
public void t2D下中央基準描画(int x, int y, Rectangle rc画像内の描画領域)
{
public void t2D下中央基準描画(int x, int y, Rectangle rc画像内の描画領域) {
this.t2D描画(x - (rc画像内の描画領域.Width / 2), y - (rc画像内の描画領域.Height), rc画像内の描画領域);
//this.t2D描画(devicek x, y, rc画像内の描画領域;
}
public void t2D_DisplayImage_RollNote(int x, int y, RectangleF rc)
{
public void t2D_DisplayImage_RollNote(int x, int y, RectangleF rc) {
this.t2D描画(x - (rc.Width / 2 * this.vcScaleRatio.X), y - (rc.Height / 2 * this.vcScaleRatio.Y), 1f, rc, true);
}
public void t2D拡大率考慮中央基準描画(int x, int y)
{
public void t2D拡大率考慮中央基準描画(int x, int y) {
this.t2D描画(x - (this.szTextureSize.Width / 2 * this.vcScaleRatio.X), y - (szTextureSize.Height / 2 * this.vcScaleRatio.Y), 1f, this.rc全画像);
}
public void t2D拡大率考慮中央基準描画(int x, int y, RectangleF rc)
{
public void t2D拡大率考慮中央基準描画(int x, int y, RectangleF rc) {
this.t2D描画(x - (rc.Width / 2 * this.vcScaleRatio.X), y - (rc.Height / 2 * this.vcScaleRatio.Y), 1f, rc);
}
public void t2D_DisplayImage_AnchorCenterLeft(int x, int y, RectangleF rc)
{
public void t2D_DisplayImage_AnchorCenterLeft(int x, int y, RectangleF rc) {
this.t2D描画(x, y - (rc.Height / 2 * this.vcScaleRatio.Y), 1f, rc);
}
public void t2D拡大率考慮上中央基準描画(int x, int y, RectangleF rc)
{
public void t2D拡大率考慮上中央基準描画(int x, int y, RectangleF rc) {
this.t2D描画(x - (rc.Width / 2 * this.vcScaleRatio.X), y, 1f, rc);
}
public void t2D_DisplayImage_AnchorUpRight(int x, int y, RectangleF rc)
{
public void t2D_DisplayImage_AnchorUpRight(int x, int y, RectangleF rc) {
this.t2D描画(x - (rc.Width * this.vcScaleRatio.X), y, 1f, rc);
}
public void t2D拡大率考慮上中央基準描画(int x, int y)
{
public void t2D拡大率考慮上中央基準描画(int x, int y) {
this.t2D描画(x - (rc全画像.Width / 2 * this.vcScaleRatio.X), y, 1f, rc全画像);
}
public void t2D拡大率考慮中央基準描画(float x, float y)
{
public void t2D拡大率考慮中央基準描画(float x, float y) {
this.t2D描画(x - (this.szTextureSize.Width / 2 * this.vcScaleRatio.X), y - (szTextureSize.Height / 2 * this.vcScaleRatio.Y), 1f, this.rc全画像);
}
public void t2D拡大率考慮中央基準描画Mirrored(float x, float y)
{
public void t2D拡大率考慮中央基準描画Mirrored(float x, float y) {
this.t2D左右反転描画(x - (this.szTextureSize.Width / 2 * this.vcScaleRatio.X), y - (szTextureSize.Height / 2 * this.vcScaleRatio.Y), 1f, this.rc全画像);
}
public void t2D拡大率考慮中央基準描画(float x, float y, RectangleF rc)
{
public void t2D拡大率考慮中央基準描画(float x, float y, RectangleF rc) {
this.t2D描画(x - (rc.Width / 2 * this.vcScaleRatio.X), y - (rc.Height / 2 * this.vcScaleRatio.Y), 1f, rc);
}
public void t2D拡大率考慮描画(RefPnt refpnt, float x, float y)
{
public void t2D拡大率考慮描画(RefPnt refpnt, float x, float y) {
this.t2D拡大率考慮描画(refpnt, x, y, rc全画像);
}
public void t2D拡大率考慮描画(RefPnt refpnt, float x, float y, Rectangle rect)
{
public void t2D拡大率考慮描画(RefPnt refpnt, float x, float y, Rectangle rect) {
this.t2D拡大率考慮描画(refpnt, x, y, 1f, rect);
}
public void t2D拡大率考慮描画(RefPnt refpnt, float x, float y, float depth, Rectangle rect)
{
switch (refpnt)
{
public void t2D拡大率考慮描画(RefPnt refpnt, float x, float y, float depth, Rectangle rect) {
switch (refpnt) {
case RefPnt.UpLeft:
this.t2D描画(x, y, depth, rect);
break;
@ -699,21 +599,17 @@ namespace FDK
}
}
public void t2D_DisplayImage_AnchorCenter(int x, int y)
{
public void t2D_DisplayImage_AnchorCenter(int x, int y) {
this.t2D描画(x - (this.rc全画像.Width / 2 * this.vcScaleRatio.X), y - (this.rc全画像.Height / 2 * this.vcScaleRatio.Y), 1f, this.rc全画像);
}
public void t2D_DisplayImage_AnchorCenter(int x, int y, Rectangle rc)
{
public void t2D_DisplayImage_AnchorCenter(int x, int y, Rectangle rc) {
this.t2D描画(x - (rc.Width / 2 * this.vcScaleRatio.X), y - (rc.Height / 2 * this.vcScaleRatio.Y), 1f, rc);
}
public void t2D_DisplayImage_AnchorCenter(int x, int y, RectangleF rc)
{
public void t2D_DisplayImage_AnchorCenter(int x, int y, RectangleF rc) {
this.t2D描画(x - (rc.Width / 2 * this.vcScaleRatio.X), y - (rc.Height / 2 * this.vcScaleRatio.Y), 1f, rc);
}
public enum RefPnt
{
public enum RefPnt {
UpLeft,
Up,
UpRight,
@ -725,16 +621,13 @@ namespace FDK
DownRight,
}
public void t2D_DisplayImage(int x, int y)
{
public void t2D_DisplayImage(int x, int y) {
this.t2D描画(x, y, 1f, this.rc全画像);
}
public void t2D_DisplayImage(int x, int y, Rectangle rc画像内の描画領域)
{
public void t2D_DisplayImage(int x, int y, Rectangle rc画像内の描画領域) {
this.t2D描画(x, y, 1f, rc画像内の描画領域);
}
public void t2D_DisplayImage(int x, int y, RectangleF rc)
{
public void t2D_DisplayImage(int x, int y, RectangleF rc) {
this.t2D描画(x, y, 1f, rc);
}
@ -744,45 +637,31 @@ namespace FDK
/// <param name="device">Direct3D9 デバイス。</param>
/// <param name="x">描画位置(テクスチャの左上位置の X 座標[dot])。</param>
/// <param name="y">描画位置(テクスチャの左上位置の Y 座標[dot])。</param>
public void t2D描画(int x, int y)
{
public void t2D描画(int x, int y) {
this.t2D描画(x, y, 1f, this.rc全画像);
}
public void t2D描画(int x, int y, RectangleF rc画像内の描画領域)
{
public void t2D描画(int x, int y, RectangleF rc画像内の描画領域) {
this.t2D描画(x, y, 1f, rc画像内の描画領域);
}
public void t2D描画(float x, float y)
{
public void t2D描画(float x, float y) {
this.t2D描画((int)x, (int)y, 1f, this.rc全画像);
}
public void t2D描画(float x, float y, RectangleF rc画像内の描画領域)
{
public void t2D描画(float x, float y, RectangleF rc画像内の描画領域) {
this.t2D描画((int)x, (int)y, 1f, rc画像内の描画領域);
}
public void t2D描画(float x, float y, float depth, RectangleF rc画像内の描画領域, bool flipX = false, bool flipY = false, bool rollMode = false)
{
public void t2D描画(float x, float y, float depth, RectangleF rc画像内の描画領域, bool flipX = false, bool flipY = false, bool rollMode = false) {
this.color4.Alpha = this._opacity / 255f;
BlendType blendType;
if (b加算合成)
{
if (b加算合成) {
blendType = BlendType.Add;
}
else if (b乗算合成)
{
} else if (b乗算合成) {
blendType = BlendType.Multi;
}
else if (b減算合成)
{
} else if (b減算合成) {
blendType = BlendType.Sub;
}
else if (bスクリーン合成)
{
} else if (bスクリーン合成) {
blendType = BlendType.Screen;
}
else
{
} else {
blendType = BlendType.Normal;
}
@ -793,8 +672,7 @@ namespace FDK
Game.Gl.BindTexture(TextureTarget.Texture2D, Texture_); //テクスチャをバインド
//MVPを設定----
unsafe
{
unsafe {
Matrix4X4<float> mvp = Matrix4X4<float>.Identity;
float gameAspect = (float)GameWindowSize.Width / GameWindowSize.Height;
@ -837,76 +715,59 @@ namespace FDK
//描画-----
Game.Gl.BindVertexArray(VAO);
unsafe
{
unsafe {
Game.Gl.DrawElements(PrimitiveType.Triangles, IndicesCount, DrawElementsType.UnsignedInt, (void*)0);//描画!
}
BlendHelper.SetBlend(BlendType.Normal);
}
public void t2D描画(int x, int y, float depth, Rectangle rc画像内の描画領域)
{
public void t2D描画(int x, int y, float depth, Rectangle rc画像内の描画領域) {
t2D描画((float)x, (float)y, depth, rc画像内の描画領域);
}
public void t2D上下反転描画(int x, int y)
{
public void t2D上下反転描画(int x, int y) {
this.t2D上下反転描画(x, y, 1f, this.rc全画像);
}
public void t2D上下反転描画(int x, int y, Rectangle rc画像内の描画領域)
{
public void t2D上下反転描画(int x, int y, Rectangle rc画像内の描画領域) {
this.t2D上下反転描画(x, y, 1f, rc画像内の描画領域);
}
public void t2D左右反転描画(int x, int y)
{
public void t2D左右反転描画(int x, int y) {
this.t2D左右反転描画(x, y, 1f, this.rc全画像);
}
public void t2D左右反転描画(float x, float y)
{
public void t2D左右反転描画(float x, float y) {
this.t2D左右反転描画(x, y, 1f, this.rc全画像);
}
public void t2D左右反転描画(int x, int y, Rectangle rc画像内の描画領域)
{
public void t2D左右反転描画(int x, int y, Rectangle rc画像内の描画領域) {
this.t2D左右反転描画(x, y, 1f, rc画像内の描画領域);
}
public void t2D左右反転描画(float x, float y, float depth, Rectangle rc画像内の描画領域)
{
public void t2D左右反転描画(float x, float y, float depth, Rectangle rc画像内の描画領域) {
t2D描画(x, y, depth, rc画像内の描画領域, flipX: true);
}
public void t2D上下反転描画(int x, int y, float depth, Rectangle rc画像内の描画領域)
{
public void t2D上下反転描画(int x, int y, float depth, Rectangle rc画像内の描画領域) {
t2D描画(x, y, depth, rc画像内の描画領域, flipY: true);
}
public void t2D上下反転描画(Point pt)
{
public void t2D上下反転描画(Point pt) {
this.t2D上下反転描画(pt.X, pt.Y, 1f, this.rc全画像);
}
public void t2D上下反転描画(Point pt, Rectangle rc画像内の描画領域)
{
public void t2D上下反転描画(Point pt, Rectangle rc画像内の描画領域) {
this.t2D上下反転描画(pt.X, pt.Y, 1f, rc画像内の描画領域);
}
public void t2D上下反転描画(Point pt, float depth, Rectangle rc画像内の描画領域)
{
public void t2D上下反転描画(Point pt, float depth, Rectangle rc画像内の描画領域) {
this.t2D上下反転描画(pt.X, pt.Y, depth, rc画像内の描画領域);
}
public static Vector3D<float> t論理画面座標をワールド座標へ変換する(int x, int y)
{
public static Vector3D<float> t論理画面座標をワールド座標へ変換する(int x, int y) {
return CTexture.t論理画面座標をワールド座標へ変換する(new Vector3D<float>((float)x, (float)y, 0f));
}
public static Vector3D<float> t論理画面座標をワールド座標へ変換する(float x, float y)
{
public static Vector3D<float> t論理画面座標をワールド座標へ変換する(float x, float y) {
return CTexture.t論理画面座標をワールド座標へ変換する(new Vector3D<float>(x, y, 0f));
}
public static Vector3D<float> t論理画面座標をワールド座標へ変換する(Point pt論理画面座標)
{
public static Vector3D<float> t論理画面座標をワールド座標へ変換する(Point pt論理画面座標) {
return CTexture.t論理画面座標をワールド座標へ変換する(new Vector3D<float>(pt論理画面座標.X, pt論理画面座標.Y, 0.0f));
}
public static Vector3D<float> t論理画面座標をワールド座標へ変換する(Vector2D<float> v2論理画面座標)
{
public static Vector3D<float> t論理画面座標をワールド座標へ変換する(Vector2D<float> v2論理画面座標) {
return CTexture.t論理画面座標をワールド座標へ変換する(new Vector3D<float>(v2論理画面座標, 0f));
}
public static Vector3D<float> t論理画面座標をワールド座標へ変換する(Vector3D<float> v3論理画面座標)
{
public static Vector3D<float> t論理画面座標をワールド座標へ変換する(Vector3D<float> v3論理画面座標) {
return new Vector3D<float>(
(v3論理画面座標.X - (CTexture.sz論理画面.Width / 2.0f)) * CTexture.f画面比率,
(-(v3論理画面座標.Y - (CTexture.sz論理画面.Height / 2.0f)) * CTexture.f画面比率),
@ -916,32 +777,22 @@ namespace FDK
public void t2D描画SongObj(float x, float y, float xScale, float yScale)
{
public void t2D描画SongObj(float x, float y, float xScale, float yScale) {
this.color4.Alpha = this._opacity / 255f;
var rc画像内の描画領域 = rc全画像;
this.color4.Alpha = this._opacity / 255f;
BlendType blendType;
if (b加算合成)
{
if (b加算合成) {
blendType = BlendType.Add;
}
else if (b乗算合成)
{
} else if (b乗算合成) {
blendType = BlendType.Multi;
}
else if (b減算合成)
{
} else if (b減算合成) {
blendType = BlendType.Sub;
}
else if (bスクリーン合成)
{
} else if (bスクリーン合成) {
blendType = BlendType.Screen;
}
else
{
} else {
blendType = BlendType.Normal;
}
@ -952,8 +803,7 @@ namespace FDK
Game.Gl.BindTexture(TextureTarget.Texture2D, Texture_); //テクスチャをバインド
//MVPを設定----
unsafe
{
unsafe {
Matrix4X4<float> mvp = Matrix4X4<float>.Identity;
float gameAspect = (float)GameWindowSize.Width / GameWindowSize.Height;
@ -996,8 +846,7 @@ namespace FDK
//描画-----
Game.Gl.BindVertexArray(VAO);
unsafe
{
unsafe {
Game.Gl.DrawElements(PrimitiveType.Triangles, IndicesCount, DrawElementsType.UnsignedInt, (void*)0);//描画!
}
@ -1007,10 +856,8 @@ namespace FDK
#region [ IDisposable ]
//-----------------
public void Dispose()
{
if (!this.bDispose完了済み)
{
public void Dispose() {
if (!this.bDispose完了済み) {
Game.Gl.DeleteTexture(Texture_); //解放
this.bDispose完了済み = true;
@ -1027,13 +874,11 @@ namespace FDK
private int _opacity;
private bool bDispose完了済み;
private Size t指定されたサイズを超えない最適なテクスチャサイズを返す(Size sz指定サイズ)
{
private Size t指定されたサイズを超えない最適なテクスチャサイズを返す(Size sz指定サイズ) {
return sz指定サイズ;
}
private int ToArgb(Color4 col4)
{
private int ToArgb(Color4 col4) {
uint a = (uint)(col4.Alpha * 255.0f) & 255;
uint r = (uint)(col4.Red * 255.0f) & 255;
uint g = (uint)(col4.Green * 255.0f) & 255;
@ -1053,13 +898,11 @@ namespace FDK
protected Rectangle rc全画像; // テクスチャ作ったらあとは不変
public Color4 color4 = new Color4(1f, 1f, 1f, 1f); // アルファ以外は不変
public void tUpdateColor4(Color4 c4)
{
public void tUpdateColor4(Color4 c4) {
this.color4 = c4;
}
public void tUpdateOpacity(int o)
{
public void tUpdateOpacity(int o) {
this.Opacity = o;
}
//-----------------

View File

@ -1,6 +1,5 @@
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;

View File

@ -1,26 +1,17 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Diagnostics;
using System.Drawing;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Globalization;
using System.Net.NetworkInformation;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using DiscordRPC;
using FDK;
using SampleFramework;
using System.Reflection;
using System.Threading.Tasks;
using System.Linq;
using Silk.NET.Maths;
using SkiaSharp;
using DiscordRPC;
using Rectangle = System.Drawing.Rectangle;
using Point = System.Drawing.Point;
using Color = System.Drawing.Color;
using System.Runtime.InteropServices;
namespace TJAPlayer3 {
internal class TJAPlayer3 : Game {
@ -2028,8 +2019,7 @@ for (int i = 0; i < 3; i++) {
if (r現在のステージ != null && r現在のステージ.eStageID != CStage.EStage.StartUp && TJAPlayer3.Tx.Network_Connection != null) {
if (Math.Abs(SoundManager.PlayTimer.SystemTimeMs - this.ms) > 10000) {
this.ms = SoundManager.PlayTimer.SystemTimeMs;
Task.Factory.StartNew(() =>
{
Task.Factory.StartNew(() => {
//IPv4 8.8.8.8にPingを送信する(timeout 5000ms)
PingReply reply = new Ping().Send("8.8.8.8", 5000);
this.bネットワークに接続中 = reply.Status == IPStatus.Success;

View File

@ -24,20 +24,16 @@ namespace TJAPlayer3 {
}
public string str項目名;
public string strName
{
get
{
public string strName {
get {
return str項目名;
}
}
public string str説明文;
public string strDescription
{
get
{
public string strDescription {
get {
return str説明文;
}
@ -110,13 +106,11 @@ namespace TJAPlayer3 {
return null;
}
public string tGetValueText()
{
public string tGetValueText() {
object value = obj現在値();
return value == null ? "" : value.ToString();
}
public virtual int GetIndex()
{
public virtual int GetIndex() {
return 0;
}
public virtual void SetIndex(int index) {

View File

@ -1,29 +1,16 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using FDK;
using NLua;
using static KeraLua.LuaGC;
using Silk.NET.OpenGLES;
using SkiaSharp;
using TJAPlayer3;
using static TJAPlayer3.CActSelect曲リスト;
namespace TJAPlayer3
{
class CLuaScript : IDisposable
{
namespace TJAPlayer3 {
class CLuaScript : IDisposable {
private static List<CLuaScript> listScripts = new List<CLuaScript>();
public static void tReloadLanguage(string lang)
{
foreach (var item in listScripts)
{
public static void tReloadLanguage(string lang) {
foreach (var item in listScripts) {
item.ReloadLanguage(lang);
}
}
@ -48,86 +35,69 @@ namespace TJAPlayer3
private List<IDisposable> listDisposables = new List<IDisposable>();
protected bool Avaibale
{
get
{
protected bool Avaibale {
get {
return bLoadedAssets && !bDisposed && !bCrashed;
}
}
private double getNum(JsonValue x)
{
private double getNum(JsonValue x) {
return (double)x;
}
private string getText(JsonValue x)
{
private string getText(JsonValue x) {
return (string)x;
}
private List<double> getNumArray(JsonArray x)
{
private List<double> getNumArray(JsonArray x) {
List<double> array = new List<double>();
foreach (double value in x)
{
foreach (double value in x) {
array.Add(value);
}
return array;
}
private List<string> getTextArray(JsonArray x)
{
private List<string> getTextArray(JsonArray x) {
List<string> array = new List<string>();
foreach (string value in x)
{
foreach (string value in x) {
array.Add(value);
}
return array;
}
protected object[] RunLuaCode(LuaFunction luaFunction, params object[] args)
{
try
{
protected object[] RunLuaCode(LuaFunction luaFunction, params object[] args) {
try {
var ret = luaFunction.Call(args);
LuaScript.State.GarbageCollector(KeraLua.LuaGC.Collect, 0);
return ret;
}
catch (Exception exception)
{
} catch (Exception exception) {
Crash(exception);
}
return new object[0];
}
private JsonNode LoadConfig(string name)
{
private JsonNode LoadConfig(string name) {
using Stream stream = File.OpenRead($"{strDir}/{name}");
JsonNode jsonNode = JsonNode.Parse(stream);
return jsonNode;
}
private CTexture LoadTexture(string name)
{
private CTexture LoadTexture(string name) {
CTexture texture = new CTexture($"{strTexturesDir}/{name}", false);
listDisposables.Add(texture);
return texture;
}
private void DebugLog(string message)
{
private void DebugLog(string message) {
Trace.TraceInformation("<Lua Log>: " + message);
}
private CSound LoadSound(string name, string soundGroupName)
{
private CSound LoadSound(string name, string soundGroupName) {
ESoundGroup soundGroup;
switch (soundGroupName)
{
switch (soundGroupName) {
case "soundeffect":
soundGroup = ESoundGroup.SoundEffect;
break;
@ -150,11 +120,9 @@ namespace TJAPlayer3
return sound;
}
private CCachedFontRenderer LoadFontRenderer(int size, string fontStyleName)
{
private CCachedFontRenderer LoadFontRenderer(int size, string fontStyleName) {
CFontRenderer.FontStyle fontStyle;
switch (fontStyleName)
{
switch (fontStyleName) {
case "regular":
fontStyle = CFontRenderer.FontStyle.Regular;
break;
@ -180,18 +148,15 @@ namespace TJAPlayer3
return fontRenderer;
}
private TitleTextureKey CreateTitleTextureKey(string title, CCachedFontRenderer fontRenderer, int maxSize, Color? color = null, Color? edgeColor = null)
{
private TitleTextureKey CreateTitleTextureKey(string title, CCachedFontRenderer fontRenderer, int maxSize, Color? color = null, Color? edgeColor = null) {
return new TitleTextureKey(title, fontRenderer, color ?? Color.White, edgeColor ?? Color.Black, maxSize);
}
private CTexture GetTextTex(CActSelect曲リスト.TitleTextureKey titleTextureKey, bool vertical, bool keepCenter)
{
private CTexture GetTextTex(CActSelect曲リスト.TitleTextureKey titleTextureKey, bool vertical, bool keepCenter) {
return TJAPlayer3.stageSongSelect.actSongList.ResolveTitleTexture(titleTextureKey, vertical, keepCenter);
}
public CLuaScript(string dir, string? texturesDir = null, string? soundsDir = null, bool loadAssets = true)
{
public CLuaScript(string dir, string? texturesDir = null, string? soundsDir = null, bool loadAssets = true) {
strDir = dir;
strTexturesDir = texturesDir ?? $"{dir}/Textures";
strSounsdDir = soundsDir ?? $"{dir}/Sounds";
@ -228,8 +193,7 @@ namespace TJAPlayer3
listScripts.Add(this);
}
public void LoadAssets(params object[] args)
{
public void LoadAssets(params object[] args) {
if (bLoadedAssets) return;
RunLuaCode(lfLoadAssets, args);
@ -238,17 +202,14 @@ namespace TJAPlayer3
bDisposed = false;
}
public void ReloadLanguage(params object[] args)
{
public void ReloadLanguage(params object[] args) {
RunLuaCode(lfReloadLanguage, args);
}
public void Dispose()
{
public void Dispose() {
if (bDisposed) return;
foreach (IDisposable disposable in listDisposables)
{
foreach (IDisposable disposable in listDisposables) {
disposable.Dispose();
}
listDisposables.Clear();
@ -261,8 +222,7 @@ namespace TJAPlayer3
listScripts.Remove(this);
}
private void Crash(Exception exception)
{
private void Crash(Exception exception) {
bCrashed = true;
LogNotification.PopError($"Lua Script Error: {exception.ToString()}");

View File

@ -1,13 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TJAPlayer3
{
internal class CLuaFps
{
namespace TJAPlayer3 {
internal class CLuaFps {
public double deltaTime => TJAPlayer3.FPS.DeltaTime;
public int fps => TJAPlayer3.FPS.NowFPS;
}

View File

@ -1,13 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TJAPlayer3
{
internal class CLuaInfo
{
namespace TJAPlayer3 {
internal class CLuaInfo {
public int playerCount => TJAPlayer3.ConfigIni.nPlayerCount;
public string lang => TJAPlayer3.ConfigIni.sLang;
public bool simplemode => TJAPlayer3.ConfigIni.SimpleMode;
@ -16,8 +8,7 @@ namespace TJAPlayer3
public string dir { get; init; }
public CLuaInfo(string dir)
{
public CLuaInfo(string dir) {
this.dir = dir;
}
}

View File

@ -1,15 +1,8 @@
using FDK;
using NLua;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TJAPlayer3
{
internal class CLuaNamePlateScript : CLuaScript
{
namespace TJAPlayer3 {
internal class CLuaNamePlateScript : CLuaScript {
private LuaFunction lfGetCharaOffset;
private LuaFunction lfSetInfos;
private LuaFunction lfDrawDan;
@ -17,8 +10,7 @@ namespace TJAPlayer3
private LuaFunction lfUpdate;
private LuaFunction lfDraw;
public CLuaNamePlateScript(string dir, string? texturesDir = null, string? soundsDir = null, bool loadAssets = true) : base(dir, texturesDir, soundsDir, loadAssets)
{
public CLuaNamePlateScript(string dir, string? texturesDir = null, string? soundsDir = null, bool loadAssets = true) : base(dir, texturesDir, soundsDir, loadAssets) {
lfGetCharaOffset = (LuaFunction)LuaScript["getCharaOffset"];
lfSetInfos = (LuaFunction)LuaScript["setInfos"];
lfDrawDan = (LuaFunction)LuaScript["drawDan"];
@ -27,43 +19,37 @@ namespace TJAPlayer3
lfDraw = (LuaFunction)LuaScript["draw"];
}
public int GetCharaOffset()
{
public int GetCharaOffset() {
if (!Avaibale) return 0;
double result = (double)RunLuaCode(lfGetCharaOffset)[0];
return (int)result;
}
public void SetInfos(int player, string name, string title, string dan, SaveFile.Data data)
{
public void SetInfos(int player, string name, string title, string dan, SaveFile.Data data) {
if (!Avaibale) return;
RunLuaCode(lfSetInfos, player, name ?? "", title ?? "", dan ?? "", data);
}
public void DrawDan(int x, int y, int opacity, int danGrade, CTexture titleTex)
{
public void DrawDan(int x, int y, int opacity, int danGrade, CTexture titleTex) {
if (!Avaibale) return;
RunLuaCode(lfDrawDan, x, y, opacity, danGrade, titleTex);
}
public void DrawTitlePlate(int x, int y, int opacity, int type, CTexture titleTex, int rarity, int nameplateId)
{
public void DrawTitlePlate(int x, int y, int opacity, int type, CTexture titleTex, int rarity, int nameplateId) {
if (!Avaibale) return;
RunLuaCode(lfDrawTitlePlate, x, y, opacity, type, titleTex, rarity, nameplateId);
}
public void Update(params object[] args)
{
public void Update(params object[] args) {
if (!Avaibale) return;
RunLuaCode(lfUpdate, args);
}
public void Draw(int x, int y, int opacity, int player, int side)
{
public void Draw(int x, int y, int opacity, int player, int side) {
if (!Avaibale) return;
RunLuaCode(lfDraw, x, y, opacity, player, side);

View File

@ -1,20 +1,7 @@
using FDK;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static TJAPlayer3.CActSelect曲リスト;
namespace TJAPlayer3
{
class CNamePlate
{
namespace TJAPlayer3 {
class CNamePlate {
public CLuaNamePlateScript lcNamePlate { get; private set; }
public void RefleshSkin()
{
public void RefleshSkin() {
/*
for (int player = 0; player < 5; player++)
{
@ -35,16 +22,13 @@ namespace TJAPlayer3
lcNamePlate?.Dispose();
lcNamePlate = new CLuaNamePlateScript(CSkin.Path("Modules/NamePlate"));
for (int player = 0; player < 5; player++)
{
for (int player = 0; player < 5; player++) {
tNamePlateRefreshTitles(player);
}
}
public CNamePlate()
{
for (int player = 0; player < 5; player++)
{
public CNamePlate() {
for (int player = 0; player < 5; player++) {
if (TJAPlayer3.SaveFileInstances[player].data.DanType < 0) TJAPlayer3.SaveFileInstances[player].data.DanType = 0;
else if (TJAPlayer3.SaveFileInstances[player].data.DanType > 2) TJAPlayer3.SaveFileInstances[player].data.DanType = 2;
@ -77,8 +61,7 @@ namespace TJAPlayer3
}
*/
public void tNamePlateRefreshTitles(int player)
{
public void tNamePlateRefreshTitles(int player) {
int actualPlayer = TJAPlayer3.GetActualPlayer(player);
string[] stages = { "初", "二", "三", "四", "五", "六", "七", "八", "九", "極" };
@ -88,14 +71,11 @@ namespace TJAPlayer3
string dan;
bool isAI = TJAPlayer3.ConfigIni.bAIBattleMode && player == 1;
if (isAI)
{
if (isAI) {
name = CLangManager.LangInstance.GetString("AI_NAME");
title = CLangManager.LangInstance.GetString("AI_TITLE");
dan = stages[Math.Max(0, TJAPlayer3.ConfigIni.nAILevel - 1)] + "面";
}
else
{
} else {
name = TJAPlayer3.SaveFileInstances[player].data.Name;
title = TJAPlayer3.SaveFileInstances[player].data.Title;
dan = TJAPlayer3.SaveFileInstances[player].data.Dan;
@ -116,8 +96,7 @@ namespace TJAPlayer3
}
public void tNamePlateDraw(int x, int y, int player, bool bTitle = false, int Opacity = 255)
{
public void tNamePlateDraw(int x, int y, int player, bool bTitle = false, int Opacity = 255) {
float resolutionScaleX = TJAPlayer3.Skin.Resolution[0] / 1280.0f;
float resolutionScaleY = TJAPlayer3.Skin.Resolution[1] / 720.0f;
@ -125,8 +104,7 @@ namespace TJAPlayer3
player = TJAPlayer3.GetActualPlayer(player);
bool isAI = TJAPlayer3.ConfigIni.bAIBattleMode && basePlayer == 1;
if (bIsPrevAI[basePlayer] != isAI)
{
if (bIsPrevAI[basePlayer] != isAI) {
tNamePlateRefreshTitles(player);
}
bIsPrevAI[basePlayer] = isAI;