Removed redundant code

This commit is contained in:
Anthony Calosa
2019-09-04 12:23:36 +08:00
parent 51ea20b1df
commit 5876ee8220

View File

@@ -505,14 +505,25 @@ public class MatchScreen extends FScreen {
float x = topPlayerPanel.getField().getLeft();
float y = midField - topPlayerPanel.getField().getHeight();
float w = getWidth() - x;
if(FModel.getPreferences().getPrefBoolean(FPref.UI_DYNAMIC_PLANECHASE_BG)
&& hasActivePlane())
setPlanarBG(g, getPlaneName(), x, y, w, midField);
else {
float bgFullWidth;
float scaledbgHeight;
float bgFullWidth, scaledbgHeight;
float bgHeight = midField + bottomPlayerPanel.getField().getHeight() - y;
if(FModel.getPreferences().getPrefBoolean(FPref.UI_DYNAMIC_PLANECHASE_BG)
&& hasActivePlane()) {
String imageName = getPlaneName()
.replace(" ", "_")
.replace("'", "")
.replace("-", "");
if (FSkinTexture.getValues().contains(imageName)) {
bgFullWidth = bgHeight * FSkinTexture.valueOf(imageName).getWidth() / FSkinTexture.valueOf(imageName).getHeight();
if (bgFullWidth < w) {
scaledbgHeight = w * (bgHeight / bgFullWidth);
bgFullWidth = w;
bgHeight = scaledbgHeight;
}
g.drawImage(FSkinTexture.valueOf(imageName), x + (w - bgFullWidth) / 2, y, bgFullWidth, bgHeight, true);
}
}
else {
bgFullWidth = bgHeight * FSkinTexture.BG_MATCH.getWidth() / FSkinTexture.BG_MATCH.getHeight();
if (bgFullWidth < w) {
scaledbgHeight = w * (bgHeight / bgFullWidth);
@@ -657,34 +668,5 @@ public class MatchScreen extends FScreen {
}
return false;
}
private void setPlanarBG(Graphics g, String planeName, float x, float y, float w, float midField ){
float planeFullWidth;
float scaledPlaneHeight;
float planeHeight = midField + bottomPlayerPanel.getField().getHeight() - y;
String imageName = planeName
.replace(" ", "_")
.replace("'", "")
.replace("-", "");
if (FSkinTexture.getValues().contains(imageName))
{
planeFullWidth = planeHeight * FSkinTexture.valueOf(imageName).getWidth() / FSkinTexture.valueOf(imageName).getHeight();
if (planeFullWidth < w) {
scaledPlaneHeight = w * (planeHeight / planeFullWidth);
planeFullWidth = w;
planeHeight = scaledPlaneHeight;
}
g.drawImage(FSkinTexture.valueOf(imageName), x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight, true);
}
else
{
planeFullWidth = planeHeight * FSkinTexture.BG_MATCH.getWidth() / FSkinTexture.BG_MATCH.getHeight();
if (planeFullWidth < w) {
scaledPlaneHeight = w * (planeHeight / planeFullWidth);
planeFullWidth = w;
planeHeight = scaledPlaneHeight;
}
g.drawImage(FSkinTexture.BG_MATCH, x + (w - planeFullWidth) / 2, y, planeFullWidth, planeHeight);
}
}
}
}