Jump to content
chronicsilence

createDiarySubject picture

Recommended Posts

The createDiarySubject script command can apparently take a third parameter, which is named "picture". I have tried giving paths to an image file for that parameter, but it doesn't seem to be doing anything. Does anyone know if it's possible to have an icon/picture next to a diary subject?

 

Alternatively, does anyone know if it's possible to change the color of the font for a diary subject (not the entry, just the subject title)?

Share this post


Link to post
Share on other sites

Is this what you mean?

 

Place an empty object > intel > secret file

 

In the init put 

if (isServer) then {
    this setVariable ["RscAttributeDiaryRecord_texture","a3\structures_f_epc\Items\Documents\Data\document_secret_01_co.paa", true];
    [this,"RscAttributeDiaryRecord",["Top Secret Docs","These Docs outline the enemies defenses",""]] call bis_fnc_setServerVariable;
    this setVariable ["recipients", west, true];
    [this,"init"] spawn bis_fnc_initIntelObject;
};

Now go pick it up.

Share this post


Link to post
Share on other sites

 

Does anyone know if it's possible to have an icon/picture next to a diary subject?

It is but the one passed by createDiarySubject is ignored in the engine by the looks of things.

The subject list is nothing but a listbox so you can use lbSetPicture and lbSetPictureRight along with lbSetPictureColor and lbSetPictureRightColor.

You can also use lbSetColor to change an entries text colour.

There are no commands to change an entries font only the whole listbox.

The only problem is that the list box is redrawn continuously along with the map so you have to keep updating the icons..

player createDiarySubject [ "New", "Something" ];
(uiNamespace getVariable "RscDiary" displayCtrl 51) ctrlAddEventHandler [ "Draw", {
    (uiNamespace getVariable "RscDiary" displayCtrl 1001) lbSetPicture [ 3, "a3\modules_f_curator\Data\portraitanimalsbutterflies_ca.paa" ];
    (uiNamespace getVariable "RscDiary" displayCtrl 1001) lbSetPictureColor [ 3, [ 0, 1, 0, 1 ] ];
    (uiNamespace getVariable "RscDiary" displayCtrl 1001) lbSetPictureRight [ 3, "a3\modules_f_curator\Data\portraitanimalsbutterflies_ca.paa" ];
    (uiNamespace getVariable "RscDiary" displayCtrl 1001) lbSetPictureRightColor [ 3, [ 1, 0, 0, 1 ] ];
    (uiNamespace getVariable "RscDiary" displayCtrl 1001) lbSetColor [ 3, [ 0, 0, 1, 1 ] ];
}];
  • Like 1

Share this post


Link to post
Share on other sites

Ok, so maybe not quite perfect. Your code snippet works for the briefing menu (map screen before the mission starts), but not when you open the map screen after the mission starts. Is it a different display or something when it's opened from the map screen instead of the briefing screen?

Share this post


Link to post
Share on other sites

Yes they are different displays but both are stored in the uiNamespace variable RscDiary when initialised. If you run the code at/before the briefing then the EH will be added to the briefing display. All you need to do is run it again once time > 0 to make sure it is also added to the in game map screen (I know the above code works there as i done my test from the debugConsole once the mission was running).

Share this post


Link to post
Share on other sites

Larrow,

I have some issue using the lbSetPicture: because of mods (CBA for example), server (are statistics on or off...Etc), it seems that I can't rely on the index returned by createDiarySubject.

 

Here's my code:

mynum = player createDiarySubject [ "WZ_newcomm", "Communication" ];
(uiNamespace getVariable "RscDiary" displayCtrl 51) ctrlAddEventHandler [ "Draw", {
    (uiNamespace getVariable "RscDiary" displayCtrl 1001) lbSetPicture [ mynum, "a3\modules_f_curator\Data\portraitradio_ca.paa" ];
    (uiNamespace getVariable "RscDiary" displayCtrl 1001) lbSetPictureColor [ mynum, [ 1, 0, 0, 1 ] ];
    (uiNamespace getVariable "RscDiary" displayCtrl 1001) lbSetColor [ mynum, [ 1, 0, 0, 1 ] ];
}];

I'm supposed to have a nice radio icon and "Communication", all in red but most of the time either it's white with no picture (because the index returned is too big compared to the number of lines appearing below "Map"), sometimes, while trying to correct it (through a mynum=mynum-1 or -2) I'm lowering it too much.

How can I check the real index I should use in the lbSet(...) commands ?

 

Thx !

Share this post


Link to post
Share on other sites

I had noticed this when i was playing with it, that subject index != to listbox index.

Only way i can think of getting around this is to update the listbox per the listboxes lbText.

Description.ext

class CfgFunctions {
	class myTag {
		class briefing {
			class addDiarySubjectIcons {
			};
		};
	};
};
\functions\briefing\fn_addDiarySubjectIcons.sqf

//[ Subject, Name, textColor, IconLeft, color, IconRight, color ] call myTag_fnc_addDiarySubjectIcons;
//["WZ_newcomm", "Communication", [1,0,0,1], "a3\modules_f_curator\Data\portraitradio_ca.paa", [1,0,0,1]] call myTag_fnc_addDiarySubjectIcons

if ( !hasInterface ) exitWith {};

if ( !((_this select [0, 2]) params [
	[ "_subject", "", [ "" ]],
	[ "_name", "", [ "" ]]
]) || { { _x isEqualTo "" }count [ _subject, _name ] > 0 } ) exitWith {
	"Diary subject - has no subject and/or name supplied" call BIS_fnc_error;
};

(_this select [2, (( count _this ) -2 )]) params [
	[ "_nameColor", [1,1,1,1], [ [] ], [4]],
	[ "_iconLeft", "", [ "" ]],
	[ "_ILColor", [1,1,1,1], [ [] ], [4]],
	[ "_iconRight", "", [ "" ]],
	[ "_IRColor", [1,1,1,1], [ [] ], [4]]
];

if ( player diarySubjectExists _subject ) exitWith {
	format [ "A diary subject called %1 already exists", str _subject ] call BIS_fnc_error;
};

if ( !isNil "addedDiarySubjects" && { { (_x select 0 select 0) isEqualTo _name }count addedDiarySubjects > 0 } ) exitWith {
	format [ "A diary subject named %1 already exists", str _name ] call BIS_fnc_error;
};

player createDiarySubject [_subject, _name];

if ( isNil "addedDiarySubjects" ) then {
	addedDiarySubjects = [ [ [_name, _nameColor], [_iconLeft, _ILColor], [_iconRight, _IRColor] ] ];
	_thread = [] spawn {

		_fnc_addEH = {
			addedDiarySubjects_EH = (uiNamespace getVariable "RscDiary" displayCtrl 51) ctrlAddEventHandler [ "Draw", {
				_subjectList = (ctrlParent( _this select 0 ) displayCtrl 1001);
				for "_index" from 0 to ((lbSize _subjectList) -1) do {
					{
						_name = _x select 0;
						_iconLeft = _x select 1;
						_iconRight = _x select 2;

						if ( (_subjectList lbText _index)  isEqualTo (_name select 0) ) then {
							if !( (_name select 1) isEqualTo [1,1,1,1] ) then {
								_subjectList lbSetColor [_index, _name select 1];
							};
							if !( (_iconLeft select 0) isEqualTo "" ) then {
								_subjectList lbSetPicture [ _index, _iconLeft select 0 ];
								_subjectList lbSetPictureColor [ _index, _iconLeft select 1 ];
							};
							if !( (_iconRight select 0)  isEqualTo "" ) then {
								_subjectList lbSetPictureRight [ _index, _iconRight select 0 ];
								_subjectList lbSetPictureRightColor [ _index, _iconRight select 1 ];
							};
						};
					}forEach ( missionNamespace getVariable [ "addedDiarySubjects", [] ] );
				};
			}];
		};

		//Wait for briefing screen to initialise
		waitUntil { !isNull ( uiNamespace getVariable [ "RscDiary", displayNull ] ) };
		//Add EH to briefing map screen
		[] call _fnc_addEH;
		//If we added subjects during briefing
		if ( isNull ( findDisplay 12 ) ) then {
			//Wait for mission map screen to initialise
			waitUntil { !isNull ( findDisplay 12 ) };
			//Add EH to mission map screen
			[] call _fnc_addEH;
		};

	};

}else{

	addedDiarySubjects pushBack [ [ _name, _nameColor ], [ _iconLeft, _ILColor ], [ _iconRight, _IRColor ] ];
};
Init.sqf (just as an example of adding subjects before and after mission start)

["test_before", "before", [1,0,0,1], "a3\modules_f_curator\Data\portraitradio_ca.paa", [1,0,0,1]] call myTag_fnc_addDiarySubjectIcons;

waitUntil { !isNull player && time > 0 };

["WZ_newcomm", "Communication", [1,0,0,1], "a3\modules_f_curator\Data\portraitradio_ca.paa", [1,0,0,1]] call myTag_fnc_addDiarySubjectIcons;
  • Like 2

Share this post


Link to post
Share on other sites

I had noticed this when i was playing with it, that subject index != to listbox index.

Only way i can think of getting around this is to update the listbox per the listboxes lbText.

Description.ext

class CfgFunctions {
	class myTag {
		class briefing {
			class addDiarySubjectIcons {
			};
		};
	};
};
\functions\briefing\fn_addDiarySubjectIcons.sqf

//[ Subject, Name, textColor, IconLeft, color, IconRight, color ] call myTag_fnc_addDiarySubjectIcons;
//["WZ_newcomm", "Communication", [1,0,0,1], "a3\modules_f_curator\Data\portraitradio_ca.paa", [1,0,0,1]] call myTag_fnc_addDiarySubjectIcons

if ( !hasInterface ) exitWith {};

if ( !((_this select [0, 2]) params [
	[ "_subject", "", [ "" ]],
	[ "_name", "", [ "" ]]
]) || { { _x isEqualTo "" }count [ _subject, _name ] > 0 } ) exitWith {
	"Diary subject - has no subject and/or name supplied" call BIS_fnc_error;
};

(_this select [2, (( count _this ) -2 )]) params [
	[ "_nameColor", [1,1,1,1], [ [] ], [4]],
	[ "_iconLeft", "", [ "" ]],
	[ "_ILColor", [1,1,1,1], [ [] ], [4]],
	[ "_iconRight", "", [ "" ]],
	[ "_IRColor", [1,1,1,1], [ [] ], [4]]
];

if ( player diarySubjectExists _subject ) exitWith {
	format [ "A diary subject called %1 already exists", str _subject ] call BIS_fnc_error;
};

if ( !isNil "addedDiarySubjects" && { { (_x select 0 select 0) isEqualTo _name }count addedDiarySubjects > 0 } ) exitWith {
	format [ "A diary subject named %1 already exists", str _name ] call BIS_fnc_error;
};

player createDiarySubject [_subject, _name];

if ( isNil "addedDiarySubjects" ) then {
	addedDiarySubjects = [ [ [_name, _nameColor], [_iconLeft, _ILColor], [_iconRight, _IRColor] ] ];
	_thread = [] spawn {

		_fnc_addEH = {
			addedDiarySubjects_EH = (uiNamespace getVariable "RscDiary" displayCtrl 51) ctrlAddEventHandler [ "Draw", {
				_subjectList = (uiNamespace getVariable "RscDiary" displayCtrl 1001);
				for "_index" from 0 to ((lbSize _subjectList) -1) do {
					{
						_name = _x select 0;
						_iconLeft = _x select 1;
						_iconRight = _x select 2;

						if ( (_subjectList lbText _index)  isEqualTo (_name select 0) ) then {
							if !( (_name select 1) isEqualTo [1,1,1,1] ) then {
								_subjectList lbSetColor [_index, _name select 1];
							};
							if !( (_iconLeft select 0) isEqualTo "" ) then {
								_subjectList lbSetPicture [ _index, _iconLeft select 0 ];
								_subjectList lbSetPictureColor [ _index, _iconLeft select 1 ];
							};
							if !( (_iconRight select 0)  isEqualTo "" ) then {
								_subjectList lbSetPictureRight [ _index, _iconRight select 0 ];
								_subjectList lbSetPictureRightColor [ _index, _iconRight select 1 ];
							};
						};
					}forEach ( missionNamespace getVariable [ "addedDiarySubjects", [] ] );
				};
			}];
		};

		//Wait for briefing screen to initialise
		waitUntil { !isNull ( uiNamespace getVariable [ "RscDiary", displayNull ] ) };
		//Add EH to briefing map screen
		[] call _fnc_addEH;
		//If we added subjects during briefing
		if ( isNull ( findDisplay 12 ) ) then {
			//Wait for mission map screen to initialise
			waitUntil { !isNull ( findDisplay 12 ) };
			//Add EH to mission map screen
			[] call _fnc_addEH;
		};

	};

}else{

	addedDiarySubjects pushBack [ [ _name, _nameColor ], [ _iconLeft, _ILColor ], [ _iconRight, _IRColor ] ];
};
Init.sqf (just as an example of adding subjects before and after mission start)

["test_before", "before", [1,0,0,1], "a3\modules_f_curator\Data\portraitradio_ca.paa", [1,0,0,1]] call myTag_fnc_addDiarySubjectIcons;

waitUntil { !isNull player && time > 0 };

["WZ_newcomm", "Communication", [1,0,0,1], "a3\modules_f_curator\Data\portraitradio_ca.paa", [1,0,0,1]] call myTag_fnc_addDiarySubjectIcons;

 

Very cool functions Larrow. One bug that I've noticed: if you open the "journal" (with the J key) after the mission starts, then open the map screen, the colour/icon customization won't be there. It's like opening the journal resets it somehow.

Share this post


Link to post
Share on other sites

Very cool functions Larrow. One bug that I've noticed: if you open the "journal" (with the J key) after the mission starts, then open the map screen, the colour/icon customization won't be there. It's like opening the journal resets it somehow.

Fixed code in post #8, changed line 37 from

_subjectList = (uiNamespace getVariable "RscDiary" displayCtrl 1001);
to

_subjectList = (ctrlParent( _this select 0 ) displayCtrl 1001);
The journal is also known as RscDiary, once it has been used it nil's the uiNamespace variable. When you open the map and it tried to get the subjectlist by querying "RscDiary" which of course now didnt exist, so i have changed it to get the maps (ctrl event is added to) parent which will be the display.

Share this post


Link to post
Share on other sites

Fixed code in post #8, changed line 37 from

_subjectList = (uiNamespace getVariable "RscDiary" displayCtrl 1001);
to

_subjectList = (ctrlParent( _this select 0 ) displayCtrl 1001);
The journal is also known as RscDiary, once it has been used it nil's the uiNamespace variable. When you open the map and it tried to get the subjectlist by querying "RscDiary" which of course now didnt exist, so i have changed it to get the maps (ctrl event is added to) parent which will be the display.

 

 

Unfortunately, this didn't work for me. With the new code, the changes aren't applied in the map screen regardless of whether the journal has been opened yet. Were you able to get it working in a test mission?

Share this post


Link to post
Share on other sites

Unfortunately, this didn't work for me. With the new code, the changes aren't applied in the map screen regardless of whether the journal has been opened yet. Were you able to get it working in a test mission?

Yes the code in post #8 was copied straight from my test mission that i tested in SP,MP and dedicated just to make sure there were no oddities. I have cast my eye over the code in post #8 and i see no errors that may have occured by the forums formatting. I have re-pasted the code just to make sure, as i said in my last post the only thing that has changed is that one line.

Share this post


Link to post
Share on other sites

Yes the code in post #8 was copied straight from my test mission that i tested in SP,MP and dedicated just to make sure there were no oddities. I have cast my eye over the code in post #8 and i see no errors that may have occured by the forums formatting. I have re-pasted the code just to make sure, as i said in my last post the only thing that has changed is that one line.

 

Perhaps it's an issue with how I'm calling it then. If I want it in the pre-mission briefing AND the map screen, do I need to call it twice (with a waitUntil {time > 0} in between)? I tried calling it twice, but that didn't seem to work either. Maybe there's something else I'm missing.

Share this post


Link to post
Share on other sites

f I want it in the pre-mission briefing AND the map screen, do I need to call it twice (with a waitUntil {time > 0} in between)?

No, you only need to call it the once, it will then apply it to the map screen after the briefing aswell.

What are the subject and name of what your trying to add? Its not a conflict with these?

My test mission is basically what is in post #8, the description for defining the function, the function itself and the init which shows to different subjects one from briefing and onwards and one only applied after the briefing.

Share this post


Link to post
Share on other sites

No, you only need to call it the once, it will then apply it to the map screen after the briefing aswell.

What are the subject and name of what your trying to add? Its not a conflict with these?

My test mission is basically what is in post #8, the description for defining the function, the function itself and the init which shows to different subjects one from briefing and onwards and one only applied after the briefing.

 

Aha, I have figured out the problem. Try this in your init.sqf file:

 

["Test","Test", [1,0,0,1]] call myTag_fnc_addDiarySubjectIcons;

player unlinkItem "ItemMap";

Now when you open the map screen after the mission has started, the added subjects won't be coloured. It looks like opening the map screen when you don't have a map in your inventory causes it to open a different display, which apparently isn't covered in your event handler.

Share this post


Link to post
Share on other sites

Bump? Come on Larrow, you appear to be a wizard or something and I need your magic right now. I realized that it's because the map's "draw" event handler doesn't fire when there's no map to draw. So now I just need to find a way to trigger it without that event handler...

 

EDIT: nevermind, I got it! I used an "onEachFrame" event handler, then just added a check in it to only run if visibleMap returns true. I had to do a combination of the "draw" and "onEachFrame" handlers, since "visibleMap" returns false when the briefing screen is open.

Share this post


Link to post
Share on other sites

I did have a look into it, Ive just been trying to think of a better way to go about it. Im not a fan of onEachFrame, one its on each frame, ok you can hide it behind a condition of visibleMap but its still on each frame, two onEachFrame can so easily be canceled/overwritten.

MissionEventHandler Draw3D doesnt work unless the camera is the active view, other than turning it into an addon so you can add to the onLoad event the next best option has to create an invisible mapControl an use its onDraw event. This though has its own problems of losing focus when options on the title bar are clicked on. In the end i opted for this but just set focus back to the subject list, you end up with a small flicker here and there. Hence the reason i had not bothered replying while trying to thnik of a better solution.

//[ Subject, Name, textColor, IconLeft, color, IconRight, color ] call myTag_fnc_addDiarySubjectIcons;
//["WZ_newcomm", "Communication", [1,0,0,1], "a3\modules_f_curator\Data\portraitradio_ca.paa", [1,0,0,1]] call myTag_fnc_addDiarySubjectIcons

if ( !hasInterface ) exitWith {};

if ( !((_this select [0, 2]) params [
	[ "_subject", "", [ "" ]],
	[ "_name", "", [ "" ]]
]) || { { _x isEqualTo "" }count [ _subject, _name ] > 0 } ) exitWith {
	"Diary subject - has no subject and/or name supplied" call BIS_fnc_error;
};

(_this select [2, (( count _this ) -2 )]) params [
	[ "_nameColor", [1,1,1,1], [ [] ], [4]],
	[ "_iconLeft", "", [ "" ]],
	[ "_ILColor", [1,1,1,1], [ [] ], [4]],
	[ "_iconRight", "", [ "" ]],
	[ "_IRColor", [1,1,1,1], [ [] ], [4]]
];

if ( player diarySubjectExists _subject ) exitWith {
	format [ "A diary subject called %1 already exists", str _subject ] call BIS_fnc_error;
};

if ( !isNil "addedDiarySubjects" && { { (_x select 0 select 0) isEqualTo _name }count addedDiarySubjects > 0 } ) exitWith {
	format [ "A diary subject named %1 already exists", str _name ] call BIS_fnc_error;
};

player createDiarySubject [_subject, _name];

if ( isNil "addedDiarySubjects" ) then {
	addedDiarySubjects = [ [ [_name, _nameColor], [_iconLeft, _ILColor], [_iconRight, _IRColor] ] ];
	_thread = [] spawn {

		_fnc_addEH = {
			disableSerialization;
			_display = ( [ findDisplay 12, uiNamespace getVariable "RscDiary" ] select ( isNull findDisplay 12 ));
			_ctrl = _display ctrlCreate [ "RscMapControlEmpty", 999 ];
			_ctrl ctrlSetPosition [0, 0, 0, 0];
			_ctrl ctrlCommit 0;
			{
				_x ctrlAddEventHandler [ "Draw", {

					_subjectList = ( [ findDisplay 12, uiNamespace getVariable "RscDiary" ] select ( isNull findDisplay 12 ))  displayCtrl 1001;
					ctrlSetFocus _subjectList;
					for "_index" from 0 to ((lbSize _subjectList) -1) do {
						{
							_name = _x select 0;
							_iconLeft = _x select 1;
							_iconRight = _x select 2;

							if ( (_subjectList lbText _index)  isEqualTo (_name select 0) ) then {
								if !( (_name select 1) isEqualTo [1,1,1,1] ) then {
									_subjectList lbSetColor [_index, _name select 1];
								};
								if !( (_iconLeft select 0) isEqualTo "" ) then {
									_subjectList lbSetPicture [ _index, _iconLeft select 0 ];
									_subjectList lbSetPictureColor [ _index, _iconLeft select 1 ];
								};
								if !( (_iconRight select 0)  isEqualTo "" ) then {
									_subjectList lbSetPictureRight [ _index, _iconRight select 0 ];
									_subjectList lbSetPictureRightColor [ _index, _iconRight select 1 ];
								};
							};
						}forEach ( missionNamespace getVariable [ "addedDiarySubjects", [] ] );
					};

				}];
			}forEach [ _ctrl, _display displayCtrl 51 ];
		};

		//Wait for briefing screen to initialise
		waitUntil { !isNull ( uiNamespace getVariable [ "RscDiary", displayNull ] ) };
		//Add EH to briefing map screen
		[] call _fnc_addEH;
		//If we added subjects during briefing
		if ( isNull ( findDisplay 12 ) ) then {
			//Wait for mission map screen to initialise
			waitUntil { !isNull ( findDisplay 12 ) };
			//Add EH to mission map screen
			[] call _fnc_addEH;
		};

	};

}else{

	addedDiarySubjects pushBack [ [ _name, _nameColor ], [ _iconLeft, _ILColor ], [ _iconRight, _IRColor ] ];
};

Still not 100% happy with it, if i ever think of a better solution ill post it up.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×