From 2260f6bf4feb62929e32a1bea9cd3f403aa034b1 Mon Sep 17 00:00:00 2001 From: Krzysztof Dermont Date: Fri, 20 Jun 2014 23:41:38 +0200 Subject: Big part of PhysFS support * removed -mod argument * removed -datadir argument * removed -lang argument * removed some dead ui code * added resource manager and file loaders (stream and SDL) * changed interface textures location to match new directory structure * removed CGameData for mod support * added PhysFS support --- src/ui/displayinfo.cpp | 282 ------------------------------------------------- 1 file changed, 282 deletions(-) (limited to 'src/ui/displayinfo.cpp') diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp index 8db53c5..ee29e27 100644 --- a/src/ui/displayinfo.cpp +++ b/src/ui/displayinfo.cpp @@ -342,8 +342,6 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc m_index = index; m_bSoluce = bSoluce; -//? CreateObjectsFile(); - m_bEditLock = m_main->GetEditLock(); if ( m_bEditLock ) // edition running program? { @@ -941,284 +939,4 @@ CObject* CDisplayInfo::SearchToto() return 0; } - -// Creating the list of objects. - -struct ObjectList -{ - int total; - ObjectType type; -}; - -void ObjectAdd(ObjectList list[], ObjectType type) -{ - int i; - - for ( i=0 ; i<200 ; i++ ) - { - if ( list[i].total == 0 ) - { - list[i].total ++; - list[i].type = type; - list[i+1].total = 0; - return; - } - if ( list[i].type == type ) - { - list[i].total ++; - return; - } - } -} - -void ObjectWrite(FILE* file, ObjectList list[], int i) -{ - std::string line; - - if ( list[i].total < 10 ) - { - line = StrUtils::Format("\\c; %dx \\n;\\l;", list[i].total); - } - else - { - line = StrUtils::Format("\\c;%dx \\n;\\l;", list[i].total); - } - - std::string res; - GetResource(RES_OBJECT, list[i].type, res); - if (res.empty()) - return; - - line += res; - - line += "\\u "; - - std::string helpFilename = GetHelpFilename(list[i].type); - if (helpFilename.empty()) - return; - - line += helpFilename.substr(7); // skip "help\?\" - - auto pos = line.find(".txt"); - if (pos != std::string::npos) - { - line = line.substr(0, pos); - } - - line += ";\n"; - - fputs(line.c_str(), file); -} - -// Creates the file containing the list of objects. - -void CDisplayInfo::CreateObjectsFile() -{ - FILE* file; - CObject* pObj; - ObjectType type; - ObjectList list[200]; - std::string line; - int i; - bool bRadar, bAtLeast; - - CInstanceManager* iMan = CInstanceManager::GetInstancePointer(); - - file = fopen((std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("objects.txt")).c_str(), "w"); - if ( file == 0 ) return; - - list[0].total = 0; // empty list - bRadar = false; - for ( i=0 ; i<1000000 ; i++ ) - { - pObj = static_cast(iMan->SearchInstance(CLASS_OBJECT, i)); - if ( pObj == 0 ) break; - - if ( !pObj->GetActif() ) continue; - if ( !pObj->GetSelectable() ) continue; - if ( pObj->GetProxyActivate() ) continue; - - type = pObj->GetType(); - if ( type == OBJECT_NULL ) continue; - if ( type == OBJECT_FIX ) continue; - - ObjectAdd(list, type); - - if ( type == OBJECT_RADAR ) bRadar = true; - } - - if ( bRadar ) - { - GetResource(RES_TEXT, RT_SATCOM_LIST, line); - fputs(line.c_str(), file); - bAtLeast = false; - for ( i=0 ; i<200 ; i++ ) - { - if ( list[i].total == 0 ) break; // end of the list? - - if ( list[i].type == OBJECT_BASE || - list[i].type == OBJECT_HUMAN ) - { - ObjectWrite(file, list, i); - bAtLeast = true; - } - } - if ( !bAtLeast ) - { - GetResource(RES_TEXT, RT_SATCOM_NULL, line); - fputs(line.c_str(), file); - } - - fputs("\n", file); - GetResource(RES_TEXT, RT_SATCOM_BOT, line); - fputs(line.c_str(), file); - bAtLeast = false; - for ( i=0 ; i<200 ; i++ ) - { - if ( list[i].total == 0 ) break; // end of the list? - - if ( list[i].type == OBJECT_MOBILEwt || - list[i].type == OBJECT_MOBILEtt || - list[i].type == OBJECT_MOBILEft || - list[i].type == OBJECT_MOBILEit || - list[i].type == OBJECT_MOBILEwa || - list[i].type == OBJECT_MOBILEta || - list[i].type == OBJECT_MOBILEfa || - list[i].type == OBJECT_MOBILEia || - list[i].type == OBJECT_MOBILEwc || - list[i].type == OBJECT_MOBILEtc || - list[i].type == OBJECT_MOBILEfc || - list[i].type == OBJECT_MOBILEic || - list[i].type == OBJECT_MOBILEwi || - list[i].type == OBJECT_MOBILEti || - list[i].type == OBJECT_MOBILEfi || - list[i].type == OBJECT_MOBILEii || - list[i].type == OBJECT_MOBILEws || - list[i].type == OBJECT_MOBILEts || - list[i].type == OBJECT_MOBILEfs || - list[i].type == OBJECT_MOBILEis || - list[i].type == OBJECT_MOBILErt || - list[i].type == OBJECT_MOBILErc || - list[i].type == OBJECT_MOBILErr || - list[i].type == OBJECT_MOBILErs || - list[i].type == OBJECT_MOBILEsa || - list[i].type == OBJECT_MOBILEtg || - list[i].type == OBJECT_MOBILEdr ) - { - ObjectWrite(file, list, i); - bAtLeast = true; - } - } - if ( !bAtLeast ) - { - GetResource(RES_TEXT, RT_SATCOM_NULL, line); - fputs(line.c_str(), file); - } - - fputs("\n", file); - GetResource(RES_TEXT, RT_SATCOM_BUILDING, line); - fputs(line.c_str(), file); - bAtLeast = false; - for ( i=0 ; i<200 ; i++ ) - { - if ( list[i].total == 0 ) break; // end of the list? - - if ( list[i].type == OBJECT_DERRICK || - list[i].type == OBJECT_FACTORY || - list[i].type == OBJECT_STATION || - list[i].type == OBJECT_CONVERT || - list[i].type == OBJECT_REPAIR || - list[i].type == OBJECT_DESTROYER|| - list[i].type == OBJECT_TOWER || - list[i].type == OBJECT_NEST || - list[i].type == OBJECT_RESEARCH || - list[i].type == OBJECT_RADAR || - list[i].type == OBJECT_ENERGY || - list[i].type == OBJECT_LABO || - list[i].type == OBJECT_NUCLEAR || - list[i].type == OBJECT_START || - list[i].type == OBJECT_END || - list[i].type == OBJECT_INFO || - list[i].type == OBJECT_PARA || - list[i].type == OBJECT_TARGET1 || - list[i].type == OBJECT_TARGET2 || - list[i].type == OBJECT_SAFE || - list[i].type == OBJECT_HUSTON ) - { - ObjectWrite(file, list, i); - bAtLeast = true; - } - } - if ( !bAtLeast ) - { - GetResource(RES_TEXT, RT_SATCOM_NULL, line); - fputs(line.c_str(), file); - } - - fputs("\n", file); - GetResource(RES_TEXT, RT_SATCOM_FRET, line); - fputs(line.c_str(), file); - bAtLeast = false; - for ( i=0 ; i<200 ; i++ ) - { - if ( list[i].total == 0 ) break; // end of the list? - - if ( list[i].type == OBJECT_STONE || - list[i].type == OBJECT_URANIUM || - list[i].type == OBJECT_METAL || - list[i].type == OBJECT_POWER || - list[i].type == OBJECT_ATOMIC || - list[i].type == OBJECT_BULLET || - list[i].type == OBJECT_BBOX || - list[i].type == OBJECT_TNT ) - { - ObjectWrite(file, list, i); - bAtLeast = true; - } - } - if ( !bAtLeast ) - { - GetResource(RES_TEXT, RT_SATCOM_NULL, line); - fputs(line.c_str(), file); - } - - fputs("\n", file); - GetResource(RES_TEXT, RT_SATCOM_ALIEN, line); - fputs(line.c_str(), file); - bAtLeast = false; - for ( i=0 ; i<200 ; i++ ) - { - if ( list[i].total == 0 ) break; // end of the list? - - if ( list[i].type == OBJECT_MOTHER || - list[i].type == OBJECT_ANT || - list[i].type == OBJECT_BEE || - list[i].type == OBJECT_WORM || - list[i].type == OBJECT_SPIDER ) - { - ObjectWrite(file, list, i); - bAtLeast = true; - } - } - if ( !bAtLeast ) - { - GetResource(RES_TEXT, RT_SATCOM_NULL, line); - fputs(line.c_str(), file); - } - } - else - { - GetResource(RES_TEXT, RT_SATCOM_ERROR1, line); - fputs(line.c_str(), file); - GetResource(RES_TEXT, RT_SATCOM_ERROR2, line); - fputs(line.c_str(), file); - } - - fputs("\n", file); - - fclose(file); -} - - } - -- cgit v1.2.3-1-g7c22