hedgewars/uCommandHandlers.pas
changeset 14681 bd43e703608b
parent 14680 d74517fdb34f
child 14749 533ac9774279
equal deleted inserted replaced
14680:d74517fdb34f 14681:bd43e703608b
    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 
       
    36 // helper function for volume
       
    37 procedure updateVolumeDelta(precise: boolean);
       
    38 begin
       
    39 if cVolumeUpKey and (not cVolumeDownKey) then
       
    40     if precise then
       
    41         cVolumeDelta:= 1
       
    42     else
       
    43         cVolumeDelta:= 3
       
    44 else if cVolumeDownKey and (not cVolumeUpKey) then
       
    45     if precise then
       
    46         cVolumeDelta:= -1
       
    47     else
       
    48         cVolumeDelta:= -3
       
    49 else
       
    50     cVolumeDelta:= 0;
       
    51 end;
       
    52 
    36 procedure chGenCmd(var s: shortstring);
    53 procedure chGenCmd(var s: shortstring);
    37 begin
    54 begin
    38 case s[1] of
    55 case s[1] of
    39     'R': if ReadyTimeLeft > 0 then
    56     'R': if ReadyTimeLeft > 0 then
    40         begin
    57         begin
   275 end;
   292 end;
   276 
   293 
   277 procedure chPrecise_p(var s: shortstring);
   294 procedure chPrecise_p(var s: shortstring);
   278 begin
   295 begin
   279 s:= s; // avoid compiler hint
   296 s:= s; // avoid compiler hint
       
   297 updateVolumeDelta(true);
   280 if CheckNoTeamOrHH then
   298 if CheckNoTeamOrHH then
   281     exit;
   299     exit;
   282 if not isExternalSource then
   300 if not isExternalSource then
   283     SendIPC(_S'Z');
   301     SendIPC(_S'Z');
   284 bShowFinger:= false;
   302 bShowFinger:= false;
   285 with CurrentHedgehog^.Gear^ do
   303 with CurrentHedgehog^.Gear^ do
   286     Message:= Message or (gmPrecise and InputMask);
   304     Message:= Message or (gmPrecise and InputMask);
   287     ScriptCall('onPrecise');
   305     ScriptCall('onPrecise');
   288 if cVolumeDelta > 0 then
       
   289     cVolumeDelta:= 1;
       
   290 if cVolumeDelta < 0 then
       
   291     cVolumeDelta:= -1;
       
   292 end;
   306 end;
   293 
   307 
   294 procedure chPrecise_m(var s: shortstring);
   308 procedure chPrecise_m(var s: shortstring);
   295 begin
   309 begin
   296 s:= s; // avoid compiler hint
   310 s:= s; // avoid compiler hint
       
   311 updateVolumeDelta(false);
   297 if CheckNoTeamOrHH then
   312 if CheckNoTeamOrHH then
   298     exit;
   313     exit;
   299 if not isExternalSource then
   314 if not isExternalSource then
   300     SendIPC(_S'z');
   315     SendIPC(_S'z');
   301 with CurrentHedgehog^.Gear^ do
   316 with CurrentHedgehog^.Gear^ do
   302     Message:= Message and (not (gmPrecise and InputMask));
   317     Message:= Message and (not (gmPrecise and InputMask));
   303     ScriptCall('onPreciseUp');
   318     ScriptCall('onPreciseUp');
   304 if cVolumeDelta > 0 then
       
   305     cVolumeDelta:= 3;
       
   306 if cVolumeDelta < 0 then
       
   307     cVolumeDelta:= -3;
       
   308 end;
   319 end;
   309 
   320 
   310 procedure chLJump(var s: shortstring);
   321 procedure chLJump(var s: shortstring);
   311 begin
   322 begin
   312 s:= s; // avoid compiler hint
   323 s:= s; // avoid compiler hint
   598                 bShowAmmoMenu:= true
   609                 bShowAmmoMenu:= true
   599             end;
   610             end;
   600     end
   611     end
   601 end;
   612 end;
   602 
   613 
   603 procedure chVol_p(var s: shortstring);
   614 procedure chVolUp_p(var s: shortstring);
   604 begin
   615 begin
   605 s:= s; // avoid compiler hint
   616 s:= s; // avoid compiler hint
   606 if (LocalMessage and gmPrecise) <> 0 then
   617 cVolumeUpKey:= true;
   607     inc(cVolumeDelta, 1)
   618 updateVolumeDelta((LocalMessage and gmPrecise) <> 0);
   608 else
   619 end;
   609     inc(cVolumeDelta, 3);
   620 
   610 end;
   621 procedure chVolUp_m(var s: shortstring);
   611 
   622 begin
   612 procedure chVol_m(var s: shortstring);
   623 s:= s; // avoid compiler hint
   613 begin
   624 cVolumeUpKey:= false;
   614 s:= s; // avoid compiler hint
   625 updateVolumeDelta((LocalMessage and gmPrecise) <> 0);
   615 if (LocalMessage and gmPrecise) <> 0 then
   626 end;
   616     dec(cVolumeDelta, 1)
   627 
   617 else
   628 procedure chVolDown_p(var s: shortstring);
   618     dec(cVolumeDelta, 3);
   629 begin
       
   630 s:= s; // avoid compiler hint
       
   631 cVolumeDownKey:= true;
       
   632 updateVolumeDelta((LocalMessage and gmPrecise) <> 0);
       
   633 end;
       
   634 
       
   635 procedure chVolDown_m(var s: shortstring);
       
   636 begin
       
   637 s:= s; // avoid compiler hint
       
   638 cVolumeDownKey:= false;
       
   639 updateVolumeDelta((LocalMessage and gmPrecise) <> 0);
   619 end;
   640 end;
   620 
   641 
   621 procedure chMute(var s: shortstring);
   642 procedure chMute(var s: shortstring);
   622 begin
   643 begin
   623 s:= s; // avoid compiler hint
   644 s:= s; // avoid compiler hint
   986     RegisterVariable('-precise', @chPrecise_m    , false, true);
  1007     RegisterVariable('-precise', @chPrecise_m    , false, true);
   987     RegisterVariable('switch'  , @chSwitch       , false);
  1008     RegisterVariable('switch'  , @chSwitch       , false);
   988     RegisterVariable('timer'   , @chTimer        , false, true);
  1009     RegisterVariable('timer'   , @chTimer        , false, true);
   989     RegisterVariable('taunt'   , @chTaunt        , false);
  1010     RegisterVariable('taunt'   , @chTaunt        , false);
   990     RegisterVariable('put'     , @chPut          , false);
  1011     RegisterVariable('put'     , @chPut          , false);
   991     RegisterVariable('+volup'  , @chVol_p        , true );
  1012     RegisterVariable('+volup'  , @chVolUp_p      , true );
   992     RegisterVariable('-volup'  , @chVol_m        , true );
  1013     RegisterVariable('-volup'  , @chVolUp_m      , true );
   993     RegisterVariable('+voldown', @chVol_m        , true );
  1014     RegisterVariable('+voldown', @chVolDown_p    , true );
   994     RegisterVariable('-voldown', @chVol_p        , true );
  1015     RegisterVariable('-voldown', @chVolDown_m    , true );
   995     RegisterVariable('mute'    , @chMute         , true );
  1016     RegisterVariable('mute'    , @chMute         , true );
   996     RegisterVariable('findhh'  , @chFindhh       , true );
  1017     RegisterVariable('findhh'  , @chFindhh       , true );
   997     RegisterVariable('pause'   , @chPause        , true );
  1018     RegisterVariable('pause'   , @chPause        , true );
   998     RegisterVariable('+cur_u'  , @chCurU_p       , true );
  1019     RegisterVariable('+cur_u'  , @chCurU_p       , true );
   999     RegisterVariable('-cur_u'  , @chCurU_m       , true );
  1020     RegisterVariable('-cur_u'  , @chCurU_m       , true );