Shop-Core icon indicating copy to clipboard operation
Shop-Core copied to clipboard

Added Callbacks and Forwards on pressing the Exit and Back buttons in the item panel (in the menu).

Open IL0co opened this issue 3 years ago • 2 comments

Added forwards: Shop_OnItemPanelExitButton Shop_OnItemPanelBackButton

As well as callbacks that are registered when registering an item (Shop_SetCallbacks)

IL0co avatar Jun 27 '22 17:06 IL0co

Each addition into Shop_SetCallbacks is a pain. Need to think about another registration callbacks.

enum SHOP_CB_TYPE {
  ItemRegistration = 1,
  ItemToggle = 2,
  OtherThing = 3
}
Like `Shop_SetCallbackHandler(type: SHOP_CB_TYPE, handler: FuncPrototype);` and each row extend it like subscribing for individual events instead of having them at this complex function

TiBarification avatar Jun 28 '22 20:06 TiBarification

Each addition into Shop_SetCallbacks is a pain. Need to think about another registration callbacks.

enum SHOP_CB_TYPE {
  ItemRegistration = 1,
  ItemToggle = 2,
  OtherThing = 3
}
Like `Shop_SetCallbackHandler(type: SHOP_CB_TYPE, handler: FuncPrototype);` and each row extend it like subscribing for individual events instead of having them at this complex function

Yes, I think it will be very useful to use a system like sdkhooks. But how to do this in the current situation, when we already register everything in one native in a row?

This is what I do with my plugin, one native for registration and enum with a list of all types, as well as typeset MCS_ItemCallBack - where all function references are indicated.

enum MCS_ItemCallBackType {
	ItemCB_OnDisplay,			// Callback to the display name of an item
	ItemCB_OnPreview,			// Callback for the preview display request
	ItemCB_OnSwitching,			// Callback when switching an item.
	ItemCB_OnUsing,				// Callback when the item is used.
	ItemCB_Length,				// The number of elements in the enum.
};

native void MCS_RegItemCallBack(MCS_ItemCallBackType type, MCS_ItemCallBack callback, any data = 0);

IL0co avatar Jun 28 '22 20:06 IL0co