-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
version 1.5 update, no more silly code
- Loading branch information
1 parent
05237de
commit e6f8a5d
Showing
83 changed files
with
2,532 additions
and
1,547 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.