Added Api Call checking if the Mod has the latest version and Message in Main Menu if not up-to-date
Removed unused GuiConstants Fields
This commit is contained in:
@@ -26,6 +26,7 @@ import eu.crushedpixel.replaymod.utils.ReplayFile;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import eu.crushedpixel.replaymod.utils.TooltipRenderer;
|
||||
import eu.crushedpixel.replaymod.video.frame.*;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.client.resources.IResourcePack;
|
||||
@@ -89,6 +90,9 @@ public class ReplayMod {
|
||||
public static SoundHandler soundHandler = new SoundHandler();
|
||||
public static CrosshairRenderHandler crosshairRenderHandler;
|
||||
|
||||
@Getter
|
||||
private static boolean latestModVersion = false;
|
||||
|
||||
// The instance of your mod that Forge uses.
|
||||
@Instance(value = "ReplayModID")
|
||||
public static ReplayMod instance;
|
||||
@@ -121,6 +125,13 @@ public class ReplayMod {
|
||||
|
||||
replayFileAppender = new ReplayFileAppender();
|
||||
FMLCommonHandler.instance().bus().register(replayFileAppender);
|
||||
|
||||
//check if latest mod version
|
||||
try {
|
||||
latestModVersion = apiClient.isVersionUpToDate(getContainer().getVersion());
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -202,6 +202,12 @@ public class ApiClient {
|
||||
invokeAndReturn(builder, Success.class);
|
||||
}
|
||||
|
||||
public boolean isVersionUpToDate(String versionIdentifier) throws IOException, ApiException {
|
||||
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.up_to_date);
|
||||
builder.put("version", versionIdentifier);
|
||||
return invokeAndReturn(builder, Success.class).isSuccess();
|
||||
}
|
||||
|
||||
private <T> T invokeAndReturn(QueryBuilder builder, Class<T> classOfT) throws IOException, ApiException {
|
||||
return invokeAndReturn(builder.toString(), classOfT);
|
||||
}
|
||||
|
||||
@@ -20,4 +20,5 @@ public class ReplayModApiMethods {
|
||||
public static final String check_auth = REPLAYMOD_BASE_URL+"check_auth";
|
||||
public static final String get_language = REPLAYMOD_BASE_URL+"get_language";
|
||||
public static final String search = REPLAYMOD_BASE_URL+"search";
|
||||
public static final String up_to_date = REPLAYMOD_BASE_URL+"up_to_date";
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import eu.crushedpixel.replaymod.replay.ReplayProcess;
|
||||
import eu.crushedpixel.replaymod.studio.VersionValidator;
|
||||
import eu.crushedpixel.replaymod.utils.MouseUtils;
|
||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||
import eu.crushedpixel.replaymod.utils.StringUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.*;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
@@ -81,6 +82,29 @@ public class GuiEventHandler {
|
||||
e.gui.drawString(mc.fontRendererObj, I18n.format("replaymod.gui.loggedout").toUpperCase(), 5, 15, DARK_RED.getRGB());
|
||||
}
|
||||
|
||||
//if version not up to date, display info string
|
||||
if(!ReplayMod.isLatestModVersion()) {
|
||||
int width = Math.max(100, e.gui.width / 2 - 100 - 10);
|
||||
|
||||
String[] lines = StringUtils.splitStringInMultipleRows(I18n.format("replaymod.gui.outdated"), width);
|
||||
|
||||
int maxLineWidth = 0;
|
||||
for(String line : lines) {
|
||||
int lineWidth = mc.fontRendererObj.getStringWidth(line);
|
||||
if(lineWidth > maxLineWidth) {
|
||||
maxLineWidth = lineWidth;
|
||||
}
|
||||
}
|
||||
|
||||
Gui.drawRect(2, 77, 5+maxLineWidth+3, 80+(lines.length * 10), 0x80FF0000);
|
||||
|
||||
int i = 0;
|
||||
for(String line : lines) {
|
||||
mc.fontRendererObj.drawStringWithShadow(line, 5, 80 + (i * 10), Color.WHITE.getRGB());
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if(replayCount == 0) {
|
||||
if(editorButton.isMouseOver()) {
|
||||
Point mouse = MouseUtils.getMousePos();
|
||||
|
||||
@@ -2,6 +2,8 @@ package eu.crushedpixel.replaymod.gui;
|
||||
|
||||
public class GuiConstants {
|
||||
|
||||
public static final int MAIN_MENU_UPDATE_BUTTON = 8765;
|
||||
|
||||
public static final int CENTER_DOWNLOADED_REPLAYS_BUTTON = 2001;
|
||||
public static final int CENTER_SEARCH_BUTTON = 2002;
|
||||
public static final int CENTER_BACK_BUTTON = 2003;
|
||||
@@ -31,19 +33,6 @@ public class GuiConstants {
|
||||
public static final int REPLAY_EDITOR_BUTTON_ID = 9002;
|
||||
public static final int REPLAY_CENTER_BUTTON_ID = 9003;
|
||||
|
||||
public static final int LOGIN_OKAY_BUTTON = 1100;
|
||||
public static final int LOGIN_CANCEL_BUTTON = 1101;
|
||||
public static final int LOGIN_REGISTER_BUTTON = 1102;
|
||||
public static final int LOGIN_USERNAME_FIELD = 1103;
|
||||
public static final int LOGIN_PASSWORD_FIELD = 1104;
|
||||
|
||||
public static final int REGISTER_USERNAME_FIELD = 2000;
|
||||
public static final int REGISTER_PASSWORD_FIELD = 2001;
|
||||
public static final int REGISTER_PASSWORD_CONFIRM_FIELD = 2002;
|
||||
public static final int REGISTER_CANCEL_BUTTON = 2003;
|
||||
public static final int REGISTER_OKAY_BUTTON = 2004;
|
||||
public static final int REGISTER_MAIL_FIELD = 2005;
|
||||
|
||||
public static final int REPLAY_EDITOR_TRIM_TAB = 5000;
|
||||
public static final int REPLAY_EDITOR_CONNECT_TAB = 5001;
|
||||
public static final int REPLAY_EDITOR_MODIFY_TAB = 5002;
|
||||
|
||||
@@ -86,6 +86,8 @@ replaymod.gui.pleasewait=Please wait
|
||||
replaymod.gui.render=Render
|
||||
replaymod.gui.iphidden=Server IP Hidden
|
||||
|
||||
replaymod.gui.outdated=There is a newer Replay Mod version available. Please download it from replaymod.com
|
||||
|
||||
replaymod.gui.hours=h
|
||||
replaymod.gui.minutes=min
|
||||
replaymod.gui.seconds=sec
|
||||
|
||||
Reference in New Issue
Block a user