diff --git a/builds/HentaiGameManager.exe b/builds/HentaiGameManager.exe index a8c209b..cff4210 100644 Binary files a/builds/HentaiGameManager.exe and b/builds/HentaiGameManager.exe differ diff --git a/builds/HentaiGameManager.jar b/builds/HentaiGameManager.jar index e600708..fa02dae 100644 Binary files a/builds/HentaiGameManager.jar and b/builds/HentaiGameManager.jar differ diff --git a/readme.md b/readme.md index a258eb9..d0b39bf 100644 --- a/readme.md +++ b/readme.md @@ -31,7 +31,7 @@ Also, discord integration, because why not - [ ] FAQ - [ ] Optimizations - [ ] Text size small on large display - [Bug here]() -- [ ] Random game choose if you are bored (Maybe with filter) +- [x] Random game choose if you are bored (Maybe with filter) --- diff --git a/src/addUpdRemGames/addGames/addManually.java b/src/addUpdRemGames/addGames/addManually.java index f374d6d..c4d6c65 100644 --- a/src/addUpdRemGames/addGames/addManually.java +++ b/src/addUpdRemGames/addGames/addManually.java @@ -28,7 +28,7 @@ public class addManually { public static void addOneGameToFile(){ boolean repeat = true; while (repeat) { - JPanel panel = new JPanel(new GridLayout(14*2, 0)); + JPanel panel = new JPanel(new GridLayout(8*2, 2)); JTextField id = new JTextField(6); JTextField name = new JTextField(40); diff --git a/src/addUpdRemGames/updateGames/updateManually.java b/src/addUpdRemGames/updateGames/updateManually.java index 81f609d..3474a05 100644 --- a/src/addUpdRemGames/updateGames/updateManually.java +++ b/src/addUpdRemGames/updateGames/updateManually.java @@ -27,7 +27,7 @@ public class updateManually { static String[] base = langLoad.base, basic = langLoad.basic, jla = langLoad.jlapa, folder = langLoad.folder, jrb = langLoad.jrabu; public static void updateOneGameFromToFile(){ JOptionPane optionPane = new JOptionPane(); - JPanel panel = new JPanel(new GridLayout(14*2, 0)); + JPanel panel = new JPanel(new GridLayout(8*2, 2)); JTextField id = new JTextField(); Object[] message = { jla[0]!=null?jla[0]:"ID of the game to update:", id diff --git a/src/main/application/frameCreate.java b/src/main/application/frameCreate.java index cc8b483..a1be375 100644 --- a/src/main/application/frameCreate.java +++ b/src/main/application/frameCreate.java @@ -38,7 +38,7 @@ public class frameCreate extends JFrame implements ActionListener { JMenuItem saveFileToDifferent, refreshTable, refreshFromAPI; JMenu random; - JMenuItem fullRandom, randomDev, randomEngine, randomSite; + JMenuItem fullRandom, randomDev, randomProgress, randomEngine, randomSite; JMenu search; JMenuItem searchById, searchByName, searchByDeveloper; @@ -89,9 +89,10 @@ public void WindowCreate(Object[][] dataFromXMLFile) { // TODO add language for random mb.add(random = new JMenu("Random")); random.add(fullRandom = new JMenuItem("Fully random game")); fullRandom.setActionCommand("RandomFully"); - random.add(randomDev = new JMenuItem("Random game from a developer")); randomDev.setActionCommand("RandomDev"); - random.add(randomEngine = new JMenuItem("Random with specific engine")); randomEngine.setActionCommand("RandomEngine"); - random.add(randomSite = new JMenuItem("Random from specific site")); randomSite.setActionCommand("RandomSite"); + random.add(randomDev = new JMenuItem("Random game by developer")); randomDev.setActionCommand("RandomDev"); + random.add(randomProgress = new JMenuItem("Random by player progress")); randomProgress.setActionCommand("RandomProgress"); + random.add(randomEngine = new JMenuItem("Random by engine")); randomEngine.setActionCommand("RandomEngine"); + random.add(randomSite = new JMenuItem("Random by site")); randomSite.setActionCommand("RandomSite"); mb.add(search = new JMenu(bu[1]!=null?bu[1]:"Search")); search.add(searchById = new JMenuItem(bu[15]!=null?bu[15]:"Search by ID")); searchById.setActionCommand("Search by ID"); @@ -137,7 +138,8 @@ public void WindowCreate(Object[][] dataFromXMLFile) { refreshFromAPI.addActionListener(this); fullRandom.addActionListener(this); randomDev.addActionListener(this); - randomEngine.addActionListener(this); randomSite.addActionListener(this); + randomProgress.addActionListener(this); randomEngine.addActionListener(this); + randomSite.addActionListener(this); searchById.addActionListener(this);searchByName.addActionListener(this); searchByDeveloper.addActionListener(this); @@ -236,6 +238,7 @@ public void actionPerformed(ActionEvent e) { case "RandomFully": randomGame.fullyRandom(); break; case "RandomDev": randomGame.randomFromDeveloper(); break; + case "RandomProgress": randomGame.randomFromProgress(); break; case "RandomEngine": randomGame.randomWithEngine(); break; case "RandomSite": randomGame.randomFromSite(); break; @@ -311,6 +314,7 @@ private void WindowRefresh(){ random.setBackground(bg); random.setForeground(fg); fullRandom.setBackground(bg); fullRandom.setForeground(fg); randomDev.setBackground(bg); randomDev.setForeground(fg); + randomProgress.setBackground(bg); randomProgress.setForeground(fg); randomEngine.setBackground(bg); randomEngine.setForeground(fg); randomSite.setBackground(bg); randomSite.setForeground(fg); @@ -386,6 +390,7 @@ private void WindowRefresh(){ random.setBackground(null); random.setForeground(null); fullRandom.setBackground(null); fullRandom.setForeground(null); randomDev.setBackground(null); randomDev.setForeground(null); + randomProgress.setBackground(null); randomProgress.setForeground(null); randomEngine.setBackground(null); randomEngine.setForeground(null); randomSite.setBackground(null); randomSite.setForeground(null); diff --git a/src/main/application/randomGame.java b/src/main/application/randomGame.java index bf5d3fe..888b78b 100644 --- a/src/main/application/randomGame.java +++ b/src/main/application/randomGame.java @@ -26,75 +26,64 @@ public static void fullyRandom() { } public static void randomFromDeveloper() { - Integer devLegth = 0; String wantedRandomDev; - wantedRandomDev = JOptionPane.showInputDialog(null, "Enter developer name you wish to search for:", "Random game from developer", JOptionPane.QUESTION_MESSAGE); - for (int i = 0; i < allGames.length; i++) { - if (allGames[i][3].equals(wantedRandomDev)) { - devLegth++; - } - } - if (devLegth == 0) { JOptionPane.showMessageDialog(null, "No games found from developer: "+wantedRandomDev, "Random game from developer", JOptionPane.INFORMATION_MESSAGE); return;} - Object[][] gamesFromDevs = new Object[devLegth][allGames[0].length]; - for (int i = 0; i < allGames.length; i++) { - if (allGames[i][3].equals(wantedRandomDev)) { - gamesFromDevs[i] = allGames[i]; - } - } - Integer random = (int) (Math.random() * devLegth); - Object[] result = gamesFromDevs[random]; - resultShow(result, "Random game from developer"); + String wantedRandomDev = JOptionPane.showInputDialog(null, "Enter developer name you wish to search for:", "Random game from developer", JOptionPane.QUESTION_MESSAGE); + if (wantedRandomDev == null) { return; } + Object[] result = randomFilter(3, "from developer", wantedRandomDev); + if (result != null) {resultShow(result, "Random game from developer");} + } + + public static void randomFromProgress(){ + JRadioButton howFarUserPlayed_NotPlayed = new JRadioButton("Not played", true), howFarUserPlayed_Playing = new JRadioButton("In progress", false), howFarUserPlayed_Finished = new JRadioButton("Finish", false), howFarUserPlayed_100Percent = new JRadioButton("100% Finished", false); + howFarUserPlayed_NotPlayed.setActionCommand("Not played"); howFarUserPlayed_Playing.setActionCommand("In progress"); howFarUserPlayed_Finished.setActionCommand("Finish"); howFarUserPlayed_100Percent.setActionCommand("100% Finished"); + ButtonGroup progressGroup = new ButtonGroup(); progressGroup.add(howFarUserPlayed_NotPlayed); progressGroup.add(howFarUserPlayed_Playing); progressGroup.add(howFarUserPlayed_Finished); progressGroup.add(howFarUserPlayed_100Percent); + JPanel progressPanel = new JPanel(); progressPanel.add(howFarUserPlayed_NotPlayed); progressPanel.add(howFarUserPlayed_Playing); progressPanel.add(howFarUserPlayed_Finished); progressPanel.add(howFarUserPlayed_100Percent); + JOptionPane.showMessageDialog(null, progressPanel, "Random game from progress", JOptionPane.QUESTION_MESSAGE); + Object[] result = randomFilter(10, "from progress", progressGroup.getSelection().getActionCommand()); + if (result != null) {resultShow(result, "Random game from progress");} } public static void randomWithEngine() { - Integer engineLegth = 0; String wantedRandomEngine; JRadioButton engine_Flash = new JRadioButton("Flash"), engine_HTML = new JRadioButton("HTML"), engine_Java = new JRadioButton("Java"), engine_QSP = new JRadioButton("QSP"), engine_RenPy = new JRadioButton("RenPy"), engine_RPGmaker = new JRadioButton("RPGmaker"), engine_Unity = new JRadioButton("Unity"), engine_Unreal = new JRadioButton("Unreal"), engine_WinGit = new JRadioButton("WinGit"), engine_WolfRPG = new JRadioButton("WolfRPG"), engine_other = new JRadioButton("other/unknown", true); - engine_Flash.setActionCommand("Flash"); engine_HTML.setActionCommand("HTML"); engine_Java.setActionCommand("Java"); engine_QSP.setActionCommand("QSP"); engine_RenPy.setActionCommand("RenPy"); engine_RPGmaker.setActionCommand("RPGmaker"); engine_Unity.setActionCommand("Unity"); engine_Unreal.setActionCommand("Unreal"); engine_WinGit.setActionCommand("WinGit"); engine_WolfRPG.setActionCommand("WolfRPG"); engine_other.setActionCommand("other/unknown"); + engine_Flash.setActionCommand("Flash"); engine_HTML.setActionCommand("HTML"); engine_Java.setActionCommand("Java"); engine_QSP.setActionCommand("QSP"); engine_RenPy.setActionCommand("Ren'Py"); engine_RPGmaker.setActionCommand("RPGM"); engine_Unity.setActionCommand("Unity"); engine_Unreal.setActionCommand("Unreal Engine"); engine_WinGit.setActionCommand("WinGit"); engine_WolfRPG.setActionCommand("WolfRPG"); engine_other.setActionCommand("other/unknown"); ButtonGroup engineGroup = new ButtonGroup(); engineGroup.add(engine_Flash); engineGroup.add(engine_HTML); engineGroup.add(engine_Java); engineGroup.add(engine_QSP); engineGroup.add(engine_RenPy); engineGroup.add(engine_RPGmaker); engineGroup.add(engine_Unity); engineGroup.add(engine_Unreal); engineGroup.add(engine_WinGit); engineGroup.add(engine_WolfRPG); engineGroup.add(engine_other); JLabel engineLabel = new JLabel("Select engine to search for:"); JPanel enginePanel = new JPanel(); enginePanel.add(engineLabel); enginePanel.add(engine_Flash); enginePanel.add(engine_HTML); enginePanel.add(engine_Java); enginePanel.add(engine_QSP); enginePanel.add(engine_RenPy); enginePanel.add(engine_RPGmaker); enginePanel.add(engine_Unity); enginePanel.add(engine_Unreal); enginePanel.add(engine_WinGit); enginePanel.add(engine_WolfRPG); enginePanel.add(engine_other); JOptionPane.showMessageDialog(null, enginePanel, "Random game with engine", JOptionPane.QUESTION_MESSAGE); - wantedRandomEngine = engineGroup.getSelection().getActionCommand(); - for (int i = 0; i < allGames.length; i++) { - if (allGames[i][12].equals(wantedRandomEngine)) { - engineLegth++; - } - } - if (engineLegth == 0) { JOptionPane.showMessageDialog(null, "No games found with engine: "+wantedRandomEngine, "Random game with engine", JOptionPane.INFORMATION_MESSAGE); return;} - Object[][] gamesWithEngine = new Object[engineLegth][allGames[0].length]; - for (int i = 0; i < allGames.length; i++) { - if (allGames[i][12].equals(wantedRandomEngine)) { - gamesWithEngine[i] = allGames[i]; - } - } - Integer random = (int) (Math.random() * engineLegth); - Object[] result = gamesWithEngine[random]; - resultShow(result, "Random game with engine"); + Object[] result = randomFilter(12, "with engine", engineGroup.getSelection().getActionCommand()); + if (result != null) {resultShow(result, "Random game with engine");} } public static void randomFromSite() { - Integer siteLegth = 0; String wantedRandomSite; JRadioButton site_F95 = new JRadioButton("F95zone"), site_man = new JRadioButton("Manual", true); site_F95.setActionCommand("f95"); site_man.setActionCommand("man"); ButtonGroup sitesGroup = new ButtonGroup(); sitesGroup.add(site_F95); sitesGroup.add(site_man); JLabel siteLabel = new JLabel("Select site to search from:"); JPanel sitePanel = new JPanel(); sitePanel.add(siteLabel) ;sitePanel.add(site_F95); sitePanel.add(site_man); JOptionPane.showMessageDialog(null, sitePanel, "Random game from site", JOptionPane.QUESTION_MESSAGE); - wantedRandomSite = sitesGroup.getSelection().getActionCommand(); + Object[] result = randomFilter(0, "from site", sitesGroup.getSelection().getActionCommand()); + if (result != null) {resultShow(result, "Random game from site");} + } + + private static Object[] randomFilter(Integer place, String fromWith, String wanted){ + Integer length = 0; + Object[] result; for (int i = 0; i < allGames.length; i++) { - if (allGames[i][0].equals(wantedRandomSite)) { - siteLegth++; + if (allGames[i][place].toString().contains(wanted)) { + length++; } } - if (siteLegth == 0) { JOptionPane.showMessageDialog(null, "No games found from site: "+wantedRandomSite, "Random game from site", JOptionPane.INFORMATION_MESSAGE); return;} - Object[][] gamesFromSite = new Object[siteLegth][allGames[0].length]; + if (length == 0) { JOptionPane.showMessageDialog(null, "No games found "+fromWith+": "+wanted, "Random game "+fromWith, JOptionPane.INFORMATION_MESSAGE); return null;} + Object[][] gamesFromSite = new Object[length][allGames[0].length]; + Integer counter = 0; for (int i = 0; i < allGames.length; i++) { - if (allGames[i][0].equals(wantedRandomSite)) { - gamesFromSite[i] = allGames[i]; + if (allGames[i][place].toString().contains(wanted)) { + gamesFromSite[counter] = allGames[i]; + counter++; } } - Integer random = (int) (Math.random() * siteLegth); - Object[] result = gamesFromSite[random]; - resultShow(result, "Random game from site"); + Integer random = (int) (Math.random() * length); + result = gamesFromSite[random]; + return result; } private static void resultShow(Object[] result, String title) {