Remove some unused code

This commit is contained in:
UnknownShadow200 2018-03-23 22:34:35 +11:00
parent 2f07a00b54
commit 3852e8e5c1
10 changed files with 34 additions and 73 deletions

View File

@ -5,6 +5,16 @@ using ClassicalSharp.GraphicsAPI;
namespace ClassicalSharp {
/// <summary> Stores the four texture coordinates that describe a textured quad. </summary>
public struct TextureRec {
public float U1, V1, U2, V2;
public TextureRec(float u, float v, float uWidth, float vHeight) {
U1 = u; V1 = v;
U2 = u + uWidth; V2 = v + vHeight;
}
}
/// <summary> Contains the information necessary to describe a 2D textured quad. </summary>
public struct Texture {

View File

@ -296,7 +296,6 @@
<Compile Include="Utils\Options.cs" />
<Compile Include="Utils\ReadOnlyStream.cs" />
<Compile Include="Utils\Respawn.cs" />
<Compile Include="Utils\TextureRectangle.cs" />
<Compile Include="Utils\StringBuffer.cs" />
<Compile Include="Utils\Utils.cs" />
<Compile Include="Utils\Utils.Math.cs" />

View File

@ -1,30 +0,0 @@
// Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
using System;
namespace ClassicalSharp {
/// <summary> Stores the four texture coordinates that describe a textured quad. </summary>
public struct TextureRec {
public float U1, V1, U2, V2;
public TextureRec(float u, float v, float uWidth, float vHeight) {
U1 = u; V1 = v;
U2 = u + uWidth; V2 = v + vHeight;
}
public static TextureRec FromPoints(float u1, float v1, float u2, float v2) {
TextureRec rec;
rec.U1 = u1; rec.V1 = v1;
rec.U2 = u2; rec.V2 = v2;
return rec;
}
public override string ToString() {
return String.Format("{0}, {1} : {2}, {3}", U1, V1, U2, V2);
}
public void SwapU() {
float u2 = U2; U2 = U1; U1 = u2;
}
}
}

View File

@ -21,21 +21,3 @@ Size2D Size2D_Make(Int32 width, Int32 height) {
Point2D Point2D_Make(Int32 x, Int32 y) {
Point2D p; p.X = x; p.Y = y; return p;
}
TextureRec TextureRec_FromRegion(Real32 u, Real32 v, Real32 uWidth, Real32 vHeight) {
TextureRec rec;
rec.U1 = u; rec.V1 = v;
rec.U2 = u + uWidth; rec.V2 = v + vHeight;
return rec;
}
TextureRec TextureRec_FromPoints(Real32 u1, Real32 v1, Real32 u2, Real32 v2) {
TextureRec rec;
rec.U1 = u1; rec.V1 = v1;
rec.U2 = u2; rec.V2 = v2;
return rec;
}
void TextureRec_SwapU(TextureRec* rec) {
Real32 u2 = rec->U2; rec->U2 = rec->U1; rec->U1 = u2;
}

View File

@ -24,13 +24,5 @@ bool Rectangle2D_Equals(Rectangle2D a, Rectangle2D b);
Size2D Size2D_Make(Int32 width, Int32 height);
Point2D Point2D_Make(Int32 x, Int32 y);
/* Stores the four texture coordinates that describe a textured quad. */
typedef struct TextureRec_ { Real32 U1, V1, U2, V2; } TextureRec;
/* Constructs a texture rectangle from origin and size. */
TextureRec TextureRec_FromRegion(Real32 u, Real32 v, Real32 uWidth, Real32 vHeight);
/* Constructs a texture rectangle from four points. */
TextureRec TextureRec_FromPoints(Real32 u1, Real32 v1, Real32 u2, Real32 v2);
/* Swaps U1 and U2 of a texture rectangle. */
void TextureRec_SwapU(TextureRec* rec);
#endif

View File

@ -331,7 +331,8 @@ void ResolutionCommand_Execute(STRING_PURE String* args, UInt32 argsCount) {
} else if (width <= 0 || height <= 0) {
Chat_AddRaw(tmp, "&e/client: &cWidth and height must be above 0.");
} else {
Window_SetClientSize(Size2D_Make(width, height));
Size2D size = { width, height };
Window_SetClientSize(size);
Options_SetInt32(OPTION_WINDOW_WIDTH, width);
Options_SetInt32(OPTION_WINDOW_HEIGHT, height);
}

View File

@ -477,7 +477,7 @@ void ShadowComponent_DrawCoords(VertexP3fT2fC4b** vertices, Entity* entity, Shad
void ShadowComponent_DrawSquareShadow(VertexP3fT2fC4b** vertices, Real32 y, Real32 x, Real32 z) {
PackedCol col = PACKEDCOL_CONST(255, 255, 255, 220);
TextureRec rec = TextureRec_FromRegion(63.0f / 128.0f, 63.0f / 128.0f, 1.0f / 128.0f, 1.0f / 128.0f);
TextureRec rec = { 63.0f / 128.0f, 63.0f / 128.0f, 64.0f / 128.0f, 64.0f / 128.0f };
VertexP3fT2fC4b* ptr = *vertices;
VertexP3fT2fC4b v; v.Y = y; v.Col = col;

View File

@ -50,10 +50,12 @@ TextureRec Atlas1D_TexRec(TextureLoc texLoc, Int32 uCount, Int32* index) {
Int32 y = texLoc % Atlas1D_ElementsPerAtlas;
/* Adjust coords to be slightly inside - fixes issues with AMD/ATI cards. */
return TextureRec_FromRegion(
0.0f, y * Atlas1D_InvElementSize,
(uCount - 1) + UV2_Scale,
UV2_Scale * Atlas1D_InvElementSize);
TextureRec rec;
rec.U1 = 0.0f;
rec.V1 = y * Atlas1D_InvElementSize;
rec.U2 = (uCount - 1) + UV2_Scale;
rec.V2 = rec.V1 + UV2_Scale * Atlas1D_InvElementSize;
return rec;
}
void Atlas1D_Make1DTexture(Int32 i, Int32 atlas1DHeight, Int32* index) {

View File

@ -98,9 +98,6 @@ void TextWidget_SetText(TextWidget* widget, STRING_PURE String* text) {
Texture Button_ShadowTex = { 0, 0, 0, 0, 0, 0.0f, 66.0f / 256.0f, 200.0f / 256.0f, 86.0f / 256.0f };
Texture Button_SelectedTex = { 0, 0, 0, 0, 0, 0.0f, 86.0f / 256.0f, 200.0f / 256.0f, 106.0f / 256.0f };
Texture Button_DisabledTex = { 0, 0, 0, 0, 0, 0.0f, 46.0f / 256.0f, 200.0f / 256.0f, 66.0f / 256.0f };
PackedCol Button_NormCol = PACKEDCOL_CONST(224, 224, 244, 255);
PackedCol Button_ActiveCol = PACKEDCOL_CONST(255, 255, 160, 255);
PackedCol Button_DisabledCol = PACKEDCOL_CONST(160, 160, 160, 255);
void ButtonWidget_Init(GuiElement* elem) {
ButtonWidget* widget = (ButtonWidget*)elem;
@ -152,7 +149,10 @@ void ButtonWidget_Render(GuiElement* elem, Real64 delta) {
GfxCommon_Draw2DTexture(&back, white);
}
PackedCol col = elemW->Disabled ? Button_DisabledCol : (elemW->Active ? Button_ActiveCol : Button_NormCol);
PackedCol normCol = PACKEDCOL_CONST(224, 224, 244, 255);
PackedCol activeCol = PACKEDCOL_CONST(255, 255, 160, 255);
PackedCol disabledCol = PACKEDCOL_CONST(160, 160, 160, 255);
PackedCol col = elemW->Disabled ? disabledCol : (elemW->Active ? activeCol : normCol);
Texture_RenderShaded(&widget->Texture, col);
}
@ -350,7 +350,7 @@ void HotbarWidget_RenderHotbarBlocks(HotbarWidget* widget) {
void HotbarWidget_RepositonBackgroundTexture(HotbarWidget* widget) {
Widget* w = &widget->Base;
TextureRec rec = TextureRec_FromPoints(0.0f, 0.0f, 182.0f / 256.0f, 22.0f / 256.0f);
TextureRec rec = { 0.0f, 0.0f, 182.0f / 256.0f, 22.0f / 256.0f };
widget->BackTex = Texture_FromRec(0, w->X, w->Y, w->Width, w->Height, rec);
}
@ -362,7 +362,7 @@ void HotbarWidget_RepositionSelectionTexture(HotbarWidget* widget) {
Int32 vSize = (Int32)(22.0f * scale);
Int32 y = w->Y + (w->Height - (Int32)(23.0f * scale));
TextureRec rec = TextureRec_FromPoints(0.0f, 22.0f / 256.0f, 24.0f / 256.0f, 22.0f / 256.0f);
TextureRec rec = { 0.0f, 22.0f / 256.0f, 24.0f / 256.0f, 44.0f / 256.0f };
widget->SelTex = Texture_FromRec(0, 0, y, hSize, vSize, rec);
}

View File

@ -527,12 +527,16 @@ void Window_SetBounds(Rectangle2D rect) {
SetWindowPos(win_Handle, NULL, rect.X, rect.Y, rect.Width, rect.Height, 0);
}
Point2D Window_GetLocation(void) { return Point2D_Make(win_Bounds.X, win_Bounds.Y); }
Point2D Window_GetLocation(void) {
Point2D point = { win_Bounds.X, win_Bounds.Y }; return point;
}
void Window_SetLocation(Point2D point) {
SetWindowPos(win_Handle, NULL, point.X, point.Y, 0, 0, SWP_NOSIZE);
}
Size2D Window_GetSize(void) { return Size2D_Make(win_Bounds.Width, win_Bounds.Height); }
Size2D Window_GetSize(void) {
Size2D size = { win_Bounds.Width, win_Bounds.Height }; return size;
}
void Window_SetSize(Size2D size) {
SetWindowPos(win_Handle, NULL, 0, 0, size.Width, size.Height, SWP_NOMOVE);
}
@ -544,7 +548,7 @@ void Window_SetClientRectangle(Rectangle2D rect) {
}
Size2D Window_GetClientSize(void) {
return Size2D_Make(win_ClientRect.Width, win_ClientRect.Height);
Size2D size = { win_ClientRect.Width, win_ClientRect.Height }; return size;
}
void Window_SetClientSize(Size2D size) {
DWORD style = GetWindowLongA(win_Handle, GWL_STYLE);
@ -553,7 +557,8 @@ void Window_SetClientSize(Size2D size) {
rect.right = size.Width; rect.bottom = size.Height;
AdjustWindowRect(&rect, style, false);
Window_SetSize(Size2D_Make(RECT_WIDTH(rect), RECT_HEIGHT(rect)));
Size2D size = { RECT_WIDTH(rect), RECT_HEIGHT(rect) };
Window_SetSize(size);
}
/* TODO: Set window icon