Exemple #1
0
Fichier : xyz.c Projet : fbbs/fbbs
//      pager与msg设定
//
int x_userdefine() {
	int id;
	unsigned int newlevel;
	set_user_status(ST_USERDEF);
	if (!(id = getuser(currentuser.userid))) {
		screen_move_clear(3);
		screen_printf("错误的使用者 ID...");
		pressreturn();
		screen_clear();
		return 0;
	}
	screen_move(1, 0);
	screen_clrtobot();
	screen_move(2, 0);
	use_define = 1;
	newlevel = setperms(lookupuser.userdefine, "参数", NUMDEFINES,
			showperminfo);
	screen_move(2, 0);
	if (newlevel == lookupuser.userdefine)
		screen_printf("参数没有修改...\n");
	else {
		lookupuser.userdefine = newlevel;
		currentuser.userdefine = newlevel;
		substitut_record(PASSFILE, &lookupuser, sizeof(struct userec), id);
		screen_printf("新的参数设定完成...\n\n");
	}
	pressreturn();
	screen_clear();
	use_define = 0;
	return 0;
}
Exemple #2
0
int t_query(const char *uname)
{
	if (streq(currentuser.userid, "guest"))
		return DONOTHING;

	char userid[EXT_IDLEN + 1];
	if (uname) {
		if (*uname == '\0')
			return DONOTHING;
		strlcpy(userid, uname, sizeof(userid));
		strtok(userid, " ");
	} else {
		set_user_status(ST_QUERY);
		screen_flush();
		screen_move(2, 0);
		screen_clrtobot();
		screen_printf("<输入使用者代号, 按空白键可列出符合字串>");
		user_complete(1, "查询谁: ", userid, sizeof(userid));
		if (*userid == '\0')
			return FULLUPDATE;
	}

	if (tui_query_result(userid) != 0) {
		screen_move_clear(2);
		screen_printf("\033[1m不正确的使用者代号\033[m\n");
		pressanykey();
		return FULLUPDATE;
	}

	if (session_status() != ST_LUSERS && session_status() != ST_LAUSERS
			&& session_status() != ST_FRIEND && session_status() != ST_GMENU)
	pressanykey();
	return FULLUPDATE;
}
// Analogous to 'save_game()', but does not present any dialog to the user, and reports the results
// using screen_printf().  If inOverwriteRecent is set, it will save over the most recently saved
// or restored game (if possible).  If inOverwriteRecent is not set, or if there is no recent game
// to save over, it will pick a new, nonconflicting filename and save to it.
// Returns whether save was successful.
bool
save_game_full_auto(bool inOverwriteRecent) {
        bool createNewFile = !inOverwriteRecent;

        FileSpecifier theRecentSavedGame;
        get_current_saved_game_name(theRecentSavedGame);

        char theSavedGameName[256]; // XXX

        // If we're supposed to overwrite, change our minds if we seem to have no 'existing file'.
        if(!createNewFile) {
                theRecentSavedGame.GetName(theSavedGameName);
                if(strcmp(theSavedGameName, TS_GetCString(strFILENAMES, filenameDEFAULT_SAVE_GAME)) == 0)
                        createNewFile = true;
        }
        
        // Make up a filename (currently based on level name)
        if(createNewFile) {
                if(strncpy_filename_friendly(theSavedGameName, static_world->level_name, kMaxFilenameChars) <= 0)
                        strcpy(theSavedGameName, "Automatic Save");

                DirectorySpecifier theDirectory;
                theRecentSavedGame.ToDirectory(theDirectory);
                theRecentSavedGame.FromDirectory(theDirectory);
#if defined(mac) || defined(SDL_RFORK_HACK)
                // Note: SetName() currently ignores the 'type' argument, so I feel
                // little compulsion to try to figure it out.
                theRecentSavedGame.SetName(theSavedGameName,NONE);
#else
                theRecentSavedGame.AddPart(theSavedGameName);
#endif
        }
                
        
        FileSpecifier theOutputFile;
        
        if(createNewFile)
                make_nonconflicting_filename_variant(theRecentSavedGame, theOutputFile, kMaxFilenameChars);
        else
                theOutputFile = theRecentSavedGame;
        
        bool successfulSave = save_game_file(theOutputFile);

        theOutputFile.GetName(theSavedGameName);
        
        if(successfulSave) {
                screen_printf("%s saved game '%s'", createNewFile ? "Created new" : "Replaced existing", theSavedGameName);
                // play a sound?
        }
        else {
                screen_printf("Unable to save game as '%s'", theSavedGameName);
                // play a sound?
        }

        return successfulSave;
}
Exemple #4
0
Fichier : tui.c Projet : fbbs/fbbs
void tui_update_status_line(void)
{
	extern time_t login_start_time; //main.c

	char date[STRLEN];

	screen_move_clear(-1);

	if (!DEFINE(DEF_ENDLINE))
		return;

	fb_time_t now = fb_time();
	int cur_sec = now % 10;

	if (cur_sec < 5) {
		strlcpy(date, format_time(now, TIME_FORMAT_UTF8_ZH), sizeof(date));
	} else {
		if (resolve_boards() >= 0)
			convert_g2u(brdshm->date, date);
		else
			date[0] = '\0';
	}

	if (cur_sec >= 5 && is_birth(&currentuser)) {
		screen_printf("\033[0;1;33;44m[\033[36m                      "
				"啦啦~~生日快乐!记得要请客哟 :P"
				"                       \033[33m]\033[m");
	} else {
		int stay = (now - login_start_time) / 60;
		char stay_str[20];
		describe_stay(stay, stay_str, sizeof(stay_str));

		char notice[128];
		notice_string(notice, sizeof(notice));
		int notice_width = screen_display_width(notice, true);

		screen_printf("\033[1;44;33m[\033[36m%29s\033[33m]"
			"[\033[36m%5d\033[33m人\033[36m%3d\033[33m友]",
			date, session_count_online(),
			session_count_online_followed(!HAS_PERM(PERM_SEECLOAK)));
		// 剩下35列
		if (notice_width) {
			int space = 33 - notice_width;
			if (space > 0)
				tui_repeat_char(' ', space);
			screen_printf("[\033[%d;36m%s\033[m\033[1;33;44m]\033[m",
					_suppress_notice ? 1 : 5, notice);
		} else {
			int space = 27 - strlen(currentuser.userid);
			tui_repeat_char(' ', space);
			prints("[\033[36m%s\033[33m]%s\033[m", currentuser.userid,
					stay_str);
		}
	}
}
bool save_game(void)
{
	pause_game();
    bool success = create_quick_save();
    if (success)
        screen_printf("Game saved");
    else
        screen_printf("Save failed");
	resume_game();

	return success;
}
Exemple #6
0
Fichier : tui.c Projet : fbbs/fbbs
void tui_header_line(const char *menu, bool check_mail)
{
	extern int mailXX; //main.c
	char title[36];

	if (check_mail && chkmail())
		strlcpy(title, strstr(menu, "讨论区列表") ? "[您有信件,按 M 看新信]"
				: "[您有信件]", sizeof(title));
	else if (check_mail && mailXX == 1)
		strlcpy(title, "[信件过量,请整理信件!]", sizeof(title));
	else
		strlcpy(title, BBSNAME_UTF8, sizeof(title));

	bool show_board = true;
	int w1 = screen_display_width(menu, true),
		w2 = screen_display_width(title, true),
		w3 = screen_display_width(currboard, true) + 2;
	int spaces = 80 - w1 - w2 - w3;
	if (spaces < 0) {
		spaces = 80 - w1 - w2;
		show_board = false;
	}

	screen_move_clear(0);
	screen_printf("\033[1;33;44m%s", menu);
	if (spaces > 0)
		tui_repeat_char(' ', spaces / 2);
	if (streq(title, BBSNAME_UTF8))
		screen_printf("\033[37m%s", title);
	else if (title[0] == '[')
		screen_printf("\033[5;36m%s\033[0;1;44m", title);
	else
		screen_printf("\033[36m%s", title);
	if (spaces > 0)
		tui_repeat_char(' ', spaces - spaces / 2);
	if (show_board)
		screen_printf("\033[33m[%s]\033[m", currboard);
	tui_update_status_line();
	screen_move(1, 0);
}
Exemple #7
0
static void show_status_line(const editor_t *editor)
{
	screen_move_clear(-1);
	if (editor->hide_status_line)
		return;

	bool mail = chkmail();

	vector_size_t x;
	text_line_size_t y;
	real_pos(editor, &x, &y);

	screen_printf("\033[1;33;44m[%s] [\033[32m%s\033[33m]"
			" [\033[32m按\033[31mCtrl-Q\033[32m求救\033[33m]"
			" [\033[32m%d\033[33m,\033[32m%d\033[33m]\033[K\033[m",
			mail ? "\033[5;32m信\033[m\033[1;33;44m" : "  ",
			format_time(fb_time(), TIME_FORMAT_UTF8_ZH) + 7,
			x, y);
}
Exemple #8
0
void init_ddb_syms(void){
#if 0
    int s=0, x=0;

    if( ddbinit ) return;
    ddbinit = 1;

    if( !strcmp("SYMBOLS", end) ){
	x = 1;
    }

    s = *(int*)(end + 8);
    symlen = s;

    screen_printf("ddb symbols %d bytes @ 0x%x (%d)\n", s, end, x);

    for(s=0;s<100000;s++){ ; }
#endif
}
Exemple #9
0
Fichier : user.c Projet : fbbs/fbbs
user_id_t user_complete_id(int row, const char *prompt)
{
	char name[IDLEN + 1];
	user_complete(row, prompt, name, sizeof(name));

	if (*name == '\0') {
		screen_clear();
		return 0;
	}

	user_id_t id = getuser(name);
	if (!id) {
		screen_move_clear(row + 3);
		screen_printf("错误的使用者代号");
		pressreturn();
		return 0;
	}
	return id;
}
Exemple #10
0
Fichier : xyz.c Projet : fbbs/fbbs
//      更改用户的权限设定
unsigned int setperms(unsigned int pbits, char *prompt, int numbers, int (*showfunc) ())
{
	int lastperm = numbers - 1;
	int i, done = NA;
	char choice[3], buf[80];
	screen_move(4, 0);
	screen_printf("\033[m请按下您要的代码来设定%s,按 Enter 结束.\n", prompt);
	screen_move(6, 0);
	screen_clrtobot();

	for (int j = 0; j < 16 && j < numbers; ++j) {
		showfunc(pbits, j, false);
		if (j + 16 < numbers) {
			tui_repeat_char(' ', 4);
			showfunc(pbits, j + 16, false);
		}
	}
	while (!done) {
		//% sprintf(buf, "选择(ENTER 结束%s): ",
		sprintf(buf, "\xd1\xa1\xd4\xf1(ENTER \xbd\xe1\xca\xf8%s): ",
				//% ((strcmp(prompt, "权限") != 0)) ? "" : ",0 停权");
				((strcmp(prompt, "\xc8\xa8\xcf\xde") != 0)) ? "" : "\xa3\xac""0 \xcd\xa3\xc8\xa8");
		getdata(-1, 0, buf, choice, 2, DOECHO, YEA);
		*choice = toupper(*choice);
		/*		if (*choice == '0')
		 return (0);
		 else modified by kit,rem 0停权* remed all by Amigo 2002.04.03*/
		if (*choice == '\n' || *choice == '\0')
		done = YEA;
		else if (*choice < 'A' || *choice> 'A' + lastperm)
		bell ();
		else {
			i = *choice - 'A';
			pbits ^= (1 << i);
			if ((*showfunc) (pbits, i, YEA) == NA) {
				pbits ^= (1 << i);
			} //if
		} //else
	}
	//while !done
	return (pbits);
}
Exemple #11
0
static tui_list_title_t online_users_title(tui_list_t *p)
{
	online_users_t *up = p->data;
	tui_header_line(up->follow ? "[关注列表]" : "[使用者列表]", true);
	screen_printf(" 寄信[\033[1;32mm\033[m] 送讯息[\033[1;32ms\033[m]"
			" 加,减关注[\033[1;32mo\033[m,\033[1;32md\033[m]"
			" 看说明档[\033[1;32m→\033[m,\033[1;32mRtn\033[m]"
			" 切换模式 [\033[1;32mf\033[m] 求救[\033[1;32mh\033[m]");
	
	//% const char *field = up->show_note ? "备注" : "昵称";
	const char *field = up->show_note ? "\xb1\xb8\xd7\xa2" : "\xea\xc7\xb3\xc6";

	char title[256];
	//% snprintf(title, sizeof(title), "\033[1;44m 编号  使用者代号   %s        "
	snprintf(title, sizeof(title), "\033[1;44m \xb1\xe0\xba\xc5  \xca\xb9\xd3\xc3\xd5\xdf\xb4\xfa\xba\xc5   %s        "
			//% "         上站位置            目前动态   发呆   \033[m\n",
			"         \xc9\xcf\xd5\xbe\xce\xbb\xd6\xc3            \xc4\xbf\xc7\xb0\xb6\xaf\xcc\xac   \xb7\xa2\xb4\xf4   \033[m\n",
			field);

	screen_move_clear(2);
	prints("%s", title);
}
Exemple #12
0
static int login_query(void)
{
#ifndef ENABLE_SSH
	char uname[IDLEN + 2];
	char passbuf[PASSLEN];
	int attempts;
	int recover; // For giveupBBS
	bool auth = false;
#endif // ENABLE_SSH

	// Deny new logins if too many users online.
	int online = session_count_online();
#ifndef ENABLE_SSH
	if (online >= MAXACTIVE) {
		ansimore("etc/loginfull", NA);
		return -1;
	}
#endif // ENABLE_SSH

	ansimore2("etc/issue", false, 0, 0);
	screen_printf("\033[1;35m欢迎光临\033[1;40;33m【 %s 】 \033[m"
			"[\033[1;33;41m Add '.' after YourID to login for BIG5 \033[m]\n",
			BBSNAME_UTF8);

	int peak = session_get_online_record();
	if (peak < online) {
		session_set_online_record(online);
		peak = online;
	}

	screen_printf("\033[1;32m目前已有帐号: [\033[1;36m%d\033[32m/\033[36m%d\033[32m] "
			"\033[32m目前站上人数: [\033[36m%d\033[32m/\033[36m%d\033[1;32m]\n",
			get_user_count(), MAXUSERS, online, MAXACTIVE);
	visitlog(peak);

#ifndef ENABLE_SSH
	attempts = 0;
	while (!auth) {
		if (attempts++ >= LOGINATTEMPTS) {
			ansimore("etc/goodbye", NA);
			return -1;
		}
		//% getdata(0, 0, "\033[1;33m请输入帐号\033[m"
		getdata(0, 0, "\033[1;33m\xc7\xeb\xca\xe4\xc8\xeb\xd5\xca\xba\xc5\033[m"
				//% "(试用请输入'\033[1;36mguest\033[m', "
				"(\xca\xd4\xd3\xc3\xc7\xeb\xca\xe4\xc8\xeb'\033[1;36mguest\033[m', "
				//% "注册请输入'\033[1;31mnew\033[m'): ",
				"\xd7\xa2\xb2\xe1\xc7\xeb\xca\xe4\xc8\xeb'\033[1;31mnew\033[m'): ",
				uname, IDLEN + 1, DOECHO, YEA);
		if (strcaseeq(uname, "guest") && (online > MAXACTIVE - 10)) {
			ansimore("etc/loginfull", NA);
			return -1;
		}
		if (strcaseeq(uname, "new")) {
			memset(&currentuser, 0, sizeof(currentuser));
			new_register();
			terminal_flush();
			exit(1);
		} else if (*uname == '\0')
			;
		else if (!dosearchuser(uname, &currentuser, &usernum)) {
			screen_printf("\033[1;31m经查证,无此 ID。\033[m\n");
		} else if (strcaseeq(uname, "guest")) {
			currentuser.userlevel = 0;
			break;
		} else {
			//% getdata(0, 0, "\033[1;37m请输入密码: \033[m", passbuf, PASSLEN,
			getdata(0, 0, "\033[1;37m\xc7\xeb\xca\xe4\xc8\xeb\xc3\xdc\xc2\xeb: \033[m", passbuf, PASSLEN,
					NOECHO, YEA);
			passbuf[8] = '\0';
			switch (bbs_auth(uname, passbuf)) {
				case BBS_EWPSWD:
					screen_printf("\033[1;31m密码输入错误...\033[m\n");
					break;
				case BBS_EGIVEUP:
					recover = chk_giveupbbs();
					screen_printf("\033[33m您正在戒网,离戒网结束还有%d天\033[m\n",
							recover - fb_time() / 3600 / 24);
					return -1;
				case BBS_ESUICIDE:
					screen_printf("\033[32m您已经自杀\033[m\n");
					return -1;
				case BBS_EBANNED:
					screen_printf("\033[32m本帐号已停机。请到 "
							"\033[36mNotice\033[32m版 查询原因\033[m\n");
					return -1;
				case BBS_ELFREQ:
					screen_printf("登录过于频繁,请稍候再来\n");
					return -1;
				case 0:
					auth = true;
					break;
				default:
					auth = false;
					break;
			}
			memset(passbuf, 0, PASSLEN - 1);
		}
	}
#else // ENABLE_SSH
	//% 欢迎使用ssh方式访问本站,请按任意键继续
	presskeyfor("\033[1;33m\xbb\xb6\xd3\xad\xca\xb9\xd3\xc3ssh\xb7\xbd\xca\xbd\xb7\xc3\xce\xca\xb1\xbe\xd5\xbe\xa3\xac\xc7\xeb\xb0\xb4\xc8\xce\xd2\xe2\xbc\xfc\xbc\xcc\xd0\xf8", -1);
#endif // ENABLE_SSH

	if (multi_user_check() == -1)
		return -1;

	sethomepath(genbuf, currentuser.userid);
	mkdir(genbuf, 0755);
	login_start_time = time(NULL);
	return 0;
}
Exemple #13
0
Fichier : tui.c Projet : fbbs/fbbs
static int _tui_input(int line, int col, const char *prompt, char *buf,
		int len, int echo, int clear, bool utf8)
{
	extern int RMSG;
	extern int msg_num;

	if (clear)
		buf[0] = '\0';
	buf[len - 1] = '\0';

	int real_x = prompt ? screen_display_width(prompt, utf8) : 0;

	int cur, clen;
	cur = clen = strlen(buf);

	bool inited = screen_inited(), prompted = false;
	while (1) {
		if (inited || !prompted) {
			screen_move(line, col);
			clrtoeol();
			if (prompt) {
				if (utf8)
					screen_printf("%s", prompt);
				else
					prints("%s", prompt);
			}
			prompted = true;
		}
		if (inited) {
			if (echo)
				prints("%s", buf);
			else
				tui_repeat_char('*', clen);
			screen_move(line, real_x + cur);
		}

		if (RMSG)
			screen_flush();

		int ch = terminal_getchar();

		if (RMSG && msg_num == 0) {
			if (ch == Ctrl('Z') || ch == KEY_UP) {
				buf[0] = Ctrl('Z');
				clen = 1;
				break;
			}
			if (ch == Ctrl('A') || ch == KEY_DOWN) {
				buf[0] = Ctrl('A');
				clen = 1;
				break;
			}
		}

		if (ch == '\n' || ch == '\r')
			break;

		if (!inited) {
			if (ch == '\x7f' || ch == Ctrl('H')) {
				int dec = remove_character(buf, &cur, clen, true);
				if (dec) {
					clen -= dec;
					screen_puts("\x8 \x8", 3);
				}
			} else if (isprint2(ch) && clen < len - 1) {
				buf[cur] = ch;
				buf[++cur] = '\0';
				++clen;
				screen_putc(echo ? ch : '*');
			}
			continue;
		}

		if (ch == '\x7f' || ch == Ctrl('H')) {
			clen -= remove_character(buf, &cur, clen, true);
		} else if (ch == KEY_DEL) {
			clen -= remove_character(buf, &cur, clen, false);
		} else if (ch == KEY_LEFT) {
			if (cur > 0)
				--cur;
		} else if (ch == KEY_RIGHT) {
			if (cur < clen)
				++cur;
		} else if (ch == Ctrl('E') || ch == KEY_END) {
			cur = clen;
		} else if (ch == Ctrl('A') || ch == KEY_HOME) {
			cur = 0;
		} else if (isprint2(ch) && clen < len - 1) {
			if (buf[cur] != '\0')
				memmove(buf + cur + 1, buf + cur, clen - cur);
			buf[cur++] = ch;
			buf[++clen] = '\0';
		}
	}

	screen_putc('\n');
	screen_flush();
	return clen;
}
Exemple #14
0
static void handle_game_key(const SDL_Event &event)
{
	SDL_Keycode key = event.key.keysym.sym;
	SDL_Scancode sc = event.key.keysym.scancode;
	bool changed_screen_mode = false;
	bool changed_prefs = false;

	if (!game_is_networked && (event.key.keysym.mod & KMOD_CTRL) && CheatsActive) {
		int type_of_cheat = process_keyword_key(key);
		if (type_of_cheat != NONE)
			handle_keyword(type_of_cheat);
	}
	if (Console::instance()->input_active()) {
		switch(key) {
			case SDLK_RETURN:
			case SDLK_KP_ENTER:
				Console::instance()->enter();
				break;
			case SDLK_ESCAPE:
				Console::instance()->abort();
				break;
			case SDLK_BACKSPACE:
				Console::instance()->backspace();
				break;
			case SDLK_DELETE:
				Console::instance()->del();
				break;
			case SDLK_UP:
				Console::instance()->up_arrow();
				break;
			case SDLK_DOWN:
				Console::instance()->down_arrow();
				break;
			case SDLK_LEFT:
				Console::instance()->left_arrow();
				break;
			case SDLK_RIGHT:
				Console::instance()->right_arrow();
				break;
			case SDLK_HOME:
				Console::instance()->line_home();
				break;
			case SDLK_END:
				Console::instance()->line_end();
				break;
			case SDLK_a:
				if (event.key.keysym.mod & KMOD_CTRL)
					Console::instance()->line_home();
				break;
			case SDLK_b:
				if (event.key.keysym.mod & KMOD_CTRL)
					Console::instance()->left_arrow();
				break;
			case SDLK_d:
				if (event.key.keysym.mod & KMOD_CTRL)
					Console::instance()->del();
				break;
			case SDLK_e:
				if (event.key.keysym.mod & KMOD_CTRL)
					Console::instance()->line_end();
				break;
			case SDLK_f:
				if (event.key.keysym.mod & KMOD_CTRL)
					Console::instance()->right_arrow();
				break;
			case SDLK_h:
				if (event.key.keysym.mod & KMOD_CTRL)
					Console::instance()->backspace();
				break;
			case SDLK_k:
				if (event.key.keysym.mod & KMOD_CTRL)
					Console::instance()->forward_clear();
				break;
			case SDLK_n:
				if (event.key.keysym.mod & KMOD_CTRL)
					Console::instance()->down_arrow();
				break;
			case SDLK_p:
				if (event.key.keysym.mod & KMOD_CTRL)
					Console::instance()->up_arrow();
				break;
			case SDLK_t:
				if (event.key.keysym.mod & KMOD_CTRL)
					Console::instance()->transpose();
				break;
			case SDLK_u:
				if (event.key.keysym.mod & KMOD_CTRL)
					Console::instance()->clear();
				break;
			case SDLK_w:
				if (event.key.keysym.mod & KMOD_CTRL)
					Console::instance()->delete_word();
				break;
		}
	}
	else
	{
		if (sc == SDL_SCANCODE_ESCAPE) // (ZZZ) Quit gesture (now safer)
		{
			if(!player_controlling_game())
				do_menu_item_command(mGame, iQuitGame, false);
			else {
				if(get_ticks_since_local_player_in_terminal() > 1 * TICKS_PER_SECOND) {
					if(!game_is_networked) {
						do_menu_item_command(mGame, iQuitGame, false);
					}
					else {
#if defined(__APPLE__) && defined(__MACH__)
						screen_printf("If you wish to quit, press Command-Q");
#else
						screen_printf("If you wish to quit, press Alt+Q.");
#endif
					}
				}
			}
		}
		else if (input_preferences->shell_key_bindings[_key_volume_up].count(sc))
		{
			changed_prefs = SoundManager::instance()->AdjustVolumeUp(Sound_AdjustVolume());
		}
		else if (input_preferences->shell_key_bindings[_key_volume_down].count(sc))
		{
			changed_prefs = SoundManager::instance()->AdjustVolumeDown(Sound_AdjustVolume());
		}
		else if (input_preferences->shell_key_bindings[_key_switch_view].count(sc))
		{
			walk_player_list();
			render_screen(NONE);
		}
		else if (input_preferences->shell_key_bindings[_key_zoom_in].count(sc))
		{
			if (zoom_overhead_map_in())
				PlayInterfaceButtonSound(Sound_ButtonSuccess());
			else
				PlayInterfaceButtonSound(Sound_ButtonFailure());
		}
		else if (input_preferences->shell_key_bindings[_key_zoom_out].count(sc))
		{
			if (zoom_overhead_map_out())
				PlayInterfaceButtonSound(Sound_ButtonSuccess());
			else
				PlayInterfaceButtonSound(Sound_ButtonFailure());
		}
		else if (input_preferences->shell_key_bindings[_key_inventory_left].count(sc))
		{
			if (player_controlling_game()) {
				PlayInterfaceButtonSound(Sound_ButtonSuccess());
				scroll_inventory(-1);
			} else
				decrement_replay_speed();
		}
		else if (input_preferences->shell_key_bindings[_key_inventory_right].count(sc))
		{
			if (player_controlling_game()) {
				PlayInterfaceButtonSound(Sound_ButtonSuccess());
				scroll_inventory(1);
			} else
				increment_replay_speed();
		}
		else if (input_preferences->shell_key_bindings[_key_toggle_fps].count(sc))
		{
			PlayInterfaceButtonSound(Sound_ButtonSuccess());
			extern bool displaying_fps;
			displaying_fps = !displaying_fps;
		}
		else if (input_preferences->shell_key_bindings[_key_activate_console].count(sc))
		{
			if (game_is_networked) {
#if !defined(DISABLE_NETWORKING)
				Console::instance()->activate_input(InGameChatCallbacks::SendChatMessage, InGameChatCallbacks::prompt());
#endif
				PlayInterfaceButtonSound(Sound_ButtonSuccess());
			} 
			else if (Console::instance()->use_lua_console())
			{
				PlayInterfaceButtonSound(Sound_ButtonSuccess());
				Console::instance()->activate_input(ExecuteLuaString, ">");
			}
			else
			{
				PlayInterfaceButtonSound(Sound_ButtonFailure());
			}
		} 
		else if (input_preferences->shell_key_bindings[_key_show_scores].count(sc))
		{
			PlayInterfaceButtonSound(Sound_ButtonSuccess());
			{
				extern bool ShowScores;
				ShowScores = !ShowScores;
			}
		}	
		else if (sc == SDL_SCANCODE_F1) // Decrease screen size
		{
			if (!graphics_preferences->screen_mode.hud)
			{
				PlayInterfaceButtonSound(Sound_ButtonSuccess());
				graphics_preferences->screen_mode.hud = true;
				changed_screen_mode = changed_prefs = true;
			}
			else
			{
				int mode = alephone::Screen::instance()->FindMode(get_screen_mode()->width, get_screen_mode()->height);
				if (mode < alephone::Screen::instance()->GetModes().size() - 1)
				{
					PlayInterfaceButtonSound(Sound_ButtonSuccess());
					graphics_preferences->screen_mode.width = alephone::Screen::instance()->ModeWidth(mode + 1);
					graphics_preferences->screen_mode.height = alephone::Screen::instance()->ModeHeight(mode + 1);
					graphics_preferences->screen_mode.auto_resolution = false;
					graphics_preferences->screen_mode.hud = false;
					changed_screen_mode = changed_prefs = true;
				} else
					PlayInterfaceButtonSound(Sound_ButtonFailure());
			}
		}
		else if (sc == SDL_SCANCODE_F2) // Increase screen size
		{
			if (graphics_preferences->screen_mode.hud)
			{
				PlayInterfaceButtonSound(Sound_ButtonSuccess());
				graphics_preferences->screen_mode.hud = false;
				changed_screen_mode = changed_prefs = true;
			}
			else
			{
				int mode = alephone::Screen::instance()->FindMode(get_screen_mode()->width, get_screen_mode()->height);
				int automode = get_screen_mode()->fullscreen ? 0 : 1;
				if (mode > automode)
				{
					PlayInterfaceButtonSound(Sound_ButtonSuccess());
					graphics_preferences->screen_mode.width = alephone::Screen::instance()->ModeWidth(mode - 1);
					graphics_preferences->screen_mode.height = alephone::Screen::instance()->ModeHeight(mode - 1);
					if ((mode - 1) == automode)
						graphics_preferences->screen_mode.auto_resolution = true;
					graphics_preferences->screen_mode.hud = true;
					changed_screen_mode = changed_prefs = true;
				} else
					PlayInterfaceButtonSound(Sound_ButtonFailure());
			}
		}
		else if (sc == SDL_SCANCODE_F3) // Resolution toggle
		{
			if (!OGL_IsActive()) {
				PlayInterfaceButtonSound(Sound_ButtonSuccess());
				graphics_preferences->screen_mode.high_resolution = !graphics_preferences->screen_mode.high_resolution;
				changed_screen_mode = changed_prefs = true;
			} else
				PlayInterfaceButtonSound(Sound_ButtonFailure());
		}
		else if (sc == SDL_SCANCODE_F4)		// Reset OpenGL textures
		{
#ifdef HAVE_OPENGL
			if (OGL_IsActive()) {
				// Play the button sound in advance to get the full effect of the sound
				PlayInterfaceButtonSound(Sound_OGL_Reset());
				OGL_ResetTextures();
			} else
#endif
				PlayInterfaceButtonSound(Sound_ButtonInoperative());
		}
		else if (sc == SDL_SCANCODE_F5) // Make the chase cam switch sides
		{
			if (ChaseCam_IsActive())
				PlayInterfaceButtonSound(Sound_ButtonSuccess());
			else
				PlayInterfaceButtonSound(Sound_ButtonInoperative());
			ChaseCam_SwitchSides();
		}
		else if (sc == SDL_SCANCODE_F6) // Toggle the chase cam
		{
			PlayInterfaceButtonSound(Sound_ButtonSuccess());
			ChaseCam_SetActive(!ChaseCam_IsActive());
		}
		else if (sc == SDL_SCANCODE_F7) // Toggle tunnel vision
		{
			PlayInterfaceButtonSound(Sound_ButtonSuccess());
			SetTunnelVision(!GetTunnelVision());
		}
		else if (sc == SDL_SCANCODE_F8) // Toggle the crosshairs
		{
			PlayInterfaceButtonSound(Sound_ButtonSuccess());
			player_preferences->crosshairs_active = !player_preferences->crosshairs_active;
			Crosshairs_SetActive(player_preferences->crosshairs_active);
			changed_prefs = true;
		}
		else if (sc == SDL_SCANCODE_F9) // Screen dump
		{
			dump_screen();
		}
		else if (sc == SDL_SCANCODE_F10) // Toggle the position display
		{
			PlayInterfaceButtonSound(Sound_ButtonSuccess());
			{
				extern bool ShowPosition;
				ShowPosition = !ShowPosition;
			}
		}
		else if (sc == SDL_SCANCODE_F11) // Decrease gamma level
		{
			if (graphics_preferences->screen_mode.gamma_level) {
				PlayInterfaceButtonSound(Sound_ButtonSuccess());
				graphics_preferences->screen_mode.gamma_level--;
				change_gamma_level(graphics_preferences->screen_mode.gamma_level);
				changed_prefs = true;
			} else
				PlayInterfaceButtonSound(Sound_ButtonFailure());
		}
		else if (sc == SDL_SCANCODE_F12) // Increase gamma level
		{
			if (graphics_preferences->screen_mode.gamma_level < NUMBER_OF_GAMMA_LEVELS - 1) {
				PlayInterfaceButtonSound(Sound_ButtonSuccess());
				graphics_preferences->screen_mode.gamma_level++;
				change_gamma_level(graphics_preferences->screen_mode.gamma_level);
				changed_prefs = true;
			} else
				PlayInterfaceButtonSound(Sound_ButtonFailure());
		}
		else
		{
			if (get_game_controller() == _demo)
				set_game_state(_close_game);
		}
	}
	
	if (changed_screen_mode) {
		screen_mode_data temp_screen_mode = graphics_preferences->screen_mode;
		temp_screen_mode.fullscreen = get_screen_mode()->fullscreen;
		change_screen_mode(&temp_screen_mode, true);
		render_screen(0);
	}

	if (changed_prefs)
		write_preferences();
}