本文整理汇总了C++中SmallVector::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ SmallVector::Get方法的具体用法?C++ SmallVector::Get怎么用?C++ SmallVector::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmallVector
的用法示例。
在下文中一共展示了SmallVector::Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddTextEffect
/* Text Effects */
TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, TextEffectMode mode)
{
if (_game_mode == GM_MENU) return INVALID_TE_ID;
TextEffectID i;
for (i = 0; i < _text_effects.Length(); i++) {
if (_text_effects[i].string_id == INVALID_STRING_ID) break;
}
if (i == _text_effects.Length()) _text_effects.Append();
TextEffect *te = _text_effects.Get(i);
/* Start defining this object */
te->string_id = msg;
te->duration = duration;
te->params_1 = GetDParam(0);
te->params_2 = GetDParam(1);
te->mode = mode;
/* Make sure we only dirty the new area */
te->width_normal = 0;
te->UpdatePosition(center, y, msg);
return i;
}
示例2: UpdateTextEffect
void UpdateTextEffect(TextEffectID te_id, StringID msg)
{
/* Update details */
TextEffect *te = _text_effects.Get(te_id);
if (msg == te->string_id && GetDParam(0) == te->params_1) return;
te->string_id = msg;
te->params_1 = GetDParam(0);
te->UpdatePosition(te->center, te->top, msg);
}
示例3: AddFile
/**
* Try to add a fios item set with the given filename.
* @param filename the full path to the file to read
* @param basepath_length amount of characters to chop of before to get a relative filename
* @return true if the file is added.
*/
bool FiosFileScanner::AddFile(const char *filename, size_t basepath_length, const char *tar_filename)
{
const char *ext = strrchr(filename, '.');
if (ext == NULL) return false;
char fios_title[64];
fios_title[0] = '\0'; // reset the title;
FiosType type = this->callback_proc(this->mode, filename, ext, fios_title, lastof(fios_title));
if (type == FIOS_TYPE_INVALID) return false;
for (const FiosItem *fios = _fios_items.Begin(); fios != _fios_items.End(); fios++) {
if (strcmp(fios->name, filename) == 0) return false;
}
FiosItem *fios = _fios_items.Append();
#ifdef WIN32
struct _stat sb;
if (_tstat(OTTD2FS(filename), &sb) == 0) {
#else
struct stat sb;
if (stat(filename, &sb) == 0) {
#endif
fios->mtime = sb.st_mtime;
} else {
fios->mtime = 0;
}
fios->type = type;
strecpy(fios->name, filename, lastof(fios->name));
/* If the file doesn't have a title, use its filename */
const char *t = fios_title;
if (StrEmpty(fios_title)) {
t = strrchr(filename, PATHSEPCHAR);
t = (t == NULL) ? filename : (t + 1);
}
strecpy(fios->title, t, lastof(fios->title));
str_validate(fios->title, lastof(fios->title));
return true;
}
/**
* Fill the list of the files in a directory, according to some arbitrary rule.
* @param mode The mode we are in. Some modes don't allow 'parent'.
* @param callback_proc The function that is called where you need to do the filtering.
* @param subdir The directory from where to start (global) searching.
*/
static void FiosGetFileList(SaveLoadDialogMode mode, fios_getlist_callback_proc *callback_proc, Subdirectory subdir)
{
struct stat sb;
struct dirent *dirent;
DIR *dir;
FiosItem *fios;
int sort_start;
char d_name[sizeof(fios->name)];
_fios_items.Clear();
/* A parent directory link exists if we are not in the root directory */
if (!FiosIsRoot(_fios_path)) {
fios = _fios_items.Append();
fios->type = FIOS_TYPE_PARENT;
fios->mtime = 0;
strecpy(fios->name, "..", lastof(fios->name));
strecpy(fios->title, ".. (Parent directory)", lastof(fios->title));
}
/* Show subdirectories */
if ((dir = ttd_opendir(_fios_path)) != NULL) {
while ((dirent = readdir(dir)) != NULL) {
strecpy(d_name, FS2OTTD(dirent->d_name), lastof(d_name));
/* found file must be directory, but not '.' or '..' */
if (FiosIsValidFile(_fios_path, dirent, &sb) && S_ISDIR(sb.st_mode) &&
(!FiosIsHiddenFile(dirent) || strncasecmp(d_name, PERSONAL_DIR, strlen(d_name)) == 0) &&
strcmp(d_name, ".") != 0 && strcmp(d_name, "..") != 0) {
fios = _fios_items.Append();
fios->type = FIOS_TYPE_DIR;
fios->mtime = 0;
strecpy(fios->name, d_name, lastof(fios->name));
snprintf(fios->title, lengthof(fios->title), "%s" PATHSEP " (Directory)", d_name);
str_validate(fios->title, lastof(fios->title));
}
}
closedir(dir);
}
/* Sort the subdirs always by name, ascending, remember user-sorting order */
{
SortingBits order = _savegame_sort_order;
_savegame_sort_order = SORT_BY_NAME | SORT_ASCENDING;
//.........这里部分代码省略.........