Removed unnecessary reloading of GuiReplayCenter

Extended max Render Distance to 64 chunks
This commit is contained in:
CrushedPixel
2015-05-16 15:57:13 +02:00
parent 5183796802
commit 7c9b0eb8a7
2 changed files with 78 additions and 58 deletions

View File

@@ -17,6 +17,7 @@ import eu.crushedpixel.replaymod.settings.ReplaySettings;
import eu.crushedpixel.replaymod.utils.ReplayFile; import eu.crushedpixel.replaymod.utils.ReplayFile;
import eu.crushedpixel.replaymod.utils.ReplayFileIO; import eu.crushedpixel.replaymod.utils.ReplayFileIO;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLCommonHandler;
@@ -115,6 +116,8 @@ public class ReplayMod {
@EventHandler @EventHandler
public void postInit(FMLPostInitializationEvent event) { public void postInit(FMLPostInitializationEvent event) {
GameSettings.Options.RENDER_DISTANCE.setValueMax(64f);
overlay = new GuiReplayOverlay(); overlay = new GuiReplayOverlay();
FMLCommonHandler.instance().bus().register(overlay); FMLCommonHandler.instance().bus().register(overlay);
MinecraftForge.EVENT_BUS.register(overlay); MinecraftForge.EVENT_BUS.register(overlay);

View File

@@ -33,7 +33,7 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
private Tab currentTab = Tab.RECENT_FILES; private Tab currentTab = Tab.RECENT_FILES;
private SearchPagination myFilePagination; private SearchPagination myFilePagination;
private GuiButton loadButton, favButton, likeButton, dislikeButton; private GuiButton loadButton, favButton, likeButton, dislikeButton;
private List<GuiButton> replayButtonBar; private List<GuiButton> replayButtonBar, bottomBar, topBar;
public static GuiYesNo getYesNoGui(GuiYesNoCallback p_152129_0_, int p_152129_2_) { public static GuiYesNo getYesNoGui(GuiYesNoCallback p_152129_0_, int p_152129_2_) {
String s1 = I18n.format("replaymod.gui.center.logoutcallback"); String s1 = I18n.format("replaymod.gui.center.logoutcallback");
@@ -42,37 +42,72 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
return guiyesno; return guiyesno;
} }
private boolean initialized = false;
@Override @Override
public void initGui() { public void initGui() {
Keyboard.enableRepeatEvents(true); Keyboard.enableRepeatEvents(true);
if(AuthenticationHandler.isAuthenticated()) { if(!initialized) {
SearchQuery query = new SearchQuery(); if(AuthenticationHandler.isAuthenticated()) {
query.auth = AuthenticationHandler.getKey(); SearchQuery query = new SearchQuery();
query.order = false; query.auth = AuthenticationHandler.getKey();
myFilePagination = new SearchPagination(query); query.order = false;
myFilePagination = new SearchPagination(query);
} else {
mc.displayGuiScreen(new GuiLoginPrompt(new GuiMainMenu(), this));
}
//Top Button Bar
topBar = new ArrayList<GuiButton>();
GuiButton recentButton = new GuiButton(GuiConstants.CENTER_RECENT_BUTTON, 20, 30, I18n.format("replaymod.gui.center.newest"));
topBar.add(recentButton);
GuiButton bestButton = new GuiButton(GuiConstants.CENTER_BEST_BUTTON, 20, 30, I18n.format("replaymod.gui.center.best"));
topBar.add(bestButton);
GuiButton ownReplayButton = new GuiButton(GuiConstants.CENTER_MY_REPLAYS_BUTTON, 20, 30, I18n.format("replaymod.gui.center.my"));
ownReplayButton.enabled = AuthenticationHandler.isAuthenticated();
topBar.add(ownReplayButton);
GuiButton searchButton = new GuiButton(GuiConstants.CENTER_SEARCH_BUTTON, 20, 30, I18n.format("replaymod.gui.center.search"));
topBar.add(searchButton);
//Replay specific actions (load, rate, etc)
replayButtonBar = new ArrayList<GuiButton>();
loadButton = new GuiButton(GuiConstants.CENTER_LOAD_REPLAY_BUTTON, 20, 30, I18n.format("replaymod.gui.download"));
replayButtonBar.add(loadButton);
favButton = new GuiButton(GuiConstants.CENTER_FAV_REPLAY_BUTTON, 20, 30, I18n.format("replaymod.gui.center.favorite"));
replayButtonBar.add(favButton);
likeButton = new GuiButton(GuiConstants.CENTER_LIKE_REPLAY_BUTTON, 20, 30, I18n.format("replaymod.gui.like"));
replayButtonBar.add(likeButton);
dislikeButton = new GuiButton(GuiConstants.CENTER_DISLIKE_REPLAY_BUTTON, 20, 30, I18n.format("replaymod.gui.dislike"));
replayButtonBar.add(dislikeButton);
//Bottom Button Bar (dat alliteration)
bottomBar = new ArrayList<GuiButton>();
GuiButton exitButton = new GuiButton(GuiConstants.CENTER_BACK_BUTTON, 20, 20, I18n.format("replaymod.gui.mainmenu"));
bottomBar.add(exitButton);
GuiButton managerButton = new GuiButton(GuiConstants.CENTER_MANAGER_BUTTON, 20, 20, I18n.format("replaymod.gui.replayviewer"));
bottomBar.add(managerButton);
GuiButton logoutButton = new GuiButton(GuiConstants.CENTER_LOGOUT_BUTTON, 20, 20, I18n.format("replaymod.gui.logout"));
bottomBar.add(logoutButton);
showOnlineRecent();
} }
//Top Button Bar
List<GuiButton> buttonBar = new ArrayList<GuiButton>();
GuiButton recentButton = new GuiButton(GuiConstants.CENTER_RECENT_BUTTON, 20, 30, I18n.format("replaymod.gui.center.newest"));
buttonBar.add(recentButton);
GuiButton bestButton = new GuiButton(GuiConstants.CENTER_BEST_BUTTON, 20, 30, I18n.format("replaymod.gui.center.best"));
buttonBar.add(bestButton);
GuiButton ownReplayButton = new GuiButton(GuiConstants.CENTER_MY_REPLAYS_BUTTON, 20, 30, I18n.format("replaymod.gui.center.my"));
ownReplayButton.enabled = AuthenticationHandler.isAuthenticated();
buttonBar.add(ownReplayButton);
GuiButton searchButton = new GuiButton(GuiConstants.CENTER_SEARCH_BUTTON, 20, 30, I18n.format("replaymod.gui.center.search"));
buttonBar.add(searchButton);
int i = 0; int i = 0;
for(GuiButton b : buttonBar) { for(GuiButton b : topBar) {
int w = this.width - 30; int w = this.width - 30;
int w2 = w / buttonBar.size(); int w2 = w / topBar.size();
int x = 15 + (w2 * i); int x = 15 + (w2 * i);
b.xPosition = x + 2; b.xPosition = x + 2;
@@ -84,21 +119,6 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
i++; i++;
} }
//Replay specific actions (load, rate, etc)
replayButtonBar = new ArrayList<GuiButton>();
loadButton = new GuiButton(GuiConstants.CENTER_LOAD_REPLAY_BUTTON, 20, 30, I18n.format("replaymod.gui.download"));
replayButtonBar.add(loadButton);
favButton = new GuiButton(GuiConstants.CENTER_FAV_REPLAY_BUTTON, 20, 30, I18n.format("replaymod.gui.center.favorite"));
replayButtonBar.add(favButton);
likeButton = new GuiButton(GuiConstants.CENTER_LIKE_REPLAY_BUTTON, 20, 30, I18n.format("replaymod.gui.like"));
replayButtonBar.add(likeButton);
dislikeButton = new GuiButton(GuiConstants.CENTER_DISLIKE_REPLAY_BUTTON, 20, 30, I18n.format("replaymod.gui.dislike"));
replayButtonBar.add(dislikeButton);
i = 0; i = 0;
for(GuiButton b : replayButtonBar) { for(GuiButton b : replayButtonBar) {
int w = this.width - 30; int w = this.width - 30;
@@ -116,18 +136,6 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
i++; i++;
} }
//Bottom Button Bar (dat alliteration)
List<GuiButton> bottomBar = new ArrayList<GuiButton>();
GuiButton exitButton = new GuiButton(GuiConstants.CENTER_BACK_BUTTON, 20, 20, I18n.format("replaymod.gui.mainmenu"));
bottomBar.add(exitButton);
GuiButton managerButton = new GuiButton(GuiConstants.CENTER_MANAGER_BUTTON, 20, 20, I18n.format("replaymod.gui.replayviewer"));
bottomBar.add(managerButton);
GuiButton logoutButton = new GuiButton(GuiConstants.CENTER_LOGOUT_BUTTON, 20, 20, I18n.format("replaymod.gui.logout"));
bottomBar.add(logoutButton);
i = 0; i = 0;
for(GuiButton b : bottomBar) { for(GuiButton b : bottomBar) {
int w = this.width - 30; int w = this.width - 30;
@@ -143,7 +151,7 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
i++; i++;
} }
showOnlineRecent(); initialized = true;
} }
public void elementSelected(int index) { public void elementSelected(int index) {
@@ -282,38 +290,47 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
} }
} }
private Thread currentListLoader;
private void cancelCurrentListLoader() {
if(currentListLoader != null && currentListLoader.isAlive()) currentListLoader.stop();
}
public void showOnlineRecent() { public void showOnlineRecent() {
Thread t = new Thread(new Runnable() { cancelCurrentListLoader();
currentListLoader = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
updateCurrentList(recentFileList, recentFilePagination); updateCurrentList(recentFileList, recentFilePagination);
currentTab = Tab.RECENT_FILES; currentTab = Tab.RECENT_FILES;
} }
}); });
t.start(); currentListLoader.start();
} }
public void showOnlineBest() { public void showOnlineBest() {
Thread t = new Thread(new Runnable() { cancelCurrentListLoader();
currentListLoader = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
updateCurrentList(bestFileList, bestFilePagination); updateCurrentList(bestFileList, bestFilePagination);
currentTab = Tab.BEST_FILES; currentTab = Tab.BEST_FILES;
} }
}); });
t.start(); currentListLoader.start();
} }
public void showOnlineOwnFiles() { public void showOnlineOwnFiles() {
cancelCurrentListLoader();
if(!AuthenticationHandler.isAuthenticated() || myFilePagination == null) return; if(!AuthenticationHandler.isAuthenticated() || myFilePagination == null) return;
Thread t = new Thread(new Runnable() { currentListLoader = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
updateCurrentList(myFileList, myFilePagination); updateCurrentList(myFileList, myFilePagination);
currentTab = Tab.MY_FILES; currentTab = Tab.MY_FILES;
} }
}); });
t.start(); currentListLoader.start();
} }
private enum Tab { private enum Tab {