void OpenFile() { puts("Путь к файлу:"); scanf("%s", &path); if (file = fopen(path, "r")) { //Считаем количество строк в фале recordCount = GetRowsCount(file); //Инициализируем массив структур routeArray = new Route[recordCount]; printf("Файл '%s' загружен! Количество записей: %u.\n", path, recordCount); isLoaded = true; //Парсим строки файла в структуры char fcontent[BUFFER_SIZE]; char* line; int i = 0; while (fgets(fcontent, BUFFER_SIZE, file)) { line = strdup(fcontent); routeArray[i] = ParseRoute(line); free(line); i++; } Print(); } else { printf("Не удалось загрузить файл '%s'.\n", path); getch(); isLoaded = false; } }
int TileSet::GetTileIDFromCell(int col, int row) const { int columns = GetColumnsCount(); int rows = GetRowsCount(); return (row * columns + col); }
int TileSet::GetTileIDFromPosition(sf::Vector2f position) const { int columns = GetColumnsCount(); int rows = GetRowsCount(); int tileColumn = position.x / tileSize.x; int tileRow = position.y / tileSize.y; return (tileColumn * columns + tileRow); }
CXTPSyntaxEditDrawTextProcessor::CXTPRowInfo* CXTPSyntaxEditDrawTextProcessor::GetRowInfo(int nRow) { if (nRow < 0) return NULL; if (nRow > GetRowsCount(TRUE)) nRow = GetRowsCount(TRUE) + 10; if (nRow >= m_arRows.GetSize()) m_arRows.SetSize(nRow + 100); CXTPRowInfo* pRI = m_arRows.GetAt(nRow, FALSE); if (!pRI) { pRI = new CXTPRowInfo(); CXTPRowsInfoArray::TObjectPtr ptrRowI(pRI, FALSE); m_arRows.SetAt(nRow, ptrRowI); } return pRI; }
int CXTPSyntaxEditDrawTextProcessor::GetRowsMaxWidth() { int nMaxWidth = 0; int nRowsCount = GetRowsCount(TRUE); for (int i = 0; i < nRowsCount; i++) { CXTPRowInfo* pRI = GetRowInfo(i); if (pRI && pRI->nMaxWidth > nMaxWidth) { nMaxWidth = pRI->nMaxWidth; } } return nMaxWidth; }
sf::Vector2u TileSet::GetTileCellFromID(int id) const { int columns = GetColumnsCount(); int rows = GetRowsCount(); return sf::Vector2u(id - (id / columns) * columns, id / columns); }