2020-11-05 16:44:34 +01:00
|
|
|
#pragma once
|
2020-11-06 14:56:32 +01:00
|
|
|
|
2022-08-31 10:11:21 +02:00
|
|
|
enum class Msg : int;
|
2022-08-31 06:58:03 +02:00
|
|
|
|
2021-09-23 11:16:58 +02:00
|
|
|
enum class Menu1:int
|
|
|
|
{
|
|
|
|
New_Game = 101,
|
|
|
|
About_Pinball = 102,
|
|
|
|
High_Scores = 103,
|
|
|
|
Exit = 105,
|
|
|
|
Sounds = 201,
|
|
|
|
Music = 202,
|
Implement stereo sound. (#138)
* Implement stereo sound.
Original Space Cadet has mono sound. To achieve stereo, the following
steps were accomplished:
- Add a game option to turn on/off stereo sound. Default is on.
- TPinballComponent objects were extended with a method called
get_coordinates() that returns a single 2D point, approximating the
on-screen position of the object, re-mapped between 0 and 1 vertically
and horizontally, {0, 0} being at the top-left.
- For static objects like bumpers and lights, the coordinate refers
to the geometric center of the corresponding graphic sprite, and
is precalculated at initialization.
- For ball objects, the coordinate refers to the geometric center of
the ball, calculated during play when requested.
- Extend all calls to sound-playing methods so that they include a
TPinballComponent* argument that refers to the sound source, e.g.
where the sound comes from. For instance, when a flipper is
activated, its method call to emit a sound now includes a reference to
the flipper object; when a ball goes under a SkillShotGate, its method
call to emit a sound now includes a reference to the corresponding
light; and so on.
For some cases, like light rollovers, the sound source is taken from
the ball that triggered the light rollover.
For other cases, like holes, flags and targets, the sound source is
taken from the object itself.
For some special cases like ramp activation, sound source is
taken from the nearest light position that makes sense.
For all game-progress sounds, like mission completion sounds or ball
drain sounds, the sound source is undefined (set to nullptr), and the
Sound::PlaySound() method takes care of positioning them at a default
location, where speakers on a pinball machine normally are.
- Make the Sound::PlaySound() method accept a new argument, a
TPinballComponent reference, as described above.
If the stereo option is turned on, the Sound::PlaySound() method calls
the get_coordinates() method of the TPinballComponent reference to get
the sound position.
This project uses SDL_mixer and there is a function called
Mix_SetPosition() that allows placing a sound in the stereo field, by
giving it a distance and an angle.
We arbitrarily place the player's ears at the bottom of the table; we
set the ears' height to half a table's length. Intensity of the
stereo effect is directly related to this value; the farther the
player's ears from the table, the narrowest the stereo picture gets,
and vice-versa.
From there we have all we need to calculate distance and angle; we do
just that and position all the sounds.
* Copy-paste typo fix.
2022-05-30 09:35:29 +02:00
|
|
|
SoundStereo = 203,
|
2021-09-23 11:16:58 +02:00
|
|
|
Help_Topics = 301,
|
|
|
|
Launch_Ball = 401,
|
|
|
|
Pause_Resume_Game = 402,
|
|
|
|
Full_Screen = 403,
|
|
|
|
Demo = 404,
|
|
|
|
Select_Table = 405,
|
|
|
|
Player_Controls = 406,
|
|
|
|
OnePlayer = 408,
|
|
|
|
TwoPlayers = 409,
|
|
|
|
ThreePlayers = 410,
|
|
|
|
FourPlayers = 411,
|
2021-09-29 02:21:21 +02:00
|
|
|
Show_Menu = 412,
|
2021-09-23 11:16:58 +02:00
|
|
|
MaximumResolution = 500,
|
|
|
|
R640x480 = 501,
|
|
|
|
R800x600 = 502,
|
|
|
|
R1024x768 = 503,
|
|
|
|
WindowUniformScale = 600,
|
|
|
|
WindowLinearFilter = 601,
|
2021-11-22 07:32:17 +01:00
|
|
|
WindowIntegerScale = 602,
|
2021-11-21 13:40:56 +01:00
|
|
|
Prefer3DPBGameData = 700,
|
2021-09-23 11:16:58 +02:00
|
|
|
};
|
|
|
|
|
2021-10-17 17:18:29 +02:00
|
|
|
enum class InputTypes: unsigned
|
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
Keyboard = 1,
|
|
|
|
Mouse = 2,
|
|
|
|
GameController = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GameInput
|
|
|
|
{
|
|
|
|
InputTypes Type;
|
|
|
|
int Value;
|
|
|
|
|
|
|
|
bool operator==(const GameInput& other) const
|
|
|
|
{
|
|
|
|
return Type == other.Type && Value == other.Value;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-10-01 08:05:38 +02:00
|
|
|
struct ControlsStruct
|
|
|
|
{
|
2021-10-17 17:18:29 +02:00
|
|
|
GameInput LeftFlipper[3];
|
|
|
|
GameInput RightFlipper[3];
|
|
|
|
GameInput Plunger[3];
|
|
|
|
GameInput LeftTableBump[3];
|
|
|
|
GameInput RightTableBump[3];
|
|
|
|
GameInput BottomTableBump[3];
|
2021-10-01 08:05:38 +02:00
|
|
|
};
|
|
|
|
|
2021-01-29 14:42:05 +01:00
|
|
|
struct optionsStruct
|
2020-11-06 14:56:32 +01:00
|
|
|
{
|
2021-10-01 08:05:38 +02:00
|
|
|
ControlsStruct Key;
|
|
|
|
ControlsStruct KeyDft;
|
2021-10-09 16:28:30 +02:00
|
|
|
bool Sounds;
|
|
|
|
bool Music;
|
|
|
|
bool FullScreen;
|
2020-11-06 14:56:32 +01:00
|
|
|
int Players;
|
2021-02-06 14:53:47 +01:00
|
|
|
int Resolution;
|
2021-02-09 16:09:44 +01:00
|
|
|
bool UniformScaling;
|
2021-09-23 11:16:58 +02:00
|
|
|
bool LinearFiltering;
|
2021-09-28 07:14:18 +02:00
|
|
|
int FramesPerSecond;
|
|
|
|
int UpdatesPerSecond;
|
2021-09-29 06:46:13 +02:00
|
|
|
bool ShowMenu;
|
2021-10-02 06:42:08 +02:00
|
|
|
bool UncappedUpdatesPerSecond;
|
2021-10-09 16:28:30 +02:00
|
|
|
int SoundChannels;
|
2021-11-18 15:58:53 +01:00
|
|
|
bool HybridSleep;
|
2021-11-21 13:40:56 +01:00
|
|
|
bool Prefer3DPBGameData;
|
2021-11-22 07:32:17 +01:00
|
|
|
bool IntegerScaling;
|
2022-01-12 15:17:38 +01:00
|
|
|
int SoundVolume;
|
|
|
|
int MusicVolume;
|
Implement stereo sound. (#138)
* Implement stereo sound.
Original Space Cadet has mono sound. To achieve stereo, the following
steps were accomplished:
- Add a game option to turn on/off stereo sound. Default is on.
- TPinballComponent objects were extended with a method called
get_coordinates() that returns a single 2D point, approximating the
on-screen position of the object, re-mapped between 0 and 1 vertically
and horizontally, {0, 0} being at the top-left.
- For static objects like bumpers and lights, the coordinate refers
to the geometric center of the corresponding graphic sprite, and
is precalculated at initialization.
- For ball objects, the coordinate refers to the geometric center of
the ball, calculated during play when requested.
- Extend all calls to sound-playing methods so that they include a
TPinballComponent* argument that refers to the sound source, e.g.
where the sound comes from. For instance, when a flipper is
activated, its method call to emit a sound now includes a reference to
the flipper object; when a ball goes under a SkillShotGate, its method
call to emit a sound now includes a reference to the corresponding
light; and so on.
For some cases, like light rollovers, the sound source is taken from
the ball that triggered the light rollover.
For other cases, like holes, flags and targets, the sound source is
taken from the object itself.
For some special cases like ramp activation, sound source is
taken from the nearest light position that makes sense.
For all game-progress sounds, like mission completion sounds or ball
drain sounds, the sound source is undefined (set to nullptr), and the
Sound::PlaySound() method takes care of positioning them at a default
location, where speakers on a pinball machine normally are.
- Make the Sound::PlaySound() method accept a new argument, a
TPinballComponent reference, as described above.
If the stereo option is turned on, the Sound::PlaySound() method calls
the get_coordinates() method of the TPinballComponent reference to get
the sound position.
This project uses SDL_mixer and there is a function called
Mix_SetPosition() that allows placing a sound in the stereo field, by
giving it a distance and an angle.
We arbitrarily place the player's ears at the bottom of the table; we
set the ears' height to half a table's length. Intensity of the
stereo effect is directly related to this value; the farther the
player's ears from the table, the narrowest the stereo picture gets,
and vice-versa.
From there we have all we need to calculate distance and angle; we do
just that and position all the sounds.
* Copy-paste typo fix.
2022-05-30 09:35:29 +02:00
|
|
|
bool SoundStereo;
|
2022-05-19 13:17:31 +02:00
|
|
|
bool DebugOverlay;
|
|
|
|
bool DebugOverlayGrid;
|
|
|
|
bool DebugOverlayAllEdges;
|
|
|
|
bool DebugOverlayBallPosition;
|
|
|
|
bool DebugOverlayBallEdges;
|
|
|
|
bool DebugOverlayCollisionMask;
|
2022-05-31 10:34:04 +02:00
|
|
|
bool DebugOverlaySprites;
|
2022-06-01 15:19:27 +02:00
|
|
|
bool DebugOverlaySounds;
|
2022-10-11 11:45:03 +02:00
|
|
|
bool DebugOverlayBallDepthGrid;
|
2022-08-31 06:58:03 +02:00
|
|
|
std::string FontFileName;
|
2020-11-06 14:56:32 +01:00
|
|
|
};
|
|
|
|
|
2021-10-01 08:05:38 +02:00
|
|
|
struct ControlRef
|
|
|
|
{
|
2022-08-31 06:58:03 +02:00
|
|
|
Msg NameStringId;
|
2021-10-17 17:18:29 +02:00
|
|
|
GameInput (&Option)[3];
|
2021-10-01 08:05:38 +02:00
|
|
|
};
|
|
|
|
|
2020-11-06 14:56:32 +01:00
|
|
|
|
2020-11-05 16:44:34 +01:00
|
|
|
class options
|
|
|
|
{
|
|
|
|
public:
|
2021-09-28 07:14:18 +02:00
|
|
|
// Original does ~120 updates per second.
|
|
|
|
static constexpr int MaxUps = 360, MaxFps = MaxUps, MinUps = 60, MinFps = MinUps,
|
|
|
|
DefUps = 120, DefFps = 60;
|
2021-10-09 16:28:30 +02:00
|
|
|
// Original uses 8 sound channels
|
|
|
|
static constexpr int MaxSoundChannels = 32, MinSoundChannels = 1, DefSoundChannels = 8;
|
2022-01-12 15:17:38 +01:00
|
|
|
static constexpr int MaxVolume = MIX_MAX_VOLUME, MinVolume = 0, DefVolume = MaxVolume;
|
2021-09-16 09:57:46 +02:00
|
|
|
static optionsStruct Options;
|
|
|
|
|
2021-11-21 13:40:56 +01:00
|
|
|
static void InitPrimary();
|
|
|
|
static void InitSecondary();
|
2020-12-04 16:35:47 +01:00
|
|
|
static void uninit();
|
2021-09-16 09:57:46 +02:00
|
|
|
static int get_int(LPCSTR lpValueName, int defaultValue);
|
|
|
|
static void set_int(LPCSTR lpValueName, int data);
|
|
|
|
static std::string get_string(LPCSTR lpValueName, LPCSTR defaultValue);
|
|
|
|
static void set_string(LPCSTR lpValueName, LPCSTR value);
|
2021-09-22 14:50:07 +02:00
|
|
|
static float get_float(LPCSTR lpValueName, float defaultValue);
|
|
|
|
static void set_float(LPCSTR lpValueName, float data);
|
2021-10-17 17:18:29 +02:00
|
|
|
static void GetInput(const std::string& rowName, GameInput (&defaultValues)[3]);
|
|
|
|
static void SetInput(const std::string& rowName, GameInput (&values)[3]);
|
2021-09-23 11:16:58 +02:00
|
|
|
static void toggle(Menu1 uIDCheckItem);
|
2021-10-17 17:18:29 +02:00
|
|
|
static void InputDown(GameInput input);
|
2021-10-01 08:05:38 +02:00
|
|
|
static void ShowControlDialog();
|
|
|
|
static void RenderControlDialog();
|
2021-10-17 17:18:29 +02:00
|
|
|
static bool WaitingForInput() { return ControlWaitingForInput != nullptr; }
|
2020-11-05 16:44:34 +01:00
|
|
|
private:
|
2021-09-16 09:57:46 +02:00
|
|
|
static std::map<std::string, std::string> settings;
|
2021-10-01 08:05:38 +02:00
|
|
|
static ControlsStruct RebindControls;
|
|
|
|
static bool ShowDialog;
|
|
|
|
static const ControlRef Controls[6];
|
2021-10-17 17:18:29 +02:00
|
|
|
static GameInput* ControlWaitingForInput;
|
2021-09-16 09:57:46 +02:00
|
|
|
|
|
|
|
static void MyUserData_ReadLine(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line);
|
|
|
|
static void* MyUserData_ReadOpen(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name);
|
|
|
|
static void MyUserData_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf);
|
|
|
|
static const std::string& GetSetting(const std::string& key, const std::string& value);
|
|
|
|
static void SetSetting(const std::string& key, const std::string& value);
|
2020-11-05 16:44:34 +01:00
|
|
|
};
|