summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c5bd8da)
raw | patch | inline | side by side (parent: c5bd8da)
author | fgsfds <pvt.fgsfds@gmail.com> | |
Fri, 9 Feb 2018 14:37:36 +0000 (17:37 +0300) | ||
committer | fgsfds <pvt.fgsfds@gmail.com> | |
Fri, 9 Feb 2018 14:37:36 +0000 (17:37 +0300) |
src/engine/e_graphics.pas | patch | blob | history | |
src/game/g_basic.pas | patch | blob | history | |
src/game/g_game.pas | patch | blob | history |
index 47e69d602a1cec3e3a93ba2e13a8d7bc32d449ed..bb805dab58b530d8e855bdabc7eebbf44144a7a5 100644 (file)
procedure e_CharFont_GetSizeFmt(FontID: DWORD; Text: string; var w, h: Word);
var
a, lines, len: Integer;
- h2, w2: Word;
+ h2, w2, tw, th: Word;
begin
w2 := 0;
- w := 0;
- h := 0;
+ h2 := 0;
+ tw := 0;
+ th := 0;
if Text = '' then Exit;
if e_CharFonts = nil then Exit;
if Text[a] = #10 then
begin
Inc(lines);
- if w2 > w then
- begin
- w := w2;
- w2 := 0;
- end;
- continue;
- end
- else if Text[a] in [#1, #2, #3, #4, #18, #19, #20, #21] then
+ if w2 > tw then tw := w2;
+ w2 := 0;
continue;
+ end;
with Chars[Ord(Text[a])] do
- if TextureID <> -1 then
- begin
- w2 := w2 + Width + IfThen(a = len, 0, Space);
- e_GetTextureSize(TextureID, nil, @h2);
- if h2 > h then h := h2;
- end;
+ if TextureID <> -1 then
+ begin
+ w2 := w2 + Width + IfThen(a = len, 0, Space);
+ e_GetTextureSize(TextureID, nil, @h2);
+ if h2 > th then th := h2;
+ end;
end;
end;
- if w2 > w then
- w := w2;
- h := h * lines;
+ if w2 > tw then
+ tw := w2;
+
+ w := tw;
+ h := th * lines;
end;
function e_CharFont_GetMaxWidth(FontID: DWORD): Word;
diff --git a/src/game/g_basic.pas b/src/game/g_basic.pas
index eba4094cb147133a49a42269fc4da56cb5b63287..e5ef3d9c28acdff92c10e22ddf19ef8beb635e92 100644 (file)
--- a/src/game/g_basic.pas
+++ b/src/game/g_basic.pas
procedure SortSArray(var S: SSArray);
function b_Text_Format(S: string): string;
function b_Text_Unformat(S: string): string;
-
+function b_Text_Wrap(S: string; LineLen: Integer): string;
var
gmon_dbg_los_enabled: Boolean = true;
end;
end;
+function b_Text_Wrap(S: string; LineLen: Integer): string;
+begin
+ Result := WrapText(S, ''#10, [#10, ' ', '-'], LineLen);
+end;
+
end.
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 918a94714df9f810469a5204a8e83d817fac5074..345f11232604bd161208a4f3f0d92e32b7c75982 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
EndingGameCounter: Byte = 0;
MessageText: String;
MessageTime: Word;
+ MessageLineLength: Integer = 80;
MapList: SSArray = nil;
MapIndex: Integer = -1;
MegaWAD: record
procedure g_Game_Message(Msg: string; Time: Word);
begin
- MessageText := b_Text_Format(Msg);
+ MessageLineLength := (gScreenWidth - 204) div e_CharFont_GetMaxWidth(gMenuFont);
+ MessageText := b_Text_Wrap(b_Text_Format(Msg), MessageLineLength);
MessageTime := Time;
end;