Skip to content

Commit

Permalink
add an "Always Run" switch to the Control menu
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
fabiangreffrath committed Aug 12, 2020
1 parent 4e65cce commit 2d92b93
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 7 deletions.
4 changes: 2 additions & 2 deletions wl_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void ControlMovement (objtype *ob)
angle = ob->angle + ANGLES/4;
if(angle >= ANGLES)
angle -= ANGLES;
if(buttonstate[bt_run])
if(buttonstate[bt_run] ^ always_run) // [FG] toggle always run
Thrust(angle, RUNMOVE * MOVESCALE * tics);
else
Thrust(angle, BASEMOVE * MOVESCALE * tics);
Expand All @@ -171,7 +171,7 @@ void ControlMovement (objtype *ob)
angle = ob->angle - ANGLES/4;
if(angle < 0)
angle += ANGLES;
if(buttonstate[bt_run])
if(buttonstate[bt_run] ^ always_run) // [FG] toggle always run
Thrust(angle, RUNMOVE * MOVESCALE * tics );
else
Thrust(angle, BASEMOVE * MOVESCALE * tics);
Expand Down
1 change: 1 addition & 0 deletions wl_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@ extern longword param_samplerate;
extern int param_audiobuffer;
extern int param_mission;
extern boolean param_ignorenumchunks;
extern boolean always_run;


void NewGame (int difficulty,int episode);
Expand Down
13 changes: 13 additions & 0 deletions wl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ int param_audiobuffer = 2048 / (44100 / param_samplerate);

int param_mission = 0;
boolean param_ignorenumchunks = false;
boolean always_run = false;

/*
=============================================================================
Expand Down Expand Up @@ -165,6 +166,12 @@ void ReadConfig(void)
mouseadjustment_v = mouseadjustment;
}

// [FG] toggle always run
if (read(file,&always_run,sizeof(always_run))<0)
{
always_run = false;
}

close(file);
#undef read2

Expand Down Expand Up @@ -196,6 +203,8 @@ void ReadConfig(void)
if(viewsize<4) viewsize=4;
else if(viewsize>21) viewsize=21;

always_run = !!always_run;

MainMenu[6].active=1;
MainItems.curpos=0;
}
Expand Down Expand Up @@ -229,6 +238,7 @@ void ReadConfig(void)

viewsize = 19; // start with a good size
mouseadjustment_v=mouseadjustment=5;
always_run = false;
}

SD_SetMusicMode (sm);
Expand Down Expand Up @@ -285,6 +295,9 @@ void WriteConfig(void)
// [FG] vertical mouse sensitivity
write2(file,&mouseadjustment_v,sizeof(mouseadjustment_v));

// [FG] toggle always run
write2(file,&always_run,sizeof(always_run));

close(file);
}
#undef write2
Expand Down
20 changes: 18 additions & 2 deletions wl_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ CP_itemtype SndMenu[] = {
{1, STR_ALSB, 0}
};

enum { CTL_MOUSEENABLE, CTL_MOUSESENS, CTL_JOYENABLE, CTL_CUSTOMIZE };
enum { CTL_MOUSEENABLE, CTL_MOUSESENS, CTL_JOYENABLE, CTL_CUSTOMIZE, CTL_ALWAYSRUN }; // [FG] toggle always run

CP_itemtype CtlMenu[] = {
{0, STR_MOUSEEN, 0},
{0, STR_SENS, MouseSensitivity},
{0, STR_JOYEN, 0},
{1, STR_CUSTOM, CustomControls}
{1, STR_CUSTOM, CustomControls},
{1, "Always Run", 0} // [FG] toggle always run
};

#ifndef SPEAR
Expand Down Expand Up @@ -1648,6 +1649,14 @@ CP_Control (int)
MenuFadeIn ();
WaitKeyUp ();
break;

// [FG] toggle always run
case CTL_ALWAYSRUN:
always_run ^= 1;
DrawCtlScreen ();
CusItems.curpos = -1;
ShootSnd ();
break;
}
}
while (which >= 0);
Expand Down Expand Up @@ -1880,6 +1889,13 @@ DrawCtlScreen (void)
else
VWB_DrawPic (x, y, C_NOTSELECTEDPIC);

// [FG] toggle always run
y = CTL_Y + 55;
if (always_run)
VWB_DrawPic (x, y, C_SELECTEDPIC);
else
VWB_DrawPic (x, y, C_NOTSELECTEDPIC);

//
// PICK FIRST AVAILABLE SPOT
//
Expand Down
2 changes: 1 addition & 1 deletion wl_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#define CTL_X 24
#define CTL_Y 86
#define CTL_W 284
#define CTL_H 60
#define CTL_H (60+13) // [FG] toggle always run

#define LSM_X 85
#define LSM_Y 55
Expand Down
4 changes: 2 additions & 2 deletions wl_play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void PollJoystickButtons (void)

void PollKeyboardMove (void)
{
int delta = buttonstate[bt_run] ? RUNMOVE * tics : BASEMOVE * tics;
int delta = (buttonstate[bt_run] ^ always_run) ? RUNMOVE * tics : BASEMOVE * tics; // [FG] toggle always run

if (Keyboard[dirscan[di_north]])
controly -= delta;
Expand Down Expand Up @@ -358,7 +358,7 @@ void PollJoystickMove (void)

IN_GetJoyDelta (&joyx, &joyy);

int delta = buttonstate[bt_run] ? RUNMOVE * tics : BASEMOVE * tics;
int delta = (buttonstate[bt_run] ^ always_run) ? RUNMOVE * tics : BASEMOVE * tics; // [FG] toggle always run

if (joyx > 64 || buttonstate[bt_turnright])
controlx += delta;
Expand Down

0 comments on commit 2d92b93

Please sign in to comment.