-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added displaying box name on box texture
- Loading branch information
Showing
4 changed files
with
297 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
params ["_display"]; | ||
|
||
private _paramStr = displayUniqueName _display; | ||
(parseSimpleArray (_paramStr regexReplace ["\*", """"] regexReplace ["_\._", ","])) params ["_model", "_srcTex", "_text"]; | ||
|
||
(_display displayCtrl 1) ctrlSetText _srcTex; // Put original texture as background | ||
|
||
#define PixelCoordToUV2048(x) (x/2048) | ||
#define PixelCoords1024(x,y,w,h) (x/1024),(y/1024),(w/1024),(h/1024) | ||
#define UVToArr(x1,y1,x2,y2) x1,y1,x2-x1,y2-y1 | ||
|
||
private _boxParams = [ | ||
["plasticcase_01_large_f.p3d", { | ||
[ | ||
// Twice on front (One is mirrored.. ugh) | ||
[PixelCoordToUV2048(292), PixelCoordToUV2048(978), PixelCoordToUV2048(280), PixelCoordToUV2048(333), 0.05], | ||
// Top twice, one mirrored.. | ||
[PixelCoordToUV2048(503), PixelCoordToUV2048(1687), PixelCoordToUV2048(228), PixelCoordToUV2048(273), 0.04], | ||
// Twice back, mirrored | ||
[PixelCoordToUV2048(0), PixelCoordToUV2048(975), PixelCoordToUV2048(280), PixelCoordToUV2048(335), 0.05] | ||
] | ||
}], | ||
["plasticcase_01_medium_f.p3d", { | ||
[ | ||
// Top twice, one mirrored.. | ||
[PixelCoordToUV2048(1437), PixelCoordToUV2048(890), PixelCoordToUV2048(514), PixelCoordToUV2048(187), 0.08] | ||
] | ||
}], | ||
["plasticcase_01_small_f.p3d", { | ||
[ | ||
// We use the sign selection here | ||
[UVToArr(0.0079087317, 0.2437216789, 0.4664944708, 0.6534416080), 0.04] | ||
] | ||
}], | ||
["metalcase_01_large_f.p3d", { | ||
[ | ||
// Front duplicate mirrored | ||
[UVToArr(0.0159685612, 0.5834286809, 0.3323798478, 0.9881689548), 0.04], | ||
// top duplicate mirrored | ||
[UVToArr(0.8160079122, 0.3738329411, 0.9722650051, 0.5495740175), 0.04] | ||
] | ||
}], | ||
["equipment_box_f.p3d", { // Huh, same UV's as last one, neat | ||
[ | ||
// Front duplicate mirrored | ||
[UVToArr(0.0159685612, 0.5834286809, 0.3323798478, 0.9881689548), 0.04], | ||
// top duplicate mirrored | ||
[UVToArr(0.8160079122, 0.3738329411, 0.9722650051, 0.5495740175), 0.04] | ||
] | ||
}], | ||
["ammobox_f.p3d", { // This box is a mess. It has 4 sets of vertices, and depending on which type (explosives, grenades) 3 sets are hidden | ||
[ | ||
// Front and back | ||
[PixelCoords1024(654, 782, 360, 167), 0.06] | ||
] | ||
}], | ||
["wpnsbox_f.p3d", { | ||
[ | ||
// Front and back | ||
[UVToArr(0.0140264034, 0.0685211420, 0.3375537395, 0.2060282230), 0.04] | ||
] | ||
}], | ||
["wpnsbox_long_f.p3d", { | ||
[ | ||
// Front and back | ||
[UVToArr(0.0074185133, 0.5042082071, 0.5999680758, 0.6417262554), 0.06] | ||
] | ||
}], | ||
["box_uav_06_f.p3d", { | ||
[ | ||
// Top | ||
[UVToArr(0.8217381239, 0.0366767906, 0.9999704361, 0.2156434953), 0.04] | ||
] | ||
}] | ||
]; | ||
|
||
private _found = _boxParams findIf {_model == (_x select 0)}; | ||
//(call ((_boxParams param [_found, ["",{[0.3, 1, 1]}]]) select 1)) params ["_overlays"]; | ||
private _overlays = (call ((_boxParams param [_found, ["",{[0.3, 1, 1]}]]) select 1)); | ||
|
||
|
||
{ | ||
_x params ["_x", "_y", "_w", "_h", "_sz"]; | ||
|
||
private _ctrl = _display ctrlCreate ["RscTextNoShadow", -1]; | ||
_ctrl ctrlSetPosition [_x, _y, _w, _h]; | ||
_ctrl ctrlSetFont "TahomaB"; | ||
_ctrl ctrlSetFontHeight _sz; | ||
_ctrl ctrlCommit 0; | ||
_ctrl ctrlSetText _text; | ||
} | ||
forEach _overlays; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
#include "script_component.hpp" | ||
|
||
private _box = ace_cargo_interactionVehicle; | ||
private _newName = _box getVariable ["ace_cargo_customName", ""]; | ||
private _model = (getModelinfo _box) select 0; | ||
//diag_log _box; | ||
//diag_log _newName; | ||
|
||
// Try to find the name of the camo selection | ||
|
||
/* | ||
// Based on Wolf Arsenal available boxes these are the selections we want to replace | ||
private _selectionWhitelist = ["camo2", "camo_signs", "medical"]; | ||
private _availableSelection = getArray (configOf _box >> "hiddenSelections") select {toLower _x in _selectionWhitelist} param [0, ""]; | ||
if (_availableSelection == "") exitWith {}; | ||
private _expectedWidth = (_newName getTextWidth ["RobotoCondensed", 0.1]) max 0.001; // No zero | ||
// Some boxes have quite messed up UV's, and we need to adjust the size to fit | ||
// availableWidth is determined by putting on flagTexture | ||
// format ['#(rgb,512,512,3)text(2,1,"RobotoCondensed",0.1,"#00000000","#ff0000","%1")', "A##########################A"] | ||
// Add or remove # so that text is fully visible with no cut sides, and anything extra would be cut off. | ||
// then "A##########################A" getTextWidth ["RobotoCondensed", 0.1]; | ||
// to get the availableWidth | ||
// How to get the linearConversion limits | ||
// Set texture '#(rgb,512,512,3)text(2,1,"RobotoCondensed",0.1,"#00000000","#ff0000","A")' | ||
// increase size until it barely still fits. | ||
// minFrom = "A" getTextWidth ["RobotoCondensed", 0.1]; | ||
// minTo = the size we just determined | ||
// Set texture '#(rgb,512,512,3)text(2,1,"RobotoCondensed",0.1,"#00000000","#ff0000","A##A")' | ||
// Leave size as 0.1. Insert # until it barely fits | ||
// maxFrom = "A##A" getTextWidth ["RobotoCondensed", 0.1]; (Put in same number of #) | ||
// maxTo = 0.1 | ||
private _boxParams = [ | ||
["plasticcase_01_large_f.p3d", { | ||
[0.1, 2, 1]// Text on side. Top is also possible with values of medium/small. But not both... | ||
}], | ||
["plasticcase_01_medium_f.p3d", { | ||
[0.1, 1, 0] // Text on top | ||
}], | ||
["plasticcase_01_small_f.p3d", { | ||
[0.1, 1, 0] // Text on top | ||
}], | ||
["equipment_box_f.p3d", { | ||
_newName = _newName + "\n"; | ||
[0.2, 2, 1] | ||
}], | ||
["ammobox_f.p3d", { | ||
// Aligned bottom right, and needs a padding on the right to fit | ||
_newName = _newName + " \n"; | ||
[0.1, 2, 2] | ||
}], | ||
["wpnsbox_f.p3d", { | ||
// Needs a headpat... | ||
_newName = "\n " + _newName; | ||
[0.1, 0, 0] | ||
}], | ||
["wpnsbox_long_f.p3d", { | ||
_newName = "\n " + _newName; | ||
[0.15, 1, 0] | ||
}], | ||
["box_uav_06_f.p3d", { | ||
[1, 1, 1] // No chance, their UV is messed up. We got a region from 0.59,0.49 to 0.68,0.57 not centered or any edge or anything. Just messed up. Would need ui2tex to fix | ||
}] | ||
]; | ||
private _found = _boxParams findIf {_model == (_x select 0)}; | ||
(call ((_boxParams param [_found, ["",{[0.3, 1, 1]}]]) select 1)) params ["_size", "_vAlign", "_hAlign"]; | ||
//private _size = (-25.65* _expectedWidth^3+ 27.032* _expectedWidth^2 -9.941* _expectedWidth +1.485) min 0.8; | ||
// Works, but bug where 0.280496 text is invisible, but 0.280495 and 0.280497 are working fine... gosh. | ||
//private _size = 0.2; | ||
_box setObjectTextureGlobal [ | ||
_availableSelection, | ||
format ['#(rgb,512,512,3)text(%2,%3,"RobotoCondensed",%4,"#00000000","#ff0000","%1")', _newName, _vAlign, _hAlign, _size] | ||
] | ||
*/ | ||
|
||
// Some we want to choose the non-main one | ||
private _customCamoSelections = [ | ||
["plasticcase_01_small_f.p3d", 1] // camo2 | ||
]; | ||
private _found = _customCamoSelections findIf {_model == (_x select 0)}; | ||
private _selection = (_customCamoSelections param [_found, ["", 0]]) select 1; | ||
|
||
private _srcTex = (getArray (configOf _box >> "hiddenSelectionsTextures")) select _selection; | ||
|
||
// The display will copy the original texture as background, and overlay texts in appropriate places | ||
_box setObjectTextureGlobal [ | ||
_selection, | ||
format ['#(rgb,512,512,3)ui("wolf_logistics_ace_boxName","%1","co")', (str [_model, _srcTex, _newName]) regexReplace ["""", "*"] regexReplace [",", "_._"]] | ||
] | ||
|
||
/* | ||
{ | ||
_class = _x select 0; | ||
ace_cargo_interactionVehicle = _class createVehicle (getPos player vectorAdd [_forEachIndex, 0, 0]); | ||
ace_cargo_interactionVehicle setVariable ["ace_cargo_customName", "Testomagico"]; | ||
call wolf_logistics_ace_fnc_onPostObjectRename; | ||
} forEach | ||
[ | ||
["ACE_medicalSupplyCrate_advanced",["Camo_Signs","Camo"]], | ||
["Land_WoodenCrate_01_F",[]], | ||
["Land_MetalCase_01_large_F",[]], | ||
["Land_MetalCase_01_medium_F",[]], | ||
["Land_MetalCase_01_small_F",[]], | ||
["Box_IDAP_Equip_F",["camo","camo_signs"]], | ||
["Box_CSAT_Equip_F",["camo","camo_signs"]], | ||
["Box_NATO_Equip_F",["camo","camo_signs"]], | ||
["Box_EAF_Equip_F",["camo","camo_signs"]], | ||
["Box_GEN_Equip_F",["camo","camo_signs"]], | ||
["Land_PlasticCase_01_large_F",["camo"]], | ||
["Land_PlasticCase_01_large_CBRN_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_large_black_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_large_black_CBRN_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_large_olive_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_large_olive_CBRN_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_large_gray_F",["camo"]], | ||
["Land_PlasticCase_01_large_idap_F",["camo"]], | ||
["Land_PlasticCase_01_medium_F",["camo"]], | ||
["Land_PlasticCase_01_medium_CBRN_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_medium_black_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_medium_black_CBRN_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_medium_olive_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_medium_olive_CBRN_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_medium_gray_F",["camo"]], | ||
["Land_PlasticCase_01_medium_idap_F",["camo"]], | ||
["Land_PlasticCase_01_small_F",["camo"]], | ||
["Land_PlasticCase_01_small_CBRN_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_small_black_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_small_black_CBRN_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_small_olive_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_small_olive_CBRN_F",["Camo","Camo2"]], | ||
["Land_PlasticCase_01_small_gray_F",["camo"]], | ||
["Land_PlasticCase_01_small_idap_F",["camo"]], | ||
["Box_IND_Ammo_F",["Camo_Signs","Camo"]], | ||
["Box_T_East_Ammo_F",["Camo_Signs","Camo"]], | ||
["Box_East_Ammo_F",["Camo_Signs","Camo"]], | ||
["Box_EAF_Ammo_F",["Camo_Signs","Camo"]], | ||
["Box_NATO_Ammo_F",["Camo_Signs","Camo"]], | ||
["Box_IND_Wps_F",["Camo_Signs","Camo"]], | ||
["Box_T_East_Wps_F",["Camo_Signs","Camo"]], | ||
["Box_East_Wps_F",["Camo_Signs","Camo"]], | ||
["Box_EAF_Wps_F",["Camo_Signs","Camo"]], | ||
["Box_T_NATO_Wps_F",["Camo_Signs","Camo"]], | ||
["Box_NATO_Wps_F",["Camo_Signs","Camo"]], | ||
["Box_IND_WpsLaunch_F",["Camo_Signs","Camo"]], | ||
["Box_East_WpsLaunch_F",["Camo_Signs","Camo"]], | ||
["Box_EAF_WpsLaunch_F",["Camo_Signs","Camo"]], | ||
["Box_NATO_WpsLaunch_F",["Camo_Signs","Camo"]], | ||
["CargoNet_01_box_F",[]], | ||
["Box_C_UAV_06_F",["Camo","Medical"]], | ||
["Box_C_UAV_06_medical_F",["Camo","Medical"]], | ||
["Box_C_IDAP_UAV_06_medical_F",["Camo","Medical"]], | ||
["Box_C_UAV_06_Swifd_F",["Camo","Medical"]], | ||
["Box_C_IDAP_UAV_06_F",["Camo","Medical"]], | ||
["ACE_Wheel",[]], | ||
["ACE_Track",[]], | ||
["Land_CanisterFuel_F",["camo"]], | ||
["rhsusf_props_ScepterMFC_OD",["camo_fc"]], | ||
["FlexibleTank_01_forest_F",["Camo_1"]], | ||
["FlexibleTank_01_sand_F",["Camo_1"]] | ||
] | ||
*/ |