This commit is contained in:
168
java/src/wiiusej/test/GuitarHero3GuiTest.java
Normal file
168
java/src/wiiusej/test/GuitarHero3GuiTest.java
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* GuitarHeroGUITest.java
|
||||
*
|
||||
* Created on 12 juin 2008, 23:10
|
||||
*/
|
||||
package wiiusej.test;
|
||||
|
||||
import wiiusej.Wiimote;
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.GuitarHeroEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.utils.WiimoteListener;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
|
||||
/**
|
||||
* This frame is used to display events from a Guitar Hero 3.
|
||||
* @author guiguito
|
||||
*/
|
||||
public class GuitarHero3GuiTest extends javax.swing.JFrame implements WiimoteListener {
|
||||
|
||||
private Wiimote wiimote;
|
||||
private static int MAX_WHAMMY_BAR = 100;
|
||||
|
||||
/** Creates new form GuitarHeroGUITest */
|
||||
public GuitarHero3GuiTest(Wiimote wiimote) {
|
||||
initComponents();
|
||||
this.wiimote = wiimote;
|
||||
whammyProgressBar.setMaximum(MAX_WHAMMY_BAR);
|
||||
registerListeners();
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
wiimote.addWiiMoteEventListeners(this);
|
||||
//register panel buttons
|
||||
wiimote.addWiiMoteEventListeners(guitarHero3ButtonsEventPanel);
|
||||
//register joystick panel
|
||||
wiimote.addWiiMoteEventListeners(guitarHero3JoystickPanel);
|
||||
}
|
||||
|
||||
public void unRegisterListeners() {
|
||||
wiimote.removeWiiMoteEventListeners(this);
|
||||
wiimote.removeWiiMoteEventListeners(guitarHero3ButtonsEventPanel);
|
||||
wiimote.removeWiiMoteEventListeners(guitarHero3JoystickPanel);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
buttonsEventPanel = new javax.swing.JPanel();
|
||||
guitarHero3ButtonsEventPanel = new wiiusej.utils.GuitarHero3ButtonsEventPanel();
|
||||
bottomPanel = new javax.swing.JPanel();
|
||||
guitarHero3JoystickPanel = new wiiusej.utils.GuitarHeroJoystickEventPanel();
|
||||
whammyProgressBar = new javax.swing.JProgressBar();
|
||||
|
||||
setTitle("WiiuseJ Guitar Hero 3 Test GUI");
|
||||
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
|
||||
|
||||
buttonsEventPanel.setBackground(new java.awt.Color(0, 0, 0));
|
||||
|
||||
javax.swing.GroupLayout buttonsEventPanelLayout = new javax.swing.GroupLayout(buttonsEventPanel);
|
||||
buttonsEventPanel.setLayout(buttonsEventPanelLayout);
|
||||
buttonsEventPanelLayout.setHorizontalGroup(
|
||||
buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 526, Short.MAX_VALUE)
|
||||
.addGroup(buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(buttonsEventPanelLayout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(guitarHero3ButtonsEventPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
);
|
||||
buttonsEventPanelLayout.setVerticalGroup(
|
||||
buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 96, Short.MAX_VALUE)
|
||||
.addGroup(buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(buttonsEventPanelLayout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(guitarHero3ButtonsEventPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
);
|
||||
|
||||
getContentPane().add(buttonsEventPanel);
|
||||
|
||||
bottomPanel.setBackground(new java.awt.Color(0, 0, 0));
|
||||
bottomPanel.setLayout(new javax.swing.BoxLayout(bottomPanel, javax.swing.BoxLayout.X_AXIS));
|
||||
bottomPanel.add(guitarHero3JoystickPanel);
|
||||
|
||||
whammyProgressBar.setBackground(new java.awt.Color(255, 255, 255));
|
||||
whammyProgressBar.setForeground(new java.awt.Color(255, 0, 255));
|
||||
bottomPanel.add(whammyProgressBar);
|
||||
|
||||
getContentPane().add(bottomPanel);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
public void onButtonsEvent(WiimoteButtonsEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onIrEvent(IREvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent arg0) {
|
||||
if (arg0 instanceof GuitarHeroEvent) {
|
||||
GuitarHeroEvent guitar = (GuitarHeroEvent) arg0;
|
||||
//move progress bar for whammy bar
|
||||
whammyProgressBar.setValue(Math.round(MAX_WHAMMY_BAR*guitar.getWhammyBar()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onDisconnectionEvent(DisconnectionEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {
|
||||
// nothing to do
|
||||
}
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel bottomPanel;
|
||||
private javax.swing.JPanel buttonsEventPanel;
|
||||
private wiiusej.utils.GuitarHero3ButtonsEventPanel guitarHero3ButtonsEventPanel;
|
||||
private wiiusej.utils.GuitarHeroJoystickEventPanel guitarHero3JoystickPanel;
|
||||
private javax.swing.JProgressBar whammyProgressBar;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
Reference in New Issue
Block a user