字幕指令,用法同新对话指令
^^改变文字颜色
## 延时
**换行
@@等待击键
&&显示姓名
%%显示名
$$显示姓- procedure ShowTitle(talknum, color: integer);
- var
- newcolor, alen, x1, y1, ch, color1, color2, c1, r1, n, namelen, i, t1, grp, idx, offset, len, i1, i2, face, c, x, y, w, h, cell, row: integer;
- np3, np1, np2, tp, p1, ap: pchar;
- actorarray, name1, name2, talkarray: array of byte;
- pword: array[0..1] of Uint16;
- wd, str: string;
- temp2: widestring;
- begin
- pword[1] := 0;
- color1 := color and $FF;
- color2 := (color shr 8) and $FF;
- x := 0;
- y := 30;
- w := 640;
- h := 109;
- row := 5;
- cell := 25;
- //read talk
- idx := fileopen('\resource\TALK.IDX', fmopenread);
- grp := fileopen('\resource\TALK.GRP', fmopenread);
- if talknum = 0 then
- begin
- offset := 0;
- fileread(idx, len, 4);
- end
- else
- begin
- fileseek(idx, (talknum - 1) * 4, 0);
- fileread(idx, offset, 4);
- fileread(idx, len, 4);
- end;
- len := (len - offset);
- setlength(talkarray, len + 1);
- fileseek(grp, offset, 0);
- fileread(grp, talkarray[0], len);
- fileclose(idx);
- fileclose(grp);
- for i := 0 to len - 1 do
- begin
- talkarray[ i ] := talkarray[ i ] xor $FF;
- if (talkarray[ i ] = $FF) then
- talkarray[ i ] := 0;
- end;
- talkarray[len] := byte(0);
- tp := @talkarray[0];
- if length(tp) > cell * 2 then
- begin
- x1 := 300 - cell * 10;
- end
- else x1 := 300 - length(tp) * 5;
- if ((length(tp) div 2) > cell * row) then
- begin
- y1 := y + (h div 2) - 50
- end
- else y1 := y + (h div 2) - 10 - ((length(tp) div 2) div cell) * 10;
- p1 := @Rrole[0].Name;
- alen := length(p1) + 2;
- setlength(actorarray, alen);
- ap := @actorarray[0];
- for n := 0 to alen - 1 do
- begin
- (ap + n)^ := (p1 + n)^;
- if (p1 + n)^ = char(0) then break;
- end;
- (ap + n)^ := char($0);
- (ap + n + 1)^ := char(0);
- if alen = 6 then
- begin
- setlength(name1, 4);
- np1 := @name1[0];
- np1^ := ap^;
- (np1 + 1)^ := (ap + 1)^;
- (np1 + 2)^ := char(0);
- (np1 + 3)^ := char(0);
- setlength(name2, 4);
- np2 := @name2[0];
- np2^ := ap^;
- for i := 0 to length(name2) - 1 do
- (np2 + i)^ := (ap + i + 2)^;
- end
- else if alen > 8 then
- begin
- setlength(name1, 6);
- np1 := @name1[0];
- np1^ := ap^;
- (np1 + 1)^ := (ap + 1)^;
- (np1 + 2)^ := (ap + 2)^;
- (np1 + 3)^ := (ap + 3)^;
- (np1 + 4)^ := char(0);
- (np1 + 5)^ := char(0);
- setlength(name2, 6);
- np2 := @name2[0];
- for i := 0 to length(name2) - 1 do
- (np2 + i)^ := (ap + i + 4)^;
- end
- else if alen = 8 then
- begin
- if ((puint16(ap)^ = $6EAB) and ((puint16(ap + 2)^ = $63AE))) or
- ((puint16(ap)^ = $E8A6) and ((puint16(ap + 2)^ = $F9AA))) or
- ((puint16(ap)^ = $46AA) and ((puint16(ap + 2)^ = $E8A4))) or
- ((puint16(ap)^ = $4FA5) and ((puint16(ap + 2)^ = $B0AA))) or
- ((puint16(ap)^ = $7DBC) and ((puint16(ap + 2)^ = $65AE))) or
- ((puint16(ap)^ = $71A5) and ((puint16(ap + 2)^ = $A8B0))) or
- ((puint16(ap)^ = $D1BD) and ((puint16(ap + 2)^ = $AFB8))) or
- ((puint16(ap)^ = $71A5) and ((puint16(ap + 2)^ = $C5AA))) or
- ((puint16(ap)^ = $D3A4) and ((puint16(ap + 2)^ = $76A5))) or
- ((puint16(ap)^ = $BDA4) and ((puint16(ap + 2)^ = $5DAE))) or
- ((puint16(ap)^ = $DABC) and ((puint16(ap + 2)^ = $A7B6))) or
- ((puint16(ap)^ = $43AD) and ((puint16(ap + 2)^ = $DFAB))) or
- ((puint16(ap)^ = $71A5) and ((puint16(ap + 2)^ = $7BAE))) or
- ((puint16(ap)^ = $B9A7) and ((puint16(ap + 2)^ = $43C3))) or
- ((puint16(ap)^ = $61B0) and ((puint16(ap + 2)^ = $D5C1))) or
- ((puint16(ap)^ = $74A6) and ((puint16(ap + 2)^ = $E5A4))) or
- ((puint16(ap)^ = $DDA9) and ((puint16(ap + 2)^ = $5BB6))) then
- begin
- setlength(name1, 6);
- np1 := @name1[0];
- np1^ := ap^;
- (np1 + 1)^ := (ap + 1)^;
- (np1 + 2)^ := (ap + 2)^;
- (np1 + 3)^ := (ap + 3)^;
- (np1 + 4)^ := char(0);
- (np1 + 5)^ := char(0);
- setlength(name2, 4);
- np2 := @name2[0];
- for i := 0 to length(name2) - 1 do
- (np2 + i)^ := (ap + i + 4)^;
- end
- else
- begin
- setlength(name1, 4);
- np1 := @name1[0];
- np1^ := ap^;
- (np1 + 1)^ := (ap + 1)^;
- (np1 + 2)^ := char(0);
- (np1 + 3)^ := char(0);
- setlength(name2, 6);
- np2 := @name2[0];
- for i := 0 to length(name2) - 1 do
- (np2 + i)^ := (ap + i + 2)^;
- end;
- end;
- temp2 := big5tounicode(tp);
- str := unicodetobig5(@temp2[1]);
- setlength(wd, 0);
- i := 0;
- while i < length(str) do
- begin
- setlength(wd, length(wd) + 1);
- wd[length(wd) - 1] := str[ i ];
- if (integer(str[ i ]) in [$81..$FE]) and (integer(str[i + 1]) <> $7E) then
- begin
- setlength(wd, length(wd) + 1);
- wd[length(wd) - 1] := str[i + 1];
- wd[length(wd) - 2] := str[ i ];
- inc(i, 2);
- continue
- end;
- if (str[ i ] = #$0D) and (str[i + 1] = #$0A) then
- begin
- setlength(wd, length(wd) + 1);
- wd[length(wd) - 1] := '*';
- wd[length(wd) - 2] := '*';
- inc(i, 2);
- continue;
- end;
- if (integer(str[ i ]) in [$20..$7F]) then
- begin
- if str[ i ] = '^' then
- begin
- if (integer(str[i + 1]) in [$30..$39]) or (str[i + 1] = '^') then
- begin
- setlength(wd, length(wd) + 1);
- wd[length(wd) - 1] := str[i + 1];
- inc(i, 2);
- continue;
- end;
- end
- else if (str[ i ] = '*') and (str[i + 1] = '*') then
- begin
- setlength(wd, length(wd) + 1);
- wd[length(wd) - 1] := str[i + 1];
- inc(i, 2);
- continue;
- end
- else if (str[ i ] = '&') and (str[i + 1] = '&') then
- begin
- setlength(wd, length(wd) + 1);
- wd[length(wd) - 1] := str[i + 1];
- inc(i, 2);
- continue;
- end
- else if (str[ i ] = '#') and (str[i + 1] = '#') then
- begin
- setlength(wd, length(wd) + 1);
- wd[length(wd) - 1] := str[i + 1];
- inc(i, 2);
- continue;
- end
- else if (str[ i ] = '@') and (str[i + 1] = '@') then
- begin
- setlength(wd, length(wd) + 1);
- wd[length(wd) - 1] := str[i + 1];
- inc(i, 2);
- continue;
- end
- else if (str[ i ] = '$') and (str[i + 1] = '$') then
- begin
- setlength(wd, length(wd) + 1);
- wd[length(wd) - 1] := str[i + 1];
- inc(i, 2);
- continue;
- end
- else if (str[ i ] = '%') and (str[i + 1] = '%') then
- begin
- setlength(wd, length(wd) + 1);
- wd[length(wd) - 1] := str[i + 1];
- inc(i, 2);
- continue;
- end;
- setlength(wd, length(wd) + 1);
- wd[length(wd) - 1] := char($A0 + (smallint(str[ i ]) - 32));
- wd[length(wd) - 2] := char($A3);
- end;
- inc(i);
- end;
- tp := @wd[3];
- ch := 0;
- while ((puint16(tp + ch))^ shl 8 <> 0) and ((puint16(tp + ch))^ shr 8 <> 0) do
- begin
- redraw;
- c1 := 0;
- r1 := 0;
- DrawRectangleWithoutFrame(x, y, w, h, 0, 40);
- while r1 < row do
- begin
- pword[0] := (puint16(tp + ch))^;
- if (pword[0] shr 8 <> 0) and (pword[0] shl 8 <> 0) then
- begin
- ch := ch + 2;
- if (pword[0] and $FF) = $5E then //^^改变文字颜色
- begin
- case smallint((pword[0] and $FF00) shr 8) - $30 of
- 0: newcolor := 28515;
- 1: newcolor := 28421;
- 2: newcolor := 28435;
- 3: newcolor := 28563;
- 4: newcolor := 28466;
- 5: newcolor := 28450;
- 64: newcolor := color;
- else newcolor := color;
- end;
- color1 := newcolor and $FF;
- color2 := (newcolor shr 8) and $FF;
- end
- else if pword[0] = $2323 then //## 延时
- begin
- sdl_delay(500);
- end
- else if pword[0] = $2A2A then //**换行
- begin
- if c1 > 0 then
- begin
- inc(r1);
- DrawRectangleWithoutFrame(x, y + h + 11 * (r1 - 1) + 1, w, 10, 0, 40);
- end;
- c1 := 0;
- end
- else if pword[0] = $4040 then //@@等待击键
- begin
- sdl_updaterect(screen, 0, 0, screen.w, screen.h);
- n := waitanykey;
- while (n = sdlk_up) or
- (n = sdlk_down) or
- (n = sdlk_right) or
- (n = sdlk_left) do
- n := waitanykey;
- end
- else if (pword[0] = $2626) or (pword[0] = $2525) or (pword[0] = $2424) then
- begin
- case pword[0] of
- $2626: np3 := ap; //&&显示姓名
- $2525: np3 := np2; //%%显示名
- $2424: np3 := np1; //$$显示姓
- end;
- i := 0;
- while (puint16(np3 + i)^ shr 8 <> 0) and (puint16(np3 + i)^ shl 8 <> 0) do
- begin
- pword[0] := puint16(np3 + i)^;
- i := i + 2;
- DrawBig5ShadowText(@pword[0], x1 + CHINESE_FONT_SIZE * c1, y1 + CHINESE_FONT_SIZE * r1, colcolor( color1), colcolor( color2));
- inc(c1);
- if c1 = cell then
- begin
- c1 := 0;
- inc(r1);
- DrawRectangleWithoutFrame(x, y + h + 11 * (r1 - 1) + 1, w, 10, 0, 40);
- if r1 = row then
- begin
- redraw;
- c1 := 0;
- r1 := 0;
- DrawRectangleWithoutFrame(x, y, w, h, 0, 40);
- end;
- end;
- end;
- end
- else //显示文字
- begin
- Drawbig5ShadowText(@pword, x1 + CHINESE_FONT_SIZE * c1, y1 + CHINESE_FONT_SIZE * r1, colcolor( color1), colcolor(color2));
- inc(c1);
- if c1 = cell then
- begin
- c1 := 0;
- inc(r1);
- DrawRectangleWithoutFrame(x, y + h + 11 * (r1 - 1) + 1, w, 10, 0, 40);
- end;
- end;
- end
- else break;
- end;
- sdl_updaterect(screen, 0, 0, screen.w, screen.h);
- n := waitanykey;
- while (n = sdlk_up) or
- (n = sdlk_down) or
- (n = sdlk_right) or
- (n = sdlk_left) do
- n := waitanykey;
- if (pword[0] and $FF = 0) or (pword[0] and $FF00 = 0) then break;
- end;
- redraw;
- //DrawBig5ShadowText(@pword, x1 + CHINESE_FONT_SIZE * c1, y1 + CHINESE_FONT_SIZE * r1, colcolor(0, color1), colcolor(0, color2));
- setlength(wd, 0);
- setlength(str, 0);
- setlength(temp2, 0);
- end;
复制代码
[ 本帖最后由 KG 于 2010-2-13 20:20 编辑 ] |