NewGRFAddWindow(const WindowDesc *desc, Window *parent, GRFConfig **list) : QueryStringBaseWindow(EDITBOX_MAX_SIZE) { this->parent = parent; this->InitNested(desc, 0); InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, EDITBOX_MAX_LENGTH); this->SetFocusedWidget(ANGRFW_FILTER); this->list = list; this->grfs.SetListing(this->last_sorting); this->grfs.SetFiltering(this->last_filtering); this->grfs.SetSortFuncs(this->sorter_funcs); this->grfs.SetFilterFuncs(this->filter_funcs); this->OnInvalidateData(0); }
void UpdateSignEditWindow(const Sign *si) { char *last_of = &this->edit_str_buf[this->edit_str_size - 1]; // points to terminating '\0' /* Display an empty string when the sign hasnt been edited yet */ if (si->name != NULL) { SetDParam(0, si->index); GetString(this->edit_str_buf, STR_SIGN_NAME, last_of); } else { GetString(this->edit_str_buf, STR_EMPTY, last_of); } *last_of = '\0'; this->cur_sign = si->index; InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, this->max_chars); this->SetWidgetDirty(WID_QES_TEXT); this->SetFocusedWidget(WID_QES_TEXT); }
SignListWindow(const WindowDesc *desc, WindowNumber window_number) : QueryStringBaseWindow(MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS) { this->CreateNestedTree(desc); this->vscroll = this->GetScrollbar(WID_SIL_SCROLLBAR); this->FinishInitNested(desc, window_number); this->SetWidgetLoweredState(WID_SIL_FILTER_MATCH_CASE_BTN, SignList::match_case); /* Initialize the text edit widget */ this->afilter = CS_ALPHANUMERAL; InitializeTextBuffer(&this->text, this->edit_str_buf, MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS); ClearFilterTextWidget(); /* Initialize the filtering variables */ this->SetFilterString(""); /* Create initial list. */ this->signs.ForceRebuild(); this->signs.ForceResort(); this->BuildSortSignList(); }
/** * Create the content list window. * @param desc the window description to pass to Window's constructor. */ NetworkContentListWindow(const WindowDesc *desc, bool select_all) : QueryStringBaseWindow(EDITBOX_MAX_SIZE), selected(NULL), list_pos(0) { this->InitNested(desc, 1); this->GetWidget<NWidgetStacked>(NCLWW_SEL_ALL_UPDATE)->SetDisplayedPlane(select_all); this->afilter = CS_ALPHANUMERAL; InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, EDITBOX_MAX_LENGTH); this->SetFocusedWidget(NCLWW_FILTER); _network_content_client.AddCallback(this); this->content.SetListing(this->last_sorting); this->content.SetFiltering(this->last_filtering); this->content.SetSortFuncs(this->sorter_funcs); this->content.SetFilterFuncs(this->filter_funcs); this->content.ForceRebuild(); this->FilterContentList(); this->SortContentList(); this->InvalidateData(); }
SaveLoadWindow(const WindowDesc *desc, SaveLoadDialogMode mode) : QueryStringBaseWindow(64) { static const StringID saveload_captions[] = { STR_SAVELOAD_LOAD_CAPTION, STR_SAVELOAD_LOAD_SCENARIO, STR_SAVELOAD_SAVE_CAPTION, STR_SAVELOAD_SAVE_SCENARIO, STR_SAVELOAD_LOAD_HEIGHTMAP, }; assert((uint)mode < lengthof(saveload_captions)); /* Use an array to define what will be the current file type being handled * by current file mode */ switch (mode) { case SLD_SAVE_GAME: this->GenerateFileName(); break; case SLD_SAVE_SCENARIO: strecpy(this->edit_str_buf, "UNNAMED", &this->edit_str_buf[edit_str_size - 1]); break; default: break; } this->afilter = CS_ALPHANUMERAL; InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 240); this->CreateNestedTree(desc); if (mode == SLD_LOAD_GAME) this->GetWidget<NWidgetStacked>(SLWW_CONTENT_DOWNLOAD_SEL)->SetDisplayedPlane(SZSP_HORIZONTAL); this->GetWidget<NWidgetCore>(SLWW_WINDOWTITLE)->widget_data = saveload_captions[mode]; this->FinishInitNested(desc, 0); this->LowerWidget(SLWW_DRIVES_DIRECTORIES_LIST); /* pause is only used in single-player, non-editor mode, non-menu mode. It * will be unpaused in the WE_DESTROY event handler. */ if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) { DoCommandP(0, PM_PAUSED_SAVELOAD, 1, CMD_PAUSE); } SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0); this->OnInvalidateData(0); ResetObjectToPlace(); o_dir.type = FIOS_TYPE_DIRECT; switch (_saveload_mode) { case SLD_SAVE_GAME: case SLD_LOAD_GAME: FioGetDirectory(o_dir.name, lengthof(o_dir.name), SAVE_DIR); break; case SLD_SAVE_SCENARIO: case SLD_LOAD_SCENARIO: FioGetDirectory(o_dir.name, lengthof(o_dir.name), SCENARIO_DIR); break; case SLD_LOAD_HEIGHTMAP: FioGetDirectory(o_dir.name, lengthof(o_dir.name), HEIGHTMAP_DIR); break; default: strecpy(o_dir.name, _personal_dir, lastof(o_dir.name)); } /* Focus the edit box by default in the save windows */ if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { this->SetFocusedWidget(SLWW_SAVE_OSK_TITLE); } }