hedgewars/uConsole.pas
changeset 108 08f1fe6f21f8
parent 107 b08ce0293a51
child 161 d8870bbf960e
equal deleted inserted replaced
107:b08ce0293a51 108:08f1fe6f21f8
    34 unit uConsole;
    34 unit uConsole;
    35 interface
    35 interface
    36 uses SDLh;
    36 uses SDLh;
    37 {$INCLUDE options.inc}
    37 {$INCLUDE options.inc}
    38 const isDeveloperMode: boolean = true;
    38 const isDeveloperMode: boolean = true;
    39 type TVariableType = (vtCommand, vtInteger, vtReal, vtBoolean);
    39 type TVariableType = (vtCommand, vtInteger, vtDouble, vtBoolean);
    40      TCommandHandler = procedure (var params: shortstring);
    40      TCommandHandler = procedure (var params: shortstring);
    41 
    41 
    42 procedure DrawConsole(Surface: PSDL_Surface);
    42 procedure DrawConsole(Surface: PSDL_Surface);
    43 procedure WriteToConsole(s: shortstring);
    43 procedure WriteToConsole(s: shortstring);
    44 procedure WriteLnToConsole(s: shortstring);
    44 procedure WriteLnToConsole(s: shortstring);
   161 if cLineWidth > 255 then cLineWidth:= 255;
   161 if cLineWidth > 255 then cLineWidth:= 255;
   162 for i:= 0 to Pred(cLinesCount) do PLongWord(@ConsoleLines[i])^:= 0
   162 for i:= 0 to Pred(cLinesCount) do PLongWord(@ConsoleLines[i])^:= 0
   163 end;
   163 end;
   164 
   164 
   165 procedure ParseCommand(CmdStr: shortstring);
   165 procedure ParseCommand(CmdStr: shortstring);
   166 type PReal = ^Double;
   166 type PDouble = ^Double;
   167 var i, ii: integer;
   167 var i, ii: integer;
   168     s: shortstring;
   168     s: shortstring;
   169     t: PVariable;
   169     t: PVariable;
   170     c: char;
   170     c: char;
   171 begin
   171 begin
   189                          if s[0]=#0 then
   189                          if s[0]=#0 then
   190                             begin
   190                             begin
   191                             str(PInteger(t.Handler)^, s);
   191                             str(PInteger(t.Handler)^, s);
   192                             WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
   192                             WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
   193                             end else val(s, PInteger(t.Handler)^, i);
   193                             end else val(s, PInteger(t.Handler)^, i);
   194                  vtReal: if c='$' then
   194                  vtDouble: if c='$' then
   195                          if s[0]=#0 then
   195                          if s[0]=#0 then
   196                             begin
   196                             begin
   197                             str(PReal(t.Handler)^:4:6, s);
   197                             str(PDouble(t.Handler)^:4:6, s);
   198                             WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
   198                             WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
   199                             end else val(s, PReal(t.Handler)^   , i);
   199                             end else val(s, PDouble(t.Handler)^   , i);
   200              vtBoolean: if c='$' then
   200              vtBoolean: if c='$' then
   201                          if s[0]=#0 then
   201                          if s[0]=#0 then
   202                             begin
   202                             begin
   203                             str(ord(boolean(t.Handler^)), s);
   203                             str(ord(boolean(t.Handler^)), s);
   204                             WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
   204                             WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');