/****************************************************************************** This source file is part of AstroMenace game (Hardcore 3D space shooter with spaceship upgrade possibilities.) For the latest info, see http://www.viewizard.com/ File name: Menu_Information.cpp Copyright (c) 2006-2007 Michael Kurinnoy, Viewizard All Rights Reserved. File Version: 1.2 ****************************************************************************** AstroMenace game source code available under "dual licensing" model. The licensing options available are: * Commercial Licensing. This is the appropriate option if you are creating proprietary applications and you are not prepared to distribute and share the source code of your application. Contact us for pricing at viewizard@viewizard.com * Open Source Licensing. This is the appropriate option if you want to share the source code of your application with everyone you distribute it to, and you also want to give them the right to share who uses it. You should have received a copy of the GNU General Public License version 3 with this source codes. If not, see . ******************************************************************************/ #include "../Game.h" #include "../Defines.h" // в демо версии вообще тут ничего нет //------------------------------------------------------------------------------------ // переменные //------------------------------------------------------------------------------------ CEarthSpaceFighter *InfoFighter = 0; CWeapon *InfoWeapon = 0; CProjectile *InfoMine = 0; VECTOR3D InfoWeaponPoint; CAlienSpaceFighter *InfoAlien = 0; CAlienSpaceMotherShip *InfoAlienMotherShip = 0; CPirateShip *InfoPirateShip = 0; CBuilding *InfoBuilding = 0; CMilitaryBuilding *InfoMilitaryBuilding = 0; CWheeled *InfoWheeled = 0; CTracked *InfoTracked = 0; int GetWeaponHullDamage(int Num); int GetWeaponSystemsDamage(int Num); char *GetWeaponGroupTitle(int Num); char *GetWeaponName(int Num); char *GetShipGroupTitle(int Num); char *GetWorkshopShipName(int Num); float GetProjectileRange(int Num); float LastRotateInfoObject = 0.0f; VECTOR3D PointCamera; VECTOR3D Point(1000,-1000,0); int CreateNum = 1; float RotationSum =0.0f; float InfoObjectWidth = 0.0f; float InfoObjectLength = 0.0f; float InfoObjectHeight = 0.0f; float InfoObjectStrength = 0.0f; int InfoObjectWeaponQuantity = 0; int InfoObjectEngineQuantity = 0; float InfoObjectEnergyUse = 0; int InfoObjectAmmo = 0; float InfoObjectReload = 0; float InfoObjectRange = 0; // кол-во и положение в списке отображения #define InfoFighterStart 1 #define InfoFighterQuant 22 #define InfoWeaponStart (InfoFighterStart+InfoFighterQuant) #define InfoWeaponQuant 19 #define InfoMineStart (InfoWeaponStart+InfoWeaponQuant) #define InfoMineQuant 4 #define InfoAlienStart (InfoMineStart+InfoMineQuant) #define InfoAlienQuant 17 #define InfoAlienMotherShipStart (InfoAlienStart+InfoAlienQuant) #define InfoAlienMotherShipQuant 8 #define InfoPirateShipStart (InfoAlienMotherShipStart+InfoAlienMotherShipQuant) #define InfoPirateShipQuant 15 #define InfoBuildingStart (InfoPirateShipStart+InfoPirateShipQuant) #define InfoBuildingQuant 11 #define InfoMilitaryBuildingStart (InfoBuildingStart+InfoBuildingQuant) #define InfoMilitaryBuildingQuant 7 #define InfoWheeledStart (InfoMilitaryBuildingStart+InfoMilitaryBuildingQuant) #define InfoWheeledQuant 8 #define InfoTrackedStart (InfoWheeledStart+InfoWheeledQuant) #define InfoTrackedQuant 14 #define InfoEnd 125 char *InfoGroupNames[10] = {"4_Earth_Spaceships", "4_Weapons", "4_Space_Mines", "4_Alien_Spaceships", "4_Alien_Motherships", "4_Pirate_Spaceships", "4_Civilian_Buildings", "4_Military_Buildings", "4_Wheeled_Vehicles", "4_Tracked_Vehicles"}; //------------------------------------------------------------------------------------ // Получаем номер текущего меню, и следующий элемент при нажатии //------------------------------------------------------------------------------------ int GetInfoNextGroup() { if (CreateNum>=InfoFighterStart && CreateNum=InfoWeaponStart && CreateNum=InfoMineStart && CreateNum=InfoAlienStart && CreateNum=InfoAlienMotherShipStart && CreateNum=InfoPirateShipStart && CreateNum=InfoBuildingStart && CreateNum=InfoMilitaryBuildingStart && CreateNum=InfoWheeledStart && CreateNum=InfoTrackedStart && CreateNum=InfoFighterStart && CreateNum=InfoWeaponStart && CreateNum=InfoMineStart && CreateNum=InfoAlienStart && CreateNum=InfoAlienMotherShipStart && CreateNum=InfoPirateShipStart && CreateNum=InfoBuildingStart && CreateNum=InfoMilitaryBuildingStart && CreateNum=InfoWheeledStart && CreateNum=InfoTrackedStart && CreateNum=InfoFighterStart && CreateNumCreate(tmpCreateNum); InfoFighter->ID = 1000; InfoFighter->EngineDestroyType = true; InfoFighter->SetLocation(VECTOR3D(1000,-1000-InfoFighter->AABB[6].y, 0)); Point = VECTOR3D(1000,-1000+InfoFighter->Height/3.0f,0); PointCamera = VECTOR3D(0.0f,(InfoFighter->Length +InfoFighter->Width+ InfoFighter->Height)*0.24f +InfoFighter->Height*0.3f, -(InfoFighter->Length +InfoFighter->Width+ InfoFighter->Height)*0.56f-InfoFighter->Height*0.7f); InfoObjectWidth = InfoFighter->Width; InfoObjectLength = InfoFighter->Length; InfoObjectHeight = InfoFighter->Height; InfoObjectStrength = InfoFighter->StrengthStart; InfoObjectWeaponQuantity = InfoFighter->WeaponQuantity; InfoObjectEngineQuantity = InfoFighter->EngineQuantity; if (InfoFighter->Engine != 0) for (int i=0; iEngineQuantity; i++) if (InfoFighter->Engine[i] != 0) InfoFighter->Engine[i]->SpeedOnCreation = -1.0f; InfoFighter->SetRotation(VECTOR3D(0.0f,RotationSum,0.0f)); } if (CreateNum>=InfoWeaponStart && CreateNumCreate(tmpCreateNum); InfoWeapon->ID = 1000; InfoWeaponPoint = VECTOR3D(0.0f,-InfoWeapon->AABB[6].y, -(InfoWeapon->Length/2.0f + InfoWeapon->AABB[6].z)); Point = VECTOR3D(1000,-1000+InfoWeapon->Height/3.0f,0); PointCamera = VECTOR3D(0.0f,(InfoWeapon->Length +InfoWeapon->Width+ InfoWeapon->Height)*0.3f +InfoWeapon->Height*0.3f, -(InfoWeapon->Length +InfoWeapon->Width+ InfoWeapon->Height)*0.7f-InfoWeapon->Height*0.7f); InfoObjectWidth = InfoWeapon->Width; InfoObjectLength = InfoWeapon->Length; InfoObjectHeight = InfoWeapon->Height; InfoObjectStrength = InfoWeapon->StrengthStart; InfoWeapon->SetRotation(VECTOR3D(0.0f,RotationSum,0.0f)); RotatePoint(&InfoWeaponPoint, VECTOR3D(0.0f, RotationSum, 0.0f)); InfoWeapon->SetLocation(VECTOR3D(1000+InfoWeaponPoint.x, -1000+InfoWeaponPoint.y, InfoWeaponPoint.z)); InfoObjectEnergyUse = InfoWeapon->EnergyUse; InfoObjectAmmo = InfoWeapon->AmmoStart; InfoObjectReload = InfoWeapon->NextFireTime; InfoObjectRange = GetProjectileRange(tmpCreateNum); // убираем источник света if (InfoWeapon->Fire != 0) if (InfoWeapon->Fire->Light != 0){vw_ReleaseLight(InfoWeapon->Fire->Light); InfoWeapon->Fire->Light = 0;} } if (CreateNum>=InfoMineStart && CreateNumCreate(213+tmpCreateNum); InfoMine->ID = 1000; InfoMine->ObjectStatus = -1; // чтобы не наводилось InfoMine->SpeedStart = InfoMine->SpeedEnd = InfoMine->Speed = 0.0f; InfoMine->GraphicFXDestroyType = true; InfoMine->SetLocation(VECTOR3D(1000,-1000-InfoMine->AABB[6].y, 0)); Point = VECTOR3D(1000,-1000+InfoMine->Height/2.0f,0); PointCamera = VECTOR3D(0.0f,(InfoMine->Length +InfoMine->Width+ InfoMine->Height)*0.3f +InfoMine->Height*0.3f, -(InfoMine->Length +InfoMine->Width+ InfoMine->Height)*0.7f-InfoMine->Height*0.7f); InfoObjectWidth = InfoMine->Width; InfoObjectLength = InfoMine->Length; InfoObjectHeight = InfoMine->Height; InfoObjectStrength = InfoMine->StrengthStart; InfoMine->SetRotation(VECTOR3D(0.0f,RotationSum,0.0f)); } if (CreateNum>=InfoAlienStart && CreateNumCreate(tmpCreateNum); InfoAlien->ID = 1000; InfoAlien->EngineDestroyType = true; InfoAlien->SetLocation(VECTOR3D(1000,-1000-InfoAlien->AABB[6].y, 0)); Point = VECTOR3D(1000,-1000+InfoAlien->Height/3.0f,0); PointCamera = VECTOR3D(0.0f,(InfoAlien->Length +InfoAlien->Width+ InfoAlien->Height)*0.24f +InfoAlien->Height*0.3f, -(InfoAlien->Length +InfoAlien->Width+ InfoAlien->Height)*0.56f-InfoAlien->Height*0.7f); InfoObjectWidth = InfoAlien->Width; InfoObjectLength = InfoAlien->Length; InfoObjectHeight = InfoAlien->Height; InfoObjectStrength = InfoAlien->StrengthStart; if (InfoAlien->Engine != 0) for (int i=0; iEngineQuantity; i++) if (InfoAlien->Engine[i] != 0) InfoAlien->Engine[i]->SpeedOnCreation = -1.0f; InfoAlien->SetRotation(VECTOR3D(0.0f,RotationSum,0.0f)); } if (CreateNum>=InfoAlienMotherShipStart && CreateNumCreate(tmpCreateNum); InfoAlienMotherShip->ID = 1000; InfoAlienMotherShip->EngineDestroyType = true; InfoAlienMotherShip->SetLocation(VECTOR3D(1000,-1000-InfoAlienMotherShip->AABB[6].y, 0)); Point = VECTOR3D(1000,-1000+InfoAlienMotherShip->Height/3.0f,0); PointCamera = VECTOR3D(0.0f,(InfoAlienMotherShip->Length +InfoAlienMotherShip->Width+ InfoAlienMotherShip->Height)*0.24f +InfoAlienMotherShip->Height*0.3f, -(InfoAlienMotherShip->Length +InfoAlienMotherShip->Width+ InfoAlienMotherShip->Height)*0.56f-InfoAlienMotherShip->Height*0.7f); InfoObjectWidth = InfoAlienMotherShip->Width; InfoObjectLength = InfoAlienMotherShip->Length; InfoObjectHeight = InfoAlienMotherShip->Height; InfoObjectStrength = InfoAlienMotherShip->StrengthStart; if (InfoAlienMotherShip->Engine != 0) for (int i=0; iEngineQuantity; i++) if (InfoAlienMotherShip->Engine[i] != 0) InfoAlienMotherShip->Engine[i]->SpeedOnCreation = -1.0f; InfoAlienMotherShip->SetRotation(VECTOR3D(0.0f,RotationSum,0.0f)); } if (CreateNum>=InfoPirateShipStart && CreateNumCreate(tmpCreateNum); InfoPirateShip->ID = 1000; InfoPirateShip->EngineDestroyType = true; InfoPirateShip->SetLocation(VECTOR3D(1000,-1000-InfoPirateShip->AABB[6].y, 0)); Point = VECTOR3D(1000,-1000+InfoPirateShip->Height/3.0f,0); PointCamera = VECTOR3D(0.0f,(InfoPirateShip->Length +InfoPirateShip->Width+ InfoPirateShip->Height)*0.24f +InfoPirateShip->Height*0.3f, -(InfoPirateShip->Length +InfoPirateShip->Width+ InfoPirateShip->Height)*0.56f-InfoPirateShip->Height*0.7f); InfoObjectWidth = InfoPirateShip->Width; InfoObjectLength = InfoPirateShip->Length; InfoObjectHeight = InfoPirateShip->Height; InfoObjectStrength = InfoPirateShip->StrengthStart; if (InfoPirateShip->Engine != 0) for (int i=0; iEngineQuantity; i++) if (InfoPirateShip->Engine[i] != 0) InfoPirateShip->Engine[i]->SpeedOnCreation = -1.0f; InfoPirateShip->SetRotation(VECTOR3D(0.0f,RotationSum,0.0f)); } if (CreateNum>=InfoBuildingStart && CreateNumCreate(tmpCreateNum); InfoBuilding->ID = 1000; InfoBuilding->SetLocation(VECTOR3D(1000,-1000-InfoBuilding->AABB[6].y, 0)); Point = VECTOR3D(1000,-1000+InfoBuilding->Height/3.0f,0); PointCamera = VECTOR3D(0.0f,(InfoBuilding->Length +InfoBuilding->Width+ InfoBuilding->Height)*0.16f +InfoBuilding->Height*0.3f, -(InfoBuilding->Length +InfoBuilding->Width+ InfoBuilding->Height)*0.38f-InfoBuilding->Height*0.7f); InfoObjectWidth = InfoBuilding->Width; InfoObjectLength = InfoBuilding->Length; InfoObjectHeight = InfoBuilding->Height; InfoObjectStrength = InfoBuilding->StrengthStart; InfoBuilding->SetRotation(VECTOR3D(0.0f,RotationSum,0.0f)); } if (CreateNum>=InfoMilitaryBuildingStart && CreateNumCreate(tmpCreateNum); InfoMilitaryBuilding->ID = 1000; InfoMilitaryBuilding->SetLocation(VECTOR3D(1000,-1000-InfoMilitaryBuilding->AABB[6].y, 0)); Point = VECTOR3D(1000,-1000+InfoMilitaryBuilding->Height/3.0f,0); PointCamera = VECTOR3D(0.0f,(InfoMilitaryBuilding->Length +InfoMilitaryBuilding->Width+ InfoMilitaryBuilding->Height)*0.24f +InfoMilitaryBuilding->Height*0.3f, -(InfoMilitaryBuilding->Length +InfoMilitaryBuilding->Width+ InfoMilitaryBuilding->Height)*0.56f-InfoMilitaryBuilding->Height*0.7f); InfoObjectWidth = InfoMilitaryBuilding->Width; InfoObjectLength = InfoMilitaryBuilding->Length; InfoObjectHeight = InfoMilitaryBuilding->Height; InfoObjectStrength = InfoMilitaryBuilding->StrengthStart; InfoMilitaryBuilding->SetRotation(VECTOR3D(0.0f,RotationSum,0.0f)); } if (CreateNum>=InfoWheeledStart && CreateNumCreate(tmpCreateNum); InfoWheeled->DeviationOn = true; InfoWheeled->ID = 1000; InfoWheeled->SetLocation(VECTOR3D(1000,-1000-InfoWheeled->AABB[6].y, 0)); InfoWheeled->WheelTrackSpeed = 350.0f; Point = VECTOR3D(1000,-1000+InfoWheeled->Height/3.0f,0); PointCamera = VECTOR3D(0.0f,(InfoWheeled->Length +InfoWheeled->Width+ InfoWheeled->Height)*0.24f +InfoWheeled->Height*0.3f, -(InfoWheeled->Length +InfoWheeled->Width+ InfoWheeled->Height)*0.56f-InfoWheeled->Height*0.7f); InfoObjectWidth = InfoWheeled->Width; InfoObjectLength = InfoWheeled->Length; InfoObjectHeight = InfoWheeled->Height; InfoObjectStrength = InfoWheeled->StrengthStart; InfoWheeled->SetRotation(VECTOR3D(0.0f,RotationSum,0.0f)); } if (CreateNum>=InfoTrackedStart && CreateNumCreate(tmpCreateNum); InfoTracked->DeviationOn = true; InfoTracked->ID = 1000; InfoTracked->SetLocation(VECTOR3D(1000,-1000-InfoTracked->AABB[6].y, 0)); InfoTracked->WheelTrackSpeed = 350.0f; Point = VECTOR3D(1000,-1000+InfoTracked->Height/3.0f,0); PointCamera = VECTOR3D(0.0f,(InfoTracked->Length +InfoTracked->Width+ InfoTracked->Height)*0.24f +InfoTracked->Height*0.3f, -(InfoTracked->Length +InfoTracked->Width+ InfoTracked->Height)*0.56f-InfoTracked->Height*0.7f); InfoObjectWidth = InfoTracked->Width; InfoObjectLength = InfoTracked->Length; InfoObjectHeight = InfoTracked->Height; InfoObjectStrength = InfoTracked->StrengthStart; InfoTracked->SetRotation(VECTOR3D(0.0f,RotationSum,0.0f)); } GameNPCArmorPenalty = TMPGameNPCArmorPenalty; LastRotateInfoObject = vw_GetTime(); #endif // #ifndef DEMO_VERSION } void InformationObject3DText(int ObjectNum) { #ifndef DEMO_VERSION int X1 = Setup.iAspectRatioWidth/2 + 68; int Y1 = 50; int Offset = 30; int Size = 170; int SizeB = FontSize(GetText("3_GAME_OBJECTS_INFORMATION")); int SizeI = (Setup.iAspectRatioWidth-SizeB)/2; DrawFont(SizeI, Y1-14, 0, 0, 0, MenuContentTransp, GetText("3_GAME_OBJECTS_INFORMATION")); // общее для файтеров землян if (CreateNum>=InfoFighterStart && CreateNum=InfoWeaponStart && CreateNum=InfoMineStart && CreateNum=InfoAlienStart && CreateNum=InfoAlienMotherShipStart && CreateNum=InfoPirateShipStart && CreateNum=InfoBuildingStart && CreateNum=InfoMilitaryBuildingStart && CreateNum=InfoWheeledStart && CreateNum=InfoTrackedStart && CreateNumInfoEnd) CreateNum = 1; CreateInfoObject(); } if (vw_GetKeys(SDLK_PAGEDOWN)) { CreateNum ++; if (CreateNum>InfoEnd) CreateNum = 1; CreateInfoObject(); vw_SetKeys(SDLK_PAGEDOWN, false); } X = (Setup.iAspectRatioWidth - 384)/2; Y = Y+Prir; if (DrawButton384(X,Y, GetText("1_MAIN_MENU"), MenuContentTransp, &Button1Transp, &LastButton1UpdateTime)) { DestroyInfoObject(); ComBuffer = MAIN_MENU; } #endif // DEMO_VERSION } //------------------------------------------------------------------------------------ // Прорисовка 3д части //------------------------------------------------------------------------------------ void InformationDrawObject() { #ifndef DEMO_VERSION int x, y, width, height; float znear, zfar; vw_GetViewport(&x, &y, &width, &height, &znear, &zfar); int W, H; vw_GetViewport(0, 0, &W, &H); float AWw = W*1.0f; float AHw = H*1.0f; float AW; float AH; bool ASpresent=false; ASpresent = vw_GetAspectWH(&AW, &AH); vw_SetViewport((int)((Setup.iAspectRatioWidth/2-432)/(AW/AWw)), (int)(80/(AH/AHw)), (int)(444/(AW/AWw)), (int)(333/(AH/AHw)), 0.0f, 0.3f, RI_UL_CORNER); vw_ResizeScene(45.0f, 444.0f/333.0f, 1.0f, 10000.0f); vw_LoadIdentity(); vw_SetCameraLocation(VECTOR3D(1000+PointCamera.x,-1000+PointCamera.y,PointCamera.z)); vw_SetCameraMoveAroundPoint(Point, 0.0f, VECTOR3D(0.0f, 0.0f, 0.0f)); vw_CameraLookAt(); // рисуем линии // буфер для последовательности RI_LINES float *tmpDATA = 0; // делаем массив для всех элементов RI_3f_XYZ | RI_4f_COLOR | RI_2f_TEX tmpDATA = new float[4*(3+4+2)]; int SizeCell = (int)(vw_sqrtf((InfoObjectLength*InfoObjectLength/4.0f+ InfoObjectWidth*InfoObjectWidth/4.0f+ InfoObjectHeight*InfoObjectHeight/4.0f))); float Alpha = 0.3f*MenuContentTransp; float LineSize = 0.004f * vw_sqrtf(PointCamera.x*PointCamera.x+PointCamera.y*PointCamera.y+ PointCamera.z*PointCamera.z); if (SizeCell<2) SizeCell = 2; // особенные для ракетных систем if (CreateNum == InfoWeaponStart+17) SizeCell = 3; if (CreateNum == InfoWeaponStart+18) SizeCell = 3; vw_SetTexBlend(RI_BLEND_SRCALPHA, RI_BLEND_ONE); vw_SetTextureT(0, vw_FindTextureByName("DATA/MENU/line.tga"), 1); vw_DepthTest(false, -1); for (int i=-SizeCell; iSetRotation(VECTOR3D(0.0f,RotateInfoObject,0.0f)); InfoFighter->Draw(); } if (InfoWeapon != 0) { RotatePointInv(&InfoWeaponPoint, VECTOR3D(0.0f, -(RotationSum-RotateInfoObject), 0.0f)); RotatePoint(&InfoWeaponPoint, VECTOR3D(0.0f, RotationSum, 0.0f)); // InfoWeapon->SetLocation(InfoWeaponPoint); InfoWeapon->SetLocation(VECTOR3D(1000+InfoWeaponPoint.x, -1000+InfoWeaponPoint.y, InfoWeaponPoint.z)); InfoWeapon->SetRotation(VECTOR3D(0.0f,RotateInfoObject,0.0f)); InfoWeapon->Draw(); } if (InfoMine != 0) { InfoMine->SetRotation(VECTOR3D(0.0f,RotateInfoObject,0.0f)); InfoMine->Draw(); } if (InfoAlien != 0) { InfoAlien->SetRotation(VECTOR3D(0.0f,RotateInfoObject,0.0f)); InfoAlien->Draw(); } if (InfoAlienMotherShip != 0) { InfoAlienMotherShip->SetRotation(VECTOR3D(0.0f,RotateInfoObject,0.0f)); InfoAlienMotherShip->Draw(); } if (InfoPirateShip != 0) { InfoPirateShip->SetRotation(VECTOR3D(0.0f,RotateInfoObject,0.0f)); InfoPirateShip->Draw(); // рисуем оружие if (InfoPirateShip->Weapon != 0) for (int i=0; iWeaponQuantity; i++) if (InfoPirateShip->Weapon[i] != 0) { InfoPirateShip->Weapon[i]->Draw(); } } if (InfoBuilding != 0) { InfoBuilding->SetRotation(VECTOR3D(0.0f,RotateInfoObject,0.0f)); InfoBuilding->Draw(); } if (InfoMilitaryBuilding != 0) { InfoMilitaryBuilding->SetRotation(VECTOR3D(0.0f,RotateInfoObject,0.0f)); InfoMilitaryBuilding->Draw(); } if (InfoWheeled != 0) { InfoWheeled->SetRotation(VECTOR3D(0.0f,RotateInfoObject,0.0f)); InfoWheeled->Draw(); } if (InfoTracked != 0) { InfoTracked->SetRotation(VECTOR3D(0.0f,RotateInfoObject,0.0f)); InfoTracked->Draw(); } vw_DrawAllParticleSystems(); vw_SetCameraLocation(VECTOR3D(-50,30,-50)); vw_SetViewport(x, y, width, height, znear, zfar); vw_ResizeScene(45.0f, Setup.fAspectRatioWidth/Setup.fAspectRatioHeight, 1.0f, 10000.0f); // бордюр с тенью vw_Start2DMode(-1,1); RECT SrcRest, DstRest; SetRect(&SrcRest,2,2,484-2,373-2); SetRect(&DstRest,(Setup.iAspectRatioWidth/2-432)+2-20,80+2-20,(Setup.iAspectRatioWidth/2-432)-2+484-20,80-2+373-20); vw_DrawTransparent(&DstRest, &SrcRest, vw_FindTextureByName("DATA/MENU/panel444_333_border.tga"), true, 1.0f*MenuContentTransp); vw_End2DMode(); #endif // #ifndef DEMO_VERSION }