Skip to content

Commit e54d932

Browse files
committed
Support enabling/disabling moving with mouse
1 parent 090c843 commit e54d932

File tree

5 files changed

+38
-10
lines changed

5 files changed

+38
-10
lines changed

foreign.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#define STR_SB "Sound Blaster"
4545

4646
#define STR_MOUSEEN "Mouse Enabled"
47+
#define STR_MOVEWITHMOUSE "Move with mouse"
4748
#define STR_JOYEN "Gamepad Enabled"
4849
#define STR_PORT2 "Use joystick port 2"
4950
#define STR_GAMEPAD "Gamepad Enabled"

wl_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ extern memptr demobuffer;
10401040
//
10411041
// control info
10421042
//
1043-
extern boolean mouseenabled,joystickenabled;
1043+
extern boolean mouseenabled,joystickenabled,movewithmouse;
10441044
extern int dirscan[4];
10451045
extern int buttonscan[NUMBUTTONS];
10461046
extern int buttonmouse[4];

wl_main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ void ReadConfig(void)
174174
read(file,&viewsize,sizeof(viewsize));
175175
read(file,&mouseadjustment,sizeof(mouseadjustment));
176176
read(file,&joyadjustment,sizeof(joyadjustment));
177+
read(file,&movewithmouse,sizeof(movewithmouse));
177178

178179
close(file);
179180

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

192193
if(mouseenabled) mouseenabled=true;
193194
if(joystickenabled) joystickenabled=true;
195+
if(movewithmouse) movewithmouse=true;
194196

195197
if (!MousePresent)
198+
{
196199
mouseenabled = false;
200+
movewithmouse = false;
201+
}
197202
if (!IN_JoyPresent())
198203
joystickenabled = false;
199204

@@ -296,6 +301,7 @@ void WriteConfig(void)
296301
write(file,&viewsize,sizeof(viewsize));
297302
write(file,&mouseadjustment,sizeof(mouseadjustment));
298303
write(file,&joyadjustment,sizeof(joyadjustment));
304+
write(file,&movewithmouse,sizeof(movewithmouse));
299305

300306
close(file);
301307
}

wl_menu.cpp

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ CP_itemtype SndMenu[] = {
120120
};
121121

122122
#ifdef JAPAN
123-
enum { CTL_MOUSEENABLE, CTL_JOYENABLE, CTL_JOY2BUTTONUNKNOWN, CTL_GAMEPADUNKONWN, CTL_MOUSESENS, CTL_JOYSENS, CTL_CUSTOMIZEKB, CTL_CUSTOMIZEJOY };
123+
enum { CTL_MOUSEENABLE, CTL_MOVEWITHMOUSE, CTL_JOYENABLE, CTL_JOY2BUTTONUNKNOWN, CTL_GAMEPADUNKONWN, CTL_MOUSESENS, CTL_JOYSENS, CTL_CUSTOMIZEKB, CTL_CUSTOMIZEJOY };
124124
#else
125-
enum { CTL_MOUSEENABLE, CTL_MOUSESENS, CTL_JOYENABLE, CTL_JOYSENS, CTL_CUSTOMIZEKB, CTL_CUSTOMIZEJOY };
125+
enum { CTL_MOUSEENABLE, CTL_MOVEWITHMOUSE, CTL_MOUSESENS, CTL_CUSTOMIZEKB, CTL_JOYENABLE, CTL_JOYSENS, CTL_CUSTOMIZEJOY };
126126
#endif
127127

128128
CP_itemtype CtlMenu[] = {
@@ -131,16 +131,18 @@ CP_itemtype CtlMenu[] = {
131131
{0, "", 0},
132132
{0, "", 0},
133133
{0, "", 0},
134+
{0, "", 0},
134135
{0, "", MouseSensitivity},
135136
{0, "", JoySensitivity},
136137
{1, "", CustomControls},
137138
{0, "", CustomGamepadControls}
138139
#else
139140
{0, STR_MOUSEEN, 0},
141+
{0, STR_MOVEWITHMOUSE, 0},
140142
{0, STR_SENS, MouseSensitivity},
143+
{1, STR_CUSTOM, CustomControls},
141144
{0, STR_JOYEN, 0},
142145
{0, STR_JOYSENS, JoySensitivity},
143-
{1, STR_CUSTOM, CustomControls},
144146
{0, STR_CUSTOMJOY, CustomGamepadControls}
145147
#endif
146148
};
@@ -293,6 +295,9 @@ static int pickquick;
293295
static char SaveGameNames[10][32];
294296
static char SaveName[13] = "savegam?.";
295297

298+
#define MENUSPACING 13
299+
#define MENUPADDING 5
300+
#define RADIOOFFSET 3
296301

297302
////////////////////////////////////////////////////////////////////
298303
//
@@ -1994,6 +1999,13 @@ CP_Control (int)
19941999
ShootSnd ();
19952000
break;
19962001

2002+
case CTL_MOVEWITHMOUSE:
2003+
movewithmouse ^= 1;
2004+
DrawCtlScreen ();
2005+
CusItems.curpos = -1;
2006+
ShootSnd ();
2007+
break;
2008+
19972009
case CTL_JOYENABLE:
19982010
joystickenabled ^= 1;
19992011
DrawCtlScreen ();
@@ -2237,7 +2249,7 @@ DrawCtlScreen (void)
22372249
DrawStripes (10);
22382250
VWB_DrawPic (80, 0, C_CONTROLPIC);
22392251
VWB_DrawPic (112, 184, C_MOUSELBACKPIC);
2240-
DrawWindow (CTL_X - 8, CTL_Y - 5, CTL_W, lengthof(CtlMenu) * 15, BKGDCOLOR);
2252+
DrawWindow (CTL_X - 8, CTL_Y - MENUPADDING, CTL_W, lengthof(CtlMenu) * MENUSPACING + MENUPADDING * 2, BKGDCOLOR);
22412253
#endif
22422254
WindowX = 0;
22432255
WindowW = 320;
@@ -2258,19 +2270,25 @@ DrawCtlScreen (void)
22582270
}
22592271

22602272
CtlMenu[CTL_MOUSESENS].active = mouseenabled;
2273+
CtlMenu[CTL_MOVEWITHMOUSE].active = mouseenabled;
22612274

22622275

22632276
DrawMenu (&CtlItems, CtlMenu);
22642277

2265-
22662278
x = CTL_X + CtlItems.indent - 24;
2267-
y = CTL_Y + 3;
2279+
y = CTL_Y + RADIOOFFSET;
22682280
if (mouseenabled)
22692281
VWB_DrawPic (x, y, C_SELECTEDPIC);
22702282
else
22712283
VWB_DrawPic (x, y, C_NOTSELECTEDPIC);
22722284

2273-
y = CTL_Y + 29;
2285+
y = CTL_Y + MENUSPACING + RADIOOFFSET;
2286+
if (movewithmouse)
2287+
VWB_DrawPic (x, y, C_SELECTEDPIC);
2288+
else
2289+
VWB_DrawPic (x, y, C_NOTSELECTEDPIC);
2290+
2291+
y = CTL_Y + (MENUSPACING * 4) + RADIOOFFSET;
22742292
if (joystickenabled)
22752293
VWB_DrawPic (x, y, C_SELECTEDPIC);
22762294
else

wl_play.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ unsigned tics;
5050
//
5151
// control info
5252
//
53-
boolean mouseenabled, joystickenabled;
53+
boolean mouseenabled, joystickenabled, movewithmouse;
5454
int dirscan[4] = { sc_UpArrow, sc_RightArrow, sc_DownArrow, sc_LeftArrow };
5555
int buttonscan[NUMBUTTONS] = { sc_Control, sc_Alt, sc_LShift, sc_Space, sc_1, sc_2, sc_3, sc_4 };
5656
int buttonmouse[4] = { bt_attack, bt_strafe, bt_use, bt_nobutton };
@@ -348,7 +348,10 @@ void PollMouseMove (void)
348348
mouseymove -= screenHeight / 2;
349349

350350
controlx += mousexmove * 10 / (13 - mouseadjustment);
351-
controly += mouseymove * 20 / (13 - mouseadjustment);
351+
352+
if (movewithmouse) {
353+
controly += mouseymove * 20 / (13 - mouseadjustment);
354+
}
352355
}
353356

354357

0 commit comments

Comments
 (0)