hedgewars/uCommandHandlers.pas
changeset 15908 014f4edd0421
parent 15897 d7b53d08ad9c
equal deleted inserted replaced
15907:a323e1954a6f 15908:014f4edd0421
    25 procedure initModule;
    25 procedure initModule;
    26 procedure freeModule;
    26 procedure freeModule;
    27 
    27 
    28 implementation
    28 implementation
    29 uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uWorld, uRandom, uCaptions
    29 uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uWorld, uRandom, uCaptions
    30     , uVisualGearsList, uGearsHedgehog
    30     , uVisualGearsList, uGearsHedgehog, uDrawing
    31      {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF};
    31      {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF};
    32 
    32 
    33 var cTagsMasks : array[0..15] of byte = (7, 0, 0, 0, 0, 4, 5, 6, 15, 8, 8, 8, 8, 12, 13, 14);
    33 var cTagsMasks : array[0..15] of byte = (7, 0, 0, 0, 0, 4, 5, 6, 15, 8, 8, 8, 8, 12, 13, 14);
    34     cTagsMasksNoHealth: array[0..15] of byte = (3, 0, 1, 2, 0, 0, 0, 0, 11, 8, 9, 10, 8, 8, 8, 8);
    34     cTagsMasksNoHealth: array[0..15] of byte = (3, 0, 1, 2, 0, 0, 0, 0, 11, 8, 9, 10, 8, 8, 8, 8);
    35 
    35 
   512     SendIPC('t' + s);
   512     SendIPC('t' + s);
   513 
   513 
   514 PlayTaunt(byte(s[1]))
   514 PlayTaunt(byte(s[1]))
   515 end;
   515 end;
   516 
   516 
   517 procedure chPut(var s: shortstring);
   517 procedure chPut_p(var s: shortstring);
   518 begin
   518 begin
   519     s:= s; // avoid compiler hint
   519     s:= s; // avoid compiler hint
   520     doPut(0, 0, false);
   520     if uDrawing.isDrawingModeActive() then
       
   521        uDrawing.onLeftMouseButtonPressed()
       
   522     else
       
   523        doPut(0, 0, false, false);
       
   524 end;
       
   525 
       
   526 procedure chPut_m(var s: shortstring);
       
   527 begin
       
   528     s:= s; // avoid compiler hint
       
   529     if uDrawing.isDrawingModeActive() then
       
   530        uDrawing.onLeftMouseButtonReleased()
   521 end;
   531 end;
   522 
   532 
   523 procedure chCapture(var s: shortstring);
   533 procedure chCapture(var s: shortstring);
   524 begin
   534 begin
   525 s:= s; // avoid compiler hint
   535 s:= s; // avoid compiler hint
   573 end;
   583 end;
   574 
   584 
   575 procedure chAmmoMenu(var s: shortstring);
   585 procedure chAmmoMenu(var s: shortstring);
   576 begin
   586 begin
   577 s:= s; // avoid compiler hint
   587 s:= s; // avoid compiler hint
       
   588 
       
   589 if uDrawing.isDrawingModeActive() then
       
   590 begin
       
   591    uDrawing.onRightMouseButtonPressed();
       
   592    exit;
       
   593 end;
       
   594 
   578 if CheckNoTeamOrHH then
   595 if CheckNoTeamOrHH then
   579     bShowAmmoMenu:= (not bShowAmmoMenu)
   596     bShowAmmoMenu:= (not bShowAmmoMenu)
   580 else
   597 else
   581     begin
   598     begin
   582     with CurrentTeam^ do
   599     with CurrentTeam^ do
   758 end;
   775 end;
   759 
   776 
   760 procedure chZoomReset(var s: shortstring);
   777 procedure chZoomReset(var s: shortstring);
   761 begin
   778 begin
   762     s:= s; // avoid compiler hint
   779     s:= s; // avoid compiler hint
       
   780     if uDrawing.isDrawingModeActive() then
       
   781     begin
       
   782        uDrawing.onMiddleMouseButtonPressed();
       
   783        exit;
       
   784     end;
   763     if (LocalMessage and gmPrecise <> 0) then
   785     if (LocalMessage and gmPrecise <> 0) then
   764         ZoomValue:= cDefaultZoomLevel
   786         ZoomValue:= cDefaultZoomLevel
   765     else
   787     else
   766         ZoomValue:= UserZoom;
   788         ZoomValue:= UserZoom;
   767 end;
   789 end;
   891     begin
   913     begin
   892         // update health bars and the wind indicator
   914         // update health bars and the wind indicator
   893         AddVisualGear(0, 0, vgtTeamHealthSorter);
   915         AddVisualGear(0, 0, vgtTeamHealthSorter);
   894         AddVisualGear(0, 0, vgtSmoothWindBar)
   916         AddVisualGear(0, 0, vgtSmoothWindBar)
   895     end
   917     end
       
   918 end;
       
   919 
       
   920 procedure chTeamDraw_p(var s: shortstring);
       
   921 begin
       
   922    s:= s;
       
   923    uDrawing.onModeButtonPressed();
       
   924 end;
       
   925 
       
   926 procedure chTeamDraw_m(var s: shortstring);
       
   927 begin
       
   928    s:= s;
       
   929    uDrawing.onModeButtonReleased();
   896 end;
   930 end;
   897 
   931 
   898 procedure chFastForward(var cmd: shortstring);
   932 procedure chFastForward(var cmd: shortstring);
   899 var str0, str1, str2 : shortstring;
   933 var str0, str1, str2 : shortstring;
   900     h, m, s : integer;
   934     h, m, s : integer;
  1000     RegisterVariable('nextturn', @chNextTurn     , false);
  1034     RegisterVariable('nextturn', @chNextTurn     , false);
  1001     RegisterVariable('-attack' , @chAttack_m     , false);
  1035     RegisterVariable('-attack' , @chAttack_m     , false);
  1002     RegisterVariable('slot'    , @chSlot         , false);
  1036     RegisterVariable('slot'    , @chSlot         , false);
  1003     RegisterVariable('setweap' , @chSetWeapon    , false, true);
  1037     RegisterVariable('setweap' , @chSetWeapon    , false, true);
  1004 //////// End top by freq analysis
  1038 //////// End top by freq analysis
       
  1039     RegisterVariable('+teamdraw', @chTeamDraw_p  , true);
       
  1040     RegisterVariable('-teamdraw', @chTeamDraw_m  , true);
  1005     RegisterVariable('gencmd'  , @chGenCmd       , false);
  1041     RegisterVariable('gencmd'  , @chGenCmd       , false);
  1006     RegisterVariable('script'  , @chScript       , false);
  1042     RegisterVariable('script'  , @chScript       , false);
  1007     RegisterVariable('scriptparam', @chScriptParam, false);
  1043     RegisterVariable('scriptparam', @chScriptParam, false);
  1008     RegisterVariable('proto'   , @chCheckProto   , true );
  1044     RegisterVariable('proto'   , @chCheckProto   , true );
  1009     RegisterVariable('spectate', @chFastUntilLag   , false);
  1045     RegisterVariable('spectate', @chFastUntilLag   , false);
  1051     RegisterVariable('+precise', @chPrecise_p    , false, true);
  1087     RegisterVariable('+precise', @chPrecise_p    , false, true);
  1052     RegisterVariable('-precise', @chPrecise_m    , false, true);
  1088     RegisterVariable('-precise', @chPrecise_m    , false, true);
  1053     RegisterVariable('switch'  , @chSwitch       , false);
  1089     RegisterVariable('switch'  , @chSwitch       , false);
  1054     RegisterVariable('timer'   , @chTimer        , false, true);
  1090     RegisterVariable('timer'   , @chTimer        , false, true);
  1055     RegisterVariable('taunt'   , @chTaunt        , false);
  1091     RegisterVariable('taunt'   , @chTaunt        , false);
  1056     RegisterVariable('put'     , @chPut          , false);
  1092     RegisterVariable('+put'    , @chPut_p        , true);
       
  1093     RegisterVariable('-put'    , @chPut_m        , true);
  1057     RegisterVariable('+volup'  , @chVolUp_p      , true );
  1094     RegisterVariable('+volup'  , @chVolUp_p      , true );
  1058     RegisterVariable('-volup'  , @chVolUp_m      , true );
  1095     RegisterVariable('-volup'  , @chVolUp_m      , true );
  1059     RegisterVariable('+voldown', @chVolDown_p    , true );
  1096     RegisterVariable('+voldown', @chVolDown_p    , true );
  1060     RegisterVariable('-voldown', @chVolDown_m    , true );
  1097     RegisterVariable('-voldown', @chVolDown_m    , true );
  1061     RegisterVariable('mute'    , @chMute         , true );
  1098     RegisterVariable('mute'    , @chMute         , true );