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

Cargo load menu overhaul #4871

Merged
merged 9 commits into from
May 31, 2017
Merged

Conversation

Dystopian
Copy link
Contributor

@Dystopian Dystopian commented Feb 4, 2017

  • add submenu with vehicles to cargo load menu
  • rewrite Load menu action and add condition
  • clean code

load_submenu

Vehicles with alive crew are suffixed with its name (in brackets).

There are also some questions to resolve:

  • should statement for Load menu be deleted? ATM it works as usually - loads to the nearest vehicle, while submenu items load to the specified vehicle;
  • should Load menu be renamed to "Load to" e.g.? If yes statement should be deleted (previous question);
  • should show condition be modified to take into account the nearest vehicles?

_action = [format ["%1", _x], _name, _icon, _statement, {true}, {}, [_x]] call ace_interact_menu_fnc_createAction;
_actions pushBack [_action, [], _target];
false
} count (_player nearEntities [["Car", "Air", "Tank", "Ship", "Cargo_base_F"], MAX_LOAD_DISTANCE]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not all vehicles can load stuff. I don't see that filtered here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean by that, what happens if you're near a vehicle that is Car, but cannot load anything? (e.g. a Kart)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"could not be loaded" message appears as earlier in "Load" action. And I think it's OK, in RL you can't magically see which vehicles have enough room.
As for Kart - maybe it has sense to check vehicles cargo space config in show condition. But this behavior differs from current "Load" action, I didn't want to change it. If you insist I'll add it and remove "Load" action.

#include "script_component.hpp"

params ["_target", "_player"];
private ["_statement", "_actions", "_name", "_ownerName", "_icon", "_action"];
Copy link
Contributor

@commy2 commy2 Feb 4, 2017

Choose a reason for hiding this comment

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

please use private keyword. The variables from L31 onwards aren't even in the same script instance!

@jonpas
Copy link
Member

jonpas commented Feb 4, 2017

should statement for Load menu be deleted? ATM it works as usually - loads to the nearest vehicle, while submenu items load to the specified vehicle;

I'd keep it.

should Load menu be renamed to "Load to" e.g.? If yes statement should be deleted (previous question);

I don't think so, as it has it's own action as well I think it's good as is.

should show condition be modified to take into account the nearest vehicles?

That probably wouldn't be bad if you can sort by distance easily without losing on performance.

TRACE_3("params",_player,_object,_vehicle);

if (isNull _vehicle) then {
_vehicle = [_player, _object] call FUNC(findNearestVehicle);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't reuse variable names in this way. Name it differently and set it to private.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you mean "_vehicle" I don't reuse it. I need it set to vehicle from parameters or from nearest vehicles.
If you mean something else I don't understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or you mean I shouldn't reuse variable which is from params? OK, I'll fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also I'll add new argument description.

_name = format ["%1 (%2)", _name, _ownerName];
};
private _icon = (getText (configFile >> "CfgVehicles" >> typeOf _x >> "icon")) call BIS_fnc_textureVehicleIcon;
private _action = [format ["%1", _x], _name, _icon, _statement, {true}, {}, [_x]] call ace_interact_menu_fnc_createAction;
Copy link
Contributor

Choose a reason for hiding this comment

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

EFUNC(interact_menu,createAction)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my bad

if ((isNull _vehicle) || {_vehicle isKindOf "Cargo_Base_F"}) then {
{
if ([_object, _x] call FUNC(canLoadItemIn)) exitWith {_vehicle = _x};
} forEach (nearestObjects [_player, ["Cargo_base_F", "Land_PaperBox_closed_F"], MAX_LOAD_DISTANCE]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a fan of magic numbers in code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not my code. I just put it inside if-then. Anyway I don't understand about magic numbers.

Copy link
Contributor

@commy2 commy2 Feb 5, 2017

Choose a reason for hiding this comment

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

Hard coded classnames like "Cargo_base_F" and especially "Land_PaperBox_closed_F".
This will make it harder to add compatibility with new objects later, because you have to alter lines buried in the code instead of a separate config and it will make it almost impossible for 3rd party mods.

@Dystopian
Copy link
Contributor Author

WIP

@jonpas jonpas added kind/feature Release Notes: **ADDED:** status/WIP labels Feb 8, 2017
@jonpas jonpas added this to the 3.10.0 milestone Feb 8, 2017
@Dystopian Dystopian changed the title Add submenu with vehicles to cargo load menu Cargo load menu overhaul Feb 8, 2017
@Dystopian
Copy link
Contributor Author

All done, please review

Copy link
Contributor

@PabstMirror PabstMirror left a comment

Choose a reason for hiding this comment

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

Tried this out and like it a lot

  • Good simplification of the code, while adding a feature
  • Also like how the base action "Load" still works and will just select the closest vehicle automatically (could possibly not show sub actions if there is only 1 vic in range, but that might be confusing as well?)

@PabstMirror PabstMirror added kind/enhancement Release Notes: **IMPROVED:** and removed status/needs-testing labels May 26, 2017
@kymckay
Copy link
Member

kymckay commented May 28, 2017

Yeah I'd definitely still show the sub action when only one is in range for consistency

@thojkooi thojkooi merged commit 9f291c8 into acemod:master May 31, 2017
@Dystopian Dystopian deleted the cargo-vehicles-submenu branch August 16, 2017 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Release Notes: **IMPROVED:** kind/feature Release Notes: **ADDED:**
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants