标签:
打开sc_pr_editror如下图:
若已安装jdk,则可以删掉JRE文件夹,双击exe或jar运行.
如下图所示:
假设我们要做的sc_pr data如下图所示:
则我们依次往下填,如琪露诺的背景的class为icepool_background,music的文件名,注意是文件名,为“上海アリス幻樂団 -おてんば恋娘~the Embodiment.ogg“,
loopend=170,looplength=170单位是s,依次填好,注意不要有空行,如下图:
接下来保存即可,若保存时error.log出现以下错误,可忽略,不影响使用,这因为你没有选择路径.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at Sc_pr$3.actionPerformed(Sc_pr.java:138) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
替换掉data/UI/sc_pr.lua或直接保存在UI文件夹下自动替换,再更新data.zip.注意:不要删掉user.dat,她记录了你上次的数据.
接下来是源码:
1 import java.awt.Font; 2 import java.awt.Toolkit; 3 import java.awt.event.ActionEvent; 4 import java.awt.event.ActionListener; 5 import java.io.BufferedReader; 6 import java.io.BufferedWriter; 7 import java.io.File; 8 import java.io.FileReader; 9 import java.io.FileWriter; 10 import java.io.IOException; 11 import java.util.regex.Matcher; 12 import java.util.regex.Pattern; 13 14 import javax.swing.JButton; 15 import javax.swing.JFileChooser; 16 import javax.swing.JFrame; 17 import javax.swing.JLabel; 18 import javax.swing.JOptionPane; 19 import javax.swing.JScrollPane; 20 import javax.swing.JTable; 21 import javax.swing.UIManager; 22 import javax.swing.UnsupportedLookAndFeelException; 23 import javax.swing.event.TableModelEvent; 24 import javax.swing.event.TableModelListener; 25 import javax.swing.table.DefaultTableModel; 26 public class Sc_pr extends JFrame { 27 /** 28 * @author 氙钬钍 29 * @since thhxg ver1.02 30 */ 31 private static final long serialVersionUID = -7489863630962159874L; 32 final int Width = 640; 33 final int Height = 480; 34 public JTable table; 35 public DefaultTableModel tableModel; 36 37 public static void main(String[] args) throws ClassNotFoundException, 38 InstantiationException, IllegalAccessException, 39 UnsupportedLookAndFeelException, NumberFormatException, IOException { 40 new Sc_pr().setVisible(true); 41 } 42 43 @SuppressWarnings("resource") 44 public Sc_pr() throws ClassNotFoundException, InstantiationException, 45 IllegalAccessException, UnsupportedLookAndFeelException, 46 NumberFormatException, IOException { 47 String windows = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; 48 UIManager.setLookAndFeel(windows); 49 setTitle("Spell Practice Editor"); 50 setResizable(false); 51 setFont(new Font("Meiryo UI", Font.PLAIN, 12)); 52 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 53 setBounds( 54 (Toolkit.getDefaultToolkit().getScreenSize().width - Width) / 2, 55 (Toolkit.getDefaultToolkit().getScreenSize().height - Height) / 2, 56 Width, Height); 57 setLayout(null); 58 JLabel label = new JLabel("Spell Practice Editor"); 59 label.setFont(new Font("Meiryo UI", Font.PLAIN, 17)); 60 label.setBounds(220, 0, 200, 30); 61 add(label); 62 63 final File datafile = new File("user.dat"); 64 String[] columnNames = { "background", "musicname", "loopend", 65 "looplength" }; 66 if (datafile.exists()) { 67 FileReader fr = new FileReader(datafile); 68 BufferedReader br = new BufferedReader(fr); 69 int rowcount = Integer.parseInt(br.readLine()); 70 Object[][] tableValues = new Object[rowcount][4]; 71 for (int i = 0; i < rowcount; i++) { 72 for (int j = 0; j < 4; j++) { 73 tableValues[i][j] = br.readLine(); 74 } 75 } 76 tableModel = new DefaultTableModel(tableValues, new String[] { 77 "background", "musicname", "loopend", "looplength" }); 78 table = new JTable(tableValues, columnNames); 79 } else { 80 Object[][] tableValues = { { "Class", "Example.ogg", 123, 123 } }; 81 tableModel = new DefaultTableModel(tableValues, new String[] { 82 "background", "musicname", "loopend", "looplength" }); 83 table = new JTable(tableValues, columnNames); 84 } 85 table.setModel(tableModel); 86 table.setAutoResizeMode(1); 87 table.setRowHeight(20); 88 Font font = new Font("微软雅黑", Font.PLAIN, 17); 89 table.setFont(font); 90 JScrollPane scrollPane = new JScrollPane(table); 91 scrollPane.setBounds(10, 40, 620, 370); 92 scrollPane.setFont(new Font("微软雅黑", Font.PLAIN, 10)); 93 add(scrollPane); 94 final JButton addButton = new JButton("添加"); 95 addButton.setFont(font); 96 addButton.setBounds(140, 410, 100, 30); 97 addButton.addActionListener(new ActionListener() { 98 99 @Override 100 public void actionPerformed(ActionEvent e) { 101 String[] rowvalues = {}; 102 tableModel.addRow(rowvalues); 103 104 } 105 }); 106 final JButton deleteButton = new JButton("删除"); 107 deleteButton.setFont(font); 108 deleteButton.setBounds(255, 410, 100, 30); 109 deleteButton.addActionListener(new ActionListener() { 110 111 @Override 112 public void actionPerformed(ActionEvent e) { 113 tableModel.removeRow(table.getSelectedRow()); 114 } 115 }); 116 final JButton saveButton = new JButton("保存"); 117 saveButton.setFont(font); 118 saveButton.setBounds(370, 410, 100, 30); 119 saveButton.addActionListener(new ActionListener() { 120 121 @Override 122 public void actionPerformed(ActionEvent e) { 123 boolean cansave = true; 124 for (int i = 0; i < table.getRowCount(); i++) { 125 126 if (!isNumeric(String.valueOf(table.getValueAt(i, 2))) 127 || !isNumeric(String.valueOf(table.getValueAt(i, 3)))) { 128 JOptionPane.showMessageDialog(null, "只能为number", 129 "系统提示", JOptionPane.ERROR_MESSAGE); 130 cansave = false; 131 } 132 } 133 if (cansave) { 134 JFileChooser chooser = new JFileChooser(); 135 chooser.setDialogTitle("请选择保存目录"); 136 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 137 chooser.showOpenDialog(null); 138 String path = chooser.getSelectedFile().getAbsolutePath(); 139 System.out.println(path); 140 File file = new File(path + "\\sc_pr.lua"); 141 if (file.exists()) { 142 file.delete(); 143 } 144 try { 145 file.createNewFile(); 146 } catch (IOException e1) { 147 e1.printStackTrace(); 148 } 149 StringBuffer contentBuffer = new StringBuffer(); 150 StringBuffer dataBuffer = new StringBuffer(); 151 dataBuffer.append(table.getRowCount() + "\n"); 152 contentBuffer 153 .append("sc_pr_data_id=0\nstage.group.New(‘menu‘,{},\"Spell Practice\",{lifeleft=7,power=500,faith=50000,bomb=0},false)\n"); 154 contentBuffer 155 .append("stage.group.AddStage(‘Spell Practice‘,‘Spell Practice@Spell Practice‘,{lifeleft=7,power=500,faith=50000,bomb=0},false)\n"); 156 contentBuffer 157 .append("stage.group.DefStageFunc(‘Spell Practice@Spell Practice‘,‘init‘,function(self)\n" 158 + "_init_item(self)\nNew(mask_fader,‘open‘)\n New(_G[lstg.var.player_name])\nlocal sc_pr_data={\n"); 159 for (int i = 0; i < table.getRowCount(); i++) { 160 contentBuffer.append("{sc_background="); 161 contentBuffer.append(table.getValueAt(i, 0) 162 + ",music=\""); 163 contentBuffer.append(table.getValueAt(i, 1) 164 + "\",loopend="); 165 contentBuffer.append(table.getValueAt(i, 2) 166 + ",looplength="); 167 contentBuffer.append(table.getValueAt(i, 3) + "},\n"); 168 dataBuffer.append(table.getValueAt(i, 0) + "\n"); 169 dataBuffer.append(table.getValueAt(i, 1) + "\n"); 170 dataBuffer.append(table.getValueAt(i, 2) + "\n"); 171 dataBuffer.append(table.getValueAt(i, 3) + "\n"); 172 } 173 contentBuffer 174 .append("}\ntask.New(self,function()\n" 175 + "do\nMusicRecord(\"spellcard\",sc_pr_data[sc_pr_data_id].music,sc_pr_data[sc_pr_data_id].loopend,sc_pr_data[sc_pr_data_id].looplength)\n" 176 + "LoadMusicRecord(\"spellcard\")\nNew(sc_pr_data[sc_pr_data_id].sc_background)\nend\ntask._Wait(60)\n_play_music(\"spellcard\")\n" 177 + "local _boss_wait=true local _ref=New(_editor_class[_sc_table[lstg.var.sc_index][1]],{boss.move.New(0,144,60,MOVE_NORMAL),_sc_table[lstg.var.sc_index][3]}) last=_ref\n" 178 + "if _boss_wait then while IsValid(_ref) do task.Wait() end end\ntask._Wait(180)\nend)\ntask.New(self,function()\nwhile coroutine.status(self.task[1])~=‘dead‘ do task.Wait() end\n" 179 + "New(mask_fader,‘close‘)\n_stop_music()\ntask.Wait(30)\nstage.group.FinishStage()\nend)\nend)"); 180 bufferedWriter(file.getAbsolutePath(), 181 contentBuffer.toString()); 182 if (datafile.exists()) { 183 datafile.delete(); 184 } 185 try { 186 datafile.createNewFile(); 187 } catch (IOException e1) { 188 e1.printStackTrace(); 189 } 190 bufferedWriter(datafile.getAbsolutePath(), 191 dataBuffer.toString()); 192 } 193 194 } 195 }); 196 add(addButton); 197 add(deleteButton); 198 add(saveButton); 199 tableModel.addTableModelListener(new TableModelListener() { 200 201 @Override 202 public void tableChanged(TableModelEvent e) { 203 int column = e.getColumn(); 204 if (column == 2 || column == 3) { 205 if (!isNumeric(String.valueOf(table.getValueAt( 206 e.getFirstRow(), column)))) { 207 JOptionPane.showMessageDialog(null, "只能为number", 208 "系统提示", JOptionPane.ERROR_MESSAGE); 209 210 } 211 } 212 213 } 214 }); 215 } 216 217 public void bufferedWriter(String path, String content) { 218 FileWriter fw = null; 219 BufferedWriter bfw = null; 220 try { 221 File file = new File(path); 222 fw = new FileWriter(file, true); 223 bfw = new BufferedWriter(fw); 224 225 // 写入字符串 226 bfw.write(content); 227 228 if (!file.exists()) { 229 System.out.println("文件:" + file.getName() + "不存在"); 230 } 231 232 } catch (Exception e) { 233 e.printStackTrace(); 234 } finally { 235 try { 236 if (bfw != null) { 237 bfw.close(); 238 } 239 if (fw != null) { 240 fw.close(); 241 } 242 } catch (Exception e) { 243 System.out.println("关闭输出流出错"); 244 e.printStackTrace(); 245 } 246 } 247 } 248 249 public boolean isNumeric(String str) { 250 Pattern pattern= Pattern.compile("([1-9]+[0-9]*|0)(\\.[\\d]+)?"); 251 Matcher isDecimal=pattern.matcher(str); 252 if (!isDecimal.matches()) { 253 return false; 254 } 255 return true; 256 } 257 }
标签:
原文地址:http://www.cnblogs.com/XeHoTh/p/5182943.html