This commit is contained in:
KoffeinFlummi 2015-05-03 01:08:39 +02:00
commit 697656da92
6 changed files with 121 additions and 4 deletions

BIN
ace_clipboard.dll Normal file

Binary file not shown.

View File

@ -37,3 +37,7 @@ class ACE_Settings {
values[] = {"$str_medium", "$str_large", "$str_very_large"}; values[] = {"$str_medium", "$str_large", "$str_very_large"};
}; };
}; };
class ACE_Extensions {
extensions[] += {"ace_clipboard"};
};

View File

@ -55,13 +55,26 @@ class %1 {
force = 1; force = 1;
};", _name, _value, format['"%1"', _typeName]]; };", _name, _value, format['"%1"', _typeName]];
//clipboard seems to be getting cuttoff, so do a backup dump to rpt:
diag_log text _compiledConfigEntry;
_compiledConfig = _compiledConfig + _compiledConfigEntry; _compiledConfig = _compiledConfig + _compiledConfigEntry;
}; };
} forEach EGVAR(common,settings); } forEach EGVAR(common,settings);
copyToClipboard format["%1",_compiledConfig]; FUNC(clipboardExport) = {
private["_chunks"];
_chunks = [];
_chunks = [_this select 0, ";"] call CBA_fnc_split;
{
private["_chunk"];
_chunk = _x + ";";
"ace_clipboard" callExtension format["%1", _chunk];
} forEach _chunks;
"ace_clipboard" callExtension "--COMPLETE--";
};
[_compiledConfig] call FUNC(clipboardExport);
["STR_ACE_OptionsMenu_settingsExported"] call EFUNC(common,displayTextStructured); ["STR_ACE_OptionsMenu_settingsExported"] call EFUNC(common,displayTextStructured);

View File

@ -56,6 +56,7 @@ set(GLOBAL_SOURCES ${GLOBAL_RC})
# Add extensions to build here # Add extensions to build here
add_subdirectory(fcs) add_subdirectory(fcs)
add_subdirectory(break_line) add_subdirectory(break_line)
add_subdirectory(clipboard)
add_subdirectory(advanced_ballistics) add_subdirectory(advanced_ballistics)
message("Build Type: ${CMAKE_BUILD_TYPE}") message("Build Type: ${CMAKE_BUILD_TYPE}")

View File

@ -0,0 +1,12 @@
set(ACE_EXTENSION_NAME "ace_clipboard")
file(GLOB SOURCES *.h *.hpp *.c *.cpp)
add_library( ${ACE_EXTENSION_NAME} SHARED ${SOURCES} ${GLOBAL_SOURCES})
target_link_libraries(${ACE_EXTENSION_NAME} ace_common)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES PREFIX "")
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES FOLDER Extensions)
if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_END_STATIC 1)
endif()

View File

@ -0,0 +1,87 @@
/*
* ace_clipboard.cpp
*
* Takes a string and copies it to the clipboard; bypasses arma 8k clippy limit.
*
* Takes:
* Localized string as string
*
* Returns:
* None
*/
#include "ace_common.h"
#include <vector>
#include <string>
extern "C" {
__declspec (dllexport) void __stdcall RVExtension(char *output, int outputSize, const char *function);
};
std::string gClipboardData;
void __stdcall RVExtension(char *output, int outputSize, const char *function) {
std::string cur_input(function);
std::string result;
if (cur_input.length() < 1)
return;
if (!strcmp(function, "version")) {
strncpy(output, ACE_FULL_VERSION_STR, outputSize);
return;
}
#ifdef _WIN32
if (!strcmp(function, "--COMPLETE--")) {
HGLOBAL hClipboardData = GlobalAlloc(GMEM_FIXED, gClipboardData.length() + 1);
if (!hClipboardData) {
result = "GlobalAlloc() failed, GetLastError=" + GetLastError();
gClipboardData = "";
return;
}
char *pClipboardData = (char *)GlobalLock(hClipboardData);
if (!pClipboardData) {
result = "GlobalLock() failed, GetLastError=" + GetLastError();
gClipboardData = "";
return;
}
memcpy(pClipboardData, gClipboardData.c_str(), gClipboardData.length());
pClipboardData[gClipboardData.length() + 1] = 0x00;
GlobalUnlock(hClipboardData);
if (!OpenClipboard(NULL)) {
result = "OpenClipboard() failed, GetLastError=" + GetLastError();
}
else {
if (!EmptyClipboard()) {
result = "OpenClipboard() failed, GetLastError=" + GetLastError();
}
else {
if (!SetClipboardData(CF_TEXT, hClipboardData)) {
result = "SetClipboardData() failed, GetLastError=" + GetLastError();
}
else {
if (!CloseClipboard()) {
result = "CloseClipboard() failed, GetLastError=" + GetLastError();
}
}
}
}
gClipboardData = "";
} else {
gClipboardData = gClipboardData + cur_input;
}
end:
if(result.length() > 1)
memcpy(output, result.c_str(), result.length()+1);
#endif
}