plugins/include/adminmenu.inc
author David Anderson <dvander@alliedmods.net>
Fri Aug 15 05:22:26 2008 +0000 (2008-08-15)
changeset 2226 d10b38524be3
parent 1952 b7aa2b626807
child 2289 44045ead61cd
permissions -rw-r--r--
Landed sourcepawn-1.2. The big changes:

1) JIT compilation/optimization now occurs per-function, and only when functions are first used. We're now officially a whole-method JIT rather than an AOT compiler (albiet, still a simple JIT). This has two implications: Functions are now much better abstracted internally, and loading a plugin is now much less expensive. If a function contains calls to other functions, THOSE functions are only compiled when they're invoked as well.

2) I've removed debug mode. We always show full backtraces now, as there was a very cheap way to implement this which really cleaned up everything. This is great for a number of reasons -- there's less code, the JIT is better designed, we don't need to relocate debug tables, and best of all we no longer have to tell users to enable debug mode at their own expense.
ds@1952
     1
/**
ds@1952
     2
 * vim: set ts=4 :
ds@1952
     3
 * =============================================================================
ds@1952
     4
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
ds@1952
     5
 * =============================================================================
ds@1952
     6
 *
ds@1952
     7
 * This file is part of the SourceMod/SourcePawn SDK.
ds@1952
     8
 *
ds@1952
     9
 * This program is free software; you can redistribute it and/or modify it under
ds@1952
    10
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1952
    11
 * Free Software Foundation.
ds@1952
    12
 * 
ds@1952
    13
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1952
    14
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1952
    15
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1952
    16
 * details.
ds@1952
    17
 *
ds@1952
    18
 * You should have received a copy of the GNU General Public License along with
ds@1952
    19
 * this program.  If not, see <http://www.gnu.org/licenses/>.
ds@1952
    20
 *
ds@1952
    21
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1952
    22
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1952
    23
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1952
    24
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1952
    25
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1952
    26
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1952
    27
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1952
    28
 * or <http://www.sourcemod.net/license.php>.
ds@1952
    29
 *
ds@1952
    30
 * Version: $Id$
ds@1952
    31
 */
ds@1952
    32
 
ds@1952
    33
#if defined _adminmenu_included
ds@1952
    34
 #endinput
ds@1952
    35
#endif
ds@1952
    36
#define _adminmenu_included
ds@1952
    37
ds@1952
    38
/* Decide whether topmenus should be required */
ds@1952
    39
#if !defined REQUIRE_PLUGIN
ds@1952
    40
 #if defined REQUIRE_EXTENSIONS
ds@1952
    41
 #define TEMP_REQUIRE_EXTENSIONS
ds@1952
    42
 #undef REQUIRE_EXTENSIONS
ds@1952
    43
#endif
ds@1952
    44
ds@1952
    45
#include <topmenus>
ds@1952
    46
ds@1952
    47
/* Restore old REQUIRE_EXTENSIONS value if necessary */
ds@1952
    48
#if defined TEMP_REQUIRE_EXTENSIONS
ds@1952
    49
 #define REQUIRE_EXTENSIONS
ds@1952
    50
 #undef TEMP_REQUIRE_EXTENSIONS
ds@1952
    51
#endif
ds@1952
    52
ds@1952
    53
/** Category for player commands. */
ds@1952
    54
#define ADMINMENU_PLAYERCOMMANDS		"PlayerCommands"
ds@1952
    55
/** Category for server commands. */
ds@1952
    56
#define ADMINMENU_SERVERCOMMANDS		"ServerCommands"
ds@1952
    57
/** Category for voting commands. */
ds@1952
    58
#define ADMINMENU_VOTINGCOMMANDS		"VotingCommands"
ds@1952
    59
ds@1952
    60
/**
ds@1952
    61
 * Called when the admin menu is created and 3rd party plugins can grab 
ds@1952
    62
 * the Handle or add categories.
ds@1952
    63
 * 
ds@1952
    64
 * @param topmenu		Handle to the admin menu's TopMenu.
ds@1952
    65
 * @noreturn
ds@1952
    66
 */
ds@1952
    67
forward OnAdminMenuCreated(Handle:topmenu);
ds@1952
    68
ds@1952
    69
/**
ds@1952
    70
 * Called when the admin menu is ready to have items added.
ds@1952
    71
 * 
ds@1952
    72
 * @param topmenu		Handle to the admin menu's TopMenu.
ds@1952
    73
 * @noreturn
ds@1952
    74
 */
ds@1952
    75
forward OnAdminMenuReady(Handle:topmenu);
ds@1952
    76
ds@1952
    77
/**
ds@1952
    78
 * Retrieves the Handle to the admin top menu.
ds@1952
    79
 *
ds@1952
    80
 * @return				Handle to the admin menu's TopMenu,
ds@1952
    81
 *						or INVALID_HANDLE if not created yet.
ds@1952
    82
 */
ds@1952
    83
native Handle:GetAdminTopMenu();
ds@1952
    84
ds@1952
    85
/**
ds@1952
    86
 * Adds targets to an admin menu.
ds@1952
    87
 *
ds@1952
    88
 * Each client is displayed as: name (userid)
ds@1952
    89
 * Each item contains the userid as a string for its info.
ds@1952
    90
 *
ds@1952
    91
 * @param menu			Menu Handle.
ds@1952
    92
 * @param source_client	Source client, or 0 to ignore immunity.
ds@1952
    93
 * @param in_game_only	True to only select in-game players.
ds@1952
    94
 * @param alive_only 	True to only select alive players.
ds@1952
    95
 * @return				Number of clients added.
ds@1952
    96
 */
ds@1952
    97
native AddTargetsToMenu(Handle:menu, 
ds@1952
    98
						source_client, 
ds@1952
    99
						bool:in_game_only=true, 
ds@1952
   100
						bool:alive_only=false);
ds@1952
   101
ds@1952
   102
/**
ds@1952
   103
 * Adds targets to an admin menu.
ds@1952
   104
 *
ds@1952
   105
 * Each client is displayed as: name (userid)
ds@1952
   106
 * Each item contains the userid as a string for its info.
ds@1952
   107
 *
ds@1952
   108
 * @param menu			Menu Handle.
ds@1952
   109
 * @param source_client	Source client, or 0 to ignore immunity.
ds@1952
   110
 * @param flags			COMMAND_FILTER flags from commandfilters.inc.
ds@1952
   111
 * @return				Number of clients added.
ds@1952
   112
 */
ds@1952
   113
native AddTargetsToMenu2(Handle:menu, source_client, flags);
ds@1952
   114
ds@1952
   115
/**
ds@1952
   116
 * Re-displays the admin menu to a client after selecting an item.
ds@1952
   117
 * Auto-aborts if the Handle is invalid.
ds@1952
   118
 *
ds@1952
   119
 * @param topmenu		TopMenu Handle.
ds@1952
   120
 * @param client		Client index.
ds@1952
   121
 * @return				True on success, false on failure.
ds@1952
   122
 */
ds@1952
   123
stock bool:RedisplayAdminMenu(Handle:topmenu, client)
ds@1952
   124
{
ds@1952
   125
	if (topmenu == INVALID_HANDLE)
ds@1952
   126
	{
ds@1952
   127
		return false;
ds@1952
   128
	}
ds@1952
   129
ds@1952
   130
	return DisplayTopMenu(topmenu, client, TopMenuPosition_LastCategory);
ds@1952
   131
}
ds@1952
   132
ds@1952
   133
/* DO NOT EDIT BELOW THIS LINE */
ds@1952
   134
ds@1952
   135
public SharedPlugin:__pl_adminmenu = 
ds@1952
   136
{
ds@1952
   137
	name = "adminmenu",
ds@1952
   138
	file = "adminmenu.smx",
ds@1952
   139
#if defined REQUIRE_PLUGIN
ds@1952
   140
	required = 1,
ds@1952
   141
#else
ds@1952
   142
	required = 0,
ds@1952
   143
#endif
ds@1952
   144
};
ds@1952
   145
ds@1952
   146
#if !defined REQUIRE_PLUGIN
ds@1952
   147
public __pl_adminmenu_SetNTVOptional()
ds@1952
   148
{
ds@1952
   149
	MarkNativeAsOptional("GetAdminTopMenu");
ds@1952
   150
	MarkNativeAsOptional("AddTargetsToMenu");
ds@1952
   151
	MarkNativeAsOptional("AddTargetsToMenu2");
ds@1952
   152
}
ds@1952
   153
#endif