mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-30 04:40:53 +00:00
Changed: #927 Move OS specific code from client or server to NeL when it's possible
This commit is contained in:
parent
6f19195c68
commit
fb1e8559b1
11 changed files with 470 additions and 344 deletions
|
@ -44,6 +44,39 @@ public:
|
||||||
|
|
||||||
/// Create/update a progress bar with an appearance depending on system.
|
/// Create/update a progress bar with an appearance depending on system.
|
||||||
static bool updateProgressBar(uint value, uint total);
|
static bool updateProgressBar(uint value, uint total);
|
||||||
|
|
||||||
|
/// Copy a string to system clipboard.
|
||||||
|
static bool copyTextToClipboard(const ucstring &text);
|
||||||
|
|
||||||
|
/// Paste a string from system clipboard.
|
||||||
|
static bool pasteTextFromClipboard(ucstring &text);
|
||||||
|
|
||||||
|
/// Check if system supports unicode.
|
||||||
|
static bool supportUnicode();
|
||||||
|
|
||||||
|
/// Check if keyboard layout is AZERTY.
|
||||||
|
static bool isAzertyKeyboard();
|
||||||
|
|
||||||
|
/// Check if screensaver is enabled.
|
||||||
|
static bool isScreensaverEnabled();
|
||||||
|
|
||||||
|
/// Enable or disable screeensaver.
|
||||||
|
static bool enableScreensaver(bool screensaver);
|
||||||
|
|
||||||
|
/// Get the ROOT registry key used by getRegKey and setRegKey.
|
||||||
|
static std::string getRootKey();
|
||||||
|
|
||||||
|
/// Set the ROOT registry key used by getRegKey and setRegKey.
|
||||||
|
static void setRootKey(const std::string &root);
|
||||||
|
|
||||||
|
/// Read a value from registry.
|
||||||
|
static std::string getRegKey(const std::string &Entry);
|
||||||
|
|
||||||
|
/// Write a value to registry.
|
||||||
|
static bool setRegKey(const std::string &ValueName, const std::string &Value);
|
||||||
|
|
||||||
|
/// Get desktop current color depth without using UDriver.
|
||||||
|
static uint getCurrentColorDepth();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // NLMISC
|
} // NLMISC
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "nel/misc/path.h"
|
#include "nel/misc/path.h"
|
||||||
#include "nel/misc/mutex.h"
|
#include "nel/misc/mutex.h"
|
||||||
#include "nel/misc/report.h"
|
#include "nel/misc/report.h"
|
||||||
|
#include "nel/misc/system_utils.h"
|
||||||
|
|
||||||
#include "nel/misc/debug.h"
|
#include "nel/misc/debug.h"
|
||||||
|
|
||||||
|
@ -568,19 +569,7 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m
|
||||||
|
|
||||||
str += message;
|
str += message;
|
||||||
|
|
||||||
if (OpenClipboard (NULL))
|
CSystemUtils::copyTextToClipboard(str);
|
||||||
{
|
|
||||||
HGLOBAL mem = GlobalAlloc (GHND|GMEM_DDESHARE, str.size()+1);
|
|
||||||
if (mem)
|
|
||||||
{
|
|
||||||
char *pmem = (char *)GlobalLock (mem);
|
|
||||||
strcpy (pmem, str.c_str());
|
|
||||||
GlobalUnlock (mem);
|
|
||||||
EmptyClipboard ();
|
|
||||||
SetClipboardData (CF_TEXT, mem);
|
|
||||||
}
|
|
||||||
CloseClipboard ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the string on the screen
|
// create the string on the screen
|
||||||
needSpace = false;
|
needSpace = false;
|
||||||
|
@ -758,19 +747,7 @@ void CMsgBoxDisplayer::display (const std::string& str)
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
|
|
||||||
if (OpenClipboard (NULL))
|
CSystemUtils::copyTextToClipboard(str);
|
||||||
{
|
|
||||||
HGLOBAL mem = GlobalAlloc (GHND|GMEM_DDESHARE, str.size()+1);
|
|
||||||
if (mem)
|
|
||||||
{
|
|
||||||
char *pmem = (char *)GlobalLock (mem);
|
|
||||||
strcpy (pmem, str.c_str());
|
|
||||||
GlobalUnlock (mem);
|
|
||||||
EmptyClipboard ();
|
|
||||||
SetClipboardData (CF_TEXT, mem);
|
|
||||||
}
|
|
||||||
CloseClipboard ();
|
|
||||||
}
|
|
||||||
|
|
||||||
string strf = str;
|
string strf = str;
|
||||||
strf += "\n\n(this message was copied in the clipboard)";
|
strf += "\n\n(this message was copied in the clipboard)";
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
// Key in registry
|
||||||
|
static string RootKey;
|
||||||
|
static const uint32 KeyMaxLength = 1024;
|
||||||
|
|
||||||
namespace NLMISC {
|
namespace NLMISC {
|
||||||
|
|
||||||
void *CSystemUtils::s_window = NULL;
|
void *CSystemUtils::s_window = NULL;
|
||||||
|
@ -95,4 +99,254 @@ bool CSystemUtils::updateProgressBar(uint value, uint total)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSystemUtils::copyTextToClipboard(const ucstring &text)
|
||||||
|
{
|
||||||
|
if (!text.size()) return false;
|
||||||
|
|
||||||
|
bool res = false;
|
||||||
|
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
if (OpenClipboard(NULL))
|
||||||
|
{
|
||||||
|
// check if unicode format is supported by clipboard
|
||||||
|
bool isUnicode = (IsClipboardFormatAvailable(CF_UNICODETEXT) == TRUE);
|
||||||
|
|
||||||
|
// allocates a buffer to copy text in global memory
|
||||||
|
HGLOBAL mem = GlobalAlloc(GHND|GMEM_DDESHARE, (text.size()+1) * (isUnicode ? 2:1));
|
||||||
|
|
||||||
|
if (mem)
|
||||||
|
{
|
||||||
|
// create a lock on this buffer
|
||||||
|
void *hLock = GlobalLock(mem);
|
||||||
|
|
||||||
|
// copy text to this buffer
|
||||||
|
if (isUnicode)
|
||||||
|
wcscpy((wchar_t*)hLock, (const wchar_t*)text.c_str());
|
||||||
|
else
|
||||||
|
strcpy((char*)hLock, text.toString().c_str());
|
||||||
|
|
||||||
|
// unlock buffer
|
||||||
|
GlobalUnlock(mem);
|
||||||
|
|
||||||
|
// empty clipboard
|
||||||
|
EmptyClipboard();
|
||||||
|
|
||||||
|
// set new data to clipboard in the right format
|
||||||
|
SetClipboardData(isUnicode ? CF_UNICODETEXT:CF_TEXT, mem);
|
||||||
|
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseClipboard();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSystemUtils::pasteTextFromClipboard(ucstring &text)
|
||||||
|
{
|
||||||
|
bool res = false;
|
||||||
|
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
if (OpenClipboard(NULL))
|
||||||
|
{
|
||||||
|
// check if unicode format is supported by clipboard
|
||||||
|
bool isUnicode = (IsClipboardFormatAvailable(CF_UNICODETEXT) == TRUE);
|
||||||
|
|
||||||
|
// get data from clipboard (if not of this type, they are converted)
|
||||||
|
// warning, this code can't be debuggued in VC++ IDE, hObj will be always NULL
|
||||||
|
HANDLE hObj = GetClipboardData(isUnicode ? CF_UNICODETEXT:CF_TEXT);
|
||||||
|
|
||||||
|
if (hObj)
|
||||||
|
{
|
||||||
|
// create a lock on clipboard data
|
||||||
|
void *hLock = GlobalLock(hObj);
|
||||||
|
|
||||||
|
if (hLock != NULL)
|
||||||
|
{
|
||||||
|
// retrieve clipboard data
|
||||||
|
if (isUnicode)
|
||||||
|
text = (const ucchar*)hLock;
|
||||||
|
else
|
||||||
|
text = (const char*)hLock;
|
||||||
|
|
||||||
|
// unlock data
|
||||||
|
GlobalUnlock(hObj);
|
||||||
|
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseClipboard();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSystemUtils::supportUnicode()
|
||||||
|
{
|
||||||
|
static bool init = false;
|
||||||
|
static bool unicodeSupported = false;
|
||||||
|
if (!init)
|
||||||
|
{
|
||||||
|
init = true;
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
OSVERSIONINFO osvi;
|
||||||
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
|
|
||||||
|
// get Windows version
|
||||||
|
if (GetVersionEx(&osvi))
|
||||||
|
{
|
||||||
|
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||||
|
{
|
||||||
|
// unicode is supported since Windows NT 4.0
|
||||||
|
if (osvi.dwMajorVersion >= 4)
|
||||||
|
{
|
||||||
|
unicodeSupported = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
unicodeSupported = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return unicodeSupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSystemUtils::isAzertyKeyboard()
|
||||||
|
{
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
uint16 klId = uint16((uint32)GetKeyboardLayout(0) & 0xFFFF);
|
||||||
|
// 0x040c is French, 0x080c is Belgian
|
||||||
|
if (klId == 0x040c || klId == 0x080c)
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSystemUtils::isScreensaverEnabled()
|
||||||
|
{
|
||||||
|
bool res = false;
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
// old code, is not working anymore
|
||||||
|
// BOOL bRetValue;
|
||||||
|
// SystemParametersInfoA(SPI_GETSCREENSAVEACTIVE, 0, &bRetValue, 0);
|
||||||
|
// res = (bRetValue == TRUE);
|
||||||
|
HKEY hKeyScreenSaver = NULL;
|
||||||
|
LSTATUS lReturn = RegOpenKeyExA(HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop"), 0, KEY_QUERY_VALUE, &hKeyScreenSaver);
|
||||||
|
if (lReturn == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
DWORD dwType = 0L;
|
||||||
|
DWORD dwSize = KeyMaxLength;
|
||||||
|
unsigned char Buffer[KeyMaxLength] = {0};
|
||||||
|
|
||||||
|
lReturn = RegQueryValueExA(hKeyScreenSaver, TEXT("SCRNSAVE.EXE"), NULL, &dwType, NULL, &dwSize);
|
||||||
|
// if SCRNSAVE.EXE is present, check also if it's empty
|
||||||
|
if (lReturn == ERROR_SUCCESS)
|
||||||
|
res = (Buffer[0] != '\0');
|
||||||
|
}
|
||||||
|
RegCloseKey(hKeyScreenSaver);
|
||||||
|
#endif
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSystemUtils::enableScreensaver(bool screensaver)
|
||||||
|
{
|
||||||
|
bool res = false;
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
res = (SystemParametersInfoA(SPI_SETSCREENSAVEACTIVE, screensaver ? TRUE:FALSE, NULL, 0) == TRUE);
|
||||||
|
#endif
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CSystemUtils::getRootKey()
|
||||||
|
{
|
||||||
|
return RootKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSystemUtils::setRootKey(const std::string &root)
|
||||||
|
{
|
||||||
|
RootKey = root;
|
||||||
|
}
|
||||||
|
|
||||||
|
string CSystemUtils::getRegKey(const string &Entry)
|
||||||
|
{
|
||||||
|
string ret;
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
HKEY hkey;
|
||||||
|
|
||||||
|
if(RegOpenKeyEx(HKEY_CURRENT_USER, RootKey.c_str(), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
DWORD dwType = 0L;
|
||||||
|
DWORD dwSize = KeyMaxLength;
|
||||||
|
unsigned char Buffer[KeyMaxLength];
|
||||||
|
|
||||||
|
if(RegQueryValueEx(hkey, Entry.c_str(), NULL, &dwType, Buffer, &dwSize) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
nlwarning("Can't get the reg key '%s'", Entry.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = (char*)Buffer;
|
||||||
|
}
|
||||||
|
RegCloseKey(hkey);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nlwarning("Can't get the reg key '%s'", Entry.c_str());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSystemUtils::setRegKey(const string &ValueName, const string &Value)
|
||||||
|
{
|
||||||
|
bool res = false;
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
HKEY hkey;
|
||||||
|
DWORD dwDisp;
|
||||||
|
|
||||||
|
if (RegCreateKeyExA(HKEY_CURRENT_USER, RootKey.c_str(), 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisp) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
if (RegSetValueExA(hkey, ValueName.c_str(), 0L, REG_SZ, (const BYTE *)Value.c_str(), (DWORD)(Value.size())+1) == ERROR_SUCCESS)
|
||||||
|
res = true;
|
||||||
|
RegCloseKey(hkey);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nlwarning("Can't set the reg key '%s' '%s'", ValueName.c_str(), Value.c_str());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint CSystemUtils::getCurrentColorDepth()
|
||||||
|
{
|
||||||
|
uint depth = 0;
|
||||||
|
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
HWND desktopWnd = GetDesktopWindow();
|
||||||
|
if (desktopWnd)
|
||||||
|
{
|
||||||
|
HDC desktopDC = GetWindowDC(desktopWnd);
|
||||||
|
if (desktopDC)
|
||||||
|
{
|
||||||
|
depth = (uint) GetDeviceCaps(desktopDC, BITSPIXEL);
|
||||||
|
ReleaseDC(desktopWnd, desktopDC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
Display *display = XOpenDisplay(NULL);
|
||||||
|
if (display)
|
||||||
|
{
|
||||||
|
depth = (uint) DefaultDepth(display, DefaultScreen(display));
|
||||||
|
XCloseDisplay(display);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
|
||||||
} // NLMISC
|
} // NLMISC
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "nel/misc/path.h"
|
#include "nel/misc/path.h"
|
||||||
#include "nel/misc/time_nl.h"
|
#include "nel/misc/time_nl.h"
|
||||||
#include "nel/misc/algo.h"
|
#include "nel/misc/algo.h"
|
||||||
|
#include "nel/misc/system_utils.h"
|
||||||
// 3D Interface.
|
// 3D Interface.
|
||||||
#include "nel/3d/u_driver.h"
|
#include "nel/3d/u_driver.h"
|
||||||
#include "nel/3d/u_text_context.h"
|
#include "nel/3d/u_text_context.h"
|
||||||
|
@ -2394,14 +2395,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// default to 'ZQSD' for French and Belgian keyboard, 'WASD' else
|
// default to 'ZQSD' for French and Belgian keyboard, 'WASD' else
|
||||||
bool wasd = true;
|
bool wasd = !CSystemUtils::isAzertyKeyboard();
|
||||||
#ifdef NL_OS_WINDOWS
|
|
||||||
uint16 klId = uint16((uint32)GetKeyboardLayout(0) & 0xFFFF);
|
|
||||||
if (klId == 0x040c || klId == 0x080c)
|
|
||||||
{
|
|
||||||
wasd = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*sint startIndex = wasd ? wasdIndex : zqsdIndex;
|
/*sint startIndex = wasd ? wasdIndex : zqsdIndex;
|
||||||
if (startIndex == -1) startIndex = 0;
|
if (startIndex == -1) startIndex = 0;
|
||||||
|
|
|
@ -656,16 +656,11 @@ void prelogInit()
|
||||||
|
|
||||||
set_new_handler(outOfMemory);
|
set_new_handler(outOfMemory);
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
// save screen saver state and disable it
|
||||||
{
|
LastScreenSaverEnabled = CSystemUtils::isScreensaverEnabled();
|
||||||
BOOL bRetValue;
|
|
||||||
SystemParametersInfo (SPI_GETSCREENSAVEACTIVE, 0, &bRetValue, 0);
|
if (LastScreenSaverEnabled)
|
||||||
LastScreenSaverEnabled = (bRetValue == TRUE);
|
CSystemUtils::enableScreensaver(false);
|
||||||
SystemParametersInfo (SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0);
|
|
||||||
}
|
|
||||||
#else // NL_OS_WINDOWS
|
|
||||||
// Not tested, not compiled
|
|
||||||
#endif // NL_OS_WINDOWS
|
|
||||||
|
|
||||||
// Random init
|
// Random init
|
||||||
srand ((uint)CTime::getLocalTime());
|
srand ((uint)CTime::getLocalTime());
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "interface_manager.h"
|
#include "interface_manager.h"
|
||||||
#include "input_handler_manager.h"
|
#include "input_handler_manager.h"
|
||||||
#include "nel/misc/command.h"
|
#include "nel/misc/command.h"
|
||||||
|
#include "nel/misc/system_utils.h"
|
||||||
#include "view_text.h"
|
#include "view_text.h"
|
||||||
#include "game_share/xml_auto_ptr.h"
|
#include "game_share/xml_auto_ptr.h"
|
||||||
#include "interface_options.h"
|
#include "interface_options.h"
|
||||||
|
@ -335,31 +336,11 @@ void CGroupEditBox::copy()
|
||||||
nlwarning("Selection can only be on focus");
|
nlwarning("Selection can only be on focus");
|
||||||
}
|
}
|
||||||
stopParentBlink();
|
stopParentBlink();
|
||||||
// get the selection
|
|
||||||
ucstring selection= getSelection();
|
|
||||||
|
|
||||||
// copy
|
// get the selection and copy it
|
||||||
#ifdef NL_OS_WINDOWS
|
if (CSystemUtils::copyTextToClipboard(getSelection()))
|
||||||
if (selection.size() > 0 && OpenClipboard (NULL))
|
|
||||||
{
|
|
||||||
bool isUnicode = IsClipboardFormatAvailable(CF_UNICODETEXT) == TRUE;
|
|
||||||
HGLOBAL mem = GlobalAlloc (GHND|GMEM_DDESHARE, (selection.size()+1) * (isUnicode ? 2:1));
|
|
||||||
if (mem)
|
|
||||||
{
|
|
||||||
void *hLock = GlobalLock (mem);
|
|
||||||
if (isUnicode)
|
|
||||||
wcscpy ((wchar_t*)hLock, (const wchar_t*)selection.c_str());
|
|
||||||
else
|
|
||||||
strcpy ((char*)hLock, selection.toString().c_str());
|
|
||||||
GlobalUnlock (mem);
|
|
||||||
EmptyClipboard ();
|
|
||||||
SetClipboardData (isUnicode ? CF_UNICODETEXT:CF_TEXT, mem);
|
|
||||||
}
|
|
||||||
CloseClipboard ();
|
|
||||||
nlinfo ("Chat input was copied in the clipboard");
|
nlinfo ("Chat input was copied in the clipboard");
|
||||||
}
|
}
|
||||||
#endif // NL_OS_WINDOWS
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void CGroupEditBox::paste()
|
void CGroupEditBox::paste()
|
||||||
|
@ -374,26 +355,11 @@ void CGroupEditBox::paste()
|
||||||
}
|
}
|
||||||
stopParentBlink();
|
stopParentBlink();
|
||||||
makeTopWindow();
|
makeTopWindow();
|
||||||
#ifdef NL_OS_WINDOWS
|
|
||||||
if (OpenClipboard (NULL))
|
|
||||||
{
|
|
||||||
bool isUnicode = IsClipboardFormatAvailable(CF_UNICODETEXT) == TRUE;
|
|
||||||
|
|
||||||
HANDLE hObj = GetClipboardData(isUnicode ? CF_UNICODETEXT:CF_TEXT);
|
|
||||||
|
|
||||||
if (hObj)
|
|
||||||
{
|
|
||||||
void *hLock = GlobalLock(hObj);
|
|
||||||
|
|
||||||
if (hLock != NULL)
|
|
||||||
{
|
|
||||||
ucstring sString;
|
ucstring sString;
|
||||||
|
|
||||||
if (isUnicode)
|
if (CSystemUtils::pasteTextFromClipboard(sString))
|
||||||
sString = (const ucchar*)hLock;
|
{
|
||||||
else
|
|
||||||
sString = (const char*)hLock;
|
|
||||||
|
|
||||||
sint length = (sint)sString.length();
|
sint length = (sint)sString.length();
|
||||||
|
|
||||||
ucstring toAppend;
|
ucstring toAppend;
|
||||||
|
@ -532,14 +498,11 @@ void CGroupEditBox::paste()
|
||||||
ucstring toAdd = toAppend.substr(0, length);
|
ucstring toAdd = toAppend.substr(0, length);
|
||||||
_InputString = _InputString.substr(0, _CursorPos) + toAdd + _InputString.substr(_CursorPos);
|
_InputString = _InputString.substr(0, _CursorPos) + toAdd + _InputString.substr(_CursorPos);
|
||||||
_CursorPos += (sint32)toAdd.length();
|
_CursorPos += (sint32)toAdd.length();
|
||||||
GlobalUnlock (hObj);
|
|
||||||
nlinfo ("Chat input was pasted from the clipboard");
|
nlinfo ("Chat input was pasted from the clipboard");
|
||||||
}
|
|
||||||
}
|
|
||||||
CloseClipboard ();
|
|
||||||
triggerOnChangeAH();
|
triggerOnChangeAH();
|
||||||
}
|
}
|
||||||
#endif // NL_OS_WINDOWS
|
|
||||||
_CursorAtPreviousLineEnd = false;
|
_CursorAtPreviousLineEnd = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,11 @@
|
||||||
#include "nel/misc/debug.h"
|
#include "nel/misc/debug.h"
|
||||||
#include "nel/misc/path.h"
|
#include "nel/misc/path.h"
|
||||||
#include "nel/misc/thread.h"
|
#include "nel/misc/thread.h"
|
||||||
|
#include "nel/misc/big_file.h"
|
||||||
|
#include "nel/misc/system_utils.h"
|
||||||
|
|
||||||
#include "nel/net/tcp_sock.h"
|
#include "nel/net/tcp_sock.h"
|
||||||
#include "nel/3d/u_driver.h"
|
#include "nel/3d/u_driver.h"
|
||||||
#include "nel/misc/big_file.h"
|
|
||||||
|
|
||||||
#include "interface_v3/interface_manager.h"
|
#include "interface_v3/interface_manager.h"
|
||||||
#include "interface_v3/input_handler_manager.h"
|
#include "interface_v3/input_handler_manager.h"
|
||||||
|
@ -95,10 +97,6 @@ string R2BackupPatchURL;
|
||||||
vector<string> R2PatchURLs;
|
vector<string> R2PatchURLs;
|
||||||
|
|
||||||
|
|
||||||
// Key in registry
|
|
||||||
static const string RootKey = "SOFTWARE\\Nevrax\\Ryzom";
|
|
||||||
static const uint32 KeyMaxLength = 1024;
|
|
||||||
|
|
||||||
#define CTRL_EDITBOX_LOGIN "ui:login:checkpass:content:eb_login:eb"
|
#define CTRL_EDITBOX_LOGIN "ui:login:checkpass:content:eb_login:eb"
|
||||||
#define CTRL_EDITBOX_PASSWORD "ui:login:checkpass:content:eb_password:eb"
|
#define CTRL_EDITBOX_PASSWORD "ui:login:checkpass:content:eb_password:eb"
|
||||||
#define GROUP_LIST_SHARD "ui:login:sharddisp:content:shard_list"
|
#define GROUP_LIST_SHARD "ui:login:sharddisp:content:shard_list"
|
||||||
|
@ -736,7 +734,9 @@ void initLoginScreen()
|
||||||
|
|
||||||
ClientApp = ClientCfg.ConfigFile.getVar("Application").asString(0);
|
ClientApp = ClientCfg.ConfigFile.getVar("Application").asString(0);
|
||||||
|
|
||||||
string l = getRegKeyValue("Login").c_str();
|
CSystemUtils::setRootKey("SOFTWARE\\Nevrax\\Ryzom");
|
||||||
|
|
||||||
|
string l = CSystemUtils::getRegKey("Login");
|
||||||
|
|
||||||
if(!l.empty())
|
if(!l.empty())
|
||||||
{
|
{
|
||||||
|
@ -927,60 +927,6 @@ bool login()
|
||||||
// INTERFACE HELPERS
|
// INTERFACE HELPERS
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
||||||
// ***************************************************************************
|
|
||||||
string getRegKeyValue(const string &Entry)
|
|
||||||
{
|
|
||||||
string ret;
|
|
||||||
#ifdef NL_OS_WINDOWS
|
|
||||||
HKEY hkey;
|
|
||||||
|
|
||||||
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, RootKey.c_str(), 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
DWORD dwType = 0L;
|
|
||||||
DWORD dwSize = KeyMaxLength;
|
|
||||||
unsigned char Buffer[KeyMaxLength];
|
|
||||||
|
|
||||||
if(RegQueryValueEx(hkey, Entry.c_str(), NULL, &dwType, Buffer, &dwSize) != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
nlwarning("Can't get the reg key '%s'", Entry.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = (char*)Buffer;
|
|
||||||
}
|
|
||||||
RegCloseKey(hkey);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nlwarning("Can't get the reg key '%s'", Entry.c_str());
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// TODO for Linux and Mac OS
|
|
||||||
#endif
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ***************************************************************************
|
|
||||||
void setRegKey(const string &ValueName, const string &Value)
|
|
||||||
{
|
|
||||||
#ifdef NL_OS_WINDOWS
|
|
||||||
HKEY hkey;
|
|
||||||
DWORD dwDisp;
|
|
||||||
|
|
||||||
if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, RootKey.c_str(), 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisp) == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
RegSetValueEx(hkey, ValueName.c_str(), 0L, REG_SZ, (const BYTE *)Value.c_str(), (DWORD)(Value.size())+1);
|
|
||||||
RegCloseKey(hkey);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nlwarning("Can't set the reg key '%s' '%s'", ValueName.c_str(), Value.c_str());
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// TODO for Linux and Mac OS
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void removeSpace(string &s)
|
void removeSpace(string &s)
|
||||||
{
|
{
|
||||||
|
@ -1162,7 +1108,7 @@ void onlogin(bool vanishScreen = true)
|
||||||
removeSpace(LoginPassword);
|
removeSpace(LoginPassword);
|
||||||
|
|
||||||
if(!LoginLogin.empty())
|
if(!LoginLogin.empty())
|
||||||
setRegKey("Login", LoginLogin);
|
CSystemUtils::setRegKey("Login", LoginLogin);
|
||||||
|
|
||||||
if(vanishScreen)
|
if(vanishScreen)
|
||||||
pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(-1);
|
pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(-1);
|
||||||
|
@ -1836,24 +1782,18 @@ class CAHOpenURL : public IActionHandler
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
|
|
||||||
const LONG BUFFER_LEN = 1024;
|
|
||||||
LONG bufferLenght = BUFFER_LEN;
|
|
||||||
char buffer[BUFFER_LEN];
|
|
||||||
// Check for special install tag
|
// Check for special install tag
|
||||||
const char *KeyName = "Software\\Nevrax\\Ryzom\\InstallTag";
|
const char *KeyName = "InstallTag";
|
||||||
|
|
||||||
LONG ret = RegQueryValueA(HKEY_LOCAL_MACHINE, KeyName, buffer, &bufferLenght);
|
installTag = CSystemUtils::getRegKey(KeyName);
|
||||||
if (ret == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
if (bufferLenght > 1)
|
|
||||||
{
|
|
||||||
installTag = buffer;
|
|
||||||
|
|
||||||
|
if (installTag.length() > 1)
|
||||||
|
{
|
||||||
nldebug("Found install tag '%s'", url.c_str());
|
nldebug("Found install tag '%s'", url.c_str());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DWORD ret = 0;
|
||||||
LPVOID lpMsgBuf;
|
LPVOID lpMsgBuf;
|
||||||
FormatMessage(
|
FormatMessage(
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
|
|
|
@ -61,11 +61,6 @@ std::string getBGDownloaderCommandLine();
|
||||||
bool login();
|
bool login();
|
||||||
void loginIntro();
|
void loginIntro();
|
||||||
|
|
||||||
// helpers
|
|
||||||
std::string getRegKeyValue(const std::string &Entry);
|
|
||||||
void setRegKey(const std::string &ValueName, const std::string &Value);
|
|
||||||
|
|
||||||
|
|
||||||
// force patch for the mainland part
|
// force patch for the mainland part
|
||||||
void mainLandPatch();
|
void mainLandPatch();
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "nel/misc/fast_floor.h"
|
#include "nel/misc/fast_floor.h"
|
||||||
#include "nel/misc/noise_value.h"
|
#include "nel/misc/noise_value.h"
|
||||||
#include "nel/misc/bitmap.h"
|
#include "nel/misc/bitmap.h"
|
||||||
|
#include "nel/misc/system_utils.h"
|
||||||
// Game Share
|
// Game Share
|
||||||
#include "game_share/player_visual_properties.h"
|
#include "game_share/player_visual_properties.h"
|
||||||
#include "game_share/seeds.h"
|
#include "game_share/seeds.h"
|
||||||
|
@ -1464,26 +1465,7 @@ uint getCurrentColorDepth()
|
||||||
return videoMode.Depth;
|
return videoMode.Depth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint depth = 0;
|
|
||||||
#ifdef NL_OS_WINDOWS
|
return CSystemUtils::getCurrentColorDepth();
|
||||||
HWND desktopWnd = GetDesktopWindow();
|
|
||||||
if (desktopWnd)
|
|
||||||
{
|
|
||||||
HDC desktopDC = GetWindowDC(desktopWnd);
|
|
||||||
if (desktopDC)
|
|
||||||
{
|
|
||||||
depth = (uint) GetDeviceCaps(desktopDC, BITSPIXEL);
|
|
||||||
ReleaseDC(desktopWnd, desktopDC);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
Display *display = XOpenDisplay(NULL);
|
|
||||||
if (display)
|
|
||||||
{
|
|
||||||
depth = (uint) DefaultDepth(display, DefaultScreen(display));
|
|
||||||
XCloseDisplay(display);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return depth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3028,13 +3028,9 @@ void CEditor::updateSelectingDecals()
|
||||||
void CEditor::reset()
|
void CEditor::reset()
|
||||||
{
|
{
|
||||||
//H_AUTO(R2_CEditor_reset)
|
//H_AUTO(R2_CEditor_reset)
|
||||||
#ifdef NL_OS_WINDOWS
|
|
||||||
if (ClientCfg.R2EDExtendedDebug)
|
if (ClientCfg.R2EDExtendedDebug)
|
||||||
{
|
Driver->setWindowTitle(ucstring("Resetting R2ED editor ..."));
|
||||||
HWND hWnd = (HWND)Driver->getDisplay ();
|
|
||||||
SetWindowText(hWnd, "Resetting R2ED editor ...");
|
|
||||||
}
|
|
||||||
#endif // NL_OS_WINDOW
|
|
||||||
CHECK_EDITOR
|
CHECK_EDITOR
|
||||||
_SerializeUIConfig = false; // prevent reloading of ui for speed
|
_SerializeUIConfig = false; // prevent reloading of ui for speed
|
||||||
_WantedActOnInit.clear();
|
_WantedActOnInit.clear();
|
||||||
|
@ -3077,18 +3073,17 @@ void CEditor::reset()
|
||||||
// try to return to the act with the same title
|
// try to return to the act with the same title
|
||||||
_SerializeUIConfig = true;
|
_SerializeUIConfig = true;
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
|
||||||
if (ClientCfg.R2EDExtendedDebug)
|
if (ClientCfg.R2EDExtendedDebug)
|
||||||
{
|
{
|
||||||
HWND hWnd = (HWND)Driver->getDisplay ();
|
Driver->setWindowTitle(CI18N::get("TheSagaOfRyzom"));
|
||||||
nlassert (hWnd);
|
Driver->showWindow();
|
||||||
SetWindowTextW (hWnd, (WCHAR*)CI18N::get("TheSagaOfRyzom").c_str ());
|
// TODO: check
|
||||||
// Get the window
|
// Get the window
|
||||||
// Show the window
|
// Show the window
|
||||||
ShowWindow (hWnd, SW_SHOW);
|
// ShowWindow (hWnd, SW_SHOW);
|
||||||
SetForegroundWindow(hWnd);
|
// SetForegroundWindow(hWnd);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
getUI().displaySystemInfo(CI18N::get("uiR2EDEditorReseted"), "BC");
|
getUI().displaySystemInfo(CI18N::get("uiR2EDEditorReseted"), "BC");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
// Misc.
|
// Misc.
|
||||||
#include "nel/misc/debug.h"
|
#include "nel/misc/debug.h"
|
||||||
#include "nel/misc/async_file_manager.h"
|
#include "nel/misc/async_file_manager.h"
|
||||||
|
#include "nel/misc/system_utils.h"
|
||||||
// 3D Interface.
|
// 3D Interface.
|
||||||
#include "nel/3d/bloom_effect.h"
|
#include "nel/3d/bloom_effect.h"
|
||||||
#include "nel/3d/fasthls_modifier.h"
|
#include "nel/3d/fasthls_modifier.h"
|
||||||
|
@ -525,11 +526,8 @@ void release()
|
||||||
STRING_MANAGER::CStringManagerClient::instance()->flushStringCache();
|
STRING_MANAGER::CStringManagerClient::instance()->flushStringCache();
|
||||||
STRING_MANAGER::CStringManagerClient::release(true);
|
STRING_MANAGER::CStringManagerClient::release(true);
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
// restore screensaver state
|
||||||
{
|
CSystemUtils::enableScreensaver(LastScreenSaverEnabled);
|
||||||
SystemParametersInfo (SPI_SETSCREENSAVEACTIVE, LastScreenSaverEnabled?TRUE:FALSE, NULL, 0);
|
|
||||||
}
|
|
||||||
#endif // NL_OS_WINDOWS
|
|
||||||
|
|
||||||
// release PACS primitives
|
// release PACS primitives
|
||||||
deletePrimitiveBlocks();
|
deletePrimitiveBlocks();
|
||||||
|
|
Loading…
Reference in a new issue