Skip to content

Commit

Permalink
Support enabling/disabling moving with mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
lazd committed Oct 20, 2018
1 parent 090c843 commit e54d932
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
1 change: 1 addition & 0 deletions foreign.h
Expand Up @@ -44,6 +44,7 @@
#define STR_SB "Sound Blaster"

#define STR_MOUSEEN "Mouse Enabled"
#define STR_MOVEWITHMOUSE "Move with mouse"
#define STR_JOYEN "Gamepad Enabled"
#define STR_PORT2 "Use joystick port 2"
#define STR_GAMEPAD "Gamepad Enabled"
Expand Down
2 changes: 1 addition & 1 deletion wl_def.h
Expand Up @@ -1040,7 +1040,7 @@ extern memptr demobuffer;
//
// control info
//
extern boolean mouseenabled,joystickenabled;
extern boolean mouseenabled,joystickenabled,movewithmouse;
extern int dirscan[4];
extern int buttonscan[NUMBUTTONS];
extern int buttonmouse[4];
Expand Down
6 changes: 6 additions & 0 deletions wl_main.cpp
Expand Up @@ -174,6 +174,7 @@ void ReadConfig(void)
read(file,&viewsize,sizeof(viewsize));
read(file,&mouseadjustment,sizeof(mouseadjustment));
read(file,&joyadjustment,sizeof(joyadjustment));
read(file,&movewithmouse,sizeof(movewithmouse));

close(file);

Expand All @@ -191,9 +192,13 @@ void ReadConfig(void)

if(mouseenabled) mouseenabled=true;
if(joystickenabled) joystickenabled=true;
if(movewithmouse) movewithmouse=true;

if (!MousePresent)
{
mouseenabled = false;
movewithmouse = false;
}
if (!IN_JoyPresent())
joystickenabled = false;

Expand Down Expand Up @@ -296,6 +301,7 @@ void WriteConfig(void)
write(file,&viewsize,sizeof(viewsize));
write(file,&mouseadjustment,sizeof(mouseadjustment));
write(file,&joyadjustment,sizeof(joyadjustment));
write(file,&movewithmouse,sizeof(movewithmouse));

close(file);
}
Expand Down
32 changes: 25 additions & 7 deletions wl_menu.cpp
Expand Up @@ -120,9 +120,9 @@ CP_itemtype SndMenu[] = {
};

#ifdef JAPAN
enum { CTL_MOUSEENABLE, CTL_JOYENABLE, CTL_JOY2BUTTONUNKNOWN, CTL_GAMEPADUNKONWN, CTL_MOUSESENS, CTL_JOYSENS, CTL_CUSTOMIZEKB, CTL_CUSTOMIZEJOY };
enum { CTL_MOUSEENABLE, CTL_MOVEWITHMOUSE, CTL_JOYENABLE, CTL_JOY2BUTTONUNKNOWN, CTL_GAMEPADUNKONWN, CTL_MOUSESENS, CTL_JOYSENS, CTL_CUSTOMIZEKB, CTL_CUSTOMIZEJOY };
#else
enum { CTL_MOUSEENABLE, CTL_MOUSESENS, CTL_JOYENABLE, CTL_JOYSENS, CTL_CUSTOMIZEKB, CTL_CUSTOMIZEJOY };
enum { CTL_MOUSEENABLE, CTL_MOVEWITHMOUSE, CTL_MOUSESENS, CTL_CUSTOMIZEKB, CTL_JOYENABLE, CTL_JOYSENS, CTL_CUSTOMIZEJOY };
#endif

CP_itemtype CtlMenu[] = {
Expand All @@ -131,16 +131,18 @@ CP_itemtype CtlMenu[] = {
{0, "", 0},
{0, "", 0},
{0, "", 0},
{0, "", 0},
{0, "", MouseSensitivity},
{0, "", JoySensitivity},
{1, "", CustomControls},
{0, "", CustomGamepadControls}
#else
{0, STR_MOUSEEN, 0},
{0, STR_MOVEWITHMOUSE, 0},
{0, STR_SENS, MouseSensitivity},
{1, STR_CUSTOM, CustomControls},
{0, STR_JOYEN, 0},
{0, STR_JOYSENS, JoySensitivity},
{1, STR_CUSTOM, CustomControls},
{0, STR_CUSTOMJOY, CustomGamepadControls}
#endif
};
Expand Down Expand Up @@ -293,6 +295,9 @@ static int pickquick;
static char SaveGameNames[10][32];
static char SaveName[13] = "savegam?.";

#define MENUSPACING 13
#define MENUPADDING 5
#define RADIOOFFSET 3

////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -1994,6 +1999,13 @@ CP_Control (int)
ShootSnd ();
break;

case CTL_MOVEWITHMOUSE:
movewithmouse ^= 1;
DrawCtlScreen ();
CusItems.curpos = -1;
ShootSnd ();
break;

case CTL_JOYENABLE:
joystickenabled ^= 1;
DrawCtlScreen ();
Expand Down Expand Up @@ -2237,7 +2249,7 @@ DrawCtlScreen (void)
DrawStripes (10);
VWB_DrawPic (80, 0, C_CONTROLPIC);
VWB_DrawPic (112, 184, C_MOUSELBACKPIC);
DrawWindow (CTL_X - 8, CTL_Y - 5, CTL_W, lengthof(CtlMenu) * 15, BKGDCOLOR);
DrawWindow (CTL_X - 8, CTL_Y - MENUPADDING, CTL_W, lengthof(CtlMenu) * MENUSPACING + MENUPADDING * 2, BKGDCOLOR);
#endif
WindowX = 0;
WindowW = 320;
Expand All @@ -2258,19 +2270,25 @@ DrawCtlScreen (void)
}

CtlMenu[CTL_MOUSESENS].active = mouseenabled;
CtlMenu[CTL_MOVEWITHMOUSE].active = mouseenabled;


DrawMenu (&CtlItems, CtlMenu);


x = CTL_X + CtlItems.indent - 24;
y = CTL_Y + 3;
y = CTL_Y + RADIOOFFSET;
if (mouseenabled)
VWB_DrawPic (x, y, C_SELECTEDPIC);
else
VWB_DrawPic (x, y, C_NOTSELECTEDPIC);

y = CTL_Y + 29;
y = CTL_Y + MENUSPACING + RADIOOFFSET;
if (movewithmouse)
VWB_DrawPic (x, y, C_SELECTEDPIC);
else
VWB_DrawPic (x, y, C_NOTSELECTEDPIC);

y = CTL_Y + (MENUSPACING * 4) + RADIOOFFSET;
if (joystickenabled)
VWB_DrawPic (x, y, C_SELECTEDPIC);
else
Expand Down
7 changes: 5 additions & 2 deletions wl_play.cpp
Expand Up @@ -50,7 +50,7 @@ unsigned tics;
//
// control info
//
boolean mouseenabled, joystickenabled;
boolean mouseenabled, joystickenabled, movewithmouse;
int dirscan[4] = { sc_UpArrow, sc_RightArrow, sc_DownArrow, sc_LeftArrow };
int buttonscan[NUMBUTTONS] = { sc_Control, sc_Alt, sc_LShift, sc_Space, sc_1, sc_2, sc_3, sc_4 };
int buttonmouse[4] = { bt_attack, bt_strafe, bt_use, bt_nobutton };
Expand Down Expand Up @@ -348,7 +348,10 @@ void PollMouseMove (void)
mouseymove -= screenHeight / 2;

controlx += mousexmove * 10 / (13 - mouseadjustment);
controly += mouseymove * 20 / (13 - mouseadjustment);

if (movewithmouse) {
controly += mouseymove * 20 / (13 - mouseadjustment);
}
}


Expand Down

0 comments on commit e54d932

Please sign in to comment.