Added "Downloaded" Tab to Replay Center to be able to open downloaded replays
This commit is contained in:
@@ -40,9 +40,11 @@ public class DownloadedFilePagination implements Pagination {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
files.keySet().retainAll(f.keySet());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileInfo[] fis = ReplayMod.apiClient.getFileInfo(toAdd);
|
FileInfo[] fis = ReplayMod.apiClient.getFileInfo(toAdd);
|
||||||
if(fis.length <= 1) {
|
if(fis.length < 1) {
|
||||||
page--;
|
page--;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import eu.crushedpixel.replaymod.api.client.holders.FileInfo;
|
|||||||
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -41,8 +42,10 @@ public class FavoritedFilePagination implements Pagination {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
files.keySet().retainAll(Arrays.asList(f));
|
||||||
|
|
||||||
FileInfo[] fis = ReplayMod.apiClient.getFileInfo(toAdd);
|
FileInfo[] fis = ReplayMod.apiClient.getFileInfo(toAdd);
|
||||||
if(fis.length <= 1) {
|
if(fis.length < 1) {
|
||||||
page--;
|
page--;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class SearchPagination implements Pagination {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
FileInfo[] fis = ReplayMod.apiClient.searchFiles(searchQuery);
|
FileInfo[] fis = ReplayMod.apiClient.searchFiles(searchQuery);
|
||||||
if(fis.length <= 1) {
|
if(fis.length < 1) {
|
||||||
page--;
|
page--;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package eu.crushedpixel.replaymod.gui;
|
|||||||
|
|
||||||
public class GuiConstants {
|
public class GuiConstants {
|
||||||
|
|
||||||
public static final int CENTER_MY_REPLAYS_BUTTON = 2001;
|
public static final int CENTER_DOWNLOADED_REPLAYS_BUTTON = 2001;
|
||||||
public static final int CENTER_SEARCH_BUTTON = 2002;
|
public static final int CENTER_SEARCH_BUTTON = 2002;
|
||||||
public static final int CENTER_BACK_BUTTON = 2003;
|
public static final int CENTER_BACK_BUTTON = 2003;
|
||||||
public static final int CENTER_LOGOUT_BUTTON = 2004;
|
public static final int CENTER_LOGOUT_BUTTON = 2004;
|
||||||
@@ -13,6 +13,7 @@ public class GuiConstants {
|
|||||||
public static final int CENTER_FAV_REPLAY_BUTTON = 2009;
|
public static final int CENTER_FAV_REPLAY_BUTTON = 2009;
|
||||||
public static final int CENTER_LIKE_REPLAY_BUTTON = 2010;
|
public static final int CENTER_LIKE_REPLAY_BUTTON = 2010;
|
||||||
public static final int CENTER_DISLIKE_REPLAY_BUTTON = 2011;
|
public static final int CENTER_DISLIKE_REPLAY_BUTTON = 2011;
|
||||||
|
public static final int CENTER_FAVORITED_REPLAYS_BUTTON = 2012;
|
||||||
|
|
||||||
public static final int UPLOAD_NAME_INPUT = 3001;
|
public static final int UPLOAD_NAME_INPUT = 3001;
|
||||||
public static final int UPLOAD_CATEGORY_BUTTON = 3002;
|
public static final int UPLOAD_CATEGORY_BUTTON = 3002;
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package eu.crushedpixel.replaymod.gui.online;
|
package eu.crushedpixel.replaymod.gui.online;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.api.client.SearchPagination;
|
|
||||||
import eu.crushedpixel.replaymod.api.client.SearchQuery;
|
import eu.crushedpixel.replaymod.api.client.SearchQuery;
|
||||||
import eu.crushedpixel.replaymod.api.client.holders.FileInfo;
|
import eu.crushedpixel.replaymod.api.client.holders.FileInfo;
|
||||||
|
import eu.crushedpixel.replaymod.api.client.pagination.DownloadedFilePagination;
|
||||||
|
import eu.crushedpixel.replaymod.api.client.pagination.FavoritedFilePagination;
|
||||||
|
import eu.crushedpixel.replaymod.api.client.pagination.Pagination;
|
||||||
|
import eu.crushedpixel.replaymod.api.client.pagination.SearchPagination;
|
||||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||||
import eu.crushedpixel.replaymod.gui.elements.GuiReplayListEntry;
|
import eu.crushedpixel.replaymod.gui.elements.GuiReplayListEntry;
|
||||||
import eu.crushedpixel.replaymod.gui.replayviewer.GuiReplayViewer;
|
import eu.crushedpixel.replaymod.gui.replayviewer.GuiReplayViewer;
|
||||||
@@ -26,12 +29,12 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
private static final SearchQuery bestFileSearchQuery = new SearchQuery(true, null, null, null, null, null,
|
private static final SearchQuery bestFileSearchQuery = new SearchQuery(true, null, null, null, null, null,
|
||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
private static final int LOGOUT_CALLBACK_ID = 1;
|
private static final int LOGOUT_CALLBACK_ID = 1;
|
||||||
private final SearchPagination recentFilePagination = new SearchPagination(recentFileSearchQuery);
|
private final Pagination recentFilePagination = new SearchPagination(recentFileSearchQuery);
|
||||||
private final SearchPagination bestFilePagination = new SearchPagination(bestFileSearchQuery);
|
private final Pagination bestFilePagination = new SearchPagination(bestFileSearchQuery);
|
||||||
|
private final Pagination downloadedFilePagination = new DownloadedFilePagination();
|
||||||
|
private final Pagination favoritedFilePagination = new FavoritedFilePagination();
|
||||||
private ReplayFileList currentList;
|
private ReplayFileList currentList;
|
||||||
private ReplayFileList recentFileList, bestFileList, myFileList, searchFileList;
|
|
||||||
private Tab currentTab = Tab.RECENT_FILES;
|
private Tab currentTab = Tab.RECENT_FILES;
|
||||||
private SearchPagination myFilePagination;
|
|
||||||
private GuiButton loadButton, favButton, likeButton, dislikeButton;
|
private GuiButton loadButton, favButton, likeButton, dislikeButton;
|
||||||
private List<GuiButton> replayButtonBar, bottomBar, topBar;
|
private List<GuiButton> replayButtonBar, bottomBar, topBar;
|
||||||
|
|
||||||
@@ -49,29 +52,28 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
Keyboard.enableRepeatEvents(true);
|
Keyboard.enableRepeatEvents(true);
|
||||||
|
|
||||||
if(!initialized) {
|
if(!initialized) {
|
||||||
if(AuthenticationHandler.isAuthenticated()) {
|
if(!AuthenticationHandler.isAuthenticated()) {
|
||||||
SearchQuery query = new SearchQuery();
|
|
||||||
query.auth = AuthenticationHandler.getKey();
|
|
||||||
query.order = false;
|
|
||||||
myFilePagination = new SearchPagination(query);
|
|
||||||
} else {
|
|
||||||
mc.displayGuiScreen(new GuiLoginPrompt(new GuiMainMenu(), this));
|
mc.displayGuiScreen(new GuiLoginPrompt(new GuiMainMenu(), this));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Top Button Bar
|
//Top Button Bar
|
||||||
topBar = new ArrayList<GuiButton>();
|
topBar = new ArrayList<GuiButton>();
|
||||||
|
|
||||||
GuiButton recentButton = new GuiButton(GuiConstants.CENTER_RECENT_BUTTON, 20, 30, I18n.format("replaymod.gui.center.newest"));
|
GuiButton recentButton = new GuiButton(GuiConstants.CENTER_RECENT_BUTTON, 20, 30, I18n.format("replaymod.gui.center.top.recent"));
|
||||||
topBar.add(recentButton);
|
topBar.add(recentButton);
|
||||||
|
|
||||||
GuiButton bestButton = new GuiButton(GuiConstants.CENTER_BEST_BUTTON, 20, 30, I18n.format("replaymod.gui.center.best"));
|
GuiButton bestButton = new GuiButton(GuiConstants.CENTER_BEST_BUTTON, 20, 30, I18n.format("replaymod.gui.center.top.best"));
|
||||||
topBar.add(bestButton);
|
topBar.add(bestButton);
|
||||||
|
|
||||||
GuiButton ownReplayButton = new GuiButton(GuiConstants.CENTER_MY_REPLAYS_BUTTON, 20, 30, I18n.format("replaymod.gui.center.my"));
|
GuiButton downloadedReplayButton = new GuiButton(GuiConstants.CENTER_DOWNLOADED_REPLAYS_BUTTON, 20, 30, I18n.format("replaymod.gui.center.top.downloaded"));
|
||||||
ownReplayButton.enabled = AuthenticationHandler.isAuthenticated();
|
downloadedReplayButton.enabled = AuthenticationHandler.isAuthenticated();
|
||||||
topBar.add(ownReplayButton);
|
topBar.add(downloadedReplayButton);
|
||||||
|
|
||||||
GuiButton searchButton = new GuiButton(GuiConstants.CENTER_SEARCH_BUTTON, 20, 30, I18n.format("replaymod.gui.center.search"));
|
GuiButton favoritedReplayButton = new GuiButton(GuiConstants.CENTER_FAVORITED_REPLAYS_BUTTON, 20, 30, I18n.format("replaymod.gui.center.top.favorited"));
|
||||||
|
favoritedReplayButton.enabled = AuthenticationHandler.isAuthenticated();
|
||||||
|
topBar.add(favoritedReplayButton);
|
||||||
|
|
||||||
|
GuiButton searchButton = new GuiButton(GuiConstants.CENTER_SEARCH_BUTTON, 20, 30, I18n.format("replaymod.gui.center.top.search"));
|
||||||
topBar.add(searchButton);
|
topBar.add(searchButton);
|
||||||
|
|
||||||
//Replay specific actions (load, rate, etc)
|
//Replay specific actions (load, rate, etc)
|
||||||
@@ -155,6 +157,12 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void elementSelected(int index) {
|
public void elementSelected(int index) {
|
||||||
|
if(index < 0) {
|
||||||
|
for(GuiButton b : replayButtonBar) {
|
||||||
|
b.enabled = false;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
GuiReplayListEntry entry = currentList.getListEntry(index);
|
GuiReplayListEntry entry = currentList.getListEntry(index);
|
||||||
FileInfo info = entry.getFileInfo();
|
FileInfo info = entry.getFileInfo();
|
||||||
if(info != null) {
|
if(info != null) {
|
||||||
@@ -181,8 +189,10 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
showOnlineRecent();
|
showOnlineRecent();
|
||||||
} else if(button.id == GuiConstants.CENTER_BEST_BUTTON) {
|
} else if(button.id == GuiConstants.CENTER_BEST_BUTTON) {
|
||||||
showOnlineBest();
|
showOnlineBest();
|
||||||
} else if(button.id == GuiConstants.CENTER_MY_REPLAYS_BUTTON) {
|
} else if(button.id == GuiConstants.CENTER_DOWNLOADED_REPLAYS_BUTTON) {
|
||||||
showOnlineOwnFiles();
|
showDownloadedFiles();
|
||||||
|
} else if(button.id == GuiConstants.CENTER_FAVORITED_REPLAYS_BUTTON) {
|
||||||
|
showFavoritedFiles();
|
||||||
} else if(button.id == GuiConstants.CENTER_SEARCH_BUTTON) {
|
} else if(button.id == GuiConstants.CENTER_SEARCH_BUTTON) {
|
||||||
|
|
||||||
} else if(button.id == GuiConstants.CENTER_LOAD_REPLAY_BUTTON) {
|
} else if(button.id == GuiConstants.CENTER_LOAD_REPLAY_BUTTON) {
|
||||||
@@ -260,17 +270,9 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
Keyboard.enableRepeatEvents(false);
|
Keyboard.enableRepeatEvents(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCurrentList(ReplayFileList list, SearchPagination pagination) {
|
private void updateCurrentList(Pagination pagination) {
|
||||||
currentList = list;
|
elementSelected(-1);
|
||||||
if(currentList == null) {
|
currentList = new ReplayFileList(mc, width, height, 50, height - 70, 36, this);
|
||||||
currentList = new ReplayFileList(mc, width, height, 50, height - 70, 36, this);
|
|
||||||
} else {
|
|
||||||
currentList.clearEntries();
|
|
||||||
currentList.width = width;
|
|
||||||
currentList.height = height;
|
|
||||||
currentList.top = 50;
|
|
||||||
currentList.bottom = height - 70;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pagination.getLoadedPages() < 0) {
|
if(pagination.getLoadedPages() < 0) {
|
||||||
pagination.fetchPage();
|
pagination.fetchPage();
|
||||||
@@ -301,7 +303,7 @@ 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(recentFileList, recentFilePagination);
|
updateCurrentList(recentFilePagination);
|
||||||
currentTab = Tab.RECENT_FILES;
|
currentTab = Tab.RECENT_FILES;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -313,27 +315,38 @@ 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(bestFileList, bestFilePagination);
|
updateCurrentList(bestFilePagination);
|
||||||
currentTab = Tab.BEST_FILES;
|
currentTab = Tab.BEST_FILES;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
currentListLoader.start();
|
currentListLoader.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showOnlineOwnFiles() {
|
public void showDownloadedFiles() {
|
||||||
cancelCurrentListLoader();
|
cancelCurrentListLoader();
|
||||||
if(!AuthenticationHandler.isAuthenticated() || myFilePagination == null) return;
|
|
||||||
currentListLoader = new Thread(new Runnable() {
|
currentListLoader = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateCurrentList(myFileList, myFilePagination);
|
updateCurrentList(downloadedFilePagination);
|
||||||
currentTab = Tab.MY_FILES;
|
currentTab = Tab.DOWNLOADED_FILES;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
currentListLoader.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showFavoritedFiles() {
|
||||||
|
cancelCurrentListLoader();
|
||||||
|
currentListLoader = new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateCurrentList(favoritedFilePagination);
|
||||||
|
currentTab = Tab.FAVORITED_FILES;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
currentListLoader.start();
|
currentListLoader.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum Tab {
|
private enum Tab {
|
||||||
RECENT_FILES, BEST_FILES, MY_FILES, SEARCH;
|
RECENT_FILES, BEST_FILES, DOWNLOADED_FILES, FAVORITED_FILES, SEARCH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,4 +62,8 @@ public class DownloadedFileHandler {
|
|||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashMap<Integer, File> getDownloadedFiles() {
|
||||||
|
return downloadedFiles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,10 +120,11 @@ replaymod.gui.login.noacc=Don't have an account yet?
|
|||||||
|
|
||||||
#Replay Center GUI
|
#Replay Center GUI
|
||||||
replaymod.gui.center.logoutcallback=Do you really want to log out?
|
replaymod.gui.center.logoutcallback=Do you really want to log out?
|
||||||
replaymod.gui.center.newest=Newest Replays
|
replaymod.gui.center.top.recent=Recent
|
||||||
replaymod.gui.center.best=Best Replays
|
replaymod.gui.center.top.best=Best
|
||||||
replaymod.gui.center.my=My Replays
|
replaymod.gui.center.top.downloaded=Downloaded
|
||||||
replaymod.gui.center.search=Search Replays
|
replaymod.gui.center.top.favorited=Favorited
|
||||||
|
replaymod.gui.center.top.search=Search
|
||||||
|
|
||||||
replaymod.gui.center.favorite=Favorite
|
replaymod.gui.center.favorite=Favorite
|
||||||
replaymod.gui.center.favorites=Favorites
|
replaymod.gui.center.favorites=Favorites
|
||||||
|
|||||||
Reference in New Issue
Block a user