Browse code

Add override keyword.

Naram Qashat authored on 2021/03/30 01:29:32
Showing 1 changed files
... ...
@@ -26,10 +26,10 @@ protected:
26 26
 
27 27
 	XSFConfigIO_Winamp();
28 28
 public:
29
-	void SetValueString(const std::string &name, const std::string &value);
30
-	std::string GetValueString(const std::string &name, const std::string &defaultValue) const;
31
-	void SetHInstance(HINSTANCE hInstance);
32
-	HINSTANCE GetHInstance() const;
29
+	void SetValueString(const std::string &name, const std::string &value) override;
30
+	std::string GetValueString(const std::string &name, const std::string &defaultValue) const override;
31
+	void SetHInstance(HINSTANCE hInstance) override;
32
+	HINSTANCE GetHInstance() const override;
33 33
 };
34 34
 
35 35
 XSFConfigIO *XSFConfigIO::Create()
Browse code

Various changes:

* Use enum class instead of enum (except for the enums for the resource IDs, not really necessary there).
* For NCSF specifically, included a function to convert an enum class to its underlying integral type (as this is needed for use with the std::bitset class).
* Cleanup headers so all the ones needed in a file are explicitly included even if they may possibly be included in another header.
* Used forward declarations in a few spots.
* Explicitly namespaced all (u)int*_t uses (this might seem like overkill, but it helps me see when the standard types are being used with a simple search for std::).
* Made sure it all builds with MinGW-w64 as well (both gcc and clang).
* Removed some std::move from DialogBuilder.cpp based on clang's warnings for that.
* Replaced use of std::copy_n on strings in DialogBuilder.cpp with my CopyToString functions that use wcscpy.
* Replaced CHAR_MIN/CHAR_MAX in eqstr.h and ltstr.h with std::numeric_limits<char>::min/max().

Naram Qashat authored on 2021/03/21 03:16:45
Showing 1 changed files
... ...
@@ -6,8 +6,12 @@
6 6
  */
7 7
 
8 8
 #include <filesystem>
9
+#include <stdexcept>
10
+#include <string>
11
+#include <vector>
12
+#include "windowsh_wrapper.h"
9 13
 #include "XSFConfig.h"
10
-#include "XSFCommon.h"
14
+#include "convert.h"
11 15
 #include "winamp/in2.h"
12 16
 #include "winamp/wa_ipc.h"
13 17
 
Browse code

Use C++17 std::filesystem functions instead of my own.

Naram Qashat authored on 2021/03/20 20:05:50
Showing 1 changed files
... ...
@@ -5,6 +5,7 @@
5 5
  * Partially based on the vio*sf framework
6 6
  */
7 7
 
8
+#include <filesystem>
8 9
 #include "XSFConfig.h"
9 10
 #include "XSFCommon.h"
10 11
 #include "winamp/in2.h"
... ...
@@ -50,7 +51,7 @@ XSFConfigIO_Winamp::XSFConfigIO_Winamp() : iniFilename(L"")
50 51
 		if (!result)
51 52
 			throw std::runtime_error("Unable to get path to plugin.");
52 53
 
53
-		this->iniFilename = ExtractDirectoryFromPath(std::wstring(executablePath.begin(), executablePath.begin() + result)) + L"plugins.ini";
54
+		this->iniFilename = (std::filesystem::path(std::wstring(executablePath.begin(), executablePath.begin() + result)).parent_path() / L"plugins.ini").wstring();
54 55
 	}
55 56
 }
56 57
 
Browse code

Remove last modification date from files.

(I never remember to update these and besides, GitHub history can show when they were last modified.)

Naram Qashat authored on 2021/03/19 10:58:12
Showing 1 changed files
... ...
@@ -1,7 +1,6 @@
1 1
 /*
2 2
  * xSF - Winamp-specification configuration handler
3 3
  * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
- * Last modification on 2014-10-05
5 4
  *
6 5
  * Partially based on the vio*sf framework
7 6
  */
Browse code

update for C++17 compliance, update to latest 2sf, add WINE cross-compile makefiles

Adam Higerd authored on 2021/02/11 15:36:17
Showing 1 changed files
... ...
@@ -8,8 +8,8 @@
8 8
 
9 9
 #include "XSFConfig.h"
10 10
 #include "XSFCommon.h"
11
-#include <winamp/in2.h>
12
-#include <winamp/wa_ipc.h>
11
+#include "winamp/in2.h"
12
+#include "winamp/wa_ipc.h"
13 13
 
14 14
 extern In_Module inMod;
15 15
 
Browse code

[NCSF] Fix volume issues with a little help from the Nintendo DS SDK.

Also added a clone of DeSmuME's Sound View that is only build during a
debug build, which helped to identify the above issues.

Naram Qashat authored on 2014/10/05 20:00:09
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * xSF - Winamp-specification configuration handler
3 3
  * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
- * Last modification on 2014-09-24
4
+ * Last modification on 2014-10-05
5 5
  *
6 6
  * Partially based on the vio*sf framework
7 7
  */
... ...
@@ -18,11 +18,14 @@ class XSFConfigIO_Winamp : public XSFConfigIO
18 18
 protected:
19 19
 	friend class XSFConfigIO;
20 20
 	std::wstring iniFilename;
21
+	HINSTANCE hInst;
21 22
 
22 23
 	XSFConfigIO_Winamp();
23 24
 public:
24 25
 	void SetValueString(const std::string &name, const std::string &value);
25
-	std::string GetValueString(const std::string &name, const std::string &defaultValue);
26
+	std::string GetValueString(const std::string &name, const std::string &defaultValue) const;
27
+	void SetHInstance(HINSTANCE hInstance);
28
+	HINSTANCE GetHInstance() const;
26 29
 };
27 30
 
28 31
 XSFConfigIO *XSFConfigIO::Create()
... ...
@@ -57,7 +60,7 @@ void XSFConfigIO_Winamp::SetValueString(const std::string &name, const std::stri
57 60
 	WritePrivateProfileStringW(ConvertFuncs::StringToWString(XSFConfig::commonName).c_str(), ConvertFuncs::StringToWString(name).c_str(), ConvertFuncs::StringToWString(value).c_str(), this->iniFilename.c_str());
58 61
 }
59 62
 
60
-std::string XSFConfigIO_Winamp::GetValueString(const std::string &name, const std::string &defaultValue)
63
+std::string XSFConfigIO_Winamp::GetValueString(const std::string &name, const std::string &defaultValue) const
61 64
 {
62 65
 	auto value = std::vector<wchar_t>(MAX_PATH / 2);
63 66
 
... ...
@@ -73,3 +76,13 @@ std::string XSFConfigIO_Winamp::GetValueString(const std::string &name, const st
73 76
 
74 77
 	return ConvertFuncs::WStringToString(std::wstring(value.begin(), value.begin() + result));
75 78
 }
79
+
80
+void XSFConfigIO_Winamp::SetHInstance(HINSTANCE hInstance)
81
+{
82
+	this->hInst = hInstance;
83
+}
84
+
85
+HINSTANCE XSFConfigIO_Winamp::GetHInstance() const
86
+{
87
+	return this->hInst;
88
+}
Browse code

Lots of changes in regards to strings, as follows:

* Removed my custom String class, as well as removed the really old
Unicode ConvertUTF, the UTF Converter, and the UTF Encode/Decode
functions.
* Replaced the above with using standard C++ std::wstring_convert and
std::codecvt_utf8.
* Added headers adapted from llvm's libc++ project for allowing the
above C++ classes to exist with GCC and Clang when libc++ isn't being
used.
* Used std::string over std::wstring whenever possible.
* Added header adapted from llvm's libc++ project to create special
versions of the ifstream and ofstream classes that would utilize _wfopen
on non-MSVC Windows compilers, so those compilers could access files on
Windows that use characters outside the current codepage.
* Removed the -static-libgcc and -static-libstdc++ flags from the
Makefile for non-MSVC builds. The generated DLLs will require extra DLLs
from either Cygwin or MinGW (whichever is used to compile), I've only
tested with MinGW and for some reason they crash Winamp on exit, I have
no idea why.

Naram Qashat authored on 2014/09/24 13:58:55
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * xSF - Winamp-specification configuration handler
3 3
  * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
- * Last modification on 2013-04-23
4
+ * Last modification on 2014-09-24
5 5
  *
6 6
  * Partially based on the vio*sf framework
7 7
  */
... ...
@@ -21,8 +21,8 @@ protected:
21 21
 
22 22
 	XSFConfigIO_Winamp();
23 23
 public:
24
-	void SetValueString(const std::wstring &name, const std::wstring &value);
25
-	std::wstring GetValueString(const std::wstring &name, const std::wstring &defaultValue);
24
+	void SetValueString(const std::string &name, const std::string &value);
25
+	std::string GetValueString(const std::string &name, const std::string &defaultValue);
26 26
 };
27 27
 
28 28
 XSFConfigIO *XSFConfigIO::Create()
... ...
@@ -33,7 +33,7 @@ XSFConfigIO *XSFConfigIO::Create()
33 33
 XSFConfigIO_Winamp::XSFConfigIO_Winamp() : iniFilename(L"")
34 34
 {
35 35
 	if (SendMessage(inMod.hMainWindow, WM_WA_IPC, 0, IPC_GETVERSION) >= 0x2900)
36
-		this->iniFilename = String(reinterpret_cast<char *>(SendMessage(inMod.hMainWindow, WM_WA_IPC, 0, IPC_GETINIFILE))).GetWStr();
36
+		this->iniFilename = ConvertFuncs::StringToWString(reinterpret_cast<char *>(SendMessage(inMod.hMainWindow, WM_WA_IPC, 0, IPC_GETINIFILE)));
37 37
 	else
38 38
 	{
39 39
 		auto executablePath = std::vector<wchar_t>(MAX_PATH / 2);
... ...
@@ -52,12 +52,12 @@ XSFConfigIO_Winamp::XSFConfigIO_Winamp() : iniFilename(L"")
52 52
 	}
53 53
 }
54 54
 
55
-void XSFConfigIO_Winamp::SetValueString(const std::wstring &name, const std::wstring &value)
55
+void XSFConfigIO_Winamp::SetValueString(const std::string &name, const std::string &value)
56 56
 {
57
-	WritePrivateProfileStringW(XSFConfig::commonName.c_str(), name.c_str(), value.c_str(), this->iniFilename.c_str());
57
+	WritePrivateProfileStringW(ConvertFuncs::StringToWString(XSFConfig::commonName).c_str(), ConvertFuncs::StringToWString(name).c_str(), ConvertFuncs::StringToWString(value).c_str(), this->iniFilename.c_str());
58 58
 }
59 59
 
60
-std::wstring XSFConfigIO_Winamp::GetValueString(const std::wstring &name, const std::wstring &defaultValue)
60
+std::string XSFConfigIO_Winamp::GetValueString(const std::string &name, const std::string &defaultValue)
61 61
 {
62 62
 	auto value = std::vector<wchar_t>(MAX_PATH / 2);
63 63
 
... ...
@@ -65,11 +65,11 @@ std::wstring XSFConfigIO_Winamp::GetValueString(const std::wstring &name, const
65 65
 	do
66 66
 	{
67 67
 		value.resize(value.size() * 2);
68
-		result = GetPrivateProfileStringW(XSFConfig::commonName.c_str(), name.c_str(), defaultValue.c_str(), &value[0], value.size(), this->iniFilename.c_str());
68
+		result = GetPrivateProfileStringW(ConvertFuncs::StringToWString(XSFConfig::commonName).c_str(), ConvertFuncs::StringToWString(name).c_str(), ConvertFuncs::StringToWString(defaultValue).c_str(), &value[0], value.size(), this->iniFilename.c_str());
69 69
 	} while (result + 1 == value.size());
70 70
 
71 71
 	if (!result)
72 72
 		throw std::runtime_error("Unable to get value from INI file.");
73 73
 
74
-	return std::wstring(value.begin(), value.begin() + result);
74
+	return ConvertFuncs::WStringToString(std::wstring(value.begin(), value.begin() + result));
75 75
 }
Browse code

Added Lanczos interpolation to the NCSF plugin, and cleaned up a bit of the other code, as well as removing pstdint.h since it's no longer needed.

Naram Qashat authored on 2013/04/23 20:29:21
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * xSF - Winamp-specification configuration handler
3 3
  * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
- * Last modification on 2013-03-30
4
+ * Last modification on 2013-04-23
5 5
  *
6 6
  * Partially based on the vio*sf framework
7 7
  */
... ...
@@ -36,7 +36,7 @@ XSFConfigIO_Winamp::XSFConfigIO_Winamp() : iniFilename(L"")
36 36
 		this->iniFilename = String(reinterpret_cast<char *>(SendMessage(inMod.hMainWindow, WM_WA_IPC, 0, IPC_GETINIFILE))).GetWStr();
37 37
 	else
38 38
 	{
39
-		std::vector<wchar_t> executablePath(MAX_PATH / 2);
39
+		auto executablePath = std::vector<wchar_t>(MAX_PATH / 2);
40 40
 
41 41
 		DWORD result;
42 42
 		do
... ...
@@ -59,7 +59,7 @@ void XSFConfigIO_Winamp::SetValueString(const std::wstring &name, const std::wst
59 59
 
60 60
 std::wstring XSFConfigIO_Winamp::GetValueString(const std::wstring &name, const std::wstring &defaultValue)
61 61
 {
62
-	std::vector<wchar_t> value(MAX_PATH / 2);
62
+	auto value = std::vector<wchar_t>(MAX_PATH / 2);
63 63
 
64 64
 	DWORD result;
65 65
 	do
Browse code

Cleanup of some warnings, updating modification dates, using nullptr instead of NULL in some cases.

Naram Qashat authored on 2013/03/30 16:17:42
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * xSF - Winamp-specification configuration handler
3 3
  * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
- * Last modification on 2013-03-21
4
+ * Last modification on 2013-03-30
5 5
  *
6 6
  * Partially based on the vio*sf framework
7 7
  */
... ...
@@ -42,7 +42,7 @@ XSFConfigIO_Winamp::XSFConfigIO_Winamp() : iniFilename(L"")
42 42
 		do
43 43
 		{
44 44
 			executablePath.resize(executablePath.size() * 2);
45
-			result = GetModuleFileNameW(NULL, &executablePath[0], executablePath.size());
45
+			result = GetModuleFileNameW(nullptr, &executablePath[0], executablePath.size());
46 46
 		} while (result == executablePath.size());
47 47
 
48 48
 		if (!result)
Browse code

Import actual code.

Naram Qashat authored on 2013/03/26 02:41:19
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,75 @@
1
+/*
2
+ * xSF - Winamp-specification configuration handler
3
+ * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
+ * Last modification on 2013-03-21
5
+ *
6
+ * Partially based on the vio*sf framework
7
+ */
8
+
9
+#include "XSFConfig.h"
10
+#include "XSFCommon.h"
11
+#include <winamp/in2.h>
12
+#include <winamp/wa_ipc.h>
13
+
14
+extern In_Module inMod;
15
+
16
+class XSFConfigIO_Winamp : public XSFConfigIO
17
+{
18
+protected:
19
+	friend class XSFConfigIO;
20
+	std::wstring iniFilename;
21
+
22
+	XSFConfigIO_Winamp();
23
+public:
24
+	void SetValueString(const std::wstring &name, const std::wstring &value);
25
+	std::wstring GetValueString(const std::wstring &name, const std::wstring &defaultValue);
26
+};
27
+
28
+XSFConfigIO *XSFConfigIO::Create()
29
+{
30
+	return new XSFConfigIO_Winamp();
31
+}
32
+
33
+XSFConfigIO_Winamp::XSFConfigIO_Winamp() : iniFilename(L"")
34
+{
35
+	if (SendMessage(inMod.hMainWindow, WM_WA_IPC, 0, IPC_GETVERSION) >= 0x2900)
36
+		this->iniFilename = String(reinterpret_cast<char *>(SendMessage(inMod.hMainWindow, WM_WA_IPC, 0, IPC_GETINIFILE))).GetWStr();
37
+	else
38
+	{
39
+		std::vector<wchar_t> executablePath(MAX_PATH / 2);
40
+
41
+		DWORD result;
42
+		do
43
+		{
44
+			executablePath.resize(executablePath.size() * 2);
45
+			result = GetModuleFileNameW(NULL, &executablePath[0], executablePath.size());
46
+		} while (result == executablePath.size());
47
+
48
+		if (!result)
49
+			throw std::runtime_error("Unable to get path to plugin.");
50
+
51
+		this->iniFilename = ExtractDirectoryFromPath(std::wstring(executablePath.begin(), executablePath.begin() + result)) + L"plugins.ini";
52
+	}
53
+}
54
+
55
+void XSFConfigIO_Winamp::SetValueString(const std::wstring &name, const std::wstring &value)
56
+{
57
+	WritePrivateProfileStringW(XSFConfig::commonName.c_str(), name.c_str(), value.c_str(), this->iniFilename.c_str());
58
+}
59
+
60
+std::wstring XSFConfigIO_Winamp::GetValueString(const std::wstring &name, const std::wstring &defaultValue)
61
+{
62
+	std::vector<wchar_t> value(MAX_PATH / 2);
63
+
64
+	DWORD result;
65
+	do
66
+	{
67
+		value.resize(value.size() * 2);
68
+		result = GetPrivateProfileStringW(XSFConfig::commonName.c_str(), name.c_str(), defaultValue.c_str(), &value[0], value.size(), this->iniFilename.c_str());
69
+	} while (result + 1 == value.size());
70
+
71
+	if (!result)
72
+		throw std::runtime_error("Unable to get value from INI file.");
73
+
74
+	return std::wstring(value.begin(), value.begin() + result);
75
+}