Skip to content
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
6 changes: 6 additions & 0 deletions MakeSpriteFont/CommandLineParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class CommandLineParser
List<string> requiredUsageHelp = new List<string>();
List<string> optionalUsageHelp = new List<string>();

private const string feedbackURL = "https://github.com/microsoft/DirectXTK/issues";

// Constructor.
public CommandLineParser(object optionsObject)
Expand Down Expand Up @@ -127,6 +128,11 @@ bool ParseArgument(string arg)

return SetOption(field, value);
}
else if (arg.Equals("feedback", StringComparison.OrdinalIgnoreCase))
{
System.Diagnostics.Process.Start(feedbackURL);
return false;
}
else
{
// Parse a required argument.
Expand Down
14 changes: 7 additions & 7 deletions XWBTool/CmdLineHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace Helpers
};

template<typename T>
T LookupByName(const wchar_t _In_z_ *pName, const SValue<T> *pArray)
T LookupByName(const wchar_t _In_z_ *pName, const SValue<T> *pArray) noexcept
{
while (pArray->name)
{
Expand All @@ -72,7 +72,7 @@ namespace Helpers
}

template<typename T>
const wchar_t* LookupByValue(T value, const SValue<T> *pArray)
const wchar_t* LookupByValue(T value, const SValue<T> *pArray) noexcept
{
while (pArray->name)
{
Expand All @@ -85,7 +85,7 @@ namespace Helpers
return L"";
}

void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList)
void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList) noexcept
{
for (auto pFormat = pFormatList; pFormat->name; pFormat++)
{
Expand All @@ -99,7 +99,7 @@ namespace Helpers
wprintf(L"*UNKNOWN*");
}

void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList1, const SValue<DXGI_FORMAT>* pFormatList2)
void PrintFormat(DXGI_FORMAT Format, const SValue<DXGI_FORMAT>* pFormatList1, const SValue<DXGI_FORMAT>* pFormatList2) noexcept
{
for (auto pFormat = pFormatList1; pFormat->name; pFormat++)
{
Expand All @@ -123,7 +123,7 @@ namespace Helpers
}

template<typename T>
void PrintList(size_t cch, const SValue<T> *pValue)
void PrintList(size_t cch, const SValue<T> *pValue) noexcept
{
while (pValue->name)
{
Expand All @@ -143,7 +143,7 @@ namespace Helpers
wprintf(L"\n");
}

void PrintLogo(bool versionOnly, _In_z_ const wchar_t* name, _In_z_ const wchar_t* desc)
void PrintLogo(bool versionOnly, _In_z_ const wchar_t* name, _In_z_ const wchar_t* desc) noexcept
{
wchar_t version[32] = {};

Expand Down Expand Up @@ -336,7 +336,7 @@ namespace Helpers
}
}

const wchar_t* GetErrorDesc(HRESULT hr)
const wchar_t* GetErrorDesc(HRESULT hr) noexcept
{
static wchar_t desc[1024] = {};

Expand Down
51 changes: 39 additions & 12 deletions XWBTool/xwbtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@

#include "WAVFileReader.h"

#include <shellapi.h>

#define TOOL_VERSION 0
#include "CmdLineHelpers.h"

Expand Down Expand Up @@ -270,14 +272,14 @@ namespace
static_assert(sizeof(ENTRYCOMPACT) == 4, "Mismatch with xact3wb.h");
static_assert(sizeof(BANKDATA) == 96, "Mismatch with xact3wb.h");

template <typename T> WORD ChannelsSpecifiedInMask(T x)
template <typename T> WORD ChannelsSpecifiedInMask(T x) noexcept
{
WORD bitCount = 0;
while (x) { ++bitCount; x &= (x - 1); }
return bitCount;
}

WORD AdpcmBlockSizeFromPcmFrames(WORD nPcmFrames, WORD nChannels)
WORD AdpcmBlockSizeFromPcmFrames(WORD nPcmFrames, WORD nChannels) noexcept
{
// The full calculation is as follows:
// UINT uHeaderBytes = MSADPCM_HEADER_LENGTH * nChannels;
Expand Down Expand Up @@ -305,7 +307,7 @@ namespace
}
}

DWORD EncodeWMABlockAlign(DWORD dwBlockAlign, DWORD dwAvgBytesPerSec)
DWORD EncodeWMABlockAlign(DWORD dwBlockAlign, DWORD dwAvgBytesPerSec) noexcept
{
static const uint32_t aWMABlockAlign[17] =
{
Expand Down Expand Up @@ -354,7 +356,7 @@ namespace
return DWORD(blockAlignIndex | (bytesPerSecIndex << 5));
}

bool ConvertToMiniFormat(const WAVEFORMATEX* wfx, bool hasSeek, MINIWAVEFORMAT& miniFmt)
bool ConvertToMiniFormat(const WAVEFORMATEX* wfx, bool hasSeek, MINIWAVEFORMAT& miniFmt) noexcept
{
if (!wfx)
return false;
Expand Down Expand Up @@ -787,6 +789,7 @@ namespace

const wchar_t* g_ToolName = L"xwbtool";
const wchar_t* g_Description = L"Microsoft (R) XACT-style Wave Bank Tool [DirectXTK]";
const wchar_t* g_FeedbackURL = L"https://github.com/microsoft/DirectXTK/issues";

enum OPTIONS : uint32_t
{
Expand Down Expand Up @@ -828,7 +831,7 @@ namespace
WaveFile(WaveFile&&) = default;
};

void FileNameToIdentifier(_Inout_updates_all_(count) wchar_t* str, size_t count)
void FileNameToIdentifier(_Inout_updates_all_(count) wchar_t* str, size_t count) noexcept
{
size_t j = 0;
for (wchar_t* c = str; j < count && *c != 0; ++c, ++j)
Expand Down Expand Up @@ -880,13 +883,14 @@ namespace
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

void PrintUsage()
void PrintUsage(bool full = false) noexcept
{
PrintLogo(false, g_ToolName, g_Description);

static const wchar_t* const s_usage =
L"Usage: xwbtool <options> [--] <wav-files>\n"
L"\n"
L"Usage: xwbtool <options> [--] <wav-files>\n\n";

static const wchar_t* const s_fullUsage =
L" -r wildcard filename search is recursive\n"
L" -flist <filename>, --file-list <filename>\n"
L" use text file with a list of input files (one per line)\n"
Expand All @@ -909,9 +913,14 @@ namespace
L" '-- ' is needed if any input filepath starts with the '-' or '/' character\n";

wprintf(L"%ls", s_usage);

if (!full)
return;

wprintf(L"%ls", s_fullUsage);
}

const char* GetFormatTagName(WORD wFormatTag)
const char* GetFormatTagName(WORD wFormatTag) noexcept
{
switch (wFormatTag)
{
Expand All @@ -930,7 +939,7 @@ namespace
}
}

const char *ChannelDesc(DWORD dwChannelMask)
const char *ChannelDesc(DWORD dwChannelMask) noexcept
{
switch (dwChannelMask)
{
Expand All @@ -948,7 +957,7 @@ namespace
}
}

void PrintInfo(const WaveFile& wave)
void PrintInfo(const WaveFile& wave) noexcept
{
if (wave.data.wfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE
&& (wave.data.wfx->cbSize >= (sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))))
Expand Down Expand Up @@ -985,6 +994,24 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
std::locale::global(std::locale(""));

// Process command line
if (argc < 2)
{
PrintUsage();
return 0;
}

// check for these first
if (!_wcsicmp(argv[1], L"help") || !_wcsicmp(argv[1], L"/?"))
{
PrintUsage(true);
return 0;
}
else if (!_wcsicmp(argv[1], L"feedback"))
{
std::ignore = ShellExecuteW(nullptr, L"open", g_FeedbackURL, nullptr, nullptr, SW_SHOW);
return 0;
}

uint32_t dwOptions = 0;
std::list<SConversion> conversion;
bool allowOpts = true;
Expand Down Expand Up @@ -1056,7 +1083,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 0;

case OPT_HELP:
PrintUsage();
PrintUsage(true);
return 0;

default:
Expand Down
Loading