UI tweaks for more layers and debug
This commit is contained in:
@@ -25,7 +25,7 @@ UINineSlice::~UINineSlice()
|
||||
|
||||
}
|
||||
|
||||
void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, int x1, int y0, int y1, SDL_Rect finalRect,int scale)
|
||||
void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, int x1, int y0, int y1, SDL_Rect finalRect,int scale, Game::groupLabels group)
|
||||
{
|
||||
// Note about the variables: The source texture is what everything is drawn from, with srcW and srcH defining the size of that texture and x0 x1 being the vertical slices position across the x axis, and the y0, y1 being the horizontal slices. This is also in the project readme with an ASCII art diagram. finalRect refers to the Rectangle that describes the area of the screen in which we want the 9-sliced source to appear in it's final in-game rendering.
|
||||
|
||||
@@ -158,7 +158,7 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
destRect.x = finalRect.x+(finalRect.w-srcRect.w*scale);
|
||||
destRect.y = finalRect.y+(finalRect.h-srcRect.h*scale);
|
||||
}
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
AddSlice(srcRect,destRect,scale,group);
|
||||
}
|
||||
// Slices 1,7 need to be repeated in a row
|
||||
if (i==1||i==7)
|
||||
@@ -169,14 +169,14 @@ 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);
|
||||
AddSlice(srcRect,destRect,scale,group);
|
||||
}
|
||||
if (colsRemainder>0){
|
||||
destRect.x = finalRect.x+(x0*scale+cols*(x1*scale-x0*scale));
|
||||
destRect.y = finalRect.y;
|
||||
srcRect.w = colsRemainder;
|
||||
destRect.w = colsRemainder;
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
AddSlice(srcRect,destRect,scale,group);
|
||||
}
|
||||
}
|
||||
if (i==7)
|
||||
@@ -185,14 +185,14 @@ 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);
|
||||
AddSlice(srcRect,destRect,scale,group);
|
||||
}
|
||||
if (colsRemainder>0){
|
||||
destRect.x = finalRect.x+(x0*scale+cols*(x1*scale-x0*scale));
|
||||
destRect.y = finalRect.y+(finalRect.h-(srcH-y1)*scale);
|
||||
srcRect.w = colsRemainder;
|
||||
destRect.w = colsRemainder;
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
AddSlice(srcRect,destRect,scale,group);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -205,14 +205,14 @@ 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);
|
||||
AddSlice(srcRect,destRect,scale,group);
|
||||
}
|
||||
if (rowsRemainder>0){
|
||||
destRect.x = finalRect.x;
|
||||
destRect.y = finalRect.y+(y0*scale+rows*(y1-y0)*scale);
|
||||
srcRect.h = rowsRemainder;
|
||||
destRect.h = rowsRemainder;
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
AddSlice(srcRect,destRect,scale,group);
|
||||
}
|
||||
}
|
||||
if (i==5)
|
||||
@@ -221,14 +221,14 @@ 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);
|
||||
AddSlice(srcRect,destRect,scale,group);
|
||||
}
|
||||
if (rowsRemainder>0){
|
||||
destRect.x = finalRect.x+(finalRect.w-(srcW-x1)*scale);
|
||||
destRect.y = finalRect.y+(y0*scale+rows*(y1-y0)*scale);
|
||||
srcRect.h = rowsRemainder;
|
||||
destRect.h = rowsRemainder;
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
AddSlice(srcRect,destRect,scale,group);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,7 @@ 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);
|
||||
AddSlice(srcRect,destRect,scale,group);
|
||||
}
|
||||
if (colsRemainder>0)
|
||||
{
|
||||
@@ -251,7 +251,7 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
destRect.y = finalRect.y+(y0*scale+rowY*scale);
|
||||
srcRect.w = colsRemainder;
|
||||
destRect.w = colsRemainder;
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
AddSlice(srcRect,destRect,scale,group);
|
||||
}
|
||||
}
|
||||
if (rowsRemainder>0)
|
||||
@@ -264,7 +264,7 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
destRect.h = rowsRemainder;
|
||||
srcRect.w = (srcW-x0-(srcW-x1));
|
||||
destRect.w = (srcW-x0-(srcW-x1));
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
AddSlice(srcRect,destRect,scale,group);
|
||||
}
|
||||
}
|
||||
if(rowsRemainder>0&&colsRemainder>0)
|
||||
@@ -275,13 +275,13 @@ void UINineSlice::MakeSlices(std::string texture, int srcW, int srcH, int x0, in
|
||||
srcRect.h = rowsRemainder;
|
||||
destRect.w = colsRemainder;
|
||||
destRect.h = rowsRemainder;
|
||||
AddSlice(srcRect,destRect,scale);
|
||||
AddSlice(srcRect,destRect,scale,group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UINineSlice::AddSlice(SDL_Rect srcRect, SDL_Rect destRect, int scale)
|
||||
void UINineSlice::AddSlice(SDL_Rect srcRect, SDL_Rect destRect, int scale, Game::groupLabels group)
|
||||
{
|
||||
auto& slice(manager.addEntity());
|
||||
SDL_Rect scaledRect = SDL_Rect();
|
||||
@@ -291,5 +291,5 @@ void UINineSlice::AddSlice(SDL_Rect srcRect, SDL_Rect destRect, int scale)
|
||||
scaledRect.h = destRect.h*scale;
|
||||
slice.addComponent<TransformComponent>(scaledRect.x, scaledRect.y, scaledRect.w, scaledRect.h, 1);
|
||||
slice.addComponent<SpriteComponent>("textBox",SpriteComponent::spriteUIL0,srcRect,scaledRect);
|
||||
slice.addGroup(Game::groupUI_Layer0);
|
||||
slice.addGroup(group);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user