mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Added 'DarkTheme.png' theme image with encoded colors
This commit is contained in:
parent
4f2472c276
commit
287922693e
11 changed files with 93 additions and 14 deletions
|
@ -154,5 +154,10 @@ namespace Beefy.gfx
|
||||||
{
|
{
|
||||||
return (color & 0xFF00FF00) | ((color & 0x00FF0000) >> 16) | ((color & 0x000000FF) << 16);
|
return (color & 0xFF00FF00) | ((color & 0x00FF0000) >> 16) | ((color & 0x000000FF) << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static uint32 FromNative(Color color)
|
||||||
|
{
|
||||||
|
return (color & 0xFF00FF00) | ((color & 0x00FF0000) >> 16) | ((color & 0x000000FF) << 16);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,15 @@ namespace Beefy.gfx
|
||||||
{
|
{
|
||||||
#if !STUDIO_CLIENT
|
#if !STUDIO_CLIENT
|
||||||
public class Image : IDrawable
|
public class Image : IDrawable
|
||||||
{
|
{
|
||||||
|
enum LoadFlags
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Additive = 1,
|
||||||
|
NoPremult = 2,
|
||||||
|
AllowRead = 4
|
||||||
|
}
|
||||||
|
|
||||||
public Image mSrcTexture;
|
public Image mSrcTexture;
|
||||||
public int32 mSrcX;
|
public int32 mSrcX;
|
||||||
public int32 mSrcY;
|
public int32 mSrcY;
|
||||||
|
@ -29,7 +37,7 @@ namespace Beefy.gfx
|
||||||
public static extern void Gfx_DrawTextureSegment(void* textureSegment, float a, float b, float c, float d, float tx, float ty, float z, uint32 color, int32 pixelSnapping);
|
public static extern void Gfx_DrawTextureSegment(void* textureSegment, float a, float b, float c, float d, float tx, float ty, float z, uint32 color, int32 pixelSnapping);
|
||||||
|
|
||||||
[StdCall, CLink]
|
[StdCall, CLink]
|
||||||
static extern void* Gfx_LoadTexture(char8* fileName, int32 additive);
|
static extern void* Gfx_LoadTexture(char8* fileName, int32 flags);
|
||||||
|
|
||||||
[StdCall, CLink]
|
[StdCall, CLink]
|
||||||
static extern void* Gfx_CreateDynTexture(int32 width, int32 height);
|
static extern void* Gfx_CreateDynTexture(int32 width, int32 height);
|
||||||
|
@ -49,6 +57,9 @@ namespace Beefy.gfx
|
||||||
[StdCall, CLink]
|
[StdCall, CLink]
|
||||||
static extern void Gfx_Texture_SetBits(void* textureSegment, int32 destX, int32 destY, int32 destWidth, int32 destHeight, int32 srcPitch, uint32* bits);
|
static extern void Gfx_Texture_SetBits(void* textureSegment, int32 destX, int32 destY, int32 destWidth, int32 destHeight, int32 srcPitch, uint32* bits);
|
||||||
|
|
||||||
|
[StdCall, CLink]
|
||||||
|
static extern void Gfx_Texture_GetBits(void* textureSegment, int32 srcX, int32 srcY, int32 srcWidth, int32 srcHeight, int32 destPitch, uint32* bits);
|
||||||
|
|
||||||
[StdCall, CLink]
|
[StdCall, CLink]
|
||||||
static extern void Gfx_Texture_Delete(void* textureSegment);
|
static extern void Gfx_Texture_Delete(void* textureSegment);
|
||||||
|
|
||||||
|
@ -82,11 +93,11 @@ namespace Beefy.gfx
|
||||||
return CreateFromNativeTextureSegment(aNativeTextureSegment);
|
return CreateFromNativeTextureSegment(aNativeTextureSegment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image LoadFromFile(String fileName, bool additive = false)
|
public static Image LoadFromFile(String fileName, LoadFlags flags = .None)
|
||||||
{
|
{
|
||||||
scope AutoBeefPerf("Image.LoadFromFile");
|
scope AutoBeefPerf("Image.LoadFromFile");
|
||||||
|
|
||||||
void* aNativeTextureSegment = Gfx_LoadTexture(fileName, additive ? 1 : 0);
|
void* aNativeTextureSegment = Gfx_LoadTexture(fileName, (int32)flags);
|
||||||
if (aNativeTextureSegment == null)
|
if (aNativeTextureSegment == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -175,6 +186,11 @@ namespace Beefy.gfx
|
||||||
Gfx_Texture_SetBits(mNativeTextureSegment, (.)destX, (.)destY, (.)destWidth, (.)destHeight, (.)srcPitch, bits);
|
Gfx_Texture_SetBits(mNativeTextureSegment, (.)destX, (.)destY, (.)destWidth, (.)destHeight, (.)srcPitch, bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GetBits(int srcX, int srcY, int srcWidth, int srcHeight, int destPitch, uint32* bits)
|
||||||
|
{
|
||||||
|
Gfx_Texture_GetBits(mNativeTextureSegment, (.)srcX, (.)srcY, (.)srcWidth, (.)srcHeight, (.)destPitch, bits);
|
||||||
|
}
|
||||||
|
|
||||||
public void CreateImageCels(Image[,] celImages)
|
public void CreateImageCels(Image[,] celImages)
|
||||||
{
|
{
|
||||||
int32 rows = (int32)celImages.GetLength(0);
|
int32 rows = (int32)celImages.GetLength(0);
|
||||||
|
|
|
@ -183,13 +183,11 @@ namespace Beefy.theme.dark
|
||||||
COUNT
|
COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
public const uint32 COLOR_WINDOW = 0xFF595959;
|
public static uint32 COLOR_WINDOW = 0xFF595959;
|
||||||
public const uint32 COLOR_BKG = 0xFF262626;
|
public static uint32 COLOR_BKG = 0xFF262626;
|
||||||
public const uint32 COLOR_SELECTED_OUTLINE = 0xFFE6A800;
|
public static uint32 COLOR_SELECTED_OUTLINE = 0xFFE6A800;
|
||||||
public const uint32 COLOR_MENU_FOCUSED = 0xFFFFA000;
|
public static uint32 COLOR_MENU_FOCUSED = 0xFFFFA000;
|
||||||
public const uint32 COLOR_MENU_SELECTED = 0xFFD0A070;
|
public static uint32 COLOR_MENU_SELECTED = 0xFFD0A070;
|
||||||
public const uint32 COLOR_TIMELINE_SEP = 0xFF202020;
|
|
||||||
public const uint32 COLOR_TIMELINE_RULE = 0xFF4A4A4A;
|
|
||||||
|
|
||||||
public static float sScale = 1.0f;
|
public static float sScale = 1.0f;
|
||||||
public static int32 sSrcImgScale = 1;
|
public static int32 sSrcImgScale = 1;
|
||||||
|
@ -309,6 +307,16 @@ namespace Beefy.theme.dark
|
||||||
delete mWindowTopImage;
|
delete mWindowTopImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Image themeImg = Image.LoadFromFile(scope String..Append(tempStr, BFApp.sApp.mInstallDir, "images/DarkTheme.png"), .AllowRead);
|
||||||
|
defer delete themeImg;
|
||||||
|
uint32[5] bits = ?;
|
||||||
|
themeImg.GetBits(0, 0, bits.Count, 1, bits.Count, &bits);
|
||||||
|
COLOR_WINDOW = Color.FromNative(bits[0]);
|
||||||
|
COLOR_BKG = Color.FromNative(bits[1]);
|
||||||
|
COLOR_SELECTED_OUTLINE = Color.FromNative(bits[2]);
|
||||||
|
COLOR_MENU_FOCUSED = Color.FromNative(bits[3]);
|
||||||
|
COLOR_MENU_SELECTED = Color.FromNative(bits[4]);
|
||||||
|
|
||||||
String uiFileName = null;
|
String uiFileName = null;
|
||||||
switch (sSrcImgScale)
|
switch (sSrcImgScale)
|
||||||
{
|
{
|
||||||
|
|
|
@ -422,6 +422,11 @@ BF_EXPORT void BF_CALLTYPE Gfx_Texture_SetBits(TextureSegment* textureSegment, i
|
||||||
textureSegment->mTexture->SetBits(destX, destY, destWidth, destHeight, srcPitch, bits);
|
textureSegment->mTexture->SetBits(destX, destY, destWidth, destHeight, srcPitch, bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BF_EXPORT void BF_CALLTYPE Gfx_Texture_GetBits(TextureSegment* textureSegment, int srcX, int srcY, int srcWidth, int srcHeight, int destPitch, uint32* bits)
|
||||||
|
{
|
||||||
|
textureSegment->mTexture->GetBits(srcX, srcY, srcWidth, srcHeight, destPitch, bits);
|
||||||
|
}
|
||||||
|
|
||||||
BF_EXPORT void BF_CALLTYPE Gfx_Texture_Delete(TextureSegment* textureSegment)
|
BF_EXPORT void BF_CALLTYPE Gfx_Texture_Delete(TextureSegment* textureSegment)
|
||||||
{
|
{
|
||||||
textureSegment->mTexture->Release();
|
textureSegment->mTexture->Release();
|
||||||
|
|
|
@ -146,7 +146,8 @@ enum CullMode : int8
|
||||||
enum TextureFlag : int8
|
enum TextureFlag : int8
|
||||||
{
|
{
|
||||||
TextureFlag_Additive = 1,
|
TextureFlag_Additive = 1,
|
||||||
TextureFlag_NoPremult = 2
|
TextureFlag_NoPremult = 2,
|
||||||
|
TextureFlag_AllowRead = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VertexDefData
|
struct VertexDefData
|
||||||
|
|
|
@ -22,6 +22,7 @@ public:
|
||||||
|
|
||||||
virtual void Blt(ImageData* imageData, int x, int y) { };
|
virtual void Blt(ImageData* imageData, int x, int y) { };
|
||||||
virtual void SetBits(int destX, int destY, int destWidth, int destHeight, int srcPitch, uint32* bits) {}
|
virtual void SetBits(int destX, int destY, int destWidth, int destHeight, int srcPitch, uint32* bits) {}
|
||||||
|
virtual void GetBits(int srcX, int srcY, int srcWidth, int srcHeight, int destPitch, uint32* bits) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextureSegment
|
class TextureSegment
|
||||||
|
|
|
@ -216,6 +216,48 @@ void DXTexture::SetBits(int destX, int destY, int destWidth, int destHeight, int
|
||||||
mRenderDevice->mD3DDeviceContext->UpdateSubresource(mD3DTexture, 0, &box, bits, srcPitch * sizeof(uint32), 0);
|
mRenderDevice->mD3DDeviceContext->UpdateSubresource(mD3DTexture, 0, &box, bits, srcPitch * sizeof(uint32), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DXTexture::GetBits(int srcX, int srcY, int srcWidth, int srcHeight, int destPitch, uint32* bits)
|
||||||
|
{
|
||||||
|
D3D11_TEXTURE2D_DESC texDesc;
|
||||||
|
texDesc.ArraySize = 1;
|
||||||
|
texDesc.BindFlags = 0;
|
||||||
|
texDesc.CPUAccessFlags = 0;
|
||||||
|
texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
texDesc.Width = srcWidth;
|
||||||
|
texDesc.Height = srcHeight;
|
||||||
|
texDesc.MipLevels = 1;
|
||||||
|
texDesc.MiscFlags = 0;
|
||||||
|
texDesc.SampleDesc.Count = 1;
|
||||||
|
texDesc.SampleDesc.Quality = 0;
|
||||||
|
texDesc.Usage = D3D11_USAGE_STAGING;
|
||||||
|
texDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
||||||
|
|
||||||
|
D3D11_BOX srcBox = { 0 };
|
||||||
|
srcBox.left = srcX;
|
||||||
|
srcBox.top = srcY;
|
||||||
|
srcBox.right = srcX + srcWidth;
|
||||||
|
srcBox.bottom = srcY + srcHeight;
|
||||||
|
srcBox.back = 1;
|
||||||
|
|
||||||
|
ID3D11Texture2D *texture;
|
||||||
|
DXCHECK(mRenderDevice->mD3DDevice->CreateTexture2D(&texDesc, 0, &texture));
|
||||||
|
mRenderDevice->mD3DDeviceContext->CopySubresourceRegion(texture, 0, 0, 0, 0, mD3DTexture, 0, &srcBox);
|
||||||
|
|
||||||
|
D3D11_MAPPED_SUBRESOURCE mapTex;
|
||||||
|
DXCHECK(mRenderDevice->mD3DDeviceContext->Map(texture, 0, D3D11_MAP_READ, NULL, &mapTex));
|
||||||
|
|
||||||
|
uint8* srcPtr = (uint8*) mapTex.pData;
|
||||||
|
uint8* destPtr = (uint8*) bits;
|
||||||
|
for (int y = 0; y < srcHeight; y++)
|
||||||
|
{
|
||||||
|
memcpy(destPtr, srcPtr, srcWidth*sizeof(uint32));
|
||||||
|
srcPtr += mapTex.RowPitch;
|
||||||
|
destPtr += destPitch * 4;
|
||||||
|
}
|
||||||
|
mRenderDevice->mD3DDeviceContext->Unmap(texture, 0);
|
||||||
|
texture->Release();
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
||||||
static int GetPowerOfTwo(int input)
|
static int GetPowerOfTwo(int input)
|
||||||
|
|
|
@ -72,6 +72,7 @@ public:
|
||||||
virtual void PhysSetAsTarget() override;
|
virtual void PhysSetAsTarget() override;
|
||||||
virtual void Blt(ImageData* imageData, int x, int y) override;
|
virtual void Blt(ImageData* imageData, int x, int y) override;
|
||||||
virtual void SetBits(int destX, int destY, int destWidth, int destHeight, int srcPitch, uint32* bits) override;
|
virtual void SetBits(int destX, int destY, int destWidth, int destHeight, int srcPitch, uint32* bits) override;
|
||||||
|
virtual void GetBits(int srcX, int srcY, int srcWidth, int srcHeight, int destPitch, uint32* bits) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DXShaderParam : public ShaderParam
|
class DXShaderParam : public ShaderParam
|
||||||
|
|
BIN
IDE/dist/images/DarkTheme.png
vendored
Normal file
BIN
IDE/dist/images/DarkTheme.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
IDE/dist/images/LaoUI.ttf
vendored
Normal file
BIN
IDE/dist/images/LaoUI.ttf
vendored
Normal file
Binary file not shown.
|
@ -215,9 +215,9 @@ namespace IDE.ui
|
||||||
if (atError)
|
if (atError)
|
||||||
bkgColor = 0xFF800000;
|
bkgColor = 0xFF800000;
|
||||||
if (gApp.IsCompiling)
|
if (gApp.IsCompiling)
|
||||||
bkgColor = 0xFF303060;
|
bkgColor = 0xFF35306A;
|
||||||
else if (gApp.mDebugger.mIsRunning)
|
else if (gApp.mDebugger.mIsRunning)
|
||||||
bkgColor = 0xFFCA5100;
|
bkgColor = 0xFFB65D08;
|
||||||
else if (gApp.AreTestsRunning())
|
else if (gApp.AreTestsRunning())
|
||||||
bkgColor = 0xFF562143;
|
bkgColor = 0xFF562143;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue