1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 07:43:01 +01:00

Pack nested namespaces together

This commit is contained in:
Hielke Morsink
2018-02-16 00:43:16 +01:00
parent dbbd5b89e6
commit bc44792da9
29 changed files with 214 additions and 226 deletions

View File

@@ -17,7 +17,7 @@
#include <openrct2/interface/Cursors.h>
#include "CursorRepository.h"
namespace OpenRCT2 { namespace Ui
namespace OpenRCT2::Ui
{
static constexpr const CursorData BlankCursorData =
{
@@ -664,4 +664,4 @@ namespace OpenRCT2 { namespace Ui
}
return result;
}
} }
}

View File

@@ -23,59 +23,56 @@
struct SDL_Cursor;
namespace OpenRCT2
namespace OpenRCT2::Ui
{
namespace Ui
class CursorRepository
{
class CursorRepository
private:
class CursorSetHolder
{
private:
class CursorSetHolder
{
private:
SDL_Cursor * _cursors[CURSOR_COUNT] = {nullptr};
public:
CursorSetHolder(const std::function<SDL_Cursor *(CURSOR_ID)> & getCursor)
{
for (size_t i = 0; i < CURSOR_COUNT; i++)
{
_cursors[i] = getCursor(static_cast<CURSOR_ID>(i));
}
}
~CursorSetHolder()
{
for (size_t i = 0; i < CURSOR_COUNT; i++)
{
SDL_FreeCursor(_cursors[i]);
}
}
SDL_Cursor * getScaledCursor(CURSOR_ID cursorId)
{
return _cursors[cursorId];
}
};
constexpr static sint32 BASE_CURSOR_WIDTH = 32;
constexpr static sint32 BASE_CURSOR_HEIGHT = 32;
CURSOR_ID _currentCursor = CURSOR_UNDEFINED;
uint8 _currentCursorScale = 1;
std::map<uint8, CursorSetHolder> _scaledCursors;
SDL_Cursor * _cursors[CURSOR_COUNT] = {nullptr};
public:
~CursorRepository();
void LoadCursors();
CURSOR_ID GetCurrentCursor();
void SetCurrentCursor(CURSOR_ID cursorId);
void SetCursorScale(uint8 cursorScale);
CursorSetHolder(const std::function<SDL_Cursor *(CURSOR_ID)> & getCursor)
{
for (size_t i = 0; i < CURSOR_COUNT; i++)
{
_cursors[i] = getCursor(static_cast<CURSOR_ID>(i));
}
}
private:
SDL_Cursor * Create(const CursorData * cursorInfo, uint8 scale);
void GenerateScaledCursorSetHolder(uint8 scale);
static const CursorData * GetCursorData(CURSOR_ID cursorId);
~CursorSetHolder()
{
for (size_t i = 0; i < CURSOR_COUNT; i++)
{
SDL_FreeCursor(_cursors[i]);
}
}
SDL_Cursor * getScaledCursor(CURSOR_ID cursorId)
{
return _cursors[cursorId];
}
};
}
constexpr static sint32 BASE_CURSOR_WIDTH = 32;
constexpr static sint32 BASE_CURSOR_HEIGHT = 32;
CURSOR_ID _currentCursor = CURSOR_UNDEFINED;
uint8 _currentCursorScale = 1;
std::map<uint8, CursorSetHolder> _scaledCursors;
public:
~CursorRepository();
void LoadCursors();
CURSOR_ID GetCurrentCursor();
void SetCurrentCursor(CURSOR_ID cursorId);
void SetCursorScale(uint8 cursorScale);
private:
SDL_Cursor * Create(const CursorData * cursorInfo, uint8 scale);
void GenerateScaledCursorSetHolder(uint8 scale);
static const CursorData * GetCursorData(CURSOR_ID cursorId);
};
}

View File

@@ -20,39 +20,36 @@
union SDL_Event;
namespace OpenRCT2
namespace OpenRCT2::Ui
{
namespace Ui
/**
* Represents a
*/
class TextComposition
{
/**
* Represents a
*/
class TextComposition
{
private:
TextInputSession _session = { 0 };
private:
TextInputSession _session = { 0 };
bool _imeActive = false;
sint32 _imeStart = 0;
sint32 _imeLength = 0;
utf8 _imeBuffer[32] = { 0 };
bool _imeActive = false;
sint32 _imeStart = 0;
sint32 _imeLength = 0;
utf8 _imeBuffer[32] = { 0 };
public:
bool IsActive();
TextInputSession * Start(utf8 * buffer, size_t bufferSize);
void Stop();
void HandleMessage(const SDL_Event * e);
public:
bool IsActive();
TextInputSession * Start(utf8 * buffer, size_t bufferSize);
void Stop();
void HandleMessage(const SDL_Event * e);
private:
void CursorHome();
void CursorEnd();
void CursorLeft();
void CursorRight();
void Insert(const utf8 * text);
void InsertCodepoint(codepoint_t codepoint);
void Clear();
void Delete();
void RecalculateLength();
};
}
private:
void CursorHome();
void CursorEnd();
void CursorLeft();
void CursorRight();
void Insert(const utf8 * text);
void InsertCodepoint(codepoint_t codepoint);
void Clear();
void Delete();
void RecalculateLength();
};
}

View File

@@ -26,54 +26,54 @@
#include <SDL.h>
namespace OpenRCT2 { namespace Ui
namespace OpenRCT2::Ui
{
class AndroidContext final : public IPlatformUiContext
{
private:
class AndroidContext final : public IPlatformUiContext
public:
AndroidContext()
{
private:
public:
AndroidContext()
{
}
void SetWindowIcon(SDL_Window * window) override
{
}
bool IsSteamOverlayAttached() override
{
return false;
}
void ShowMessageBox(SDL_Window * window, const std::string &message) override
{
log_verbose(message.c_str());
STUB();
}
std::string ShowFileDialog(SDL_Window * window, const FileDialogDesc &desc) override
{
STUB();
return nullptr;
}
std::string ShowDirectoryDialog(SDL_Window * window, const std::string &title) override
{
log_info(title.c_str());
STUB();
return "/sdcard/rct2";
}
};
IPlatformUiContext * CreatePlatformUiContext()
{
return new AndroidContext();
}
} }
void SetWindowIcon(SDL_Window * window) override
{
}
bool IsSteamOverlayAttached() override
{
return false;
}
void ShowMessageBox(SDL_Window * window, const std::string &message) override
{
log_verbose(message.c_str());
STUB();
}
std::string ShowFileDialog(SDL_Window * window, const FileDialogDesc &desc) override
{
STUB();
return nullptr;
}
std::string ShowDirectoryDialog(SDL_Window * window, const std::string &title) override
{
log_info(title.c_str());
STUB();
return "/sdcard/rct2";
}
};
IPlatformUiContext * CreatePlatformUiContext()
{
return new AndroidContext();
}
}
#endif // __ANDROID__

View File

@@ -29,7 +29,7 @@
#include <SDL.h>
namespace OpenRCT2 { namespace Ui
namespace OpenRCT2::Ui
{
enum class DIALOG_TYPE
{
@@ -385,6 +385,6 @@ namespace OpenRCT2 { namespace Ui
{
return new LinuxContext();
}
} }
}
#endif // __linux__ || __OpenBSD__

View File

@@ -54,7 +54,7 @@ static std::wstring SHGetPathFromIDListLongPath(LPCITEMIDLIST pidl)
return pszPath;
}
namespace OpenRCT2 { namespace Ui
namespace OpenRCT2::Ui
{
class Win32Context : public IPlatformUiContext
{
@@ -224,6 +224,6 @@ namespace OpenRCT2 { namespace Ui
{
return new Win32Context();
}
} }
}
#endif // _WIN32

View File

@@ -27,7 +27,7 @@
#include <SDL.h>
namespace OpenRCT2 { namespace Ui
namespace OpenRCT2::Ui
{
class macOSContext final : public IPlatformUiContext
{
@@ -182,6 +182,6 @@ namespace OpenRCT2 { namespace Ui
{
return new macOSContext();
}
} }
}
#endif // __APPLE__ && __MACH__

View File

@@ -16,9 +16,9 @@
#include <openrct2/common.h>
namespace OpenRCT2 { namespace Ui
namespace OpenRCT2::Ui
{
interface IWindowManager;
IWindowManager * CreateWindowManager();
} }
}

View File

@@ -24,7 +24,7 @@
#include "AudioContext.h"
#include "AudioFormat.h"
namespace OpenRCT2 { namespace Audio
namespace OpenRCT2::Audio
{
class AudioChannelImpl : public ISDLAudioChannel
{
@@ -295,4 +295,4 @@ namespace OpenRCT2 { namespace Audio
{
return new (std::nothrow) AudioChannelImpl();
}
} }
}

View File

@@ -21,7 +21,7 @@
#include "../SDLException.h"
#include "AudioContext.h"
namespace OpenRCT2 { namespace Audio
namespace OpenRCT2::Audio
{
class AudioContext : public IAudioContext
{
@@ -98,4 +98,4 @@ namespace OpenRCT2 { namespace Audio
{
return new AudioContext();
}
} }
}

View File

@@ -9,7 +9,7 @@
struct SDL_RWops;
using SpeexResamplerState = struct SpeexResamplerState_;
namespace OpenRCT2 { namespace Audio
namespace OpenRCT2::Audio
{
struct AudioFormat;
interface IAudioContext;
@@ -70,4 +70,4 @@ namespace OpenRCT2 { namespace Audio
}
IAudioContext * CreateAudioContext();
} }
}

View File

@@ -19,7 +19,7 @@
#include <openrct2/common.h>
#include <SDL2/SDL.h>
namespace OpenRCT2 { namespace Audio
namespace OpenRCT2::Audio
{
/**
* Represents the size, frequency and number of channels for
@@ -53,4 +53,4 @@ namespace OpenRCT2 { namespace Audio
{
return !(lhs == rhs);
}
} }
}

View File

@@ -36,7 +36,7 @@
#include <openrct2/OpenRCT2.h>
#include <openrct2/platform/platform.h>
namespace OpenRCT2 { namespace Audio
namespace OpenRCT2::Audio
{
class AudioMixerImpl final : public IAudioMixer
{
@@ -513,4 +513,4 @@ namespace OpenRCT2 { namespace Audio
{
return new AudioMixerImpl();
}
} }
}

View File

@@ -21,7 +21,7 @@
#include "AudioContext.h"
#include "AudioFormat.h"
namespace OpenRCT2 { namespace Audio
namespace OpenRCT2::Audio
{
/**
* An audio source where raw PCM data is streamed directly from
@@ -207,4 +207,4 @@ namespace OpenRCT2 { namespace Audio
}
return source;
}
} }
}

View File

@@ -24,7 +24,7 @@
#include "AudioContext.h"
#include "AudioFormat.h"
namespace OpenRCT2 { namespace Audio
namespace OpenRCT2::Audio
{
/**
* An audio source where raw PCM data is initially loaded into RAM from
@@ -243,4 +243,4 @@ namespace OpenRCT2 { namespace Audio
}
return source;
}
} }
}

View File

@@ -1,6 +1,6 @@
#include <openrct2/interface/Console.h>
namespace OpenRCT2 { namespace Ui
namespace OpenRCT2::Ui
{
class InGameConsole final : public InteractiveConsole
{
@@ -53,4 +53,4 @@ namespace OpenRCT2 { namespace Ui
void Invalidate() const;
sint32 GetNumVisibleLines() const;
};
} }
}

View File

@@ -18,7 +18,7 @@
#include "../common.h"
namespace OpenRCT2 { namespace Audio
namespace OpenRCT2::Audio
{
interface IAudioSource;
@@ -73,4 +73,4 @@ namespace OpenRCT2 { namespace Audio
virtual size_t Read(void * dst, size_t len) abstract;
};
} }
}

View File

@@ -20,47 +20,44 @@
#include <vector>
#include "../common.h"
namespace OpenRCT2
namespace OpenRCT2::Audio
{
namespace Audio
interface IAudioChannel;
interface IAudioMixer;
interface IAudioSource;
/**
* Audio services for playing music and sound effects.
*/
interface IAudioContext
{
interface IAudioChannel;
interface IAudioMixer;
interface IAudioSource;
virtual ~IAudioContext() = default;
/**
* Audio services for playing music and sound effects.
*/
interface IAudioContext
{
virtual ~IAudioContext() = default;
virtual IAudioMixer * GetMixer() abstract;
virtual IAudioMixer * GetMixer() abstract;
virtual std::vector<std::string> GetOutputDevices() abstract;
virtual void SetOutputDevice(const std::string &deviceName) abstract;
virtual std::vector<std::string> GetOutputDevices() abstract;
virtual void SetOutputDevice(const std::string &deviceName) abstract;
virtual IAudioSource * CreateStreamFromWAV(const std::string &path) abstract;
virtual IAudioSource * CreateStreamFromWAV(const std::string &path) abstract;
virtual void StartTitleMusic() abstract;
virtual void StartTitleMusic() abstract;
virtual IAudioChannel * PlaySound(sint32 soundId, sint32 volume, sint32 pan) abstract;
virtual IAudioChannel * PlaySoundAtLocation(sint32 soundId, sint16 x, sint16 y, sint16 z) abstract;
virtual IAudioChannel * PlaySoundPanned(sint32 soundId, sint32 pan, sint16 x, sint16 y, sint16 z) abstract;
virtual IAudioChannel * PlaySound(sint32 soundId, sint32 volume, sint32 pan) abstract;
virtual IAudioChannel * PlaySoundAtLocation(sint32 soundId, sint16 x, sint16 y, sint16 z) abstract;
virtual IAudioChannel * PlaySoundPanned(sint32 soundId, sint32 pan, sint16 x, sint16 y, sint16 z) abstract;
virtual void ToggleAllSounds() abstract;
virtual void PauseSounds() abstract;
virtual void UnpauseSounds() abstract;
virtual void ToggleAllSounds() abstract;
virtual void PauseSounds() abstract;
virtual void UnpauseSounds() abstract;
virtual void StopAll() abstract;
virtual void StopCrowdSound() abstract;
virtual void StopRainSound() abstract;
virtual void StopRideMusic() abstract;
virtual void StopTitleMusic() abstract;
virtual void StopVehicleSounds() abstract;
};
virtual void StopAll() abstract;
virtual void StopCrowdSound() abstract;
virtual void StopRainSound() abstract;
virtual void StopRideMusic() abstract;
virtual void StopTitleMusic() abstract;
virtual void StopVehicleSounds() abstract;
};
IAudioContext * CreateDummyAudioContext();
}
IAudioContext * CreateDummyAudioContext();
}

View File

@@ -29,7 +29,7 @@ enum MIXER_GROUP
MIXER_GROUP_TITLE_MUSIC,
};
namespace OpenRCT2 { namespace Audio
namespace OpenRCT2::Audio
{
interface IAudioSource;
interface IAudioChannel;
@@ -53,7 +53,7 @@ namespace OpenRCT2 { namespace Audio
virtual IAudioSource * GetSoundSource(sint32 id) abstract;
virtual IAudioSource * GetMusicSource(sint32 id) abstract;
};
} }
}
#ifndef DSBPAN_LEFT
#define DSBPAN_LEFT -10000

View File

@@ -19,7 +19,7 @@
#include "../common.h"
#include "AudioMixer.h"
namespace OpenRCT2 { namespace Audio
namespace OpenRCT2::Audio
{
/**
* Represents a readable source of audio PCM data.
@@ -37,4 +37,4 @@ namespace OpenRCT2 { namespace Audio
{
IAudioSource * CreateNull();
}
} }
}

View File

@@ -16,7 +16,7 @@
#include "AudioContext.h"
namespace OpenRCT2 { namespace Audio
namespace OpenRCT2::Audio
{
class DummyAudioContext final : public IAudioContext
{
@@ -49,4 +49,4 @@ namespace OpenRCT2 { namespace Audio
{
return new DummyAudioContext();
}
} }
}

View File

@@ -16,7 +16,7 @@
#include "AudioSource.h"
namespace OpenRCT2 { namespace Audio
namespace OpenRCT2::Audio
{
/**
* An audio source representing silence.
@@ -39,4 +39,4 @@ namespace OpenRCT2 { namespace Audio
{
return new NullAudioSource();
}
} }
}

View File

@@ -20,7 +20,7 @@
#include "Drawing.h"
namespace OpenRCT2 { namespace Drawing
namespace OpenRCT2::Drawing
{
interface IDrawingEngine;
@@ -39,4 +39,4 @@ namespace OpenRCT2 { namespace Drawing
virtual void DrawSpriteSolid(uint32 image, sint32 x, sint32 y, uint8 colour) abstract;
virtual void DrawGlyph(uint32 image, sint32 x, sint32 y, uint8 * palette) abstract;
};
} }
}

View File

@@ -40,7 +40,7 @@ enum DRAWING_ENGINE_FLAGS
struct rct_drawpixelinfo;
struct rct_palette_entry;
namespace OpenRCT2 { namespace Drawing
namespace OpenRCT2::Drawing
{
interface IDrawingContext;
@@ -80,4 +80,4 @@ namespace OpenRCT2 { namespace Drawing
sint32 xStart,
sint32 yStart) abstract;
};
} }
}

View File

@@ -20,9 +20,9 @@
struct rct_drawpixelinfo;
namespace OpenRCT2 { namespace Drawing
namespace OpenRCT2::Drawing
{
interface IRainDrawer;
} }
}
void DrawRain(rct_drawpixelinfo * dpi, OpenRCT2::Drawing::IRainDrawer * rainDrawer);

View File

@@ -51,7 +51,7 @@ enum CURSOR_ID
CURSOR_COUNT,
};
namespace OpenRCT2 { namespace Ui
namespace OpenRCT2::Ui
{
constexpr size_t CURSOR_BIT_WIDTH = 32;
constexpr size_t CURSOR_HEIGHT = 4;
@@ -65,4 +65,4 @@ namespace OpenRCT2 { namespace Ui
uint8 Data[CURSOR_BIT_WIDTH * CURSOR_HEIGHT];
uint8 Mask[CURSOR_BIT_WIDTH * CURSOR_HEIGHT];
};
} }
}

View File

@@ -20,7 +20,7 @@
using namespace OpenRCT2::Drawing;
namespace OpenRCT2 { namespace Ui
namespace OpenRCT2::Ui
{
/**
* Represents the window or screen that OpenRCT2 is presented on.
@@ -96,4 +96,4 @@ namespace OpenRCT2 { namespace Ui
{
return new DummyUiContext();
}
} }
}

View File

@@ -16,7 +16,7 @@
#include "WindowManager.h"
namespace OpenRCT2 { namespace Ui
namespace OpenRCT2::Ui
{
class DummyWindowManager final : public IWindowManager
{
@@ -38,4 +38,4 @@ namespace OpenRCT2 { namespace Ui
{
return new DummyWindowManager();
}
} }
}

View File

@@ -22,30 +22,27 @@
#include "../interface/Window.h"
namespace OpenRCT2
namespace OpenRCT2::Ui
{
namespace Ui
/**
* Manager of in-game windows and widgets.
*/
interface IWindowManager
{
/**
* Manager of in-game windows and widgets.
*/
interface IWindowManager
{
virtual ~IWindowManager() = default;
virtual void Init() abstract;
virtual rct_window * OpenWindow(rct_windowclass wc) abstract;
virtual rct_window * OpenView(uint8 view) abstract;
virtual rct_window * OpenDetails(uint8 type, sint32 id) abstract;
virtual rct_window * OpenIntent(Intent * intent) abstract;
virtual void BroadcastIntent(const Intent &intent) abstract;
virtual rct_window * ShowError(rct_string_id title, rct_string_id message) abstract;
virtual void ForceClose(rct_windowclass windowClass) abstract;
virtual void UpdateMapTooltip() abstract;
virtual void HandleInput() abstract;
virtual void HandleKeyboard(bool isTitle) abstract;
virtual std::string GetKeyboardShortcutString(sint32 shortcut) abstract;
};
virtual ~IWindowManager() = default;
virtual void Init() abstract;
virtual rct_window * OpenWindow(rct_windowclass wc) abstract;
virtual rct_window * OpenView(uint8 view) abstract;
virtual rct_window * OpenDetails(uint8 type, sint32 id) abstract;
virtual rct_window * OpenIntent(Intent * intent) abstract;
virtual void BroadcastIntent(const Intent &intent) abstract;
virtual rct_window * ShowError(rct_string_id title, rct_string_id message) abstract;
virtual void ForceClose(rct_windowclass windowClass) abstract;
virtual void UpdateMapTooltip() abstract;
virtual void HandleInput() abstract;
virtual void HandleKeyboard(bool isTitle) abstract;
virtual std::string GetKeyboardShortcutString(sint32 shortcut) abstract;
};
IWindowManager * CreateDummyWindowManager();
}
IWindowManager * CreateDummyWindowManager();
}