{PUBLIC_VARS TexID: integer; VisLine: string; Power: boolean; DebugInput: string; StopRequest: single; } {PUBLIC_BUTTONS DEBUG; } const MAXLINELENGTH_PX = 1184; INTERVAL_S = 4; LINES_HIGH = 2; var NotFirstRun: boolean; Fulltext: string; Lines: array[0..LINES_HIGH] of string; Font: integer; Timer: single; CurrLine: integer; PIS_StopSeq: integer; PIS_StopIndex: integer; PIS_RouteIndex: integer; procedure Initialize; begin Power := true; Font := TexGetFontIndex(Self, 740067, 514400464); PIS_StopSeq := -1; PIS_StopIndex := -1; PIS_RouteIndex := -1; end; procedure RefreshVisibleLine; begin VisLine := Lines[CurrLine]; end; procedure SimStep; begin if not NotFirstRun then begin SendBroadcastInteger(Self, 'DISPLAY_SLAVE_TEX_ID', 'STOP', TexID); NotFirstRun := true; end; Timer := Timer - Timegap; if Timer < 0 then begin inc(CurrLine); if (CurrLine > LINES_HIGH) then CurrLine := 0; if (Lines[CurrLine] = '') then CurrLine := 0; Timer := INTERVAL_S; RefreshVisibleLine; end; end; function CheckLen(str: string): boolean; begin result := (TexGetTextLenPixel(Self, str, Font) <= MAXLINELENGTH_PX); end; procedure Refresh; var i: integer; line: string; lineindex: integer; chara: char; begin for lineindex := 0 to LINES_HIGH do Lines[lineindex] := ''; if CheckLen(Fulltext) then Lines[0] := Fulltext else begin lineindex := 0; line := ''; for i := 1 to Length(Fulltext) do begin chara := Fulltext[i]; line := line + chara; if (chara = '/') or (chara = ' ') or (chara = '-') or (chara = '+') or (i = Length(Fulltext)) then begin if not CheckLen(Lines[lineindex] + line) then begin if (Lines[lineindex] <> '') then begin lineindex := lineindex + 1; if lineindex > LINES_HIGH then break; end; end; Lines[lineindex] := Lines[lineindex] + line; line := ''; end; end; end; CurrLine := 0; Timer := INTERVAL_S; RefreshVisibleLine; end; procedure CheckRefresh; var newtext: string; begin begin if PIS_StopIndex > 0 then newtext := PIS_GetStationStdString(Self, PIS_StopIndex, 0) else newtext := ''; end; if newtext <> Fulltext then begin Fulltext := newtext; Refresh; end; end; procedure ReceiveBroadcastInteger(busId: string; id: string; value: integer); var stopcode: integer; begin if busId <> 'PIS' then exit; if id = 'STOP_SEQ' then begin PIS_StopSeq := value; stopcode := PIS_GetRouteStopCode(Self, PIS_RouteIndex, PIS_StopSeq); PIS_StopIndex := PIS_GetStationMainListIndexByTerminusCode(Self, stopcode); CheckRefresh; end else if id = 'ROUTE_LISTINDEX' then begin PIS_RouteIndex := value; end; end; procedure ReceiveBroadcastSingle(busId: string; id: string; value: single); var newtext: string; begin if busId <> 'GEN' then exit; if id = 'STOPREQUEST' then StopRequest := value; end; procedure OnButton(id: string; value: boolean; cockpitIndex: byte); begin if value then begin if (id = 'DEBUG') then begin Fulltext := DebugInput; Refresh; end; end; end; end.