/** Called when hit next button, updates the model */
  public void onSubmit() {
    // update diff, num, and map
    model.setDifficulty(view.getDifficultyValue());
    model.setNumberOfPlayers(view.getNumPlayers());
    model.setMapType(view.getMapType());

    System.out.println("Model.difficulty = " + model.getDifficulty());
    System.out.println("model.num = " + model.getNumberOfPlayers());
    System.out.println("model.mapType = " + model.getMapType());

    // check if 0 entered -- bad!
    if (view.getNumPlayers() == 0) {
      JOptionPane.showMessageDialog(null, "num players cant be 0 dummy");
    } else {
      PlayerConfigPresenter p = new PlayerConfigPresenter(view, view.getNumPlayers());
    }
  }
Exemple #2
0
  private void createView(Element viewXML, Game window) {
    String id = viewXML.getAttribute("id");
    String type = ((Element) viewXML.getElementsByTagName("type").item(0)).getTextContent();

    View view = viewFactory.createView(id, type);
    view.fill(viewXML);

    Node textNode = viewXML.getElementsByTagName("text").item(0);
    view.setText(nodeToString(textNode));

    NodeList buttonsList = viewXML.getElementsByTagName("button");
    view.setNumberOfButtons(buttonsList.getLength());
    for (int i = 0; i < buttonsList.getLength(); i++) {
      Element xmlButton = (Element) buttonsList.item(i);
      view.addButton(this.createButton(xmlButton, window));
    }

    window.addView(view);
  }