Ejemplo n.º 1
0
//called at the end of the program
void close_editor() {

	//	_MARK_("end of editor");//Nuked to compile -KRB
	
#ifndef __LINUX__
	set_warn_func(msgbox_warning);
#else
	clear_warn_func(NULL);
#endif
	
	close_editor_screen();
	
	//kill our camera object
	
	Viewer = ConsoleObject;					//reset viewer
	//@@obj_delete(camera_objnum);
	
	padnum = ui_pad_get_current();
	
	close_autosave();

	ui_close();

	gr_close_font(editor_font);

	PHYSFSX_removeRelFromSearchPath("editor/data");
	PHYSFSX_removeRelFromSearchPath("editor");
	PHYSFSX_removeRelFromSearchPath("editor.zip");
	PHYSFSX_removeRelFromSearchPath("editor.dxa");

	switch (ModeFlag)
	{
		case 1:
			if (Game_wind)
				window_close(Game_wind);
			break;

		case 2:
			if (Game_wind)
				window_close(Game_wind);
			set_screen_mode(SCREEN_MENU);		//put up menu screen
			show_menus();
			break;

		case 3:
			set_screen_mode(SCREEN_GAME);		//put up game screen
			Game_mode = GM_EDITOR;
			editor_reset_stuff_on_level();
			N_players = 1;
			break;
	}

	return;
}
Ejemplo n.º 2
0
void releasebutton(short code)
{
	int kbcode = AKEY_NONE, temp_ui = -1;
	
	if(ui_is_active)
		release_key(kbcode);
	else
	{
		if(code == joykey_map[get_screen_mode()][0])
			stick0 |= 1;
		else if(code == joykey_map[get_screen_mode()][1])
			stick0 |= 2;
		else if(code == joykey_map[get_screen_mode()][2])
			stick0 |= 4;
		else if(code == joykey_map[get_screen_mode()][3])
			stick0 |= 8;
		else if(code == klist.vkA || code == klist.vkB || ((code == '4' || code == '6') && issmartphone))
			trig0 = 1;
		else if(code == klist.vkC)
			if (kbui_timerset)
			{
				KillTimer(hWndMain, 1);
				kbui_timerset = FALSE;
				set_screen_mode(0);
				kbcode = AKEY_UI;
				push_key(kbcode);
				ui_clearkey = TRUE;
				return;
			}
	}

	release_key(kbcode);		// always release or the ui gets stuck
}
Ejemplo n.º 3
0
int do_game_pause()
{
	char *msg;
	char total_time[9],level_time[9];

#ifdef NETWORK
	if (Game_mode & GM_MULTI)
	{
		netplayerinfo_on= !netplayerinfo_on;
		return(KEY_PAUSE);
	}
#endif

	MALLOC(msg, char, 1024);
	if (!msg)
		return 0;

	songs_pause();

	format_time(total_time, f2i(Players[Player_num].time_total) + Players[Player_num].hours_total*3600);
	format_time(level_time, f2i(Players[Player_num].time_level) + Players[Player_num].hours_level*3600);
	if (Newdemo_state!=ND_STATE_PLAYBACK)
		snprintf(msg,1024,"PAUSE\n\nSkill level:  %s\nHostages on board:  %d\nTime on level: %s\nTotal time in game: %s",MENU_DIFFICULTY_TEXT(Difficulty_level),Players[Player_num].hostages_on_board,level_time,total_time);
	else
	  	snprintf(msg,1024,"PAUSE\n\nSkill level:  %s\nHostages on board:  %d\n",MENU_DIFFICULTY_TEXT(Difficulty_level),Players[Player_num].hostages_on_board);
	set_screen_mode(SCREEN_MENU);

	if (!window_create(&grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, (int (*)(window *, d_event *, void *))pause_handler, msg))
		d_free(msg);

	return 0 /*key*/;	// Keycode returning ripped out (kreatordxx)
}
Ejemplo n.º 4
0
void game_render_frame()
{
	set_screen_mode(SCREEN_GAME);
	play_homing_warning();
	game_render_frame_mono(GameArg.DbgUseDoubleBuffer);
	FrameCount++;
}
Ejemplo n.º 5
0
static void credits_show_common(RAIIPHYSFS_File file, const int have_bin_file)
{
	palette_array_t backdrop_palette;
	auto cr = make_unique<credits>();
	*cr = {};
	cr->file = std::move(file);
	cr->have_bin_file = have_bin_file;

	set_screen_mode(SCREEN_MENU);
#if defined(DXX_BUILD_DESCENT_II)
	gr_use_palette_table( "credits.256" );
#endif
	cr->backdrop.bm_data=NULL;

	const auto pcx_error = pcx_read_bitmap(STARS_BACKGROUND, cr->backdrop,backdrop_palette);
	if (pcx_error != PCX_ERROR_NONE)		{
		return;
	}

	songs_play_song( SONG_CREDITS, 1 );

	gr_remap_bitmap_good(cr->backdrop,backdrop_palette, -1, -1);

	gr_set_current_canvas(NULL);
	show_fullscr(cr->backdrop);
	gr_palette_load( gr_palette );

	key_flush();

	credits *pcr = cr.get();
	const auto wind = window_create(grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, credits_handler, cr.release());
	if (!wind)
	{
		d_event event = { EVENT_WINDOW_CLOSE };
		credits_handler(NULL, event, pcr);
		return;
	}

	event_process_all();
}
Ejemplo n.º 6
0
void kmatrix_view(int network)
{
	kmatrix_screen *km;
	window *wind;
	int i = 0;

	MALLOC(km, kmatrix_screen, 1);
	if (!km)
		return;

	gr_init_bitmap_data(&km->background);
	if (pcx_read_bitmap(STARS_BACKGROUND, &km->background, BM_LINEAR, gr_palette) != PCX_ERROR_NONE)
	{
		d_free(km);
		return;
	}
	gr_palette_load(gr_palette);
	
	km->network = network;
	km->end_time = -1;
	km->playing = 0;
	
	set_screen_mode( SCREEN_MENU );
	game_flush_inputs();

	for (i=0;i<MAX_PLAYERS;i++)
		digi_kill_sound_linked_to_object (Players[i].objnum);

	wind = window_create(&grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, (int (*)(window *, d_event *, void *))kmatrix_handler, km);
	if (!wind)
	{
		d_free(km);
		return;
	}
	
	while (window_exists(wind))
		event_process();
	gr_free_bitmap_data(&km->background);
	d_free(km);
}
Ejemplo n.º 7
0
void scores_view(stats_info *last_game, int citem)
{
	scores_menu *menu;

	MALLOC(menu, scores_menu, 1);
	if (!menu)
		return;

	menu->citem = citem;
	menu->t1 = timer_query();
	menu->looper = 0;
	if (last_game)
		menu->last_game = *last_game;

	newmenu_free_background();

	scores_read(&menu->scores);

	set_screen_mode(SCREEN_MENU);
	show_menus();

	window_create(&grd_curscreen->sc_canvas, (SWIDTH - FSPACX(320))/2, (SHEIGHT - FSPACY(200))/2, FSPACX(320), FSPACY(200),
				  (int (*)(window *, d_event *, void *))scores_handler, menu);
}
Ejemplo n.º 8
0
//	-----------------------------------------------------------------------------
//	Does the bonus scoring.
//	Call with dead_flag = 1 if player died, but deserves some portion of bonus (only skill points), anyway.
void DoEndLevelScoreGlitz(int network)
{ 
	int level_points, skill_points, energy_points, shield_points, hostage_points;
	int	all_hostage_points;
	int	endgame_points;
	char	all_hostage_text[64];
	char	endgame_text[64];
	#define N_GLITZITEMS 9
	char				m_str[N_GLITZITEMS][30];
	newmenu_item	m[9];
	int				i,c;
	char				title[128];
	int				is_last_level;

	gr_palette_load( gr_palette );

        set_screen_mode(SCREEN_MENU);

	level_points = Players[Player_num].score-Players[Player_num].last_score;

	if (!Cheats_enabled) {
		if (Difficulty_level > 1) {
			skill_points = level_points*(Difficulty_level-1)/2;
			skill_points -= skill_points % 100;
		} else
			skill_points = 0;

		shield_points = f2i(Players[Player_num].shields) * 10 * (Difficulty_level+1);
		energy_points = f2i(Players[Player_num].energy) * 5 * (Difficulty_level+1);
		hostage_points = Players[Player_num].hostages_on_board * 500 * (Difficulty_level+1);
	} else {
		skill_points = 0;
		shield_points = 0;
		energy_points = 0;
		hostage_points = 0;
	}

	all_hostage_text[0] = 0;
	endgame_text[0] = 0;

	if (!Cheats_enabled && (Players[Player_num].hostages_on_board == Players[Player_num].hostages_level)) {
		all_hostage_points = Players[Player_num].hostages_on_board * 1000 * (Difficulty_level+1);
		sprintf(all_hostage_text, "%s%i\n", TXT_FULL_RESCUE_BONUS, all_hostage_points);
	} else
		all_hostage_points = 0;

	if (!Cheats_enabled && !(Game_mode & GM_MULTI) && (Players[Player_num].lives) && (Current_level_num == Last_level)) {		//player has finished the game!
		endgame_points = Players[Player_num].lives * 10000;
		sprintf(endgame_text, "%s%i\n", TXT_SHIP_BONUS, endgame_points);
		is_last_level=1;
	} else
		endgame_points = is_last_level = 0;

	add_bonus_points_to_score(skill_points + energy_points + shield_points + hostage_points + all_hostage_points + endgame_points);

	c = 0;
	sprintf(m_str[c++], "%s%i", TXT_SHIELD_BONUS, shield_points);		// Return at start to lower menu...
	sprintf(m_str[c++], "%s%i", TXT_ENERGY_BONUS, energy_points);
	sprintf(m_str[c++], "%s%i", TXT_HOSTAGE_BONUS, hostage_points);
	sprintf(m_str[c++], "%s%i", TXT_SKILL_BONUS, skill_points);

	sprintf(m_str[c++], "%s", all_hostage_text);
	if (!(Game_mode & GM_MULTI) && (Players[Player_num].lives) && (Current_level_num == Last_level))
		sprintf(m_str[c++], "%s", endgame_text);

	sprintf(m_str[c++], "%s%i\n", TXT_TOTAL_BONUS, shield_points+energy_points+hostage_points+skill_points+all_hostage_points+endgame_points);
	sprintf(m_str[c++], "%s%i", TXT_TOTAL_SCORE, Players[Player_num].score);

	for (i=0; i<c; i++) {
		m[i].type = NM_TYPE_TEXT;
		m[i].text = m_str[i];
	}

	// m[c].type = NM_TYPE_MENU;	m[c++].text = "Ok";

	if (Current_level_num < 0)
		sprintf(title,"%s%s %d %s\n %s %s",is_last_level?"\n\n\n":"\n",TXT_SECRET_LEVEL, -Current_level_num, TXT_COMPLETE, Current_level_name, TXT_DESTROYED);
	else
		sprintf(title,"%s%s %d %s\n%s %s",is_last_level?"\n\n\n":"\n",TXT_LEVEL, Current_level_num, TXT_COMPLETE, Current_level_name, TXT_DESTROYED);

	Assert(c <= N_GLITZITEMS);

	time_out_value = timer_get_approx_seconds() + i2f(60*5);

#ifdef NETWORK
	if ( network && (Game_mode & GM_NETWORK) )
		newmenu_do2(NULL, title, c, m, network_endlevel_poll2, 0, Menu_pcx_name);
	else
#endif	// Note link!
		newmenu_do2(NULL, title, c, m, DoEndLevelScoreGlitzPoll, 0, Menu_pcx_name);
}
Ejemplo n.º 9
0
int automap_key_command(window *wind, d_event *event, automap *am)
{
	int c = event_key_get(event);
	int marker_num;
	char maxdrop;

	switch (c)
	{
		case KEY_PRINT_SCREEN: {
			gr_set_current_canvas(NULL);
			save_screen_shot(1);
			return 1;
		}
			
		case KEY_ESC:
			if (am->leave_mode==0)
			{
				window_close(wind);
				return 1;
			}
			return 1;
			
#ifndef NDEBUG
		case KEY_DEBUGGED+KEY_F: 	{
				int i;
				
				for (i=0; i<=Highest_segment_index; i++ )
					Automap_visited[i] = 1;
				automap_build_edge_list(am);
				am->max_segments_away = set_segment_depths(Objects[Players[Player_num].objnum].segnum, Automap_visited);
				am->segment_limit = am->max_segments_away;
				adjust_segment_limit(am, am->segment_limit);
			}
			return 1;
#endif
			
		case KEY_F9:
			if (am->segment_limit > 1) 		{
				am->segment_limit--;
				adjust_segment_limit(am, am->segment_limit);
			}
			return 1;
		case KEY_F10:
			if (am->segment_limit < am->max_segments_away) 	{
				am->segment_limit++;
				adjust_segment_limit(am, am->segment_limit);
			}
			return 1;
		case KEY_1:
		case KEY_2:
		case KEY_3:
		case KEY_4:
		case KEY_5:
		case KEY_6:
		case KEY_7:
		case KEY_8:
		case KEY_9:
		case KEY_0:
			if (Game_mode & GM_MULTI)
				maxdrop=2;
			else
				maxdrop=9;
			
			marker_num = c-KEY_1;
			if (marker_num<=maxdrop)
			{
				if (MarkerObject[marker_num] != -1)
					HighlightMarker=marker_num;
			}
			return 1;
			
		case KEY_D+KEY_CTRLED:
			if (HighlightMarker > -1 && MarkerObject[HighlightMarker] != -1) {
				gr_set_current_canvas(NULL);
				if (nm_messagebox( NULL, 2, TXT_YES, TXT_NO, "Delete Marker?" ) == 0) {
					obj_delete(MarkerObject[HighlightMarker]);
					MarkerObject[HighlightMarker]=-1;
					MarkerMessage[HighlightMarker][0]=0;
					HighlightMarker = -1;
				}
				set_screen_mode(SCREEN_GAME);
			}
			return 1;
			
#ifndef RELEASE
		case KEY_F11:	//KEY_COMMA:
			if (MarkerScale>.5)
				MarkerScale-=.5;
			return 1;
		case KEY_F12:	//KEY_PERIOD:
			if (MarkerScale<30.0)
				MarkerScale+=.5;
			return 1;
#endif
	}
	
	return 0;
}
Ejemplo n.º 10
0
static int main(int argc, char *argv[])
{
	if (!PHYSFSX_init(argc, argv))
		return 1;
	con_init();  // Initialise the console

	setbuf(stdout, NULL); // unbuffered output via printf
#ifdef _WIN32
	freopen( "CON", "w", stdout );
	freopen( "CON", "w", stderr );
#endif

	if (CGameArg.SysShowCmdHelp) {
		print_commandline_help();

		return(0);
	}

	printf("\nType '%s -help' for a list of command-line options.\n\n", PROGNAME);

	PHYSFSX_listSearchPathContent();
	
	if (!PHYSFSX_checkSupportedArchiveTypes())
		return(0);

#if defined(DXX_BUILD_DESCENT_I)
	if (! PHYSFSX_contfile_init("descent.hog", 1))
#define DXX_NAME_NUMBER	"1"
#define DXX_HOGFILE_NAMES	"descent.hog"
#elif defined(DXX_BUILD_DESCENT_II)
	if (! PHYSFSX_contfile_init("descent2.hog", 1) && ! PHYSFSX_contfile_init("d2demo.hog", 1))
#define DXX_NAME_NUMBER	"2"
#define DXX_HOGFILE_NAMES	"descent2.hog or d2demo.hog"
#endif
	{
#if defined(__unix__) && !defined(__APPLE__)
#define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
			      "\t$HOME/.d" DXX_NAME_NUMBER "x-rebirth\n"	\
			      "\t" SHAREPATH "\n"
#else
#define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
				  "\tDirectory containing D" DXX_NAME_NUMBER "X\n"
#endif
#if (defined(__APPLE__) && defined(__MACH__)) || defined(macintosh)
#define DXX_HOGFILE_APPLICATION_BUNDLE	\
				  "\tIn 'Resources' inside the application bundle\n"
#else
#define DXX_HOGFILE_APPLICATION_BUNDLE	""
#endif
#define DXX_MISSING_HOGFILE_ERROR_TEXT	\
		"Could not find a valid hog file (" DXX_HOGFILE_NAMES ")\nPossible locations are:\n"	\
		DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
		"\tIn a subdirectory called 'Data'\n"	\
		DXX_HOGFILE_APPLICATION_BUNDLE	\
		"Or use the -hogdir option to specify an alternate location."
		UserError(DXX_MISSING_HOGFILE_ERROR_TEXT);
	}

#if defined(DXX_BUILD_DESCENT_I)
	switch (PHYSFSX_fsize("descent.hog"))
	{
		case D1_MAC_SHARE_MISSION_HOGSIZE:
		case D1_MAC_MISSION_HOGSIZE:
			MacHog = 1;	// used for fonts and the Automap
			break;
	}
#endif

	load_text();

	//print out the banner title
#if defined(DXX_BUILD_DESCENT_I)
	con_printf(CON_NORMAL, "%s  %s", DESCENT_VERSION, g_descent_build_datetime); // D1X version
	con_printf(CON_NORMAL, "This is a MODIFIED version of Descent, based on %s.", BASED_VERSION);
	con_printf(CON_NORMAL, "%s\n%s",TXT_COPYRIGHT,TXT_TRADEMARK);
	con_printf(CON_NORMAL, "Copyright (C) 2005-2013 Christian Beckhaeuser");
#elif defined(DXX_BUILD_DESCENT_II)
	con_printf(CON_NORMAL, "%s%s  %s", DESCENT_VERSION, PHYSFSX_exists(MISSION_DIR "d2x.hog",1) ? "  Vertigo Enhanced" : "", g_descent_build_datetime); // D2X version
	con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2, based on %s.", BASED_VERSION);
	con_printf(CON_NORMAL, "%s\n%s",TXT_COPYRIGHT,TXT_TRADEMARK);
	con_printf(CON_NORMAL, "Copyright (C) 1999 Peter Hawkins, 2002 Bradley Bell, 2005-2013 Christian Beckhaeuser");
#endif

	if (CGameArg.DbgVerbose)
		con_puts(CON_VERBOSE, TXT_VERBOSE_1);
	
	ReadConfigFile();

	PHYSFSX_addArchiveContent();

	arch_init();

	select_tmap(CGameArg.DbgTexMap);

#if defined(DXX_BUILD_DESCENT_II)
	Lighting_on = 1;
#endif

	con_printf(CON_VERBOSE, "Going into graphics mode...");
	gr_set_mode(Game_screen_mode);

	// Load the palette stuff. Returns non-zero if error.
	con_printf(CON_DEBUG, "Initializing palette system..." );
#if defined(DXX_BUILD_DESCENT_I)
	gr_use_palette_table( "PALETTE.256" );
#elif defined(DXX_BUILD_DESCENT_II)
	gr_use_palette_table(D2_DEFAULT_PALETTE );
#endif

	con_printf(CON_DEBUG, "Initializing font system..." );
	gamefont_init();	// must load after palette data loaded.

#if defined(DXX_BUILD_DESCENT_II)
	con_printf( CON_DEBUG, "Initializing movie libraries..." );
	init_movies();		//init movie libraries
#endif

	show_titles();

	set_screen_mode(SCREEN_MENU);
#ifdef DEBUG_MEMORY_ALLOCATIONS
	/* Memdebug runs before global destructors, so it incorrectly
	 * reports as leaked any allocations that would be freed by a global
	 * destructor.  This local will force the newmenu globals to be
	 * reset before memdebug scans, which prevents memdebug falsely
	 * reporting them as leaked.
	 *
	 * External tools, such as Valgrind, know to run global destructors
	 * before checking for leaks, so this hack is only necessary when
	 * memdebug is used.
	 */
	struct hack_free_global_backgrounds
	{
		~hack_free_global_backgrounds()
		{
			newmenu_free_background();
		}
	};
	hack_free_global_backgrounds hack_free_global_background;
#endif

	con_printf( CON_DEBUG, "\nDoing gamedata_init..." );
	gamedata_init();

#if defined(DXX_BUILD_DESCENT_II)
#if DXX_USE_EDITOR
	if (GameArg.EdiSaveHoardData) {
		save_hoard_data();
		exit(1);
	}
	#endif
#endif

	if (CGameArg.DbgNoRun)
		return(0);

	con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
	texmerge_init();		// 10 cache bitmaps

#if defined(DXX_BUILD_DESCENT_II)
	piggy_init_pigfile("groupa.pig");	//get correct pigfile
#endif

	con_printf( CON_DEBUG, "\nRunning game..." );
	init_game();

	get_local_player().callsign = {};

#if defined(DXX_BUILD_DESCENT_I)
	key_flush();
#elif defined(DXX_BUILD_DESCENT_II)
	//	If built with editor, option to auto-load a level and quit game
	//	to write certain data.
	#ifdef	EDITOR
	if (!GameArg.EdiAutoLoad.empty()) {
		Players[0].callsign = "dummy";
	} else
	#endif
#endif
	{
		if (!CGameArg.SysPilot.empty())
		{
			char filename[sizeof(PLAYER_DIRECTORY_TEXT) + CALLSIGN_LEN + 4];

			/* Step over the literal PLAYER_DIRECTORY_TEXT when it is
			 * present.  Point at &filename[0] when
			 * PLAYER_DIRECTORY_TEXT is absent.
			 */
			const auto b = &filename[-CGameArg.SysUsePlayersDir];
			snprintf(filename, sizeof(filename), PLAYER_DIRECTORY_STRING("%.12s"), CGameArg.SysPilot.c_str());
			/* The pilot name is never used after this.  Clear it to
			 * free the allocated memory, if any.
			 */
			CGameArg.SysPilot.clear();
			auto p = b;
			for (const auto &facet = std::use_facet<std::ctype<char>>(std::locale::classic()); char &c = *p; ++p)
			{
				c = facet.tolower(static_cast<uint8_t>(c));
			}
			auto j = p - filename;
			if (j < sizeof(filename) - 4 && (j <= 4 || strcmp(&filename[j - 4], ".plr"))) // if player hasn't specified .plr extension in argument, add it
			{
				strcpy(&filename[j], ".plr");
				j += 4;
			}
			if(PHYSFSX_exists(filename,0))
			{
				get_local_player().callsign.copy(b, std::distance(b, &filename[j - 4]));
				read_player_file();
				WriteConfigFile();
			}
		}
	}

#if defined(DXX_BUILD_DESCENT_II)
#if DXX_USE_EDITOR
	if (!GameArg.EdiAutoLoad.empty()) {
		/* Any number >= FILENAME_LEN works */
		Level_names[0].copy_if(GameArg.EdiAutoLoad.c_str(), GameArg.EdiAutoLoad.size());
		LoadLevel(1, 1);
	}
	else
#endif
#endif
	{
		Game_mode = GM_GAME_OVER;
		DoMenu();
	}

	while (window_get_front())
		// Send events to windows and the default handler
		event_process();
	
	// Tidy up - avoids a crash on exit
	{
		window *wind;

		show_menus();
		while ((wind = window_get_front()))
			window_close(wind);
	}

	WriteConfigFile();
	show_order_form();

	con_printf( CON_DEBUG, "\nCleanup..." );
	close_game();
	texmerge_close();
	gamedata_close();
	gamefont_close();
	Current_mission.reset();
	PHYSFSX_removeArchiveContent();

	return(0);		//presumably successful exit
}
Ejemplo n.º 11
0
Archivo: main.cpp Proyecto: Lucki/Lix
int main(int argc, char* argv[])
{
    MainArgs margs = parse_main_arguments(argc, argv);

    if (margs.print_version_and_exit) {
        std::cout << Help::version_to_string(Globals::version) << std::endl;
        return 0;
    }
    else if (margs.print_help_and_exit) {
        print_usage();
        return 0;
    }

    // From here, load either the game or the interactive replay checker.
    // This will depend on existing dirs later on.

    setenv_allegro_modules();
    allegro_init();
    unsetenv_allegro_modules();

    Help::timer_start();

    ::loadpng_init();

    Globals::initialize();
    User::initialize();
    Log::initialize();
    LixEn::initialize();

    // Check whether the Globals decided we're in one of the accepted
    // working directories, so all files are found. Otherwise, exit with error.
    if (! Help::dir_exists(gloB->dir_data_bitmap)) {
        allegro_message("%s", gloB->error_wrong_working_dir.c_str());
        Log::deinitialize();
        Globals::deinitialize();
        return -1;
    }

    gloB->load();
    if (margs.input_user_name) {
        gloB->user_name = "";
    }
    useR->load();

    // Graphics are needed both by interactive and noninteractive mode
    ::set_color_depth(16);

    if (margs.replays_to_verify.empty()) {
        // interactive mode, i.e., no replay checking mode

        install_keyboard();
        hardware.set_mouse_accel_on_windows(useR->mouse_acceleration);
        install_mouse();
        if (! margs.suppress_sound_driver && gloB->sound_load_driver)
            Sound::initialize();

        if (margs.resolution_or_fullscreen_suggested_via_args)
            set_screen_mode(margs.fullscreen, margs.graphics_driver,
                            margs.screen_xl,  margs.screen_yl);
        else
            set_screen_mode(! useR->screen_windowed,
                            margs.graphics_driver, 0, 0);

        // BUG: in Windows, setting the window title with non-ASCII UTF-8
        // string does not seem to work (Allegro bug?)--non-ASCII characters
        // turn into ^.  Workaround by forcing use of English string here.
        //
        // (should main_name_of_the_game even be allowed for translation?)
        set_window_title(Language::main_name_of_game_English);

        if (useR->language == Language::NONE
         || useR->language >= Language::MAX) {
            // This is for the "initial use" case where there is no
            // user profile and therefore no language set.
            //
            // It is preferrable in that case to load the custom language
            // if it exists, so that we display the "loading..." texts (inside
            // load_all_bitmaps() below) text in the language the user probably
            // wants (the custom one if it exists, otherwise English)
            static_cast<void>(Language::try_load_custom_language(false));
        }

        load_all_bitmaps(GraLib::LOAD_WITH_RECOLOR_LIX);
        Network::initialize();

        // Main loop. See other/lmain.cpp for this.
        LMain* l_main = new LMain;
        l_main->main_loop();
        delete l_main;

        // Clean up
        useR->save();
        gloB->save();

        destroy_all_bitmaps();

        Network::deinitialize();
        Sound::deinitialize();
    }

    else {
        // noninteractive mode that checks replays
        Help::interactive_mode = false;
        Verifier(margs.replays_to_verify, margs.convert_and_overwrite
            ? Verifier::yes
            : Verifier::no);
    }

    Log::deinitialize();
    Globals::deinitialize();

    // don't call allegro_exit(), doing that causes the program
    // to not terminate in rare cases
    return 0;
}
Ejemplo n.º 12
0
void tapscreen(short x, short y)
{
	short kbcode;
	
	stylus_down = 1;

	/* On-screen joystick */
	if(virtual_joystick && !ui_is_active && currentKeyboardMode == 4 && y < 240)
	{
		stick0 = 0xff;
		trig0 = 1;
		if(y < 90) /* up */
			stick0 &= ~1;
		if(y >= 150) /* down */
			stick0 &= ~2;
		if(x < 120) /* left */
			stick0 &= ~4;
		if(x >= 200) /* right */
			stick0 &= ~8;
		if(x >= 60 && x < 260 && y >= 45 && y < 195)
			trig0 = 0;
		return;
	}

	translate_kbd(&x, &y);
	
	/* In landscape - show keyboard if clicked bottom right corner */
	if(get_screen_mode() && currentKeyboardMode == 4 && x > 300 && y > 220)
		return;
	
	kbcode = get_keypress(x, y);
	
	/* Special keys */
	switch(kbcode)
	{
	case KBD_ROTATE:
	case KBD_NEGATE:
	case KBD_HIDE:
		return;
	}
	
	/* The way current UI works, it is not compatible with keyboard implementation
	in landscape mode */
	if(kbcode == AKEY_UI)
		set_screen_mode(0);
	
	/* Special translation to make on-screen UI easier to use */
	if(ui_is_active)
	{
		if(machine_type == MACHINE_5200)
		{
			switch(kbcode)
			{
			case 0x3d: /* 2 */
				kbcode = AKEY_UP;
				break;
			case 0x2d: /* 8 */
				kbcode = AKEY_DOWN;
				break;
			case 0x37: /* 4 */
				kbcode = AKEY_LEFT;
				break;
			case 0x33: /* 6 */
				kbcode = AKEY_RIGHT;
				break;
			case 0x39: /* Start */
				kbcode = AKEY_RETURN;
				break;
			case 0x27: /* * */
				kbcode = AKEY_ESCAPE;
				break;
			case 0x31: /* Pause */
				kbcode = AKEY_TAB;
				break;
			case 0x23: /* # */
				kbcode = AKEY_SPACE;
				break;
			}
		}
		else
		{
			switch(kbcode)
			{
			case AKEY_MINUS:
				kbcode = AKEY_UP;
				break;
			case AKEY_EQUAL:
				kbcode = AKEY_DOWN;
				break;
			case AKEY_PLUS:
				kbcode = AKEY_LEFT;
				break;
			case AKEY_ASTERISK:
				kbcode = AKEY_RIGHT;
				break;
			}
		}
	}

	push_key(kbcode);
}
Ejemplo n.º 13
0
//	-----------------------------------------------------------------------------
//	Create the main menu.
void create_main_menu(newmenu_item *m, int *menu_choice, int *callers_num_options)
{
	int	num_options;

	#ifndef DEMO_ONLY
	num_options = 0;

//	//	Move down to allow for space to display "Destination Saturn"
//	if (Saturn) {
//		int	i;
//
//		for (i=0; i<4; i++)
//			ADD_ITEM("", 0, -1);
//
//		if (First_time) {
//			main_menu_choice = 4;
//			First_time = 0;
//		}
//	}

	set_screen_mode (SCREEN_MENU);
	

	ADD_ITEM(TXT_NEW_GAME,MENU_NEW_GAME,KEY_N);

#ifdef SHAREWARE
	if (get_game_list(NULL)>0)
#endif

  	ADD_ITEM(TXT_LOAD_GAME,MENU_LOAD_GAME,KEY_L);

#ifdef NETWORK
	ADD_ITEM(TXT_MULTIPLAYER_,MENU_MULTIPLAYER,-1);
#endif

	ADD_ITEM(TXT_OPTIONS_, MENU_CONFIG, -1 );
	ADD_ITEM(TXT_CHANGE_PILOTS,MENU_NEW_PLAYER,unused);
	ADD_ITEM(TXT_VIEW_DEMO,MENU_DEMO_PLAY,0);
	ADD_ITEM(TXT_VIEW_SCORES,MENU_VIEW_SCORES,KEY_V);
	#ifdef SHAREWARE
	ADD_ITEM(TXT_ORDERING_INFO,MENU_ORDER_INFO,-1);
	#endif
	ADD_ITEM(TXT_CREDITS,MENU_SHOW_CREDITS,-1);
	#endif
	ADD_ITEM(TXT_QUIT,MENU_QUIT,KEY_Q);

        #ifndef RELEASE
	if (!(Game_mode & GM_MULTI ))	{
		//m[num_options].type=NM_TYPE_TEXT;
		//m[num_options++].text=" Debug options:";

		ADD_ITEM("  Load level...",MENU_LOAD_LEVEL ,KEY_N);
		#ifdef EDITOR
		ADD_ITEM("  Editor", MENU_EDITOR, KEY_E);
		#endif
	}

	ADD_ITEM( "  Play song", MENU_PLAY_SONG, -1 );
        #endif

	*callers_num_options = num_options;
}
Ejemplo n.º 14
0
void scores_view(int citem)
{
	fix time_out_value;
	fix t1;
	int i,done,looper;
	int k;
	byte fades[64] = { 1,1,1,2,2,3,4,4,5,6,8,9,10,12,13,15,16,17,19,20,22,23,24,26,27,28,28,29,30,30,31,31,31,31,31,30,30,29,28,28,27,26,24,23,22,20,19,17,16,15,13,12,10,9,8,6,5,4,4,3,2,2,1,1 };

ReshowScores:
	scores_read();

	set_screen_mode(SCREEN_MENU);
	
	gr_set_current_canvas(NULL);
	
	nm_draw_background(0,0,grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );

	grd_curcanv->cv_font = Gamefonts[GFONT_MEDIUM_3];

	gr_string( 0x8000, 15, TXT_HIGH_SCORES );

	grd_curcanv->cv_font = Gamefonts[GFONT_SMALL];

	gr_set_fontcolor( BM_XRGB(31,26,5), -1 );
	gr_string(  31+33+XX, 46+7+YY, TXT_NAME );
	gr_string(  82+33+XX, 46+7+YY, TXT_SCORE );
	gr_string( 127+33+XX, 46+7+YY, TXT_SKILL );
	gr_string( 170+33+XX, 46+7+YY, TXT_LEVELS );
//	gr_string( 202, 46, "Kills" );
//	gr_string( 234, 46, "Rescues" );
	gr_string( 288-42+XX, 46+7+YY, TXT_TIME );

	if ( citem < 0 )	
		gr_string( 0x8000, 175, TXT_PRESS_CTRL_R );

	gr_set_fontcolor( BM_XRGB(28,28,28), -1 );

	gr_printf( 0x8000, 31, "%c%s%c  - %s", 34, Scores.cool_saying, 34, Scores.stats[0].name );
	
	for (i=0; i<MAX_HIGH_SCORES; i++ )		{
		if (i==0)	{
			gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
		} else {
			gr_set_fontcolor( gr_fade_table[BM_XRGB(28,28,28)+((28-i*2)*256)], -1 );
		}														 
		scores_draw_item( i, &Scores.stats[i] );
	}

	gr_palette_fade_in( gr_palette,32, 0);

	game_flush_inputs();

	done = 0;
	looper = 0;

	time_out_value = timer_get_fixed_seconds()+i2f(60*5);
	while(!done)	{
		if ( citem > -1 )	{
	
			t1	= timer_get_fixed_seconds();
			if ( t1 > time_out_value ) done = 1;
			while ( timer_get_fixed_seconds() < t1+F1_0/128 );	

			gr_set_fontcolor( gr_fade_table[fades[looper]*256+BM_XRGB(28,28,28)], -1 );
			looper++;
			if (looper>63) looper=0;
			if ( citem ==  MAX_HIGH_SCORES )
				scores_draw_item( MAX_HIGH_SCORES, &Last_game );
			else
				scores_draw_item( citem, &Scores.stats[citem] );
		}

		for (i=0; i<4; i++ )	
			if (joy_get_button_down_cnt(i)>0) done=1;
		for (i=0; i<3; i++ )	
			if (mouse_button_down_count(i)>0) done=1;

		k = key_inkey();
		switch( k )	{
		case KEY_CTRLED+KEY_R:		
			if ( citem < 0 )		{
				// Reset scores...
				if ( nm_messagebox( NULL, 2,  TXT_NO, TXT_YES, TXT_RESET_HIGH_SCORES )==1 )	{
					remove( get_scores_filename() );
					gr_palette_fade_out( gr_palette, 32, 0 );
					goto ReshowScores;
				}
			}
			break;
		case KEY_BACKSP:				Int3(); k = 0; break;
		case KEY_PRINT_SCREEN:		save_screen_shot(0); k = 0; break;
			
		case KEY_ENTER:
		case KEY_SPACEBAR:
		case KEY_ESC:
			done=1;
			break;
		}
	}

// Restore background and exit
	gr_palette_fade_out( gr_palette, 32, 0 );
	gr_set_current_canvas(NULL);

	game_flush_inputs();
	
}
Ejemplo n.º 15
0
void LMain::calc()
{
    hardware.main_loop();
    Api::Manager::calc();

    if (menu)
    {
        menu->calc();

        // Exit the menu?
        switch (menu->get_exit_with())
        {
        case Menu::START_LEVEL: {
            gameplay_started_with_replay = false;
            gameplay = new Gameplay();
            delete menu;
            menu = 0;
            break; }

        case Menu::START_REPLAY: {
            gameplay_started_with_replay = true;
            Replay r(useR->replay_last_level);
            gameplay = new Gameplay(&r);
            delete menu;
            menu = 0;
            break; }

        case Menu::START_EDITOR:
            editor = new Editor();
            delete menu;
            menu = 0;
            break;

        case Menu::EXIT_PROGRAM:
            exit = true;
            break;

        default:
            break;
        }
    }
    else if (gameplay) {
        gameplay->calc();

        if (gameplay->get_exit()) {
            SubMenu                           sub = SUBMENU_SINGLE;
            if (gameplay_started_with_replay) sub = SUBMENU_REPLAY;
            else if (Network::get_started())  sub = SUBMENU_NETWORK;

            menu = new Menu(sub);
            delete gameplay;
            gameplay = 0;
        }
    }
    else if (editor) {
        editor->calc();
        if (editor->get_exit()) {
            delete editor;
            editor = 0;
            menu = new Menu(SUBMENU_SINGLE);
        }
    }

    // Hotkey combination to terminate the program instantly from
    // everywhere. This doesn't bug the user about unsaved data.
    // Same goes for clicking the [x] button of the Allegro window.
    if ((key[KEY_ESC] && key[KEY_LSHIFT])
     || lmain_exit_window_button_pressed) {
        exit = true;
    }
    // Hotkey combination for fullscreen
    // Do not use key_enter_once() here, this is the time we want it with alt
    if (hardware.get_alt()
     && (hardware.key_once(KEY_ENTER) || hardware.key_once(KEY_ENTER_PAD))) {
        set_screen_mode(!gloB->screen_fullscreen_now);
    }

}
Ejemplo n.º 16
0
Archivo: scores.c Proyecto: btb/d2x
void scores_view(int citem)
{
	grs_canvas *center_canv;
	fix t1;
	int i,done,looper;
	int k;
	sbyte fades[64] = { 1,1,1,2,2,3,4,4,5,6,8,9,10,12,13,15,16,17,19,20,22,23,24,26,27,28,28,29,30,30,31,31,31,31,31,30,30,29,28,28,27,26,24,23,22,20,19,17,16,15,13,12,10,9,8,6,5,4,4,3,2,2,1,1 };

ReshowScores:
	scores_read();

	set_screen_mode(SCREEN_MENU);
 
	gr_set_current_canvas(NULL);
	
	nm_draw_background(0, 0, GWIDTH-1, GHEIGHT-1); // args are x,y,x2,y2 NOT x,y,w,h

	center_canv = gr_create_sub_canvas(grd_curcanv, GWIDTH/2-LHX(160), 0, LHX(320), GHEIGHT);
	gr_set_current_canvas(center_canv);

	grd_curcanv->cv_font = MEDIUM3_FONT;

	gr_string( 0x8000, LHY(15), TXT_HIGH_SCORES );

	grd_curcanv->cv_font = SMALL_FONT;

	gr_set_fontcolor( BM_XRGB(31,26,5), -1 );
	gr_string(  LHX(31+33+XX), LHY(46+7+YY), TXT_NAME );
	gr_string(  LHX(82+33+XX), LHY(46+7+YY), TXT_SCORE );
	gr_string( LHX(127+33+XX), LHY(46+7+YY), TXT_SKILL );
	gr_string( LHX(170+33+XX), LHY(46+7+YY), TXT_LEVELS );
//	gr_string( 202, 46, "Kills" );
//	gr_string( 234, 46, "Rescues" );
	gr_string( LHX(288-42+XX), LHY(46+7+YY), TXT_TIME );

	if ( citem < 0 )	
		gr_string( 0x8000, LHY(175), TXT_PRESS_CTRL_R );

	gr_set_fontcolor( BM_XRGB(28,28,28), -1 );

	gr_printf( 0x8000, LHY(31), "%c%s%c  - %s", 34, Scores.cool_saying, 34, Scores.stats[0].name );

	for (i=0; i<MAX_HIGH_SCORES; i++ )		{
		//@@if (i==0)	{
		//@@	gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
		//@@} else {
		//@@	gr_set_fontcolor( gr_fade_table[BM_XRGB(28,28,28)+((28-i*2)*256)], -1 );
		//@@}														 

		gr_set_fontcolor( BM_XRGB(28-i*2,28-i*2,28-i*2), -1 );
		scores_draw_item( i, &Scores.stats[i] );
	}

	gr_palette_fade_in( gr_palette,32, 0);

#ifdef OGL
	vid_update();
#endif

	game_flush_inputs();

	done = 0;
	looper = 0;

	while(!done)	{
		if ( citem > -1 )	{
	
			t1	= timer_get_fixed_seconds();
			while ( timer_get_fixed_seconds() < t1+F1_0/128 );	

			//@@gr_set_fontcolor( gr_fade_table[fades[looper]*256+BM_XRGB(28,28,28)], -1 );
			gr_set_fontcolor( BM_XRGB(7+fades[looper],7+fades[looper],7+fades[looper]), -1 );
			looper++;
			if (looper>63) looper=0;
			if ( citem ==  MAX_HIGH_SCORES )
				scores_draw_item( MAX_HIGH_SCORES, &Last_game );
			else
				scores_draw_item( citem, &Scores.stats[citem] );
			vid_update();
		}

		for (i=0; i<4; i++ )	
			if (joy_get_button_down_cnt(i)>0) done=1;
		for (i=0; i<3; i++ )	
			if (mouse_button_down_count(i)>0) done=1;

		//see if redbook song needs to be restarted
		songs_check_redbook_repeat();

		k = newmenu_inkey();
		switch( k )	{
		case KEY_CTRLED+KEY_R:		
			if ( citem < 0 )		{
				// Reset scores...
				if ( nm_messagebox( NULL, 2,  TXT_NO, TXT_YES, TXT_RESET_HIGH_SCORES )==1 )	{
					PHYSFS_delete(get_scores_filename());
					gr_palette_fade_out( gr_palette, 32, 0 );
					goto ReshowScores;
				}
			}
			break;
		case KEY_BACKSP:				Int3(); k = 0; break;
		case KEY_PRINT_SCREEN:		save_screen_shot(0); k = 0; break;
			
		case KEY_ENTER:
		case KEY_SPACEBAR:
		case KEY_ESC:
			done=1;
			break;
		}
	}

// Restore background and exit
	gr_palette_fade_out( gr_palette, 32, 0 );

	gr_set_current_canvas(NULL);
	gr_free_sub_canvas(center_canv);

	game_flush_inputs();
	
}
Ejemplo n.º 17
0
//if filename passed is NULL, show normal credits
void credits_show(char *credits_filename)
{
	credits *cr;
	window *wind;
	int i;
	int pcx_error;
	char * tempp;
	char filename[32];
	ubyte backdrop_palette[768];
	
	MALLOC(cr, credits, 1);
	if (!cr)
		return;
	
	cr->have_bin_file = 0;
	cr->buffer_line = 0;
	cr->first_line_offset = 0;
	cr->extra_inc = 0;
	cr->done = 0;
	cr->row = 0;

	// Clear out all tex buffer lines.
	for (i=0; i<NUM_LINES; i++ )
		cr->buffer[i][0] = 0;

	sprintf(filename, "%s", CREDITS_FILE);
	cr->have_bin_file = 0;
	if (credits_filename) {
		strcpy(filename,credits_filename);
		cr->have_bin_file = 1;
	}
	cr->file = PHYSFSX_openReadBuffered( filename );
	if (cr->file == NULL) {
		char nfile[32];
		
		if (credits_filename)
		{
			d_free(cr);
			return;		//ok to not find special filename
		}

		tempp = strchr(filename, '.');
		*tempp = '\0';
		sprintf(nfile, "%s.txb", filename);
		cr->file = PHYSFSX_openReadBuffered(nfile);
		if (cr->file == NULL)
			Error("Missing CREDITS.TEX and CREDITS.TXB file\n");
		cr->have_bin_file = 1;
	}

	set_screen_mode(SCREEN_MENU);
	gr_use_palette_table( "credits.256" );
	cr->backdrop.bm_data=NULL;

	pcx_error = pcx_read_bitmap(STARS_BACKGROUND,&cr->backdrop, BM_LINEAR,backdrop_palette);
	if (pcx_error != PCX_ERROR_NONE)		{
		PHYSFS_close(cr->file);
		d_free(cr);
		return;
	}

	songs_play_song( SONG_CREDITS, 1 );

	gr_remap_bitmap_good( &cr->backdrop,backdrop_palette, -1, -1 );

	gr_set_current_canvas(NULL);
	show_fullscr(&cr->backdrop);
	gr_palette_load( gr_palette );

	key_flush();

	wind = window_create(&grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, (int (*)(window *, d_event *, void *))credits_handler, cr);
	if (!wind)
	{
		d_event event = { EVENT_WINDOW_CLOSE };
		credits_handler(NULL, &event, cr);
		return;
	}

	while (window_exists(wind))
		event_process();
}
Ejemplo n.º 18
0
void credits_show()
{
	int i, j, l, done;
	CFILE * file;
	char buffer[NUM_LINES][80];
	grs_bitmap backdrop;
	ubyte backdrop_palette[768];
	int pcx_error;
	int buffer_line = 0;
	fix last_time;
	fix time_delay = 4180 / f2fl(Scale_y);			// ~ F1_0 / 12.9
	int first_line_offset,extra_inc=0;
	int have_bin_file = 0;
	char * tempp;
	grs_point scale_pts[] = FULLSCREEN_SCALE_PTS;
	ubyte *fade_values = malloc(grd_curscreen->sc_h);

	for (i = 0; i < grd_curscreen->sc_h; ++i) {
		fade_values[i] = fade_values_200[(int)(((float)i / (float)grd_curscreen->sc_h) * 200)];
	}

	set_screen_mode(SCREEN_MENU);

	// Clear out all tex buffer lines.
	for (i=0; i<NUM_LINES; i++ ) buffer[i][0] = 0;

	have_bin_file = 0;
	file = cfopen( "credits.tex", "rb" );
	if (file == NULL) {
		file = cfopen("credits.txb", "rb");
		if (file == NULL)
			Error("Missing CREDITS.TEX and CREDITS.TXB file\n");
		have_bin_file = 1;
	}

	gr_use_palette_table( "credits.256" );
	header_font = gr_init_font( "font1-1.fnt" );
	title_font = gr_init_font( "font2-3.fnt" );
	names_font = gr_init_font( "font2-2.fnt" );
	backdrop.bm_data=NULL;
	pcx_error = pcx_read_bitmap("stars.pcx",&backdrop,BM_LINEAR,backdrop_palette);
	if (pcx_error != PCX_ERROR_NONE)		{
		cfclose(file);
		return;
	}

	songs_play_song( SONG_CREDITS, 0 );

	gr_remap_bitmap_good( &backdrop,backdrop_palette, -1, -1 );

	gr_set_current_canvas(NULL);
	scale_bitmap(&backdrop,scale_pts);
	gr_palette_fade_in( gr_palette, 32, 0 );
	vfx_set_palette_sub( gr_palette );

	//gr_clear_canvas(BM_XRGB(0,0,0));
	key_flush();
	last_time = timer_get_fixed_seconds();
	done = 0;
	first_line_offset = 0;
	while( 1 )	{
		int k;

		do {
			buffer_line = (buffer_line+1) % NUM_LINES;
			if (cfgets( buffer[buffer_line], 80, file ))	{
				char *p;
				if (have_bin_file) {				// is this a binary tbl file
					for (i = 0; i < strlen(buffer[buffer_line]) - 1; i++) {
						encode_rotate_left(&(buffer[buffer_line][i]));
						buffer[buffer_line][i] ^= BITMAP_TBL_XOR;
						encode_rotate_left(&(buffer[buffer_line][i]));
					}
				}
				p = strchr(&buffer[buffer_line][0],'\n');
				if (p) *p = '\0';
			} else	{
				//fseek( file, 0, SEEK_SET);
				buffer[buffer_line][0] = 0;
				done++;
			}
		} while (extra_inc--);
		extra_inc = 0;

		for (i=0; i<ROW_SPACING; i++ )	{
			int y;

			y = first_line_offset - i;

#ifndef OGLES
			gr_set_current_canvas(VR_offscreen_buffer);
#endif
			scale_bitmap(&backdrop, scale_pts);
			for (j=0; j<NUM_LINES; j++ )	{
				char *s;

				l = (buffer_line + j + 1 ) %  NUM_LINES;
				s = buffer[l];

				if ( s[0] == '!' ) {
					s++;
				} else if ( s[0] == '$' )	{
					grd_curcanv->cv_font = header_font;
					s++;
				} else if ( s[0] == '*' )	{
					grd_curcanv->cv_font = title_font;
					s++;
				} else
					grd_curcanv->cv_font = names_font;

				gr_bitblt_fade_table = fade_values;

				tempp = strchr( s, '\t' );
				if ( tempp )	{
					int w, h, aw;
					*tempp = 0;
					gr_get_string_size( s, &w, &h, &aw );
					w *= f2fl(Scale_x);
					h *= f2fl(Scale_y);
					gr_scale_printf( (160-w)/2, y, Scale_factor, Scale_factor, s );
					gr_get_string_size( &tempp[1], &w, &h, &aw );
					w *= f2fl(Scale_x);
					h *= f2fl(Scale_y);
					gr_scale_printf( 160+((160-w)/2), y, Scale_factor, Scale_factor, &tempp[1] );
					*tempp = '\t';
				} else {
					gr_scale_printf( 0x8000, y, Scale_factor, Scale_factor, s );
				}
				gr_bitblt_fade_table = NULL;
				if (buffer[l][0] == '!')
					y += ROW_SPACING/2;
				else
					y += ROW_SPACING;
			}
#ifdef OGLES
			showRenderBuffer();
#else
			gr_bm_ubitblt(grd_curscreen->sc_w, grd_curscreen->sc_h, 0, 0, 0, 0, &(VR_offscreen_buffer->cv_bitmap), &(grd_curscreen->sc_canvas.cv_bitmap) );
#endif

			while( timer_get_fixed_seconds() < last_time+time_delay );
			last_time = timer_get_fixed_seconds();
		

			k = key_inkey();

			#ifndef NDEBUG
			if (k == KEY_BACKSP) {
				Int3();
				k=0;
			}
			#endif

//			{
//				fix ot = time_delay;
//				time_delay += (keyd_pressed[KEY_X] - keyd_pressed[KEY_Z])*100;
//				if (ot!=time_delay)	{
//					mprintf( (0, "[%x] ", time_delay ));
//				}
//			}

			if (k == KEY_PRINT_SCREEN) {
				save_screen_shot(0);
				k = 0;
			}

			if ((k>0)||(done>NUM_LINES))	{
					gr_close_font(header_font);
					gr_close_font(title_font);
					gr_close_font(names_font);
					gr_palette_fade_out( gr_palette, 32, 0 );
					gr_use_palette_table( "palette.256" );
					free(backdrop.bm_data);
					cfclose(file);
					songs_play_song( SONG_TITLE, 1 );
					return;
			}
		}

		if (buffer[(buffer_line + 1 ) %  NUM_LINES][0] == '!') {
			first_line_offset -= ROW_SPACING-ROW_SPACING/2;
			if (first_line_offset <= -ROW_SPACING) {
				first_line_offset += ROW_SPACING;
				extra_inc++;
			}
		}
	}
	free(fade_values);
}
Ejemplo n.º 19
0
void untapscreen(short x, short y)
{
	int kbcode;

	stylus_down = 0;

	/* On-screen joystick */
	if(virtual_joystick && !ui_is_active && currentKeyboardMode == 4 && y < 240)
	{
		stick0 = 0xff;
		trig0 = 1;
		return;
	}
	
	translate_kbd(&x, &y);
	
	/* Special tricks */
	/* In landscape - show keyboard if clicked bottom right corner */
	if(get_screen_mode() && currentKeyboardMode == 4)
	{
		if(x > 300 && y > 220 && !ui_is_active)
			currentKeyboardMode = 3;
		else if(ui_is_active)
			set_screen_mode(0);
		return;
	}
	
	/* In landscape -- move keyboard if clicked outside of it */
	int newKeyboardMode = currentKeyboardMode;
	if(get_screen_mode() && currentKeyboardMode != 4)
	{
		if(x<0 || x>=240)
			newKeyboardMode = newKeyboardMode ^ 1;
		if(y<0 || y>=80)
			newKeyboardMode = newKeyboardMode ^ 2;
	}
	if(newKeyboardMode != currentKeyboardMode)
	{
		currentKeyboardMode = newKeyboardMode;
		return;
	}
	
	kbcode = get_keypress(x, y);
	
	/* Special keys */
	switch(kbcode)
	{
	case KBD_ROTATE:
		if(!ui_is_active)
			set_screen_mode(get_screen_mode()+1);
		return;
	case KBD_NEGATE:
		currentKeyboardColor = 1-currentKeyboardColor;
		return;
	case KBD_HIDE:
		if(get_screen_mode())
			currentKeyboardMode = 4;
		return;
	}
	
	/* Special translation to make on-screen UI easier to use */
	if(ui_is_active)
	{
		if(machine_type == MACHINE_5200)
		{
			switch(kbcode)
			{
			case 0x3d: /* 2 */
				kbcode = AKEY_UP;
				break;
			case 0x2d: /* 8 */
				kbcode = AKEY_DOWN;
				break;
			case 0x37: /* 4 */
				kbcode = AKEY_LEFT;
				break;
			case 0x33: /* 6 */
				kbcode = AKEY_RIGHT;
				break;
			case 0x39: /* Start */
				kbcode = AKEY_RETURN;
				break;
			case 0x27: /* * */
				kbcode = AKEY_ESCAPE;
				break;
			case 0x31: /* Pause */
				kbcode = AKEY_TAB;
				break;
			case 0x23: /* # */
				kbcode = AKEY_SPACE;
				break;
			}
		}
		else
		{
			switch(kbcode)
			{
			case AKEY_MINUS:
				kbcode = AKEY_UP;
				break;
			case AKEY_EQUAL:
				kbcode = AKEY_DOWN;
				break;
			case AKEY_PLUS:
				kbcode = AKEY_LEFT;
				break;
			case AKEY_ASTERISK:
				kbcode = AKEY_RIGHT;
				break;
			}
		}
	}

	release_key(kbcode);
}
Ejemplo n.º 20
0
void init_editor()
{
	void med_show_warning(char *s);

	// first, make sure we can find the files we need
	PHYSFSX_addRelToSearchPath("editor/data", 1);	// look in source directory first (for work in progress)
	PHYSFSX_addRelToSearchPath("editor", 1);		// then in editor directory
	PHYSFSX_addRelToSearchPath("editor.zip", 1);	// then in a zip file
	PHYSFSX_addRelToSearchPath("editor.dxa", 1);	// or addon pack

	ui_init();

	init_med_functions();	// Must be called before medlisp_init

	ui_pad_read( 0, "segmove.pad" );
	ui_pad_read( 1, "segsize.pad" );
	ui_pad_read( 2, "curve.pad" );
	ui_pad_read( 3, "texture.pad" );
	ui_pad_read( 4, "object.pad" );
	ui_pad_read( 5, "objmov.pad" );
	ui_pad_read( 6, "group.pad" );
	ui_pad_read( 7, "lighting.pad" );
	ui_pad_read( 8, "test.pad" );

	medkey_init();

	game_flush_inputs();
	
	editor_font = gr_init_font( "pc8x16.fnt" );
	
	menubar_init( "MED.MNU" );

	Draw_all_segments = 1;						// Say draw all segments, not just connected ones
	
	if (!Cursegp)
		Cursegp = &Segments[0];

	init_autosave();
  
//	atexit(close_editor);

	Clear_window = 1;	//	do full window clear.
	
	InitCurve();
	
	restore_effect_bitmap_icons();
	
	if (!set_screen_mode(SCREEN_EDITOR))	{
		set_screen_mode(SCREEN_MENU);
		show_menus();			//force back into menu
		return;
	}
	
	load_palette(Current_level_palette,1,0);
	
	//Editor renders into full (320x200) game screen 
	
	game_init_render_buffers(320, 200);
	gr_init_sub_canvas( &_canv_editor, &grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT );
	Canv_editor = &_canv_editor;
	gr_set_current_canvas( Canv_editor );
	init_editor_screen(); // load the main editor dialog
	gr_set_current_canvas( NULL );
	gr_set_curfont(editor_font);
	
	set_warn_func(med_show_warning);
	
	//	_MARK_("start of editor");//Nuked to compile -KRB
	
	//@@	//create a camera for viewing in the editor. copy position from ConsoleObject
	//@@	camera_objnum = obj_create(OBJ_CAMERA,0,ConsoleObject->segnum,&ConsoleObject->pos,&ConsoleObject->orient,0);
	//@@	Viewer = &Objects[camera_objnum];
	//@@	slew_init(Viewer);		//camera is slewing
	
	Viewer = ConsoleObject;
	slew_init(ConsoleObject);
	init_player_object();
	
	Update_flags = UF_ALL;
	
	//set the wire-frame window to be the current view
	current_view = &LargeView;
	
	if (faded_in==0)
	{
		faded_in = 1;
		//gr_pal_fade_in( grd_curscreen->pal );
	}
	
	gr_set_current_canvas( GameViewBox->canvas );
	gr_set_curfont(editor_font);
	//gr_setcolor( CBLACK );
	//gr_deaccent_canvas();
	//gr_grey_canvas();
	
	gr_set_curfont(editor_font);
	FNTScaleX = FNTScaleY = 1;		// No font scaling!
	ui_pad_goto(padnum);
	
	ModeFlag = 0;
	
	gamestate_restore_check();
}
Ejemplo n.º 21
0
void hitbutton(short code)
{
	int kbcode;
	
	if(ui_is_active)
	{
		trig0 = 1;
		stick0 = 0xff;

		kbcode = AKEY_NONE;
		if(code == joykey_map[get_screen_mode()][0])
			kbcode = AKEY_UP;
		else if(code == joykey_map[get_screen_mode()][1])
			kbcode = AKEY_DOWN;
		else if(code == joykey_map[get_screen_mode()][2])
			kbcode = AKEY_LEFT;
		else if(code == joykey_map[get_screen_mode()][3])
			kbcode = AKEY_RIGHT;
		else if(code == klist.vkStart)
			kbcode = AKEY_TAB;
		else if(code == klist.vkA)
			kbcode = AKEY_SPACE;
		else if(code == klist.vkB)
			kbcode = AKEY_RETURN;
		else if(code == klist.vkC)
			kbcode = AKEY_ESCAPE;
		
		push_key(kbcode);
	}
	else
	{
		kbcode = AKEY_NONE;
		if(code == joykey_map[get_screen_mode()][0])
			stick0 &= ~1;
		else if(code == joykey_map[get_screen_mode()][1])
			stick0 &= ~2;
		else if(code == joykey_map[get_screen_mode()][2])
			stick0 &= ~4;
		else if(code == joykey_map[get_screen_mode()][3])
			stick0 &= ~8;
		else if(code == klist.vkA || code == klist.vkB)
			trig0 = 0;
		else if(code == klist.vkC)
			kbcode = AKEY_UI;
		else
		for(int i=0; i<sizeof(kbd_translation)/sizeof(kbd_translation[0]); i++)
			if(code == kbd_translation[i].winKey)
			{
				kbcode = kbd_translation[i].aKey;
				break;
			}

		if(kbcode != AKEY_NONE)
			push_key(kbcode);
	}

	/* The way current UI works, it is not compatible with keyboard implementation
	in landscape mode */
	if(kbcode == AKEY_UI)
		set_screen_mode(0);
}
Ejemplo n.º 22
0
Archivo: med.c Proyecto: btb/d2x
// ---------------------------------------------------------------------------------------------------
//this function is the editor. called when editor mode selected.  runs until
//game mode or exit selected
void editor(void)
{
	int w,h;
	grs_bitmap * savedbitmap;
	editor_view *new_cv;
        static int padnum=0;
	vms_matrix	MouseRotMat,tempm;
	//@@short camera_objnum;			//a camera for viewing

	init_editor();

	InitCurve();

	restore_effect_bitmap_icons();

	if (!set_screen_mode(SCREEN_EDITOR))	{
		set_screen_mode(SCREEN_GAME);
		Function_mode=FMODE_GAME;			//force back into game
		return;
	}

	gr_set_current_canvas( NULL );
	gr_set_curfont(editor_font);

	//Editor renders into full (320x200) game screen 

	set_warn_func(med_show_warning);

	keyd_repeat = 1;		// Allow repeat in editor

//	_MARK_("start of editor");//Nuked to compile -KRB

	ui_mouse_hide();

	ui_reset_idle_seconds();

//@@	//create a camera for viewing in the editor. copy position from ConsoleObject
//@@	camera_objnum = obj_create(OBJ_CAMERA,0,ConsoleObject->segnum,&ConsoleObject->pos,&ConsoleObject->orient,0);
//@@	Viewer = &Objects[camera_objnum];
//@@	slew_init(Viewer);		//camera is slewing

	Viewer = ConsoleObject;
	slew_init(ConsoleObject);

	Update_flags = UF_ALL;

	medlisp_update_screen();

	//set the wire-frame window to be the current view
	current_view = &LargeView;

	if (faded_in==0)
	{
		faded_in = 1;
		//gr_pal_fade_in( grd_curscreen->pal );
	}

	w = GameViewBox->canvas->cv_bitmap.bm_w;
	h = GameViewBox->canvas->cv_bitmap.bm_h;
	
	savedbitmap = gr_create_bitmap(w, h );

	gr_bm_ubitblt( w, h, 0, 0, 0, 0, &GameViewBox->canvas->cv_bitmap, savedbitmap );

	gr_set_current_canvas( GameViewBox->canvas );
	gr_set_curfont(editor_font);
	//gr_setcolor( CBLACK );
	//gr_deaccent_canvas();
	//gr_grey_canvas();
	
	ui_mouse_show();

	gr_set_curfont(editor_font);
	ui_pad_goto(padnum);

	gamestate_restore_check();

	while (Function_mode == FMODE_EDITOR) {

		gr_set_curfont(editor_font);
		info_display_all(EditorWindow);

		ModeFlag = 0;

		// Update the windows

		// Only update if there is no key waiting and we're not in
		// fast play mode.
		if (!key_peekkey()) //-- && (MacroStatus != UI_STATUS_FASTPLAY))
			medlisp_update_screen();

		//do editor stuff
		gr_set_curfont(editor_font);
		ui_mega_process();
		last_keypress &= ~KEY_DEBUGGED;		//	mask off delete key bit which has no function in editor.
		ui_window_do_gadgets(EditorWindow);
		do_robot_window();
		do_object_window();
		do_wall_window();
		do_trigger_window();
		do_hostage_window();
		do_centers_window();
		check_wall_validity();
		Assert(Num_walls>=0);

		if (Gameview_lockstep) {
			static segment *old_cursegp=NULL;
			static int old_curside=-1;

			if (old_cursegp!=Cursegp || old_curside!=Curside) {
				SetPlayerFromCursegMinusOne();
				old_cursegp = Cursegp;
				old_curside = Curside;
			}
		}

//		mprintf((0, "%d	", ui_get_idle_seconds() ));

		if ( ui_get_idle_seconds() > COMPRESS_INTERVAL ) 
			{
			med_compress_mine();
			ui_reset_idle_seconds();
			}
  
//	Commented out because it occupies about 25% of time in twirling the mine.
// Removes some Asserts....
//		med_check_all_vertices();
		clear_editor_status();		// if enough time elapsed, clear editor status message
		TimedAutosave(mine_filename);
		set_editor_time_of_day();
		gr_set_current_canvas( GameViewBox->canvas );
		
		// Remove keys used for slew
		switch(last_keypress)
		{
		case KEY_PAD9:
		case KEY_PAD7:
		case KEY_PADPLUS:
		case KEY_PADMINUS:
		case KEY_PAD8:
		case KEY_PAD2:
		case KEY_LBRACKET:
		case KEY_RBRACKET:
		case KEY_PAD1:
		case KEY_PAD3:
		case KEY_PAD6:
		case KEY_PAD4:
			last_keypress = 0;
		}
		if ((last_keypress&0xff)==KEY_LSHIFT) last_keypress=0;
		if ((last_keypress&0xff)==KEY_RSHIFT) last_keypress=0;
		if ((last_keypress&0xff)==KEY_LCTRL) last_keypress=0;
		if ((last_keypress&0xff)==KEY_RCTRL) last_keypress=0;
//		if ((last_keypress&0xff)==KEY_LALT) last_keypress=0;
//		if ((last_keypress&0xff)==KEY_RALT) last_keypress=0;
		if ((last_keypress&0xff)==KEY_LMETA) last_keypress=0;
		if ((last_keypress&0xff)==KEY_RMETA) last_keypress=0;

		gr_set_curfont(editor_font);
		menubar_do( last_keypress );

		//=================== DO FUNCTIONS ====================

		if ( KeyFunction[ last_keypress ] != NULL )	{
			KeyFunction[last_keypress]();
			last_keypress = 0;
		}
		switch (last_keypress)
		{
		case 0:
		case KEY_Z:
		case KEY_G:
		case KEY_LALT:
		case KEY_RALT:
		case KEY_LCTRL:
		case KEY_RCTRL:
		case KEY_LSHIFT:
		case KEY_RSHIFT:
		case KEY_LAPOSTRO:
			break;
		case KEY_SHIFTED + KEY_L:
			ToggleLighting();
			break;
		case KEY_F1:
			render_3d_in_big_window = !render_3d_in_big_window;
			Update_flags |= UF_ALL;
			break;			
		default:
			{
			char kdesc[100];
			GetKeyDescription( kdesc, last_keypress );
			editor_status("Error: %s isn't bound to anything.", kdesc  );
			}
		}

		//================================================================

		if (ModeFlag==1)
		{
			close_editor_screen();
			Function_mode=FMODE_EXIT;
				gr_free_bitmap( savedbitmap );
			break;
		}

		if (ModeFlag==2) //-- && MacroStatus==UI_STATUS_NORMAL )
		{
			close_editor_screen();
			Function_mode = FMODE_MENU;
			set_screen_mode(SCREEN_MENU);		//put up menu screen
			gr_free_bitmap(savedbitmap);
			break;
		}

		if (ModeFlag==3) //-- && MacroStatus==UI_STATUS_NORMAL )
		{
//			med_compress_mine();						//will be called anyways before game.
			close_editor_screen();
			Function_mode=FMODE_GAME;			//force back into game
			set_screen_mode(SCREEN_GAME);		//put up game screen
			gr_free_bitmap( savedbitmap );
			break;
		}

//		if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)GameViewBox) current_view=NULL;
//		if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)GroupViewBox) current_view=NULL;

		new_cv = current_view ;

#if ORTHO_VIEWS
		if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)LargeViewBox) new_cv=&LargeView;
		if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)TopViewBox)	new_cv=&TopView;
		if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)FrontViewBox) new_cv=&FrontView;
		if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)RightViewBox) new_cv=&RightView;
#endif
		if (new_cv != current_view ) {
			current_view->ev_changed = 1;
			new_cv->ev_changed = 1;
			current_view = new_cv;
		}

		calc_frame_time();
		if (slew_frame(0)) {		//do movement and check keys
			Update_flags |= UF_GAME_VIEW_CHANGED;
			if (Gameview_lockstep) {
				Cursegp = &Segments[ConsoleObject->segnum];
				med_create_new_segment_from_cursegp();
				Update_flags |= UF_ED_STATE_CHANGED;
			}
		}

		// DO TEXTURE STUFF
		texpage_do();
		objpage_do();


		// Process selection of Cursegp using mouse.
		if (LargeViewBox->mouse_onme && LargeViewBox->b1_clicked && !render_3d_in_big_window) 
		{
			int	xcrd,ycrd;
			xcrd = LargeViewBox->b1_drag_x1;
			ycrd = LargeViewBox->b1_drag_y1;

			find_segments(xcrd,ycrd,LargeViewBox->canvas,&LargeView,Cursegp,Big_depth);	// Sets globals N_found_segs, Found_segs

			// If shift is down, then add segment to found list
			if (keyd_pressed[ KEY_LSHIFT ] || keyd_pressed[ KEY_RSHIFT ])
				subtract_found_segments_from_selected_list();
			else
				add_found_segments_to_selected_list();

  			Found_seg_index = 0;	
		
			if (N_found_segs > 0) {
				sort_seg_list(N_found_segs,Found_segs,&ConsoleObject->pos);
				Cursegp = &Segments[Found_segs[0]];
				med_create_new_segment_from_cursegp();
				if (Lock_view_to_cursegp)
					set_view_target_from_segment(Cursegp);
			}

			Update_flags |= UF_ED_STATE_CHANGED | UF_VIEWPOINT_MOVED;
		}

		if (GameViewBox->mouse_onme && GameViewBox->b1_dragging) {
			int	x, y;
			x = GameViewBox->b1_drag_x2;
			y = GameViewBox->b1_drag_y2;

			ui_mouse_hide();
			gr_set_current_canvas( GameViewBox->canvas );
			gr_setcolor( 15 );
			gr_rect( x-1, y-1, x+1, y+1 );
			ui_mouse_show();

		}
		
		// Set current segment and side by clicking on a polygon in game window.
		//	If ctrl pressed, also assign current texture map to that side.
		//if (GameViewBox->mouse_onme && (GameViewBox->b1_done_dragging || GameViewBox->b1_clicked)) {
		if ((GameViewBox->mouse_onme && GameViewBox->b1_clicked && !render_3d_in_big_window) ||
			(LargeViewBox->mouse_onme && LargeViewBox->b1_clicked && render_3d_in_big_window)) {

			int	xcrd,ycrd;
			int seg,side,face,poly,tmap;

			if (render_3d_in_big_window) {
				xcrd = LargeViewBox->b1_drag_x1;
				ycrd = LargeViewBox->b1_drag_y1;
			}
			else {
				xcrd = GameViewBox->b1_drag_x1;
				ycrd = GameViewBox->b1_drag_y1;
			}
	
			//Int3();

			if (find_seg_side_face(xcrd,ycrd,&seg,&side,&face,&poly)) {


				if (seg<0) {							//found an object

					Cur_object_index = -seg-1;
					editor_status("Object %d selected.",Cur_object_index);

					Update_flags |= UF_ED_STATE_CHANGED;
				}
				else {

					//	See if either shift key is down and, if so, assign texture map
					if (keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) {
						Cursegp = &Segments[seg];
						Curside = side;
						AssignTexture();
						med_create_new_segment_from_cursegp();
						editor_status("Texture assigned");
					} else if (keyd_pressed[KEY_G])	{
						tmap = Segments[seg].sides[side].tmap_num;
						texpage_grab_current(tmap);
						editor_status( "Texture grabbed." );
					} else if (keyd_pressed[ KEY_LAPOSTRO] ) {
						ui_mouse_hide();
						move_object_to_mouse_click();
					} else {
						Cursegp = &Segments[seg];
						Curside = side;
						med_create_new_segment_from_cursegp();
						editor_status("Curseg and curside selected");
					}
				}

				Update_flags |= UF_ED_STATE_CHANGED;
			}
			else 
				editor_status("Click on non-texture ingored");

		}

		// Allow specification of LargeView using mouse
		if (keyd_pressed[ KEY_LCTRL ] || keyd_pressed[ KEY_RCTRL ]) {
			ui_mouse_hide();
			if ( (Mouse.dx!=0) && (Mouse.dy!=0) ) {
				GetMouseRotation( Mouse.dx, Mouse.dy, &MouseRotMat );
				vm_matrix_x_matrix(&tempm,&LargeView.ev_matrix,&MouseRotMat);
				LargeView.ev_matrix = tempm;
				LargeView.ev_changed = 1;
				Large_view_index = -1;			// say not one of the orthogonal views
			}
		} else  {
			ui_mouse_show();
		}

		if ( keyd_pressed[ KEY_Z ] ) {
			ui_mouse_hide();
			if ( Mouse.dy!=0 ) {
				current_view->ev_dist += Mouse.dy*10000;
				current_view->ev_changed = 1;
			}
		} else {
			ui_mouse_show();
		}

		vid_update();
	}

//	_MARK_("end of editor");//Nuked to compile -KRB

	clear_warn_func(med_show_warning);

	//kill our camera object

	Viewer = ConsoleObject;					//reset viewer
	//@@obj_delete(camera_objnum);

	padnum = ui_pad_get_current();

	close_editor();
	ui_close();


}
Ejemplo n.º 23
0
void OptionMenu::calc_self()
{
    // Bei geaendertem Spielernamen die neue Userdatei laden.
    // Die alte wird jedoch nicht gespeichert. Dazu muss man erst auf OK
    // klicken und das Optionsmenue erneut aufrufen.
    // Ob der Name zu lang ist, prueft User::get_name().
    if (user_name.get_text() != gloB->user_name) {
        gloB->user_name    = user_name.get_text();
        useR->load();
        useR->option_group = GROUP_GENERAL; // da sind wir ja
        reset_elements();
    }

    /////////////////////////
    // Angeklickte Buttons //
    /////////////////////////

    if (button_okay.get_clicked() || hardware.get_mr()) {
        const int res_fx = atoi(screen_resolution_x.get_text().c_str());
        const int res_fy = atoi(screen_resolution_y.get_text().c_str());
        const int res_wx = atoi(screen_windowed_x.get_text().c_str());
        const int res_wy = atoi(screen_windowed_y.get_text().c_str());
        const bool full  = gloB->screen_fullscreen_now;

        // Only call set_screen_mode() if it's necessary. The main menu
        // flickers for a very short time. A different screen_scaling option
        // should also call the function, because the function sets
        // glob_gfx.h's clear_screen_at_next_blit to true, to clear option
        // menu remainders on the screen borders.
        bool call_ssm = false;
        if (       useR->screen_scaling != screen_scaling.get_number()
                   ||(  full && gloB->screen_resolution_x != res_fx)
                   ||(  full && gloB->screen_resolution_y != res_fy)
                   ||(! full && gloB->screen_windowed_x   != res_wx)
                   ||(! full && gloB->screen_windowed_y   != res_wy)) call_ssm = true;

        bool reload_gralib = (
                                 useR->gui_color_red   != gui_color_red  .get_number()
                                 || useR->gui_color_green != gui_color_green.get_number()
                                 || useR->gui_color_blue  != gui_color_blue .get_number() );

        // Die Werte aller Checkboxen und Buttons in die Optionen schreiben
        // Die Konfigurationsdatei wird gegen eventuelle Abstuerze oder
        // Allegro-Abschuesse schon am Ende dieser Abarbeitung gespeichert.
        gloB->user_name_ask          = user_name_ask.get_checked();
        gloB->replay_auto_single     = replay_auto_single.get_checked();
        gloB->replay_auto_multi      = replay_auto_multi.get_checked();
        gloB->replay_auto_max        = replay_auto_max.get_number();

        if (useR->language != language_nr)
            Language::set(useR->language = language_nr);

        useR->mouse_speed       = mouse_speed       .get_number();
        useR->scroll_speed_edge = scroll_speed_edge .get_number();
        useR->scroll_speed_click= scroll_speed_click.get_number();
        useR->scroll_edge       = scroll_edge       .get_checked();
        useR->scroll_right      = scroll_right      .get_checked();
        useR->scroll_middle     = scroll_middle     .get_checked();
        useR->replay_cancel     = replay_cancel     .get_checked();
        useR->replay_cancel_at  = replay_cancel_at  .get_number();
        useR->allow_builder_queuing   = allow_builder_queuing   .get_checked();
        useR->avoid_builder_queuing   = avoid_builder_queuing   .get_checked();
        useR->avoid_batter_to_exploder= avoid_batter_to_exploder.get_checked();
        useR->prioinv_middle          = prioinv_middle          .get_checked();
        useR->prioinv_right           = prioinv_right           .get_checked();

        useR->key_force_left       = key_force_left      .get_scancode();
        useR->key_force_right      = key_force_right     .get_scancode();
        useR->key_rate_minus       = key_rate_minus      .get_scancode();
        useR->key_rate_plus        = key_rate_plus       .get_scancode();
        useR->key_pause            = key_pause           .get_scancode();
        useR->key_speed_back_one   = key_speed_back_one  .get_scancode();
        useR->key_speed_back_many  = key_speed_back_many .get_scancode();
        useR->key_speed_ahead_one  = key_speed_ahead_one .get_scancode();
        useR->key_speed_ahead_many = key_speed_ahead_many.get_scancode();
        useR->key_speed_fast       = key_speed_fast      .get_scancode();
        useR->key_speed_turbo      = key_speed_turbo     .get_scancode();
        useR->key_restart          = key_restart         .get_scancode();
        useR->key_state_load       = key_state_load      .get_scancode();
        useR->key_state_save       = key_state_save      .get_scancode();
        useR->key_zoom             = key_zoom            .get_scancode();
        useR->key_chat             = key_chat            .get_scancode();
        useR->key_spec_tribe       = key_spec_tribe      .get_scancode();
        useR->key_nuke             = key_nuke            .get_scancode();
        useR->key_ga_exit          = key_ga_exit         .get_scancode();
        useR->key_scroll           = key_scroll          .get_scancode();
        useR->key_priority         = key_priority        .get_scancode();

        for (size_t i = 0; i < useR->skill_sort.size(); ++i) {
            LixEn::Ac ac = img_skill[i].get_skill();
            // set the user's sorting to the skill panel's order here
            useR->skill_sort[i] = ac;
            useR->key_skill[ac] = key_skill[i].get_scancode();
            // There's only the EXPLODER2 hotkey in the options menu, but
            // it shall control both hotkeys. This is a design barnacle,
            // the skills should be treated interally more like they were
            // only one. To the player, they should appear very different.
            if (ac == LixEn::EXPLODER2)
                useR->key_skill[LixEn::EXPLODER] = key_skill[i].get_scancode();
        }

        useR->key_ed_left        = ed_left       .get_scancode();
        useR->key_ed_right       = ed_right      .get_scancode();
        useR->key_ed_up          = ed_up         .get_scancode();
        useR->key_ed_down        = ed_down       .get_scancode();
        useR->key_ed_copy        = ed_copy       .get_scancode();
        useR->key_ed_delete      = ed_delete     .get_scancode();
        useR->key_ed_grid        = ed_grid       .get_scancode();
        useR->key_ed_sel_all     = ed_sel_all    .get_scancode();
        useR->key_ed_sel_frame   = ed_sel_frame  .get_scancode();
        useR->key_ed_sel_add     = ed_sel_add    .get_scancode();
        useR->key_ed_background  = ed_background .get_scancode();
        useR->key_ed_foreground  = ed_foreground .get_scancode();
        useR->key_ed_mirror      = ed_mirror     .get_scancode();
        useR->key_ed_rotate      = ed_rotate     .get_scancode();
        useR->key_ed_dark        = ed_dark       .get_scancode();
        useR->key_ed_noow        = ed_noow       .get_scancode();
        useR->key_ed_zoom        = ed_zoom       .get_scancode();
        useR->key_ed_help        = ed_help       .get_scancode();
        useR->key_ed_menu_size   = ed_menu_size  .get_scancode();
        useR->key_ed_menu_vars   = ed_menu_vars  .get_scancode();
        useR->key_ed_menu_skills = ed_menu_skills.get_scancode();
        useR->key_ed_add_terrain = ed_add_terrain.get_scancode();
        useR->key_ed_add_steel   = ed_add_steel  .get_scancode();
        useR->key_ed_add_hatch   = ed_add_hatch  .get_scancode();
        useR->key_ed_add_goal    = ed_add_goal   .get_scancode();
        useR->key_ed_add_deco    = ed_add_deco   .get_scancode();
        useR->key_ed_add_hazard  = ed_add_hazard .get_scancode();
        useR->key_ed_exit        = ed_exit       .get_scancode();
        useR->editor_grid_custom = ed_grid_custom.get_number();

        useR->key_me_okay           = me_okay              .get_scancode();
        useR->key_me_edit           = me_edit              .get_scancode();
        useR->key_me_export         = me_export            .get_scancode();
        useR->key_me_delete         = me_delete            .get_scancode();
        useR->key_me_up_dir         = me_up_dir            .get_scancode();
        useR->key_me_up_1           = me_up_1              .get_scancode();
        useR->key_me_up_5           = me_up_5              .get_scancode();
        useR->key_me_down_1         = me_down_1            .get_scancode();
        useR->key_me_down_5         = me_down_5            .get_scancode();
        useR->key_me_exit           = me_exit              .get_scancode();
        useR->key_me_main_single    = me_main_single       .get_scancode();
        useR->key_me_main_network   = me_main_network      .get_scancode();
        useR->key_me_main_replay    = me_main_replay       .get_scancode();
        useR->key_me_main_options   = me_main_options      .get_scancode();

        useR->screen_windowed       = screen_windowed      .get_checked();
        useR->screen_scaling        = screen_scaling       .get_number();
        useR->screen_border_colored = screen_border_colored.get_checked();
        useR->arrows_replay         = arrows_replay        .get_checked();
        useR->arrows_network        = arrows_network       .get_checked();
        useR->game_show_tooltips    = game_show_tooltips   .get_checked();
        useR->game_show_skill_keys  = game_show_skill_keys .get_checked();
        useR->debris_amount         = debris_amount        .get_number();
        useR->debris_type           = debris_type          .get_number();
        useR->gui_color_red         = gui_color_red        .get_number();
        useR->gui_color_green       = gui_color_green      .get_number();
        useR->gui_color_blue        = gui_color_blue       .get_number();

        gloB->screen_resolution_x = atoi(screen_resolution_x.get_text().c_str());
        gloB->screen_resolution_y = atoi(screen_resolution_y.get_text().c_str());
        gloB->screen_windowed_x   = atoi(screen_windowed_x  .get_text().c_str());
        gloB->screen_windowed_y   = atoi(screen_windowed_y  .get_text().c_str());
        gloB->screen_vsync        = screen_vsync            .get_checked();

        gloB->sound_load_driver = sound_load_driver.get_checked();
        useR->sound_volume = sound_volume     .get_number();

        // Use new resolution that's already written to globals
        if (call_ssm) set_screen_mode(gloB->screen_fullscreen_now,
                                          gloB->screen_modestr_now);
        if (reload_gralib) {
            make_all_colors();
            GraLib::deinitialize();
            GraLib::initialize(GraLib::LOAD_WITH_RECOLOR_LIX);
            // the mouse cursor must be recerated by the Menu class
        }

        gloB->save();
        useR->save();
        exit = true;
    }
    else if (button_cancel.get_clicked()) {
        exit = true;
    }

    for (size_t i = 0; i < GROUP_MAX; ++i)
        if (button_group[i].get_clicked())
            show_group(static_cast <OptionGroup> (i));

    // Eigentliche Schalter einer ausgewaehlten Optionsgruppe
    switch (useR->option_group) {

    case GROUP_GENERAL:
        if (language.get_clicked()) {
            ++language_nr;

            if (language_nr == Language::MAX) {
                language_nr = Language::ENGLISH;
            } else if (language_nr == Language::CUSTOM) {
                // argument of true means only try to load
                // the custom language's display name
                if (!Language::try_load_custom_language(true)) {
                    // reach here means unable to load custom
                    // language (eg. no data/translate.txt)
                    // go back to English
                    language_nr = Language::ENGLISH;
                }
            }
            language.set_text(Language::language_name[language_nr]);
        }
        break;

    case GROUP_CONTROLS: {
        if (!scroll_edge && !scroll_right && !scroll_middle) {
            if (scroll_edge.get_clicked()) scroll_right.set_checked();
            else                           scroll_edge .set_checked();
        }
        break;
    }

    case GROUP_HOTKEYS:
    case GROUP_GRAPHICS:
    case GROUP_SOUND:
        break;

    default:
        break;
    }
}
Ejemplo n.º 24
0
int main(int argc, char *argv[])
{
	mem_init();
#ifdef __LINUX__
	error_init(NULL);
#else
	error_init(msgbox_error);
	set_warn_func(msgbox_warning);
#endif
	PHYSFSX_init(argc, argv);
	con_init();  // Initialise the console

	setbuf(stdout, NULL); // unbuffered output via printf
#ifdef _WIN32
	freopen( "CON", "w", stdout );
	freopen( "CON", "w", stderr );
#endif

	if (GameArg.SysShowCmdHelp) {
		print_commandline_help();

		return(0);
	}

	printf("\nType %s -help' for a list of command-line options.\n\n", PROGNAME);

	PHYSFSX_listSearchPathContent();
	
	if (!PHYSFSX_checkSupportedArchiveTypes())
		return(0);

	if (! PHYSFSX_contfile_init("descent2.hog", 1)) {
		if (! PHYSFSX_contfile_init("d2demo.hog", 1))
#define DXX_NAME_NUMBER	"2"
#define DXX_HOGFILE_NAMES	"descent2.hog or d2demo.hog"
#if defined(__unix__) && !defined(__APPLE__)
#define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
			      "\t$HOME/.d" DXX_NAME_NUMBER "x-rebirth\n"	\
			      "\t" SHAREPATH "\n"
#else
#define DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
				  "\tDirectory containing D" DXX_NAME_NUMBER "X\n"
#endif
#if (defined(__APPLE__) && defined(__MACH__)) || defined(macintosh)
#define DXX_HOGFILE_APPLICATION_BUNDLE	\
				  "\tIn 'Resources' inside the application bundle\n"
#else
#define DXX_HOGFILE_APPLICATION_BUNDLE	""
#endif
#define DXX_MISSING_HOGFILE_ERROR_TEXT	\
		"Could not find a valid hog file (" DXX_HOGFILE_NAMES ")\nPossible locations are:\n"	\
		DXX_HOGFILE_PROGRAM_DATA_DIRECTORY	\
		"\tIn a subdirectory called 'Data'\n"	\
		DXX_HOGFILE_APPLICATION_BUNDLE	\
		"Or use the -hogdir option to specify an alternate location."
		Error(DXX_MISSING_HOGFILE_ERROR_TEXT);
	}

	load_text();

	//print out the banner title
	con_printf(CON_NORMAL, "%s%s  %s\n", DESCENT_VERSION, PHYSFSX_exists(MISSION_DIR "d2x.hog",1) ? "  Vertigo Enhanced" : "", g_descent_build_datetime); // D2X version
	con_printf(CON_NORMAL, "This is a MODIFIED version of Descent 2, based on %s.\n", BASED_VERSION);
	con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK);
	con_printf(CON_NORMAL, "Copyright (C) 1999 Peter Hawkins, 2002 Bradley Bell, 2005-2011 Christian Beckhaeuser\n\n");

	if (GameArg.DbgVerbose)
		con_printf(CON_VERBOSE,"%s%s", TXT_VERBOSE_1, "\n");
	
	ReadConfigFile();

	PHYSFSX_addArchiveContent();

	arch_init();

	select_tmap(GameArg.DbgTexMap);

	Lighting_on = 1;

	con_printf(CON_VERBOSE, "Going into graphics mode...\n");
	gr_set_mode(Game_screen_mode);

	// Load the palette stuff. Returns non-zero if error.
	con_printf(CON_DEBUG, "Initializing palette system...\n" );
	gr_use_palette_table(D2_DEFAULT_PALETTE );

	con_printf(CON_DEBUG, "Initializing font system...\n" );
	gamefont_init();	// must load after palette data loaded.

	set_default_handler(standard_handler);

	con_printf( CON_DEBUG, "Initializing movie libraries...\n" );
	init_movies();		//init movie libraries

	show_titles();

	set_screen_mode(SCREEN_MENU);

	con_printf( CON_DEBUG, "\nDoing gamedata_init..." );
	gamedata_init();

	#ifdef EDITOR
	if (GameArg.EdiSaveHoardData) {
		save_hoard_data();
		exit(1);
	}
	#endif

	if (GameArg.DbgNoRun)
		return(0);

	con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
	texmerge_init( 10 );		// 10 cache bitmaps

	piggy_init_pigfile("groupa.pig");	//get correct pigfile

	con_printf( CON_DEBUG, "\nRunning game...\n" );
	init_game();

	Players[Player_num].callsign[0] = '\0';

	//	If built with editor, option to auto-load a level and quit game
	//	to write certain data.
	#ifdef	EDITOR
	if (GameArg.EdiAutoLoad) {
		strcpy(Auto_file, GameArg.EdiAutoLoad);
		strcpy(Players[0].callsign, "dummy");
	} else
	#endif
	{
		if(GameArg.SysPilot)
		{
			char filename[32] = "";
			int j;

			if (GameArg.SysUsePlayersDir)
				strcpy(filename, "Players/");
			strncat(filename, GameArg.SysPilot, 12);
			filename[8 + 12] = '\0';	// unfortunately strncat doesn't put the terminating 0 on the end if it reaches 'n'
			for (j = GameArg.SysUsePlayersDir? 8 : 0; filename[j] != '\0'; j++) {
				switch (filename[j]) {
					case ' ':
						filename[j] = '\0';
				}
			}
			if(!strstr(filename,".plr")) // if player hasn't specified .plr extension in argument, add it
				strcat(filename,".plr");
			if(PHYSFSX_exists(filename,0))
			{
				strcpy(strstr(filename,".plr"),"\0");
				strcpy(Players[Player_num].callsign, GameArg.SysUsePlayersDir? &filename[8] : filename);
				read_player_file();
				WriteConfigFile();
			}
		}
	}

#ifdef EDITOR
	if (GameArg.EdiAutoLoad) {
		strcpy((char *)&Level_names[0], Auto_file);
		LoadLevel(1, 1);
	}
	else
#endif
	{
		Game_mode = GM_GAME_OVER;
		DoMenu();
	}

	setjmp(LeaveEvents);
	while (window_get_front())
		// Send events to windows and the default handler
		event_process();
	
	// Tidy up - avoids a crash on exit
	{
		window *wind;

		show_menus();
		while ((wind = window_get_front()))
			window_close(wind);
	}

	WriteConfigFile();
	show_order_form();

	con_printf( CON_DEBUG, "\nCleanup...\n" );
	close_game();
	texmerge_close();
	gamedata_close();
	gamefont_close();
	free_text();
	args_exit();
	newmenu_free_background();
	free_mission();
	PHYSFSX_removeArchiveContent();

	return(0);		//presumably successful exit
}
Ejemplo n.º 25
0
int main(int argc, char *argv[])
{
	mem_init();
#ifdef __LINUX__
	error_init(NULL, NULL);
#else
	error_init(msgbox_error, NULL);
	set_warn_func(msgbox_warning);
#endif
	PHYSFSX_init(argc, argv);
	con_init();  // Initialise the console

	setbuf(stdout, NULL); // unbuffered output via printf
#ifdef _WIN32
	freopen( "CON", "w", stdout );
	freopen( "CON", "w", stderr );
#endif

	if (GameArg.SysShowCmdHelp) {
		print_commandline_help();
		set_exit_message("");

		return(0);
	}

	printf("\nType %s -help' for a list of command-line options.\n\n", PROGNAME);

	PHYSFSX_listSearchPathContent();
	
	if (!PHYSFSX_checkSupportedArchiveTypes())
		return(0);

	if (! PHYSFSX_contfile_init("descent.hog", 1))
		Error("Could not find a valid hog file (descent.hog)\nPossible locations are:\n"
#if defined(__unix__) && !defined(__APPLE__)
			  "\t$HOME/.d1x-rebirth\n"
			  "\t" SHAREPATH "\n"
#else
			  "\tDirectory containing D1X\n"
#endif
			  "\tIn a subdirectory called 'Data'\n"
#if (defined(__APPLE__) && defined(__MACH__)) || defined(macintosh)
			  "\tIn 'Resources' inside the application bundle\n"
#endif
			  "Or use the -hogdir option to specify an alternate location.");
	
	switch (PHYSFSX_fsize("descent.hog"))
	{
		case D1_MAC_SHARE_MISSION_HOGSIZE:
		case D1_MAC_MISSION_HOGSIZE:
			MacHog = 1;	// used for fonts and the Automap
			break;
	}

	load_text();

	//print out the banner title
	con_printf(CON_NORMAL, "%s", DESCENT_VERSION); // D1X version
	con_printf(CON_NORMAL, "  %s %s\n", __DATE__,__TIME__);
	con_printf(CON_NORMAL, "This is a MODIFIED version of Descent, based on %s.\n", BASED_VERSION);
	con_printf(CON_NORMAL, "%s\n%s\n",TXT_COPYRIGHT,TXT_TRADEMARK);
	con_printf(CON_NORMAL, "Copyright (C) 2005-2011 Christian Beckhaeuser\n\n");

	if (GameArg.DbgVerbose)
		con_printf(CON_VERBOSE,"%s%s", TXT_VERBOSE_1, "\n");
	
	ReadConfigFile();

	PHYSFSX_addArchiveContent();

	arch_init();

	select_tmap(GameArg.DbgTexMap);

	con_printf(CON_VERBOSE, "Going into graphics mode...\n");
	gr_set_mode(Game_screen_mode);

	// Load the palette stuff. Returns non-zero if error.
	con_printf(CON_DEBUG, "Initializing palette system...\n" );
	gr_use_palette_table( "PALETTE.256" );

	con_printf(CON_DEBUG, "Initializing font system...\n" );
	gamefont_init();	// must load after palette data loaded.

	set_default_handler(standard_handler);

	show_titles();

	set_screen_mode(SCREEN_MENU);

	con_printf( CON_DEBUG, "\nDoing gamedata_init..." );
	gamedata_init();

	if (GameArg.DbgNoRun)
		return(0);

	con_printf( CON_DEBUG, "\nInitializing texture caching system..." );
	texmerge_init( 10 );		// 10 cache bitmaps

	con_printf( CON_DEBUG, "\nRunning game...\n" );
	init_game();

	Players[Player_num].callsign[0] = '\0';

	key_flush();

	if(GameArg.SysPilot)
	{
		char filename[32] = "";
		int j;

		if (GameArg.SysUsePlayersDir)
			strcpy(filename, "Players/");
		strncat(filename, GameArg.SysPilot, 12);
		filename[8 + 12] = '\0';	// unfortunately strncat doesn't put the terminating 0 on the end if it reaches 'n'
		for (j = GameArg.SysUsePlayersDir? 8 : 0; filename[j] != '\0'; j++) {
			switch (filename[j]) {
				case ' ':
					filename[j] = '\0';
			}
		}
		if(!strstr(filename,".plr")) // if player hasn't specified .plr extension in argument, add it
			strcat(filename,".plr");
		if(PHYSFSX_exists(filename,0))
		{
			strcpy(strstr(filename,".plr"),"\0");
			strcpy(Players[Player_num].callsign, GameArg.SysUsePlayersDir? &filename[8] : filename);
			read_player_file();
			WriteConfigFile();
		}
	}


	Game_mode = GM_GAME_OVER;
	DoMenu();

	setjmp(LeaveEvents);
	while (window_get_front())
		// Send events to windows and the default handler
		event_process();
	
	// Tidy up - avoids a crash on exit
	{
		window *wind;

		show_menus();
		while ((wind = window_get_front()))
			window_close(wind);
	}

	WriteConfigFile();
	show_order_form();

	con_printf( CON_DEBUG, "\nCleanup...\n" );
	close_game();
	texmerge_close();
	gamedata_close();
	gamefont_close();
	free_text();
	args_exit();
	newmenu_free_background();
	free_mission();
	PHYSFSX_removeArchiveContent();

	return(0);		//presumably successful exit
}
Ejemplo n.º 26
0
void hitbutton(short code)
{
	int kbcode = AKEY_NONE;
	
	if(ui_is_active)
	{
		trig0 = 1;
		stick0 = 0xff;

		if(code == joykey_map[get_screen_mode()][0])
			kbcode = AKEY_UP;
		else if(code == joykey_map[get_screen_mode()][1])
			kbcode = AKEY_DOWN;
		else if(code == joykey_map[get_screen_mode()][2])
			kbcode = AKEY_LEFT;
		else if(code == joykey_map[get_screen_mode()][3])
			kbcode = AKEY_RIGHT;
		else if(code == klist.vkStart && !issmartphone)
			kbcode = AKEY_BACKSPACE;
		else if(code == klist.vkA)
			kbcode = AKEY_SPACE;
		else if(code == klist.vkB)
			kbcode = AKEY_RETURN;
		else if(code == klist.vkC)
			kbcode = AKEY_ESCAPE;
		else
			for(int i=0; i<sizeof(kbd_translation)/sizeof(kbd_translation[0]); i++)
				if(code == kbd_translation[i].winKey)
				{
					kbcode = kbd_translation[i].aKey;
					break;
				}
	}
	else
	{
		if(code == joykey_map[get_screen_mode()][0])
			stick0 &= ~1;
		else if(code == joykey_map[get_screen_mode()][1])
			stick0 &= ~2;
		else if(code == joykey_map[get_screen_mode()][2])
			stick0 &= ~4;
		else if(code == joykey_map[get_screen_mode()][3])
			stick0 &= ~8;
		else if(code == klist.vkA || code == klist.vkB || ((code == '4' || code == '6') && issmartphone))
			trig0 = 0;
		else if(code == klist.vkC)
		{
			if (!kbui_timerset)
			{
				SetTimer(hWndMain, 1, 1000, NULL);
				kbui_timerset = TRUE;
			}
		}
		else if ((code == VK_F3) && (issmartphone))
			set_screen_mode(get_screen_mode()+1); 
		else
			for(int i=0; i<sizeof(kbd_translation)/sizeof(kbd_translation[0]); i++)
				if(code == kbd_translation[i].winKey)
				{
					kbcode = kbd_translation[i].aKey;
					break;
				}
	}
	if(kbcode != AKEY_NONE)
		push_key(kbcode);
}