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 "initRetro" event to addClassEventHandler #324

Merged
merged 4 commits into from
May 10, 2016
Merged

Conversation

PabstMirror
Copy link
Contributor

  • Adds ability to run init code on all current and future objects via addClassEventHandler

Example usage:

["SettingsInitialized", {
    if (feature_enabled) then {
        ["CAManBase", "initRetro", {
            systemChat format ["Enable Feature On %1", _this]
        }] call CBA_fnc_addClassEventHandler;
    };
} call ace_common_fnc_addEventHandler;

Normal "init" would have no effect on existing units because unit's init event has already happened by the time the settingsInit event has happened.

Runs init code on all current and future objects
@nicolasbadano
Copy link
Contributor

Looks interesting

@Killswitch00
Copy link
Contributor

Killswitch00 commented May 3, 2016

Looks useful. I'm pondering if there are other ways of naming the event. Still thinking...

@commy2
Copy link
Contributor

commy2 commented May 3, 2016

Why not make the _runRetroactiveInit flag an additional parameter of the function, instead of creating a new event name (that could potentially collide with something BI creates at some point even if very unlikely) ?

@nicolasbadano
Copy link
Contributor

nicolasbadano commented May 3, 2016

I was thinking the same, but that function has two optional parameters already, and _runRetroactiveInit would only work for one event type.

I have two wacky alt proposals:

  • Make the initRetro a wrapper function around CBA_fnc_addClassEventHandler, that just adds the init event and sepparately runs it for existing objects.
  • Or more daringly: make initRetro behaviour the default "init" behaviour

@PabstMirror
Copy link
Contributor Author

I was not sure about the event name; I think commy2 's idea would look like this:

Parameters:
5: _applyInitRetroactivly - Apply "init" event type on existing units that have already been initilized. [optional] (default: false)

To Call:

["CAManBase", "init", {systemChat str _this}, true, [], true] call CBA_fnc_addClassEventHandler;

If we like this way more, I will make the changes

@jonpas
Copy link
Member

jonpas commented May 8, 2016

I like the optional argument more, don't really see a need for a completely separate event.

@Killswitch00
Copy link
Contributor

Killswitch00 commented May 9, 2016

Agree - I prefer to have it as an optional argument to CBA_fnc_addClassEventHandler.

@PabstMirror
Copy link
Contributor Author

Updated

@commy2
Copy link
Contributor

commy2 commented May 10, 2016

I added another check to not do weird stuff with events that are not "init" and "initPost"

@nicolasbadano
Copy link
Contributor

As far as I can tell, it should be spelled Retroactively

@commy2 commy2 merged commit 27b0692 into master May 10, 2016
@commy2 commy2 deleted the retroactiveInit branch May 10, 2016 21:09
@commy2 commy2 added this to the 2.3.2 milestone May 15, 2016
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.

None yet

5 participants