Browse Source

#defcfunc の中では,ほかの #defcfunc で宣言された関数を利用できなぃらしぃ.

main
Miteruzo 1 year ago
parent
commit
f148df36ed
4 changed files with 81 additions and 126 deletions
  1. +1
    -90
      assets/dict.dat
  2. +6
    -4
      main.hsp
  3. +57
    -19
      modules/char.mod.hsp
  4. +17
    -13
      modules/keyboard.mod.hsp

+ 1
- 90
assets/dict.dat View File

@@ -1,90 +1 @@
あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもや(ゆ)よらりるれろわゐーゑをん!?・…がぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽぁぃぅぇぉゃ,ゅ.ょ

+ 6
- 4
main.hsp View File

@@ -43,6 +43,8 @@
ChDir "assets" ChDir "assets"
#endif ; not _DEBUG #endif ; not _DEBUG


Font MSGOTHIC, 96

ViewCalc VPTYPE_2D, Double (gInfo_winX) / DISPLAY_WIDTH, Double (gInfo_winY) / DISPLAY_HEIGHT ViewCalc VPTYPE_2D, Double (gInfo_winX) / DISPLAY_WIDTH, Double (gInfo_winY) / DISPLAY_HEIGHT


; 背景 ; 背景
@@ -87,10 +89,7 @@
Show@Keyboard Show@Keyboard


Pos 100, 100 Pos 100, 100
NoteSel test
NoteLoad "test.txt"
NoteUnsel
Text = New@Char (test)
Text = New@Char ("")
size@Char.Text = 240 size@Char.Text = 240


Repeat Repeat
@@ -101,6 +100,9 @@
Draw@Goatoh Goatoh Draw@Goatoh Goatoh
Draw@Char Draw@Char
Draw@Keyboard Draw@Keyboard

a = GetChar@Keyboard ()
text@Char.Text = text@Keyboard
ReDraw True ReDraw True


Await LOOP_INTERVAL Await LOOP_INTERVAL


+ 57
- 19
modules/char.mod.hsp View File

@@ -8,9 +8,10 @@ Char
New \ New \
str p_text str p_text
If insNum <= 0 { If insNum <= 0 {
NoteSel charDict
NoteLoad "dict.dat"
NoteUnsel
SDim charDict, 384
SDim text, 1024

BLoad "dict.dat", charDict
} }


text.insNum = p_text text.insNum = p_text
@@ -34,31 +35,68 @@ Destroy \


#deffunc local \ #deffunc local \
Draw \ Draw \
local cnt_,\
local found,\
local zoom
local l_cnt,\
local l_found
Repeat insNum Repeat insNum
If exists.cnt { If exists.cnt {
cnt_ = cnt

NoteSel charDict
Repeat StrLen (text.cnt_) / 3
Pos posX.cnt_ + cnt * size.cnt_, posY.cnt_
l_cnt = cnt


found = NoteFind (StrMid (text.cnt_, cnt * 3, 3))
Repeat StrLen (text.l_cnt) / 3
l_found = MyInStr (charDict, 0, StrMid (text.l_cnt, cnt * 3, 3)) / 3


If found = -1 {
found = UNKNOWN
}
If darw_found < 0 {
l_found = UNKNOWN
}


zoom = Double (size.cnt_) / CHAR_WIDTH
CelPut BUFFER_CHAR, found, zoom, zoom
Loop
NoteUnsel
Pos posX.l_cnt + cnt * size.l_cnt, posY.l_cnt
l_zoom = Double (size.l_cnt) / CHAR_WIDTH
CelPut BUFFER_CHAR, l_found, l_zoom, l_zoom
Loop
} }
Loop Loop


Return Return


#defcfunc local \
MyInStr \
str p_haystack,\
int p_offset,\
str p_needle
myInStr_haystack = p_haystack

myInStr_flag = True

Repeat StrLen (myInStr_haystack) / 3
SDim myInStr_work, 3
myInStr_cnt = cnt
Repeat 3
Poke myInStr_work, cnt, Peek (myInStr_haystack, myInStr_cnt * 3 + cnt)
Loop

If myInStr_work = p_needle {
myInStr_flag = False

Break
}
Loop

If myInStr_flag {
Return -1
}

Return myInStr_cnt * 3

#defcfunc local \
MyStrMid \
str p_string,\
int p_offset,\
int p_length,\
int p_test
myStrMid_string = p_string

SDim myStrMid_return, p_length

Return myStrMid_return

#global #global



+ 17
- 13
modules/keyboard.mod.hsp View File

@@ -15,33 +15,37 @@ Hide
Return Return


#defcfunc local \ #defcfunc local \
GetChar \
local l_ids,\
local l_touchInfo,\
local l_charId,\
local l_char
GetChar
if showing = False { if showing = False {
Return "" Return ""
} }


MTList l_id
MTList getChar_id


If stat = 0 { If stat = 0 {
touching = False

Return ""
}

If touching {
Return "" Return ""
} }


MTInfo l_touchInfo, l_id.0
MTInfo getChar_touchInfo, getChar_id.0


If l_touchInfo.2 < 1920 - 480 {
If getChar_touchInfo.2 < 1920 - 480 {
Return "" Return ""
} }


l_charId = (1080 - l_touchInfo.1) / 96 * 5 + (l_touchInfo.2 - (1920 - 480)) / 96
getChar_charId = (1080 - getChar_touchInfo.1) / 96 * 5 + (getChar_touchInfo.2 - (1920 - 480)) / 96
getChar_textLength = StrLen (text)

Repeat 3
Poke text, getChar_textLength + cnt, Peek (charDict@Char, getChar_charId * 3 + cnt)
Loop


NoteSel charDict@Char
NoteGet l_char, l_charId
text += l_char
NoteUnsel
touching = True


Return "" Return ""




Loading…
Cancel
Save