Indicates current Tab in the Replay Center by deactivating the according button
Restricted Favoriting Replays to downloaded ones
This commit is contained in:
@@ -115,6 +115,8 @@ public abstract class GuiReplayListExtended extends GuiListExtended {
|
|||||||
int l = k / this.slotHeight;
|
int l = k / this.slotHeight;
|
||||||
|
|
||||||
if(this.mouseX >= i && this.mouseX <= j && l >= 0 && k >= 0 && l < this.getSize()) {
|
if(this.mouseX >= i && this.mouseX <= j && l >= 0 && k >= 0 && l < this.getSize()) {
|
||||||
|
//LoadingListEntries should not do anything
|
||||||
|
if(this.getListEntry(l) instanceof GuiLoadingListEntry) return;
|
||||||
boolean flag1 = l == this.selectedElement && Minecraft.getSystemTime() - this.lastClicked < 250L;
|
boolean flag1 = l == this.selectedElement && Minecraft.getSystemTime() - this.lastClicked < 250L;
|
||||||
this.elementClicked(l, flag1, this.mouseX, this.mouseY);
|
this.elementClicked(l, flag1, this.mouseX, this.mouseY);
|
||||||
this.selectedElement = l;
|
this.selectedElement = l;
|
||||||
|
|||||||
@@ -102,6 +102,11 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
bottomBar.add(logoutButton);
|
bottomBar.add(logoutButton);
|
||||||
|
|
||||||
showOnlineRecent();
|
showOnlineRecent();
|
||||||
|
disableTopBarButton(GuiConstants.CENTER_RECENT_BUTTON);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(currentList != null) {
|
||||||
|
currentList.height = height-60;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -170,7 +175,8 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
|
|
||||||
boolean favorited = ReplayMod.favoritedFileHandler.isFavorited(info.getId());
|
boolean favorited = ReplayMod.favoritedFileHandler.isFavorited(info.getId());
|
||||||
favButton.displayString = favorited ? I18n.format("replaymod.gui.center.unfavorite") : I18n.format("replaymod.gui.center.favorite");
|
favButton.displayString = favorited ? I18n.format("replaymod.gui.center.unfavorite") : I18n.format("replaymod.gui.center.favorite");
|
||||||
favButton.enabled = true;
|
//if not downloaded, disable favorising
|
||||||
|
favButton.enabled = favorited || downloaded;
|
||||||
} else {
|
} else {
|
||||||
for(GuiButton b : replayButtonBar) {
|
for(GuiButton b : replayButtonBar) {
|
||||||
b.enabled = false;
|
b.enabled = false;
|
||||||
@@ -178,6 +184,12 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void disableTopBarButton(int id) {
|
||||||
|
for(GuiButton b : topBar) {
|
||||||
|
b.enabled = b.id != id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void actionPerformed(GuiButton button) throws java.io.IOException {
|
protected void actionPerformed(GuiButton button) throws java.io.IOException {
|
||||||
if(!button.enabled) return;
|
if(!button.enabled) return;
|
||||||
@@ -188,15 +200,19 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
} else if(button.id == GuiConstants.CENTER_MANAGER_BUTTON) {
|
} else if(button.id == GuiConstants.CENTER_MANAGER_BUTTON) {
|
||||||
mc.displayGuiScreen(new GuiReplayViewer());
|
mc.displayGuiScreen(new GuiReplayViewer());
|
||||||
} else if(button.id == GuiConstants.CENTER_RECENT_BUTTON) {
|
} else if(button.id == GuiConstants.CENTER_RECENT_BUTTON) {
|
||||||
|
disableTopBarButton(button.id);
|
||||||
showOnlineRecent();
|
showOnlineRecent();
|
||||||
} else if(button.id == GuiConstants.CENTER_BEST_BUTTON) {
|
} else if(button.id == GuiConstants.CENTER_BEST_BUTTON) {
|
||||||
|
disableTopBarButton(button.id);
|
||||||
showOnlineBest();
|
showOnlineBest();
|
||||||
} else if(button.id == GuiConstants.CENTER_DOWNLOADED_REPLAYS_BUTTON) {
|
} else if(button.id == GuiConstants.CENTER_DOWNLOADED_REPLAYS_BUTTON) {
|
||||||
|
disableTopBarButton(button.id);
|
||||||
showDownloadedFiles();
|
showDownloadedFiles();
|
||||||
} else if(button.id == GuiConstants.CENTER_FAVORITED_REPLAYS_BUTTON) {
|
} else if(button.id == GuiConstants.CENTER_FAVORITED_REPLAYS_BUTTON) {
|
||||||
|
disableTopBarButton(button.id);
|
||||||
showFavoritedFiles();
|
showFavoritedFiles();
|
||||||
} else if(button.id == GuiConstants.CENTER_SEARCH_BUTTON) {
|
} else if(button.id == GuiConstants.CENTER_SEARCH_BUTTON) {
|
||||||
|
disableTopBarButton(button.id);
|
||||||
} else if(button.id == GuiConstants.CENTER_LOAD_REPLAY_BUTTON) {
|
} else if(button.id == GuiConstants.CENTER_LOAD_REPLAY_BUTTON) {
|
||||||
GuiReplayListEntry entry = (GuiReplayListEntry)currentList.getListEntry(currentList.selected);
|
GuiReplayListEntry entry = (GuiReplayListEntry)currentList.getListEntry(currentList.selected);
|
||||||
FileInfo info = entry.getFileInfo();
|
FileInfo info = entry.getFileInfo();
|
||||||
@@ -247,13 +263,18 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
@Override
|
@Override
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
this.drawDefaultBackground();
|
this.drawDefaultBackground();
|
||||||
this.drawCenteredString(fontRendererObj, I18n.format("replaymod.gui.replaycenter"), this.width / 2, 8, Color.WHITE.getRGB());
|
|
||||||
|
|
||||||
if(currentList != null) {
|
if(currentList != null) {
|
||||||
currentList.drawScreen(mouseX, mouseY, partialTicks);
|
currentList.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
|
if(((favButton.isMouseOver() && !favButton.enabled) || (likeButton.isMouseOver() && !likeButton.enabled)
|
||||||
|
|| (dislikeButton.isMouseOver() && !dislikeButton.enabled ))&& currentList.selected != -1) {
|
||||||
|
this.drawString(fontRendererObj, I18n.format("replaymod.gui.center.downloadrequired"), mouseX, mouseY + 4, Color.RED.getRGB());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.drawCenteredString(fontRendererObj, I18n.format("replaymod.gui.replaycenter"), this.width / 2, 5, Color.WHITE.getRGB());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -287,7 +308,7 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
|
|
||||||
private void updateCurrentList(Pagination pagination) {
|
private void updateCurrentList(Pagination pagination) {
|
||||||
elementSelected(-1);
|
elementSelected(-1);
|
||||||
currentList = new ReplayFileList(mc, width, height, 50, height - 70, 36, this);
|
currentList = new ReplayFileList(mc, width, height, 50, height - 60, 36, this);
|
||||||
loadingListEntry = new GuiLoadingListEntry(currentList);
|
loadingListEntry = new GuiLoadingListEntry(currentList);
|
||||||
currentList.addEntry(loadingListEntry);
|
currentList.addEntry(loadingListEntry);
|
||||||
|
|
||||||
@@ -322,8 +343,8 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
currentListLoader = new Thread(new Runnable() {
|
currentListLoader = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateCurrentList(new SearchPagination(recentFileSearchQuery));
|
|
||||||
currentTab = Tab.RECENT_FILES;
|
currentTab = Tab.RECENT_FILES;
|
||||||
|
updateCurrentList(new SearchPagination(recentFileSearchQuery));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
currentListLoader.start();
|
currentListLoader.start();
|
||||||
@@ -334,8 +355,8 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
currentListLoader = new Thread(new Runnable() {
|
currentListLoader = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateCurrentList(new SearchPagination(bestFileSearchQuery));
|
|
||||||
currentTab = Tab.BEST_FILES;
|
currentTab = Tab.BEST_FILES;
|
||||||
|
updateCurrentList(new SearchPagination(bestFileSearchQuery));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
currentListLoader.start();
|
currentListLoader.start();
|
||||||
@@ -346,8 +367,8 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
currentListLoader = new Thread(new Runnable() {
|
currentListLoader = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateCurrentList(new DownloadedFilePagination());
|
|
||||||
currentTab = Tab.DOWNLOADED_FILES;
|
currentTab = Tab.DOWNLOADED_FILES;
|
||||||
|
updateCurrentList(new DownloadedFilePagination());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
currentListLoader.start();
|
currentListLoader.start();
|
||||||
@@ -358,15 +379,27 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
currentListLoader = new Thread(new Runnable() {
|
currentListLoader = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
currentTab = Tab.FAVORITED_FILES;
|
||||||
ReplayMod.favoritedFileHandler.reloadFavorites();
|
ReplayMod.favoritedFileHandler.reloadFavorites();
|
||||||
updateCurrentList(new FavoritedFilePagination());
|
updateCurrentList(new FavoritedFilePagination());
|
||||||
currentTab = Tab.FAVORITED_FILES;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
currentListLoader.start();
|
currentListLoader.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum Tab {
|
private enum Tab {
|
||||||
RECENT_FILES, BEST_FILES, DOWNLOADED_FILES, FAVORITED_FILES, SEARCH;
|
RECENT_FILES("replaymod.gui.center.tab.recent"),
|
||||||
|
BEST_FILES("replaymod.gui.center.tab.best"),
|
||||||
|
DOWNLOADED_FILES("replaymod.gui.center.tab.downloaded"),
|
||||||
|
FAVORITED_FILES("replaymod.gui.center.tab.favorited"),
|
||||||
|
SEARCH("replaymod.gui.center.tab.search");
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
Tab(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() { return I18n.format(title); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class DownloadedFileHandler {
|
|||||||
downloadFolder.mkdirs();
|
downloadFolder.mkdirs();
|
||||||
|
|
||||||
for(File f : downloadFolder.listFiles()) {
|
for(File f : downloadFolder.listFiles()) {
|
||||||
|
if(!FilenameUtils.getExtension(f.getAbsolutePath()).equals("mcpr")) continue;
|
||||||
try {
|
try {
|
||||||
Integer i = Integer.valueOf(FilenameUtils.getBaseName(f.getAbsolutePath()));
|
Integer i = Integer.valueOf(FilenameUtils.getBaseName(f.getAbsolutePath()));
|
||||||
if(i != null) {
|
if(i != null) {
|
||||||
|
|||||||
@@ -127,6 +127,8 @@ replaymod.gui.center.top.downloaded=Downloaded
|
|||||||
replaymod.gui.center.top.favorited=Favorited
|
replaymod.gui.center.top.favorited=Favorited
|
||||||
replaymod.gui.center.top.search=Search
|
replaymod.gui.center.top.search=Search
|
||||||
|
|
||||||
|
replaymod.gui.center.downloadrequired=Download the Replay to rate or favorite it
|
||||||
|
|
||||||
replaymod.gui.center.favorite=Favorite
|
replaymod.gui.center.favorite=Favorite
|
||||||
replaymod.gui.center.unfavorite=Unfavorite
|
replaymod.gui.center.unfavorite=Unfavorite
|
||||||
replaymod.gui.center.favorites=Favorites
|
replaymod.gui.center.favorites=Favorites
|
||||||
|
|||||||
Reference in New Issue
Block a user