• R/O
  • SSH

Jindolf: 提交

Jindolfプロジェクトは、CGIゲーム「人狼BBS」を快適にプレイするための専用クライアントを製作するために発足したオープンソースプロジェクトです。


Commit MetaInfo

修订版13c3d917816461a9e6e53c40d1bec01a054b2178 (tree)
时间2018-07-08 12:08:38
作者 <olyutorskii@user...>

Log Message

キャスト表Wiki出力の見栄えを改善

更改概述

差异

diff -r dfebfbf01f55 -r 13c3d9178164 CHANGELOG.txt
--- a/CHANGELOG.txt Sun Jul 08 09:35:13 2018 +0900
+++ b/CHANGELOG.txt Sun Jul 08 12:08:38 2018 +0900
@@ -5,8 +5,9 @@
55
66
77 X.XXX.X (XXXX-XX-XX)
8+ ・JDK9以降のWindows HiDPI環境に対応。
9+ ・キャスト表Wiki出力の見栄えを改善。
810 ・JinParser 2.101.4 に対応。
9- ・JDK9以降のWindows HiDPI環境に対応。
1011 ・-nosplashオプションの廃止。
1112
1213 3.302.4 (2017-04-09)
diff -r dfebfbf01f55 -r 13c3d9178164 src/main/java/jp/sfjp/jindolf/dxchg/WolfBBS.java
--- a/src/main/java/jp/sfjp/jindolf/dxchg/WolfBBS.java Sun Jul 08 09:35:13 2018 +0900
+++ b/src/main/java/jp/sfjp/jindolf/dxchg/WolfBBS.java Sun Jul 08 12:08:38 2018 +0900
@@ -7,6 +7,7 @@
77
88 package jp.sfjp.jindolf.dxchg;
99
10+import java.awt.Color;
1011 import java.io.FileNotFoundException;
1112 import java.io.IOException;
1213 import java.nio.ByteBuffer;
@@ -58,6 +59,12 @@
5859
5960 private static final String WOLFBBS_URL = "http://wolfbbs.jp/";
6061
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+
6168 private static final Logger LOGGER = Logger.getAnonymousLogger();
6269
6370 static{
@@ -374,13 +381,60 @@
374381 }
375382
376383 /**
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+ * 陣営の色を返す。
378432 *
379433 * @param role 役職
380- * @return 色Wiki表記
434+ * @return 色
381435 */
382- public static String getTeamWikiColor(GameRole role){
383- String result;
436+ public static Color getTeamColor(GameRole role){
437+ Color result;
384438
385439 switch(role){
386440 case INNOCENT:
@@ -388,14 +442,14 @@
388442 case SHAMAN:
389443 case HUNTER:
390444 case FRATER:
391- result = "#b7bad3";
445+ result = COLOR_INNOCENT;
392446 break;
393447 case WOLF:
394448 case MADMAN:
395- result = "#e0b8b8";
449+ result = COLOR_WOLF;
396450 break;
397451 case HAMSTER:
398- result = "#b9d0be";
452+ result = COLOR_HAMSTER;
399453 break;
400454 default:
401455 assert false;
@@ -449,15 +503,15 @@
449503 }
450504
451505 /**
452- * 運命に対応する色Wiki表記を返す。
506+ * 運命に対応する色を返す。
453507 *
454508 * @param destiny 運命
455- * @return 色Wiki表記
509+ * @return 色
456510 */
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;
461515 return result;
462516 }
463517
diff -r dfebfbf01f55 -r 13c3d9178164 src/main/java/jp/sfjp/jindolf/summary/GameSummary.java
--- a/src/main/java/jp/sfjp/jindolf/summary/GameSummary.java Sun Jul 08 09:35:13 2018 +0900
+++ b/src/main/java/jp/sfjp/jindolf/summary/GameSummary.java Sun Jul 08 12:08:38 2018 +0900
@@ -7,6 +7,7 @@
77
88 package jp.sfjp.jindolf.summary;
99
10+import java.awt.Color;
1011 import java.net.MalformedURLException;
1112 import java.net.URI;
1213 import java.net.URISyntaxException;
@@ -46,6 +47,8 @@
4647 public static final Comparator<Player> COMPARATOR_CASTING =
4748 new CastingComparator();
4849
50+ private static final Color COLOR_PLAINTABLE = new Color(0xedf5fe);
51+
4952 private static final String GENERATOR =
5053 VerInfo.TITLE + "\u0020Ver." + VerInfo.VERSION;
5154
@@ -694,6 +697,8 @@
694697 .append('\n');
695698 wikiText.append(WolfBBS.COMMENTLINE);
696699
700+ boolean even = true;
701+
697702 for(Player player : getCastingPlayerList()){
698703 Avatar avatar = player.getAvatar();
699704 GameRole role = player.getRole();
@@ -720,34 +725,48 @@
720725 .append("]");
721726 wikiText.append(" ==========\n");
722727
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)
725746 + "):";
726747
727748 String avatarIcon = iconSet.getAvatarIconWiki(avatar);
728749
729- wikiText.append('|').append(teamColor);
750+ wikiText.append('|').append(teamWikiColor);
730751 wikiText.append(avatarIcon).append("&br;");
731752
732753 wikiText.append("[[").append(avatar.getName()).append("]]");
733754
734- wikiText.append('|').append(teamColor);
755+ wikiText.append('|').append(teamWikiColor);
735756 wikiText.append("[[").append(WolfBBS.escapeWikiBracket(name));
736757 if(urlText != null && urlText.length() > 0){
737758 wikiText.append('>').append(urlText);
738759 }
739760 wikiText.append("]]");
740761
741- wikiText.append('|').append(teamColor);
762+ wikiText.append('|').append(teamWikiColor);
742763 wikiText.append(WolfBBS.getRoleIconWiki(role));
743764 wikiText.append("&br;");
744765 wikiText.append("[[");
745766 wikiText.append(role.getRoleName());
746767 wikiText.append("]]");
747768
748- String destinyColor = WolfBBS.getDestinyColorWiki(destiny);
749- wikiText.append('|');
750- wikiText.append("BGCOLOR(").append(destinyColor).append("):");
769+ wikiText.append('|').append(destinyWikiColor);
751770 if(destiny == Destiny.ALIVE){
752771 wikiText.append("最後まで&br;生存");
753772 }else{
@@ -755,7 +774,7 @@
755774 wikiText.append(destiny.getMessage());
756775 }
757776
758- wikiText.append('|');
777+ wikiText.append('|').append(plainWikiColor);
759778 wikiText.append(avatar.getJobTitle()).append('。');
760779
761780 if(avatar == Avatar.AVATAR_GERD){
diff -r dfebfbf01f55 -r 13c3d9178164 src/test/java/jp/sfjp/jindolf/dxchg/WolfBBSTest.java
--- a/src/test/java/jp/sfjp/jindolf/dxchg/WolfBBSTest.java Sun Jul 08 09:35:13 2018 +0900
+++ b/src/test/java/jp/sfjp/jindolf/dxchg/WolfBBSTest.java Sun Jul 08 12:08:38 2018 +0900
@@ -6,8 +6,7 @@
66
77 package jp.sfjp.jindolf.dxchg;
88
9-import jp.sourceforge.jindolf.corelib.Destiny;
10-import jp.sourceforge.jindolf.corelib.GameRole;
9+import java.awt.Color;
1110 import org.junit.After;
1211 import org.junit.AfterClass;
1312 import org.junit.Before;
@@ -68,64 +67,31 @@
6867 }
6968
7069 /**
71- * Test of getTeamWikiColor method, of class WolfBBS.
70+ * Test of cnvWikiColor method, of class WolfBBS.
7271 */
7372 @Test
74- public void testGetTeamWikiColor() {
75- System.out.println("getTeamWikiColor");
73+ public void testCnvWikiColor() {
74+ System.out.println("cnvWikiColor");
7675
7776 String result;
7877
79- result = WolfBBS.getTeamWikiColor(GameRole.INNOCENT);
80- assertEquals("#b7bad3", result);
81-
82- result = WolfBBS.getTeamWikiColor(GameRole.FRATER);
83- assertEquals("#b7bad3", result);
84-
85- result = WolfBBS.getTeamWikiColor(GameRole.HUNTER);
86- assertEquals("#b7bad3", result);
87-
88- result = WolfBBS.getTeamWikiColor(GameRole.SEER);
89- assertEquals("#b7bad3", result);
90-
91- result = WolfBBS.getTeamWikiColor(GameRole.SHAMAN);
92- assertEquals("#b7bad3", result);
93-
94- result = WolfBBS.getTeamWikiColor(GameRole.WOLF);
95- assertEquals("#e0b8b8", result);
78+ result = WolfBBS.cnvWikiColor(new Color(0x00, 0x00, 0x00));
79+ assertEquals("#000000", result);
9680
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- }
81+ result = WolfBBS.cnvWikiColor(new Color(0x12, 0x34, 0x56));
82+ assertEquals("#123456", result);
10583
106- /**
107- * Test of getDestinyColorWiki method, of class WolfBBS.
108- */
109- @Test
110- public void testGetDestinyColorWiki() {
111- System.out.println("getDestinyColorWiki");
84+ result = WolfBBS.cnvWikiColor(new Color(0x01, 0x00, 0x00));
85+ assertEquals("#010000", result);
11286
113- String result;
87+ result = WolfBBS.cnvWikiColor(new Color(0x00, 0x00, 0x01));
88+ assertEquals("#000001", result);
11489
115- result = WolfBBS.getDestinyColorWiki(Destiny.ALIVE);
90+ result = WolfBBS.cnvWikiColor(new Color(0xff, 0xff, 0xff));
11691 assertEquals("#ffffff", result);
11792
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);
12995
13096 return;
13197 }
Show on old repository browser