Better News

This commit is contained in:
kirillsaint 2023-11-01 22:40:41 +06:00
parent 7d8e00a983
commit bc9fd11f8f
6 changed files with 206 additions and 66 deletions

View File

@ -309,13 +309,13 @@ public class Client {
Client.logger.info("STARTING > launching-detector"); Client.logger.info("STARTING > launching-detector");
Requests.post("https://api.silentclient.net/_next/launch_v2", new JSONObject().put("branch", getBuildData().getBranch()).toString()); Requests.post("https://api.silentclient.net/_next/launch_v2", new JSONObject().put("branch", getBuildData().getBranch()).toString());
logger.info("STARTING > news"); logger.info("STARTING > promo");
String content = Requests.get("https://api.silentclient.net/_next/news/latest"); String panelContent = Requests.get("https://assets.silentclient.net/client/promo.json");
if(content != null) { if(panelContent != null) {
try { try {
NewsResponse newsResponse = getGson().fromJson(content, NewsResponse.class); PromoController.PromoResponse promoResponse = getGson().fromJson(panelContent, PromoController.PromoResponse.class);
GuiNews.news = newsResponse; PromoController.setResponse(promoResponse);
} catch (Exception err) { } catch (Exception err) {
logger.catching(err); logger.catching(err);
} }

View File

@ -5,7 +5,6 @@ import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client; import net.silentclient.client.Client;
import net.silentclient.client.gui.SilentScreen; import net.silentclient.client.gui.SilentScreen;
@ -13,25 +12,17 @@ import net.silentclient.client.gui.elements.Button;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.util.RenderUtil; import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.utils.MouseCursorHandler; import net.silentclient.client.utils.MouseCursorHandler;
import net.silentclient.client.utils.SCTextureManager; import net.silentclient.client.utils.PromoController;
import net.silentclient.client.utils.TimerUtils; import net.silentclient.client.utils.TimerUtils;
import net.silentclient.client.utils.types.NewsResponse;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.Random;
public class GuiNews extends SilentScreen { public class GuiNews extends SilentScreen {
public static ResourceLocation imageLocation = null;
public static BufferedImage image = null;
public static boolean loading = false;
public static boolean initPanel = false;
private TimerUtils logoTimer = new TimerUtils(); private TimerUtils logoTimer = new TimerUtils();
private int logoY = 0; private int logoY = 0;
private final boolean firstTime; private final boolean firstTime;
public static NewsResponse news;
public GuiNews() { public GuiNews() {
this.firstTime = false; this.firstTime = false;
@ -41,25 +32,9 @@ public class GuiNews extends SilentScreen {
this.firstTime = firstTime; this.firstTime = firstTime;
} }
public static void loadPanel() {
if(image == null && !loading && news != null) {
loading = true;
(new Thread("NewsThread") {
public void run() {
GuiNews.image = SCTextureManager.getImage(news.getItem().getCover());
GuiNews.loading = false;
}
}).start();
}
if(image != null && !initPanel) {
imageLocation = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("image_panel_" + new Random().nextLong(), new DynamicTexture(image));
initPanel = true;
}
}
@Override @Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) { public void drawScreen(int mouseX, int mouseY, float partialTicks) {
loadPanel(); PromoController.getResponse().update();
MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList); MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList);
GlStateManager.disableAlpha(); GlStateManager.disableAlpha();
Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks);
@ -71,11 +46,23 @@ public class GuiNews extends SilentScreen {
} }
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if(imageLocation != null) { if(PromoController.getResponse().getPanels().size() > 1) {
RenderUtil.drawImage(imageLocation, (this.width / 2) - (300 / 2), (this.height / 2) - (168 / 2) - 10, 300, 168, false); if(MouseUtils.isInside(mouseX, mouseY, 40, this.height / 2 - 10, 20, 20) || MouseUtils.isInside(mouseX, mouseY, this.width - 40 - 20, this.height / 2 - 10, 20, 20)) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
RenderUtil.drawImage(new ResourceLocation("silentclient/icons/back.png"), 40, this.height / 2 - 10, 20, 20);
RenderUtil.drawImage(new ResourceLocation("silentclient/icons/next.png"), this.width - 40 - 20, this.height / 2 - 10, 20, 20);
}
if(PromoController.getResponse().getCurrentPanel() != null) {
if(PromoController.getResponse().getCurrentPanel().getImageLocation() != null) {
RenderUtil.drawImage(PromoController.getResponse().getCurrentPanel().getImageLocation(), (this.width / 2) - (300 / 2), (this.height / 2) - (168 / 2) - 10, 300, 168, false);
if(MouseUtils.isInside(mouseX, mouseY, (this.width / 2) - (300 / 2), (this.height / 2) - (168 / 2) - 10, 300, 168)) { if(MouseUtils.isInside(mouseX, mouseY, (this.width / 2) - (300 / 2), (this.height / 2) - (168 / 2) - 10, 300, 168)) {
cursorType = MouseCursorHandler.CursorType.POINTER; cursorType = MouseCursorHandler.CursorType.POINTER;
} }
} else {
PromoController.getResponse().getCurrentPanel().loadImage();
}
} }
super.drawScreen(mouseX, mouseY, partialTicks); super.drawScreen(mouseX, mouseY, partialTicks);
@ -100,6 +87,7 @@ public class GuiNews extends SilentScreen {
Client.backgroundPanorama.updateWidthHeight(this.width, this.height); Client.backgroundPanorama.updateWidthHeight(this.width, this.height);
this.buttonList.add(new Button(1, (this.width / 2) - (98 / 2), this.height - 30, 98, 20, "Exit")); this.buttonList.add(new Button(1, (this.width / 2) - (98 / 2), this.height - 30, 98, 20, "Exit"));
super.initGui(); super.initGui();
PromoController.getResponse().setPanelIndex(0);
} }
@Override @Override
@ -112,11 +100,22 @@ public class GuiNews extends SilentScreen {
@Override @Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton); super.mouseClicked(mouseX, mouseY, mouseButton);
if(MouseUtils.isInside(mouseX, mouseY, (this.width / 2) - (300 / 2), (this.height / 2) - (168 / 2) - 10, 300, 168) && news != null) { if(PromoController.getResponse().getPanels().size() > 1) {
if(MouseUtils.isInside(mouseX, mouseY, 40, this.height / 2 - 10, 20, 20)) {
PromoController.getResponse().prevPanel();
return;
}
if(MouseUtils.isInside(mouseX, mouseY, this.width - 40 - 20, this.height / 2 - 10, 20, 20)) {
PromoController.getResponse().nextPanel();
return;
}
}
if(MouseUtils.isInside(mouseX, mouseY, (this.width / 2) - (300 / 2), (this.height / 2) - (168 / 2) - 10, 300, 168) && PromoController.getResponse().getCurrentPanel() != null && PromoController.getResponse().getCurrentPanel().getImageLocation() != null) {
try { try {
Class<?> oclass = Class.forName("java.awt.Desktop"); Class<?> oclass = Class.forName("java.awt.Desktop");
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); Object object = oclass.getMethod("getDesktop", new Class[0]).invoke(null, new Object[0]);
oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("https://silentclient.net/news/" + GuiNews.news.getItem().id)}); oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI(PromoController.getResponse().getCurrentPanel().getRedirectUrl())});
} catch (Throwable err) { } catch (Throwable err) {
err.printStackTrace(); err.printStackTrace();
} }

View File

@ -16,6 +16,7 @@ import net.silentclient.client.gui.silentmainmenu.components.AccountPicker;
import net.silentclient.client.gui.util.RenderUtil; import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.utils.ColorUtils; import net.silentclient.client.utils.ColorUtils;
import net.silentclient.client.utils.MouseCursorHandler; import net.silentclient.client.utils.MouseCursorHandler;
import net.silentclient.client.utils.PromoController;
import java.awt.*; import java.awt.*;
import java.io.IOException; import java.io.IOException;
@ -56,7 +57,7 @@ public class LiteMainMenu extends SilentScreen
@Override @Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) { public void drawScreen(int mouseX, int mouseY, float partialTicks) {
GuiNews.loadPanel(); PromoController.getResponse().update();
MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList); MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList);
GlStateManager.disableAlpha(); GlStateManager.disableAlpha();
Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks);
@ -74,14 +75,18 @@ public class LiteMainMenu extends SilentScreen
ColorUtils.setColor(-1); ColorUtils.setColor(-1);
Client.getInstance().getSilentFontRenderer().drawString(3, height - 14, "SLC Lite 1.8.9", 12, SilentFontRenderer.FontType.TITLE); Client.getInstance().getSilentFontRenderer().drawString(3, height - 14, "SLC Lite 1.8.9", 12, SilentFontRenderer.FontType.TITLE);
if(GuiNews.imageLocation != null) { if(PromoController.getResponse().getCurrentPanel() != null) {
if(PromoController.getResponse().getCurrentPanel().getImageLocation() != null) {
if(MouseUtils.isInside(mouseX, mouseY, this.width - 74, this.height - 42, 71, 40)) { if(MouseUtils.isInside(mouseX, mouseY, this.width - 74, this.height - 42, 71, 40)) {
cursorType = MouseCursorHandler.CursorType.POINTER; cursorType = MouseCursorHandler.CursorType.POINTER;
this.bannerAnimation.setAnimation(4, 20); this.bannerAnimation.setAnimation(4, 20);
} else { } else {
this.bannerAnimation.setAnimation(0, 30); this.bannerAnimation.setAnimation(0, 30);
} }
RenderUtil.drawImage(GuiNews.imageLocation, this.width - 74 + (-this.bannerAnimation.getValue()), this.height - 42 + (-this.bannerAnimation.getValue()), 71, 40, false); RenderUtil.drawImage(PromoController.getResponse().getCurrentPanel().getImageLocation(), this.width - 74 + (-this.bannerAnimation.getValue()), this.height - 42 + (-this.bannerAnimation.getValue()), 71, 40, false);
} else {
PromoController.getResponse().getCurrentPanel().loadImage();
}
} }
MouseCursorHandler.CursorType accountCursor = accountPicker.draw(mc, mouseX, mouseY); MouseCursorHandler.CursorType accountCursor = accountPicker.draw(mc, mouseX, mouseY);
@ -140,11 +145,11 @@ public class LiteMainMenu extends SilentScreen
@Override @Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton); super.mouseClicked(mouseX, mouseY, mouseButton);
if(MouseUtils.isInside(mouseX, mouseY, this.width - 74, this.height - 42, 71, 40)) { if(MouseUtils.isInside(mouseX, mouseY, this.width - 74, this.height - 42, 71, 40) && PromoController.getResponse().getCurrentPanel() != null && PromoController.getResponse().getCurrentPanel().getImageLocation() != null) {
try { try {
Class<?> oclass = Class.forName("java.awt.Desktop"); Class<?> oclass = Class.forName("java.awt.Desktop");
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); Object object = oclass.getMethod("getDesktop", new Class[0]).invoke(null, new Object[0]);
oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("https://silentclient.net/news/" + GuiNews.news.getItem().id)}); oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI(PromoController.getResponse().getCurrentPanel().getRedirectUrl())});
} catch (Throwable err) { } catch (Throwable err) {
err.printStackTrace(); err.printStackTrace();
} }

View File

@ -13,7 +13,6 @@ import net.silentclient.client.cosmetics.gui.CosmeticsGui;
import net.silentclient.client.gui.SilentScreen; import net.silentclient.client.gui.SilentScreen;
import net.silentclient.client.gui.elements.IconButton; import net.silentclient.client.gui.elements.IconButton;
import net.silentclient.client.gui.font.SilentFontRenderer; import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.lite.GuiNews;
import net.silentclient.client.gui.lite.LiteMainMenu; import net.silentclient.client.gui.lite.LiteMainMenu;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
@ -22,6 +21,7 @@ import net.silentclient.client.gui.silentmainmenu.components.MenuOption;
import net.silentclient.client.gui.theme.button.IButtonTheme; import net.silentclient.client.gui.theme.button.IButtonTheme;
import net.silentclient.client.gui.util.RenderUtil; import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.utils.MouseCursorHandler; import net.silentclient.client.utils.MouseCursorHandler;
import net.silentclient.client.utils.PromoController;
import net.silentclient.client.utils.SCTextureManager; import net.silentclient.client.utils.SCTextureManager;
import java.awt.*; import java.awt.*;
@ -79,7 +79,6 @@ public class MainMenuConcept extends SilentScreen {
@Override @Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) { public void drawScreen(int mouseX, int mouseY, float partialTicks) {
GuiNews.loadPanel();
MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList); MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList);
this.loadSkin(); this.loadSkin();
GlStateManager.disableAlpha(); GlStateManager.disableAlpha();
@ -93,12 +92,18 @@ public class MainMenuConcept extends SilentScreen {
RenderUtil.drawImage(new ResourceLocation("silentclient/images/steve.png"), width - 120, height / 2 - (75), 62, 150, false); RenderUtil.drawImage(new ResourceLocation("silentclient/images/steve.png"), width - 120, height / 2 - (75), 62, 150, false);
} }
if(GuiNews.imageLocation != null) { PromoController.getResponse().update();
if(PromoController.getResponse().getCurrentPanel() != null) {
if(PromoController.getResponse().getCurrentPanel().getImageLocation() != null) {
if(MouseUtils.isInside(mouseX, mouseY, 10, 10, 109, 63)) { if(MouseUtils.isInside(mouseX, mouseY, 10, 10, 109, 63)) {
cursorType = MouseCursorHandler.CursorType.POINTER; cursorType = MouseCursorHandler.CursorType.POINTER;
} }
RenderUtils.drawRect(10, 10, 109, 63, -1); RenderUtils.drawRect(10, 10, 109, 63, -1);
RenderUtil.drawImage(GuiNews.imageLocation, 12, 12, 105, 59, false); RenderUtil.drawImage(PromoController.getResponse().getCurrentPanel().getImageLocation(), 12, 12, 105, 59, false);
} else {
PromoController.getResponse().getCurrentPanel().loadImage();
}
} }
Client.getInstance().getSilentFontRenderer().drawString(3, height - 14, "Silent Client 1.8.9", 12, SilentFontRenderer.FontType.TITLE); Client.getInstance().getSilentFontRenderer().drawString(3, height - 14, "Silent Client 1.8.9", 12, SilentFontRenderer.FontType.TITLE);
@ -153,11 +158,11 @@ public class MainMenuConcept extends SilentScreen {
@Override @Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton); super.mouseClicked(mouseX, mouseY, mouseButton);
if(MouseUtils.isInside(mouseX, mouseY, 10, 10, 109, 63)) { if(MouseUtils.isInside(mouseX, mouseY, 10, 10, 109, 63) && PromoController.getResponse().getCurrentPanel() != null) {
try { try {
Class<?> oclass = Class.forName("java.awt.Desktop"); Class<?> oclass = Class.forName("java.awt.Desktop");
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); Object object = oclass.getMethod("getDesktop", new Class[0]).invoke(null, new Object[0]);
oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("https://silentclient.net/news/" + GuiNews.news.getItem().id)}); oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI(PromoController.getResponse().getCurrentPanel().getRedirectUrl())});
} catch (Throwable err) { } catch (Throwable err) {
err.printStackTrace(); err.printStackTrace();
} }

View File

@ -7,11 +7,11 @@ import net.silentclient.client.Client;
import net.silentclient.client.cosmetics.gui.CosmeticsGui; import net.silentclient.client.cosmetics.gui.CosmeticsGui;
import net.silentclient.client.gui.SilentScreen; import net.silentclient.client.gui.SilentScreen;
import net.silentclient.client.gui.font.SilentFontRenderer; import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.lite.GuiNews;
import net.silentclient.client.gui.lite.LiteMainMenu; import net.silentclient.client.gui.lite.LiteMainMenu;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
import net.silentclient.client.gui.util.RenderUtil; import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.utils.PromoController;
import java.awt.*; import java.awt.*;
import java.io.IOException; import java.io.IOException;
@ -31,7 +31,7 @@ public class SilentMainMenu extends SilentScreen {
@Override @Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) { public void drawScreen(int mouseX, int mouseY, float partialTicks) {
GuiNews.loadPanel(); PromoController.getResponse().update();
GlStateManager.disableAlpha(); GlStateManager.disableAlpha();
Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks);
GlStateManager.enableAlpha(); GlStateManager.enableAlpha();
@ -51,8 +51,12 @@ public class SilentMainMenu extends SilentScreen {
blockY = 70; blockY = 70;
} }
RenderUtils.drawRect(blockX, blockY, 320, 150, new Color(20, 20, 20).getRGB()); RenderUtils.drawRect(blockX, blockY, 320, 150, new Color(20, 20, 20).getRGB());
if(GuiNews.imageLocation != null) { if(PromoController.getResponse().getCurrentPanel() != null) {
RenderUtil.drawImage(GuiNews.imageLocation, blockX + 78, blockY + 10, 231, 130, false); if(PromoController.getResponse().getCurrentPanel().getImageLocation() != null) {
RenderUtil.drawImage(PromoController.getResponse().getCurrentPanel().getImageLocation(), blockX + 78, blockY + 10, 231, 130, false);
} else {
PromoController.getResponse().getCurrentPanel().loadImage();
}
} }
int optionY = blockY + 10; int optionY = blockY + 10;
@ -121,12 +125,11 @@ public class SilentMainMenu extends SilentScreen {
if(blockY < 70) { if(blockY < 70) {
blockY = 70; blockY = 70;
} }
if(MouseUtils.isInside(mouseX, mouseY, blockX + 78, blockY + 10, 231, 130) && PromoController.getResponse().getCurrentPanel() != null) {
if(MouseUtils.isInside(mouseX, mouseY, blockX + 78, blockY + 10, 231, 130)) {
try { try {
Class<?> oclass = Class.forName("java.awt.Desktop"); Class<?> oclass = Class.forName("java.awt.Desktop");
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);
oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("https://silentclient.net/news/" + GuiNews.news.getItem().id)}); oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI(PromoController.getResponse().getCurrentPanel().getRedirectUrl())});
} catch (Throwable err) { } catch (Throwable err) {
err.printStackTrace(); err.printStackTrace();
} }

View File

@ -0,0 +1,128 @@
package net.silentclient.client.utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Random;
public class PromoController {
public static PromoResponse promo;
public static boolean loading = false;
public static PromoResponse getResponse() {
return promo;
}
public static void setResponse(PromoResponse promo) {
PromoController.promo = promo;
}
public class PromoResponse {
public ArrayList<Panel> panels;
private int panelIndex = 0;
private TimerUtils timer;
public int getPanelIndex() {
return panelIndex;
}
public void update() {
if(timer == null) {
timer = new TimerUtils();
}
if(timer.delay(6000)) {
nextPanel();
}
}
public void setPanelIndex(int panelIndex) {
if(timer == null) {
timer = new TimerUtils();
}
timer.reset();
this.panelIndex = panelIndex;
}
public void prevPanel() {
if(timer == null) {
timer = new TimerUtils();
}
timer.reset();
if(panelIndex == 0) {
this.panelIndex = PromoController.getResponse().getPanels().size() - 1;
} else {
this.panelIndex -= 1;
}
}
public void nextPanel() {
if(timer == null) {
timer = new TimerUtils();
}
timer.reset();
if(panelIndex == PromoController.getResponse().getPanels().size() - 1) {
this.panelIndex = 0;
} else {
this.panelIndex += 1;
}
}
public Panel getCurrentPanel() {
return panels.get(panelIndex) != null ? panels.get(panelIndex) : null;
}
public ArrayList<Panel> getPanels() {
return panels;
}
}
public class Panel {
public String imageUrl;
public String redirectUrl;
public ResourceLocation imageLocation;
public BufferedImage image = null;
public boolean initImage = false;
public void loadImage() {
if(image == null && !PromoController.loading && !initImage) {
PromoController.loading = true;
(new Thread("PromoImageThread") {
public void run() {
Client.logger.info(String.format("Downloading promo image %s...", imageUrl));
BufferedImage avatar = SCTextureManager.getImage(imageUrl);
if(avatar != null) {
Client.logger.info(String.format("Promo image %s successfully downloaded!", imageUrl));
image = avatar;
} else {
Client.logger.info(String.format("Promo image %s downloading failed!", imageUrl));
initImage = true;
}
PromoController.loading = false;
}
}).start();
}
if(image != null && !initImage) {
Client.logger.info(String.format("Crating ResourceLocation of promo image %s...", imageUrl));
imageLocation = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("promo_image_" + new Random().nextLong(), new DynamicTexture(image));
initImage = true;
}
}
public ResourceLocation getImageLocation() {
return imageLocation;
}
public String getImageUrl() {
return imageUrl;
}
public String getRedirectUrl() {
return redirectUrl;
}
}
}