• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

密猟オンラインクライアントプログラム JAVAベース


Commit MetaInfo

Revision22 (tree)
Time2016-12-29 17:00:19
Authormanjihq

Log Message

システムメッセージでリスト表示が必要そうなものをリスト表示ウィンドウへ表示するようにした

Change Summary

Incremental Difference

--- trunk/src/hunton/Hunt.java (revision 21)
+++ trunk/src/hunton/Hunt.java (revision 22)
@@ -148,10 +148,12 @@
148148 static Component mainView;
149149 static Component statusView;
150150 static Component messageView;
151+ static HuntListView listViewWnd;
151152
152153 static Rectangle mainWndBounds;
153154 static Rectangle statusViewBounds;
154155 static Rectangle messageViewBounds;
156+ static Rectangle listViewBounds;
155157
156158 static pktio session;
157159 static RecvTask rtask;
@@ -606,6 +608,19 @@
606608 }
607609 }
608610
611+ public static void kick_listview(String s) {
612+ if (listViewWnd == null) {
613+ listViewWnd = new HuntListView();
614+ if (listViewBounds == null) {
615+ listViewWnd.setBounds(0, 0, 400, 300);
616+ } else {
617+ listViewWnd.setBounds(listViewBounds);
618+ }
619+ listViewWnd.setVisible(true);
620+ }
621+ listViewWnd.add_message(s);
622+ }
623+
609624 public static void set_effect(int n, long nspan) {
610625 if (messageView != null) {
611626 HuntMainView hview = (HuntMainView) mainView;
@@ -796,6 +811,7 @@
796811 messageView.setVisible(true);
797812
798813 mainWnd.setVisible(true);
814+ mainWnd.toFront();
799815 }
800816
801817 /* try to login server */
@@ -860,6 +876,7 @@
860876 save_rect(ofile, mainWndBounds);
861877 save_rect(ofile, statusViewBounds);
862878 save_rect(ofile, messageViewBounds);
879+ save_rect(ofile, listViewBounds);
863880 }
864881 } catch (IOException e) {
865882 System.out.println("fail to save setup-file!"); //NOI18N
@@ -911,6 +928,7 @@
911928 mainWndBounds = null;
912929 statusViewBounds = null;
913930 messageViewBounds = null;
931+ listViewBounds = null;
914932 try {
915933 try (BufferedReader ifile
916934 = new BufferedReader(new FileReader("hunt_setup.def"))) { //NOI18N
@@ -930,6 +948,7 @@
930948 mainWndBounds = load_rect(ifile);
931949 statusViewBounds = load_rect(ifile);
932950 messageViewBounds = load_rect(ifile);
951+ listViewBounds = load_rect(ifile);
933952 }
934953 } catch (IOException e) {
935954 }
@@ -948,6 +967,10 @@
948967 statusViewBounds = wnd.getBounds();
949968 wnd.dispose();
950969 }
970+ if (listViewWnd != null) {
971+ listViewBounds = listViewWnd.getBounds();
972+ listViewWnd.dispose();
973+ }
951974 if (mainWnd != null) {
952975 mainWndBounds = mainWnd.getBounds();
953976 mainWnd.dispose();
--- trunk/src/hunton/HuntListView.java (nonexistent)
+++ trunk/src/hunton/HuntListView.java (revision 22)
@@ -0,0 +1,86 @@
1+package hunton;
2+
3+import java.awt.*;
4+import java.awt.event.*;
5+import java.util.ArrayList;
6+
7+/**
8+ * List view window
9+ *
10+ * @author terry
11+ */
12+public class HuntListView extends Frame {
13+
14+ List plist;
15+ ArrayList<String> mesg;
16+ ArrayList<Integer> fieldWidth;
17+
18+ HuntListView() {
19+ super();
20+ mesg = new ArrayList<>();
21+ fieldWidth = new ArrayList<>();
22+ ScrollPane scpane = new ScrollPane();
23+ plist = new List();
24+ plist.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
25+ scpane.add(plist);
26+ add(scpane);
27+ addWindowListener(new HuntListViewEvent());
28+ pack();
29+ }
30+
31+ int add_mesg_fields(String s) {
32+ String fields[] = s.split(":");
33+ int i;
34+ for (i = 0; i < fields.length; i++) {
35+ int n = Hunt.countStringWidth(fields[i]);
36+ if (i < fieldWidth.size()) {
37+ if (n > fieldWidth.get(i)) {
38+ fieldWidth.set(i, n);
39+ }
40+ } else {
41+ fieldWidth.add(n);
42+ }
43+ }
44+ mesg.add(s);
45+ return i;
46+ }
47+
48+ String format_message_line(String s) {
49+ int i;
50+ StringBuilder wk = new StringBuilder();
51+ String fields[] = s.split(":");
52+ for (i = 0; i < fields.length; i++) {
53+ wk.append(Hunt.formatStringWidth(fields[i], fieldWidth.get(i)));
54+ wk.append(":");
55+ }
56+ if (i > 0) {
57+ //remove last separator
58+ wk.deleteCharAt(wk.length() - 1);
59+ }
60+ return wk.toString();
61+ }
62+
63+ public void add_message(String s) {
64+ if (add_mesg_fields(s) == 1) {
65+ //found last message mark
66+ //update list view
67+ int i;
68+ plist.removeAll();
69+ for (i = 0; i < mesg.size(); i++) {
70+ plist.add(format_message_line(mesg.get(i)));
71+ }
72+ mesg.clear();
73+ }
74+ }
75+
76+}
77+
78+class HuntListViewEvent extends WindowAdapter {
79+
80+ @Override
81+ public void windowClosing(WindowEvent e) {
82+ }
83+
84+}
85+
86+/* EOF */
--- trunk/src/hunton/RecvTask.java (revision 21)
+++ trunk/src/hunton/RecvTask.java (revision 22)
@@ -100,7 +100,11 @@
100100 } catch (UnsupportedEncodingException e) {
101101 message = "?"; //NOI18N
102102 }
103- Hunt.display_message(message);
103+ if (message.length() > 1 && message.charAt(0) == '<') {
104+ Hunt.kick_listview(message);
105+ } else {
106+ Hunt.display_message(message);
107+ }
104108 }
105109 }
106110