LocalStorageに未登録時に、自動的に登録するように修正
ダイスプラグインを削除
@@ -1,33 +0,0 @@ | ||
1 | -/* DiceServerPlugin.java | |
2 | - * 作成日: 2004/09/20 | |
3 | - */ | |
4 | -package jp.sf.chaplet.dice.server; | |
5 | - | |
6 | -import jp.sf.chaplet.core.server.RollAction; | |
7 | -import jp.sf.chaplet.core.server.ServerPlugin; | |
8 | - | |
9 | -/** | |
10 | - * ダイス機能を提供するサーバ側プラグイン。<br> | |
11 | - * | |
12 | - * @author koe | |
13 | - * @version $Id$ | |
14 | - */ | |
15 | -public class DiceServerPlugin extends ServerPlugin { | |
16 | - /** | |
17 | - * @see jp.sourceforge.chaplet.core.server.ServerPlugin#getPluginId() | |
18 | - */ | |
19 | - public String getPluginId() { | |
20 | - return "jp.sourceforge.chaplet.dice"; | |
21 | - } | |
22 | - | |
23 | - /** | |
24 | - * @see jp.sourceforge.chaplet.core.server.ServerPlugin#init() | |
25 | - */ | |
26 | - public void init() throws Exception { | |
27 | - { | |
28 | - RollAction action = new RollAction(); | |
29 | - action.init(server, this); | |
30 | - addAction("dice:roll", action); | |
31 | - } | |
32 | - } | |
33 | -} |
@@ -1,387 +0,0 @@ | ||
1 | -/** | |
2 | - * | |
3 | - */ | |
4 | -package jp.sf.chaplet.dice.ui; | |
5 | - | |
6 | -import java.awt.Color; | |
7 | -import java.awt.Font; | |
8 | -import java.awt.GridBagConstraints; | |
9 | -import java.awt.GridBagLayout; | |
10 | -import java.awt.Insets; | |
11 | - | |
12 | -import javax.swing.BorderFactory; | |
13 | -import javax.swing.JButton; | |
14 | -import javax.swing.JComboBox; | |
15 | -import javax.swing.JLabel; | |
16 | -import javax.swing.JPanel; | |
17 | -import javax.swing.JRadioButton; | |
18 | -import javax.swing.JScrollPane; | |
19 | -import javax.swing.JSpinner; | |
20 | -import javax.swing.JTextField; | |
21 | -import javax.swing.border.TitledBorder; | |
22 | -import javax.swing.ButtonGroup; | |
23 | - | |
24 | -import jp.sf.chaplet.core.client.ClientPlugin; | |
25 | -import jp.sf.chaplet.core.ui.IPluginView; | |
26 | -import javax.swing.JList; | |
27 | -import javax.swing.JToggleButton; | |
28 | - | |
29 | -/** | |
30 | - * DiceView<br> | |
31 | - * @version $Id$ | |
32 | - */ | |
33 | -public class DiceView extends JPanel implements IPluginView{ | |
34 | - | |
35 | - private static final long serialVersionUID = 1L; | |
36 | - private JTextField formulaText = null; | |
37 | - private JSpinner bonusSpinner = null; | |
38 | - private JScrollPane scroll2Pane = null; | |
39 | - private JButton rollButton = null; | |
40 | - private JButton addFormulaButton = null; | |
41 | - private JButton removeFormulaButton = null; | |
42 | - private JPanel evalRulePanel = null; | |
43 | - private JRadioButton addRuleButton = null; | |
44 | - private JRadioButton countRuleButton = null; | |
45 | - private JSpinner countRuleSpinner = null; | |
46 | - private JComboBox countRuleComboBox = null; | |
47 | - private ButtonGroup diceRuleGroup = null; // @jve:decl-index=0:visual-constraint="371,20" | |
48 | - private JLabel jLabel = null; | |
49 | - private JList historyList = null; | |
50 | - private JToggleButton hideButton = null; | |
51 | - /** | |
52 | - * This is the default constructor | |
53 | - */ | |
54 | - public DiceView() { | |
55 | - super(); | |
56 | - initialize(); | |
57 | - getDiceRuleGroup(); | |
58 | - } | |
59 | - | |
60 | - /** | |
61 | - * This method initializes this | |
62 | - * | |
63 | - * @return void | |
64 | - */ | |
65 | - private void initialize() { | |
66 | - GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); | |
67 | - gridBagConstraints2.gridx = 1; | |
68 | - gridBagConstraints2.gridwidth = 2; | |
69 | - gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL; | |
70 | - gridBagConstraints2.insets = new Insets(2, 5, 2, 5); | |
71 | - gridBagConstraints2.gridy = 2; | |
72 | - GridBagConstraints gridBagConstraints110 = new GridBagConstraints(); | |
73 | - gridBagConstraints110.gridx = 1; | |
74 | - gridBagConstraints110.gridy = 0; | |
75 | - jLabel = new JLabel(); | |
76 | - jLabel.setText("+"); | |
77 | - GridBagConstraints gridBagConstraints10 = new GridBagConstraints(); | |
78 | - gridBagConstraints10.gridx = 0; | |
79 | - gridBagConstraints10.gridwidth = 5; | |
80 | - gridBagConstraints10.fill = GridBagConstraints.BOTH; | |
81 | - gridBagConstraints10.gridy = 7; | |
82 | - GridBagConstraints gridBagConstraints9 = new GridBagConstraints(); | |
83 | - gridBagConstraints9.gridx = 1; | |
84 | - gridBagConstraints9.gridwidth = 2; | |
85 | - gridBagConstraints9.fill = GridBagConstraints.HORIZONTAL; | |
86 | - gridBagConstraints9.insets = new Insets(2, 5, 2, 5); | |
87 | - gridBagConstraints9.gridy = 4; | |
88 | - GridBagConstraints gridBagConstraints8 = new GridBagConstraints(); | |
89 | - gridBagConstraints8.gridx = 1; | |
90 | - gridBagConstraints8.gridwidth = 2; | |
91 | - gridBagConstraints8.fill = GridBagConstraints.HORIZONTAL; | |
92 | - gridBagConstraints8.insets = new Insets(2, 5, 2, 5); | |
93 | - gridBagConstraints8.gridy = 3; | |
94 | - GridBagConstraints gridBagConstraints6 = new GridBagConstraints(); | |
95 | - gridBagConstraints6.gridx = 1; | |
96 | - gridBagConstraints6.gridwidth = 2; | |
97 | - gridBagConstraints6.fill = GridBagConstraints.HORIZONTAL; | |
98 | - gridBagConstraints6.insets = new Insets(2, 5, 2, 5); | |
99 | - gridBagConstraints6.gridy = 1; | |
100 | - GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); | |
101 | - gridBagConstraints5.fill = GridBagConstraints.BOTH; | |
102 | - gridBagConstraints5.gridy = 1; | |
103 | - gridBagConstraints5.weightx = 1.0; | |
104 | - gridBagConstraints5.weighty = 1.0; | |
105 | - gridBagConstraints5.gridheight = 6; | |
106 | - gridBagConstraints5.gridx = 0; | |
107 | - GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); | |
108 | - gridBagConstraints1.gridx = 2; | |
109 | - gridBagConstraints1.weightx = 1.0; | |
110 | - gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL; | |
111 | - gridBagConstraints1.insets = new Insets(0, 2, 2, 2); | |
112 | - gridBagConstraints1.gridy = 0; | |
113 | - GridBagConstraints gridBagConstraints = new GridBagConstraints(); | |
114 | - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; | |
115 | - gridBagConstraints.gridy = 0; | |
116 | - gridBagConstraints.weightx = 40.0; | |
117 | - gridBagConstraints.insets = new Insets(0, 0, 2, 2); | |
118 | - gridBagConstraints.gridx = 0; | |
119 | - this.setSize(352, 304); | |
120 | - this.setLayout(new GridBagLayout()); | |
121 | - this.add(getFormulaText(), gridBagConstraints); | |
122 | - this.add(getBonusSpinner(), gridBagConstraints1); | |
123 | - this.add(getScroll2Pane(), gridBagConstraints5); | |
124 | - this.add(getRollButton(), gridBagConstraints6); | |
125 | - this.add(getAddFormulaButton(), gridBagConstraints8); | |
126 | - this.add(getRemoveFormulaButton(), gridBagConstraints9); | |
127 | - this.add(getEvalRulePanel(), gridBagConstraints10); | |
128 | - this.add(jLabel, gridBagConstraints110); | |
129 | - this.add(getHideButton(), gridBagConstraints2); | |
130 | - } | |
131 | - | |
132 | - /** | |
133 | - * This method initializes formulaText | |
134 | - * | |
135 | - * @return javax.swing.JTextField | |
136 | - */ | |
137 | - private JTextField getFormulaText() { | |
138 | - if (formulaText == null) { | |
139 | - formulaText = new JTextField(); | |
140 | - } | |
141 | - return formulaText; | |
142 | - } | |
143 | - | |
144 | - /** | |
145 | - * This method initializes bonusSpinner | |
146 | - * | |
147 | - * @return javax.swing.JSpinner | |
148 | - */ | |
149 | - private JSpinner getBonusSpinner() { | |
150 | - if (bonusSpinner == null) { | |
151 | - bonusSpinner = new JSpinner(); | |
152 | - } | |
153 | - return bonusSpinner; | |
154 | - } | |
155 | - | |
156 | - /** | |
157 | - * This method initializes scroll2Pane | |
158 | - * | |
159 | - * @return javax.swing.JScrollPane | |
160 | - */ | |
161 | - private JScrollPane getScroll2Pane() { | |
162 | - if (scroll2Pane == null) { | |
163 | - scroll2Pane = new JScrollPane(); | |
164 | - scroll2Pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); | |
165 | - scroll2Pane.setViewportView(getHistoryList()); | |
166 | - } | |
167 | - return scroll2Pane; | |
168 | - } | |
169 | - | |
170 | - /** | |
171 | - * This method initializes rollButton | |
172 | - * | |
173 | - * @return javax.swing.JButton | |
174 | - */ | |
175 | - private JButton getRollButton() { | |
176 | - if (rollButton == null) { | |
177 | - rollButton = new JButton(); | |
178 | - rollButton.setText("振る"); | |
179 | - } | |
180 | - return rollButton; | |
181 | - } | |
182 | - | |
183 | - /** | |
184 | - * This method initializes addFormulaButton | |
185 | - * | |
186 | - * @return javax.swing.JButton | |
187 | - */ | |
188 | - private JButton getAddFormulaButton() { | |
189 | - if (addFormulaButton == null) { | |
190 | - addFormulaButton = new JButton(); | |
191 | - addFormulaButton.setText("登録"); | |
192 | - } | |
193 | - return addFormulaButton; | |
194 | - } | |
195 | - | |
196 | - /** | |
197 | - * This method initializes removeFormulaButton | |
198 | - * | |
199 | - * @return javax.swing.JButton | |
200 | - */ | |
201 | - private JButton getRemoveFormulaButton() { | |
202 | - if (removeFormulaButton == null) { | |
203 | - removeFormulaButton = new JButton(); | |
204 | - removeFormulaButton.setText("削除"); | |
205 | - } | |
206 | - return removeFormulaButton; | |
207 | - } | |
208 | - | |
209 | - /** | |
210 | - * This method initializes evalRulePanel | |
211 | - * | |
212 | - * @return javax.swing.JPanel | |
213 | - */ | |
214 | - private JPanel getEvalRulePanel() { | |
215 | - if (evalRulePanel == null) { | |
216 | - GridBagConstraints gridBagConstraints23 = new GridBagConstraints(); | |
217 | - gridBagConstraints23.fill = GridBagConstraints.HORIZONTAL; | |
218 | - gridBagConstraints23.gridy = 0; | |
219 | - gridBagConstraints23.weightx = 10.0; | |
220 | - gridBagConstraints23.gridx = 3; | |
221 | - GridBagConstraints gridBagConstraints22 = new GridBagConstraints(); | |
222 | - gridBagConstraints22.gridx = 2; | |
223 | - gridBagConstraints22.weightx = 5.0; | |
224 | - gridBagConstraints22.fill = GridBagConstraints.HORIZONTAL; | |
225 | - gridBagConstraints22.gridy = 0; | |
226 | - GridBagConstraints gridBagConstraints20 = new GridBagConstraints(); | |
227 | - gridBagConstraints20.gridx = 1; | |
228 | - gridBagConstraints20.weightx = 20.0; | |
229 | - gridBagConstraints20.anchor = GridBagConstraints.WEST; | |
230 | - gridBagConstraints20.gridy = 0; | |
231 | - GridBagConstraints gridBagConstraints19 = new GridBagConstraints(); | |
232 | - gridBagConstraints19.gridx = 0; | |
233 | - gridBagConstraints19.weightx = 20.0; | |
234 | - gridBagConstraints19.anchor = GridBagConstraints.WEST; | |
235 | - gridBagConstraints19.gridy = 0; | |
236 | - evalRulePanel = new JPanel(); | |
237 | - evalRulePanel.setLayout(new GridBagLayout()); | |
238 | - evalRulePanel.setBorder(BorderFactory.createTitledBorder(null, "\u30c0\u30a4\u30b9\u306e\u76ee", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("MS UI Gothic", Font.PLAIN, 12), Color.black)); | |
239 | - evalRulePanel.add(getAddRuleButton(), gridBagConstraints19); | |
240 | - evalRulePanel.add(getCountRuleButton(), gridBagConstraints20); | |
241 | - evalRulePanel.add(getCountRuleSpinner(), gridBagConstraints22); | |
242 | - evalRulePanel.add(getCountRuleComboBox(), gridBagConstraints23); | |
243 | - } | |
244 | - return evalRulePanel; | |
245 | - } | |
246 | - | |
247 | - /** | |
248 | - * This method initializes addRuleButton | |
249 | - * | |
250 | - * @return javax.swing.JRadioButton | |
251 | - */ | |
252 | - private JRadioButton getAddRuleButton() { | |
253 | - if (addRuleButton == null) { | |
254 | - addRuleButton = new JRadioButton(); | |
255 | - addRuleButton.setText("合計する"); | |
256 | - } | |
257 | - return addRuleButton; | |
258 | - } | |
259 | - | |
260 | - /** | |
261 | - * This method initializes countRuleButton | |
262 | - * | |
263 | - * @return javax.swing.JRadioButton | |
264 | - */ | |
265 | - private JRadioButton getCountRuleButton() { | |
266 | - if (countRuleButton == null) { | |
267 | - countRuleButton = new JRadioButton(); | |
268 | - countRuleButton.setText("カウントする"); | |
269 | - } | |
270 | - return countRuleButton; | |
271 | - } | |
272 | - | |
273 | - /** | |
274 | - * This method initializes countRuleSpinner | |
275 | - * | |
276 | - * @return javax.swing.JSpinner | |
277 | - */ | |
278 | - private JSpinner getCountRuleSpinner() { | |
279 | - if (countRuleSpinner == null) { | |
280 | - countRuleSpinner = new JSpinner(); | |
281 | - countRuleSpinner.setValue(6); | |
282 | - } | |
283 | - return countRuleSpinner; | |
284 | - } | |
285 | - | |
286 | - /** | |
287 | - * This method initializes countRuleComboBox | |
288 | - * | |
289 | - * @return javax.swing.JComboBox | |
290 | - */ | |
291 | - private JComboBox getCountRuleComboBox() { | |
292 | - if (countRuleComboBox == null) { | |
293 | - countRuleComboBox = new JComboBox(); | |
294 | - countRuleComboBox.addItem("以上"); | |
295 | - countRuleComboBox.addItem("以下"); | |
296 | - } | |
297 | - return countRuleComboBox; | |
298 | - } | |
299 | - | |
300 | - /** | |
301 | - * This method initializes diceRuleGroup | |
302 | - * | |
303 | - * @return javax.swing.ButtonGroup | |
304 | - */ | |
305 | - private ButtonGroup getDiceRuleGroup() { | |
306 | - if (diceRuleGroup == null) { | |
307 | - diceRuleGroup = new ButtonGroup(); | |
308 | - diceRuleGroup.add(getAddRuleButton()); | |
309 | - diceRuleGroup.add(getCountRuleButton()); | |
310 | - } | |
311 | - return diceRuleGroup; | |
312 | - } | |
313 | - | |
314 | - /** | |
315 | - * @see jp.sf.chaplet.core.ui.IPluginView#getPluginId() | |
316 | - */ | |
317 | - public String getPluginId() { | |
318 | - // TODO 自動生成されたメソッド・スタブ | |
319 | - return null; | |
320 | - } | |
321 | - | |
322 | - /** | |
323 | - * @see jp.sf.chaplet.core.ui.IPluginView#getPluginName() | |
324 | - */ | |
325 | - public String getPluginName() { | |
326 | - // TODO 自動生成されたメソッド・スタブ | |
327 | - return null; | |
328 | - } | |
329 | - | |
330 | - /** | |
331 | - * @see jp.sf.chaplet.core.ui.IPluginView#getSwingComponent() | |
332 | - */ | |
333 | - public JPanel getSwingComponent() { | |
334 | - // TODO 自動生成されたメソッド・スタブ | |
335 | - return null; | |
336 | - } | |
337 | - | |
338 | - /** | |
339 | - * @see jp.sf.chaplet.core.ui.IPluginView#setController(jp.sf.chaplet.core.client.ClientPlugin) | |
340 | - */ | |
341 | - public void setController(ClientPlugin ctl) { | |
342 | - // TODO 自動生成されたメソッド・スタブ | |
343 | - | |
344 | - } | |
345 | - | |
346 | - /** | |
347 | - * @see jp.sf.chaplet.core.ui.IPluginView#setGM(boolean) | |
348 | - */ | |
349 | - public void setGM(boolean gm) { | |
350 | - // TODO 自動生成されたメソッド・スタブ | |
351 | - | |
352 | - } | |
353 | - | |
354 | - /** | |
355 | - * @see jp.sf.chaplet.core.ui.IPluginView#setLoginOK(boolean) | |
356 | - */ | |
357 | - public void setLoginOK(boolean ok) { | |
358 | - // TODO 自動生成されたメソッド・スタブ | |
359 | - | |
360 | - } | |
361 | - | |
362 | - /** | |
363 | - * This method initializes historyList | |
364 | - * | |
365 | - * @return javax.swing.JList | |
366 | - */ | |
367 | - private JList getHistoryList() { | |
368 | - if (historyList == null) { | |
369 | - historyList = new JList(); | |
370 | - } | |
371 | - return historyList; | |
372 | - } | |
373 | - | |
374 | - /** | |
375 | - * This method initializes hideButton | |
376 | - * | |
377 | - * @return javax.swing.JToggleButton | |
378 | - */ | |
379 | - private JToggleButton getHideButton() { | |
380 | - if (hideButton == null) { | |
381 | - hideButton = new JToggleButton(); | |
382 | - hideButton.setText("非表示"); | |
383 | - } | |
384 | - return hideButton; | |
385 | - } | |
386 | - | |
387 | -} // @jve:decl-index=0:visual-constraint="10,10" |
@@ -1,34 +0,0 @@ | ||
1 | -/* IDiceView.java | |
2 | - * 作成日: 2004/09/20 | |
3 | - */ | |
4 | -package jp.sf.chaplet.dice.ui; | |
5 | - | |
6 | -import jp.sf.chaplet.core.ui.IPluginView; | |
7 | - | |
8 | -/** | |
9 | - * IDiceView<br> | |
10 | - * | |
11 | - * @author koe | |
12 | - * @version $Id$ | |
13 | - */ | |
14 | -public interface IDiceView extends IPluginView{ | |
15 | - | |
16 | - /** | |
17 | - * ダイスを振った結果をセットする。 | |
18 | - * @param result 結果 result[0]は今回の合計、result[1]は前回の数値、それ以降は個々のダイスの値 | |
19 | - * @param isRerole 振り足しした場合true | |
20 | - */ | |
21 | - void setRoleResult(String[] result, boolean isRerole); | |
22 | - | |
23 | - /** | |
24 | - * 初期状態で表示されるダイスの規則を設定する。 | |
25 | - * @param rules 規則 | |
26 | - */ | |
27 | - void setDiceRule(String[] rules); | |
28 | - | |
29 | - /** | |
30 | - * 現在表示中のダイスの規則を返す。 | |
31 | - * @param rules 規則 | |
32 | - */ | |
33 | - String[] getDiceRule(); | |
34 | -} |
@@ -1,181 +0,0 @@ | ||
1 | -/* DiceClientPlugin.java | |
2 | - * 作成日: 2004/09/20 | |
3 | - */ | |
4 | -package jp.sf.chaplet.dice.client; | |
5 | - | |
6 | -import java.text.ParseException; | |
7 | -import java.util.ArrayList; | |
8 | -import java.util.Iterator; | |
9 | -import java.util.Properties; | |
10 | - | |
11 | -import javax.swing.JPanel; | |
12 | - | |
13 | -import application.Action; | |
14 | - | |
15 | -import jp.sf.chaplet.ConfigLoader; | |
16 | -import jp.sf.chaplet.DiceManager; | |
17 | -import jp.sf.chaplet.StorageUtils; | |
18 | -import jp.sf.chaplet.core.client.ClientPlugin; | |
19 | -import jp.sf.chaplet.core.client.Handle; | |
20 | -import jp.sf.chaplet.core.client.RollAction; | |
21 | -import jp.sf.chaplet.core.ui.IPluginView; | |
22 | -import jp.sf.chaplet.dice.ui.DiceView; | |
23 | - | |
24 | -/** | |
25 | - * DiceClientPlugin<br> | |
26 | - * | |
27 | - * @author koe | |
28 | - * @version $Id$ | |
29 | - */ | |
30 | -public class DiceClientPlugin extends ClientPlugin { | |
31 | - private DiceView form; | |
32 | - | |
33 | - /** | |
34 | - * @see application.Application#startup() | |
35 | - */ | |
36 | - @Override | |
37 | - protected void startup() { | |
38 | - { | |
39 | - RollAction action = new RollAction(); | |
40 | - action.init(getController(), this); | |
41 | - addAction("dice:roll", action); | |
42 | - } | |
43 | - } | |
44 | - | |
45 | - /** | |
46 | - * @see jp.sf.chaplet.core.client.ClientPlugin#initSWT(org.eclipse.swt.widgets.Composite) | |
47 | - */ | |
48 | - public JPanel initSwing(JPanel parent) { | |
49 | - form = new DiceView(); | |
50 | - form.setVisible(false); | |
51 | - parent.add(form); | |
52 | -// form.setController(this); | |
53 | - ArrayList<String> ruleList = new ArrayList<String>(); | |
54 | - String ruleKey = getPluginId() + ".rule"; | |
55 | - Properties properties = ConfigLoader.getInstance().load().getProperties(); | |
56 | - for(Iterator iter = properties.keySet().iterator(); iter.hasNext();){ | |
57 | - String key = (String) iter.next(); | |
58 | - if(key.startsWith(ruleKey)){ | |
59 | - String rule = properties.getProperty(key); | |
60 | - ruleList.add(rule); | |
61 | - } | |
62 | - } | |
63 | -// form.setDiceRule((String[]) ruleList.toArray(new String[ruleList.size()])); | |
64 | - return form; | |
65 | - } | |
66 | - | |
67 | - /** | |
68 | - * @see jp.sf.chaplet.core.client.ClientPlugin#destroy() | |
69 | - */ | |
70 | - public void destroy() { | |
71 | -// String[] rules = form.getDiceRule(); | |
72 | -// String ruleKey = getPluginId() + ".rule"; | |
73 | -// Configuration conf = ConfigLoader.getInstance().load(); | |
74 | -// Properties properties = conf.getProperties(); | |
75 | -// for (int i = 0; i < rules.length; i++) { | |
76 | -// properties.setProperty(ruleKey + "." + i, rules[i]); | |
77 | -// } | |
78 | - } | |
79 | -// | |
80 | -// /** | |
81 | -// * @see jp.sf.chaplet.core.client.ClientPlugin#getPluginView() | |
82 | -// */ | |
83 | -// public IPluginView getPluginView() { | |
84 | -// return form; | |
85 | -// } | |
86 | - | |
87 | - public JPanel getSwingComponent(){ | |
88 | - return form; | |
89 | - } | |
90 | - | |
91 | - /** | |
92 | - * @see jp.sf.chaplet.core.client.ClientPlugin#getPluginId() | |
93 | - */ | |
94 | - public String getPluginId() { | |
95 | - return "jp.sf.chaplet.dice"; | |
96 | - } | |
97 | - | |
98 | - @Action | |
99 | - public void rollSum(String rule, int bonus, int prevValue, int numRerole, boolean hidden){ | |
100 | - Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE); | |
101 | - int[] result = null; | |
102 | - try { | |
103 | - result = DiceManager.getInstance().rollSum(rule, bonus, numRerole); | |
104 | - } catch (ParseException e) { | |
105 | - getConnection().sendMessage(new String[]{"dice:role", | |
106 | - rule + "=評価できません", handle.getName()}); | |
107 | - return; | |
108 | - } | |
109 | - | |
110 | - StringBuilder sb = new StringBuilder(rule); | |
111 | - if(bonus != 0){ | |
112 | - if(bonus > 0){ | |
113 | - sb.append('+'); | |
114 | - } | |
115 | - sb.append(bonus); | |
116 | - } | |
117 | - sb.append('='); | |
118 | - sb.append('('); | |
119 | - int sum = bonus; | |
120 | - for (int i = 0; i < result.length; i++) { | |
121 | - sb.append(result[i]); | |
122 | - sb.append('+'); | |
123 | - sum += result[i]; | |
124 | - } | |
125 | - if(result.length > 0){ | |
126 | - sb.deleteCharAt(sb.length() - 1); | |
127 | - } | |
128 | - sb.append(')'); | |
129 | - if(bonus != 0){ | |
130 | - if(bonus > 0){ | |
131 | - sb.append('+'); | |
132 | - } | |
133 | - sb.append(bonus); | |
134 | - } | |
135 | - sb.append('='); | |
136 | - sb.append(sum); | |
137 | - | |
138 | - String exp = sb.toString(); | |
139 | - getController().getView().appendFunctionLog("ダイス", handle.getName(), exp); | |
140 | - getConnection().sendMessage(new String[]{"dice:role", exp, handle.getName()}); | |
141 | - } | |
142 | - | |
143 | - @Action | |
144 | - public void rollCount(String rule, int target, boolean upperRole, int prevValue, int numRerole, boolean hidden){ | |
145 | - Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE); | |
146 | - int[] result = null; | |
147 | - try { | |
148 | - result = DiceManager.getInstance().roleCount(rule, target, upperRole, numRerole); | |
149 | - } catch (ParseException e) { | |
150 | - getConnection().sendMessage(new String[]{"dice:roll", | |
151 | - rule + "=評価できません", handle.getName()}); | |
152 | - return; | |
153 | - } | |
154 | - | |
155 | - StringBuilder sb = new StringBuilder(rule); | |
156 | - sb.append('='); | |
157 | - sb.append('['); | |
158 | - int sum = 0; | |
159 | - for (int i = 0; i < result.length; i++) { | |
160 | - sb.append(result[i]); | |
161 | - sb.append(','); | |
162 | - if(result[i] >= target){ | |
163 | - sum ++; | |
164 | - } | |
165 | - } | |
166 | - if(result.length > 0){ | |
167 | - sb.deleteCharAt(sb.length() - 1); | |
168 | - } | |
169 | - sb.append(']'); | |
170 | - sb.append('='); | |
171 | - sb.append(sum); | |
172 | - | |
173 | - String exp = sb.toString(); | |
174 | - getController().getView().appendFunctionLog("ダイス", handle.getName(), exp); | |
175 | - getConnection().sendMessage(new String[]{"dice:roll", exp, handle.getName()}); | |
176 | - } | |
177 | - | |
178 | - public IPluginView getPluginView(){ | |
179 | - return form; | |
180 | - } | |
181 | -} |
@@ -7,6 +7,7 @@ | ||
7 | 7 | import java.util.Map; |
8 | 8 | import java.util.logging.Level; |
9 | 9 | |
10 | +import jp.sf.chaplet.StorageUtils; | |
10 | 11 | import jp.sf.chaplet.core.server.ClientProxy; |
11 | 12 | import jp.sf.chaplet.core.server.ServerAction; |
12 | 13 | import jp.sf.chaplet.core.server.ServerPlugin; |
@@ -42,7 +43,7 @@ | ||
42 | 43 | * @see jp.sf.chaplet.core.server.ServerPlugin#reload() |
43 | 44 | */ |
44 | 45 | public void reload() throws Exception{ |
45 | - NovaConfig config = NovaConfig.getInstance(); | |
46 | + NovaConfig config = (NovaConfig) StorageUtils.load(NovaConfig.NAME, NovaConfig.class); | |
46 | 47 | tarotManager.setConfig(config); |
47 | 48 | cardManager.setNumDeck(config.getNumDeck()); |
48 | 49 | cardManager.setNumJoker(config.getNumJoker()); |
@@ -90,7 +91,7 @@ | ||
90 | 91 | addAction("nova:exchange", actions[12]); |
91 | 92 | addAction("nova:init", actions[13]); |
92 | 93 | |
93 | - NovaConfig config = NovaConfig.getInstance(); | |
94 | + NovaConfig config = (NovaConfig) StorageUtils.load(NovaConfig.NAME, NovaConfig.class); | |
94 | 95 | tarotManager.setConfig(config); |
95 | 96 | cardManager.setNumDeck(config.getNumDeck()); |
96 | 97 | cardManager.setNumJoker(config.getNumJoker()); |
@@ -3,7 +3,6 @@ | ||
3 | 3 | */ |
4 | 4 | package jp.sf.chaplet.nova; |
5 | 5 | |
6 | -import jp.sf.chaplet.StorageUtils; | |
7 | 6 | |
8 | 7 | /** |
9 | 8 | * NovaConfig<br> |
@@ -25,15 +24,6 @@ | ||
25 | 24 | |
26 | 25 | private boolean ayakashiEnabled; |
27 | 26 | |
28 | - public static NovaConfig getInstance(){ | |
29 | - NovaConfig config = (NovaConfig) StorageUtils.load(NAME); | |
30 | - if(config == null){ | |
31 | - config = new NovaConfig(); | |
32 | - StorageUtils.save(config, NAME); | |
33 | - } | |
34 | - return config; | |
35 | - } | |
36 | - | |
37 | 27 | public boolean isArashiEnabled() { |
38 | 28 | return arashiEnabled; |
39 | 29 | } |
@@ -45,7 +45,7 @@ | ||
45 | 45 | public BasicPrefPanel() { |
46 | 46 | super(); |
47 | 47 | initialize(); |
48 | - NovaConfig config = NovaConfig.getInstance(); | |
48 | + NovaConfig config = (NovaConfig) StorageUtils.load(NovaConfig.NAME, NovaConfig.class); | |
49 | 49 | getNumDeckModel().setValue(config.getNumDeck()); |
50 | 50 | getNumJokerModel().setValue(config.getNumJoker()); |
51 | 51 | getHirukoRadio().setSelected(config.isHirukoEnabled()); |
@@ -269,7 +269,7 @@ | ||
269 | 269 | * @see jp.sf.chaplet.core.ui.IPrefView#save() |
270 | 270 | */ |
271 | 271 | public void save() { |
272 | - NovaConfig config = NovaConfig.getInstance(); | |
272 | + NovaConfig config = (NovaConfig) StorageUtils.load(NovaConfig.NAME, NovaConfig.class); | |
273 | 273 | config.setNumDeck((Integer) getNumDeckModel().getValue()); |
274 | 274 | config.setNumJoker((Integer) getNumJokerModel().getValue()); |
275 | 275 | config.setHirukoEnabled(getHirukoRadio().isSelected()); |
@@ -3,6 +3,7 @@ | ||
3 | 3 | */ |
4 | 4 | package jp.sf.chaplet; |
5 | 5 | |
6 | +import java.beans.Beans; | |
6 | 7 | import java.io.File; |
7 | 8 | import java.io.IOException; |
8 | 9 | import java.util.HashMap; |
@@ -31,7 +32,20 @@ | ||
31 | 32 | } |
32 | 33 | } |
33 | 34 | |
34 | - public static final Object load(String name){ | |
35 | + public static final Object load(String name, Class theClass){ | |
36 | + Object obj = load(name); | |
37 | + if(obj == null){ | |
38 | + try { | |
39 | + obj = Beans.instantiate(StorageUtils.class.getClassLoader(), theClass.getName()); | |
40 | + } catch (Exception e) { | |
41 | + Logger.getLogger(StorageUtils.class.getName()).log(Level.SEVERE, e.getMessage(), e); | |
42 | + return null; | |
43 | + } | |
44 | + } | |
45 | + return obj; | |
46 | + } | |
47 | + | |
48 | + static final Object load(String name){ | |
35 | 49 | LocalStorage localStorage = ApplicationContext.getInstance().getLocalStorage(); |
36 | 50 | try { |
37 | 51 | return localStorage.load(prefix == null ? name : prefix + "-" + name); |
@@ -413,7 +413,7 @@ | ||
413 | 413 | */ |
414 | 414 | @SuppressWarnings("unchecked") |
415 | 415 | public void load(String fileName){ |
416 | - HashMap<String, HashMap<String, Object>> map = (HashMap<String, HashMap<String, Object>>) StorageUtils.load(StorageUtils.SERVER); | |
416 | + HashMap<String, HashMap<String, Object>> map = (HashMap<String, HashMap<String, Object>>) StorageUtils.load(StorageUtils.SERVER, HashMap.class); | |
417 | 417 | HashMap<String, Object> coreMap = map.get("core"); |
418 | 418 | userManager.setAllUsers((User[])coreMap.get("users")); |
419 | 419 | for (String key : pluginMap.keySet()) { |
@@ -88,20 +88,20 @@ | ||
88 | 88 | this.setSize(335, 200); |
89 | 89 | this.setTitle("接続設定"); |
90 | 90 | this.setContentPane(getJContentPane()); |
91 | - addressList = (List<ServerAddress>) StorageUtils.load("server.xml"); | |
92 | - if(addressList == null){ | |
91 | + addressList = (List<ServerAddress>) StorageUtils.load("server.xml", ArrayList.class); | |
92 | + if(addressList == null || addressList.size() == 0){ | |
93 | 93 | addressList = new ArrayList<ServerAddress>(); |
94 | - } else { | |
95 | - for (ServerAddress address : addressList) { | |
96 | - getHistoryListModel().addElement(address); | |
97 | - } | |
98 | - if(addressList.size() > 0){ | |
99 | - ServerAddress address = addressList.get(0); | |
100 | - getServerText().setText(address.getHost()); | |
101 | - getPortText().setText(String.valueOf(address.getPort())); | |
102 | - getPortText().setValue(address.getPort()); | |
103 | - } | |
94 | + addressList.add(new ServerAddress("127.0.0.1", 10001)); | |
104 | 95 | } |
96 | + for (ServerAddress address : addressList) { | |
97 | + getHistoryListModel().addElement(address); | |
98 | + } | |
99 | + if(addressList.size() > 0){ | |
100 | + ServerAddress address = addressList.get(0); | |
101 | + getServerText().setText(address.getHost()); | |
102 | + getPortText().setText(String.valueOf(address.getPort())); | |
103 | + getPortText().setValue(address.getPort()); | |
104 | + } | |
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -94,12 +94,7 @@ | ||
94 | 94 | this.setTitle("フォント"); |
95 | 95 | this.setContentPane(getJContentPane()); |
96 | 96 | HashMap<String, Object> fontMap = null; |
97 | - fontMap = (HashMap<String, Object>) StorageUtils.load("font.xml"); | |
98 | - if(fontMap == null){ | |
99 | - fontMap = new HashMap<String, Object>(); | |
100 | - fontMap.put("fontName", "MS ゴシック"); | |
101 | - fontMap.put("fontSize", Integer.valueOf(10)); | |
102 | - } | |
97 | + fontMap = (HashMap<String, Object>) StorageUtils.getFontMap(); | |
103 | 98 | fontNameList.setSelectedValue(fontMap.get("fontName"), true); |
104 | 99 | fontSizeList.setSelectedValue(fontMap.get("fontSize"), true); |
105 | 100 | } |
@@ -23,10 +23,10 @@ | ||
23 | 23 | @SuppressWarnings("unchecked") |
24 | 24 | public ActionResult responseRecieved(String[] response) { |
25 | 25 | ConfigLoader.getInstance().load().setGM(response.length > 3); |
26 | - Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE); | |
26 | + Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class); | |
27 | 27 | appendSystemLog(handle.getName() + " さんがログインしました。"); |
28 | 28 | ArrayList<ServerAddress> serverList = |
29 | - (ArrayList<ServerAddress>) StorageUtils.load("server.xml"); | |
29 | + (ArrayList<ServerAddress>) StorageUtils.load("server.xml", ArrayList.class); | |
30 | 30 | if(serverList.size() > 0){ |
31 | 31 | ServerAddress address = serverList.get(0); |
32 | 32 | address.setSessionId(response[1]); |
@@ -14,6 +14,14 @@ | ||
14 | 14 | /** ポート番号 */ |
15 | 15 | private int port; |
16 | 16 | |
17 | + public ServerAddress(){} | |
18 | + | |
19 | + public ServerAddress(String host, int port) { | |
20 | + super(); | |
21 | + this.host = host; | |
22 | + this.port = port; | |
23 | + } | |
24 | + | |
17 | 25 | private String sessionId; |
18 | 26 | /** |
19 | 27 | * @return host |
@@ -152,7 +152,7 @@ | ||
152 | 152 | view.setVisible(true); |
153 | 153 | view.setLoginOK(false); |
154 | 154 | |
155 | - Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE); | |
155 | + Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class); | |
156 | 156 | if(handle != null){ |
157 | 157 | view.getHandleText().setText(handle.getName()); |
158 | 158 | view.getAliasComboModel().addAll(handle.getAliasList()); |
@@ -455,7 +455,7 @@ | ||
455 | 455 | @Action |
456 | 456 | synchronized public void login() { |
457 | 457 | ArrayList<ServerAddress> serverList = null; |
458 | - serverList = (ArrayList<ServerAddress>) StorageUtils.load("server.xml"); | |
458 | + serverList = (ArrayList<ServerAddress>) StorageUtils.load("server.xml", ArrayList.class); | |
459 | 459 | if (serverList.size() == 0) { |
460 | 460 | view.setMessage("接続失敗です。先にサーバのアドレスを指定してください。"); |
461 | 461 | return; |
@@ -573,7 +573,7 @@ | ||
573 | 573 | public void startServer() { |
574 | 574 | ArrayList<ServerAddress> serverList = null; |
575 | 575 | ServerAddress address = null; |
576 | - serverList = (ArrayList<ServerAddress>) StorageUtils.load("server.xml"); | |
576 | + serverList = (ArrayList<ServerAddress>) StorageUtils.load("server.xml", ArrayList.class); | |
577 | 577 | if(serverList == null){ |
578 | 578 | return; |
579 | 579 | } |
@@ -666,7 +666,7 @@ | ||
666 | 666 | public void rollSum(){ |
667 | 667 | String rule = view.getDiceCombo().getSelectedItem().toString(); |
668 | 668 | int bonus = (Integer) view.getDiceBonusSpinner().getValue(); |
669 | - Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE); | |
669 | + Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class); | |
670 | 670 | int[] result = null; |
671 | 671 | try { |
672 | 672 | result = DiceManager.getInstance().rollSum(rule, bonus, -1); |
@@ -70,12 +70,12 @@ | ||
70 | 70 | view = new DxView(); |
71 | 71 | view.setController(this); |
72 | 72 | |
73 | - ArrayList<Lois> loisList = (ArrayList<Lois>) StorageUtils.load(STRAGE_LOIS); | |
73 | + ArrayList<Lois> loisList = (ArrayList<Lois>) StorageUtils.load(STRAGE_LOIS, ArrayList.class); | |
74 | 74 | if(loisList != null && loisList.size() > 0){ |
75 | 75 | view.getLoisTableModel().setAll(loisList); |
76 | 76 | } |
77 | 77 | |
78 | - DxCharacter character = (DxCharacter) StorageUtils.load(STRAGE_CHARA); | |
78 | + DxCharacter character = (DxCharacter) StorageUtils.load(STRAGE_CHARA, DxCharacter.class); | |
79 | 79 | if(character != null){ |
80 | 80 | view.getHpSpinner().setValue(character.getHp()); |
81 | 81 | view.getInvasionSpinner().setValue(character.getInvasion()); |
@@ -97,7 +97,7 @@ | ||
97 | 97 | |
98 | 98 | @Action |
99 | 99 | public void rollSum(){ |
100 | - Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE); | |
100 | + Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class); | |
101 | 101 | int numDice = (Integer)view.getDiceSpinner().getValue(); |
102 | 102 | int bonus = (Integer)view.getBonusSpinner().getValue(); |
103 | 103 | int critical = (Integer) view.getCriticalSpinner().getValue(); |
@@ -117,7 +117,7 @@ | ||
117 | 117 | |
118 | 118 | @Action |
119 | 119 | public void rollDamage(){ |
120 | - Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE); | |
120 | + Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class); | |
121 | 121 | int numDice = (Integer)view.getDiceSpinner().getValue(); |
122 | 122 | int bonus = (Integer)view.getBonusSpinner().getValue(); |
123 | 123 | DiceRoll roll = new DiceRoll(numDice, bonus, 0); |
@@ -148,7 +148,7 @@ | ||
148 | 148 | |
149 | 149 | @Action |
150 | 150 | public void roll1d(){ |
151 | - Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE); | |
151 | + Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class); | |
152 | 152 | DiceRoll roll = new DiceRoll(1, 0, 0); |
153 | 153 | DiceResult result = DiceRoller.getInstance().rollDamage(roll); |
154 | 154 | view.getHistoryComboModel().add(roll); |
@@ -164,7 +164,7 @@ | ||
164 | 164 | |
165 | 165 | @Action |
166 | 166 | public void roll2d(){ |
167 | - Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE); | |
167 | + Handle handle = (Handle) StorageUtils.load(StorageUtils.HANDLE, Handle.class); | |
168 | 168 | DiceRoll roll = new DiceRoll(2, 0, 0); |
169 | 169 | DiceResult result = DiceRoller.getInstance().rollDamage(roll); |
170 | 170 | view.getHistoryComboModel().add(roll); |