OSDN Git Service

feat: Non-select mode add v0.2.0
authorhizumiaoba <56146205+hizumiaoba@users.noreply.github.com>
Fri, 23 Jul 2021 01:14:41 +0000 (10:14 +0900)
committerhizumiaoba <56146205+hizumiaoba@users.noreply.github.com>
Fri, 23 Jul 2021 01:14:41 +0000 (10:14 +0900)
src/com/ranfa/lib/Scraping.java
src/com/ranfa/main/DelesteRandomSelector.java

index a5f5b5c..a8abf0b 100644 (file)
@@ -21,6 +21,7 @@ public class Scraping {
 
        private final static String URI = "https://imascg-slstage-wiki.gamerch.com/%E6%A5%BD%E6%9B%B2%E8%A9%B3%E7%B4%B0%E4%B8%80%E8%A6%A7";
        private final static String DBPATH = "database.json";
+       public final static String NONSELECTED = "指定なし";
        public final static String ALL = "全タイプ";
        public final static String CUTE = "キュート";
        public final static String COOL = "クール";
@@ -90,16 +91,21 @@ public class Scraping {
                if(!attribute.equals(ALL)
                                && !attribute.equals(CUTE)
                                && !attribute.equals(COOL)
-                               && !attribute.equals(PASSION))
+                               && !attribute.equals(PASSION)
+                               && !attribute.equals(NONSELECTED))
                        throw new IllegalArgumentException("Illegal attribute value: " + attribute);
                if(data.isEmpty()) {
                        JOptionPane.showMessageDialog(null, "指定された属性の曲は存在しません。\n条件を変えてみてください");
                        throw new IllegalArgumentException("ArrayList must not empty.");
                }
                ArrayList<Song> res = new ArrayList<Song>();
-               for(int i = 0; i < data.size(); i ++) {
-                       if(data.get(i).getAttribute().equals(attribute))
-                               res.add(data.get(i));
+               if(attribute.equals(NONSELECTED)) {
+                       res = data;
+               } else {
+                       for(int i = 0; i < data.size(); i ++) {
+                               if(data.get(i).getAttribute().equals(attribute))
+                                       res.add(data.get(i));
+                       }
                }
                return res;
        }
@@ -115,14 +121,19 @@ public class Scraping {
                                && !difficulty.equals(TRICK)
                                && !difficulty.equals(PIANO)
                                && !difficulty.equals(FORTE)
-                               && !difficulty.equals(WITCH))
+                               && !difficulty.equals(WITCH)
+                               && !difficulty.equals(NONSELECTED))
                        throw new IllegalArgumentException("Illegal difficulty value.");
                if(data.isEmpty())
                        throw new IllegalArgumentException("ArrayList must not empty.");
                ArrayList<Song> res = new ArrayList<Song>();
-               for(int i = 0; i < data.size(); i++) {
-                       if(data.get(i).getDifficulty().equals(difficulty))
-                               res.add(data.get(i));
+               if(difficulty.equals(NONSELECTED)) {
+                       res = data;
+               } else {
+                       for(int i = 0; i < data.size(); i++) {
+                               if(data.get(i).getDifficulty().equals(difficulty))
+                                       res.add(data.get(i));
+                       }
                }
                return res;
        }
index 6bad509..d2db55e 100644 (file)
@@ -38,7 +38,7 @@ import com.ranfa.lib.Settings;
 import com.ranfa.lib.Song;
 import com.ranfa.lib.Version;
 
-@Version(major = 0, minor = 1, patch = 1)
+@Version(major = 0, minor = 2, patch = 0)
 public class DelesteRandomSelector extends JFrame {
 
        private static ArrayList<Song> selectedSongsList = new ArrayList<Song>();
@@ -186,12 +186,13 @@ public class DelesteRandomSelector extends JFrame {
                panelWest.add(labelDifficulty, "2, 2, center, default");
 
                comboDifficultySelect = new JComboBox();
-               comboDifficultySelect.setModel(new DefaultComboBoxModel(new String[] {"DEBUT", "REGULAR", "PRO", "MASTER", "MASTER+", "ⓁMASTER+", "LIGHT", "TRICK", "PIANO", "FORTE", "WITCH"}));
+               comboDifficultySelect.setFont(new Font("UD デジタル 教科書体 NP-B", Font.BOLD, 13));
+               comboDifficultySelect.setModel(new DefaultComboBoxModel(new String[] {"指定なし", "DEBUT", "REGULAR", "PRO", "MASTER", "MASTER+", "ⓁMASTER+", "LIGHT", "TRICK", "PIANO", "FORTE", "WITCH"}));
                panelWest.add(comboDifficultySelect, "2, 4, fill, default");
 
                                comboAttribute = new JComboBox();
                                comboAttribute.setFont(new Font("UD デジタル 教科書体 NP-B", Font.BOLD, 13));
-                               comboAttribute.setModel(new DefaultComboBoxModel(new String[] {"全タイプ", "キュート", "クール", "パッション"}));
+                               comboAttribute.setModel(new DefaultComboBoxModel(new String[] {"指定なし", "全タイプ", "キュート", "クール", "パッション"}));
                                panelWest.add(comboAttribute, "2, 6, fill, default");
 
                                labelLevel = new JLabel("楽曲Lv");
@@ -253,7 +254,7 @@ public class DelesteRandomSelector extends JFrame {
                                String[] tmp = new String[property.getSongLimit()];
                                for(int i = 0; i < property.getSongLimit(); i++) {
                                        int randomInt = random.nextInt(selectedSongsList.size());
-                                       tmp[i] = (i + 1) + "曲目:[" + selectedSongsList.get(randomInt).getDifficulty() + "]「" + selectedSongsList.get(randomInt).getName() + "」!\n\n";
+                                       tmp[i] = (i + 1) + "曲目: " + selectedSongsList.get(randomInt).getAttribute() + " [" + selectedSongsList.get(randomInt).getDifficulty() + "]「" + selectedSongsList.get(randomInt).getName() + "」!(Lv:" + selectedSongsList.get(randomInt).getLevel() + ")\n\n";
                                }
                                String paneString = "";
                                for (int i = 0; i < tmp.length; i++) {