/** * The method that sets the effects of the buttons * * @param e The actionevent that triggers this method */ public void actionPerformed(ActionEvent e) { if (e.getActionCommand() == btnString2) { dispose(); } else if (e.getActionCommand() == btnString1) { le.setSaveFileName(textField.getText()); le.saveLevel(); dispose(); } }
/** * Panel that will display the stats for the object that is being added to the level in the level * editor environment. */ public ObjectStatsPanel(ObjectEditorContainer container, LevelEditor editor) { homePanel = new JPanel(); panelSize = new Dimension(PANEL_WIDTH, container.HEIGHT); setLayout(new BorderLayout()); homePanel.setLayout(new BoxLayout(homePanel, BoxLayout.Y_AXIS)); initializeCollisionIDs(); myLevelEditor = editor; myLevelEditor.setObjectStatsPanel(this); loadInCorrectColIDMap(myLevelEditor.getLevel().getObjects()); initialize(); add(new ObjectToolbar(myLevelEditor), BorderLayout.WEST); add(homePanel, BorderLayout.EAST); }
public static void main(String[] args) { if (args.length == 1) { try { File f = new File(args[0]); if (f.isDirectory()) { TreeMap<Integer, LinkedList<String>> levels; levels = new TreeMap<Integer, LinkedList<String>>(); File[] fl = f.listFiles(); for (int x = 0; x < fl.length; x++) { File t = fl[x]; if (t.isFile()) { FileInputStream is = new FileInputStream(t); int[] board = LevelIO.read(is); final int s = LevelStats.computeScore(board); System.out.println(t.toString() + " -> " + Integer.toString(s)); LinkedList<String> strs = levels.get(s); if (strs != null) { strs.add(t.toString()); } else { strs = new LinkedList<String>(); strs.add(t.toString()); levels.put(s, strs); } } } System.out.println("Sorted levels:"); while (!levels.isEmpty()) { Integer score = levels.firstKey(); Iterator<String> it = levels.remove(score).iterator(); while (it.hasNext()) { String fn = it.next(); System.out.println(fn + " -> " + score.toString()); } } } } catch (Exception ex) { ex.printStackTrace(); } return; } LevelEditor editor = new LevelEditor(); editor.show(); }
public ObjectStats exportStats() { return new ObjectStats( (String) objectType.getSelectedItem(), myCollisionID, (String) movementType.getSelectedItem(), mySpeedSlider.getValue(), myDurationSlider.getValue(), cameraBox.isSelected(), myLevelEditor.getMover().getImageName(), floaterBox.isSelected(), myHitPointsSlider.getValue()); }
/** Saves the actual world tiles to a file to be loaded later */ public void saveWorld() { LevelEditor editor = this.currentWorld.getEditor(); if (editor != null) editor.save(); else System.out.println("No editor to save with!"); }