すくすくゴートうちゃん 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.

139 lines
2.0 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. #defcfunc local \
  78. MyInStr \
  79. str p_haystack,\
  80. int p_offset,\
  81. str p_needle
  82. myInStr_haystack = p_haystack
  83. myInStr_flag = True
  84. Repeat StrLen (myInStr_haystack) / 3
  85. SDim myInStr_work, 3
  86. myInStr_cnt = cnt
  87. Repeat 3
  88. Poke myInStr_work, cnt, Peek (myInStr_haystack, myInStr_cnt * 3 + cnt)
  89. Loop
  90. If myInStr_work = p_needle {
  91. myInStr_flag = False
  92. Break
  93. }
  94. Loop
  95. If myInStr_flag {
  96. Return -1
  97. }
  98. Return myInStr_cnt * 3
  99. #defcfunc local \
  100. MyStrMid \
  101. str p_string,\
  102. int p_offset,\
  103. int p_length,\
  104. int p_test
  105. myStrMid_string = p_string
  106. SDim myStrMid_return, p_length
  107. Return myStrMid_return
  108. #global
  109. #endif ; not __CHAR__