mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge branch 'breakLineExtension' into linearMenuExperiment
Conflicts: addons/interact_menu/functions/fnc_renderIcon.sqf
This commit is contained in:
commit
01bc6b233a
@ -35,7 +35,10 @@ GVAR(iconCount) = GVAR(iconCount) + 1;
|
||||
if(_icon == "") then {
|
||||
_icon = DEFAULT_ICON;
|
||||
};
|
||||
|
||||
_text = format ["<img image='%1' color='%2' align='left'/><t color='%3' size='0.80' shadow='1' shadowColor='#000000' shadowOffset='0.07'>%4</t>", _icon, _color, _color, _text];
|
||||
//_text = format ["<img image='%1' color='%2' align='center'/><br/><t color='%3' size='0.80' align='center' shadow='1' shadowColor='#000000' shadowOffset='0.07'>%4</t>", _icon, _color, _color, "ace_breakLine" callExtension _text];
|
||||
|
||||
_ctrl ctrlSetStructuredText (parseText _text);
|
||||
_ctrl ctrlSetPosition [(_sPos select 0)-(0.0095*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.10*SafeZoneW, 0.035*SafeZoneW];
|
||||
//_ctrl ctrlSetBackgroundColor [0, 1, 0, 0.1];
|
||||
|
@ -3,14 +3,14 @@
|
||||
<Project name="ACE">
|
||||
<Package name="Laser_SelfDesignate">
|
||||
<Key ID="STR_ACE_Laser_SelfDesignate_DesignatorOn">
|
||||
<English>Laser<br/>Designator On</English>
|
||||
<German>Lasermarkierer<br/>an</German>
|
||||
<Spanish>Laser<br/>Designador encendido</Spanish>
|
||||
<English>Laser Designator On</English>
|
||||
<German>Lasermarkierer an</German>
|
||||
<Spanish>Laser Designador encendido</Spanish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Laser_SelfDesignate_DesignatorOff">
|
||||
<English>Laser<br/>Designator Off</English>
|
||||
<German>Lasermarkierer<br/>aus</German>
|
||||
<Spanish>Laser<br/>Designador apagado</Spanish>
|
||||
<English>Laser Designator Off</English>
|
||||
<German>Lasermarkierer aus</German>
|
||||
<Spanish>Laser Designador apagado</Spanish>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
||||
|
@ -27,5 +27,6 @@ include_directories(AFTER "common")
|
||||
|
||||
# Add extensions to build here
|
||||
add_subdirectory(fcs)
|
||||
add_subdirectory(breakline)
|
||||
|
||||
message("Build Type: ${CMAKE_BUILD_TYPE}")
|
11
extensions/breakLine/CMakeLists.txt
Normal file
11
extensions/breakLine/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
set(ACE_EXTENSION_NAME "ace_breakLine")
|
||||
|
||||
file(GLOB SOURCES *.h *.hpp *.c *.cpp)
|
||||
add_library( ${ACE_EXTENSION_NAME} SHARED ${SOURCES})
|
||||
add_dependencies(${ACE_EXTENSION_NAME} ace_common)
|
||||
SET_TARGET_PROPERTIES(${ACE_EXTENSION_NAME} PROPERTIES PREFIX "")
|
||||
|
||||
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()
|
79
extensions/breakLine/ace_breakLine.cpp
Normal file
79
extensions/breakLine/ace_breakLine.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* ace_breakLine.cpp
|
||||
*
|
||||
* Takes a string and insert as many line breaks as needed so it fits a given width
|
||||
*
|
||||
* Takes:
|
||||
* Localized string as string
|
||||
* Example: "Check weapon temperature"
|
||||
*
|
||||
* Returns:
|
||||
* String with line breaks
|
||||
*/
|
||||
|
||||
#include "ace_common.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#define MAXCHARACTERS 14
|
||||
|
||||
static char version[] = "1.0";
|
||||
|
||||
extern "C" {
|
||||
__declspec (dllexport) void __stdcall RVExtension(char *output, int outputSize, const char *function);
|
||||
};
|
||||
|
||||
std::vector<std::string> splitString(std::string input) {
|
||||
std::istringstream ss(input);
|
||||
std::string token;
|
||||
|
||||
std::vector<std::string> output;
|
||||
while (std::getline(ss, token, ' ')) {
|
||||
output.push_back(token);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
std::string addLineBreaks(const std::vector<std::string> &words) {
|
||||
|
||||
std::stringstream sstream;
|
||||
int numChar = 0;
|
||||
int i = 0;
|
||||
while (i < words.size()) {
|
||||
if (numChar == 0) {
|
||||
sstream << words[i];
|
||||
numChar += words[i].size();
|
||||
i++;
|
||||
} else {
|
||||
if (numChar + 1 + words[i].size() > MAXCHARACTERS) {
|
||||
sstream << "<br/>";
|
||||
numChar = 0;
|
||||
} else {
|
||||
sstream << " " << words[i];
|
||||
numChar += 1 + words[i].size();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sstream.str();
|
||||
}
|
||||
|
||||
// i like to live dangerously. jk, fix strncpy sometime pls.
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4996 )
|
||||
|
||||
void __stdcall RVExtension(char *output, int outputSize, const char *function) {
|
||||
//strncpy(output, function, outputSize);
|
||||
|
||||
if (!strcmp(function, "version")) {
|
||||
strncpy(output, version, outputSize);
|
||||
} else {
|
||||
strcpy(output, addLineBreaks(splitString(function)).c_str());
|
||||
output[outputSize - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning( pop )
|
Loading…
Reference in New Issue
Block a user