Flash Flash Revolution

Flash Flash Revolution (http://www.flashflashrevolution.com/vbz/index.php)
-   Simulator Files (http://www.flashflashrevolution.com/vbz/forumdisplay.php?f=21)
-   -   SMOC8 package Released (http://www.flashflashrevolution.com/vbz/showthread.php?t=134985)

SKG_Scintill 01-31-2014 01:52 PM

Re: SMOC8 package Released
 
anything else other than nps? well I can add whatever, I still have the code.
and maybe it's not that great to share, it's not exactly user-friendly :p (if you do it wrong, your comp gets stuck in a loop :))

Izzy 01-31-2014 01:55 PM

Re: SMOC8 package Released
 
Post the code and I could maybe re-implement it in c# and add a gui. Or add a java gui, but I'm not sure that is as easy.

Wafles 01-31-2014 01:56 PM

Re: SMOC8 package Released
 
java GUI's are easy as shit if you want to be silly and use something like netbeans lol
arguably easier than visual c# at least

SKG_Scintill 01-31-2014 02:03 PM

Re: SMOC8 package Released
 
trying to figure out how to copy all the code from a project in eclipse

SKG_Scintill 01-31-2014 02:22 PM

Re: SMOC8 package Released
 
Well, I just opened all the classes and copy pasted the code to a single file. I added some comments as dividers, but don't expect awesome commenting. It's a boredom program.

You kids have fun!

Code:

/*--- CONTROLLER PACKAGE ---*/
/*--- New Class ---*/

package controller;

import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JTextField;

import view.Screen;

public class CopyButtonController implements ActionListener {
        private static final CopyButtonController cbc = new CopyButtonController();
       
        private CopyButtonController(){}
       
        public void actionPerformed(ActionEvent arg0){
                Screen s = Screen.getInstance();
                ArrayList<JTextField> fields = s.getFields();
                String[] names = s.getFieldNames();
                String copy = "";
               
                for(int x = 0; x < fields.size(); x++){
                        if(x != 0){
                                copy = copy + "\n";}
                        copy = copy + names[x] + " : " + fields.get(x).getText();
                }
               
                StringSelection out = new StringSelection(copy);
                Toolkit.getDefaultToolkit().getSystemClipboard().setContents(out,out);
        }
       
        public static CopyButtonController getInstance(){
                return cbc;
        }
}

/*--- New Class ---*/

package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import model.PackSelector;

public class OpenButtonController implements ActionListener {
        private static final OpenButtonController obc = new OpenButtonController();

        private OpenButtonController() {
        }

        public void actionPerformed(ActionEvent arg0) {
                PackSelector.getInstance().loadFile();
        }

        public static OpenButtonController getInstance() {
                return obc;
        }
}

/*--- MAIN PACKAGE ---*/
/*--- New Class ---*/

package main;

import model.PackSelector;

public class Starter {
        public static void main(String[] args) {
                PackSelector.getInstance();
        }
}

/*--- MODEL PACKAGE ---*/
/*--- New Class ---*/

package model;

public class Hold {
        int startMeasure;
        int startSnap;
        int totalStartSnaps = -1;
        int endSnap;
        int measures;
        private int index;

        public Hold(int index, int measure, int snap) {
                this.index = index;
                startSnap = snap;
        }

        public int getIndex() {
                return index;
        }
}


/*--- New Class ---*/

package model;

import java.io.File;
import java.io.IOException;

import javax.swing.JFileChooser;
import javax.swing.JPanel;

import view.LoadingScreen;
import view.Screen;

public class PackSelector {
        private static final PackSelector ps = new PackSelector();
        private JFileChooser packChooser;
        private File[] files;

        private PackSelector() {
                packChooser = new JFileChooser("/Program Files/");
                packChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                loadFile();
        }

        public void loadFile() {
                if (packChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
                        long start = System.currentTimeMillis();
                        File dir = packChooser.getSelectedFile();
                        SMFileList sm = SMFileList.getInstance();
                        LoadingScreen ls = LoadingScreen.getInstance();

                        files = dir.listFiles();
                        sm.setListName(dir.getName());
                        sm.getList().clear();
                        ls.setVisible(true);

                        splitDirectory(files, true);
                        sm.setTotalAmountOfStepsJumpsHandsQuadsHoldsMinesMeasuresDifficultiesBPMChangesPackLengthAndAverageBPM();

                        Screen s = Screen.getInstance();
                        s.setFieldText();
                        s.getTimeElapsedLabel().setText(
                                        "Loaded in " + (System.currentTimeMillis() - start)
                                                        / 1000.0 + " seconds.");
                        s.setVisible(true);
                        ls.setVisible(false);
                }
        }

        private void splitDirectory(File[] f, boolean firstSplit) {
                try {
                        for (int x = 0; x < f.length; x++) {
                                if (firstSplit) {
                                        LoadingScreen ls = LoadingScreen.getInstance();
                                        JPanel p = ls.getProgressPanel();
                                        ls.getCurrentLabel().setText(files[x].getName());
                                        p.setSize(
                                                        (int) ((double) (p.getPreferredSize().width * x / files.length)),
                                                        20);
                                        ls.paint(ls.getGraphics());
                                }
                                File temp = f[x];
                                if (temp.isDirectory()) {
                                        splitDirectory(temp.listFiles(), false);
                                } else if (temp.getCanonicalPath().endsWith(".sm")) {
                                        SMFile sm = new SMFile(temp);
                                        if (!sm.getFileText().isEmpty()) {
                                                SMFileList.getInstance().addSMFile(sm);
                                        }
                                }
                        }
                } catch (IOException e) {
                }
        }

        public static PackSelector getInstance() {
                return ps;
        }
}

/*--- New Class ---*/

package model;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;

public class SMFile {
        private ArrayList<String> smFileText = new ArrayList<String>();
        private String fileName;
        private String[] bpmLines, stopLines;
        private int amountOfSteps = 0, amountOfJumps = 0, amountOfHands = 0,
                        amountOfQuads = 0, amountOfHolds = 0, amountOfMines = 0,
                        amountOfMeasures = 0, amountOfDifficulties = 0,
                        amountOfBPMChanges = 1;
        private double fileLength = 0, averageBPM = 0, averageNPS = 0;

        public SMFile(File smFile) {
                String name = smFile.getName();
                fileName = name.substring(0, name.indexOf("."));
                try {
                        FileInputStream file = new FileInputStream(smFile);
                        DataInputStream data = new DataInputStream(file);
                        BufferedReader buffer = new BufferedReader(new InputStreamReader(
                                        data));
                        String line;

                        while ((line = buffer.readLine()) != null) {
                                if (line.length() != 0) {
                                        smFileText.add(line);
                                }
                        }
                        setAmountOfStepsJumpsHandsQuadsHoldsMinesMeasuresDifficultiesAndBPMChanges();
                        setFileLengthAndAverageBPM();
                } catch (Exception e) {
                }
        }

        private String getLineContaining(String text) {
                Iterator<String> i = smFileText.iterator();
                while (i.hasNext()) {
                        String next = i.next();
                        if (next.contains(":")) {
                                String[] split = next.split(":");
                                if (split[0].contains(text)) {
                                        if (!split[1].isEmpty()) {
                                                return split[1].replace(";", "");
                                        }
                                }
                        }
                }
                return null;
        }

        private ArrayList<String> getFileLines() {
                ArrayList<String> lines = new ArrayList<String>();
                boolean startFound = false;

                Iterator<String> i = smFileText.iterator();
                while (i.hasNext()) {
                        String next = i.next();
                        if (!next.endsWith(";") && !next.endsWith(":")
                                        && !next.endsWith("-") && !next.endsWith("measure 1")) {
                                startFound = true;
                        }
                        if (startFound) {
                                lines.add(next);
                                if (next.contains(";")) {
                                        startFound = false;
                                }
                        }
                }

                return lines;
        }

        public String getTitle() {
                return getLineContaining("TITLE");
        }

        public String getSubtitle() {
                return getLineContaining("SUBTITLE");
        }

        public String getArtist() {
                return getLineContaining("ARTIST");
        }

        public String getCredit() {
                return getLineContaining("CREDIT");
        }

        public String getMusicFile() {
                return getLineContaining("MUSIC");
        }

        public String getBackgroundFile() {
                return getLineContaining("BACKGROUND");
        }

        public String getBannerFile() {
                return getLineContaining("BANNER");
        }

        public String getCDTitleFile() {
                return getLineContaining("CDTITLE");
        }

        public int getOffset() {
                String s = getLineContaining("OFFSET");
                if (!s.isEmpty()) {
                        return Integer.parseInt(s);
                }
                return 0;
        }

        public int getSampleStart() {
                String s = getLineContaining("SAMPLESTART");
                if (!s.isEmpty()) {
                        return Integer.parseInt(s);
                }
                return 0;
        }

        public int getSampleLength() {
                String s = getLineContaining("SAMPLELENGTH");
                if (!s.isEmpty()) {
                        return Integer.parseInt(s);
                }
                return 0;
        }

        public Double[] getStops() {
                String s = getLineContaining("STOPS");
                if (!s.isEmpty()) {
                        if (s.contains(",")) {
                                stopLines = s.split(",");
                                ArrayList<Double> stops = new ArrayList<Double>();
                                for (int x = 0; x < stopLines.length; x++) {
                                        stops.add(Double.parseDouble(stopLines[x].split("=")[1]));
                                }
                                return (Double[]) stops.toArray();
                        } else {
                                return new Double[] { Double.parseDouble(s.split("=")[1]) };
                        }
                }
                return new Double[] { 0.0 };
        }

        public void setFileLengthAndAverageBPM() {
                double tempBPM = 0;
                double oldMeasure = 0;
                double newMeasure = 0;
                double tempLength = 0;

                String s = getLineContaining("BPMS");
                if (!s.isEmpty()) {
                        bpmLines = s.split(",");
                        amountOfBPMChanges = bpmLines.length;

                        for (int x = 0; x < bpmLines.length; x++) {
                                String[] split = bpmLines[x].split("=");

                                newMeasure = Double.parseDouble(split[0]);
                                tempBPM = Double.parseDouble(split[1]);
                                tempLength = newMeasure - oldMeasure;

                                if (x != bpmLines.length - 1) {
                                        fileLength += 60 / tempBPM * tempLength;
                                } else {
                                        fileLength += 60 / tempBPM
                                                        * (amountOfMeasures * 4 - newMeasure);
                                }
                                oldMeasure = newMeasure;
                        }
                        averageBPM = amountOfMeasures * 4 / fileLength; // Doesn't work
                        averageNPS = amountOfSteps / (fileLength * amountOfDifficulties);
                }
        }

        public void setAmountOfStepsJumpsHandsQuadsHoldsMinesMeasuresDifficultiesAndBPMChanges() {
                Iterator<String> i = getFileLines().iterator();
                while (i.hasNext()) {
                        boolean containssemicolon = false;
                        String next = i.next();
                        String arrows = next.replaceAll("[^1]", "");
                        String holds = next.replaceAll("[^2]", "");

                        amountOfSteps += next.replaceAll("[^1-2]", "").length();
                        amountOfHolds += holds.length();
                        amountOfMines += next.replaceAll("[^M]", "").length();

                        if (next.contains(",") && !containssemicolon) {
                                amountOfMeasures++;
                        } else if (next.contains(";")) {
                                containssemicolon = true;
                                amountOfDifficulties++;
                        }

                        switch (arrows.length()) {
                        case 2:
                                amountOfJumps++;
                                break;
                        case 3:
                                amountOfHands++;
                                break;
                        case 4:
                                amountOfQuads++;
                                break;
                        }
                        switch (holds.length()) {
                        case 2:
                                amountOfJumps++;
                                break;
                        case 3:
                                amountOfHands++;
                                break;
                        case 4:
                                amountOfQuads++;
                                break;
                        }
                }
        }

        public ArrayList<String> getFileText() {
                return smFileText;
        }

        public String getFileName() {
                return fileName;
        }

        public int getAmountOfSteps() {
                return amountOfSteps;
        }

        public int getAmountOfJumps() {
                return amountOfJumps;
        }

        public int getAmountOfHands() {
                return amountOfHands;
        }

        public int getAmountOfQuads() {
                return amountOfQuads;
        }

        public int getAmountOfHolds() {
                return amountOfHolds;
        }

        public int getAmountOfMines() {
                return amountOfMines;
        }

        public int getAmountOfMeasures() {
                return amountOfMeasures;
        }

        public int getAmountOfDifficulties() {
                return amountOfDifficulties;
        }

        public int getAmountOfBPMChanges() {
                return amountOfBPMChanges;
        }

        public double getRoughFileLength() {
                return fileLength;
        }

        public String getFileLength() {
                int hours = (int) fileLength / 3600;
                int minutes = (int) (fileLength - hours * 3600) / 60;
                int seconds = (int) fileLength - hours * 3600 - minutes * 60;
                String hS = Integer.toString(hours);
                String mS = Integer.toString(minutes);
                String sS = Integer.toString(seconds);
                if (hours < 10) {
                        hS = 0 + hS;
                }
                if (minutes < 10) {
                        mS = 0 + hS;
                }
                if (seconds < 10) {
                        mS = 0 + mS;
                }
                return hS + ":" + mS + ":" + sS;
        }

        public double getAverageBPM() {
                return averageBPM;
        }

        public double getAverageNPS() {
                return averageNPS;
        }
}

/*--- New Class ---*/

package model;

import java.math.BigDecimal;
import java.util.ArrayList;

public class SMFileList {
        private static final SMFileList smfl = new SMFileList();
        private ArrayList<SMFile> smFiles;
        private BigDecimal totalAmountOfSteps = new BigDecimal(0),
                        totalAmountOfJumps = new BigDecimal(0),
                        totalAmountOfHands = new BigDecimal(0),
                        totalAmountOfQuads = new BigDecimal(0),
                        totalAmountOfHolds = new BigDecimal(0),
                        totalAmountOfMines = new BigDecimal(0),
                        totalAmountOfMeasures = new BigDecimal(0),
                        totalAmountOfDifficulties = new BigDecimal(0),
                        totalAmountOfBPMChanges = new BigDecimal(0),
                        packLength = new BigDecimal(0), packAverageBPM = new BigDecimal(0),
                        packAverageNPS = new BigDecimal(0);
        private String name;

        private SMFileList() {
                smFiles = new ArrayList<SMFile>();
        }

        public void addSMFile(SMFile smFile) {
                smFiles.add(smFile);
        }

        public int getAmountOfFiles() {
                return smFiles.size();
        }

        public SMFile getFile(String name) {
                for (int x = 0; x < smFiles.size(); x++) {
                        SMFile next = smFiles.get(x);
                        if (next.getFileName().equals(name)) {
                                return next;
                        }
                }
                return null;
        }

        public void setTotalAmountOfStepsJumpsHandsQuadsHoldsMinesMeasuresDifficultiesBPMChangesPackLengthAndAverageBPM() {
                BigDecimal totalBPMs = new BigDecimal(0);
                for (int x = 0; x < smFiles.size(); x++) {
                        SMFile temp = smFiles.get(x);
                        totalAmountOfSteps = totalAmountOfSteps.add(new BigDecimal(temp
                                        .getAmountOfSteps()));
                        totalAmountOfJumps = totalAmountOfJumps.add(new BigDecimal(temp
                                        .getAmountOfJumps()));
                        totalAmountOfHands = totalAmountOfHands.add(new BigDecimal(temp
                                        .getAmountOfHands()));
                        totalAmountOfQuads = totalAmountOfQuads.add(new BigDecimal(temp
                                        .getAmountOfQuads()));
                        totalAmountOfHolds = totalAmountOfHolds.add(new BigDecimal(temp
                                        .getAmountOfHolds()));
                        totalAmountOfMines = totalAmountOfMines.add(new BigDecimal(temp
                                        .getAmountOfMines()));
                        totalAmountOfMeasures = totalAmountOfMeasures.add(new BigDecimal(
                                        temp.getAmountOfMeasures()));
                        totalAmountOfDifficulties = totalAmountOfDifficulties
                                        .add(new BigDecimal(temp.getAmountOfDifficulties()));
                        totalAmountOfBPMChanges = totalAmountOfBPMChanges
                                        .add(new BigDecimal(temp.getAmountOfBPMChanges()));
                        packLength = packLength.add(new BigDecimal(temp
                                        .getRoughFileLength()));
                        totalBPMs = totalBPMs.add(new BigDecimal(temp.getAverageBPM()));
                }
                packAverageBPM = totalBPMs.divide(new BigDecimal(smFiles.size()), 3,
                                BigDecimal.ROUND_HALF_UP);
                packAverageNPS = totalAmountOfSteps.divide(packLength, 3,
                                BigDecimal.ROUND_HALF_UP);
        }

        public ArrayList<SMFile> getList() {
                return smFiles;
        }

        public String getName() {
                return name;
        }

        public void setListName(String name) {
                this.name = name;
        }

        public static SMFileList getInstance() {
                return smfl;
        }

        public BigDecimal getTotalAmountOfSteps() {
                return totalAmountOfSteps;
        }

        public BigDecimal getTotalAmountOfJumps() {
                return totalAmountOfJumps;
        }

        public BigDecimal getTotalAmountOfHands() {
                return totalAmountOfHands;
        }

        public BigDecimal getTotalAmountOfQuads() {
                return totalAmountOfQuads;
        }

        public BigDecimal getTotalAmountOfHolds() {
                return totalAmountOfHolds;
        }

        public BigDecimal getTotalAmountOfMines() {
                return totalAmountOfMines;
        }

        public BigDecimal getTotalAmountOfMeasures() {
                return totalAmountOfMeasures;
        }

        public BigDecimal getTotalAmountOfDifficulties() {
                return totalAmountOfDifficulties;
        }

        public BigDecimal getTotalAmountOfBPMChanges() {
                return totalAmountOfBPMChanges;
        }

        public BigDecimal getPackAverageBPM() {
                return packAverageBPM;
        }

        public BigDecimal getRoughPackLength() {
                return packLength;
        }

        public String getPackLength() {
                double totalLength = packLength.doubleValue();
                int hours = (int) totalLength / 3600;
                int minutes = (int) (totalLength - hours * 3600) / 60;
                int seconds = (int) totalLength - hours * 3600 - minutes * 60;
                String hS = Integer.toString(hours);
                String mS = Integer.toString(minutes);
                String sS = Integer.toString(seconds);
                if (hours < 10) {
                        hS = 0 + hS;
                }
                if (minutes < 10) {
                        mS = 0 + mS;
                }
                if (seconds < 10) {
                        sS = 0 + sS;
                }
                return hS + ":" + mS + ":" + sS;
        }

        public BigDecimal getPackAverageNPS() {
                return packAverageNPS;
        }
}

/*--- VIEW PACKAGE ---*/
/*--- New Class ---*/

package view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class LoadingScreen extends JFrame {
        private static final long serialVersionUID = 1L;
        private static final LoadingScreen ls = new LoadingScreen();
        private Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        private JLabel label, current;
        private JPanel progress;

        private LoadingScreen() {
                setBackground(Color.white);
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                setLayout(null);
                setResizable(false);
                setSize(screenSize.width / 4, screenSize.height / 4);
                setTitle("Loading...");
                setLocationRelativeTo(null);

                label = new JLabel("Loading files. Please wait...", JLabel.CENTER);
                label.setSize(getWidth(), getHeight() / 3);
                add(label);

                current = new JLabel("", JLabel.CENTER);
                current.setLocation(0, label.getHeight());
                current.setSize(label.getSize());
                add(current);

                progress = new JPanel();
                progress.setBackground(Color.green);
                progress.setLocation(5, getHeight() / 3 * 2);
                progress.setPreferredSize(new Dimension(getWidth() - 10, 20));
                progress.setSize(0, 20);
                add(progress);
        }

        public JLabel getCurrentLabel() {
                return current;
        }

        public JPanel getProgressPanel() {
                return progress;
        }

        public static LoadingScreen getInstance() {
                return ls;
        }
}

/*--- New Class ---*/

package view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class LoadingScreen extends JFrame {
        private static final long serialVersionUID = 1L;
        private static final LoadingScreen ls = new LoadingScreen();
        private Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        private JLabel label, current;
        private JPanel progress;

        private LoadingScreen() {
                setBackground(Color.white);
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                setLayout(null);
                setResizable(false);
                setSize(screenSize.width / 4, screenSize.height / 4);
                setTitle("Loading...");
                setLocationRelativeTo(null);

                label = new JLabel("Loading files. Please wait...", JLabel.CENTER);
                label.setSize(getWidth(), getHeight() / 3);
                add(label);

                current = new JLabel("", JLabel.CENTER);
                current.setLocation(0, label.getHeight());
                current.setSize(label.getSize());
                add(current);

                progress = new JPanel();
                progress.setBackground(Color.green);
                progress.setLocation(5, getHeight() / 3 * 2);
                progress.setPreferredSize(new Dimension(getWidth() - 10, 20));
                progress.setSize(0, 20);
                add(progress);
        }

        public JLabel getCurrentLabel() {
                return current;
        }

        public JPanel getProgressPanel() {
                return progress;
        }

        public static LoadingScreen getInstance() {
                return ls;
        }
}


Here's a link to a runnable .jar: http://www.sendspace.com/file/imb20y
Just be warned:
1. Once it's calculating, there's no "cancel" to select a new folder. It just exits.
2. Because of point 1, be careful what folder you select.
3. "Open" means using it, not going deeper in the directory. Double-clicking a folder goes deeper in the directory. A highlighted/selected folder will be used (not sure what happens if you don't highlight a folder).
4. It doesn't automatically open on top and doesn't show a minimalized tab, you might have to alt+tab a bit to find it.
5. Very minor epilepsy warning, herpaderp java paint function.

Mollocephalus 01-31-2014 03:27 PM

Re: SMOC8 package Released
 
Definitely downloading! :D

Mollocephalus 02-1-2014 02:11 PM

Re: SMOC8 package Released
 
I downloaded and played some files and this pack is HUGE wow, stepchart quality wise it stands on a decent level with a few nice files in it. Lots of jacks, jumpstreams, handstreams and pretty fucked up files, lol.

Leo137 02-2-2014 02:07 AM

Re: SMOC8 package Released
 
It might be iffy but it's being fun as fuck to play those jackstreams

Vendice 02-13-2014 04:50 PM

Re: SMOC8 package Released
 
yuck as fuck


All times are GMT -5. The time now is 02:02 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright FlashFlashRevolution