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 set callback function #583

Open
TheMade4 opened this issue Apr 8, 2023 · 9 comments
Open

Add set callback function #583

TheMade4 opened this issue Apr 8, 2023 · 9 comments
Labels
enhancement New feature or request

Comments

@TheMade4
Copy link

TheMade4 commented Apr 8, 2023

Description

Add set callback function

Solution

import _ba

def callback_func(*args):
#Code
return

_ba.set_callback(callback_name, callback_func)

Additional context

It is advisable to add a callback for the following functions:
_ba.client_info_query_response
_hooks.reset_to_main_menu
_hooks.set_config_fullscreen_on
_hooks.set_config_fullscreen_off
_hooks.not_signed_in_screen_message
_hooks.connecting_to_party_message
_hooks.rejecting_invite_already_in_party_message
_hooks.connection_failed_message
_hooks.temporarily_unavailable_message
_hooks.in_progress_message
_hooks.error_message
_hooks.purchase_not_valid_error
_hooks.purchase_already_in_progress_error
_hooks.gear_vr_controller_warning
_hooks.orientation_reset_cb_message
_hooks.orientation_reset_message
_hooks.on_app_resume
_apputils.handle_v1_cloud_log
_hooks.launch_main_menu_session
_hooks.language_test_toggle
_hooks.award_in_control_achievement
_hooks.award_dual_wielding_achievement
_apputils.print_corrupt_file_error
_hooks.play_gong_sound
_hooks.launch_coop_game
_hooks.purchases_restored_message
_hooks.dismiss_wii_remotes_window
_hooks.unavailable_message
_hooks.submit_analytics_counts
_hooks.set_last_ad_network
_hooks.no_game_circle_message
_hooks.google_play_purchases_not_available_message
_hooks.google_play_services_not_available_message
_hooks.empty_call
_hooks.level_icon_press
_hooks.trophy_icon_press
_hooks.coin_icon_press
_hooks.ticket_icon_press
_hooks.back_button_press
_hooks.friends_button_press
_hooks.print_trace
_hooks.toggle_fullscreen
_hooks.party_icon_activate
_hooks.read_config
_hooks.ui_remote_press
_hooks.quit_window
_hooks.remove_in_game_ads_message
_hooks.telnet_access_request
_hooks.on_app_pause
_hooks.do_quit
_hooks.shutdown
_hooks.gc_disable
ba.app.accounts_v1.show_post_purchase_message
_hooks.device_menu_press
_hooks.show_url_window
_hooks.party_invite_revoke
_hooks.filter_chat_message
_hooks.local_chat_message
ba.ShouldShatterMessage
ba.ImpactDamageMessage
ba.PickedUpMessage
ba.DroppedMessage
ba.OutOfBoundsMessage
ba.PickUpMessage
ba.DropMessage
_hooks.finish_bootstrapping
_input.get_device_value
_input.get_last_player_name_from_input_device
copy.deepcopy
copy.copy
ba.Activity
ba.Session
json.dumps
json.loads
OnScreenKeyboardWindow
_music.do_play_music
ba.app.handle_deep_link
ba.app.lang.get_resource
ba.app.lang.translate
ba.Lstr
ba.Call
_apputils.garbage_collect_session_end
ba.ContextError
ba.NotFoundError
ba.NodeNotFoundError
ba.SessionTeamNotFoundError
ba.InputDeviceNotFoundError
ba.DelegateNotFoundError
ba.SessionPlayerNotFoundError
ba.WidgetNotFoundError
ba.ActivityNotFoundError
ba.SessionNotFoundError
_dependency.AssetPackage
enums.TimeFormat
enums.TimeType
enums.InputType
enums.Permission
enums.SpecialChar
_player.Player
_hooks.get_player_icon
_language.Lstr.from_json
_hooks.uuid_str
_hooks.hash_strings
_hooks.have_account_v2_credentials
logging.debug
logging.info
logging.warning
logging.error
logging.critical
_hooks.implicit_sign_in
_hooks.implicit_sign_out
_hooks.login_adapter_get_sign_in_token_response
_apputils.on_too_many_file_descriptors

I got these functions from bombsquad_headless and not everything is functions here because I'm too lazy to sort it, but I think the general principle is clear.

@TheMade4 TheMade4 added the enhancement New feature or request label Apr 8, 2023
@IvanPragma
Copy link
Contributor

IvanPragma commented Apr 8, 2023

You can do monkey patch for any of this functions.

def function_new(*args, **kwargs) -> None:
    # your code here
    return function_old(*args, **kwargs)

function_old = module.function
module.function = function_new

@TheMade4 TheMade4 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 8, 2023
@TheMade4 TheMade4 reopened this Apr 8, 2023
@TheMade4
Copy link
Author

TheMade4 commented Apr 8, 2023

You can do monkey patch for any of this functions.

def function_new(*args, **kwargs) -> None:
    # your code here
    return function_uld(*args, **kwargs)

function_old = module.function
module.function = new_function

this will not work for the "ba" module from the plugin

@TheMade4
Copy link
Author

TheMade4 commented Apr 8, 2023

And also this functionality is needed on the server

@TheMade4
Copy link
Author

TheMade4 commented Apr 8, 2023

monkey patch will not work for ba._hooks.filter_chat_message from plugin

@IvanPragma
Copy link
Contributor

this will not work for the "ba" module from the plugin

For most functions/methods the monkey patch will work correctly.

@IvanPragma
Copy link
Contributor

monkey patch will not work for ba._hooks.filter_chat_message from plugin

Yes, this is known issue. As far as I know, the C++ layer caches this function on startup. So, you can't monkey patch it from the plugin. To solve this problem you can create .py file at bastd module that will do monkey patch of this function, but don't forget to import this from bastd/__init__.py file.

@TheMade4
Copy link
Author

TheMade4 commented Apr 9, 2023

edit files in folder in ba_data is not an option

@Dliwk
Copy link
Collaborator

Dliwk commented Apr 14, 2023

Yes, known issue, if anyone would come up with some reload_hooks() PR, it would be great.

@TheMade4
Copy link
Author

Yes, known issue, if anyone would come up with some reload_hooks() PR, it would be great.

Yes, that's a good idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants