Skip to content

Commit

Permalink
version 1.5 update, no more silly code
Browse files Browse the repository at this point in the history
  • Loading branch information
stringflow committed Dec 18, 2018
1 parent 05237de commit e6f8a5d
Show file tree
Hide file tree
Showing 83 changed files with 2,532 additions and 1,547 deletions.
18 changes: 18 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="res"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/jnativehook-2.1.0.jar"/>
<classpathentry kind="lib" path="lib/lwjgl_util.jar"/>
<classpathentry kind="lib" path="lib/lwjgl.jar">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="FlowTimer/native/windows"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
9 changes: 1 addition & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
# output files
out/*
src/META-INF/*

# IntelliJ files
.idea/*
*.iml
*.eml
*.userlibraries
bin/*
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>FlowTimer</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=10
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=10
1 change: 0 additions & 1 deletion README.md

This file was deleted.

Binary file removed lib/ResourceLoading.jar
Binary file not shown.
Binary file removed lib/TinySound.jar
Binary file not shown.
Binary file removed lib/ini4j-0.5.4-jdk14.jar
Binary file not shown.
Binary file removed lib/ini4j-0.5.4.jar
Binary file not shown.
Binary file removed lib/jorbis-0.0.17.jar
Binary file not shown.
Binary file added lib/lwjgl.jar
Binary file not shown.
Binary file added lib/lwjgl_util.jar
Binary file not shown.
Binary file removed lib/tritonus_share.jar
Binary file not shown.
Binary file removed lib/vorbisspi1.0.3.jar
Binary file not shown.
Binary file added native/linux/libjinput-linux.so
Binary file not shown.
Binary file added native/linux/libjinput-linux64.so
Binary file not shown.
Binary file added native/linux/liblwjgl.so
Binary file not shown.
Binary file added native/linux/liblwjgl64.so
Binary file not shown.
Binary file added native/linux/libopenal.so
Binary file not shown.
Binary file added native/linux/libopenal64.so
Binary file not shown.
Binary file added native/macosx/libjinput-osx.dylib
Binary file not shown.
Binary file added native/macosx/liblwjgl.dylib
Binary file not shown.
Binary file added native/macosx/openal.dylib
Binary file not shown.
Binary file added native/solaris/liblwjgl.so
Binary file not shown.
Binary file added native/solaris/liblwjgl64.so
Binary file not shown.
Binary file added native/solaris/libopenal.so
Binary file not shown.
Binary file added native/solaris/libopenal64.so
Binary file not shown.
Binary file added native/windows/OpenAL32.dll
Binary file not shown.
Binary file added native/windows/OpenAL64.dll
Binary file not shown.
Binary file added native/windows/jinput-dx8.dll
Binary file not shown.
Binary file added native/windows/jinput-dx8_64.dll
Binary file not shown.
Binary file added native/windows/jinput-raw.dll
Binary file not shown.
Binary file added native/windows/jinput-raw_64.dll
Binary file not shown.
Binary file added native/windows/lwjgl.dll
Binary file not shown.
Binary file added native/windows/lwjgl64.dll
Binary file not shown.
Binary file added res/audio/beep.wav
Binary file not shown.
Binary file added res/audio/clap.wav
Binary file not shown.
Binary file removed res/audio/click2.wav
Binary file not shown.
Binary file removed res/audio/snare.wav
Binary file not shown.
6 changes: 0 additions & 6 deletions res/audio_map.txt

This file was deleted.

Binary file removed res/image/nidos.png
Binary file not shown.
67 changes: 0 additions & 67 deletions res/layout/mainFrame.fxml

This file was deleted.

112 changes: 0 additions & 112 deletions res/layout/settingsWindow.fxml

This file was deleted.

71 changes: 71 additions & 0 deletions src/flowtimer/AudioEngine.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package flowtimer;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.AL10;
import org.lwjgl.util.WaveData;

import java.nio.FloatBuffer;
import java.util.ArrayList;

import static org.lwjgl.openal.AL10.*;

public class AudioEngine {

private static final float PITCH = 1.0f;
private static final float GAIN = 1.0f;
private static final FloatBuffer SOURCE_POSITION = BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).rewind();
private static final FloatBuffer SOURCE_VELOCITY = BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).rewind();
private static final FloatBuffer LISTENER_POSITION = BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).rewind();
private static final FloatBuffer LISTENER_VELOCITY = BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).rewind();
private static final FloatBuffer LISTENER_ORIENTATION = BufferUtils.createFloatBuffer(6).put(new float[] {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f}).rewind();

private static ArrayList<Integer> bufferList;
private static ArrayList<Integer> sourceList;

public static void init() {
try {
AL.create();
alGetError();
alListener(AL_POSITION, LISTENER_POSITION);
alListener(AL_VELOCITY, LISTENER_VELOCITY);
alListener(AL_ORIENTATION, LISTENER_ORIENTATION);
bufferList = new ArrayList<>();
sourceList = new ArrayList<>();
} catch(Exception e) {
ErrorHandler.handleException(e, false);
}
}

public static int createSource(String filePath) {
int buffer = alGenBuffers();
int source = alGenSources();
try {
WaveData waveFile = WaveData.create(AudioEngine.class.getResource(filePath));
alBufferData(buffer, waveFile.format, waveFile.data, waveFile.samplerate);
waveFile.dispose();
if(alGetError() != AL_NO_ERROR) {
throw new RuntimeException("Error while loading audio file! " + filePath);
}
alSourcei(source, AL_BUFFER, buffer);
alSourcef(source, AL_PITCH, PITCH);
alSourcef(source, AL_GAIN, GAIN);
alSource(source, AL_POSITION, SOURCE_POSITION);
alSource(source, AL_VELOCITY, SOURCE_VELOCITY);
bufferList.add(buffer);
sourceList.add(source);
} catch(Exception e) {
ErrorHandler.handleException(e, false);
}
return source;
}

public static void playSource(int source) {
alSourcePlay(source);
}

public static void dispose() {
bufferList.forEach(AL10::alDeleteBuffers);
sourceList.forEach(AL10::alDeleteSources);
AL.destroy();
}
}
18 changes: 18 additions & 0 deletions src/flowtimer/ColumnLabel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package flowtimer;
import javax.swing.JLabel;

public class ColumnLabel extends JLabel {

private static final long serialVersionUID = 6275772904824072659L;

public static final int WIDTH = 55;
public static final int HEIGHT = 20;
public static final int X_BASE = 146;
public static final int X_PADDING = 5;
public static final int Y_BASE = 16;

public ColumnLabel(String text, int index) {
super(text);
setBounds(X_BASE + index * (X_PADDING + WIDTH), Y_BASE, WIDTH, HEIGHT);
}
}
27 changes: 27 additions & 0 deletions src/flowtimer/ErrorHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package flowtimer;

import java.io.PrintWriter;

import javax.swing.JOptionPane;

public class ErrorHandler {

public static void handleException(Exception e, boolean delSettings) {
JOptionPane.showMessageDialog(null, "An error has occured when loading the settings file, please send the traceback.txt file to the developer for further help.", "Error", JOptionPane.ERROR_MESSAGE);
try {
PrintWriter writer = new PrintWriter("traceback.txt");
e.printStackTrace(writer);
writer.flush();
writer.close();
} catch (Exception e1) {
e1.printStackTrace();
}
if(delSettings) {
int result = JOptionPane.showOptionDialog(null, "Do you want to delete the settings file?", "Error", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, 0);
if(result == 0) {
FlowTimer.SETTINGS_FILE.delete();
}
}
System.exit(1);
}
}
Loading

0 comments on commit e6f8a5d

Please sign in to comment.