mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Tagging - Add custom stencil text tags in 3DEN (#9149)
* Tagging - Add custom stencil text tags * hack to force preloading font * Add 3den * header * Apply suggestions from code review Co-authored-by: jonpas <jonpas33@gmail.com> * Update addons/tagging/functions/fnc_generateStencilTexture.sqf --------- Co-authored-by: jonpas <jonpas33@gmail.com> Co-authored-by: Salluci <salluci.lovi@gmail.com>
This commit is contained in:
parent
e9cde7268f
commit
74984769a5
@ -34,4 +34,9 @@ class CfgFontFamilies {
|
||||
spaceWidth = 0.5;
|
||||
spacing = 0.065;
|
||||
};
|
||||
class ACE_Stencil {
|
||||
fonts[] = {
|
||||
QPATHTOF(SairaStencilOne\ace_stencil64)
|
||||
};
|
||||
};
|
||||
};
|
||||
|
BIN
addons/fonts/SairaStencilOne/ace_stencil64-01.paa
Normal file
BIN
addons/fonts/SairaStencilOne/ace_stencil64-01.paa
Normal file
Binary file not shown.
BIN
addons/fonts/SairaStencilOne/ace_stencil64.fxy
Normal file
BIN
addons/fonts/SairaStencilOne/ace_stencil64.fxy
Normal file
Binary file not shown.
@ -10,7 +10,7 @@
|
||||
#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD
|
||||
|
||||
// MINIMAL required version for the Mod. Components can specify others..
|
||||
#define REQUIRED_VERSION 2.10
|
||||
#define REQUIRED_VERSION 2.12
|
||||
#define REQUIRED_CBA_VERSION {3,15,7}
|
||||
|
||||
#ifdef COMPONENT_BEAUTIFIED
|
||||
|
20
addons/tagging/CfgEden.hpp
Normal file
20
addons/tagging/CfgEden.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
class Cfg3DEN {
|
||||
class Object {
|
||||
class AttributeCategories {
|
||||
class ace_attributes {
|
||||
class Attributes {
|
||||
class GVAR(stencilVehicle) {
|
||||
property = QGVAR(stencilVehicle);
|
||||
control = "Edit";
|
||||
displayName = CSTRING(stencilVehicle);
|
||||
tooltip = CSTRING(stencilVehicle_tooltip);
|
||||
expression = QUOTE( [ARR_2(_this,_value)] call FUNC(stencilVehicle); );
|
||||
condition = "objectVehicle";
|
||||
defaultValue = "''";
|
||||
typeName = "STRING";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
@ -14,20 +14,24 @@ class CfgWeapons {
|
||||
class ItemInfo: CBA_MiscItem_ItemInfo {
|
||||
mass = 10;
|
||||
};
|
||||
GVAR(textColor) = "000000FE";
|
||||
};
|
||||
class ACE_SpraypaintRed: ACE_SpraypaintBlack {
|
||||
displayname = CSTRING(spraypaintRed);
|
||||
picture = QPATHTOF(UI\items\itemSpraypaintRed.paa);
|
||||
hiddenSelectionsTextures[] = {QPATHTOF(data\spraycanRed_co.paa)};
|
||||
GVAR(textColor) = "FF0000FE";
|
||||
};
|
||||
class ACE_SpraypaintGreen: ACE_SpraypaintBlack {
|
||||
displayname = CSTRING(spraypaintGreen);
|
||||
picture = QPATHTOF(UI\items\itemSpraypaintGreen.paa);
|
||||
hiddenSelectionsTextures[] = {QPATHTOF(data\spraycanGreen_co.paa)};
|
||||
GVAR(textColor) = "00FF00FE";
|
||||
};
|
||||
class ACE_SpraypaintBlue: ACE_SpraypaintBlack {
|
||||
displayname = CSTRING(spraypaintBlue);
|
||||
picture = QPATHTOF(UI\items\itemSpraypaintBlue.paa);
|
||||
hiddenSelectionsTextures[] = {QPATHTOF(data\spraycanBlue_co.paa)};
|
||||
GVAR(textColor) = "0000FFFE";
|
||||
};
|
||||
};
|
||||
|
@ -1,12 +1,15 @@
|
||||
PREP(addCustomTag);
|
||||
PREP(addStencilTag);
|
||||
PREP(addTagActions);
|
||||
PREP(applyCustomTag);
|
||||
PREP(checkTaggable);
|
||||
PREP(compileConfigTags);
|
||||
PREP(compileTagAction);
|
||||
PREP(createTag);
|
||||
PREP(generateStencilTexture);
|
||||
PREP(moduleInit);
|
||||
PREP(parseConfigTag);
|
||||
PREP(quickTag);
|
||||
PREP(stencilVehicle);
|
||||
PREP(tag);
|
||||
PREP(tagTestingThread);
|
||||
|
@ -30,3 +30,7 @@ private _cfgBase = configFile >> "CfgNonAIVehicles";
|
||||
|
||||
uiNamespace setVariable [QGVAR(cacheStaticModels), compileFinal str _cacheStaticModels];
|
||||
TRACE_1("compiled",count _cacheStaticModels);
|
||||
|
||||
// force preload of stencil texture to avoid error popup
|
||||
// Warning Message: Cannot load mipmap z\ace\addons\fonts\sairastencilone\ace_stencil64-01.paa
|
||||
"Test" getTextWidth ["ACE_Stencil", 0.3];
|
||||
|
@ -19,3 +19,4 @@ class CfgPatches {
|
||||
#include "CfgEventHandlers.hpp"
|
||||
#include "CfgVehicles.hpp"
|
||||
#include "CfgWeapons.hpp"
|
||||
#include "CfgEden.hpp"
|
||||
|
@ -33,25 +33,27 @@ params [
|
||||
|
||||
// Verify
|
||||
if (_identifier == "") exitWith {
|
||||
ERROR("Failed adding custom tag - missing identifier");
|
||||
ERROR("Failed adding custom tag - missing identifier"); false
|
||||
};
|
||||
|
||||
if (_displayName == "") exitWith {
|
||||
ERROR_1("Failed adding custom tag: %1 - missing displayName",_identifier);
|
||||
ERROR_1("Failed adding custom tag: %1 - missing displayName",_identifier); false
|
||||
};
|
||||
|
||||
if (_requiredItem == "") exitWith {
|
||||
ERROR_1("Failed adding custom tag: %1 - missing requiredItem",_identifier);
|
||||
ERROR_1("Failed adding custom tag: %1 - missing requiredItem",_identifier); false
|
||||
};
|
||||
if (!isClass (configFile >> "CfgWeapons" >> _requiredItem)) exitWith {
|
||||
ERROR_2("Failed adding custom tag: %1 - requiredItem %2 does not exist",_identifier,_requiredItem);
|
||||
ERROR_2("Failed adding custom tag: %1 - requiredItem %2 does not exist",_identifier,_requiredItem); false
|
||||
};
|
||||
|
||||
if (_textures isEqualTo []) exitWith {
|
||||
ERROR_1("Failed adding custom tag: %1 - missing textures",_identifier);
|
||||
ERROR_1("Failed adding custom tag: %1 - missing textures",_identifier); false
|
||||
};
|
||||
|
||||
_identifier = [_identifier] call CBA_fnc_removeWhitespace;
|
||||
|
||||
// Add
|
||||
[QGVAR(applyCustomTag), [_identifier, _displayName, _requiredItem, _textures, _icon, _materials, _tagModel]] call CBA_fnc_globalEventJIP;
|
||||
|
||||
true
|
||||
|
50
addons/tagging/functions/fnc_addStencilTag.sqf
Normal file
50
addons/tagging/functions/fnc_addStencilTag.sqf
Normal file
@ -0,0 +1,50 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Adds custom text tag. Has to be executed on one machine only.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Display Text <STRING>
|
||||
* 1: Text Size <NUMBER> (default: 0.3)
|
||||
* 2: Required Item <STRING> (default: "ACE_SpraypaintBlack")
|
||||
* 3: Text Color (in HEX 6 or 8) <STRING> (default: based on spray item)
|
||||
* 4: Background Color (in HEX 6 or 8) <STRING> (default: "00000000" - transparent)
|
||||
* 5: Auto newlines <BOOL> (default: true)
|
||||
*
|
||||
* Return Value:
|
||||
* Sucessfully Added Tag <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* ["Orcs Go Home", 0.22] call ace_tagging_fnc_addStencilTag
|
||||
* ["LOGI-2", 0.3, "ACE_SpraypaintBlack", "f7e9e1"] call ace_tagging_fnc_addStencilTag
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
params [
|
||||
["_text", "", [""]],
|
||||
["_textSize", 0.3, [0]],
|
||||
["_requiredItem", "ACE_SpraypaintBlack", [""]],
|
||||
["_textColor", "", [""]],
|
||||
["_backgroundColor", "00000000", [""]],
|
||||
["_autoMultiline", true, [false]]
|
||||
];
|
||||
TRACE_6("",_text,_textSize,_requiredItem,_textColor,_backgroundColor,_autoMultiline);
|
||||
|
||||
if (_text == "") exitWith { ERROR_1("bad text %1",_text); false };
|
||||
// Check required item exists
|
||||
if (!isClass (configFile >> "CfgWeapons" >> _requiredItem)) exitWith { ERROR_1("bad item %1",_requiredItem); false };
|
||||
// Get color from spray item used
|
||||
if (_textColor == "") then {
|
||||
_textColor = getText (configFile >> "CfgWeapons" >> _requiredItem >> QGVAR(textColor));
|
||||
if (_textColor == "") then { _textColor = "000000" };
|
||||
};
|
||||
|
||||
|
||||
private _identifier = format ["%1_%2_%3",_text,_textColor,_backgroundColor];
|
||||
private _interactionText = _text regexReplace ["\\n", " "];
|
||||
private _texture = [_text, _textSize, _textColor, _backgroundColor, _autoMultiline] call FUNC(generateStencilTexture);
|
||||
TRACE_2("",_identifier,_texture);
|
||||
if (_texture == "") exitWith { ERROR_1("bad texture params %1",_this); false };
|
||||
|
||||
[_identifier, _interactionText, _requiredItem, [_texture]] call FUNC(addCustomTag) // return
|
55
addons/tagging/functions/fnc_generateStencilTexture.sqf
Normal file
55
addons/tagging/functions/fnc_generateStencilTexture.sqf
Normal file
@ -0,0 +1,55 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Generate a "Text to Texture"
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Display Text <STRING>
|
||||
* 1: Text Size <NUMBER> (default: 0.3)
|
||||
* 2: Text Color (in HEX 6 or 8) <STRING> (default: "000000" - black)
|
||||
* 3: Background Color (in HEX 6 or 8) <STRING> (default: "00000000" - transparent)
|
||||
* 4: Auto newlines <BOOL> (default: true)
|
||||
* 4: Texture Dimensions <BOOL> (default: 512)
|
||||
*
|
||||
* Return Value:
|
||||
* Texture <STRING>
|
||||
*
|
||||
* Example:
|
||||
* ["your text"] call ace_tagging_fnc_generateStencilTexture
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params [
|
||||
["_text", "", [""]],
|
||||
["_textSize", 0.3, [0]],
|
||||
["_textColor", "000000", [""]],
|
||||
["_backgroundColor", "00000000", [""]],
|
||||
["_autoMultiline", true, [false]],
|
||||
["_dimension", 512, [0]]
|
||||
];
|
||||
|
||||
if (_textColor select [0, 1] == "#") then { _textColor = _textColor select [1]; };
|
||||
if (_backgroundColor select [0, 1] == "#") then { _backgroundColor = _backgroundColor select [1]; };
|
||||
if (!((count _textColor) in [6,8])) exitWith { ERROR_1("bad Tcolor %1",_textColor); "" };
|
||||
if (!((count _backgroundColor) in [6,8])) exitWith { ERROR_1("bad Bcolor %1",_textColor); "" };
|
||||
|
||||
if (_autoMultiline) then {
|
||||
private _magicWidth = 0.75;
|
||||
private _words = _text splitString " ";
|
||||
private _lines = [];
|
||||
while {_words isNotEqualTo []} do {
|
||||
private _size = count _words;
|
||||
while {_size > 1} do {
|
||||
private _testLine = (_words select [0, _size]) joinString " ";
|
||||
if ((_testLine getTextWidth ["ACE_Stencil", _textSize]) < _magicWidth) exitWith {};
|
||||
_size = _size - 1;
|
||||
};
|
||||
_lines pushBack ((_words select [0, _size]) joinString " ");
|
||||
_words = _words select [_size, (count _words) - _size];
|
||||
};
|
||||
_text = _lines joinString "\n";
|
||||
};
|
||||
|
||||
// return
|
||||
format ['#(rgb,%1,%1,3)text(1,1,"ACE_Stencil",%2,"#%3","#%4","%5")', _dimension, _textSize, _backgroundColor, _textColor, _text]
|
37
addons/tagging/functions/fnc_stencilVehicle.sqf
Normal file
37
addons/tagging/functions/fnc_stencilVehicle.sqf
Normal file
@ -0,0 +1,37 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Handles 3den attribute for vehicle ID markings
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Vehicle <OBJECT>
|
||||
* 1: Display Text <STRING>
|
||||
* 2: Text Size <NUMBER> (Optional)
|
||||
* 3: Text Color <STRING> (Optional)
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [truck, "BARVO-1 Bastards"] call ace_tagging_fnc_stencilVehicle
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params [
|
||||
["_vehicle", objNull, [objNull]],
|
||||
["_text", "", [""]],
|
||||
["_textSize", 0.3, [0]], // Fits about 7-8 chars in width
|
||||
["_textcolor", "f7e9e1f8", [""]] // making text color slightly transparent (f8) fixes a "shimmering" problem (possibly related to HBAO)
|
||||
];
|
||||
TRACE_2("",_vehicle,_text);
|
||||
|
||||
if (!isServer) exitWith {};
|
||||
if (_text == "") exitWith {};
|
||||
private _clanSel = getText (configOf _vehicle >> "selectionClan");
|
||||
if (!(_clanSel in selectionNames _vehicle)) exitWith { TRACE_1("no tag",_clanSel); };
|
||||
|
||||
private _texture = [_text, _textSize, _textColor, "00000000", true] call FUNC(generateStencilTexture);
|
||||
TRACE_1("",_texture);
|
||||
if (_texture == "") exitWith { ERROR_1("bad texture params %1",_this); };
|
||||
[[], [], _texture, _vehicle, objNull, "", "", true] call FUNC(createTag); // apply texture and send event
|
@ -350,5 +350,11 @@
|
||||
<Chinesesimp>喷漆可喷涂在墙壁上</Chinesesimp>
|
||||
<Chinese>噴漆可噴塗在牆壁上</Chinese>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Tagging_stencilVehicle">
|
||||
<English>Vehicle ID Marking</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Tagging_stencilVehicle_tooltip">
|
||||
<English>Replaces clan tag with stenciled text</English>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user