1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 06:28:30 +02:00
VVVVVV/desktop_version/src/Music.h
Info Teddy 5a316d65e6 Allow using help/graphics/music/game/key/map/obj everywhere
This commit makes `help`, `graphics`, `music`, `game`, `key`, `map`, and
`obj` essentially static global objects that can be used everywhere.
This is useful in case we ever need to add a new function in the future,
so we don't have to bother with passing a new argument in which means we
have to pass a new argument in to the function that calls that function
which means having to pass a new argument into the function that calls
THAT function, etc. which is a real headache when working on fan mods of
the source code.

Note that this changes NONE of the existing function signatures, it
merely just makes those variables accessible everywhere in the same way
`script` and `ed` are.

Also note that some classes had to be initialized after the filesystem
was initialized, but C++ would keep initializing them before the
filesystem got initialized, because I *had* to put them at the top of
`main.cpp`, or else they wouldn't be global variables.

The only way to work around this was to use entityclass's initialization
style (which I'm pretty sure entityclass of all things doesn't need to
be initialized this way), where you actually initialize the class in an
`init()` function, and so then you do `graphics.init()` after the
filesystem initialization, AFTER doing `Graphics graphics` up at the
top.

I've had to do this for `graphics` (but only because its child
GraphicsResources `grphx` needs to be initialized this way), `music`,
and `game`. I don't think this will affect anything. Other than that,
`help`, `key`, and `map` are still using the C++-intended method of
having ClassName::ClassName() functions.
2020-01-29 07:58:23 -05:00

70 lines
1.4 KiB
C++

#ifndef MUSIC_H
#define MUSIC_H
#include "SoundSystem.h"
#include <vector>
#define musicroom(rx, ry) ((rx) + ((ry) * 20))
class musicclass
{
public:
void init();
void play(int t);
void loopmusic();
void stopmusic();
void haltdasmusik();
void silencedasmusik();
void fadeMusicVolumeIn(int ms);
void fadeout();
void processmusicfade();
void processmusicfadein();
void processmusic();
void niceplay(int t);
void changemusicarea(int x, int y);
// public var musicchan:Array = new Array();
// public var musicchannel:SoundChannel, musicchannel2:SoundChannel;
// public var currentmusicchan:int, musicchanlen:int, musicchancur:int, musicstopother:int, resumesong:int;
// public var currentsong:int, musicfade:int, musicfadein:int;
int currentsong, musicfade, musicfadein;
int resumesong;
//public var nicefade:int, nicechange:int;
// Play a sound effect! There are 16 channels, which iterate
void initefchannels();
void playef(int t, int offset = 0);
std::vector<SoundTrack> soundTracks;
std::vector<MusicTrack> musicTracks;
SoundSystem soundSystem;
bool safeToProcessMusic;
int nicechange;
int nicefade;
bool m_doFadeInVol;
int FadeVolAmountPerFrame;
int musicVolume;
float volume;
bool custompd;
int fadeoutqueuesong; // -1 if no song queued
bool dontquickfade;
// MMMMMM mod settings
bool mmmmmm;
bool usingmmmmmm;
};
extern musicclass music;
#endif /* MUSIC_H */