//load the x representations of the characters into the hall
//add input handler for choosing a char and functionality to let him step to the front
//add gui buttons for enter world, exit, options
//on enter world start game with the chosen, on exit cleanup, on options show options pane
Node scene = null;
Vector3f pos = null;
try{
scene = (Node) Singleton.get().getAssetManager().getJmeAssetMan()
.loadAsset(SCENES_SELECT);
if(scene != null){
//this is needed as the chars are on a different node and would not be rendered
//just add, do not remove here..
for(Light l : scene.getLocalLightList()){
Singleton.get().getSceneManager().changeRootLight(l, Action.ADD);
}
Singleton.get().getSceneManager().changeTerrainNode(scene, Action.ADD);
//BEWARE !! do not use world pos at that time the node is not attached, and world pos was not computed
pos = scene.getChild("target").getLocalTranslation().clone();
camera.setLocation(pos);
//default, changed to last selected
camera.lookAt(scene.getChild("pos1").getLocalTranslation(), Vector3f.UNIT_Y);
int chars = clientInfo.getCharHandler().getCharCount();
if(chars > 12){
logger.log(Level.SEVERE, "More than 12 characters present for selection! Check server settings! We can only display 12 chars for selection");
chars = 12;
}
for (int i = 0; i < chars; i++) {
if(clientInfo.getCharHandler().getSelectedChar().isLastUsed()){
clientInfo.getCharHandler().setSelected(i);
camera.lookAt(scene.getChild("pos"+(i+1)).getLocalTranslation(), Vector3f.UNIT_Y);
CameraNode cn;
}
NewCharacterModel v = new NewCharacterModel(clientInfo.getCharHandler().getCharSummary(i));
v.attachVisuals();
pos = scene.getChild("pos"+(i+1)).getLocalTranslation().clone();
pos.y -= 1.0f;
v.setLocalTranslation(pos);
v.setLocalRotation(new Quaternion().fromAngleNormalAxis((float) Math.PI, Vector3f.UNIT_Y.negate()));
Singleton.get().getSceneManager().changeCharNode(v,Action.ADD);
}
}
} catch (Exception e1) {
logger.log(Level.SEVERE, "Failed to load select scene file "+SCENES_SELECT, e1);
}
final Node refScene = scene;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
final JButton left = Singleton.get().getGuiController().displayButton("<", 40, 30, (settings.getWidth()/2)-100, settings.getHeight()-50);
final JButton b = Singleton.get().getGuiController().displayButton("select", 80, 30, (settings.getWidth()/2)-40, settings.getHeight()-50);
final JButton bb = Singleton.get().getGuiController().displayButton("create", 80, 30, (settings.getWidth()/2)-40, settings.getHeight()-10);
final JButton right = Singleton.get().getGuiController().displayButton(">", 40, 30, (settings.getWidth()/2)+70, settings.getHeight()-50);
left.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int sel = clientInfo.getCharHandler().getSelectedIndex();
if(sel < 1)
return;
sel--;
clientInfo.getCharHandler().setSelected(sel);
camera.lookAt(refScene.getChild("pos"+(sel+1)).getLocalTranslation(), Vector3f.UNIT_Y);
}
});
right.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int sel = clientInfo.getCharHandler().getSelectedIndex();
if(sel+1 >= clientInfo.getCharHandler().getCharCount())
return;
sel++;
clientInfo.getCharHandler().setSelected(sel);
camera.lookAt(refScene.getChild("pos"+(sel+1)).getLocalTranslation(), Vector3f.UNIT_Y);
}
});
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {