ColliderComponent hidden prop
This commit is contained in:
@ -49,20 +49,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
finalRect.w = finalRect.w*scale;
|
||||
finalRect.h = finalRect.h*scale;
|
||||
|
||||
// x0 = x0*scale;
|
||||
// x1 = x1*scale;
|
||||
// y0 = y0*scale;
|
||||
// y1 = y1*scale;
|
||||
|
||||
// printf("finalRect x:%d, y:%d, w:%d, h:%d \n",finalRect.x,finalRect.y,finalRect.w,finalRect.h);
|
||||
|
||||
// destRect.x = destRect.x*scale;
|
||||
// destRect.y = destRect.y*scale;
|
||||
// destRect.w = destRect.w*scale;
|
||||
// destRect.h = destRect.h*scale;
|
||||
// colsRemainder = colsRemainder*scale;
|
||||
// rowsRemainder = rowsRemainder*scale;
|
||||
|
||||
for (int i=0; i<9; i++)
|
||||
{
|
||||
switch(i)
|
||||
@ -72,7 +58,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
srcRect.y = 0;
|
||||
srcRect.w = x0;
|
||||
srcRect.h = y0;
|
||||
// printf("tile zero.w or x0: %d\n",x0);
|
||||
destRect.w = srcRect.w;
|
||||
destRect.h = srcRect.h;
|
||||
break;
|
||||
@ -91,8 +76,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
srcRect.h = y0;
|
||||
destRect.w = srcRect.w;
|
||||
destRect.h = srcRect.h;
|
||||
// printf("srcRect.x: %d",srcRect.x);
|
||||
// printf("UI9Slice #2 srcRect x:%d y:%d w:%d h:%d \n",srcRect.x,srcRect.y,srcRect.w,srcRect.h);
|
||||
break;
|
||||
case 3:
|
||||
srcRect.x = 0;
|
||||
@ -150,14 +133,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
destRect.w = 0;
|
||||
destRect.h = 0;
|
||||
}
|
||||
// These will be the same for each SDL_Rect except if there's a scaling int, which still needs to be implemented
|
||||
// destRect.w = srcRect.w*scale;
|
||||
// destRect.h = srcRect.h*scale;
|
||||
|
||||
// x0 = x0*scale;
|
||||
// x1 = x1*scale;
|
||||
// y0 = y0*scale;
|
||||
// y1 = y1*scale;
|
||||
|
||||
// Calculate where and how many tiles to place
|
||||
// We only need one instance of each of these in each corner or slices 0,2,6,8
|
||||
@ -184,9 +159,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
destRect.y = finalRect.y+(finalRect.h-srcRect.h*scale);
|
||||
}
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
// printf("Corner Slice\n");
|
||||
// printf("srcRect x:%d, y:%d, w:%d, h:%d \n",srcRect.x,srcRect.y,srcRect.w,srcRect.h);
|
||||
// printf("destRect x:%d, y:%d, w:%d, h:%d \n\n",destRect.x,destRect.y,destRect.w,destRect.h);
|
||||
}
|
||||
// Slices 1,7 need to be repeated in a row
|
||||
if (i==1||i==7)
|
||||
@ -198,9 +170,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
destRect.x = finalRect.x+(x0*scale+c*(x1*scale-x0*scale));
|
||||
destRect.y = finalRect.y;
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
// printf("Top Slice (1) \n");
|
||||
// printf("srcRect x:%d, y:%d, w:%d, h:%d \n",srcRect.x,srcRect.y,srcRect.w,srcRect.h);
|
||||
// printf("destRect x:%d, y:%d, w:%d, h:%d \n\n",destRect.x,destRect.y,destRect.w,destRect.h);
|
||||
}
|
||||
if (colsRemainder>0){
|
||||
destRect.x = finalRect.x+(x0*scale+cols*(x1*scale-x0*scale));
|
||||
@ -208,9 +177,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
srcRect.w = colsRemainder;
|
||||
destRect.w = colsRemainder;
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
// printf("Top Slice (1) \n");
|
||||
// printf("srcRect x:%d, y:%d, w:%d, h:%d \n",srcRect.x,srcRect.y,srcRect.w,srcRect.h);
|
||||
// printf("destRect x:%d, y:%d, w:%d, h:%d \n\n",destRect.x,destRect.y,destRect.w,destRect.h);
|
||||
}
|
||||
}
|
||||
if (i==7)
|
||||
@ -220,7 +186,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
destRect.x = finalRect.x+(x0*scale+c*(x1*scale-x0*scale));
|
||||
destRect.y = finalRect.y+(finalRect.h-(srcH-y1)*scale);
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
|
||||
}
|
||||
if (colsRemainder>0){
|
||||
destRect.x = finalRect.x+(x0*scale+cols*(x1*scale-x0*scale));
|
||||
@ -228,7 +193,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
srcRect.w = colsRemainder;
|
||||
destRect.w = colsRemainder;
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -242,7 +206,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
destRect.x = finalRect.x;
|
||||
destRect.y = finalRect.y+(y0*scale+r*(y1-y0)*scale);
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
|
||||
}
|
||||
if (rowsRemainder>0){
|
||||
destRect.x = finalRect.x;
|
||||
@ -250,7 +213,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
srcRect.h = rowsRemainder;
|
||||
destRect.h = rowsRemainder;
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
|
||||
}
|
||||
}
|
||||
if (i==5)
|
||||
@ -260,7 +222,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
destRect.x = finalRect.x+(finalRect.w-(srcW-x1)*scale);
|
||||
destRect.y = finalRect.y+(y0*scale+r*(y1-y0)*scale);
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
|
||||
}
|
||||
if (rowsRemainder>0){
|
||||
destRect.x = finalRect.x+(finalRect.w-(srcW-x1)*scale);
|
||||
@ -268,7 +229,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
srcRect.h = rowsRemainder;
|
||||
destRect.h = rowsRemainder;
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -284,7 +244,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
destRect.x = finalRect.x+(x0*scale+c*(x1-x0)*scale);
|
||||
destRect.y = finalRect.y+(y0*scale+rowY*scale);
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
|
||||
}
|
||||
if (colsRemainder>0)
|
||||
{
|
||||
@ -293,7 +252,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
srcRect.w = colsRemainder;
|
||||
destRect.w = colsRemainder;
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
|
||||
}
|
||||
}
|
||||
if (rowsRemainder>0)
|
||||
@ -307,7 +265,6 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
srcRect.w = (srcW-x0-(srcW-x1));
|
||||
destRect.w = (srcW-x0-(srcW-x1));
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
|
||||
}
|
||||
}
|
||||
if(rowsRemainder>0&&colsRemainder>0)
|
||||
@ -319,15 +276,13 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
destRect.w = colsRemainder;
|
||||
destRect.h = rowsRemainder;
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
// printf("destRect x:%d, y:%d, w:%d, h:%d \n",destRect.x,destRect.y,destRect.w,destRect.h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Need to take in variables: (srcRect, desiredRect)
|
||||
|
||||
void UINineSlice::AddSlice(SDL_Rect srcRect, SDL_Rect destRect, int scale)
|
||||
{
|
||||
// printf("adding a 9slice element");
|
||||
auto& slice(manager.addEntity());
|
||||
SDL_Rect scaledRect = SDL_Rect();
|
||||
scaledRect.x = destRect.x;
|
||||
|
@ -37,22 +37,10 @@ void UIText::ParseString(std::string inputText, int x, int y, int letterScale, s
|
||||
int posX = x;
|
||||
int posY = y;
|
||||
int i = 0;
|
||||
// printf(inputText);
|
||||
char current = inputText[i];
|
||||
// const char* newLineChar{10};
|
||||
|
||||
// std::vector<char> writableStr(inputText.begin(), inputText.end());
|
||||
// writableStr.push_back('\0');
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
// for (int i = 0; i < writableStr.size(); i++)
|
||||
// {
|
||||
// if (writableStr.at(i) == '\n')
|
||||
// {
|
||||
// printf("found new line");
|
||||
// }
|
||||
// }
|
||||
++i;
|
||||
if (strcmp(¤t,"\n")!=0)
|
||||
{
|
||||
@ -60,7 +48,6 @@ void UIText::ParseString(std::string inputText, int x, int y, int letterScale, s
|
||||
}
|
||||
else
|
||||
{
|
||||
// printf("new line detected/n");
|
||||
posX = x;
|
||||
posY += letterHeight;
|
||||
}
|
||||
@ -74,12 +61,7 @@ void UIText::AddLetter(int xpos, int ypos, char crnt, std::string tag, int lttrS
|
||||
{
|
||||
auto& letter(manager.addEntity());
|
||||
letter.addComponent<TransformComponent>(xpos*lttrScale, ypos*lttrScale, letterWidth, letterHeight, 1);
|
||||
// printf("Scale: %d\n",scale);
|
||||
letter.addComponent<SpriteComponent>("font", SpriteComponent::spriteText, crnt, letterWidth, letterHeight, lttrScale);
|
||||
letter.setTag(tag);
|
||||
letter.addGroup(Game::groupUI_Layer1);
|
||||
}
|
||||
|
||||
// void UIText::RemoveLetter()
|
||||
// {
|
||||
// }
|
||||
|
@ -23,7 +23,6 @@ public:
|
||||
UIText(std::string inputText, std::string texID, int x, int y, int letterW, int letterH, int lScale);
|
||||
~UIText();
|
||||
|
||||
// void SetCharClips(SDL_Texture* fontTex, int x, int y, int letterW, int letterH);
|
||||
void AddLetter(int xpos, int ypos, char crnt, std::string tag, int lttrScale);
|
||||
void ParseString(std::string inputText, int x, int y, int letterScale, std::string tag);
|
||||
int scale;
|
||||
|
Reference in New Issue
Block a user