Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Marker texts are now localized to client #430

Merged
merged 22 commits into from
Dec 12, 2017
Merged

Add: Marker texts are now localized to client #430

merged 22 commits into from
Dec 12, 2017

Conversation

1kuemmel1
Copy link

@1kuemmel1 1kuemmel1 commented Nov 12, 2017

  • Add: Marker texts are now localized to client.

#400

When merged this pull request will:

  • marker texts are localized accordingly to client language
  • the marker will be localized separately on the client via removeExec and setMarkerTextLocal

Final test:

  • local
  • server

Screenshots
English dedicated server and German client
20171112162442_1

@1kuemmel1 1kuemmel1 changed the title Add marker handling client Add: Marker handling client Nov 12, 2017
@1kuemmel1 1kuemmel1 changed the title Add: Marker handling client Add: Marker texts are now localized to client Nov 12, 2017
@Vdauphin Vdauphin self-requested a review November 12, 2017 16:57
@Vdauphin Vdauphin added this to the 1.18 milestone Nov 12, 2017
Copy link
Owner

@Vdauphin Vdauphin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I wanted to do the same for markers so thanks to do it :)
As always I have some question ^^, see under :).

Generally, I don't see the point to check parameter passed to a function :

  • this add unnecessary complexity in function. I like short code with just the necessary, so it easy to understand what the function actually do
  • check parameter are usefull if you return an error or warning, so the user know he is not using your function correctly and can correct himself. That why I prefer to see a syntaxe error and a message in the RTP. They discribe the error very well and explain there are something wrong. If nothing is return, you can't see you are wrong and you leave hidden error. Those are very hard to find and resolve.

Just check then when it is necessary like I did it here. If you want more information ask me directly inside the PR

Thank you very much for your time!

["_arg", ""]
];
//only run on client
if (isDedicated) exitWith {};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is only compiled client side so there are no way this function could be executed on isDedicated (https://github.com/1kuemmel1/HeartsAndMinds/blob/8dd845701e68a3e0309429e4a93bc6dcc75f175b/%3DBTC%3Dco%4030_Hearts_and_Minds.Altis/core/fnc/compile.sqf#L245).

As I understand, Guillustio choosed to only compile function where there are supposed to works. By this way, the loading is faster because there are less function to compile (only usefull function are compiled) and you avoid this type of check in every function and call :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am Sorry. That's my fault: I used this function in another project some month ago. And the snippets are remnant. I will remove them.

@@ -58,7 +58,7 @@ _group = [_pos,8, 1 + round random 5,0.8] call btc_fnc_mil_create_group;
[_pos,20, 2 + round random 4,0.5] call btc_fnc_mil_create_group;

_pos = getPosASL _generator;
leader _group setPosASL [_pos select 0, _pos select 1, (_pos select 2) + 1 + random 1];
(leader (_group select 0)) setPosASL [_pos select 0, _pos select 1, (_pos select 2) + 1 + random 1];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be here, may be you based your branch on your last PR, doesn't matter :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake, sorry.

if !((typeName _marker) isEqualTo "STRING") then {_marker = str _marker;};

//check marker
if ((getMarkerPos _marker) isEqualTo [0,0,0]) exitWith {};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mean you can't create a marker at position [0,0,0].

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

if (isDedicated) exitWith {};

//check parameters
if !((typeName _marker) isEqualTo "STRING") then {_marker = str _marker;};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createMarker only return string, nop?
Is there situation where this function is call by H&M with a _marker not a string ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -242,6 +242,7 @@ if (!isDedicated) then {
btc_fnc_systemchat_debug = compile preprocessFileLineNumbers "core\fnc\common\systemchat_debug.sqf";
btc_fnc_show_hint = compile preprocessFileLineNumbers "core\fnc\common\show_hint.sqf";
btc_fnc_intro = compile preprocessFileLineNumbers "core\fnc\common\intro.sqf";
btc_fnc_set_markerText = compile preprocessFileLineNumbers "core\fnc\common\set_markerText.sqf";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btc_fnc_set_markerTextLocal may be ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea I will change this.

@@ -6,8 +6,7 @@ _vehicle = _this select 0;
_marker = createmarker [format ["m_%1",_vehicle],getPos _vehicle];
_marker setMarkerType "mil_box";
_marker setMarkerColor "ColorRed";
_marker setMarkerText format [(localize "STR_BTC_HAM_O_EH_VEHKILLED_MRK"),getText (configFile >> "cfgVehicles" >> typeof _vehicle >> "displayName")]; // %1 wreck

[_marker,{localize "STR_BTC_HAM_O_EH_VEHKILLED_MRK"},(getText (configFile >> "cfgVehicles" >> typeof _vehicle >> "displayName"))] remoteExec ["btc_fnc_set_markerText",0,true];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a simple [_marker,"STR_BTC_HAM_O_EH_VEHKILLED_MRK",(getText (configFile >> "cfgVehicles" >> typeof _vehicle >> "displayName"))] remoteExec ["btc_fnc_set_markerText",0,true]; ?

Then in btc_fnc_set_markerText and check isLocalized ? instead of :

//check text for localization code
if ((typeName _text) isEqualTo "CODE") then {
    _text = call _text;
};

Do it for all remoteexec with {localize

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 😄

@@ -19,7 +19,8 @@ if (isNil {_cache getVariable "btc_hd_cache"} && {_explosive} && {_damage > 0.6}
deleteVehicle btc_cache_obj;
_marker = createmarker [format ["btc_cache_%1", btc_cache_n], btc_cache_pos];
_marker setmarkertype "hd_destroy";
_marker setMarkerText format ["Cached %1 destroyed", btc_cache_n];
[_marker,{localize "STR_BTC_HAM_O_EH_HDCACHE_MRK"},btc_cache_n] remoteExec ["btc_fnc_set_markerText",0,true]; //Cached %1 destroyed
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remoteexec only client side (-2) not all (0).

Do it for all remoteexec :/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the reason for the execution on all machines.

A possible solution is this (for example):

[_marker,{localize "STR_BTC_HAM_O_EH_HDCACHE_MRK"},btc_cache_n] remoteExec ["btc_fnc_set_markerText", [0, -2] select isDedicated, true];

But so you have extra code.

@@ -36,12 +36,12 @@ btc_side_jip_data = [14,getPos _city1,_city1 getVariable "name"];
//// Create markers \\\\
_marker1 = createmarker [format ["sm_2_%1",getPos _city1],getPos _city1];
_marker1 setmarkertype "hd_flag";
_marker1 setmarkertext (localize "STR_BTC_HAM_SIDE_CONVOY_MRKSTART"); //Convoy Start
[_marker,{localize "STR_BTC_HAM_SIDE_CONVOY_MRKSTART"}] remoteExec ["btc_fnc_set_markerText",0,true]; //Convoy Start
Copy link
Owner

@Vdauphin Vdauphin Nov 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JIP should be removed at the end of side mission see exemple 7.

You could handle this by two way :

  • [] remoteExec ["someScriptCommand", targets, Object or Group or netId ]; see the "JIP (Optional):" section in remoteexec

  • Or get the JIP ID returned by remoteexec and remove it in this function here. When the marker is deleted, delete also the JIP remoteexec you created (if no JIP ID use "").

    Something like this could work (I wrote the concept):

    {
      params ["_marker", "_JIP_ID"];
      deletemarker _marker;
      if !(_JIP_ID isequalto "") then remoteExec ["", _JIP_ID]; 
    } foreach [["marker name1", "JIP ID1"],["marker name2", "JIP ID2"]];
    

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I´ve changed something. Please take a look.

@1kuemmel1
Copy link
Author

As always I have some question ^^, see under :).

No problem
Your comments will make the code even better and I'll learn something. That's great!

PS: Sorry for my late answer

@Vdauphin
Copy link
Owner

Vdauphin commented Nov 19, 2017

I also learn a lot!
Dont worry for the delay, I am also busy until middle of december... I will only work on PR with "Bug" label.
Have a good day!

Copy link
Owner

@Vdauphin Vdauphin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks even more great. I will do final test when those changes are done.

@@ -2,6 +2,8 @@

{
deletemarker _x;
//remove JIP remoteExec
remoteExec ["", _x];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! So there was a third solution !

@@ -36,12 +36,12 @@ btc_side_jip_data = [14,getPos _city1,_city1 getVariable "name"];
//// Create markers \\\\
_marker1 = createmarker [format ["sm_2_%1",getPos _city1],getPos _city1];
_marker1 setmarkertype "hd_flag";
_marker1 setmarkertext (localize "STR_BTC_HAM_SIDE_CONVOY_MRKSTART"); //Convoy Start
[_marker,"STR_BTC_HAM_SIDE_CONVOY_MRKSTART"] remoteExec ["btc_fnc_set_markerTextLocal", [0, -2] select isDedicated, _marker]; //Convoy Start
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_marker1

_marker1 setMarkerSize [0.6, 0.6];

_marker2 = createmarker [format ["sm_2_%1",_pos2],_pos2];
_marker2 setmarkertype "hd_flag";
_marker2 setmarkertext (localize "STR_BTC_HAM_SIDE_CONVOY_MRKEND"); //Convoy End
[_marker,"STR_BTC_HAM_SIDE_CONVOY_MRKEND"] remoteExec ["btc_fnc_set_markerTextLocal", [0, -2] select isDedicated, _marker]; //Convoy End
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_marker2

@@ -36,12 +36,12 @@ btc_side_jip_data = [14,getPos _city1,_city1 getVariable "name"];
//// Create markers \\\\
_marker1 = createmarker [format ["sm_2_%1",getPos _city1],getPos _city1];
_marker1 setmarkertype "hd_flag";
_marker1 setmarkertext (localize "STR_BTC_HAM_SIDE_CONVOY_MRKSTART"); //Convoy Start
[_marker,"STR_BTC_HAM_SIDE_CONVOY_MRKSTART"] remoteExec ["btc_fnc_set_markerTextLocal", [0, -2] select isDedicated, _marker]; //Convoy Start
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_marker1

_marker1 setMarkerSize [0.6, 0.6];

_marker2 = createmarker [format ["sm_2_%1",_pos2],_pos2];
_marker2 setmarkertype "hd_flag";
_marker2 setmarkertext (localize "STR_BTC_HAM_SIDE_CONVOY_MRKEND"); //Convoy End
[_marker,"STR_BTC_HAM_SIDE_CONVOY_MRKEND"] remoteExec ["btc_fnc_set_markerTextLocal", [0, -2] select isDedicated, _marker]; //Convoy End
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_marker2

@@ -6,7 +6,7 @@ _vehicle = _this select 0;
_marker = createmarker [format ["m_%1",_vehicle],getPos _vehicle];
_marker setMarkerType "mil_box";
_marker setMarkerColor "ColorRed";
_marker setMarkerText format [(localize "STR_BTC_HAM_O_EH_VEHKILLED_MRK"),getText (configFile >> "cfgVehicles" >> typeof _vehicle >> "displayName")]; // %1 wreck
[_marker,"STR_BTC_HAM_O_EH_VEHKILLED_MRK",(getText (configFile >> "cfgVehicles" >> typeof _vehicle >> "displayName"))] remoteExec ["btc_fnc_set_markerTextLocal", [0, -2] select isDedicated, _marker]; // %1 wreck
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the JIP when this marker is deleted ?
Add: remoteExec [_marker, _x]; in /core/fnc/log/server_repair_wreck.sqf#L13)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

done 😄

@@ -36,12 +36,12 @@ btc_side_jip_data = [14,getPos _city1,_city1 getVariable "name"];
//// Create markers \\\\
_marker1 = createmarker [format ["sm_2_%1",getPos _city1],getPos _city1];
_marker1 setmarkertype "hd_flag";
_marker1 setmarkertext (localize "STR_BTC_HAM_SIDE_CONVOY_MRKSTART"); //Convoy Start
[_marker1,"STR_BTC_HAM_SIDE_CONVOY_MRKSTART"] remoteExec ["btc_fnc_set_markerTextLocal", [0, -2] select isDedicated, _marker]; //Convoy Start
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Started to do local test and got an error : need _marker1 at the end of remoteExec also ^^ a sad copy and paste ;)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, ok. 😞

sorry

_marker1 setMarkerSize [0.6, 0.6];

_marker2 = createmarker [format ["sm_2_%1",_pos2],_pos2];
_marker2 setmarkertype "hd_flag";
_marker2 setmarkertext (localize "STR_BTC_HAM_SIDE_CONVOY_MRKEND"); //Convoy End
[_marker2,"STR_BTC_HAM_SIDE_CONVOY_MRKEND"] remoteExec ["btc_fnc_set_markerTextLocal", [0, -2] select isDedicated, _marker]; //Convoy End
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_marker2 ^^

Extended_PreInit_EventHandlers compile the compile.sqf file before the
JIP remoteExec "btc_fnc_" is executed
@Vdauphin Vdauphin merged commit bf486a2 into Vdauphin:master_daily Dec 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants