すくすくゴートうちゃん Android 版(黒歴史)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
2.2 KiB

  1. #ifndef __CHAR__
  2. #define __CHAR__
  3. /**
  4. * 文字列表示
  5. *
  6. * @property str text
  7. * @property int posX
  8. * @property int posY
  9. * @property int size
  10. * @property bool exists
  11. */
  12. #module \
  13. Char
  14. #const CHAR_WIDTH 32
  15. #const UNKNOWN 52
  16. /**
  17. * コンストラクタ:文字列を生成する.
  18. *
  19. * @param int posX
  20. * @param int posY
  21. * @param str text
  22. */
  23. #defcfunc local \
  24. New \
  25. int p_posX,\
  26. int p_posY,\
  27. str p_text
  28. If insNum <= 0 {
  29. SDim charDict, 384
  30. SDim text, 1024
  31. BLoad "dict.dat", charDict
  32. }
  33. text.insNum = p_text
  34. posX.insNum = p_posX
  35. posY.insNum = p_posY
  36. size.insNum = CHAR_WIDTH
  37. exists.insNum = True
  38. insNum++
  39. Return insNum - 1
  40. /**
  41. * 文字列を非表示にする.
  42. *
  43. * @return void
  44. */
  45. #deffunc local \
  46. Destroy \
  47. int p_insId
  48. exists.p_insId = False
  49. Return
  50. /**
  51. * 文字列を描画する.
  52. *
  53. * @var int cnt
  54. * @var bool found
  55. * @var double zoom
  56. * @return void
  57. */
  58. #deffunc local \
  59. Draw \
  60. local l_cnt,\
  61. local l_found
  62. Repeat insNum
  63. If exists.cnt {
  64. l_cnt = cnt
  65. Repeat StrLen (text.l_cnt) / 3
  66. l_found = MyInStr (charDict, 0, StrMid (text.l_cnt, cnt * 3, 3)) / 3
  67. If darw_found < 0 {
  68. l_found = UNKNOWN
  69. }
  70. Pos posX.l_cnt + cnt * size.l_cnt, posY.l_cnt
  71. l_zoom = Double (size.l_cnt) / CHAR_WIDTH
  72. CelPut BUFFER_CHAR, l_found, l_zoom, l_zoom
  73. Loop
  74. }
  75. Loop
  76. Return
  77. /**
  78. * 文字列を検索する.
  79. *
  80. * @param str haystack
  81. * @param str offset
  82. * @param str needle
  83. * @return int
  84. */
  85. #defcfunc local \
  86. MyInStr \
  87. str p_haystack,\
  88. int p_offset,\
  89. str p_needle
  90. myInStr_haystack = p_haystack
  91. myInStr_flag = True
  92. Repeat StrLen (myInStr_haystack) / 3
  93. SDim myInStr_work, 3
  94. myInStr_cnt = cnt
  95. Repeat 3
  96. Poke myInStr_work, cnt, Peek (myInStr_haystack, myInStr_cnt * 3 + cnt)
  97. Loop
  98. If myInStr_work = p_needle {
  99. myInStr_flag = False
  100. Break
  101. }
  102. Loop
  103. If myInStr_flag {
  104. Return -1
  105. }
  106. Return myInStr_cnt * 3
  107. /**
  108. * 文字列を抜き出す.
  109. *
  110. * @param str string
  111. * @param int offset
  112. * @param int length
  113. * @return str
  114. */
  115. #defcfunc local \
  116. MyStrMid \
  117. str p_string,\
  118. int p_offset,\
  119. int p_length
  120. myStrMid_string = p_string
  121. SDim myStrMid_return, p_length
  122. Return myStrMid_return
  123. #global
  124. #endif ; not __CHAR__