Skip to content

Commit

Permalink
Another hack, the last one added bga images support...
Browse files Browse the repository at this point in the history
this add video, we have bga video support.
Thanks to the vlcj project and the VLC project.

We can't distribute the vlc files because licences issues and lazyness (D:)
In the Configuration tab you can select it, don't forget to save after.
Also:
If you are running a 64-bit JVM, then you need a 64-bit build of vlc.
If you are running a 32-bit JVM, then you need a 32-bit build of vlc.
  • Loading branch information
mrcdk committed Apr 3, 2012
1 parent 4b68645 commit 7bb47ee
Show file tree
Hide file tree
Showing 17 changed files with 308 additions and 32 deletions.
Binary file added lib/jna-3.4.0.jar
Binary file not shown.
Binary file added lib/platform-3.4.0.jar
Binary file not shown.
Binary file added lib/vlcj-2.0.0.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ excludes=
file.reference.chardet.jar=lib/chardet.jar
file.reference.jinput.jar=lib\\jinput.jar
file.reference.jlayer-1.0.1-libgdx.jar=lib/jlayer-1.0.1-libgdx.jar
file.reference.jna-3.4.0.jar=lib/jna-3.4.0.jar
file.reference.jorbis.jar=lib\\jorbis.jar
file.reference.lwjgl.jar=lib\\lwjgl.jar
file.reference.lwjgl_util.jar=lib\\lwjgl_util.jar
file.reference.lzma.jar=lib\\lzma.jar
file.reference.platform-3.4.0.jar=lib/platform-3.4.0.jar
file.reference.vlcj-2.0.0.jar=lib/vlcj-2.0.0.jar
file.reference.voile.jar=lib/voile.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
Expand All @@ -45,6 +48,9 @@ javac.classpath=\
${file.reference.lwjgl.jar}:\
${file.reference.lwjgl_util.jar}:\
${file.reference.lzma.jar}:\
${file.reference.jna-3.4.0.jar}:\
${file.reference.platform-3.4.0.jar}:\
${file.reference.vlcj-2.0.0.jar}:\
${file.reference.chardet.jar}:\
${file.reference.voile.jar}:\
${file.reference.jlayer-1.0.1-libgdx.jar}:\
Expand Down
4 changes: 4 additions & 0 deletions parsers/src/org/open2jam/parsers/BMSChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public String getGenre() {
public String getNoter() {
return noter;
}

public boolean hasVideo() {
return BMSParser.hasVideo(this);
}

public Map<Integer,SampleData> getSamples() {
return BMSParser.getSamples(this);
Expand Down
45 changes: 43 additions & 2 deletions parsers/src/org/open2jam/parsers/BMSParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private static BMSChart parseBMSHeader(File f) throws IOException
if(cmd.startsWith("#BMP")){
int id = Integer.parseInt(cmd.replaceFirst("#BMP",""), 36);
String name = st.nextToken("").trim();
chart.image_index.put(id, name);
chart.bga_index.put(id, name);
continue;
}
Matcher note_match = note_line.matcher(cmd);
Expand Down Expand Up @@ -484,7 +484,7 @@ public boolean accept(File dir, String name) {

List<File> files = Arrays.asList(chart.source.getParentFile().listFiles(filter));

Iterator<Entry<Integer, String>> it_images = chart.image_index.entrySet().iterator();
Iterator<Entry<Integer, String>> it_images = chart.bga_index.entrySet().iterator();
while(it_images.hasNext()) {
Entry<Integer, String> entry = it_images.next();

Expand All @@ -504,4 +504,45 @@ public boolean accept(File dir, String name) {
}
return images;
}

static boolean hasVideo(BMSChart chart) {

FilenameFilter filter = new FilenameFilter() {

public boolean accept(File dir, String name) {
String n = name.substring(name.lastIndexOf("."), name.length());

return (n.equalsIgnoreCase(".avi")
|| n.equalsIgnoreCase(".mpg")
|| n.equalsIgnoreCase(".mpeg")
|| n.equalsIgnoreCase(".mov")
|| n.equalsIgnoreCase(".mkv")
|| n.equalsIgnoreCase(".flv")
|| n.equalsIgnoreCase(".mp4"));
}
};

List<File> files = Arrays.asList(chart.source.getParentFile().listFiles(filter));

Iterator<Entry<Integer, String>> it_images = chart.bga_index.entrySet().iterator();
while(it_images.hasNext()) {
Entry<Integer, String> entry = it_images.next();

Iterator<File> it_files = files.iterator();
while(it_files.hasNext()) {
File f = it_files.next();
String in = entry.getValue().toLowerCase();
String fn = f.getName().toLowerCase();
String ext = fn.substring(fn.lastIndexOf("."), fn.length());
in = in.substring(0, in.lastIndexOf("."));
fn = fn.substring(0,fn.lastIndexOf("."));
if(in.equals(fn)) {
chart.video = f;
return true;
}
}
}

return false;
}
}
14 changes: 12 additions & 2 deletions parsers/src/org/open2jam/parsers/Chart.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ public abstract class Chart implements Comparable<Chart>, java.io.Serializable
protected int duration = 0;

protected File image_cover = null;
protected File video = null;

protected Map<Integer, String> sample_index = new HashMap<Integer, String>();
protected Map<Integer, String> image_index = new HashMap<Integer, String>();
protected Map<Integer, String> bga_index = new HashMap<Integer, String>();

/** the File object to the source file of this header */
public abstract File getSource();
Expand Down Expand Up @@ -97,6 +98,15 @@ public Map<Integer, File> getImages() {
public boolean hasCover() {
return image_cover != null;
}

/** Return true if the chart has a video */
public boolean hasVideo() {
return video != null;
}

public File getVideo() {
return video;
}

/** Get the sample index of the chart */
public Map<Integer, String> getSampleIndex() {
Expand All @@ -105,7 +115,7 @@ public Map<Integer, String> getSampleIndex() {

/** Get the image index of the chart */
public Map<Integer, String> getImageIndex() {
return image_index;
return bga_index;
}

/** Copy the sample files to another directory */
Expand Down
3 changes: 3 additions & 0 deletions parsers/src/org/open2jam/parsers/EventList.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public void fixEventList(boolean fix_broken_longnotes, boolean fix_autoplay_long

if(fix_broken_longnotes) {
Event.Channel c = e.getChannel();

if(c == Event.Channel.AUTO_PLAY) continue;

switch(e.getFlag()){
case NONE:
if(lnchan.containsKey(c)) {
Expand Down
11 changes: 11 additions & 0 deletions src/org/open2jam/GameOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public enum ChannelMod implements Serializable {
private boolean vsync = true;

private int width,height,bpp,freq;

// VLC lib path
private String vlc = "";

//public constructor. give default options
public GameOptions() {
Expand Down Expand Up @@ -246,6 +249,14 @@ public void setVsync(boolean vsync) {
public boolean getVsync() {
return vsync;
}

public void setVLC(String path) {
this.vlc = path;
}

public String getVLC() {
return vlc;
}

public void setDisplay(DisplayMode dm) {
this.width = dm.getWidth();
Expand Down
21 changes: 20 additions & 1 deletion src/org/open2jam/gui/parts/Configuration.form
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<Group type="103" groupAlignment="2" attributes="0">
<Component id="bSave" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="panel_keys" alignment="2" max="32767" attributes="0"/>
<Component id="lbl_vlc" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="btn_vlc" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
Expand All @@ -32,8 +34,12 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="panel_keys" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lbl_vlc" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btn_vlc" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Component id="bSave" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="152" max="32767" attributes="0"/>
<EmptySpace pref="91" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down Expand Up @@ -147,5 +153,18 @@
</Container>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="lbl_vlc">
<Properties>
<Property name="text" type="java.lang.String" value="VLC isn&apos;t selected"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btn_vlc">
<Properties>
<Property name="text" type="java.lang.String" value="Select VLC path"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btn_vlcActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>
76 changes: 74 additions & 2 deletions src/org/open2jam/gui/parts/Configuration.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package org.open2jam.gui.parts;

import com.sun.jna.NativeLibrary;
import java.awt.Font;
import java.io.File;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import javax.swing.table.DefaultTableModel;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.open2jam.Config;
import org.open2jam.GameOptions;
import org.open2jam.parsers.Event;
import org.open2jam.render.lwjgl.TrueTypeFont;

Expand All @@ -24,11 +29,39 @@ public class Configuration extends javax.swing.JPanel {

private HashMap<Integer, Event.Channel> table_map = new HashMap<Integer,Event.Channel>();

private String vlc_path;

private static FileFilter vlc_filter = new FileFilter() {

@Override
public boolean accept(File file) {
if(file.isDirectory()) return true;

String name = file.getName().toLowerCase();
if(name.startsWith("libvlc")) return true;

return false;
}

@Override
public String getDescription() {
return "libvlc file";
}
};

/** Creates new form Configuration */
public Configuration() {
initComponents();

loadTableKeys(Config.KeyboardType.K7);

vlc_path = Config.getGameOptions().getVLC();
if(vlc_path.isEmpty()) {
lbl_vlc.setText("Select the VLC path");
} else {
lbl_vlc.setText("VLC Path: "+vlc_path);
}

}

/** This method is called from within the constructor to
Expand All @@ -46,6 +79,8 @@ private void initComponents() {
combo_keyboardConfig = new javax.swing.JComboBox();
tKeys_scroll = new javax.swing.JScrollPane();
tKeys = new javax.swing.JTable();
lbl_vlc = new javax.swing.JLabel();
btn_vlc = new javax.swing.JButton();

bSave.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
bSave.setText("Save");
Expand Down Expand Up @@ -129,6 +164,15 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
);

lbl_vlc.setText("VLC isn't selected");

btn_vlc.setText("Select VLC path");
btn_vlc.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_vlcActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
Expand All @@ -137,7 +181,9 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(bSave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(panel_keys, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(panel_keys, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lbl_vlc)
.addComponent(btn_vlc))
.addContainerGap())
);
layout.setVerticalGroup(
Expand All @@ -146,8 +192,12 @@ public void mouseClicked(java.awt.event.MouseEvent evt) {
.addContainerGap()
.addComponent(panel_keys, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lbl_vlc)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btn_vlc)
.addGap(18, 18, 18)
.addComponent(bSave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(152, Short.MAX_VALUE))
.addContainerGap(91, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents

Expand All @@ -162,6 +212,10 @@ private void bSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:e
default: return;
}
Config.setKeyboardMap(kb_map, kt);
NativeLibrary.addSearchPath("libvlc", vlc_path);
GameOptions op = Config.getGameOptions();
op.setVLC(vlc_path);
Config.setGameOptions(op);
}//GEN-LAST:event_bSaveActionPerformed

private void tKeysMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tKeysMouseClicked
Expand Down Expand Up @@ -195,10 +249,28 @@ private void combo_keyboardConfigActionPerformed(java.awt.event.ActionEvent evt)
}
}//GEN-LAST:event_combo_keyboardConfigActionPerformed

private void btn_vlcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_vlcActionPerformed
JFileChooser jfc = new JFileChooser();
if(!vlc_path.isEmpty())
jfc.setCurrentDirectory(new File(vlc_path));

jfc.setDialogTitle("Choose the libvlc file");

jfc.addChoosableFileFilter(vlc_filter);

jfc.setAcceptAllFileFilterUsed(false);
if (jfc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
vlc_path = jfc.getSelectedFile().getParent();
lbl_vlc.setText("VLC Path: "+vlc_path);
}
}//GEN-LAST:event_btn_vlcActionPerformed

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton bSave;
private javax.swing.JButton btn_vlc;
private javax.swing.JComboBox combo_keyboardConfig;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel lbl_vlc;
private javax.swing.JPanel panel_keys;
private javax.swing.JTable tKeys;
private javax.swing.JScrollPane tKeys_scroll;
Expand Down
Loading

0 comments on commit 7bb47ee

Please sign in to comment.