void LogisticsVehicle::init(FitIniFile& file) { componentCount = 0; file.seekBlock("ObjectType"); char tmp[256]; file.readIdString("AppearanceName", tmp, 255); fileName = tmp; file.seekBlock("General"); file.readIdLong("DescIndex", chassisNameID); file.readIdFloat("CurTonnage", maxWeight); char tmpWeightClass[256]; cLoadString(IDS_VEHICLE_CLASS, tmpWeightClass, 256); mechClass = tmpWeightClass; if(NO_ERROR != file.readIdLong("HouseID", houseID)) { houseID = -1; } if(NO_ERROR != file.readIdLong("EncyclopediaID", encyclopediaID)) { encyclopediaID = IDS_VEHICLE_DESCRIPTION_0; } file.seekBlock("VehicleDynamics"); file.readIdFloat("MaxVelocity", speed); PSTR parts[5] = { "Front", "Left", "Right", "Rear", "Turret" }; baseArmor = 0; uint8_t pts; int32_t i; for(i = 0; i < 5; i++) { file.seekBlock(parts[i]); file.readIdUChar("MaxArmorPoints", pts); baseArmor += pts; file.readIdUChar("CurInternalStructure", pts); baseArmor += pts; } file.seekBlock("InventoryInfo"); file.readIdUChar("NumWeapons", pts); char blockName[256]; for(i = 4; i < 4 + pts; i++) { sprintf(blockName, "Item:%ld", i); if(NO_ERROR == file.seekBlock(blockName)) { uint8_t fitID; file.readIdUChar("MasterID", fitID); LogisticsComponent* pComponent = LogisticsData::instance->getComponent(fitID); if(pComponent) { components[componentCount].component = pComponent; components[componentCount].xCoord = 0; components[componentCount].yCoord = 0; componentCount++; } } } }
void MechListBoxItem::init( FitIniFile& file ) { if ( !s_templateItem ) { s_templateItem = new MechListBoxItem( NULL, 0 ); file.seekBlock( "MainBox" ); long width, height; file.readIdLong( "Width", width ); file.readIdLong( "Height", height ); ((aObject*)s_templateItem)->init( 0, 0, width, height ); memset( s_templateItem->animationIDs, 0, sizeof(long) * 9 ); // rects s_templateItem->line.init( &file, "Rect1" ); s_templateItem->outline.init( &file, "Rect0" ); long curAnim = 0; // statics s_templateItem->weightIcon.init( &file, "Static0" ); assignAnimation( file, curAnim ); s_templateItem->mechIcon.init( &file, "Static1" ); assignAnimation( file, curAnim ); s_templateItem->costIcon.init( &file, "Static2" ); assignAnimation( file, curAnim ); // texts s_templateItem->chassisName.init( &file, "Text0" ); assignAnimation( file, curAnim ); s_templateItem->weightText.init( &file, "Text1" ); assignAnimation( file, curAnim ); s_templateItem->countText.init( &file, "Text2" ); assignAnimation( file, curAnim ); s_templateItem->variantName.init( &file, "Text3" ); assignAnimation( file, curAnim ); s_templateItem->costText.init( &file, "Text4" ); assignAnimation( file, curAnim ); char blockName[64]; for ( int i = 0; i < 4; i++ ) { sprintf( blockName, "OrangeAnimation%ld", i ); s_templateItem->animations[1][i].init( &file, blockName ); sprintf( blockName, "Animation%ld", i ); s_templateItem->animations[0][i].init( &file, blockName ); } } }
bool LogisticsSaveDialog::isCorrectVersionSaveGame( char* fileName ) { FullPathFileName path; path.init( savePath, fileName, ".fit" ); FitIniFile file; if ( NO_ERR != file.open( (char*)(const char*)path ) ) { char errorStr[256]; sprintf( errorStr, "couldn't open file %s", path ); STOP((errorStr)); } long result = file.seekBlock( "Version" ); if (result != NO_ERR) return false; long testVersionNum = 0; result = file.readIdLong( "VersionNumber", testVersionNum ); if ( (result == NO_ERR) && (testVersionNum == SaveGameVersionNumber)) return true; return false; }
void LogisticsSaveDialog::readCampaignNameFromFile( char* fileName, char* resultName, long len ) { FullPathFileName path; path.init( campaignPath, fileName, ".fit" ); FitIniFile file; if ( NO_ERR != file.open( (char*)(const char*)path ) ) { char errorStr[256]; sprintf( errorStr, "couldn't open file %s", path ); Assert( 0, 0, errorStr ); } long result = file.seekBlock( "Campaign" ); Assert( result == NO_ERR, 0, "Coudln't find the mission settings block in the mission file" ); resultName[0] = 0; long lName = 0; result = file.readIdLong( "NameID", lName ); if ( result == NO_ERR ) { cLoadString( lName, resultName, len ); } else { result = file.readIdString( "CampaignName", resultName, len ); Assert( result == NO_ERR, 0, "couldn't find the missionName" ); } }
void aTextListItem::init( FitIniFile& file, const char* blockName ) { file.seekBlock( blockName ); long x, y, width, height; file.readIdLong( "XLocation", x ); file.readIdLong( "YLocation", y ); file.readIdLong( "Width", width ); file.readIdLong( "Height", height ); aObject::init( x, y, width, height ); long color; file.readIdLong( "Color", color ); setColor( color ); }
static long sReadIdInteger(FitIniFile &missionFile, const char *varName, int &value) { long result = 0; long tmpLong; result = missionFile.readIdLong((char *)varName, tmpLong); if (NO_ERR != result) { //assert(false); } else { value = tmpLong; } return result; }
void aAnimTextListItem::init( FitIniFile& file, const char* blockName ) { file.seekBlock( blockName ); long x, y, width, height; file.readIdLong( "XLocation", x ); file.readIdLong( "YLocation", y ); file.readIdLong( "Width", width ); file.readIdLong( "Height", height ); aObject::init( x, y, width, height ); long color; file.readIdLong( "Color", color ); setColor( color ); // I could read the font here char animationSt[256]; if ( NO_ERR == file.readIdString( "Animation", animationSt, 255 ) ) animInfo.init( &file, animationSt ); }
static int32_t sReadIdInteger(FitIniFile& missionFile, PCSTR varName, int32_t& value) { int32_t result = 0; int32_t tmpLong; result = missionFile.readIdLong((PSTR)varName, tmpLong); if(NO_ERROR != result) { //assert(false); } else { value = tmpLong; } return result; }
//---------------------------------------------------------------------------------- void initColorTables (void) { FullPathFileName colorPath; colorPath.init(cameraPath,"colors",".fit"); FitIniFile colorFile; long result = colorFile.open(colorPath); gosASSERT(result == NO_ERR); result = colorFile.seekBlock("Main"); gosASSERT(result == NO_ERR); result = colorFile.readIdLong("NumTables",numColorRGBTables); gosASSERT(result == NO_ERR); colorRGBLookup = (DWORD **)systemHeap->Malloc(sizeof(DWORD *) * numColorRGBTables); gosASSERT(colorRGBLookup != NULL); memset(colorRGBLookup,0,sizeof(DWORD *) * numColorRGBTables); for (long i=0;i<numColorRGBTables;i++) { char tableBlock[256]; sprintf(tableBlock,"Table%d",i); result = colorFile.seekBlock(tableBlock); gosASSERT(result == NO_ERR); colorRGBLookup[i] = (DWORD *)systemHeap->Malloc(sizeof(DWORD) * MAX_COLOR_ENTRIES); gosASSERT(colorRGBLookup[i] != NULL); DWORD *table = colorRGBLookup[i]; for (long j=0;j<MAX_COLOR_ENTRIES;j++) { char colorBlock[256]; sprintf(colorBlock,"Color%d",j); result = colorFile.readIdULong(colorBlock,table[j]); gosASSERT(result == NO_ERR); } } colorFile.close(); }
void ForceGroupBar::init( FitIniFile& file, StaticInfo* pCoverIcon ) { if ( NO_ERR != file.seekBlock( "Fonts" ) ) Assert( 0, 0, "couldn't find the font block" ); if ( !ForceGroupIcon::gosFontHandle ) ForceGroupIcon::gosFontHandle = new aFont; long fontID; file.readIdLong( "IconFont", fontID ); ForceGroupIcon::gosFontHandle->init( fontID ); swapResolutions(); for ( int i = 0; i < 16; i++ ) ForceGroupIcon::init( file, i ); s_coverIcon = pCoverIcon; }
//--------------------------------------------------------------------------- long GateType::init (FilePtr objFile, unsigned long fileSize) { long result = 0; FitIniFile bldgFile; result = bldgFile.open(objFile,fileSize); if (result != NO_ERR) return(result); //------------------------------------------------------------------ // Read in the data needed for the Gates result = bldgFile.seekBlock("GateData"); if (result != NO_ERR) return(result); result = bldgFile.readIdULong("DmgLevel",dmgLevel); if (result != NO_ERR) return(result); bldgFile.readIdULong("BlownEffectId",blownEffectId); if (result != NO_ERR) blownEffectId = -1; bldgFile.readIdULong("NormalEffectId",normalEffectId); if (result != NO_ERR) normalEffectId = -1; bldgFile.readIdULong("DamageEffectId",damageEffectId); if (result != NO_ERR) damageEffectId = -1; result = bldgFile.readIdLong("BasePixelOffsetX",basePixelOffsetX); if (result != NO_ERR) basePixelOffsetX = 0; result = bldgFile.readIdLong("BasePixelOffsetY",basePixelOffsetY); if (result != NO_ERR) basePixelOffsetY = 0; result = bldgFile.readIdFloat("ExplosionRadius",explRad); if (result != NO_ERR) explRad = 0.0; result = bldgFile.readIdFloat("ExplosionDamage",explDmg); if (result != NO_ERR) explDmg = 0.0; result = bldgFile.readIdFloat("OpenRadius",openRadius); if (result != NO_ERR) return(result); result = bldgFile.readIdFloat("LittleExtent",littleExtent); if (result != NO_ERR) littleExtent = 20.0; result = bldgFile.readIdLong ("BuildingName", gateTypeName); if (result != NO_ERR) gateTypeName = IDS_BLDOBJ_NAME; result = bldgFile.readIdLong( "BuildingDescription", buildingDescriptionID ); if ( result != NO_ERR ) buildingDescriptionID = -1; result = bldgFile.readIdBoolean("BlocksLineOfFire",blocksLineOfFire); if (result != NO_ERR) blocksLineOfFire = FALSE; //------------------------------------------------------------------ // Initialize the base object Type from the current file. result = ObjectType::init(&bldgFile); return(result); }
ObjectTypePtr ObjectTypeManager::load(ObjectTypeNumber objTypeNum, bool noCacheOut, bool forceLoad) { //----------------------------------------------------------------------- // NOTE: This function attempts to load the objectType into the table. If // the object type is ALREADY loaded, it simply returns nullptr (indicating // it's already been loaded, so no problem). Otherwise, it returns the // newly loaded object type. What I'm say'n here is--this function // CANNOT fatal out, because any calling function will want to know // if the object type had to be loaded or not. However, it will fatal // if it's unable to load the object type from the packet file. //-------------------------------------------------------- // If we are going to disk to get the object, be sure the // frame length knows to force itself into load mode. dynamicFrameTiming = false; if((objTypeNum < 0) || (objTypeNum >= numObjectTypes)) Fatal(objTypeNum, " ObjectTypeManager.load: bad objTypeNum "); if(objTypeNum == 0) //First Object always nullptr! return nullptr; if(!forceLoad && get(objTypeNum, false)) return(nullptr); bool isMiscTerrObj = false; int32_t objectTypeNum = -1; ObjectTypePtr objType = nullptr; if((objTypeNum == bridgeTypeHandle) || (objTypeNum == forestTypeHandle) || (objTypeNum == wallHeavyTypeHandle) || (objTypeNum == wallMediumTypeHandle) || (objTypeNum == wallLightTypeHandle)) { //---------------------------------------------------------- // MiscTerrainObject "hack" to maintain MC1 compatibility... objectTypeNum = TERRAINOBJECT_TYPE; isMiscTerrObj = true; } else if(objectFile->seekPacket(objTypeNum) == NO_ERROR) { if(objTypeNum == 268) { gosASSERT(objTypeNum == 268); } //-------------------------------------------------------- // All new code here. This will ask the objectType it is // loading what kind of objectType it is and create it // based on that instead of objTypeNum. FitIniFile objTypeFile; int32_t result = objTypeFile.open(objectFile, objectFile->getPacketSize()); if(result != NO_ERROR) Fatal(objTypeNum, " ObjectTypeManager.load: can't create object "); result = objTypeFile.seekBlock("ObjectClass"); if(result != NO_ERROR) Fatal(objTypeNum, " ObjectTypeManager.load: can't create object "); result = objTypeFile.readIdLong("ObjectTypeNum", objectTypeNum); if(result != NO_ERROR) Fatal(objTypeNum, " ObjectTypeManager.load: can't create object "); objTypeFile.close(); objectFile->seekPacket(objTypeNum); } else Fatal(objTypeNum, " ObjectTypeManager.load: can't create object "); //----------------------------------------------------- // Now that we know what type it is, let's create it... switch(objectTypeNum) { case CRAPPY_OBJECT: //---------------------------------------------- // In theory we can't ever get here. // Because we did our jobs correctly!! Fatal(CANT_LOAD_INVALID_OBJECT, " ObjectTypeManager.load: can't create object "); break; case BATTLEMECH_TYPE: { objType = new BattleMechType; objType->setObjTypeNum(objTypeNum); if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR) Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Mech type "); } break; case VEHICLE_TYPE: { objType = new GroundVehicleType; objType->setObjTypeNum(objTypeNum); if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR) Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Vehicle type "); } break; case TREEBUILDING_TYPE: case BUILDING_TYPE: { objType = new BuildingType; objType->setObjTypeNum(objTypeNum); if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR) Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Building type "); } break; case TREE_TYPE: { objType = new TerrainObjectType; objType->setObjTypeNum(objTypeNum); if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR) Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init TerrainObject:Tree type "); } break; case TERRAINOBJECT_TYPE: { objType = new TerrainObjectType; objType->setObjTypeNum(objTypeNum); if(isMiscTerrObj) ((TerrainObjectTypePtr)objType)->initMiscTerrObj(objTypeNum); else if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR) Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init TerrainObject type "); } break; case WEAPONBOLT_TYPE: { objType = new WeaponBoltType; objType->setObjTypeNum(objTypeNum); if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR) Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init WeaponBolt type "); } break; case TURRET_TYPE: { objType = new TurretType; objType->setObjTypeNum(objTypeNum); if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR) Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Turret type "); } break; case EXPLOSION_TYPE: { objType = new ExplosionType; objType->setObjTypeNum(objTypeNum); if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR) Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Explosion type "); } break; case FIRE_TYPE: { objType = new FireType; objType->setObjTypeNum(objTypeNum); if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR) Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Fire type "); } break; case GATE_TYPE: { objType = new GateType; objType->setObjTypeNum(objTypeNum); if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR) Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Gate type "); } break; case ARTILLERY_TYPE: { objType = new ArtilleryType; objType->setObjTypeNum(objTypeNum); if(objType->init(objectFile, objectFile->getPacketSize()) != NO_ERROR) Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Artillery type "); } break; default: //return(nullptr); //Fatal(OBJECT_TYPE_NUMBER_UNDEFINED, " ObjectTypeManager.load: undefined objType "); NODEFAULT; } if(noCacheOut) { //--------------------------------------------------- // Do NOT EVER cache this object type out. FXs, etc. // This means I'm preloading it!! objType->makeLovable(); if(objType->getExplosionObject() > 0) load(objType->getExplosionObject()); } table[objTypeNum] = objType; return(objType); }
void aButton::init( FitIniFile& buttonFile, const char* str, HGOSFONT3D font ) { textureHandle = 0; long result = buttonFile.seekBlock( str ); if ( result != NO_ERR ) { char errorStr[256]; sprintf( errorStr, "couldn't find button %s", str ); Assert( 0, 0, errorStr ); return; } buttonFile.readIdLong( "ID", data.ID ); buttonFile.readIdString("FileName", data.fileName, 32 ); buttonFile.readIdLong( "HelpCaption", helpHeader ); buttonFile.readIdLong( "HelpDesc", helpID ); buttonFile.readIdLong( "TextID", data.textID ); buttonFile.readIdLong( "TextNormal", data.textColors[0] ); buttonFile.readIdLong( "TextPressed", data.textColors[1] ); buttonFile.readIdLong( "TextDisabled", data.textColors[2] ); buttonFile.readIdBoolean( "Toggle", toggleButton ); buttonFile.readIdBoolean( "outline", data.outline ); long fontID; buttonFile.readIdLong( "Font", fontID ); if ( fontID ) data.textFont = aFont::loadFont( fontID, data.textSize ); else data.textFont = 0; long x, y, width, height; buttonFile.readIdLong( "XLocation", x ); buttonFile.readIdLong( "YLocation", y ); buttonFile.readIdLong( "Width", width ); buttonFile.readIdLong( "Height", height ); buttonFile.readIdLong( "HelpCaption", helpHeader ); buttonFile.readIdLong( "HelpDesc", helpID ); buttonFile.readIdBoolean( "texturesRotated", data.textureRotated ); if ( NO_ERR != buttonFile.readIdLong( "Alignment", data.textAlign ) ) data.textAlign = 2; location[0].x = location[1].x = x; location[0].y = location[3].y = y; location[2].x = location[3].x = x + width; location[1].y = location[2].y = y + height; for ( int j = 0; j < 4; j++ ) { location[j].argb = 0xffffffff; location[j].frgb = 0; location[j].rhw = .5; location[j].u = 0.f; location[j].v = 0.f; location[j].z = 0.f; } if ( 0 == textureHandle && data.fileName && strlen( data.fileName ) ) { char file[256]; strcpy( file, artPath ); strcat( file, data.fileName ); _strlwr( file ); if ( !strstr( data.fileName, ".tga" ) ) strcat( file, ".tga" ); int ID = mcTextureManager->loadTexture( file, gos_Texture_Alpha, 0, 0, 0x2 ); int gosID = mcTextureManager->get_gosTextureHandle( ID ); TEXTUREPTR textureData; gos_LockTexture( gosID, 0, 0, &textureData ); gos_UnLockTexture( gosID ); textureHandle = ID; data.fileWidth = textureData.Width; data.fileHeight = data.fileWidth; } if ( NO_ERR != buttonFile.readIdLong( "UNormal", data.stateCoords[0][0] ) ) data.stateCoords[0][0] = -1.f; if ( NO_ERR != buttonFile.readIdLong( "VNormal", data.stateCoords[0][1] ) ) data.stateCoords[0][1] = -1.f; if ( NO_ERR != buttonFile.readIdLong( "UPressed", data.stateCoords[1][0] ) ) data.stateCoords[1][0] = -1.f; if ( NO_ERR != buttonFile.readIdLong( "VPressed", data.stateCoords[1][1] ) ) data.stateCoords[1][1] = -1.f; if ( NO_ERR != buttonFile.readIdLong( "UDisabled", data.stateCoords[2][0] ) ) data.stateCoords[2][0] = -1.f; if ( NO_ERR != buttonFile.readIdLong( "VDisabled", data.stateCoords[2][1] ) ) data.stateCoords[2][1] = -1.f; if ( NO_ERR != buttonFile.readIdLong( "UAmbiguous", data.stateCoords[3][0] ) ) data.stateCoords[3][0] = -1.f; if ( NO_ERR != buttonFile.readIdLong( "VAmbiguous", data.stateCoords[3][1] ) ) data.stateCoords[3][1] = -1.f; if ( NO_ERR != buttonFile.readIdLong( "UHighlight", data.stateCoords[4][0] ) ) { data.stateCoords[4][0] = data.stateCoords[0][0]; } if ( NO_ERR != buttonFile.readIdLong( "VHighlight", data.stateCoords[4][1] ) ) { data.stateCoords[4][1] = data.stateCoords[0][1]; } buttonFile.readIdLong( "UWidth", data.textureWidth ); buttonFile.readIdLong( "VHeight", data.textureHeight ); if ( data.textID ) buttonFile.readIdBoolean( "TextOutline", data.outlineText ); if ( NO_ERR == buttonFile.readIdLong( "XTextLocation", data.textRect.left ) ) { buttonFile.readIdLong( "YTextLocation", data.textRect.top ); buttonFile.readIdLong( "TextWidth", width ); buttonFile.readIdLong( "TextHeight", height ); data.textRect.right = data.textRect.left + width; data.textRect.bottom = data.textRect.top + height; buttonFile.readIdBoolean( "TextOutline", data.outlineText ); } else { data.textRect.left = x; data.textRect.right = x + width; data.textRect.top = y; data.textRect.bottom = y + height; } char bmpName[256]; strcpy( bmpName, str ); strcat( bmpName, "Bmp" ); char finalName[256]; int counter = 0; while(true) { sprintf( finalName, "%s%ld", bmpName, counter ); if ( NO_ERR != buttonFile.seekBlock( finalName) ) break; aObject* pObject = new aObject; pObject->init( &buttonFile, finalName ); // Dorje is doing this in global coords pObject->move( -globalX(), -globalY() ); addChild( pObject ); counter++; } buttonFile.seekBlock( str ); disable( 0 ); press( 0 ); }
long GateType::init (FilePtr objFile, unsigned long fileSize, const char* builName) { long result = 0; //magic 24022011 begin //char tmp1[16]; //magic 29112011 disabled //sprintf( tmp1, "%ld", objFile ); //magic 29112011 disabled //char tmp2[256]; //FitIniFile MtestFile; //MtestFile.open("data\\vehicle_load.fit", CREATE); //MtestFile.writeBlock( tmp1 ); //MtestFile.writeBlock( vehicleName ); //MtestFile.close(); FitIniFile bldgFile; FitIniFile objTypeFile; result = objTypeFile.open(objFile, fileSize); if (result != NO_ERR) { FullPathFileName mFullFileName; mFullFileName.init(objectPath, builName, ".fit"); //FitIniFile objTypeFile; //MtestFile.writeBlock( mFullFileName ); //MtestFile.close(); long result1 = bldgFile.open(mFullFileName); if (result1 != NO_ERR) { Fatal(objTypeNum, " BuildingType.init1: can't open building file "); } } else bldgFile.open(objFile, fileSize); objTypeFile.close(); //magic 24022011 end /*FitIniFile bldgFile; result = bldgFile.open(objFile,fileSize); if (result != NO_ERR) return(result);*/ //------------------------------------------------------------------ // Read in the data needed for the Gates result = bldgFile.seekBlock("GateData"); if (result != NO_ERR) return(result); result = bldgFile.readIdULong("DmgLevel",dmgLevel); if (result != NO_ERR) return(result); bldgFile.readIdULong("BlownEffectId",blownEffectId); if (result != NO_ERR) blownEffectId = -1; bldgFile.readIdULong("NormalEffectId",normalEffectId); if (result != NO_ERR) normalEffectId = -1; bldgFile.readIdULong("DamageEffectId",damageEffectId); if (result != NO_ERR) damageEffectId = -1; result = bldgFile.readIdLong("BasePixelOffsetX",basePixelOffsetX); if (result != NO_ERR) basePixelOffsetX = 0; result = bldgFile.readIdLong("BasePixelOffsetY",basePixelOffsetY); if (result != NO_ERR) basePixelOffsetY = 0; result = bldgFile.readIdFloat("ExplosionRadius",explRad); if (result != NO_ERR) explRad = 0.0; result = bldgFile.readIdFloat("ExplosionDamage",explDmg); if (result != NO_ERR) explDmg = 0.0; result = bldgFile.readIdFloat("OpenRadius",openRadius); if (result != NO_ERR) return(result); result = bldgFile.readIdFloat("LittleExtent",littleExtent); if (result != NO_ERR) littleExtent = 20.0; result = bldgFile.readIdLong ("BuildingName", gateTypeName); if (result != NO_ERR) gateTypeName = IDS_BLDOBJ_NAME; result = bldgFile.readIdLong( "BuildingDescription", buildingDescriptionID ); if ( result != NO_ERR ) buildingDescriptionID = -1; result = bldgFile.readIdBoolean("BlocksLineOfFire",blocksLineOfFire); if (result != NO_ERR) blocksLineOfFire = FALSE; //magic 09092011 begin char s[255]; result = bldgFile.readIdString("Name",s,254); //magic 09092011 strcpy_s(buildingName, s);//magic 09092011 //magic 09092011 end //------------------------------------------------------------------ // Initialize the base object Type from the current file. result = ObjectType::init(&bldgFile); return(result); }
int MPPrefs::init( FitIniFile& file ) { LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" ); for ( int i = 0; i < buttonCount; i++ ) { if ( buttons[i].getID() != MP_PREFS_BASE && buttons[i].getID() != MP_PREFS_STRIPE ) buttons[i].setMessageOnRelease( ); int id = buttons[i].getID(); if ( id != MB_MSG_NEXT && id != MB_MSG_PREV && id != MB_MSG_MAINMENU ) { buttons[i].setPressFX( LOG_VIDEOBUTTONS ); buttons[i].setHighlightFX( LOG_DIGITALHIGHLIGHT ); buttons[i].setDisabledFX( LOG_WRONGBUTTON ); } } file.seekBlock( "ComboBoxes" ); long count = 0; file.readIdLong( "ComboBoxCount", count ); char blockName[256]; const char* headers[3] = {"PlayerNameComboBox", "UnitNameComboBox", "UnitInsigniaComboBox" }; for ( i = 0; i< count; i++ ) { sprintf( blockName, "ComboBox%ld", i ); file.seekBlock( blockName ); file.readIdString( "FileName", blockName, 255); long tmpX; long tmpY; file.readIdLong( "XLocation", tmpX ); file.readIdLong( "YLocation", tmpY ); FitIniFile tmpFile; FullPathFileName path; path.init( artPath, blockName, ".fit" ); if ( NO_ERR != tmpFile.open( path ) ) { char error[256]; sprintf( error, "couldn't open file %s", path ); Assert( 0, 0, error ); return -1; } comboBox[i].moveTo( tmpX, tmpY ); comboBox[i].init( &tmpFile, headers[i] ); comboBox[i].ListBox().setOrange(true ); comboBox[0].EditBox().limitEntry( 24 ); comboBox[1].EditBox().limitEntry( 24 ); if ( i == 2 ) { insigniaBmp.init( &tmpFile, "Static0" ); //insigniaBmp.move( comboBox[i].globalX(), comboBox[i].globalY() ); comboBox[i].addChild( &insigniaBmp ); } comboBox[i].EditBox().allowIME( 0 ); } comboBox[2].EditBox().setReadOnly(true); camera.init( rects[2].left(), rects[2].top(), rects[2].right(), rects[2].bottom() ); status = NEXT; return 0; }
void LogisticsScreen::init(FitIniFile& file, PCSTR staticName, PCSTR textName, PCSTR rectName, PCSTR buttonName, PCSTR editName, PCSTR animObjectName, uint32_t neverFlush) { clear(); char blockName[256]; // init statics if(staticName) { sprintf(blockName, "%s%c", staticName, 's'); if(NO_ERROR == file.seekBlock(blockName)) { file.readIdLong("staticCount", staticCount); if(staticCount) { statics = new aObject[staticCount]; char blockName[128]; for(size_t i = 0; i < staticCount; i++) { sprintf(blockName, "%s%ld", staticName, i); statics[i].init(&file, blockName); } } } } if(rectName) { // init rects sprintf(blockName, "%s%c", rectName, 's'); if(NO_ERROR == file.seekBlock(blockName)) { file.readIdLong("rectCount", rectCount); if(rectCount) { rects = new aRect[rectCount]; char blockName[128]; for(size_t i = 0; i < rectCount; i++) { sprintf(blockName, "%s%ld", rectName, i); rects[i].init(&file, blockName); } } } } // init buttons if(buttonName) { sprintf(blockName, "%s%c", buttonName, 's'); if(NO_ERROR == file.seekBlock(blockName)) { file.readIdLong("buttonCount", buttonCount); if(buttonCount) { char blockName[128]; buttons = new aAnimButton[buttonCount]; for(size_t i = 0; i < buttonCount; i++) { sprintf(blockName, "%s%ld", buttonName, i); buttons[i].init(file, blockName); addChild(&buttons[i]); } } } } // init texts if(textName) { sprintf(blockName, "%s%c", textName, 's'); if(NO_ERROR == file.seekBlock(blockName)) { if(NO_ERROR != file.readIdLong("TextEntryCount", textCount)) file.readIdLong("TextCount", textCount); if(textCount) { textObjects = new aText[textCount]; char blockName[64]; for(size_t i = 0; i < textCount; i++) { sprintf(blockName, "%s%ld", textName, i); textObjects[i].init(&file, blockName); } } } } if(editName) { sprintf(blockName, "%s%c", editName, 's'); if(NO_ERROR == file.seekBlock(blockName)) { if(NO_ERROR != file.readIdLong("EditCount", editCount)) file.readIdLong("EditCount", editCount); if(editCount) { edits = new aEdit[editCount]; char blockName[64]; for(size_t i = 0; i < editCount; i++) { sprintf(blockName, "%s%ld", editName, i); edits[i].init(&file, blockName); } } } } if(animObjectName) { sprintf(blockName, "%s%c", animObjectName, 's'); if(NO_ERROR == file.seekBlock(blockName)) { file.readIdLong("Count", animObjectsCount); if(animObjectsCount) { animObjects = new aAnimObject[animObjectsCount]; char blockName[64]; for(size_t i = 0; i < animObjectsCount; i++) { sprintf(blockName, "%s%ld", animObjectName, i); animObjects[i].init(&file, blockName, neverFlush); } } } } }
void StaticInfo::init( FitIniFile& file, char* blockName, long hiResOffsetX, long hiResOffsetY, DWORD neverFlush ) { memset( location, 0, sizeof( location ) ); char fileName[256]; textureHandle = 0; textureWidth = 0; if ( NO_ERR != file.seekBlock( blockName ) ) { char errBuffer[256]; sprintf( errBuffer, "couldn't find static block %s", blockName ); Assert( 0, 0, errBuffer ); return; } long x, y, width, height; file.readIdLong( "XLocation", x ); file.readIdLong( "YLocation", y ); x += hiResOffsetX; y += hiResOffsetY; file.readIdLong( "Width", width ); file.readIdLong( "Height", height ); file.readIdString( "FileName", fileName, 32 ); if ( !textureHandle ) { FullPathFileName fullPath; _strlwr( fileName ); fullPath.init( artPath, fileName, ".tga" ); int ID = mcTextureManager->loadTexture( fullPath, gos_Texture_Alpha, 0, 0, 0x2 ); textureHandle = ID; unsigned long gosID = mcTextureManager->get_gosTextureHandle( ID ); TEXTUREPTR textureData; gos_LockTexture( gosID, 0, 0, &textureData ); textureWidth = textureData.Width; gos_UnLockTexture( gosID ); } bool bRotated = 0; file.readIdLong( "UNormal", u ); file.readIdLong( "VNormal", v ); file.readIdLong( "UWidth", uWidth ); file.readIdLong( "VHeight", vHeight ); file.readIdBoolean( "texturesRotated", bRotated ); for ( int k = 0; k < 4; k++ ) { location[k].argb = 0xffffffff; location[k].frgb = 0; location[k].x = x; location[k].y = y; location[k].z = 0.f; location[k].rhw = .5; location[k].u = (float)u/(float)textureWidth + (.1f / (float)textureWidth); location[k].v = (float)v/(float)textureWidth + (.1f / (float)textureWidth); } location[3].x = location[2].x = x + width; location[2].y = location[1].y = y + height; location[2].u = location[3].u = ((float)(u + uWidth))/((float)textureWidth) + (.1f / (float)textureWidth); location[1].v = location[2].v = ((float)(v + vHeight))/((float)textureWidth) + (.1f / (float)textureWidth); if ( bRotated ) { location[0].u = (u + uWidth)/(float)textureWidth + (.1f / (float)textureWidth);; location[1].u = u/(float)textureWidth + (.1f / (float)textureWidth);; location[2].u = u/(float)textureWidth + (.1f / (float)textureWidth); location[3].u = (u + uWidth)/(float)textureWidth + (.1f / (float)textureWidth); location[0].v = v/(float)textureWidth + (.1f / (float)textureWidth);; location[1].v = v/(float)textureWidth + (.1f / (float)textureWidth);; location[2].v = (v + vHeight)/(float)textureWidth + (.1f / (float)textureWidth);; location[3].v = (v + vHeight)/(float)textureWidth + (.1f / (float)textureWidth);; } }
int MainMenu::init( FitIniFile& file ) { file.seekBlock("Tunes"); file.readIdLong("TuneId",tuneId); LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" ); FullPathFileName name; name.init( artPath, "mcl_sp", ".fit" ); FitIniFile file2; if ( NO_ERR != file2.open( name ) ) { char errorStr[256]; sprintf( errorStr, "couldn't open file %s", (char*)name ); Assert(0,0,errorStr ); } background.init( file2, "Static", "Text", "Rect", "Button" ); for ( int i = 0; i < buttonCount; i++ ) { buttons[i].setMessageOnRelease(); buttons[i].setPressFX(LOG_VIDEOBUTTONS); buttons[i].setHighlightFX(LOG_DIGITALHIGHLIGHT); } beginAnim.initWithBlockName( &file, "InAnim" ); endAnim.initWithBlockName( &file, "OutAnim" ); intro.init(); FullPathFileName path; path.init( artPath, "mcl_mp_loadmap", ".fit" ); FitIniFile mpFile; if ( NO_ERR != mpFile.open( path ) ) { char error[256]; sprintf( error, "couldn't open file %s", path ); Assert( 0, 0, error ); return -1; } singleLoadDlg.init( &mpFile ); introMovie = 0; path.init( moviePath, "msft", ".bik" ); RECT movieRect; movieRect.top = 0; movieRect.left = 0; movieRect.right = Environment.screenWidth; movieRect.bottom = Environment.screenHeight; introMovie = new MC2Movie; introMovie->init(path,movieRect,true); return 0; }
//--------------------------------------------------------------------------- void __stdcall InitializeGameEngine() { gosResourceHandle = gos_OpenResourceDLL("mc2res.dll"); char temp[256]; cLoadString(IDS_FLOAT_HELP_FONT, temp, 255); PSTR pStr = strstr(temp, ","); if(pStr) { gosFontScale = atoi(pStr + 2); *pStr = 0; } char path [256]; strcpy(path, "assets\\graphics\\"); strcat(path, temp); gosFontHandle = gos_LoadFont(path); //------------------------------------------------------------- // Find the CDPath in the registry and save it off so I can // look in CD Install Path for files. //Changed for the shared source release, just set to current directory //uint32_t maxPathLength = 1023; //gos_LoadDataFromRegistry("CDPath", CDInstallPath, &maxPathLength); //if (!maxPathLength) // strcpy(CDInstallPath,"..\\"); strcpy(CDInstallPath, ".\\"); cLoadString(IDS_MC2_FILEMISSING, FileMissingString, 511); cLoadString(IDS_MC2_CDMISSING, CDMissingString, 1023); cLoadString(IDS_MC2_MISSING_TITLE, MissingTitleString, 255); //-------------------------------------------------------------- // Start the SystemHeap and globalHeapList globalHeapList = new HeapList; gosASSERT(globalHeapList != nullptr); globalHeapList->init(); globalHeapList->update(); //Run Instrumentation into GOS Debugger Screen systemHeap = new UserHeap; gosASSERT(systemHeap != nullptr); systemHeap->init(systemHeapSize, "SYSTEM"); float doubleClickThreshold = 0.2f; int32_t dragThreshold = .016667; //-------------------------------------------------------------- // Read in System.CFG FitIniFile systemFile; #ifdef _DEBUG int32_t systemOpenResult = #endif systemFile.open("system.cfg"); #ifdef _DEBUG if(systemOpenResult != NO_ERROR) { char Buffer[256]; gos_GetCurrentPath(Buffer, 256); STOP(("Cannot find \"system.cfg\" file in %s", Buffer)); } #endif { #ifdef _DEBUG int32_t systemBlockResult = #endif systemFile.seekBlock("systemHeap"); gosASSERT(systemBlockResult == NO_ERROR); { int32_t result = systemFile.readIdULong("systemHeapSize", systemHeapSize); result; gosASSERT(result == NO_ERROR); } #ifdef _DEBUG int32_t systemPathResult = #endif systemFile.seekBlock("systemPaths"); gosASSERT(systemPathResult == NO_ERROR); { int32_t result = systemFile.readIdString("terrainPath", terrainPath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("artPath", artPath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("fontPath", fontPath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("savePath", savePath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("spritePath", spritePath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("shapesPath", shapesPath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("soundPath", soundPath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("objectPath", objectPath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("cameraPath", cameraPath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("tilePath", tilePath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("missionPath", missionPath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("warriorPath", warriorPath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("profilePath", profilePath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("interfacepath", interfacePath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("moviepath", moviePath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("CDsoundPath", CDsoundPath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("CDmoviepath", CDmoviePath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("tglPath", tglPath, 79); gosASSERT(result == NO_ERROR); result = systemFile.readIdString("texturePath", texturePath, 79); gosASSERT(result == NO_ERROR); } #ifdef _DEBUG int32_t fastFileResult = #endif systemFile.seekBlock("FastFiles"); gosASSERT(fastFileResult == NO_ERROR); { int32_t result = systemFile.readIdLong("NumFastFiles", maxFastFiles); if(result != NO_ERROR) maxFastFiles = 0; if(maxFastFiles) { fastFiles = (FastFile**)malloc(maxFastFiles * sizeof(FastFile*)); memset(fastFiles, 0, maxFastFiles * sizeof(FastFile*)); int32_t fileNum = 0; char fastFileId[10]; char fileName[100]; sprintf(fastFileId, "File%d", fileNum); while(systemFile.readIdString(fastFileId, fileName, 99) == NO_ERROR) { bool result = FastFileInit(fileName); if(!result) STOP(("Unable to startup fastfiles. Probably an old one in the directory!!")); fileNum++; sprintf(fastFileId, "File%d", fileNum); } } } } systemFile.close(); //-------------------------------------------------------------- // Read in Prefs.cfg bool fullScreen = false; FitIniFilePtr prefs = new FitIniFile; #ifdef _DEBUG int32_t prefsOpenResult = #endif prefs->open("prefs.cfg"); gosASSERT(prefsOpenResult == NO_ERROR); { #ifdef _DEBUG int32_t prefsBlockResult = #endif prefs->seekBlock("MechCommander2"); gosASSERT(prefsBlockResult == NO_ERROR); { int32_t filterSetting; int32_t result = prefs->readIdLong("FilterState", filterSetting); if(result == NO_ERROR) { switch(filterSetting) { default: case 0: FilterState = gos_FilterNone; break; case 1: FilterState = gos_FilterBiLinear; break; case 2: FilterState = gos_FilterTriLinear; break; } } result = prefs->readIdLong("TerrainTextureRes", TERRAIN_TXM_SIZE); if(result != NO_ERROR) TERRAIN_TXM_SIZE = 64; result = prefs->readIdLong("ObjectTextureRes", ObjectTextureSize); if(result != NO_ERROR) ObjectTextureSize = 128; result = prefs->readIdLong("Brightness", gammaLevel); if(result != NO_ERROR) gammaLevel = 0; // store volume settings in global variable since soundsystem // does not exist yet. These will be set in SoundSystem::init() result = prefs->readIdLong("DigitalMasterVolume", DigitalMasterVolume); if(result != NO_ERROR) DigitalMasterVolume = 255; result = prefs->readIdLong("MusicVolume", MusicVolume); if(result != NO_ERROR) MusicVolume = 64; result = prefs->readIdLong("RadioVolume", RadioVolume); if(result != NO_ERROR) RadioVolume = 64; result = prefs->readIdLong("SFXVolume", sfxVolume); if(result != NO_ERROR) sfxVolume = 64; result = prefs->readIdFloat("DoubleClickThreshold", doubleClickThreshold); if(result != NO_ERROR) doubleClickThreshold = 0.2f; result = prefs->readIdLong("DragThreshold", dragThreshold); if(result != NO_ERROR) dragThreshold = .016667; result = prefs->readIdULong("BaseVertexColor", BaseVertexColor); if(result != NO_ERROR) BaseVertexColor = 0x00000000; result = prefs->readIdBoolean("FullScreen", fullScreen); if(result != NO_ERROR) fullScreen = true; result = prefs->readIdLong("Rasterizer", renderer); if(result != NO_ERROR) renderer = 0; if((renderer < 0) || (renderer > 3)) renderer = 0; } } prefs->close(); delete prefs; prefs = nullptr; //------------------------------- // Used to output debug stuff! // Mondo COOL! // simply do this in the code and stuff goes to the file called mc2.output // DEBUG_STREAM << thing_you_want_to_output // // IMPORTANT NOTE: Stuff::InitializeClasses(); MidLevelRenderer::InitializeClasses(8192 * 4, 1024, 0, 0, true); gosFX::InitializeClasses(); gos_PushCurrentHeap(MidLevelRenderer::Heap); MidLevelRenderer::TGAFilePool* pool = new MidLevelRenderer::TGAFilePool("data\\Effects\\"); MidLevelRenderer::MLRTexturePool::Instance = new MidLevelRenderer::MLRTexturePool(pool); MidLevelRenderer::MLRSortByOrder* cameraSorter = new MidLevelRenderer::MLRSortByOrder(MidLevelRenderer::MLRTexturePool::Instance); theClipper = new MidLevelRenderer::MLRClipper(0, cameraSorter); gos_PopCurrentHeap(); //------------------------------------------------------ // Start the GOS FX. gos_PushCurrentHeap(gosFX::Heap); gosFX::EffectLibrary::Instance = new gosFX::EffectLibrary(); Check_Object(gosFX::EffectLibrary::Instance); FullPathFileName effectsName; effectsName.init(effectsPath, "mc2.fx", ""); File effectFile; int32_t result = effectFile.open(effectsName); if(result != NO_ERROR) STOP(("Could not find MC2.fx")); int32_t effectsSize = effectFile.fileSize(); puint8_t effectsData = (puint8_t)systemHeap->Malloc(effectsSize); effectFile.read(effectsData, effectsSize); effectFile.close(); effectStream = new Stuff::MemoryStream(effectsData, effectsSize); gosFX::EffectLibrary::Instance->Load(effectStream); gosFX::LightManager::Instance = new gosFX::LightManager(); gos_PopCurrentHeap(); systemHeap->Free(effectsData); //------------------------------------------------ // Fire up the MC Texture Manager. mcTextureManager = new MC_TextureManager; mcTextureManager->start(); //Startup the vertex array pool mcTextureManager->startVertices(500000); //-------------------------------------------------- // Setup Mouse Parameters from Prefs.CFG userInput = new UserInput; userInput->init(); userInput->setMouseDoubleClickThreshold(doubleClickThreshold); userInput->setMouseDragThreshold(dragThreshold); userInput->initMouseCursors("cursors"); userInput->setMouseCursor(mState_NORMAL); userInput->mouseOn(); // now the sound system soundSystem = new GameSoundSystem; soundSystem->init(); ((SoundSystem*)soundSystem)->init("sound"); sndSystem = soundSystem; // for things in the lib that use sound soundSystem->playDigitalMusic(LOGISTICS_LOOP); pLogData = new LogisticsData; pLogData->init(); pMechlopedia = new Mechlopedia; pMechlopedia->init(); pMechlopedia->begin(); }
void Pilot::initPilots() { CSVFile file; char path[256]; strcpy( path, objectPath ); strcat( path, "pilots.csv" ); if ( NO_ERR != file.open( path ) ) { STOP(( "couldn't find pilots.csv file" )); return; } char pilotFileName[256]; strcpy(pilotFileName, ""); PilotInfo* infos = s_GoodPilots; long* counter = &goodCount; for ( int i = 0; i < 2; i++ ) { while( true ) { int bytesRead = file.readLine( (BYTE*)pilotFileName, 256 ); if ( bytesRead < 2 ) break; CString postFix; if (0 == i) { if ((strlen(pilotFileName) > strlen("pmw")) && (0 == strnicmp(pilotFileName, "pmw", strlen("pmw")))) { /*Good pilots that start with "pmw" are single-player pilots.*/ CString tmpStr; tmpStr.LoadString(IDS_PILOT_SINGLE_PLAYER_VERSION); postFix = tmpStr.GetBuffer(0); } else if ((strlen(pilotFileName) > strlen("pmp_")) && (0 == strnicmp(pilotFileName, "pmp_", strlen("pmp_")))) { /*Good pilots that start with "pmp_" are multi-player pilots.*/ CString tmpStr; tmpStr.LoadString(IDS_PILOT_MULTIPLAYER_VERSION); postFix = tmpStr.GetBuffer(0); } } FitIniFile pilotFile; FullPathFileName tmpPath; tmpPath.init(warriorPath,pilotFileName,".fit"); if ( NO_ERR != pilotFile.open( tmpPath ) ) { char errorString[256]; sprintf( errorString, "Couldn't open file %s", tmpPath); Assert( 0, 0, errorString ); return; } infos[*counter].fileName = new char[strlen( pilotFileName ) + 1]; strcpy( infos[*counter].fileName, pilotFileName ); // if we got this far we have a file, make a pilot int result = pilotFile.seekBlock( "General" ); gosASSERT( result == 0 ); long tmp; result = pilotFile.readIdLong( "descIndex", tmp ); gosASSERT( result == NO_ERR ); cLoadString( tmp, pilotFileName, 64); strcat(pilotFileName, " "); strncat(pilotFileName, postFix.GetBuffer(0), 64); infos[*counter].name = new char[strlen( pilotFileName ) +1]; strcpy( infos[*counter].name, pilotFileName ); (*counter)++; if ( goodCount > MAX_PILOT ) return; } file.close(); FullPathFileName path; path.init(objectPath,"BadPilots",".csv"); if ( NO_ERR != file.open( path ) ) { STOP(( "couldn't find BadPilots.csv file" )); return; } infos = s_BadPilots; counter = &badCount; } }
void PauseWindow::init( FitIniFile& file ) { file.seekBlock( "PauseWindow" ); file.readIdLong( "ButtonCount", buttonCount ); file.readIdLong( "staticCount", staticCount ); if ( buttons ) delete [] buttons; if ( buttonData ) delete [] buttonData; if ( statics ) delete [] statics; buttonData = 0; buttons = 0; statics = 0; if ( buttonCount ) { buttons = new ControlButton[buttonCount]; buttonData = new ButtonData[buttonCount]; font.init( IDS_PAUSEBUTTON800 ); headerFont.init( IDS_PAUSEDFONT_800 ); ControlButton::initButtons( file, buttonCount, buttons, buttonData, "PauseButton", &font ); for ( int i = 0; i < buttonCount; i++ ) { buttons[i].move( 0, -ControlGui::hiResOffsetY ); } } if ( staticCount ) { statics = new StaticInfo[staticCount]; char buffer[256]; for ( int i = 0; i < staticCount; i++ ) { sprintf( buffer, "PauseStatic%ld", i ); statics[i].init( file, buffer, ControlGui::hiResOffsetX, 0); } } if ( NO_ERR == file.seekBlock( "PauseBackRect" ) ) { file.readIdLong( "left", backgrounds[0].left ); file.readIdLong( "right", backgrounds[0].right ); file.readIdLong( "top", backgrounds[0].top ); file.readIdLong( "bottom", backgrounds[0].bottom ); backgrounds[0].left += ControlGui::hiResOffsetX; backgrounds[0].right += ControlGui::hiResOffsetX; // backgrounds[0].top += ControlGui::hiResOffsetY; // backgrounds[0].bottom += ControlGui::hiResOffsetY; } if ( NO_ERR == file.seekBlock( "PauseText" ) ) { file.readIdLong( "left", backgrounds[1].left ); file.readIdLong( "right", backgrounds[1].right ); file.readIdLong( "top", backgrounds[1].top ); file.readIdLong( "bottom", backgrounds[1].bottom ); backgrounds[1].left += ControlGui::hiResOffsetX; backgrounds[1].right += ControlGui::hiResOffsetX; // backgrounds[1].top += ControlGui::hiResOffsetY; // backgrounds[1].bottom += ControlGui::hiResOffsetY; } }
int32_t BuildingType::init(FilePtr objFile, uint32_t fileSize) { int32_t result = 0; FitIniFile bldgFile; result = bldgFile.open(objFile, fileSize); if(result != NO_ERROR) return(result); //------------------------------------------------------------------- // Since this object type handles MC1's Building and TreeBuilding // object types, we need to check for both. Basically, "TreeBuilding" // stands for animated building. Ultimately, would be nice to get // rid of this misleading legacy object type... result = bldgFile.seekBlock("TreeData"); if(result != NO_ERROR) { result = bldgFile.seekBlock("BuildingData"); if(result != NO_ERROR) return(result); } uint32_t dmgLevel; result = bldgFile.readIdULong("DmgLevel", dmgLevel); if(result != NO_ERROR) return(result); damageLevel = (float)dmgLevel; result = bldgFile.readIdBoolean("CanRefit", canRefit); if(result != NO_ERROR) canRefit = false; if(canRefit) { result = bldgFile.readIdBoolean("MechBay", mechBay); if(result != NO_ERROR) mechBay = false; } result = bldgFile.readIdFloat("ExplosionRadius", explRad); if(result != NO_ERROR) explRad = 0.0; result = bldgFile.readIdFloat("ExplosionDamage", explDmg); if(result != NO_ERROR) explDmg = 0.0; result = bldgFile.readIdFloat("Tonnage", baseTonnage); if(result != NO_ERROR) baseTonnage = 20; result = bldgFile.readIdLong("BattleRating", startBR); if(result != NO_ERROR) startBR = 20; result = bldgFile.readIdLong("NumMarines", numMarines); if(result != NO_ERROR) numMarines = 0; float realExtent = 0.0; result = bldgFile.readIdFloat("ExtentRadius", realExtent); if(result != NO_ERROR) realExtent = -1.0; result = bldgFile.readIdULong("ActivityEffectID", activityEffectId); if(result != NO_ERROR) activityEffectId = 0xffffffff; //---------------------------- // Init sensor-related data... result = bldgFile.readIdLong("TeamID", teamId); if(result != NO_ERROR) teamId = -1; result = bldgFile.readIdFloat("SensorRange", sensorRange); if(result != NO_ERROR) sensorRange = -1.0; result = bldgFile.readIdLong("BuildingName", buildingTypeName); if(result != NO_ERROR) buildingTypeName = IDS_BLDOBJ_NAME; result = bldgFile.readIdLong("BuildingDescription", buildingDescriptionID); if(result != NO_ERROR) buildingDescriptionID = -1; result = bldgFile.readIdLong("BuildingDescription", buildingDescriptionID); if(result != NO_ERROR) buildingDescriptionID = -1; result = bldgFile.readIdLong("ResourcePoints", resourcePoints); if(result != NO_ERROR) resourcePoints = 0; result = bldgFile.readIdBoolean("ImpassableWhenDestroyed", marksImpassableWhenDestroyed); if(result != NO_ERROR) marksImpassableWhenDestroyed = true; result = bldgFile.readIdBoolean("Capturable", capturable); if(result != NO_ERROR) capturable = false; result = bldgFile.readIdBoolean("IsPowerSource", powerSource); if(result != NO_ERROR) powerSource = false; result = bldgFile.readIdFloat("LookoutTowerRange", lookoutTowerRange); if(result != NO_ERROR) lookoutTowerRange = 0.0f; result = bldgFile.readIdFloat("PerimeterAlarmRange", perimeterAlarmRange); if(result != NO_ERROR) perimeterAlarmRange = 0.0f; result = bldgFile.readIdFloat("PerimeterAlarmTimer", perimeterAlarmTimer); if(result != NO_ERROR) perimeterAlarmTimer = 0.0f; result = ObjectType::init(&bldgFile); extentRadius = realExtent; if(perimeterAlarmRange > 0.0f) extentRadius = perimeterAlarmRange; //-------------------------------------------------------------------------------- // HACK!!!!! Must fix this for localization purposes--should be in the object type // data (can't look in the string!) --gd int32_t objectNameID = buildingTypeName; if(objectNameID < IDS_MC2_STRING_START) objectNameID += IDS_MC2_STRING_START; if(objectNameID != -1) { char s[255]; cLoadString(objectNameID, s, 254); } for(size_t i = 0; i < 18; i++) { if(objTypeNum == WallType[i]) { setSubType(BUILDING_SUBTYPE_WALL); break; } } if(objTypeNum == BRIDGE_TYPE) setSubType(BUILDING_SUBTYPE_LANDBRIDGE); return(result); }
void MPLoadMap::seedFromCampaign() { char searchStr[255]; cLoadString( IDS_AUTOSAVE_NAME, searchStr, 255 ); EString finalStr; finalStr = "*.fit"; FullPathFileName findPath; findPath.init( savePath, finalStr, ".fit" ); EString newestFile; long groupCount = -1; long missionCount = -1; FitIniFile tmpFile; WIN32_FIND_DATA findResult; HANDLE searchHandle = FindFirstFile(findPath,&findResult); if ( searchHandle != INVALID_HANDLE_VALUE ) { do { if ((findResult.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { FullPathFileName path; path.init( savePath, findResult.cFileName, ".fit" ); tmpFile.open( path ); if ( NO_ERR == tmpFile.seekBlock( "General" ) ) { long group, missions; tmpFile.readIdLong( "Group ", group ); if ( group > groupCount ) { groupCount = group; tmpFile.readIdLong( "CompletedMissions", missions ); missionCount = missions; newestFile = findResult.cFileName; } else if ( group == groupCount ) { tmpFile.readIdLong( "CompletedMissions", missions ); if ( missions > missionCount ) missionCount = missions; newestFile = findResult.cFileName; } } tmpFile.close(); } } while (FindNextFile(searchHandle,&findResult) != 0); } FindClose(searchHandle); if ( newestFile.Length() ) { findPath.init( savePath, newestFile, ".fit" ); FitIniFile file; long group; long missions; char campaignFileName[256]; campaignFileName[0] = 0; if ( NO_ERR == file.open( findPath ) ) { if ( NO_ERR == file.seekBlock( "General" ) ) { file.readIdLong( "Group ", group ); file.readIdLong( "CompletedMissions", missions ); file.readIdString( "CampaignFile", campaignFileName, 255 ); } } if ( strlen( campaignFileName ) && ( group || missions ) ) { FitIniFile campaignFile; if ( NO_ERR == campaignFile.open( campaignFileName ) ) { for ( int i = 0; i < group+1; i++ ) { char blockName[64]; sprintf( blockName, "Group%ld", i ); if ( NO_ERR == campaignFile.seekBlock( blockName ) ) { long count = missions; if ( i < group ) { campaignFile.readIdLong( "MissionCount", count ); } for ( int j = 0; j < count; j++ ) { sprintf( blockName, "Group%ldMission%ld", i, j ); if ( NO_ERR == campaignFile.seekBlock( blockName ) ) { char tmpFileName[255]; campaignFile.readIdString( "FileName", tmpFileName, 255 ); aLocalizedListItem* pEntry = new aLocalizedListItem(); *pEntry = templateItem; pEntry->resize( mapList.width() - mapList.getScrollBarWidth() - 20, pEntry->height()); pEntry->setHiddenText( tmpFileName ); char displayName[256]; getMapNameFromFile( tmpFileName, displayName, 255 ); pEntry->setText( displayName ); pEntry->sizeToText(); mapList.AddItem( pEntry ); } } } } } } } }
void InfoWindow::init( FitIniFile& file ) { if ( NO_ERR != file.seekBlock( "Fonts" ) ) Assert( 0, 0, "couldn't find the font block" ); for ( int i = 0; i < 7; i++ ) { if ( skillInfos[i].textureHandle ) { long gosID = mcTextureManager->get_gosTextureHandle( skillInfos[i].textureHandle ); mcTextureManager->removeTexture( gosID ); } } memset( skillInfos, 0, sizeof( skillInfos ) ); memset( buttonData, 0, sizeof( buttonData ) ); for ( i = 0; i < 2; i++ ) { if ( buttonData[i].textureHandle ) { long gosID = mcTextureManager->get_gosTextureHandle( buttonData[i].textureHandle ); mcTextureManager->removeTexture( gosID ); } } long fontID; if ( NO_ERR != file.readIdLong( "InfoWndFont", fontID ) ) { Assert( 0, 0,"couldn't find infoWndFont in button layout file" ); } s_instance->nameFont.init( fontID ); if ( NO_ERR != file.readIdLong( "ComponentFont", fontID ) ) { Assert( 0, 0, "couldn't find componentFont in button layout file" ); } s_instance->componentFont.init( fontID ); if ( NO_ERR != file.seekBlock( "InfoWindow" ) ) { Assert( 0, 0, "couldn't find Info block in button layout file" ); } file.readIdLong( "XLocation", InfoWindow::INFOLEFT ); file.readIdLong( "YLocation", InfoWindow::INFOTOP ); file.readIdLong( "Width", InfoWindow::INFOWIDTH ); file.readIdLong( "Height", InfoWindow::INFOHEIGHT ); InfoWindow::INFOLEFT += ControlGui::hiResOffsetX; InfoWindow::INFOTOP += ControlGui::hiResOffsetY; file.readIdLong( "SkipBetweenSections", InfoWindow::SECTIONSKIP ); file.readIdLong( "InfoHeaderBoxLeft", NameRect.left ); file.readIdLong( "InfoHeaderBoxRight", NameRect.right ); file.readIdLong( "InfoHeaderBoxTop", NameRect.top ); file.readIdLong( "InfoHeaderBoxBottom", NameRect.bottom ); NameRect.left += ControlGui::hiResOffsetX; NameRect.right += ControlGui::hiResOffsetX; NameRect.top += ControlGui::hiResOffsetY; NameRect.bottom += ControlGui::hiResOffsetY; file.readIdLong( "ScrollBarToP", InfoWindow::SCROLLTOP ); file.readIdLong( "ScrollBarBottom", InfoWindow::SCROLLBOTTOM ); file.readIdLong( "ScrollBarLeft", InfoWindow::SCROLLLEFT ); file.readIdLong( "ScrollBarRight", InfoWindow::SCROLLRIGHT ); file.readIdLong( "ScrollBarColor", InfoWindow::SCROLLCOLOR ); InfoWindow::SCROLLTOP += ControlGui::hiResOffsetY; InfoWindow::SCROLLBOTTOM += ControlGui::hiResOffsetY; InfoWindow::SCROLLLEFT += ControlGui::hiResOffsetX; InfoWindow::SCROLLRIGHT += ControlGui::hiResOffsetX; file.readIdLong( "ScrollContentBoxLeft", InfoWindow::SCROLLBOXLEFT ); file.readIdLong( "ScrollContentBoxRight", InfoWindow::SCROLLBOXRIGHT ); file.readIdLong( "ScrollContentBoxBarTop", InfoWindow::SCROLLBOXTOP ); file.readIdLong( "ScrollContentBoxBarBottom", InfoWindow::SCROLLBOXBOTTOM ); InfoWindow::SCROLLBOXLEFT += ControlGui::hiResOffsetX; InfoWindow::SCROLLBOXRIGHT += ControlGui::hiResOffsetX; InfoWindow::SCROLLBOXTOP += ControlGui::hiResOffsetY; InfoWindow::SCROLLBOXBOTTOM += ControlGui::hiResOffsetY; file.readIdLong( "NameLocationLeft", InfoWindow::NAMELEFT ); file.readIdLong( "NameLocationRight", InfoWindow::NAMERIGHT ); file.readIdLong( "NameLocationTop", InfoWindow::NAMETOP ); file.readIdLong( "NameLocationBottom", InfoWindow::NAMEBOTTOM ); InfoWindow::NAMELEFT += ControlGui::hiResOffsetX; InfoWindow::NAMERIGHT += ControlGui::hiResOffsetX; InfoWindow::NAMETOP += ControlGui::hiResOffsetY; InfoWindow::NAMEBOTTOM += ControlGui::hiResOffsetY; file.readIdLong( "HealthBarLeft", InfoWindow::HEALTHLEFT ); file.readIdLong( "HealthBarRight", InfoWindow::HEALTHRIGHT ); file.readIdLong( "HealthBarTop", InfoWindow::HEALTHTOP ); file.readIdLong( "HealthBarBottom", InfoWindow::HEALTHBOTTOM ); InfoWindow::HEALTHLEFT += ControlGui::hiResOffsetX; InfoWindow::HEALTHRIGHT += ControlGui::hiResOffsetX; InfoWindow::HEALTHTOP += ControlGui::hiResOffsetY; InfoWindow::HEALTHBOTTOM += ControlGui::hiResOffsetY; file.readIdLong( "DividerLeft", InfoWindow::DIVIDERLEFT ); file.readIdLong( "DividerRight", InfoWindow::DIVIDERRIGHT ); file.readIdLong( "DividerColor", InfoWindow::DIVIDERCOLOR ); InfoWindow::DIVIDERLEFT += ControlGui::hiResOffsetX; InfoWindow::DIVIDERRIGHT += ControlGui::hiResOffsetX; file.readIdLong( "PilotLeft", InfoWindow::PILOTLEFT ); file.readIdLong( "PilotRight", InfoWindow::PILOTRIGHT ); InfoWindow::PILOTLEFT += ControlGui::hiResOffsetX; InfoWindow::PILOTRIGHT += ControlGui::hiResOffsetX; file.readIdLong( "PilotHeight", InfoWindow::PILOTHEIGHT ); file.readIdLong( "PilotNameLeft", PILOTNAMELEFT ); PILOTNAMELEFT += ControlGui::hiResOffsetX; file.readIdLong( "MechIconLeft", InfoWindow::MECHLEFT ); file.readIdLong( "MechIconRight", InfoWindow::MECHRIGHT ); file.readIdLong( "MechIconHeight", InfoWindow::MECHHEIGHT ); file.readIdLong( "MechIconBackLeft", InfoWindow::MECHBACKLEFT ); file.readIdLong( "MechIconBackRight", InfoWindow::MECHBACKRIGHT ); file.readIdLong( "MechIconBackHeight", InfoWindow::MECHBACKHEIGHT ); InfoWindow::MECHLEFT += ControlGui::hiResOffsetX; InfoWindow::MECHRIGHT += ControlGui::hiResOffsetX; InfoWindow::MECHBACKLEFT += ControlGui::hiResOffsetX; InfoWindow::MECHBACKRIGHT += ControlGui::hiResOffsetX; file.seekBlock( "SkillMeter" ); file.readIdLong( "Left", InfoWindow::SKILLLEFT ); file.readIdLong( "Right", InfoWindow::SKILLRIGHT ); InfoWindow::SKILLLEFT += ControlGui::hiResOffsetX; InfoWindow::SKILLRIGHT += ControlGui::hiResOffsetX; file.readIdLong( "Height", InfoWindow::SKILLHEIGHT ); file.readIdLong( "Skip", InfoWindow::SKILLSKIP ); file.readIdLong( "UnitWidth", InfoWindow::SKILLUNITWIDTH ); file.readIdLong( "NumberUnits", InfoWindow::NUMBERSKILLBARS ); file.seekBlock( "ScrollButton" ); file.readIdLong( "Min", SCROLLMIN ); file.readIdLong( "Max", SCROLLMAX ); file.readIdLong( "XLocation", SCROLLBUTTONX ); SCROLLMIN += ControlGui::hiResOffsetY; SCROLLMAX += ControlGui::hiResOffsetY; SCROLLBUTTONX += ControlGui::hiResOffsetX; file.readIdLong( "Width", SCROLLBUTTONWIDTH ); file.readIdLong( "Height", SCROLLBUTTONHEIGHT ); file.readIdLong( "UNormal", SCROLLBUTTONU ); file.readIdLong( "VNormal", SCROLLBUTTONV ); ControlButton::initButtons( file, 2, buttons, buttonData, "InfoButton" ); char SkillText[32]; for ( i = 0; i < 7; i++ ) { sprintf( SkillText, "Skill%ld", i ); skillInfos[i].init( file, SkillText ,ControlGui::hiResOffsetX, ControlGui::hiResOffsetY); } InfoWindow::COMPONENTLEFT = InfoWindow::PILOTLEFT; }
void LogisticsSaveDialog::updateMissionInfo() { if ( !selectedName.Length() ) { statics[MAP_STATIC].setColor( 0 ); return; } if ( bCampaign ) { updateCampaignMissionInfo(); return; } FullPathFileName fileName; fileName.init( savePath, selectedName, ".fit" ); FitIniFile file; if ( NO_ERR == file.open( fileName ) ) { char tmp[256]; char tmp2[256]; char real[1024]; file.seekBlock( "General" ); tmp[0] = 0; file.readIdString( "CampaignName", tmp, 255); _splitpath( tmp, NULL, NULL, tmp2, NULL ); strcpy( real, tmp2 ); strcat( real, "\n" ); if ( NO_ERR == file.readIdString( "MissionName", tmp, 255 ) ) { strcat( real, tmp ); strcat( real, "\n" ); } if ( NO_ERR == file.readIdString( "MissionFileName", tmp, 255 ) ) { long textureHandle = MissionBriefingScreen::getMissionTGA( tmp ); statics[MAP_STATIC].setTexture( textureHandle ); statics[MAP_STATIC].setUVs( 0, 127, 127, 0 ); statics[MAP_STATIC].setColor( 0xffffffff ); } else statics[MAP_STATIC].setColor( 0 ); long cBills; file.readIdLong( "CBills", cBills ); cLoadString( IDS_DIALOG_CBILLS, tmp2, 255 ); sprintf( tmp, tmp2, cBills ); strcat( real, tmp ); strcat( real, "\n" ); time_t time = file.getFileMTime(); struct tm* ptm = localtime(&time); char* timeStr = gos_GetFormattedTime( ptm->tm_hour, ptm->tm_min, ptm->tm_sec ); char* dateStr = gos_GetFormattedDate( 0, ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday ); cLoadString( IDS_DIALOG_TIME, tmp2, 255 ); sprintf( tmp, tmp2, dateStr, timeStr ); strcat( real, tmp ); textObjects[2].setText( real ); } else { textObjects[2].setText( "" ); statics[MAP_STATIC].setColor( 0 ); } }
//--------------------------------------------------------------------------- long SoundSystem::init (char *soundFileName) { if (useSound) { FullPathFileName soundName; soundName.init(soundPath,soundFileName,".snd"); FitIniFile soundFile; long result = soundFile.open(soundName); gosASSERT(result == NO_ERR); result = soundFile.seekBlock("SoundSetup"); gosASSERT(result == NO_ERR); result = soundFile.readIdULong("soundHeapSize",soundHeapSize); gosASSERT(result == NO_ERR); result = soundFile.readIdFloat("MaxSoundDistance",maxSoundDistance); gosASSERT(result == NO_ERR); soundHeap = new UserHeap; gosASSERT(soundHeap != NULL); result = soundHeap->init(soundHeapSize,"SOUND"); gosASSERT(result == NO_ERR); //----------------------------------------------------------------------- // Startup the Sound packet File with the sound Blocks in it. // This works by sound ID. The sound ID is the packet number. // When ordered to play a sample, the sound system check to see if that // sound ID is in the cache. If not, it is loaded. If there is no more // room, any idle sounds are flushed in order of priority. soundDataFile = new PacketFile; gosASSERT(soundDataFile != NULL); FullPathFileName soundDataPath; soundDataPath.init(CDsoundPath,soundFileName,".pak"); result = soundDataFile->open(soundDataPath); gosASSERT(result == NO_ERR); bettyDataFile = new PacketFile; gosASSERT(bettyDataFile != NULL); FullPathFileName bettyDataPath; bettyDataPath.init(CDsoundPath,"Betty",".pak"); result = bettyDataFile->open(bettyDataPath); gosASSERT(result == NO_ERR); numBettySamples = bettyDataFile->getNumPackets(); supportDataFile = new PacketFile; gosASSERT(supportDataFile != NULL); FullPathFileName supportDataPath; supportDataPath.init(CDsoundPath,"support",".pak"); result = supportDataFile->open(supportDataPath); gosASSERT(result == NO_ERR); numSupportSamples = supportDataFile->getNumPackets(); //----------------------------------------------------------------------- // Load all of the sound Bite data. Do not load actual packet unless // preload field is TRUE. result = soundFile.seekBlock("SoundBites"); gosASSERT(result == NO_ERR); result = soundFile.readIdULong("numBites",numSoundBites); gosASSERT(result == NO_ERR); //----------------------------------------------------------------------- // Preallocate SoundBites sounds = (SoundBite *)soundHeap->Malloc(sizeof(SoundBite) * numSoundBites); gosASSERT(sounds != NULL); memset(sounds,0,sizeof(SoundBite) * numSoundBites); for (long i=0;i<(long)numSoundBites;i++) { char biteBlock[20]; sprintf(biteBlock,"SoundBite%d",i); result = soundFile.seekBlock(biteBlock); gosASSERT(result == NO_ERR); result = soundFile.readIdULong("priority",sounds[i].priority); gosASSERT(result == NO_ERR); result = soundFile.readIdULong("cache",sounds[i].cacheStatus); gosASSERT(result == NO_ERR); result = soundFile.readIdULong("soundId",sounds[i].soundId); gosASSERT(result == NO_ERR); preloadSoundBite(i); //ALWAYS Preload!!!!!!!!!!!!! result = soundFile.readIdFloat("volume",sounds[i].volume); gosASSERT(result == NO_ERR); } //--------------------------------------------------------------- // Load the digital Music Data Strings result = soundFile.seekBlock("DigitalMusic"); gosASSERT(result == NO_ERR); result = soundFile.readIdLong("NumDMS",numDMS); gosASSERT(result == NO_ERR); result = soundFile.readIdFloat("StreamFadeDownTime",streamFadeDownTime); gosASSERT(result == NO_ERR); result = soundFile.readIdULong("StreamBitDepth",digitalStreamBitDepth); gosASSERT(result == NO_ERR); result = soundFile.readIdULong("StreamChannels",digitalStreamChannels); gosASSERT(result == NO_ERR); digitalMusicIds = (char **)soundHeap->Malloc(sizeof(char *) * numDMS); gosASSERT(digitalMusicIds != NULL); digitalMusicLoopFlags = (bool *)soundHeap->Malloc(sizeof(bool)*numDMS); gosASSERT(digitalMusicLoopFlags != NULL); digitalMusicVolume = (float *)soundHeap->Malloc(sizeof(float) * numDMS); for (i=0;i<numDMS;i++) { char digitalMSId[20]; sprintf(digitalMSId,"DMS%d",i); char digitalMSBId[20]; sprintf(digitalMSBId,"DMSLoop%d",i); char digitalMSVId[25]; sprintf(digitalMSVId,"DMSVolume%d",i); digitalMusicIds[i] = (char *)soundHeap->Malloc(30); result = soundFile.readIdString(digitalMSId,digitalMusicIds[i],29); gosASSERT(result == NO_ERR); result = soundFile.readIdBoolean(digitalMSBId,digitalMusicLoopFlags[i]); gosASSERT(result == NO_ERR); result = soundFile.readIdFloat(digitalMSVId,digitalMusicVolume[i]); if (result != NO_ERR) digitalMusicVolume[i] = 1.0f; } soundFile.close(); for (i=0;i<MAX_DIGITAL_SAMPLES+4;i++) { gosAudio_AllocateChannelSliders(i,gosAudio_Volume | gosAudio_Panning); } } digitalMasterVolume = float(DigitalMasterVolume) / 256.0f; SFXVolume = float(sfxVolume) / 256.0f; musicVolume = float(MusicVolume) / 256.0f; radioVolume = float(RadioVolume) / 256.0f; bettyVolume = float(BettyVolume) / 256.0f; stream1Id = stream2Id = 0; return(NO_ERR); }
int MechLabScreen::init( FitIniFile& file ) { if ( saveDlg )// already initialized return -1; ComponentListItem::init( file ); LogisticsScreen::init( file, "Static", "Text", "Rect", "Button" ); componentListBox.init( rects[2].left(), rects[2].top(), rects[2].width(), rects[2].height() ); componentListBox.setHighlightFX( -1 ); // want to do this by hand. saveDlg = new LogisticsVariantDialog; acceptDlg = new LogisticsAcceptVariantDialog; FitIniFile saveFile; FullPathFileName path; path.init( artPath, "MCL_SV", ".fit" ); if ( NO_ERR != saveFile.open( path ) ) { Assert( 0, 0, "couldn't open MCL_SV.fit" ); return -1; } saveDlg->init( saveFile ); saveFile.close(); path.init( artPath, "mcl_sv_acceptchanges", ".fit" ); if ( NO_ERR != saveFile.open( path ) ) { Assert( 0, 0, "couldn't open MCL_SV.fit" ); return -1; } acceptDlg->init( saveFile ); payloadIcon.init( &file, "PayloadUnit" ); char blockName[64]; for ( int i = 0; i < MECH_LAB_ATTRIBUTE_METER_COUNT; i++ ) { sprintf( blockName, "AttributeMeter%ld", i ); attributeMeters[i].init( &file, blockName ); } for ( i= 0; i < buttonCount; i++ ) { switch( buttons[i].getID() ) { case COMPONENT_FORM_WEAPON_ENERGY: case COMPONENT_FORM_WEAPON_BALLISTIC: case COMPONENT_FORM_WEAPON_MISSILE: case COMPONENT_FORM_JUMPJET: break; default: { buttons[i].setMessageOnRelease(); buttons[i].setPressFX(LOG_CLICKONBUTTON ); } } } file.seekBlock( "ComboBox0" ); long xLoc, yLoc; file.readIdLong( "XLocation", xLoc ); file.readIdLong( "YLocation", yLoc ); char fileName[256]; file.readIdString( "FileName", fileName, 255 ); path.init( artPath, fileName, ".fit" ); FitIniFile comboFile; if ( NO_ERR != comboFile.open( path ) ) { char errorStr[255]; sprintf( errorStr, "couldn't open file %s", (char*)path ); Assert( 0, 0, errorStr ); } variantList.init( &comboFile, "VariantComboBox" ); variantList.setReadOnly( true ); variantList.ListBox().setOrange(true); variantList.setParent( this ); variantList.setHelpID( IDS_HELP_MC_VARIANT_DROP_DOWN_LIST_BOX ); camera.init( rects[4].left(), rects[4].top(), rects[4].right(), rects[4].bottom() ); getButton( COMPONENT_FORM_WEAPON_ENERGY )->setPressFX( LOG_VIDEOBUTTONS ); getButton( COMPONENT_FORM_WEAPON_BALLISTIC )->setPressFX( LOG_VIDEOBUTTONS ); getButton( COMPONENT_FORM_WEAPON_MISSILE )->setPressFX( LOG_VIDEOBUTTONS ); getButton( COMPONENT_FORM_JUMPJET )->setPressFX( LOG_VIDEOBUTTONS ); getButton( COMPONENT_FORM_WEAPON_ENERGY )->setHighlightFX( LOG_DIGITALHIGHLIGHT ); getButton( COMPONENT_FORM_WEAPON_BALLISTIC )->setHighlightFX( LOG_DIGITALHIGHLIGHT ); getButton( COMPONENT_FORM_WEAPON_MISSILE )->setHighlightFX( LOG_DIGITALHIGHLIGHT ); getButton( COMPONENT_FORM_JUMPJET )->setHighlightFX( LOG_DIGITALHIGHLIGHT ); // initialize the selection rectangles for ( i = 0; i < 5; i++ ) { for ( int j = 0; j < 2; j++ ) { sprintf( fileName, "mcl_mc_%ldby%ld_selection.tga", j+1, i+1 ); path.init( artPath, fileName, ".tga" ); if ( fileExists( path ) ) { selRects[j][i].setTexture( path ); selRects[j][i].resize( (j+1) * LogisticsComponent::XICON_FACTOR, (i+1) * LogisticsComponent::YICON_FACTOR ); // now need to set the UV's selRects[j][i].setUVs( 0, 0, selRects[j][i].width(), selRects[j][i].height() ); } } } path.init( artPath, "mcl_mc_jumpjets_selection", ".tga" ); selJumpJetRect.setTexture( path ); selJumpJetRect.resize( 2 * LogisticsComponent::XICON_FACTOR, 2 * LogisticsComponent::YICON_FACTOR ); // now need to set the UV's selJumpJetRect.setUVs( 0, 0, selJumpJetRect.width(), selJumpJetRect.height() ); return true; }