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

Menu manager #28

Closed
Mistrick opened this issue Jul 12, 2018 · 0 comments · Fixed by #36
Closed

Menu manager #28

Mistrick opened this issue Jul 12, 2018 · 0 comments · Fixed by #36

Comments

@Mistrick
Copy link
Collaborator

Description

We need API for creating menus.
In amxx exists Old style menu and New menus.
I suggest create all in one.

enum Menu
{
	INVALID_MENU = -1
};

enum MenuStyle
{
	STYLE_ITEMS,
	STYLE_TEXT
}

enum MenuProps
{
	// def 7 like amxx
	MPROP_ITEMS_PER_PAGE,
	// def "\r#num#." like "1. item"
	// custom "\r[#num#]" like "[1] item"
	MPROP_NUMBER_FORMAT,
	// show/hide exit item
	MPROP_EXIT,
	// custom name for exit, back, next
	MPROP_EXIT_NAME,
	MPROP_NEXT_NAME,
	MPROP_BACK_NAME,
	// for hl, etc
	MPROP_NO_COLORS,
};

enum ItemStatus
{
	ITEM_ENABLED,
	ITEM_DISABLED
};


enum MenuItem
{
	MENU_EXIT = -3,
	MENU_NEXT = -2,
	MENU_BACK = -1
};

// typedef MenuHandler = function int (Menu menu, MenuAction action, int param1, int param2);

typeset MenuHandler
{
	// text style
	function void(
		Menu menu,
		int key,
		int player
	);

	// item style
	function void(
		Menu menu,
		MenuItem item,
		int player,
		any data
	);
};

typedef CallbackHandler = function ItemStatus (Menu menu, MenuItem item, int player);


methodmap Menu
{
	// param global if false then destroy after exit
	public native Menu(MenuHandler handler, MenuStyle style = STYLE_ITEMS, bool global = false);
	// param page only for STYLE_ITEMS
	public native void Show(int player, int time = -1, int page = 0);
	
	// only for STYLE_TEXT
	public native void AddText(const char text[]);
	public native void AddKeys(int keys);
	
	// only for STYLE_ITEMS
	public native void SetTitle(const char title[]);
	public native void AddItem(const char name[], any data = 0, CallbackHandler callback = 0);
	// for blank use AddText(0, "\n") or make "\n" by default instead ""
	// TODO: change native name
	public native void AddText(int slot = 0, const char text[] = "");
	public native void SetProp(MenuProps prop, any ...);
	property int Items {
		public native get();
    }
}

// close any active menu
native void CloseMenu(int player);

How do we replicate the issue?

Create manager?

Expected behavior (i.e. solution)

Other Comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants