• R/O
  • SSH
  • HTTPS

hyakutyping: コミット


コミットメタ情報

リビジョン266 (tree)
日時2008-05-15 07:15:52
作者satofumi

ログメッセージ

add script

変更サマリ

差分

--- branches/tsundere/typingText2header.rb (nonexistent)
+++ branches/tsundere/typingText2header.rb (revision 266)
@@ -0,0 +1,91 @@
1+#!/usr/bin/ruby
2+# 百人一首用のテキストを、ヘッダファイルに変換するスクリプト
3+# Satofumi KAMIMURA
4+# $Id$
5+
6+$KCODE = 'u'
7+
8+require 'kconv'
9+require 'jcode'
10+
11+
12+if ARGV.length < 1
13+ # 使い方を表示して終了
14+ print "usage:\n\t" + __FILE__ + " <resource file>\n"
15+ exit(1)
16+end
17+resource_file = ARGV[0];
18+
19+left_lines = File.readlines(resource_file).join
20+
21+numbers = []
22+yomibito_kanji = []
23+yomibito_kana = []
24+waka_upper_kanji = []
25+waka_upper_kana = []
26+waka_lower_kanji = []
27+waka_lower_kana = []
28+
29+while left_lines && (! left_lines.empty?)
30+
31+ # パース処理
32+ if left_lines =~ /^(\d+)\n+「(.+?)」\n+「(.+?)」\n+「(.+?)」\n+「(.+?)」\n+「(.+?)」\n+「(.+?)」/m
33+
34+ # データの格納
35+ numbers << $1.to_i
36+ yomibito_kanji << $2
37+ yomibito_kana << $3
38+
39+ waka_upper_kanji << $4
40+ waka_upper_kana << $5
41+
42+ waka_lower_kanji << $6
43+ waka_lower_kana << $7
44+ end
45+
46+ left_lines = $'
47+end
48+
49+
50+# 日本語文字列をヘッダファイル用の配列データに変換
51+def convertCsvLine(line)
52+
53+ out = ''
54+ line.each_char { |ch|
55+ out += '0x'
56+ out += ('0' + ch[0].to_s(16))[-2, 2]
57+ if (ch.length > 1)
58+ out += ('0' + ch[1].to_s(16))[-2, 2]
59+ end
60+ out += ', '
61+ }
62+ out += "0x0"
63+end
64+
65+# データのヘッダファイル化
66+index = 0
67+numbers.each { |id|
68+
69+ # 詠み人のヘッダファイル化
70+ print ' // ' + yomibito_kanji[index] + "\n"
71+ print ' { { ' + convertCsvLine(yomibito_kanji[index]) + " },\n"
72+ print ' { ' + convertCsvLine(yomibito_kana[index]) + " } },\n"
73+
74+ print "\n"
75+ index += 1
76+}
77+
78+index = 0
79+numbers.each { |id|
80+
81+ # 和歌のヘッダファイル化
82+
83+ # 改行毎にデータを分割する
84+ print '// ' + convertCsvLine(waka_upper_kanji[index]) + "\n"
85+ print '// ' + convertCsvLine(waka_upper_kana[index]) + "\n"
86+
87+ #print "\n"
88+ index += 1
89+}
90+
91+# !!! include guard を付加すべき
--- branches/tsundere/Makefile (revision 265)
+++ branches/tsundere/Makefile (revision 266)
@@ -8,6 +8,7 @@
88 INCLUDES = -I. -I../../../../libs/http -I../../../../libs/senario -I../../../../libs/sound -I../../../../libs/jpinput -I../../../../libs/tools/bmp2header -I../../../../libs/tools/file2header -I../../../../libs/gui -I../../../../libs/common
99 LDFLAGS =
1010 LDLIBS = `sdl-config --libs` -lSDL_mixer -lSDL_ttf -lSDL_net -lSDL_image
11+CREATE_TEYPING_HEADER_SCRIPT = typingText2header.rb
1112
1213
1314 # Target
@@ -14,7 +15,7 @@
1415 TSUNDERE_HYAKUTYPING = tsundere_hyakutyping
1516 TARGET = ${TSUNDERE_HYAKUTYPING}
1617
17-all : ${TARGET}
18+all : ${TARGET} tsundere_typing.h
1819
1920 clean :
2021 ${RM} *.o ${TARGET}
@@ -28,7 +29,10 @@
2829 ${REQUIRE_LIBS} :
2930 cd ${@D}/ && ${MAKE} ${@F}
3031
31-${TSUNDERE_HYAKUTYPING}: hyakutyping.o CommonResources.o FirstMenu.o TypingRecorder.o VoicePlayer.o AccessSettings.o UserMenu.o PracticeMenu.o NetworkMenu.o ViewHistory.o OptionMenu.o CreateUser.o RemoveUser.o ShimonokuPractice.o KimarijiPractice.o GraphDrawer.o AccessRecordPC.o ${REQUIRE_LIBS}
32+tsundere_typing.h : tsundere_typing.txt ${CREATE_TEYPING_HEADER_SCRIPT}
33+ ruby ${CREATE_TEYPING_HEADER_SCRIPT} $< > $@ || ${RM} $@
34+
35+${TSUNDERE_HYAKUTYPING}: hyakutyping.o CommonResources.o FirstMenu.o TypingRecorder.o VoicePlayer.o AccessSettings.o UserMenu.o PracticeMenu.o NetworkMenu.o ViewHistory.o OptionMenu.o CreateUser.o RemoveUser.o ShimonokuPractice.o KimarijiPractice.o GraphDrawer.o AccessRecordPC.o UpdateUtils.o ${REQUIRE_LIBS}
3236 ${CC} $^ ${LDFLAGS} ${LDLIBS} -o $@
3337
3438 hyakutyping.o : ../../hyakutyping.cpp
@@ -76,6 +80,9 @@
7680 AccessRecordPC.o : ../../AccessRecordPC.cpp
7781 ${CXX} ${CXXFLAGS} $< -c -o $@
7882
83+UpdateUtils.o : ../../UpdateUtils.cpp
84+ ${CXX} ${CXXFLAGS} $< -c -o $@
85+
7986 # DO NOT DELETE
8087
8188 KimarijiPractice.o: KimarijiPractice.h
旧リポジトリブラウザで表示