コード例 #1
0
bool save_game(
    void)
{
    pause_game();
    show_cursor();

    /* Translate the name, and display the dialog */
    FileSpecifier SaveFile;
    get_current_saved_game_name(SaveFile);
    char GameName[256];
    SaveFile.GetName(GameName);

    char Prompt[256];
    // Must allow the sound to play in the background
    bool success = SaveFile.WriteDialogAsync(
                       _typecode_savegame,
                       getcstr(Prompt, strPROMPTS, _save_game_prompt),
                       GameName);

    if (success)
        success = save_game_file(SaveFile);

    hide_cursor();
    resume_game();

    return success;
}
コード例 #2
0
ファイル: paths.c プロジェクト: irv46/Shlib4MINIX3
static const char *
getword(const char **p, const char *ep, const char *delim)
{

	(void)getcstr(p, ep, delim);

	/*
	 * Now, we're looking non-delim, or end of string.
	 */

	return (getstr(p, ep, delim));
}
コード例 #3
0
ファイル: csalerts_sdl.cpp プロジェクト: blezek/marathon-ios
void alert_user(short severity, short resid, short item, int error)
{
  char str[256];
  getcstr(str, resid, item);
  char msg[300];
  sprintf(msg, "%s (error %d)", str, error);
  if (severity == infoError) {
    logError("alert (ID=%hd): %s", error, str);
  } else if (severity == fatalError) {
    logFatal("fatal alert (ID=%hd): %s", error, str);
  }
  alert_user(msg, severity);
}
コード例 #4
0
ファイル: items.cpp プロジェクト: 0x7F800000/Aleph-NONE
void get_item_name(char *buffer, short item_id, bool plural)
{
	item_definition *definition= get_item_definition(item_id);
	// LP change: added idiot-proofing
	if (!definition)
	{
		if (plural)
			sprintf(buffer,"Unlisted items with ID %d",item_id);
		else
			sprintf(buffer,"Unlisted item with ID %d",item_id);
		
		return;
	}
	
	getcstr(buffer, strITEM_NAME_LIST, plural ? definition->plural_name_id :
		definition->singular_name_id);
}
コード例 #5
0
ファイル: macintosh_utilities.c プロジェクト: DrItanium/moo
int rsprintf(
	char *buffer,
	short resource_number, /* STR# resource */
	short string_number,
	...)
{
	char format[256];
	va_list arglist;
	int return_value;

	getcstr(format, resource_number, string_number);
	
	va_start(arglist, string_number);
	return_value= vsprintf(buffer, format, arglist);
	va_end(arglist);

	return return_value;
}
コード例 #6
0
ファイル: vbl.cpp プロジェクト: MaddTheSane/alephone
void move_replay(void)
{
	// Get source file specification
	FileSpecifier src_file, dst_file;
	if (!get_recording_filedesc(src_file))
		return;

	// Ask user for destination file
	char prompt[256], default_name[256];
	if (!dst_file.WriteDialog(_typecode_film, getcstr(prompt, strPROMPTS, _save_replay_prompt), getcstr(default_name, strFILENAMES, filenameMARATHON_RECORDING)))
		return;

	// Copy file
	dst_file.CopyContents(src_file);
	int error = dst_file.GetError();
	if (error)
		alert_user(infoError, strERRORS, fileError, error);
}
コード例 #7
0
static void dialog_export(void *arg)
{
    dialog *d = static_cast<dialog *>(arg);
    w_saves *saves_w = static_cast<w_saves *>(d->get_widget_by_id(iDIALOG_SAVES_W));
    QuickSave sel = saves_w->selected_save();
    std::string name = sel.name;
    if (!name.length())
        name = sel.level_name;
    
    FileSpecifier dstFile;
    dstFile.SetToSavedGamesDir();
    dstFile += "unused.sgaA";
    char prompt[256];
    if (dstFile.WriteDialog(_typecode_savegame, getcstr(prompt, strPROMPTS, _save_replay_prompt), utf8_to_mac_roman(name).c_str())) {
        dstFile.CopyContents(sel.save_file);
        int error = dstFile.GetError();
        if (error)
            alert_user(infoError, strERRORS, fileError, error);
    }
}
コード例 #8
0
ファイル: macintosh_utilities.c プロジェクト: DrItanium/moo
/* prsprintf and rsprintf must be carefully tested with PPC before being used */
int prsprintf(
	char *buffer,
	short resource_number, /* STR# resource */
	short string_number,
	...)
{
	char format[256];
	va_list arglist;
	int return_value;
	short length;
	
	getcstr(format, resource_number, string_number);
	
	va_start(arglist, string_number);
	return_value= vsprintf(buffer+1, format, arglist);
	va_end(arglist);
	
	*buffer= ((length= strlen(buffer+1))>255) ? 255 : length;
	
	return return_value;
}
コード例 #9
0
ファイル: game_window.c プロジェクト: DrItanium/moo
/* A change of weapon has occurred, change the weapon display panel */
static void update_weapon_panel(
	boolean force_redraw)
{
	if(force_redraw || interface_state.weapon_is_dirty)
	{
		char weapon_name[90];
		struct weapon_interface_data *definition;
		screen_rectangle *destination= get_interface_rectangle(_weapon_display_rect);
		screen_rectangle source;
		short desired_weapon= get_player_desired_weapon(current_player_index);

		/* Now we have to erase, because the panel won't do it for us.. */
		_fill_rect(destination, _inventory_background_color);
	
		if(desired_weapon != NONE)
		{
			assert(desired_weapon>=0 && desired_weapon<MAXIMUM_WEAPON_INTERFACE_DEFINITIONS);

			definition= weapon_interface_definitions+desired_weapon;
	
			/* Check if it is a multi weapon - actually special cased for the magnum... */
			if(definition->multi_weapon)
			{
#define MAGNUM_DELTA_X 97
				if(definition->item_id==_i_magnum)
				{
					/* Either way, draw the single */
					_draw_screen_shape_at_x_y(definition->weapon_panel_shape, 
						definition->standard_weapon_panel_left, 
						definition->standard_weapon_panel_top);

					if(current_player->items[definition->item_id]>1)
					{
						_draw_screen_shape_at_x_y(
							BUILD_DESCRIPTOR(_collection_interface, _left_magnum), 
							definition->standard_weapon_panel_left-MAGNUM_DELTA_X, 
							definition->standard_weapon_panel_top);
					} 
					else 
					{
						/* Draw the empty one.. */
						_draw_screen_shape_at_x_y(
							BUILD_DESCRIPTOR(_collection_interface, _left_magnum_unusable), 
							definition->standard_weapon_panel_left-MAGNUM_DELTA_X, 
							definition->standard_weapon_panel_top);
					}
				} 
				else if(definition->item_id==_i_shotgun)
				{
					if(current_player->items[definition->item_id]>1)
					{
						_draw_screen_shape_at_x_y(
							BUILD_DESCRIPTOR(_collection_interface, _double_shotgun), 
							definition->standard_weapon_panel_left, 
							definition->standard_weapon_panel_top-12);
					} else {
						_draw_screen_shape_at_x_y(definition->weapon_panel_shape, 
							definition->standard_weapon_panel_left, 
							definition->standard_weapon_panel_top);
					}
				}
			} else {
				/* Slam it to the screen! */
				if(definition->weapon_panel_shape != NONE)
				{
					_draw_screen_shape_at_x_y(definition->weapon_panel_shape, 
						definition->standard_weapon_panel_left, 
						definition->standard_weapon_panel_top);
				}
			}
		
			/* Get the weapon name.. */
			if(desired_weapon != _weapon_ball)
			{
#define strWEAPON_NAME_LIST 137
				getcstr(weapon_name, strWEAPON_NAME_LIST, desired_weapon);
			} else {
				short item_index;
				
				/* Which ball do they actually have? */
				for(item_index= BALL_ITEM_BASE; item_index<BALL_ITEM_BASE+MAXIMUM_NUMBER_OF_PLAYERS; ++item_index)
				{
					if(current_player->items[item_index]>0) break;
				}
				assert(item_index != BALL_ITEM_BASE+MAXIMUM_NUMBER_OF_PLAYERS);
				get_item_name(weapon_name, item_index, FALSE);
			}

			/* Draw the weapon name.. */
			source= *destination;
			source.top= definition->weapon_name_start_y;
			source.bottom= definition->weapon_name_end_y;
			if(definition->weapon_name_start_x != NONE)
			{
				source.left= definition->weapon_name_start_x;
			}
			
			if(definition->weapon_name_end_x != NONE)
			{
				source.right= definition->weapon_name_end_x;
			}
			
			_draw_screen_text(weapon_name, &source, _center_horizontal|_center_vertical|_wrap_text,
				_weapon_name_font, _inventory_text_color);
				
			/* And make sure that the ammo knows it needs to update */
			interface_state.ammo_is_dirty= TRUE;
		} 
		interface_state.weapon_is_dirty= FALSE;
	}
}
コード例 #10
0
ファイル: items.cpp プロジェクト: 0x7F800000/Aleph-NONE
void get_header_name(char *buffer, short type)
{
	getcstr(buffer, strHEADER_NAME_LIST, type);
}
コード例 #11
0
static bool get_default_spec(FileSpecifier &file, int type)
{
	char name[256];
	getcstr(name, strFILENAMES, type);
	return get_default_spec(file, name);
}
コード例 #12
0
bool get_default_theme_spec(FileSpecifier &file)
{
	FileSpecifier theme = "Themes";
	theme += getcstr(temporary, strFILENAMES, filenameDEFAULT_THEME);
	return get_default_spec(file, theme.GetPath());
}
コード例 #13
0
ファイル: vbl.cpp プロジェクト: MaddTheSane/alephone
bool get_recording_filedesc(FileSpecifier &File)
{
	File.SetToLocalDataDir();
	File += getcstr(temporary, strFILENAMES, filenameMARATHON_RECORDING);
	return File.Exists();
}
コード例 #14
0
ファイル: paths.c プロジェクト: irv46/Shlib4MINIX3
void
_rtld_process_hints(const char *execname, Search_Path **path_p,
    Library_Xform **lib_p, const char *fname)
{
	int fd;
	char *buf, small[128];
	const char *b, *ep, *ptr;
	struct stat st;
	ssize_t sz;
	Search_Path **head_p = path_p;

	if ((fd = open(fname, O_RDONLY)) == -1) {
		/* Don't complain */
		return;
	}

	/* Try to avoid mmap/stat on the file. */
	buf = small;
	buf[0] = '\0';
	sz = read(fd, buf, sizeof(small));
	if (sz == -1) {
		xwarn("read: %s", fname);
		(void)close(fd);
		return;
	}
	if (sz >= sizeof(small)) {
		if (fstat(fd, &st) == -1) {
			/* Complain */
			xwarn("fstat: %s", fname);
			(void)close(fd);
			return;
		}

		sz = (ssize_t) st.st_size;

		buf = mmap(0, sz, PROT_READ, MAP_SHARED|MAP_FILE, fd, 0);
		if (buf == MAP_FAILED) {
			xwarn("mmap: %s", fname);
			(void)close(fd);
			return;
		}
	}
	(void)close(fd);

	while ((*path_p) != NULL)
		path_p = &(*path_p)->sp_next;

	for (b = buf, ep = buf + sz; b < ep; b++) {
		(void)getcstr(&b, ep, WS);
		if (b == ep)
			break;

		ptr = getstr(&b, ep, "\n#");
		if (*ptr == '/') {
			/*
			 * Since '/' != '\n' and != '#', we know ptr <
			 * b.  And we will stop when b[-1] == '/'.
			 */
			while (b[-1] == ' ' || b[-1] == '\t')
				b--;
			path_p = _rtld_append_path(head_p, path_p, execname,
			    ptr, b);
		} else
			_rtld_process_mapping(lib_p, ptr, b);

		/*
		 * b points one of ' ', \t, \n, # or equal to ep.  So,
		 * make sure we are at newline or end of string.
		 */
		(void)getstr(&b, ep, "\n");
	}

	if (buf != small)
		(void)munmap(buf, sz);
}