Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed windows macro checks from _WINDOWS to _WIN32 #87

Merged
merged 1 commit into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Turn/include/Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#ifndef CONSOLE_H_INCLUDED
#define CONSOLE_H_INCLUDED

#ifdef _WINDOWS
#ifdef _WIN32
#include <Windows.h>
#endif // _WINDOWS
#endif // _WIN32

class Console {
public:
Expand Down Expand Up @@ -36,9 +36,9 @@ class Console {
// Copy constructor private and unimplemented for this singleton
Console(Console&) = delete;

#ifdef _WINDOWS
#ifdef _WIN32
HANDLE m_hConsoleHandle;
#endif // _WINDOWS
#endif // _WIN32
};

#endif // CONSOLE_H_INCLUDED
#endif // CONSOLE_H_INCLUDED
4 changes: 2 additions & 2 deletions Turn/include/Sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <string>
#include <vector>
#include <utility>
#ifndef _WINDOWS
#ifndef _WIN32
#include <mutex>
#endif

Expand Down Expand Up @@ -37,7 +37,7 @@ class PlatformSoundHelper {

void PlaySoundFile(std::string const& filename);
private:
#ifndef _WINDOWS
#ifndef _WIN32
std::mutex m_resourceMutex;
#endif
};
Expand Down
22 changes: 11 additions & 11 deletions Turn/src/Console.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#include "../include/Console.h"
#ifdef _WINDOWS
#ifdef _WIN32
#include <Windows.h>
#include <conio.h>
#else
#include <stdlib.h>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#endif // _WINDOWS
#endif // _WIN32

Console::Console() {
#if defined(_WINDOWS)
#ifdef _WIN32
m_hConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
#endif
}

void Console::ClearScreen() {
#ifdef _WINDOWS
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif // _WINDOWS
#endif // _WIN32
}

char Console::GetChar() const {
#ifdef _WINDOWS
#ifdef _WIN32
return _getch();
#else
// The following code attempts to manually reproduce the same behaviour as the
Expand All @@ -47,11 +47,11 @@ char Console::GetChar() const {

// Return the character that was read
return ch;
#endif // _WINDOWS
#endif // _WIN32
}

void Console::SetColour(EColour colour) {
#ifdef _WINDOWS
#ifdef _WIN32
enum WindowsAttributes
{
GREY = 7,
Expand All @@ -68,7 +68,7 @@ void Console::SetColour(EColour colour) {
DARK_GREY, // EColour::DarkGrey
RED, // EColour::Red
GREEN, // EColour::Green

RED_BACKGROUND, // EColour::Background_Red
GREY_BACKGROUND,// EColour::Background_Grey
};
Expand All @@ -85,10 +85,10 @@ void Console::SetColour(EColour colour) {
"\033[0m\033[47m", // EColour::Background_Grey
};
printf("%s", colourEscapeCodes[colour]);
#endif // _WINDOWS
#endif // _WIN32
}

Console& Console::GetInstance() {
static Console singletonInstance;
return singletonInstance;
}
}
13 changes: 8 additions & 5 deletions Turn/src/Sound.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "../include/Sound.h"

#ifdef _WINDOWS
#ifdef _WIN32
#include <Windows.h>
#include <MMSystem.h>
#else
Expand All @@ -21,7 +21,7 @@
PlatformSoundHelper SoundMaker::ms_SoundHelper;

PlatformSoundHelper::PlatformSoundHelper() {
#ifndef _WINDOWS
#ifndef _WIN32
m_resourceMutex.lock();
SDL_Init(SDL_INIT_AUDIO);
Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024);
Expand All @@ -30,7 +30,7 @@ PlatformSoundHelper::PlatformSoundHelper() {
}

PlatformSoundHelper::~PlatformSoundHelper() {
#ifndef _WINDOWS
#ifndef _WIN32
m_resourceMutex.lock();
Mix_CloseAudio();
SDL_Quit();
Expand All @@ -39,7 +39,7 @@ PlatformSoundHelper::~PlatformSoundHelper() {
}

void PlatformSoundHelper::PlaySoundFile(std::string const& filename) {
#ifdef _WINDOWS
#ifdef _WIN32
PlaySound(filename.c_str(), NULL, SND_ASYNC);
#else
// It would be possible to pre-cache the sounds for SDL_mixer, however instead
Expand Down Expand Up @@ -84,7 +84,8 @@ SoundMaker::SoundMaker():mInfo(),
attackFileNames.push_back(FileName + ATTACKFILENAME3);
attackFileNames.push_back(FileName + ATTACKFILENAMECRIT);
}
void SoundMaker::PlayPrimaryAttack(int damageDealt)

void SoundMaker::PlayPrimaryAttack(int damageDealt)
{
//
// play attack sound based on damage delt. 0 is miss, top is
Expand All @@ -101,10 +102,12 @@ void SoundMaker::PlayPrimaryAttack(int damageDealt)
}
PlaySoundFile(attackFileNames[index]);
}

void SoundMaker::PlaySecondaryAttack(void)
{
PlaySoundFile(altAttackFileName.c_str());
}

void SoundMaker::PlayHeal(void) {
PlaySoundFile(healFileName.c_str());
}
Expand Down