Jindolfプロジェクトは、CGIゲーム「人狼BBS」を快適にプレイするための専用クライアントを製作するために発足したオープンソースプロジェクトです。
修订版 | 2630fd0a05a69c138a804b94b1d958e6f9efe72b (tree) |
---|---|
时间 | 2018-07-08 12:08:38 |
作者 | ![]() |
Commiter | Olyutorskii |
キャスト表Wiki出力の見栄えを改善
@@ -5,8 +5,9 @@ Jindolf 変更履歴 | ||
5 | 5 | |
6 | 6 | |
7 | 7 | X.XXX.X (XXXX-XX-XX) |
8 | - ・JinParser 2.101.4 に対応。 | |
9 | 8 | ・JDK9以降のWindows HiDPI環境に対応。 |
9 | + ・キャスト表Wiki出力の見栄えを改善。 | |
10 | + ・JinParser 2.101.4 に対応。 | |
10 | 11 | ・-nosplashオプションの廃止。 |
11 | 12 | |
12 | 13 | 3.302.4 (2017-04-09) |
@@ -7,6 +7,7 @@ | ||
7 | 7 | |
8 | 8 | package jp.sfjp.jindolf.dxchg; |
9 | 9 | |
10 | +import java.awt.Color; | |
10 | 11 | import java.io.FileNotFoundException; |
11 | 12 | import java.io.IOException; |
12 | 13 | import java.nio.ByteBuffer; |
@@ -58,6 +59,12 @@ public final class WolfBBS{ | ||
58 | 59 | |
59 | 60 | private static final String WOLFBBS_URL = "http://wolfbbs.jp/"; |
60 | 61 | |
62 | + private static final Color COLOR_INNOCENT = new Color(0xb7bad3); | |
63 | + private static final Color COLOR_WOLF = new Color(0xe0b8b8); | |
64 | + private static final Color COLOR_HAMSTER = new Color(0xb9d0be); | |
65 | + private static final Color COLOR_DEAD = new Color(0xaaaaaa); | |
66 | + private static final Color COLOR_ALIVE = new Color(0xffffff); | |
67 | + | |
61 | 68 | private static final Logger LOGGER = Logger.getAnonymousLogger(); |
62 | 69 | |
63 | 70 | static{ |
@@ -374,13 +381,60 @@ public final class WolfBBS{ | ||
374 | 381 | } |
375 | 382 | |
376 | 383 | /** |
377 | - * 陣営の色Wiki表記を返す。 | |
384 | + * ColorのRGB各成分をWikiカラー表記に変換する。 | |
385 | + * | |
386 | + * α成分は無視される。 | |
387 | + * | |
388 | + * @param color 色 | |
389 | + * @return Wikiカラー表記 | |
390 | + */ | |
391 | + public static String cnvWikiColor(Color color){ | |
392 | + int packRGB = color.getRGB(); | |
393 | + | |
394 | + String txtRGB = Integer.toHexString(packRGB); | |
395 | + String leadRGB = "00000000" + txtRGB; | |
396 | + int chopLen = leadRGB.length() - 6; | |
397 | + String fixed = leadRGB.substring(chopLen); | |
398 | + String result = "#" + fixed; | |
399 | + | |
400 | + return result; | |
401 | + } | |
402 | + | |
403 | + /** | |
404 | + * 表の偶数行に色の変化を付ける。 | |
405 | + * | |
406 | + * @param color 色 | |
407 | + * @return 変化した色 | |
408 | + */ | |
409 | + public static Color evenColor(Color color){ | |
410 | + int red = color.getRed(); | |
411 | + int green = color.getGreen(); | |
412 | + int blue = color.getBlue(); | |
413 | + | |
414 | + float[] hsb = Color.RGBtoHSB(red, green, blue, null); | |
415 | + float h = hsb[0]; | |
416 | + float s = hsb[1]; | |
417 | + float b = hsb[2]; | |
418 | + | |
419 | + if(b < 0.5){ | |
420 | + b += 0.03; | |
421 | + }else{ | |
422 | + b -= 0.03; | |
423 | + } | |
424 | + | |
425 | + Color result = Color.getHSBColor(h, s, b); | |
426 | + | |
427 | + return result; | |
428 | + } | |
429 | + | |
430 | + /** | |
431 | + * 陣営の色を返す。 | |
378 | 432 | * |
379 | 433 | * @param role 役職 |
380 | - * @return 色Wiki表記 | |
434 | + * @return 色 | |
381 | 435 | */ |
382 | - public static String getTeamWikiColor(GameRole role){ | |
383 | - String result; | |
436 | + public static Color getTeamColor(GameRole role){ | |
437 | + Color result; | |
384 | 438 | |
385 | 439 | switch(role){ |
386 | 440 | case INNOCENT: |
@@ -388,14 +442,14 @@ public final class WolfBBS{ | ||
388 | 442 | case SHAMAN: |
389 | 443 | case HUNTER: |
390 | 444 | case FRATER: |
391 | - result = "#b7bad3"; | |
445 | + result = COLOR_INNOCENT; | |
392 | 446 | break; |
393 | 447 | case WOLF: |
394 | 448 | case MADMAN: |
395 | - result = "#e0b8b8"; | |
449 | + result = COLOR_WOLF; | |
396 | 450 | break; |
397 | 451 | case HAMSTER: |
398 | - result = "#b9d0be"; | |
452 | + result = COLOR_HAMSTER; | |
399 | 453 | break; |
400 | 454 | default: |
401 | 455 | assert false; |
@@ -449,15 +503,15 @@ public final class WolfBBS{ | ||
449 | 503 | } |
450 | 504 | |
451 | 505 | /** |
452 | - * 運命に対応する色Wiki表記を返す。 | |
506 | + * 運命に対応する色を返す。 | |
453 | 507 | * |
454 | 508 | * @param destiny 運命 |
455 | - * @return 色Wiki表記 | |
509 | + * @return 色 | |
456 | 510 | */ |
457 | - public static String getDestinyColorWiki(Destiny destiny){ | |
458 | - String result; | |
459 | - if(destiny == Destiny.ALIVE) result = "#ffffff"; | |
460 | - else result = "#aaaaaa"; | |
511 | + public static Color getDestinyColor(Destiny destiny){ | |
512 | + Color result; | |
513 | + if(destiny == Destiny.ALIVE) result = COLOR_ALIVE; | |
514 | + else result = COLOR_DEAD; | |
461 | 515 | return result; |
462 | 516 | } |
463 | 517 |
@@ -7,6 +7,7 @@ | ||
7 | 7 | |
8 | 8 | package jp.sfjp.jindolf.summary; |
9 | 9 | |
10 | +import java.awt.Color; | |
10 | 11 | import java.net.MalformedURLException; |
11 | 12 | import java.net.URI; |
12 | 13 | import java.net.URISyntaxException; |
@@ -46,6 +47,8 @@ public class GameSummary{ | ||
46 | 47 | public static final Comparator<Player> COMPARATOR_CASTING = |
47 | 48 | new CastingComparator(); |
48 | 49 | |
50 | + private static final Color COLOR_PLAINTABLE = new Color(0xedf5fe); | |
51 | + | |
49 | 52 | private static final String GENERATOR = |
50 | 53 | VerInfo.TITLE + "\u0020Ver." + VerInfo.VERSION; |
51 | 54 |
@@ -694,6 +697,8 @@ public class GameSummary{ | ||
694 | 697 | .append('\n'); |
695 | 698 | wikiText.append(WolfBBS.COMMENTLINE); |
696 | 699 | |
700 | + boolean even = true; | |
701 | + | |
697 | 702 | for(Player player : getCastingPlayerList()){ |
698 | 703 | Avatar avatar = player.getAvatar(); |
699 | 704 | GameRole role = player.getRole(); |
@@ -720,34 +725,48 @@ public class GameSummary{ | ||
720 | 725 | .append("]"); |
721 | 726 | wikiText.append(" ==========\n"); |
722 | 727 | |
723 | - String teamColor = "BGCOLOR(" | |
724 | - + WolfBBS.getTeamWikiColor(role) | |
728 | + Color teamColor = WolfBBS.getTeamColor(role); | |
729 | + Color destinyColor = WolfBBS.getDestinyColor(destiny); | |
730 | + Color plainColor = COLOR_PLAINTABLE; | |
731 | + if(even){ | |
732 | + teamColor = WolfBBS.evenColor(teamColor); | |
733 | + destinyColor = WolfBBS.evenColor(destinyColor); | |
734 | + plainColor = WolfBBS.evenColor(plainColor); | |
735 | + } | |
736 | + even = ! even; | |
737 | + | |
738 | + String teamWikiColor = "BGCOLOR(" | |
739 | + + WolfBBS.cnvWikiColor(teamColor) | |
740 | + + "):"; | |
741 | + String destinyWikiColor = "BGCOLOR(" | |
742 | + + WolfBBS.cnvWikiColor(destinyColor) | |
743 | + + "):"; | |
744 | + String plainWikiColor = "BGCOLOR(" | |
745 | + + WolfBBS.cnvWikiColor(plainColor) | |
725 | 746 | + "):"; |
726 | 747 | |
727 | 748 | String avatarIcon = iconSet.getAvatarIconWiki(avatar); |
728 | 749 | |
729 | - wikiText.append('|').append(teamColor); | |
750 | + wikiText.append('|').append(teamWikiColor); | |
730 | 751 | wikiText.append(avatarIcon).append("&br;"); |
731 | 752 | |
732 | 753 | wikiText.append("[[").append(avatar.getName()).append("]]"); |
733 | 754 | |
734 | - wikiText.append('|').append(teamColor); | |
755 | + wikiText.append('|').append(teamWikiColor); | |
735 | 756 | wikiText.append("[[").append(WolfBBS.escapeWikiBracket(name)); |
736 | 757 | if(urlText != null && urlText.length() > 0){ |
737 | 758 | wikiText.append('>').append(urlText); |
738 | 759 | } |
739 | 760 | wikiText.append("]]"); |
740 | 761 | |
741 | - wikiText.append('|').append(teamColor); | |
762 | + wikiText.append('|').append(teamWikiColor); | |
742 | 763 | wikiText.append(WolfBBS.getRoleIconWiki(role)); |
743 | 764 | wikiText.append("&br;"); |
744 | 765 | wikiText.append("[["); |
745 | 766 | wikiText.append(role.getRoleName()); |
746 | 767 | wikiText.append("]]"); |
747 | 768 | |
748 | - String destinyColor = WolfBBS.getDestinyColorWiki(destiny); | |
749 | - wikiText.append('|'); | |
750 | - wikiText.append("BGCOLOR(").append(destinyColor).append("):"); | |
769 | + wikiText.append('|').append(destinyWikiColor); | |
751 | 770 | if(destiny == Destiny.ALIVE){ |
752 | 771 | wikiText.append("最後まで&br;生存"); |
753 | 772 | }else{ |
@@ -755,7 +774,7 @@ public class GameSummary{ | ||
755 | 774 | wikiText.append(destiny.getMessage()); |
756 | 775 | } |
757 | 776 | |
758 | - wikiText.append('|'); | |
777 | + wikiText.append('|').append(plainWikiColor); | |
759 | 778 | wikiText.append(avatar.getJobTitle()).append('。'); |
760 | 779 | |
761 | 780 | if(avatar == Avatar.AVATAR_GERD){ |
@@ -6,8 +6,7 @@ | ||
6 | 6 | |
7 | 7 | package jp.sfjp.jindolf.dxchg; |
8 | 8 | |
9 | -import jp.sourceforge.jindolf.corelib.Destiny; | |
10 | -import jp.sourceforge.jindolf.corelib.GameRole; | |
9 | +import java.awt.Color; | |
11 | 10 | import org.junit.After; |
12 | 11 | import org.junit.AfterClass; |
13 | 12 | import org.junit.Before; |
@@ -68,64 +67,31 @@ public class WolfBBSTest { | ||
68 | 67 | } |
69 | 68 | |
70 | 69 | /** |
71 | - * Test of getTeamWikiColor method, of class WolfBBS. | |
70 | + * Test of cnvWikiColor method, of class WolfBBS. | |
72 | 71 | */ |
73 | 72 | @Test |
74 | - public void testGetTeamWikiColor() { | |
75 | - System.out.println("getTeamWikiColor"); | |
73 | + public void testCnvWikiColor() { | |
74 | + System.out.println("cnvWikiColor"); | |
76 | 75 | |
77 | 76 | String result; |
78 | 77 | |
79 | - result = WolfBBS.getTeamWikiColor(GameRole.INNOCENT); | |
80 | - assertEquals("#b7bad3", result); | |
78 | + result = WolfBBS.cnvWikiColor(new Color(0x00, 0x00, 0x00)); | |
79 | + assertEquals("#000000", result); | |
81 | 80 | |
82 | - result = WolfBBS.getTeamWikiColor(GameRole.FRATER); | |
83 | - assertEquals("#b7bad3", result); | |
81 | + result = WolfBBS.cnvWikiColor(new Color(0x12, 0x34, 0x56)); | |
82 | + assertEquals("#123456", result); | |
84 | 83 | |
85 | - result = WolfBBS.getTeamWikiColor(GameRole.HUNTER); | |
86 | - assertEquals("#b7bad3", result); | |
84 | + result = WolfBBS.cnvWikiColor(new Color(0x01, 0x00, 0x00)); | |
85 | + assertEquals("#010000", result); | |
87 | 86 | |
88 | - result = WolfBBS.getTeamWikiColor(GameRole.SEER); | |
89 | - assertEquals("#b7bad3", result); | |
87 | + result = WolfBBS.cnvWikiColor(new Color(0x00, 0x00, 0x01)); | |
88 | + assertEquals("#000001", result); | |
90 | 89 | |
91 | - result = WolfBBS.getTeamWikiColor(GameRole.SHAMAN); | |
92 | - assertEquals("#b7bad3", result); | |
93 | - | |
94 | - result = WolfBBS.getTeamWikiColor(GameRole.WOLF); | |
95 | - assertEquals("#e0b8b8", result); | |
96 | - | |
97 | - result = WolfBBS.getTeamWikiColor(GameRole.MADMAN); | |
98 | - assertEquals("#e0b8b8", result); | |
99 | - | |
100 | - result = WolfBBS.getTeamWikiColor(GameRole.HAMSTER); | |
101 | - assertEquals("#b9d0be", result); | |
102 | - | |
103 | - return; | |
104 | - } | |
105 | - | |
106 | - /** | |
107 | - * Test of getDestinyColorWiki method, of class WolfBBS. | |
108 | - */ | |
109 | - @Test | |
110 | - public void testGetDestinyColorWiki() { | |
111 | - System.out.println("getDestinyColorWiki"); | |
112 | - | |
113 | - String result; | |
114 | - | |
115 | - result = WolfBBS.getDestinyColorWiki(Destiny.ALIVE); | |
90 | + result = WolfBBS.cnvWikiColor(new Color(0xff, 0xff, 0xff)); | |
116 | 91 | assertEquals("#ffffff", result); |
117 | 92 | |
118 | - result = WolfBBS.getDestinyColorWiki(Destiny.DISSOLVE); | |
119 | - assertEquals("#aaaaaa", result); | |
120 | - | |
121 | - result = WolfBBS.getDestinyColorWiki(Destiny.EATEN); | |
122 | - assertEquals("#aaaaaa", result); | |
123 | - | |
124 | - result = WolfBBS.getDestinyColorWiki(Destiny.EXECUTED); | |
125 | - assertEquals("#aaaaaa", result); | |
126 | - | |
127 | - result = WolfBBS.getDestinyColorWiki(Destiny.SUDDENDEATH); | |
128 | - assertEquals("#aaaaaa", result); | |
93 | + result = WolfBBS.cnvWikiColor(new Color(0x12, 0x34, 0x56, 0x78)); | |
94 | + assertEquals("#123456", result); | |
129 | 95 | |
130 | 96 | return; |
131 | 97 | } |