Advertisement
Guest User

catalog.java

a guest
Mar 10th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 81.33 KB | None | 0 0
  1. package java.game;
  2.  
  3. import java.io.*;
  4. import java.util.*;
  5. import java.util.resource.*;
  6. import java.render.*;
  7. import java.render.osd.*;
  8. import java.render.osd.dialog.*;
  9. import java.sound.*;
  10.  
  11. import java.game.parts.*;
  12. import java.game.parts.bodypart.*;
  13. import java.game.parts.rgearpart.reciprocatingrgearpart.*;
  14.  
  15. public class Catalog extends GameType implements GameState
  16. {
  17. final static ResourceRef RR_ICON_CAR_COMP = new ResourceRef( misc.catalog:0x0004r );
  18. final static ResourceRef RR_ICON_CAR_1STEP = new ResourceRef( misc.catalog:0x0005r );
  19. final static ResourceRef RR_ICON_INV_COMP = new ResourceRef( misc.catalog:0x0007r );
  20.  
  21.  
  22. final static int DECALPRICE = 20;
  23.  
  24. final static int SC_ENGINE = 0;
  25. final static int SC_BODY = 1;
  26. final static int SC_RGEAR = 2;
  27. final static int SC_NONE = 3; //max+1
  28.  
  29. final static int CMD_EXIT = 0;
  30. final static int CMD_FRONTPAGE = 1;
  31. final static int CMD_MAIN1 = 2;
  32. final static int CMD_MAIN2 = 3;
  33. final static int CMD_MAIN3 = 4;
  34. final static int CMD_MAIN4 = 5;
  35. final static int CMD_MAIN5 = 6;
  36. final static int CMD_MAIN6 = 7;
  37.  
  38. final static int CMD_MAIN1_1 = 8;
  39. final static int CMD_MAIN1_2 = 9;
  40. final static int CMD_MAIN1_3 =10;
  41. final static int CMD_MAIN1_4 =11;
  42. final static int CMD_MAIN1_5 =12;
  43. final static int CMD_MAIN1_6 =13;
  44. final static int CMD_MAIN1_7 =14;
  45. final static int CMD_MAIN1_8 =15;
  46. final static int CMD_MAIN1_9 =16;
  47. final static int CMD_MAIN1_10 =17;
  48. final static int CMD_MAIN1_11 =18;
  49. final static int CMD_MAIN1_12 =19;
  50. final static int CMD_MAIN1_13 =20;
  51. final static int CMD_MAIN1_14 =21;
  52. final static int CMD_MAIN1_15 =22;
  53. final static int CMD_MAIN1_16 =23;
  54. final static int CMD_MAIN1_17 =24;
  55. final static int CMD_MAIN1_18 =25;
  56. final static int CMD_MAIN1_19 =26;
  57. final static int CMD_MAIN1_20 =27;
  58.  
  59. final static int CMD_MAIN2_1 =28;
  60. final static int CMD_MAIN2_2 =29;
  61. final static int CMD_MAIN2_3 =30;
  62. final static int CMD_MAIN2_4 =31;
  63. final static int CMD_MAIN2_5 =32;
  64. final static int CMD_MAIN2_6 =33;
  65. final static int CMD_MAIN2_7 =34;
  66.  
  67. final static int CMD_MAIN3_1 =35;
  68. final static int CMD_MAIN3_2 =36;
  69. final static int CMD_MAIN3_3 =37;
  70. final static int CMD_MAIN3_4 =38;
  71. final static int CMD_MAIN3_5 =39;
  72. final static int CMD_MAIN3_6 =40;
  73. final static int CMD_MAIN3_7 =41;
  74. final static int CMD_MAIN3_8 =42;
  75. final static int CMD_MAIN3_9 =43;
  76. //Factory
  77. final static int CMD_MAIN3_10 =44;
  78. final static int CMD_MAIN3_11 =45;
  79. final static int CMD_MAIN3_12 =46;
  80. final static int CMD_MAIN3_13 =47;
  81. final static int CMD_MAIN3_14 =48;
  82. final static int CMD_MAIN3_15 =49;
  83. //Rims
  84. final static int CMD_MAIN3_5_1 =50;
  85. final static int CMD_MAIN3_5_2 =51;
  86. final static int CMD_MAIN3_5_3 =52;
  87. final static int CMD_MAIN3_5_4 =53;
  88. final static int CMD_MAIN3_5_5 =54;
  89. final static int CMD_MAIN3_5_6 =55;
  90. final static int CMD_MAIN3_5_7 =56;
  91. final static int CMD_MAIN3_5_8 =57;
  92. final static int CMD_MAIN3_5_9 =58;
  93. final static int CMD_MAIN3_5_10 =59;
  94. //Tyres
  95. final static int CMD_MAIN3_6_1 =60;
  96. final static int CMD_MAIN3_6_2 =61;
  97. final static int CMD_MAIN3_6_3 =62;
  98. final static int CMD_MAIN3_6_4 =63;
  99. final static int CMD_MAIN3_6_5 =64;
  100. final static int CMD_MAIN3_6_6 =65;
  101. final static int CMD_MAIN3_6_7 =66;
  102. final static int CMD_MAIN3_6_8 =67;
  103. final static int CMD_MAIN3_6_9 =68;
  104. final static int CMD_MAIN3_6_10 =69;
  105.  
  106. final static int CMD_MAIN4_1 =70;
  107. final static int CMD_MAIN4_2 =71;
  108. final static int CMD_MAIN4_3 =72;
  109. final static int CMD_MAIN4_4 =73;
  110. final static int CMD_MAIN4_5 =74;
  111. final static int CMD_MAIN4_6 =75;
  112. final static int CMD_MAIN4_7 =76;
  113. final static int CMD_MAIN4_8 =77;
  114.  
  115. final static int CMD_MAIN5_1 =78;
  116. final static int CMD_MAIN5_2 =79;
  117. final static int CMD_MAIN5_3 =80;
  118. final static int CMD_MAIN5_4 =81;
  119. final static int CMD_MAIN5_5 =82;
  120. final static int CMD_MAIN5_6 =83;
  121.  
  122. final static int CMD_MAIN6_1 =84;
  123. final static int CMD_MAIN6_2 =85;
  124. final static int CMD_MAIN6_3 =86;
  125. final static int CMD_MAIN6_4 =87;
  126. final static int CMD_MAIN6_5 =88;
  127. final static int CMD_MAIN6_6 =89;
  128. final static int CMD_MAIN6_7 =90;
  129.  
  130. final static int CMD_DB0 =91;
  131. final static int CMD_DB1 =92;
  132. final static int CMD_DB2 =93;
  133. final static int CMD_DB3 =94;
  134. final static int CMD_DB4 =95;
  135. final static int CMD_DB5 =96;
  136. final static int CMD_DB6 =97;
  137. final static int CMD_DB7 =98;
  138.  
  139. final static int CMD_PREVDECALPAGE = 99;
  140. final static int CMD_NEXTDECALPAGE =100;
  141.  
  142. final static int CMD_PREVPARTPAGE =101;
  143. final static int CMD_NEXTPARTPAGE =102;
  144.  
  145. // Chassis shop
  146. final static int CMD_VEHICLE =103;
  147. final static int CMD_VEH0 =104;
  148. final static int CMD_VEH1 =105;
  149. final static int CMD_VEH2 =106;
  150. final static int CMD_VEH3 =107;
  151. final static int CMD_VEH4 =108;
  152. final static int CMD_VEH5 =109;
  153. final static int CMD_VEH6 =110;
  154. final static int CMD_VEH7 =111;
  155. final static int CMD_VEH8 =112;
  156. final static int CMD_VEH9 =113;
  157. final static int CMD_UP =114;
  158. final static int CMD_DOWN =115;
  159. final static int CMD_VEHI =116;
  160. final static int CMD_CHAS =117;
  161. final static int CMD_VBUY =118;
  162. final static int CMD_VCOLOR =119;
  163.  
  164. final static int NO_FILTER =120;
  165. final static int RIMS_FILTER =121;
  166. final static int TYRES_FILTER =122;
  167.  
  168.  
  169. final static int DEFAULT_VEHICLE_COLOR = cars:0x0025r;
  170.  
  171. final static String pageNumberPrefix;
  172.  
  173. final static float PRICERATIO = 1.1; //katalogus ar-szorzo
  174.  
  175. Player player;
  176.  
  177. Osd osd;
  178.  
  179. int actGroup;
  180.  
  181. Text moneytxt, pgNumberL, pgNumberR;
  182. Text[] pageNumberL = new Text[8];
  183. Text[] pageNumberR = new Text[8];
  184.  
  185. CatalogInventory inventory;
  186. Vector collector;
  187. GameRef parts;
  188.  
  189. int curpage=1;
  190.  
  191. int step, filter, currentCarPackId, partsPackId;
  192.  
  193. Decal[] curDecals;
  194. Button[] decalButtons;
  195. Vector decals;
  196. int showDecals;
  197.  
  198. int mainGroup, VehicleGroup, main1Group, main2Group, main3Group, main4Group, main5Group, main6Group, main7Group, main8Group;
  199. int decalsGroup, parts1Group, parts2Group, parts3Group, parts4Group, parts5Group, parts7Group, parts8Group;
  200.  
  201. ResourceRef[] carTypes;
  202. Button VColor_Button, VehButton0, VehButton1, VehButton2, VehButton3, VehButton4, VehButton5, VehButton6, VehButton7, VehButton8, VehButton9, UpButton, DownButton;
  203. int rimSize, tyreSize, VehAmount, ColorIDX, CurrentPage, CurrentName, CompleteCar, RetailP, DeliveryP, TotalP, ButtonNum;
  204. Text CurrentPageText;
  205. GameRef CarScene, Cam;
  206. //Camera Cam;
  207. RenderRef SceneSun;
  208. Thread CamThread;
  209. Ypr CamYpr;
  210. Vector3 CamVector;
  211. Viewport CarViewport;
  212. Vehicle CurrentCar;
  213. GameRef CurrentChassis;
  214. Text CurrentCarName, RetailText, DeliveryText, TotalText;
  215. TextBox CurrentCarDescription;
  216. Vector3 Size;
  217.  
  218. public Catalog()
  219. {
  220. createNativeInstance();
  221.  
  222. player = GameLogic.player;
  223.  
  224. carTypes = GameLogic.VEHICLETYPE_ROOT.getChildNodes();
  225. }
  226.  
  227. public static Vector collectDecals( String subdir )
  228. {
  229. Vector ds = new Vector();
  230.  
  231. FindFile ff = new FindFile();
  232. String name=ff.first( "decals/textures/catalog/" + subdir + "/*.png" );
  233. while( name )
  234. {
  235. Decal decal = new Decal( "decals/textures/catalog/" +subdir + "/" + name ); //extends ResourceRef
  236. ds.addElement( decal );
  237. name = ff.next();
  238. }
  239. ff.close();
  240.  
  241. return ds;
  242. }
  243.  
  244. public void clearObjectCache()
  245. {
  246. if( inventory )
  247. {
  248. inventory.hide();
  249. inventory.flushAll();
  250. inventory = null;
  251. }
  252.  
  253. collector = null;
  254. }
  255.  
  256. //puts parts of the given category and car type (+common parts) to the given inventory
  257. public void collectObjectsBegin()
  258. {
  259. clearObjectCache();
  260.  
  261. inventory = new CatalogInventory( this, player, 0.02, 0.25, 0.96, 0.50 );
  262. collector = new Vector();
  263.  
  264. if( player.car )
  265. currentCarPackId = player.car.getInfo( GII_TYPE ) >> 16;
  266. else
  267. currentCarPackId = 0;
  268.  
  269. partsPackId = System.openLib( "parts.rpk" );
  270. }
  271.  
  272. public void collectObjectsEnd()
  273. {
  274. collectObjectsStep(9);
  275.  
  276. inventory.update();
  277. inventory.show();
  278. }
  279.  
  280. public void collectObjects( GameRef root )
  281. {
  282. collectObjects( root, null, null, null, null);
  283. }
  284.  
  285. public void collectObjects( GameRef root1, GameRef root2 )
  286. {
  287. collectObjects( root1, root2, null, null, null);
  288. }
  289.  
  290. public void collectObjects( GameRef root1, GameRef root2, GameRef root3 )
  291. {
  292. collectObjects( root1, root2, root3, null, null);
  293. }
  294.  
  295. public void collectObjects( GameRef root1, GameRef root2, GameRef root3, GameRef root4 )
  296. {
  297. collectObjects( root1, root2, root3, root4, null);
  298. }
  299.  
  300. public void collectObjects( GameRef root1, GameRef root2, GameRef root3, GameRef root4, GameRef root5 )
  301. {
  302. if( root1 ) collector.addElement( root1 );
  303. if( root2 ) collector.addElement( root2 );
  304. if( root3 ) collector.addElement( root3 );
  305. if( root4 ) collector.addElement( root4 );
  306. if( root5 ) collector.addElement( root5 );
  307. }
  308.  
  309. //return false if finished collecting
  310. public int collectObjectsStep( int int_step )
  311. {
  312. step = int_step;
  313.  
  314. if( collector )
  315. {
  316. while( !collector.isEmpty() && step )
  317. {
  318. parts=collector.removeLastElement();
  319.  
  320. if( parts.isScripted( "java.game.parts.Part" ) )//it's a part
  321. {
  322. //inventory.items.addElement( new InventoryItem_Part( inventory, parts.id() ) );
  323. //step--;
  324. osdCommand( filter );// run parts filter
  325. }
  326. else
  327. if( parts.isScripted( "java.game.parts.Set" ) ) //set?
  328. {
  329. Set set = parts.create( null, parts, null, "set_loader" );
  330.  
  331. InventoryItem_Folder tmp = new InventoryItem_Folder( inventory );
  332. tmp.set = set;
  333. set.build( tmp.inv );
  334. inventory.items.addElement( tmp );
  335. }
  336. else
  337. { //dummy eloszto node!
  338. if( parts=parts.getFirstChild() )
  339. {
  340. while( parts )
  341. {
  342. if( parts.isScripted() )
  343. collector.addElement( parts );
  344. else
  345. {
  346. int carPack;
  347. int packId = parts.id() >> 16;
  348.  
  349. for( int i=carTypes.length-1; i>=0; i-- )
  350. {
  351. if( packId == carTypes[i].id()>>16 )
  352. {
  353. carPack=1;
  354. break;
  355. }
  356. }
  357.  
  358. if( !carPack || packId == currentCarPackId )
  359. collector.addElement( parts );
  360. //
  361. }
  362.  
  363. parts=parts.getNextChild();
  364. }
  365. }
  366. }
  367. }
  368.  
  369. inventory.update();
  370.  
  371. return !collector.isEmpty();
  372. }
  373.  
  374. return 0;
  375. }
  376.  
  377. public void setDecalButtons()
  378. {
  379. int max = decals.size();
  380.  
  381. clearDecalButtons();
  382.  
  383. for( int i=0; i<decalButtons.length; i++ )
  384. {
  385. //a gomb tipus (nagy)
  386. RenderRef base = new RenderRef( frontend:0x00AEr );
  387.  
  388. if( max > showDecals+i )
  389. {
  390. curDecals[i] = decals.elementAt( showDecals+i );
  391. decalButtons[i].rect.changeTexture( decals.elementAt( showDecals+i ) );
  392. }
  393. }
  394. }
  395.  
  396. public void clearDecalButtons()
  397. {
  398. for( int i=0; i<decalButtons.length; i++ )
  399. {
  400. decalButtons[i].rect.changeTexture( Osd.RRT_EMPTY );
  401. if( curDecals[i] )
  402. {
  403. curDecals[i].unload();
  404. curDecals[i] = null;
  405. }
  406. }
  407. }
  408.  
  409. public void enter( GameState prev_state )
  410. {
  411. RawEdit.setI(0x00618670,1);
  412. osd = new Osd();
  413. osd.globalHandler = this;
  414.  
  415. showDecals=0;
  416.  
  417. setEventMask( EVENT_TIME );
  418.  
  419. createOSDObjects();
  420. osd.show();
  421.  
  422. Input.cursor.enable(1);
  423. setEventMask( EVENT_CURSOR );
  424.  
  425. GfxEngine.setGlobalEnvmap( new ResourceRef( MW_Mod:0x0069r ));
  426. RawEdit.setI(0x00618670,0);
  427. }
  428.  
  429. public void exit( GameState next_state )
  430. {
  431. Frontend.loadingScreen.hide();
  432.  
  433. clearEventMask( EVENT_ANY );
  434. removeAllTimers();
  435. Input.cursor.enable(0);
  436.  
  437. pageNumberPrefix=null;
  438.  
  439. osd.hide();
  440. }
  441.  
  442. public void VehicleScene()
  443. {
  444. CarScene = new Dummy( WORLDTREEROOT );
  445.  
  446. //CarViewport = new Viewport( 12, 0.53, 0.205, 0.45, 0.40 );//MWM
  447. CarViewport = new Viewport( 12, 0.50, 0.190, 0.45, 0.50 );
  448. CarViewport.activate( Viewport.RENDERFLAG_CLEARDEPTH | Viewport.RENDERFLAG_CLEARTARGET );
  449. //Cam = new Camera( CarScene, CarViewport, 0 );
  450. Cam = new GameRef( CarScene, GameRef.RID_CAMERA, "-2,1,-3 , -2.5,0,0 ,0x02", "camera" );
  451. Cam.setMatrix( new Vector3( -2, 1, -4), new Ypr( -2.7, -0.2, 0));
  452. Cam.command( "render " + CarViewport.id() + " 0 0 1 " + (Viewport.RENDERFLAG_CLEARDEPTH | Viewport.RENDERFLAG_CLEARTARGET) );
  453. Cam.command( "look " + CarScene.id() + " 0.3,-0.6,0" );
  454. Cam.command( "zoom 35 10");
  455.  
  456. CurrentCar = new Vehicle();
  457.  
  458. RenderRef CarSun = new RenderRef(misc.garage:0x001Dr);
  459. SceneSun = new RenderRef( CarScene, CarSun, "light for this scene" );
  460.  
  461. // Reset at start
  462. ColorIDX = 0;
  463. CurrentPage = 0;
  464. CompleteCar = 0;
  465.  
  466. osdCommand( CMD_UP ); // Refresh page
  467. osdCommand( CMD_VEH0 );// Show 1st car
  468.  
  469. //getInfo( GameType.GII_SIZE )/100.0, 1 ); //size, enableRotate
  470.  
  471. //CamThread = new Thread( this, "Cam Animate Refresher" );
  472. //CamThread.start();
  473. }
  474.  
  475. private void createCatalogHeader( String text )
  476. {
  477. if( Config.catalogStyle == 1 )
  478. osd.createText( text, Frontend.largeFont, Text.ALIGN_LEFT, -0.95, -0.94 );
  479. }
  480.  
  481. public void createOSDObjects()
  482. {
  483. Style bsm = new Style( 0.70, 0.13, Frontend.largeFont, Text.ALIGN_RIGHT, Osd.RRT_TEST );
  484. Style bs = new Style( 0.70, 0.13, Frontend.mediumFont, Text.ALIGN_RIGHT, Osd.RRT_TEST );
  485.  
  486. Style bbsr = new Style( 0.12, 0.12, 1.0, Frontend.mediumFont, Text.ALIGN_RIGHT, new ResourceRef(Osd.RID_ARROWRG) );
  487. Style bbsl = new Style( 0.12, 0.12, 1.0, Frontend.mediumFont, Text.ALIGN_LEFT, new ResourceRef(Osd.RID_ARROWLF) );
  488.  
  489. Style bex = new Style( 0.12, 0.12, 1.0, Frontend.mediumFont, Text.ALIGN_CENTER, new ResourceRef(Osd.RID_EXIT) );
  490. Style bek = new Style( 0.12, 0.12, 1.0, Frontend.mediumFont, Text.ALIGN_CENTER, new ResourceRef(Osd.RID_BACK) );
  491.  
  492. Style Menu_Left = new Style( 0.7, 0.13, Frontend.mediumFont, Text.ALIGN_LEFT, Osd.RRT_TEST );
  493. Style Menu_Right = new Style( 0.7, 0.13, Frontend.mediumFont, Text.ALIGN_RIGHT, Osd.RRT_TEST );
  494. Style Menu_Center = new Style( 0.4, 0.13, Frontend.mediumFont, Text.ALIGN_CENTER, Osd.RRT_TEST );
  495. Style Menu_Button = new Style( 0.12, 0.12, Frontend.mediumFont, Text.ALIGN_CENTER, null );
  496. Style Midle_Button = new Style( 0.17, 0.17, Frontend.mediumFont, Text.ALIGN_CENTER, null );
  497. Style Big_Button = new Style( 0.2, 0.25, Frontend.mediumFont, Text.ALIGN_CENTER, new ResourceRef( frontend:0x0125r ) );
  498.  
  499. float bbcy = 0.675;
  500. if( Config.catalogStyle == 1 ) bbcy = 0.875;
  501.  
  502. Menu m;
  503.  
  504. //always visible objects:
  505. moneytxt=osd.createText( null, Frontend.mediumFont, Text.ALIGN_CENTER, 0.50, -0.94 );
  506. osd.endGroup();
  507.  
  508. //----------------------------------------Grand Index
  509.  
  510. osd.createBG( new ResourceRef(misc.catalog:0x0006r) );
  511. createCatalogHeader( "INDEX" );
  512.  
  513. m= osd.createMenu( bsm, 1.0, -0.55, 0.18 );
  514. m.addItem( "VEHICLE", CMD_VEHICLE );
  515. m.addItem( "ENGINE", CMD_MAIN1 );
  516. m.addItem( "BODY", CMD_MAIN2 );
  517. m.addItem( "RUNNING GEAR", CMD_MAIN3 );
  518. m.addItem( "INTERIOR", CMD_MAIN4 );
  519. m.addItem( "AUDIO", CMD_MAIN5 );
  520. m.addItem( "DECALS", CMD_MAIN6 );
  521.  
  522. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  523.  
  524. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_EXIT, this );
  525. actGroup = mainGroup = osd.endGroup();
  526.  
  527. //----------------------------------------Engine Index
  528.  
  529. osd.createBG( new ResourceRef(misc.catalog:0x0009r) );
  530. createCatalogHeader( "ENGINE" );
  531.  
  532. m= osd.createMenu( Menu_Left, -0.98, -0.65, 0.14 );
  533. m.addItem( "ENGINE BLOCKS", CMD_MAIN1_1 );
  534. m.addItem( "CRANKSHAFTS & BEARING", CMD_MAIN1_2 );
  535. m.addItem( "CONNECTING RODS", CMD_MAIN1_3 );
  536. m.addItem( "PISTONS", CMD_MAIN1_4 );
  537. m.addItem( "CYLINDER HEADS", CMD_MAIN1_6 );
  538. m.addItem( "INTAKE & EXHAUST CAMSHAFTS", CMD_MAIN1_7 );
  539. m.addItem( "AIR DELIVERY", CMD_MAIN1_8 );
  540. m.addItem( "FUEL DELIVERY", CMD_MAIN1_9 );
  541. m.addItem( "CLUTCHS & FLYWHEELS", CMD_MAIN1_10 );
  542. m.addItem( "TRANSMISSION & DRIVETRAIN", CMD_MAIN1_11 );
  543.  
  544. m= osd.createMenu( bs, 1.0, -0.65, 0.14 );
  545. m.addItem( "EXHAUST SYSTEM", CMD_MAIN1_12 );
  546. m.addItem( "EXHAUST PIPES", CMD_MAIN1_20 );
  547. m.addItem( "EXHAUST TIPS", CMD_MAIN1_13 );
  548. m.addItem( "DRIVE BELTS", CMD_MAIN1_14 );
  549. m.addItem( "ACCESSORIES & OTHERS", CMD_MAIN1_15 );
  550. m.addItem( "BATTERIES", CMD_MAIN1_16 );
  551. m.addItem( "OIL PANS", CMD_MAIN1_5 );
  552. m.addItem( "CHARGING SYSTEM", CMD_MAIN1_17 );
  553. m.addItem( "PRO TUNING", CMD_MAIN1_18 );
  554. m.addItem( "ENGINE KITS", CMD_MAIN1_19 );
  555.  
  556. osd.createButton( bek, 0.85, -0.92, CMD_FRONTPAGE, null );
  557. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  558.  
  559. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_FRONTPAGE, this );
  560. osd.hideGroup( main1Group = osd.endGroup() );
  561.  
  562. //----------------------------------------Vehicle Page
  563.  
  564. osd.createBG( new ResourceRef(misc.catalog:0x0026r) ); // Background
  565. createCatalogHeader( "VEHICLE" );
  566.  
  567. if( Config.catalogStyle == 1 )
  568. { // SLRR LE Style Page
  569. CurrentName = CurrentPage*10;
  570.  
  571. m = osd.createMenu( Menu_Center, 0.675, -0.725, Osd.MD_HORIZONTAL );
  572. m.addItem( "VEHICLE", CMD_VEHI );
  573.  
  574. m = osd.createMenu( Menu_Center, 0.325, -0.725, Osd.MD_HORIZONTAL );
  575. m.addItem( "CHASSIS", CMD_CHAS );
  576.  
  577. m = osd.createMenu( Midle_Button, 0.752, 0.157, 0, Osd.MD_VERTICAL );
  578. if( Config.carCatalogColor == 1 ) VColor_Button = m.addItem( new ResourceRef( frontend:0x00AFr ), CMD_VCOLOR, "Change color" );
  579. if( VColor_Button ) VColor_Button.disable();
  580.  
  581. CurrentPageText = osd.createText( "Current Page: " + (CurrentPage+1), Frontend.largeFont, Text.ALIGN_CENTER, 0, 0.81 ); CurrentPageText.changeColor(0xFFC0C0C0);// "Unselected" gray
  582. CurrentCarName = osd.createText( "-NO VEHICLE SELECTED-", Frontend.largeFont, Text.ALIGN_CENTER, 0.50, -0.625 ); CurrentCarName.changeColor(0xFFC0C0C0);// "Unselected" gray
  583.  
  584. CurrentCarDescription = osd.createTextBox( "Description: N/A", Frontend.smallFont, Text.ALIGN_CENTER, 0.15, 0.34, 0.60, null, 10 ); CurrentCarDescription.changeColor(0xFFC0C0C0);// text box, 10 lines max
  585.  
  586. osd.createText( "Retail Price:", Frontend.smallFont, Text.ALIGN_LEFT, 0.305, 0.80 ).changeColor(0xFFC0C0C0);// "Unselected" gray
  587. RetailText = osd.createText( "N/A", Frontend.smallFont, Text.ALIGN_RIGHT, 0.70, 0.80 ); RetailText.changeColor(0xFFC0C0C0);// "Unselected" gray
  588.  
  589. osd.createText( "Delivery Cost:", Frontend.smallFont, Text.ALIGN_LEFT, 0.305, 0.85 ).changeColor(0xFFC0C0C0);// "Unselected" gray
  590. DeliveryText = osd.createText( "N/A", Frontend.smallFont, Text.ALIGN_RIGHT, 0.70, 0.85 ); DeliveryText.changeColor(0xFFC0C0C0);// "Unselected" gray
  591.  
  592. osd.createText( "Total:", Frontend.smallFont, Text.ALIGN_LEFT, 0.305, 0.90 ).changeColor(0xFFC0C0C0);// "Unselected" gray
  593. TotalText = osd.createText( "N/A", Frontend.smallFont, Text.ALIGN_RIGHT, 0.70, 0.90 ); TotalText.changeColor(0xFFC0C0C0);// "Unselected" gray
  594.  
  595. osd.createText( "Choose between " + GameLogic.ChassisBox.size() + " different models." , Frontend.smallFont, Text.ALIGN_CENTER, 0, 0.88 ).changeColor(0xFFC0C0C0);// "Unselected" gray
  596.  
  597. VehAmount = GameLogic.ChassisBox.size()-1;
  598.  
  599. m= osd.createMenu( Menu_Left, -0.98, -0.60, 0 );
  600. if( CurrentName + 0 <= VehAmount ) VehButton0 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+0].vehicleName, CMD_VEH0 ); else { VehButton0 = m.addItem( "", CMD_VEH0 ); VehButton0.disable(); }
  601. if( CurrentName + 1 <= VehAmount ) VehButton1 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+1].vehicleName, CMD_VEH1 ); else { VehButton1 = m.addItem( "", CMD_VEH1 ); VehButton0.disable(); }
  602. if( CurrentName + 2 <= VehAmount ) VehButton2 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+2].vehicleName, CMD_VEH2 ); else { VehButton2 = m.addItem( "", CMD_VEH2 ); VehButton0.disable(); }
  603. if( CurrentName + 3 <= VehAmount ) VehButton3 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+3].vehicleName, CMD_VEH3 ); else { VehButton3 = m.addItem( "", CMD_VEH3 ); VehButton0.disable(); }
  604. if( CurrentName + 4 <= VehAmount ) VehButton4 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+4].vehicleName, CMD_VEH4 ); else { VehButton4 = m.addItem( "", CMD_VEH4 ); VehButton0.disable(); }
  605. if( CurrentName + 5 <= VehAmount ) VehButton5 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+5].vehicleName, CMD_VEH5 ); else { VehButton5 = m.addItem( "", CMD_VEH5 ); VehButton0.disable(); }
  606. if( CurrentName + 6 <= VehAmount ) VehButton6 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+6].vehicleName, CMD_VEH6 ); else { VehButton6 = m.addItem( "", CMD_VEH6 ); VehButton0.disable(); }
  607. if( CurrentName + 7 <= VehAmount ) VehButton7 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+7].vehicleName, CMD_VEH7 ); else { VehButton7 = m.addItem( "", CMD_VEH7 ); VehButton0.disable(); }
  608. if( CurrentName + 8 <= VehAmount ) VehButton8 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+8].vehicleName, CMD_VEH8 ); else { VehButton8 = m.addItem( "", CMD_VEH8 ); VehButton0.disable(); }
  609. if( CurrentName + 9 <= VehAmount ) VehButton9 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+9].vehicleName, CMD_VEH9 ); else { VehButton9 = m.addItem( "", CMD_VEH9 ); VehButton0.disable(); }
  610.  
  611. m = osd.createMenu( Menu_Button, -0.35, -0.73, Osd.MD_VERTICAL );
  612. UpButton = m.addItem( new ResourceRef( frontend:0x00AFr ), CMD_UP, "Prev Page" );
  613.  
  614. m = osd.createMenu( Menu_Button, -0.35, 0.865, Osd.MD_VERTICAL );
  615. DownButton = m.addItem( new ResourceRef( frontend:0x0084r ), CMD_DOWN, "Next Page" );
  616.  
  617. osd.createButton( bek, 0.85, -0.92, CMD_FRONTPAGE, null );
  618. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  619.  
  620. osd.createButton( Big_Button, 0.88, 0.847, CMD_VBUY, "Buy this vehicle" );
  621. }
  622. else
  623. { // MWM Style Page
  624. CurrentName = CurrentPage*10;
  625.  
  626. m = osd.createMenu( Menu_Center, 0.8, -0.775, Osd.MD_HORIZONTAL );
  627. m.addItem( "VEHICLE", CMD_VEHI );
  628.  
  629. m = osd.createMenu( Menu_Center, 0.45, -0.775, Osd.MD_HORIZONTAL );
  630. m.addItem( "CHASSIS", CMD_CHAS );
  631.  
  632. m = osd.createMenu( Midle_Button, 0.9, 0.1, 0, Osd.MD_VERTICAL );
  633. if( Config.carCatalogColor == 1 ) VColor_Button = m.addItem( new ResourceRef( frontend:0x00AFr ), CMD_VCOLOR, "Change color" );
  634. if( VColor_Button ) VColor_Button.disable();
  635.  
  636. CurrentPageText = osd.createText( "Current Page: " + (CurrentPage+1), Frontend.largeFont, Text.ALIGN_CENTER, -0.45, -0.86 ); CurrentPageText.changeColor(0xFFC0C0C0);// "Unselected" gray
  637. CurrentCarName = osd.createText( "-NO VEHICLE SELECTED-", Frontend.largeFont, Text.ALIGN_CENTER, 0.50, -0.65 ); CurrentCarName.changeColor(0xFFC0C0C0);// "Unselected" gray
  638.  
  639. CurrentCarDescription = osd.createTextBox( "Description: N/A", Frontend.smallFont, Text.ALIGN_CENTER, 0.09, 0.21, 0.85, null, 10 ); CurrentCarDescription.changeColor(0xFFC0C0C0);// text box, 10 lines max
  640.  
  641. osd.createText( "Retail Price:", Frontend.smallFont, Text.ALIGN_LEFT, 0.12, 0.77 ).changeColor(0xFFC0C0C0);// "Unselected" gray
  642. RetailText = osd.createText( "N/A", Frontend.smallFont, Text.ALIGN_RIGHT, 0.65, 0.77 ); RetailText.changeColor(0xFFC0C0C0);// "Unselected" gray
  643.  
  644. osd.createText( "Delivery Cost:", Frontend.smallFont, Text.ALIGN_LEFT, 0.12, 0.82 ).changeColor(0xFFC0C0C0);// "Unselected" gray
  645. DeliveryText = osd.createText( "N/A", Frontend.smallFont, Text.ALIGN_RIGHT, 0.65, 0.82 ); DeliveryText.changeColor(0xFFC0C0C0);// "Unselected" gray
  646.  
  647. osd.createText( "Total:", Frontend.smallFont, Text.ALIGN_LEFT, 0.12, 0.88 ).changeColor(0xFFC0C0C0);// "Unselected" gray
  648. TotalText = osd.createText( "N/A", Frontend.smallFont, Text.ALIGN_RIGHT, 0.65, 0.88 ); TotalText.changeColor(0xFFC0C0C0);// "Unselected" gray
  649.  
  650. osd.createText( "What you want to have today?", Frontend.smallFont, Text.ALIGN_CENTER, -0.45, 0.80 ).changeColor(0xFFC0C0C0);// "Unselected" gray
  651. osd.createText( "We have " + GameLogic.ChassisBox.size() + " vehicles at catalog." , Frontend.smallFont, Text.ALIGN_CENTER, -0.45, 0.85 ).changeColor(0xFFC0C0C0);// "Unselected" gray
  652.  
  653. VehAmount = GameLogic.ChassisBox.size()-1;
  654.  
  655. m= osd.createMenu( Menu_Left, -0.98, -0.60, 0 );
  656. if( CurrentName + 0 <= VehAmount ) VehButton0 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+0].vehicleName, CMD_VEH0 ); else { VehButton0 = m.addItem( "", CMD_VEH0 ); VehButton0.disable(); }
  657. if( CurrentName + 1 <= VehAmount ) VehButton1 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+1].vehicleName, CMD_VEH1 ); else { VehButton1 = m.addItem( "", CMD_VEH1 ); VehButton0.disable(); }
  658. if( CurrentName + 2 <= VehAmount ) VehButton2 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+2].vehicleName, CMD_VEH2 ); else { VehButton2 = m.addItem( "", CMD_VEH2 ); VehButton0.disable(); }
  659. if( CurrentName + 3 <= VehAmount ) VehButton3 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+3].vehicleName, CMD_VEH3 ); else { VehButton3 = m.addItem( "", CMD_VEH3 ); VehButton0.disable(); }
  660. if( CurrentName + 4 <= VehAmount ) VehButton4 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+4].vehicleName, CMD_VEH4 ); else { VehButton4 = m.addItem( "", CMD_VEH4 ); VehButton0.disable(); }
  661. if( CurrentName + 5 <= VehAmount ) VehButton5 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+5].vehicleName, CMD_VEH5 ); else { VehButton5 = m.addItem( "", CMD_VEH5 ); VehButton0.disable(); }
  662. if( CurrentName + 6 <= VehAmount ) VehButton6 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+6].vehicleName, CMD_VEH6 ); else { VehButton6 = m.addItem( "", CMD_VEH6 ); VehButton0.disable(); }
  663. if( CurrentName + 7 <= VehAmount ) VehButton7 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+7].vehicleName, CMD_VEH7 ); else { VehButton7 = m.addItem( "", CMD_VEH7 ); VehButton0.disable(); }
  664. if( CurrentName + 8 <= VehAmount ) VehButton8 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+8].vehicleName, CMD_VEH8 ); else { VehButton8 = m.addItem( "", CMD_VEH8 ); VehButton0.disable(); }
  665. if( CurrentName + 9 <= VehAmount ) VehButton9 = m.addItem(GameLogic.ChassisBox.elementData[CurrentName+9].vehicleName, CMD_VEH9 ); else { VehButton9 = m.addItem( "", CMD_VEH9 ); VehButton0.disable(); }
  666.  
  667. m = osd.createMenu( Menu_Button, -0.90, -0.82, Osd.MD_VERTICAL );
  668. UpButton = m.addItem( new ResourceRef( frontend:0x00AFr ), CMD_UP, "Prev Page" );
  669.  
  670. m = osd.createMenu( Menu_Button, -0.90, 0.82, Osd.MD_VERTICAL );
  671. DownButton = m.addItem( new ResourceRef( frontend:0x0084r ), CMD_DOWN, "Next Page" );
  672.  
  673. osd.createButton( bek, 0.08, -0.92, CMD_FRONTPAGE, null );
  674. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  675.  
  676. osd.createButton( Big_Button, 0.88, 0.847, CMD_VBUY, "Buy this vehicle" );
  677. }
  678.  
  679. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_FRONTPAGE, this );
  680. osd.hideGroup( VehicleGroup = osd.endGroup() );
  681.  
  682. //----------------------------------------Body Index
  683.  
  684. osd.createBG( new ResourceRef(misc.catalog:0x0010r) );
  685. createCatalogHeader( "BODY" );
  686.  
  687. m= osd.createMenu( bs, 1.0, -0.55, 0.18 );
  688. m.addItem( "BODY PANELS", CMD_MAIN2_1 );
  689. m.addItem( "REPLACEMENT PARTS", CMD_MAIN2_2 );
  690. m.addItem( "LIGHTS & WINDOWS", CMD_MAIN2_3 );
  691. m.addItem( "NEON LIGHTS", CMD_MAIN2_4 );
  692. m.addItem( "AERODYNAMIC TUNING", CMD_MAIN2_5 );
  693. m.addItem( "OTHERS", CMD_MAIN2_6 );
  694. m.addItem( "BODY KITS", CMD_MAIN2_7 );
  695.  
  696. osd.createButton( bek, 0.85, -0.92, CMD_FRONTPAGE, null );
  697. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  698.  
  699. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_FRONTPAGE, this );
  700. osd.hideGroup( main2Group = osd.endGroup() );
  701.  
  702. //----------------------------------------Running Gear Index
  703.  
  704. osd.createBG( new ResourceRef(misc.catalog:0x0011r) );
  705. createCatalogHeader( "RUNNING GEAR" );
  706.  
  707. m= osd.createMenu( Menu_Left, -0.98, -0.6, 0.133 );
  708. m.addItem( "FACTORY SUSPENSIONS", CMD_MAIN3_10 );
  709. m.addItem( "FACTORY SHOCK ABSORBERS", CMD_MAIN3_11 );
  710. m.addItem( "FACTORY SPRINGS", CMD_MAIN3_12 );
  711. m.addItem( "FACTORY BRAKE SYSTEMS", CMD_MAIN3_13 );
  712. m.addItem( "FACTORY SWAY BARS", CMD_MAIN3_14 );
  713. m.addSeparator();
  714. m.addSeparator();
  715. m.addItem( "OTHERS", CMD_MAIN3_8 );
  716. m.addItem( "RUNNING GEAR KITS", CMD_MAIN3_9 );
  717.  
  718. m= osd.createMenu( Menu_Right, 0.98, -0.6, 0.133 );
  719. m.addItem( "SUSPENSIONS", CMD_MAIN3_1 );
  720. m.addItem( "SHOCK ABSORBERS", CMD_MAIN3_2 );
  721. m.addItem( "SPRINGS", CMD_MAIN3_3 );
  722. m.addItem( "BRAKE SYSTEMS", CMD_MAIN3_4 );
  723. m.addItem( "SWAY BARS", CMD_MAIN3_7 );
  724. m.addSeparator();
  725. m.addSeparator();
  726. m.addItem( "RIMS", CMD_MAIN3_5 );
  727. m.addItem( "TYRES", CMD_MAIN3_6 );
  728.  
  729. osd.createButton( bek, 0.85, -0.92, CMD_FRONTPAGE, null );
  730. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  731.  
  732. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_FRONTPAGE, this );
  733. osd.hideGroup( main3Group = osd.endGroup() );
  734.  
  735. //----------------------------------------Rims Index
  736.  
  737. osd.createBG( new ResourceRef(misc.catalog:0x0011r) );
  738. createCatalogHeader( "RUNNING GEAR: RIMS" );
  739.  
  740. m= osd.createMenu( Menu_Right, 0.98, -0.6, 0.133 );
  741. m.addItem( "SMALLER RIMS", CMD_MAIN3_5_1 );
  742. m.addItem( "RIMS 14''", CMD_MAIN3_5_2 );
  743. m.addItem( "RIMS 15''", CMD_MAIN3_5_3 );
  744. m.addItem( "RIMS 16''", CMD_MAIN3_5_4 );
  745. m.addItem( "RIMS 17''", CMD_MAIN3_5_5 );
  746. m.addItem( "RIMS 18''", CMD_MAIN3_5_6 );
  747. m.addItem( "RIMS 19''", CMD_MAIN3_5_7 );
  748. m.addItem( "RIMS 20''", CMD_MAIN3_5_8 );
  749. m.addItem( "RIMS 21''", CMD_MAIN3_5_9 );
  750. m.addItem( "BIGGER RIMS ", CMD_MAIN3_5_10 );
  751.  
  752. osd.createButton( bek, 0.85, -0.92, CMD_MAIN3, null );
  753. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  754.  
  755. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_MAIN3, this );
  756. osd.hideGroup( main7Group = osd.endGroup() );
  757.  
  758. //----------------------------------------Tyres Index
  759.  
  760. osd.createBG( new ResourceRef(misc.catalog:0x0011r) );
  761. createCatalogHeader( "RUNNING GEAR: TYRES" );
  762.  
  763. m= osd.createMenu( Menu_Right, 0.98, -0.6, 0.133 );
  764. m.addItem( "SMALLER TYRES", CMD_MAIN3_6_1 );
  765. m.addItem( "TYRES 14''", CMD_MAIN3_6_2 );
  766. m.addItem( "TYRES 15''", CMD_MAIN3_6_3 );
  767. m.addItem( "TYRES 16''", CMD_MAIN3_6_4 );
  768. m.addItem( "TYRES 17''", CMD_MAIN3_6_5 );
  769. m.addItem( "TYRES 18''", CMD_MAIN3_6_6 );
  770. m.addItem( "TYRES 19''", CMD_MAIN3_6_7 );
  771. m.addItem( "TYRES 20''", CMD_MAIN3_6_8 );
  772. m.addItem( "TYRES 21''", CMD_MAIN3_6_9 );
  773. m.addItem( "BIGGER TYRES ", CMD_MAIN3_6_10 );
  774.  
  775. osd.createButton( bek, 0.85, -0.92, CMD_MAIN3, null );
  776. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  777.  
  778. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_MAIN3, this );
  779. osd.hideGroup( main8Group = osd.endGroup() );
  780.  
  781. //----------------------------------------Interior Index
  782.  
  783. osd.createBG( new ResourceRef(misc.catalog:0x001Er) );
  784. createCatalogHeader( "INTERIOR" );
  785.  
  786. m= osd.createMenu( bs, 1.0, -0.55, 0.16 );
  787. m.addItem( "STEERING WHEELS", CMD_MAIN4_1 );
  788. m.addItem( "DASHES", CMD_MAIN4_2 );
  789. m.addItem( "GEAR KNOBS", CMD_MAIN4_3 );
  790. m.addItem( "PEDALS", CMD_MAIN4_4 );
  791. m.addItem( "GAUGES", CMD_MAIN4_5 );
  792. m.addItem( "SEATS", CMD_MAIN4_6 );
  793. m.addItem( "ROLLBARS", CMD_MAIN4_7 );
  794. m.addItem( "DECORATION", CMD_MAIN4_8 );
  795.  
  796. osd.createButton( bek, 0.85, -0.92, CMD_FRONTPAGE, null );
  797. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  798.  
  799. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_FRONTPAGE, this );
  800. osd.hideGroup( main4Group = osd.endGroup() );
  801.  
  802. //----------------------------------------Audio Index
  803.  
  804. osd.createBG( new ResourceRef(misc.catalog:0x001Fr) );
  805. createCatalogHeader( "AUDIO" );
  806.  
  807. m= osd.createMenu( bs, 1.0, -0.55, 0.18 );
  808. m.addItem( "HEAD UNITS", CMD_MAIN5_1 );
  809. m.addItem( "AMPLIFIERS", CMD_MAIN5_2 );
  810. m.addItem( "BOXES", CMD_MAIN5_3 );
  811. m.addItem( "SUBWOOFERS", CMD_MAIN5_4 );
  812. m.addItem( "ACCESSORIES", CMD_MAIN5_5 );
  813. m.addItem( "AUDIO KITS", CMD_MAIN5_6 );
  814.  
  815. osd.createButton( bek, 0.85, -0.92, CMD_FRONTPAGE, null );
  816. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  817.  
  818. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_FRONTPAGE, this );
  819. osd.hideGroup( main5Group = osd.endGroup() );
  820.  
  821. //----------------------------------------Decal Index
  822.  
  823. osd.createBG( new ResourceRef(misc.catalog:0x0022r) );
  824. createCatalogHeader( "DECALS" );
  825.  
  826. m= osd.createMenu( bs, 1.0, -0.55, 0.18 );
  827. m.addItem( "MANUFACTURERS", CMD_MAIN6_1 );
  828. m.addItem( "LOGOS", CMD_MAIN6_2 );
  829. m.addItem( "NUMBERS", CMD_MAIN6_3 );
  830. m.addItem( "DIGITS", CMD_MAIN6_4 );
  831. m.addItem( "SMILIES", CMD_MAIN6_5 );
  832. m.addItem( "ANIMALS", CMD_MAIN6_6 );
  833. m.addItem( "MISC", CMD_MAIN6_7 );
  834.  
  835. osd.createButton( bek, 0.85, -0.92, CMD_FRONTPAGE, null );
  836. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  837.  
  838. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_FRONTPAGE, this );
  839. osd.hideGroup( main6Group = osd.endGroup() );
  840.  
  841. //----------------------------------------Akatreszlista oldalak 1
  842.  
  843. osd.createBG( new ResourceRef(misc.catalog:0x0009r) );
  844. createCatalogHeader( "ENGINE" );
  845.  
  846. pageNumberL[0] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_LEFT, -0.88, bbcy-0.025 );
  847. pageNumberR[0] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_RIGHT, 0.88, bbcy-0.025 );
  848.  
  849. osd.createButton( bbsl, -0.96, bbcy, CMD_PREVPARTPAGE, null );
  850. osd.createButton( bbsr, 0.96, bbcy, CMD_NEXTPARTPAGE, null );
  851.  
  852. osd.createButton( bek, 0.85, -0.92, CMD_MAIN1, null );
  853. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  854.  
  855. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_MAIN1, this );
  856. osd.hideGroup( parts1Group = osd.endGroup() );
  857.  
  858. //----------------------------------------Akatreszlista oldalak 2
  859.  
  860. osd.createBG( new ResourceRef(misc.catalog:0x0010r) );
  861. createCatalogHeader( "BODY" );
  862.  
  863. pageNumberL[1] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_LEFT, -0.88, bbcy-0.025 );
  864. pageNumberR[1] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_RIGHT, 0.88, bbcy-0.025 );
  865.  
  866. osd.createButton( bbsl, -0.96, bbcy, CMD_PREVPARTPAGE, null );
  867. osd.createButton( bbsr, 0.96, bbcy, CMD_NEXTPARTPAGE, null );
  868.  
  869. osd.createButton( bek, 0.85, -0.92, CMD_MAIN2, null );
  870. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  871.  
  872. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_MAIN2, this );
  873. osd.hideGroup( parts2Group = osd.endGroup() );
  874.  
  875. //----------------------------------------Akatreszlista oldalak 3
  876.  
  877. osd.createBG( new ResourceRef(misc.catalog:0x0011r) );
  878. createCatalogHeader( "RUNNING GEAR" );
  879.  
  880. pageNumberL[2] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_LEFT, -0.88, bbcy-0.025 );
  881. pageNumberR[2] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_RIGHT, 0.88, bbcy-0.025 );
  882.  
  883. osd.createButton( bbsl, -0.96, bbcy, CMD_PREVPARTPAGE, null );
  884. osd.createButton( bbsr, 0.96, bbcy, CMD_NEXTPARTPAGE, null );
  885.  
  886. osd.createButton( bek, 0.85, -0.92, CMD_MAIN3, null );
  887. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  888.  
  889. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_MAIN3, this );
  890. osd.hideGroup( parts3Group = osd.endGroup() );
  891.  
  892. //----------------------------------------Akatreszlista oldalak 3.5
  893.  
  894. osd.createBG( new ResourceRef(misc.catalog:0x0011r) );
  895. createCatalogHeader( "RUNNING GEAR: RIMS" );
  896.  
  897. pageNumberL[3] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_LEFT, -0.88, bbcy-0.025 );
  898. pageNumberR[3] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_RIGHT, 0.88, bbcy-0.025 );
  899.  
  900. osd.createButton( bbsl, -0.96, bbcy, CMD_PREVPARTPAGE, null );
  901. osd.createButton( bbsr, 0.96, bbcy, CMD_NEXTPARTPAGE, null );
  902.  
  903. osd.createButton( bek, 0.85, -0.92, CMD_MAIN3_5, null );
  904. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  905.  
  906. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_MAIN3_5, this );
  907. osd.hideGroup( parts7Group = osd.endGroup() );
  908.  
  909. //----------------------------------------Akatreszlista oldalak 3.6
  910.  
  911. osd.createBG( new ResourceRef(misc.catalog:0x0011r) );
  912. createCatalogHeader( "RUNNING GEAR: TYRES" );
  913.  
  914. pageNumberL[7] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_LEFT, -0.88, bbcy-0.025 );
  915. pageNumberR[7] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_RIGHT, 0.88, bbcy-0.025 );
  916.  
  917. osd.createButton( bbsl, -0.96, bbcy, CMD_PREVPARTPAGE, null );
  918. osd.createButton( bbsr, 0.96, bbcy, CMD_NEXTPARTPAGE, null );
  919.  
  920. osd.createButton( bek, 0.85, -0.92, CMD_MAIN3_6, null );
  921. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  922.  
  923. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_MAIN3_6, this );
  924. osd.hideGroup( parts8Group = osd.endGroup() );
  925.  
  926. //----------------------------------------Akatreszlista oldalak 4
  927.  
  928. osd.createBG( new ResourceRef(misc.catalog:0x001Er) );
  929. createCatalogHeader( "INTERIOR" );
  930.  
  931. pageNumberL[4] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_LEFT, -0.88, bbcy-0.025 );
  932. pageNumberR[4] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_RIGHT, 0.88, bbcy-0.025 );
  933.  
  934. osd.createButton( bbsl, -0.96, bbcy, CMD_PREVPARTPAGE, null );
  935. osd.createButton( bbsr, 0.96, bbcy, CMD_NEXTPARTPAGE, null );
  936.  
  937. osd.createButton( bek, 0.85, -0.92, CMD_MAIN4, null );
  938. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  939.  
  940. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_MAIN4, this );
  941. osd.hideGroup( parts4Group = osd.endGroup() );
  942.  
  943. //----------------------------------------Akatreszlista oldalak 5
  944.  
  945. osd.createBG( new ResourceRef(misc.catalog:0x001Fr) );
  946. createCatalogHeader( "AUDIO" );
  947.  
  948. pageNumberL[5] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_LEFT, -0.88, bbcy-0.025 );
  949. pageNumberR[5] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_RIGHT, 0.88, bbcy-0.025 );
  950.  
  951. osd.createButton( bbsl, -0.96, bbcy, CMD_PREVPARTPAGE, null );
  952. osd.createButton( bbsr, 0.96, bbcy, CMD_NEXTPARTPAGE, null );
  953.  
  954. osd.createButton( bek, 0.85, -0.92, CMD_MAIN5, null );
  955. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  956.  
  957. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_MAIN5, this );
  958. osd.hideGroup( parts5Group = osd.endGroup() );
  959.  
  960. //----------------------------------------Altalanos decallista oldal
  961.  
  962. osd.createBG( new ResourceRef(misc.catalog:0x0022r) );
  963. createCatalogHeader( "DECALS" );
  964.  
  965. Style dbs = new Style( 0.45, 0.45, Frontend.largeFont, Text.ALIGN_CENTER, Osd.RRT_TEST );
  966.  
  967. curDecals = new Decal[8];
  968. decalButtons=new Button[8];
  969. decalButtons[0] = osd.createButton( dbs, -0.75, -0.35, "", CMD_DB0 );
  970. decalButtons[1] = osd.createButton( dbs, -0.25, -0.35, "", CMD_DB1 );
  971. decalButtons[2] = osd.createButton( dbs, 0.25, -0.35, "", CMD_DB2 );
  972. decalButtons[3] = osd.createButton( dbs, 0.75, -0.35, "", CMD_DB3 );
  973. decalButtons[4] = osd.createButton( dbs, -0.75, 0.40, "", CMD_DB4 );
  974. decalButtons[5] = osd.createButton( dbs, -0.25, 0.40, "", CMD_DB5 );
  975. decalButtons[6] = osd.createButton( dbs, 0.25, 0.40, "", CMD_DB6 );
  976. decalButtons[7] = osd.createButton( dbs, 0.75, 0.40, "", CMD_DB7 );
  977.  
  978. pageNumberL[6] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_LEFT, -0.88, bbcy-0.025 );
  979. pageNumberR[6] = osd.createText( null, Frontend.mediumFont, Text.ALIGN_RIGHT, 0.88, bbcy-0.025 );
  980.  
  981. osd.createButton( bbsl, -0.96, bbcy, CMD_PREVDECALPAGE, null );
  982. osd.createButton( bbsr, 0.96, bbcy, CMD_NEXTDECALPAGE, null );
  983.  
  984. osd.createButton( bek, 0.85, -0.92, CMD_MAIN6, null );
  985. osd.createButton( bex, 0.92, -0.92, CMD_EXIT, null );
  986.  
  987. osd.createHotkey( Input.AXIS_CANCEL, Input.VIRTUAL, CMD_MAIN6, this );
  988. osd.hideGroup( decalsGroup = osd.endGroup() );
  989.  
  990. //------------------------------------------
  991.  
  992. refreshMoneyString();
  993. refreshPage();
  994. }
  995.  
  996.  
  997. public void changeGroup(int group)
  998. {
  999. if( actGroup != group )
  1000. {
  1001. if (actGroup >= 0)
  1002. {
  1003. osd.hideGroup (actGroup);
  1004.  
  1005. //group deinit code:
  1006. if( actGroup == decalsGroup )
  1007. {
  1008. clearDecalButtons();
  1009. }
  1010. else
  1011. if( actGroup >= parts1Group && actGroup <= parts5Group )
  1012. {
  1013. clearObjectCache();
  1014. }
  1015. }
  1016.  
  1017. actGroup = group;
  1018.  
  1019. if (actGroup >= 0)
  1020. {
  1021. osd.showGroup (actGroup);
  1022. osd.changeSelection2( -1, 0 );
  1023. }
  1024. }
  1025. }
  1026.  
  1027.  
  1028. public void refreshMoneyString()
  1029. {
  1030. new SfxRef( Frontend.SFX_MONEY ).play();
  1031. moneytxt.changeText( "$" + Integer.toString( player.money ) );
  1032. }
  1033.  
  1034. public void refreshPage()
  1035. {
  1036. if( pageNumberPrefix )
  1037. {
  1038. pgNumberL.changeText( pageNumberPrefix + curpage );
  1039. pgNumberR.changeText( pageNumberPrefix + (curpage+1) );
  1040. }
  1041. }
  1042.  
  1043. //----------------------------------------------------------------------
  1044.  
  1045. public void decalButtonPressed( int n )
  1046. {
  1047. if( showDecals+n < decals.size() )
  1048. {
  1049. int price=DECALPRICE;
  1050. if( price <= player.money )
  1051. {
  1052. Decal decal = decals.elementAt( showDecals+n );
  1053.  
  1054. Dialog dialog = new YesNoDialog( player.controller, Dialog.DF_MODAL|Dialog.DF_DEFAULTBG, "BUY DECAL SET", "Do you want to buy this decal set for $" + price + " ?\n(Each set contains 5 decals)" );
  1055. if( dialog.display() == 0 )
  1056. {
  1057. player.money-=price;
  1058. player.decals.addElement( new Decal( decal.id() ) );
  1059. refreshMoneyString();
  1060. }
  1061. }
  1062. else
  1063. {
  1064. new WarningDialog( player.controller, Dialog.DF_MODAL|Dialog.DF_DEFAULTBG, "NOT ENOUGHT MONEY", "You don't have $" + price + " to buy a decal!" ).display();
  1065. }
  1066. }
  1067. }
  1068.  
  1069. //----------------------------------------------------------------------
  1070. public void osdCommand( int cmd )
  1071. {
  1072. if( cmd == CMD_VCOLOR )
  1073. {
  1074. if(CurrentCar)
  1075. {
  1076. if( ColorIDX == GameLogic.CARCOLORS.length - 1)
  1077. ColorIDX = 0;
  1078. else
  1079. ColorIDX += 1;
  1080.  
  1081. CurrentCar.command( "texture " + GameLogic.CARCOLORS[ColorIDX] + " 1" );
  1082. if( VColor_Button ) VColor_Button.changeTexture( new ResourceRef(GameLogic.CARCOLORS[ColorIDX]) );
  1083. }
  1084. }
  1085. else
  1086. if( cmd == CMD_VBUY )
  1087. {
  1088. if( TotalP <= player.money )
  1089. {
  1090. // Create name: car name or chassis name
  1091. String Vname;
  1092. if( CompleteCar > 0 ) Vname = CurrentCar.chassis.vehicleName;
  1093. else Vname = CurrentCar.chassis.name;
  1094.  
  1095. // Check for free space at garage
  1096. int GarageFree;
  1097.  
  1098. if( GameLogic.player.car )
  1099. {
  1100. //GameLogic.garage.releaseCar();
  1101. GameLogic.player.carlot.lockPlayerCar();
  1102. GarageFree = GameLogic.player.carlot.getFreeSlot();
  1103. GameLogic.player.carlot.releasePlayerCar();
  1104.  
  1105. //Reset car pos at garage
  1106. GameLogic.garage.StartPos = new Vector3(0, 0, 0);
  1107. GameLogic.garage.StartYpr = new Ypr(0, 0, 0);
  1108. }
  1109. else
  1110. GarageFree = 1;
  1111.  
  1112. if( GarageFree >= 0 )
  1113. {
  1114. Dialog dialog = new NoYesDialog( player.controller, Dialog.DF_MODAL|Dialog.DF_DEFAULTBG, "BUY CAR", "Do you want to buy this " + Vname + " for $" + TotalP + " ?" );
  1115. if( dialog.display() == 0 )
  1116. {
  1117. player.money-=TotalP;
  1118. refreshMoneyString();
  1119.  
  1120. player.carlot.addCar( player.car );
  1121. player.carlot.saveCar( player.carlot.curcar );
  1122. player.carlot.flushCars();
  1123.  
  1124. //CurrentCar.command( "start" ); //release
  1125.  
  1126. if (File.exists("save/temp/CopyCar"))
  1127. {
  1128. File.delete( "save/temp/CopyCar" );
  1129. File.delete( "save/temp/CopyCar.*" );
  1130. }
  1131. CurrentCar.save( "save/temp/CopyCar" );
  1132.  
  1133. if(CurrentCar) CurrentCar.destroy();
  1134. if(CurrentChassis) CurrentChassis.destroy();
  1135.  
  1136. GameLogic.player.car = Vehicle.load( "save/temp/CopyCar", GameLogic.player );
  1137.  
  1138. changeGroup( -1 );
  1139. GameLogic.changeActiveSection( GameLogic.garage );
  1140. }
  1141. }
  1142. else
  1143. {
  1144. new WarningDialog( player.controller, Dialog.DF_MODAL|Dialog.DF_DEFAULTBG, "CAR LOT FULL", "There is no more free space in your car lot. \n Sell some cars to free up parking space!" ).display();
  1145. }
  1146. }
  1147. else
  1148. {
  1149. new WarningDialog( player.controller, Dialog.DF_MODAL|Dialog.DF_DEFAULTBG, "NOT ENOUGHT MONEY", "You don't have $" + TotalP + " to buy this car!" ).display();
  1150. }
  1151. }
  1152. else
  1153. if( cmd == CMD_CHAS )
  1154. {
  1155. if(CompleteCar > 0)
  1156. {
  1157. if(CurrentCar) CurrentCar.destroy();
  1158. if(CurrentChassis) CurrentChassis.destroy();
  1159.  
  1160. CurrentCar = new Vehicle();
  1161. CurrentCar.chassis = new Chassis();
  1162. CurrentCar.chassis = create(CarScene, new GameRef(GameLogic.ChassisRoot[GameLogic.ChassisResNoumber[CurrentName+ButtonNum]]), "0,0,0,0,0,0,", "chassis");
  1163. CurrentCar = new Vehicle(CurrentCar.chassis);
  1164.  
  1165. CurrentCarName.changeText( CurrentCar.chassis.vehicleName );
  1166. if( CurrentCarDescription ) CurrentCarDescription.changeText( CurrentCar.chassis.description );
  1167.  
  1168. RetailP = CurrentCar.getTotalPrice()*PRICERATIO; // Clac retail price
  1169. RetailText.changeText( "$" + RetailP );// show text
  1170.  
  1171. DeliveryP = CurrentCar.chassis.getMass()*5.8; // Calc delivery price
  1172. DeliveryText.changeText( "$" + DeliveryP );// show text
  1173.  
  1174. TotalP = RetailP + DeliveryP; // Calc total price
  1175. TotalText.changeText( "$" + TotalP );// show text
  1176.  
  1177. if( VColor_Button )
  1178. {
  1179. VColor_Button.disable();
  1180. VColor_Button.changeTexture( new ResourceRef( frontend:0x00AFr ) );
  1181. }
  1182. }
  1183.  
  1184. CompleteCar = 0;
  1185. }
  1186. else
  1187. if( cmd == CMD_VEHI )
  1188. {
  1189. if(CompleteCar == 0 && CurrentCar)
  1190. {
  1191. if( Config.carCatalogColor == 1 )
  1192. CurrentCar.chassis.addStockParts( new Descriptor( CurrentCar.chassis.getTexture(), 1, 1, 1, 1) );
  1193. else
  1194. CurrentCar.chassis.addStockParts( new Descriptor( DEFAULT_VEHICLE_COLOR, 1, 1, 1, 1) );
  1195. CurrentCar.chassis.command( "reset" );
  1196. CurrentCar.chassis.command( "setsteer -0.6" );
  1197.  
  1198. RetailP = CurrentCar.getTotalPrice()*PRICERATIO; // Clac retail price
  1199. RetailText.changeText( "$" + RetailP );// show text
  1200.  
  1201. DeliveryP = CurrentCar.chassis.getMass()*5.8; // Calc delivery price
  1202. DeliveryText.changeText( "$" + DeliveryP );// show text
  1203.  
  1204. TotalP = RetailP + DeliveryP; // Calc total price
  1205. TotalText.changeText( "$" + TotalP );// show text
  1206.  
  1207. if( VColor_Button )
  1208. {
  1209. VColor_Button.enable();
  1210. VColor_Button.changeTexture( new ResourceRef(CurrentCar.chassis.getTexture()) );
  1211. }
  1212. }
  1213. CompleteCar = 1;
  1214. }
  1215. else
  1216. if( cmd >= CMD_VEH0 && cmd <= CMD_VEH9 ) // All 10 buttons
  1217. {
  1218. if(cmd == CMD_VEH0) ButtonNum = 0;
  1219. if(cmd == CMD_VEH1) ButtonNum = 1;
  1220. if(cmd == CMD_VEH2) ButtonNum = 2;
  1221. if(cmd == CMD_VEH3) ButtonNum = 3;
  1222. if(cmd == CMD_VEH4) ButtonNum = 4;
  1223. if(cmd == CMD_VEH5) ButtonNum = 5;
  1224. if(cmd == CMD_VEH6) ButtonNum = 6;
  1225. if(cmd == CMD_VEH7) ButtonNum = 7;
  1226. if(cmd == CMD_VEH8) ButtonNum = 8;
  1227. if(cmd == CMD_VEH9) ButtonNum = 9;
  1228.  
  1229. if(CurrentCar) CurrentCar.destroy();
  1230. if(CurrentChassis) CurrentChassis.destroy();
  1231.  
  1232. CurrentCar = new Vehicle();
  1233. CurrentCar.chassis = new Chassis();
  1234. CurrentCar.chassis = create(CarScene, new GameRef(GameLogic.ChassisRoot[GameLogic.ChassisResNoumber[CurrentName+ButtonNum]]), "0,0,0,0,0,0,", "chassis");
  1235. CurrentCar = new Vehicle(CurrentCar.chassis);
  1236.  
  1237. Size = CurrentCar.chassis.getMin();
  1238.  
  1239. //Cam.setMatrix( new Vector3( -2, 1, -4), new Ypr( -2.7, -0.2, 0)); //car size fix, but I don't like it
  1240. Cam.command( "move " + CarScene.id() +" "+(Size.x*2.2)+","+(Size.y*2.2)+","+(Size.z*2.2)+" 1.0 0, -0.2, 0" );
  1241.  
  1242. //Cam.setMatrix( new Vector3(-(Max.x-Min.x+1), Max.y, -(Max.z-Min.z+1)), new Ypr(-2.358, -0.5, 0));
  1243. //float size = CurrentCar.chassis.getInfo(GameType.GII_SIZE)/100.0;
  1244.  
  1245. if(CompleteCar)
  1246. {
  1247. if( Config.carCatalogColor == 1 )
  1248. CurrentCar.chassis.addStockParts( new Descriptor( CurrentCar.chassis.getTexture(), 1, 1, 1, 1) );
  1249. else
  1250. CurrentCar.chassis.addStockParts( new Descriptor( DEFAULT_VEHICLE_COLOR, 1, 1, 1, 1) );
  1251. CurrentCar.chassis.command( "reset" );
  1252. CurrentCar.chassis.command( "setsteer -0.6" );
  1253.  
  1254. if( VColor_Button )
  1255. {
  1256. VColor_Button.enable();
  1257. VColor_Button.changeTexture( new ResourceRef(CurrentCar.chassis.getTexture()) );
  1258. }
  1259. }
  1260.  
  1261. CurrentCarName.changeText( CurrentCar.chassis.vehicleName );
  1262. if( CurrentCarDescription ) CurrentCarDescription.changeText( CurrentCar.chassis.description );
  1263.  
  1264. RetailP = CurrentCar.getTotalPrice()*PRICERATIO; // Clac retail price
  1265. RetailText.changeText( "$" + RetailP );// show text
  1266.  
  1267. DeliveryP = CurrentCar.chassis.getMass()*5.8; // Calc delivery price
  1268. DeliveryText.changeText( "$" + DeliveryP );// show text
  1269.  
  1270. TotalP = RetailP + DeliveryP; // Calc total price
  1271. TotalText.changeText( "$" + TotalP );// show text
  1272. }
  1273. else
  1274. if( cmd == CMD_UP )
  1275. {
  1276. if (CurrentPage > 0)
  1277. CurrentPage -= 1;
  1278.  
  1279. CurrentName = CurrentPage*10;
  1280. CurrentPageText.changeText( "Current Page: " + (CurrentPage+1) );
  1281.  
  1282. VehAmount = GameLogic.ChassisBox.size()-1;
  1283.  
  1284. DownButton.changeTexture( new ResourceRef( frontend:0x0084r ) ); // Arrow down
  1285. DownButton.enable();
  1286.  
  1287. if (CurrentPage == 0)
  1288. {
  1289. UpButton.changeTexture( new ResourceRef( frontend:0x00AFr ) ); // Empty.ptx
  1290. UpButton.disable();
  1291.  
  1292. if( VehAmount < 10 )
  1293. {
  1294. DownButton.changeTexture( new ResourceRef( frontend:0x00AFr ) ); // Empty.ptx
  1295. DownButton.disable();
  1296. }
  1297. }
  1298.  
  1299. if( CurrentName + 0 <= VehAmount ) { VehButton0.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+0].vehicleName); VehButton0.enable(); } else { VehButton0.changeLabelText( "" ); VehButton0.disable(); }
  1300. if( CurrentName + 1 <= VehAmount ) { VehButton1.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+1].vehicleName); VehButton1.enable(); } else { VehButton1.changeLabelText( "" ); VehButton1.disable(); }
  1301. if( CurrentName + 2 <= VehAmount ) { VehButton2.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+2].vehicleName); VehButton2.enable(); } else { VehButton2.changeLabelText( "" ); VehButton2.disable(); }
  1302. if( CurrentName + 3 <= VehAmount ) { VehButton3.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+3].vehicleName); VehButton3.enable(); } else { VehButton3.changeLabelText( "" ); VehButton3.disable(); }
  1303. if( CurrentName + 4 <= VehAmount ) { VehButton4.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+4].vehicleName); VehButton4.enable(); } else { VehButton4.changeLabelText( "" ); VehButton4.disable(); }
  1304. if( CurrentName + 5 <= VehAmount ) { VehButton5.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+5].vehicleName); VehButton5.enable(); } else { VehButton5.changeLabelText( "" ); VehButton5.disable(); }
  1305. if( CurrentName + 6 <= VehAmount ) { VehButton6.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+6].vehicleName); VehButton6.enable(); } else { VehButton6.changeLabelText( "" ); VehButton6.disable(); }
  1306. if( CurrentName + 7 <= VehAmount ) { VehButton7.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+7].vehicleName); VehButton7.enable(); } else { VehButton7.changeLabelText( "" ); VehButton7.disable(); }
  1307. if( CurrentName + 8 <= VehAmount ) { VehButton8.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+8].vehicleName); VehButton8.enable(); } else { VehButton8.changeLabelText( "" ); VehButton8.disable(); }
  1308. if( CurrentName + 9 <= VehAmount ) { VehButton9.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+9].vehicleName); VehButton9.enable(); } else { VehButton9.changeLabelText( "" ); VehButton9.disable(); }
  1309. }
  1310. else
  1311. if( cmd == CMD_DOWN )
  1312. {
  1313. if (GameLogic.ChassisRoot.length >= CurrentName+10)
  1314. CurrentPage += 1;
  1315.  
  1316. CurrentName = CurrentPage*10;
  1317.  
  1318. CurrentPageText.changeText( "Current Page: " + (CurrentPage+1) );
  1319.  
  1320. UpButton.changeTexture( new ResourceRef(frontend:0x004Cr) ); // Arrow up
  1321. UpButton.enable();
  1322.  
  1323. VehAmount = GameLogic.ChassisBox.size()-1;
  1324.  
  1325. if (VehAmount < CurrentName+10)
  1326. {
  1327. DownButton.changeTexture( new ResourceRef(frontend:0x00AFr) ); // Empty.ptx
  1328. DownButton.disable();
  1329. }
  1330.  
  1331. if( CurrentName + 0 <= VehAmount ) { VehButton0.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+0].vehicleName); VehButton0.enable(); } else { VehButton0.changeLabelText( "" ); VehButton0.disable(); }
  1332. if( CurrentName + 1 <= VehAmount ) { VehButton1.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+1].vehicleName); VehButton1.enable(); } else { VehButton1.changeLabelText( "" ); VehButton1.disable(); }
  1333. if( CurrentName + 2 <= VehAmount ) { VehButton2.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+2].vehicleName); VehButton2.enable(); } else { VehButton2.changeLabelText( "" ); VehButton2.disable(); }
  1334. if( CurrentName + 3 <= VehAmount ) { VehButton3.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+3].vehicleName); VehButton3.enable(); } else { VehButton3.changeLabelText( "" ); VehButton3.disable(); }
  1335. if( CurrentName + 4 <= VehAmount ) { VehButton4.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+4].vehicleName); VehButton4.enable(); } else { VehButton4.changeLabelText( "" ); VehButton4.disable(); }
  1336. if( CurrentName + 5 <= VehAmount ) { VehButton5.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+5].vehicleName); VehButton5.enable(); } else { VehButton5.changeLabelText( "" ); VehButton5.disable(); }
  1337. if( CurrentName + 6 <= VehAmount ) { VehButton6.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+6].vehicleName); VehButton6.enable(); } else { VehButton6.changeLabelText( "" ); VehButton6.disable(); }
  1338. if( CurrentName + 7 <= VehAmount ) { VehButton7.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+7].vehicleName); VehButton7.enable(); } else { VehButton7.changeLabelText( "" ); VehButton7.disable(); }
  1339. if( CurrentName + 8 <= VehAmount ) { VehButton8.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+8].vehicleName); VehButton8.enable(); } else { VehButton8.changeLabelText( "" ); VehButton8.disable(); }
  1340. if( CurrentName + 9 <= VehAmount ) { VehButton9.changeLabelText(GameLogic.ChassisBox.elementData[CurrentName+9].vehicleName); VehButton9.enable(); } else { VehButton9.changeLabelText( "" ); VehButton9.disable(); }
  1341. }
  1342. else
  1343. if( cmd==CMD_EXIT ) //main index pages
  1344. {
  1345. changeGroup( -1 );
  1346. GameLogic.changeActiveSection( GameLogic.garage );
  1347.  
  1348. if(CurrentCar) CurrentCar.destroy();
  1349. if(CurrentChassis) CurrentChassis.destroy();
  1350. }
  1351. else
  1352. if( cmd==CMD_FRONTPAGE )
  1353. {
  1354. changeGroup( mainGroup );
  1355.  
  1356. if(CurrentCar) CurrentCar.destroy();
  1357. if(CurrentChassis) CurrentChassis.destroy();
  1358. }
  1359. else
  1360. if( cmd==CMD_VEHICLE )
  1361. {
  1362. //pgNumberL=pageNumberL[0];
  1363. //pgNumberR=pageNumberR[0];
  1364. changeGroup( VehicleGroup );
  1365. VehicleScene();
  1366. }
  1367. else
  1368. if( cmd==CMD_MAIN1 )
  1369. {
  1370. pgNumberL=pageNumberL[0];
  1371. pgNumberR=pageNumberR[0];
  1372. changeGroup( main1Group );
  1373. }
  1374. else
  1375. if( cmd==CMD_MAIN2 )
  1376. {
  1377. pgNumberL=pageNumberL[1];
  1378. pgNumberR=pageNumberR[1];
  1379. changeGroup( main2Group );
  1380. }
  1381. else
  1382. if( cmd==CMD_MAIN3 )
  1383. {
  1384. pgNumberL=pageNumberL[2];
  1385. pgNumberR=pageNumberR[2];
  1386. changeGroup( main3Group );
  1387. }
  1388. else
  1389. if( cmd==CMD_MAIN3_5 )
  1390. {
  1391. pgNumberL=pageNumberL[3];
  1392. pgNumberR=pageNumberR[3];
  1393. changeGroup( main7Group );
  1394. }
  1395. else
  1396. if( cmd==CMD_MAIN3_6 )
  1397. {
  1398. pgNumberL=pageNumberL[7];
  1399. pgNumberR=pageNumberR[7];
  1400. changeGroup( main8Group );
  1401. }
  1402. else
  1403. if( cmd==CMD_MAIN4 )
  1404. {
  1405. pgNumberL=pageNumberL[4];
  1406. pgNumberR=pageNumberR[4];
  1407. changeGroup( main4Group );
  1408. }
  1409. else
  1410. if( cmd==CMD_MAIN5 )
  1411. {
  1412. pgNumberL=pageNumberL[5];
  1413. pgNumberR=pageNumberR[5];
  1414. changeGroup( main5Group );
  1415. }
  1416. else
  1417. if( cmd==CMD_MAIN6 )
  1418. {
  1419. pgNumberL=pageNumberL[6];
  1420. pgNumberR=pageNumberR[6];
  1421. changeGroup( main6Group );
  1422. }
  1423. else
  1424. if( cmd>=CMD_DB0 && cmd<=CMD_DB7 ) //decal buttons
  1425. {
  1426. decalButtonPressed( cmd - CMD_DB0 );
  1427. }
  1428. else
  1429. if( cmd>=CMD_MAIN6_1 && cmd<=CMD_MAIN6_7 ) //decal subsections
  1430. {
  1431. String decalsDir;
  1432. if( cmd == CMD_MAIN6_1 )
  1433. {
  1434. pageNumberPrefix="D-I/";
  1435. decalsDir = "manufacturers";
  1436. }
  1437. else
  1438. if( cmd == CMD_MAIN6_2 )
  1439. {
  1440. pageNumberPrefix="D-II/";
  1441. decalsDir = "logos";
  1442. }
  1443. else
  1444. if( cmd == CMD_MAIN6_3 )
  1445. {
  1446. pageNumberPrefix="D-III/";
  1447. decalsDir = "numbers";
  1448. }
  1449. else
  1450. if( cmd == CMD_MAIN6_4 )
  1451. {
  1452. pageNumberPrefix="D-IV/";
  1453. decalsDir = "digits";
  1454. }
  1455. else
  1456. if( cmd == CMD_MAIN6_5 )
  1457. {
  1458. pageNumberPrefix="D-V/";
  1459. decalsDir = "smilies";
  1460. }
  1461. else
  1462. if( cmd == CMD_MAIN6_6 )
  1463. {
  1464. pageNumberPrefix="D-VI/";
  1465. decalsDir = "animals";
  1466. }
  1467. else
  1468. if( cmd == CMD_MAIN6_7 )
  1469. {
  1470. pageNumberPrefix="D-VII/";
  1471. decalsDir = "misc";
  1472. }
  1473.  
  1474. decals = collectDecals( decalsDir );
  1475.  
  1476. curpage=1;
  1477. showDecals=0;
  1478.  
  1479. setDecalButtons();
  1480. refreshPage();
  1481. changeGroup( decalsGroup );
  1482. }
  1483. else
  1484. if( cmd == CMD_PREVDECALPAGE ) //page control
  1485. {
  1486. if( showDecals >= decalButtons.length )
  1487. {
  1488. showDecals-=decalButtons.length;
  1489. setDecalButtons();
  1490.  
  1491. curpage-=2;
  1492. refreshPage();
  1493. }
  1494. }
  1495. else
  1496. if( cmd == CMD_NEXTDECALPAGE )
  1497. {
  1498. int max = decals.size();
  1499. if( showDecals+decalButtons.length < max )
  1500. {
  1501. showDecals+=decalButtons.length;
  1502. setDecalButtons();
  1503.  
  1504. curpage+=2;
  1505. refreshPage();
  1506. }
  1507. }
  1508. else
  1509. if( cmd == CMD_PREVPARTPAGE )
  1510. {
  1511. if( inventory.upScroll() )
  1512. {
  1513. curpage-=2;
  1514. refreshPage();
  1515. }
  1516. }
  1517. else
  1518. if( cmd == CMD_NEXTPARTPAGE )
  1519. {
  1520. //biztositsuk, hogy a kov oldal is tele van (az init csak a legelsot tolti fel rendesen!)
  1521. //ha az user cselez, atugrik masik sectionbe, aztan visszalapoz, megszivja!
  1522. collectObjectsStep( 8 );
  1523.  
  1524. if( inventory.downScroll() )
  1525. {
  1526. curpage+=2;
  1527. refreshPage();
  1528. }
  1529. }
  1530. else // Collector filters:
  1531. if( cmd == NO_FILTER )
  1532. {
  1533. inventory.items.addElement( new InventoryItem_Part( inventory, parts.id() ) );
  1534. step--;
  1535. }
  1536. else
  1537. if( cmd == RIMS_FILTER )
  1538. {
  1539. Wheel rim = new Wheel();
  1540. rim = create( null, new GameRef(parts), "0,0,0,0,0,0,", "temp rim");
  1541.  
  1542. if( rimSize <= 13 ) // Smaller rims
  1543. {
  1544. if( rim.getRadius() <= 13 )
  1545. {
  1546. inventory.items.addElement( new InventoryItem_Part( inventory, parts.id() ) );
  1547. step--;
  1548. }
  1549. }
  1550. else
  1551. if( rimSize >= 22 ) // Bigger rims
  1552. {
  1553. if( rim.getRadius() >= 22 )
  1554. {
  1555. inventory.items.addElement( new InventoryItem_Part( inventory, parts.id() ) );
  1556. step--;
  1557. }
  1558. }
  1559. else // 14"-21"
  1560. {
  1561. if( rim.getRadius() >= rimSize && rim.getRadius() < rimSize+1 )
  1562. {
  1563. inventory.items.addElement( new InventoryItem_Part( inventory, parts.id() ) );
  1564. step--;
  1565. }
  1566. }
  1567. }
  1568. else
  1569. if( cmd == TYRES_FILTER )
  1570. {
  1571. Tyre rubber = new Tyre();
  1572. rubber = create( null, new GameRef(parts), "0,0,0,0,0,0,", "temp rubber");
  1573.  
  1574. float rimDiameter = rubber.wheel_radius*2/25.4;
  1575.  
  1576. if( tyreSize <= 13 ) // Smaller tyres
  1577. {
  1578. if( rimDiameter <= 13 )
  1579. {
  1580. inventory.items.addElement( new InventoryItem_Part( inventory, parts.id() ) );
  1581. step--;
  1582. }
  1583. }
  1584. else
  1585. if( tyreSize >= 22 ) // Bigger tyres
  1586. {
  1587. if( rimDiameter >= 22 )
  1588. {
  1589. inventory.items.addElement( new InventoryItem_Part( inventory, parts.id() ) );
  1590. step--;
  1591. }
  1592. }
  1593. else // 14"-21"
  1594. {
  1595. if( rimDiameter >= tyreSize && rimDiameter < tyreSize+1 )
  1596. {
  1597. inventory.items.addElement( new InventoryItem_Part( inventory, parts.id() ) );
  1598. step--;
  1599. }
  1600. }
  1601. }
  1602. else // Parts collector buttons:
  1603. if( cmd >= CMD_MAIN1_1 && cmd < CMD_MAIN6_1 ) // all parts pages buttons
  1604. {
  1605. collectObjectsBegin();
  1606.  
  1607. if( cmd >= CMD_MAIN1_1 && cmd < CMD_MAIN2_1 ) // all engine part page
  1608. {
  1609. changeGroup( parts1Group );
  1610.  
  1611. if( cmd == CMD_MAIN1_1 ) //engine subsections
  1612. {
  1613. pageNumberPrefix="E-I/";
  1614. collectObjects( new GameRef(parts:0x025Cr), new GameRef(parts:0xA05Cr) ); // Engine Blocks
  1615. collectObjects( new GameRef(parts:0xAB5Cr), new GameRef(parts:0xAA5Cr), new GameRef(parts:0xAD5Cr) ); // 2.3.0 LE
  1616. collectObjects( new GameRef(parts:0xAC5Cr), new GameRef(parts:0xAE5Cr), new GameRef(parts:0xAF5Cr) ); // 2.3.0 LE
  1617. filter = NO_FILTER;
  1618. }
  1619. else
  1620. if( cmd == CMD_MAIN1_2 )
  1621. {
  1622. pageNumberPrefix="E-II/";
  1623. collectObjects( new GameRef(parts:0x025Er), new GameRef(parts:0xA05Er) ); // Crankshafts & Bearning
  1624. collectObjects( new GameRef(parts:0xAA5Er), new GameRef(parts:0xAB5Er), new GameRef(parts:0xAD5Er) ); // 2.3.0 LE
  1625. collectObjects( new GameRef(parts:0xAC5Er), new GameRef(parts:0xAE5Er), new GameRef(parts:0xAF5Er) ); // 2.3.0 LE
  1626. filter = NO_FILTER;
  1627. }
  1628. else
  1629. if( cmd == CMD_MAIN1_3 )
  1630. {
  1631. pageNumberPrefix="E-III/";
  1632. collectObjects( new GameRef(parts:0x00B7r), new GameRef(parts:0x0B7Er) ); // Connecting Rods
  1633. collectObjects( new GameRef(parts:0xAB7Er), new GameRef(parts:0xBB7Er), new GameRef(parts:0xDB7Er) ); // 2.3.0 LE
  1634. collectObjects( new GameRef(parts:0xCB7Er), new GameRef(parts:0xEB7Er), new GameRef(parts:0xFB7Er) ); // 2.3.0 LE
  1635. filter = NO_FILTER;
  1636. }
  1637. else
  1638. if( cmd == CMD_MAIN1_4 )
  1639. {
  1640. pageNumberPrefix="E-IV/";
  1641. collectObjects( new GameRef(parts:0x00B6r) ); // Pistons
  1642. collectObjects( new GameRef(parts:0x0AB6r), new GameRef(parts:0x0BB6r), new GameRef(parts:0x0DB6r) ); // 2.3.0 LE
  1643. collectObjects( new GameRef(parts:0x0CB6r), new GameRef(parts:0x0EB6r), new GameRef(parts:0x0FB6r) ); // 2.3.0 LE
  1644. filter = NO_FILTER;
  1645. }
  1646. else
  1647. if( cmd == CMD_MAIN1_5 )
  1648. {
  1649. pageNumberPrefix="E-V/";
  1650. collectObjects( new GameRef(parts:0x0252r) ); // Oil Pans
  1651. filter = NO_FILTER;
  1652. }
  1653. else
  1654. if( cmd == CMD_MAIN1_6 )
  1655. {
  1656. pageNumberPrefix="E-VI/";
  1657. collectObjects( new GameRef(parts:0x025Dr) ); // Cylinder Heads
  1658. collectObjects( new GameRef(parts:0xA25Dr), new GameRef(parts:0xB25Dr), new GameRef(parts:0xD25Dr) ); // 2.3.0 LE
  1659. collectObjects( new GameRef(parts:0xC25Dr), new GameRef(parts:0xE25Dr), new GameRef(parts:0xF25Dr) ); // 2.3.0 LE
  1660. filter = NO_FILTER;
  1661. }
  1662. else
  1663. if( cmd == CMD_MAIN1_7 )
  1664. {
  1665. pageNumberPrefix="E-VII/";
  1666. collectObjects( new GameRef(parts:0x025Fr) ); // Intake & Exhaust Camshafts
  1667. collectObjects( new GameRef(parts:0xA25Fr), new GameRef(parts:0xB25Fr), new GameRef(parts:0xD25Fr) ); // 2.3.0 LE
  1668. collectObjects( new GameRef(parts:0xC25Fr), new GameRef(parts:0xE25Fr), new GameRef(parts:0xF25Fr) ); // 2.3.0 LE
  1669. filter = NO_FILTER;
  1670. }
  1671. else
  1672. if( cmd == CMD_MAIN1_8 )
  1673. {
  1674. pageNumberPrefix="E-VIII/";
  1675. collectObjects( new GameRef(parts:0x0255r), new GameRef(parts:0x026Fr) ); // Air Delivery
  1676. collectObjects( new GameRef(parts:0xA26Fr), new GameRef(parts:0xB26Fr), new GameRef(parts:0xD26Fr) ); // 2.3.0 LE
  1677. collectObjects( new GameRef(parts:0xC26Fr), new GameRef(parts:0xE26Fr), new GameRef(parts:0xF26Fr) ); // 2.3.0 LE
  1678. filter = NO_FILTER;
  1679. }
  1680. else
  1681. if( cmd == CMD_MAIN1_9 )
  1682. {
  1683. pageNumberPrefix="E-IX/";
  1684. collectObjects( new GameRef(parts:0x026Br), new GameRef(parts:0x026Er) ); // Fuel Delivery
  1685. collectObjects( new GameRef(parts:0xA26Br), new GameRef(parts:0xB26Br), new GameRef(parts:0xD26Br) ); // 2.3.0 LE
  1686. collectObjects( new GameRef(parts:0xC26Br), new GameRef(parts:0xE26Br), new GameRef(parts:0xF26Br) ); // 2.3.0 LE
  1687. filter = NO_FILTER;
  1688. }
  1689. if( cmd == CMD_MAIN1_10 )
  1690. {
  1691. pageNumberPrefix="E-X/";
  1692. collectObjects( new GameRef(parts:0x0249r), new GameRef(parts:0x023Cr) ); // Clutchs & Flywheels
  1693. collectObjects( new GameRef(parts:0xA23Cr), new GameRef(parts:0xB23Cr), new GameRef(parts:0xD23Cr) ); // 2.3.0 LE
  1694. collectObjects( new GameRef(parts:0xC23Cr), new GameRef(parts:0xE23Cr)/*, new GameRef(parts:0xF23Cr)*/ ); // 2.3.0 LE
  1695. filter = NO_FILTER;
  1696. }
  1697. if( cmd == CMD_MAIN1_11 )
  1698. {
  1699. pageNumberPrefix="E-XI/";
  1700. collectObjects( new GameRef(parts:0x024Ar), new GameRef(parts:0x023Br)/*, new GameRef(parts:0x024Br)*/ ); // Transmission & Drivetrain
  1701. collectObjects( new GameRef(parts:0xA24Br), new GameRef(parts:0xB24Br), new GameRef(parts:0xD24Br) ); // 2.3.0 LE
  1702. collectObjects( new GameRef(parts:0xC24Br), new GameRef(parts:0xE24Br), new GameRef(parts:0xF24Br) ); // 2.3.0 LE
  1703. filter = NO_FILTER;
  1704. }
  1705. if( cmd == CMD_MAIN1_12 )
  1706. {
  1707. pageNumberPrefix="E-XII/";
  1708. collectObjects( new GameRef(parts:0x0282r) ); // Exhaust System
  1709. collectObjects( new GameRef(parts:0xA282r), new GameRef(parts:0xB282r), new GameRef(parts:0xD282r) ); // 2.3.0 LE
  1710. collectObjects( new GameRef(parts:0xC282r), new GameRef(parts:0xE282r), new GameRef(parts:0xF282r) ); // 2.3.0 LE
  1711. filter = NO_FILTER;
  1712. }
  1713. if( cmd == CMD_MAIN1_20 )
  1714. {
  1715. pageNumberPrefix="E-XIII/";
  1716. collectObjects( new GameRef(parts:0x0250r) ); // Exhaust Pipes
  1717. filter = NO_FILTER;
  1718. }
  1719. if( cmd == CMD_MAIN1_13 )
  1720. {
  1721. pageNumberPrefix="E-XIV/";
  1722. collectObjects( new GameRef(parts:0x00C9r) ); // Exhaust Tips
  1723. filter = NO_FILTER;
  1724. }
  1725. if( cmd == CMD_MAIN1_14 )
  1726. {
  1727. pageNumberPrefix="E-XIIV/";
  1728. collectObjects( new GameRef(parts:0x00BEr) ); // Drive Belts
  1729. collectObjects( new GameRef(parts:0x0ABEr), new GameRef(parts:0x0BBEr), new GameRef(parts:0x0DBEr) ); // 2.3.0 LE
  1730. collectObjects( new GameRef(parts:0x0CBEr), new GameRef(parts:0x0EBEr), new GameRef(parts:0x0FBEr) ); // 2.3.0 LE
  1731. filter = NO_FILTER;
  1732. }
  1733. if( cmd == CMD_MAIN1_15 )
  1734. {
  1735. pageNumberPrefix="E-XV/";
  1736. collectObjects( new GameRef(parts:0x0012r) ); // Accesories & Others
  1737. filter = NO_FILTER;
  1738. }
  1739. if( cmd == CMD_MAIN1_16 )
  1740. {
  1741. pageNumberPrefix="E-XVI/";
  1742. collectObjects( new GameRef(parts:0x0010r) ); // Batteries
  1743. filter = NO_FILTER;
  1744. }
  1745. if( cmd == CMD_MAIN1_17 )
  1746. {
  1747. pageNumberPrefix="E-XVII/";
  1748. collectObjects( new GameRef(parts:0x00BDr), new GameRef(parts:0x0281r), new GameRef(parts:0x0279r) ); // Charging System
  1749. filter = NO_FILTER;
  1750. }
  1751. if( cmd == CMD_MAIN1_18 )
  1752. {
  1753. pageNumberPrefix="E-XVIII/";
  1754. collectObjects( new GameRef(parts:0xF27Dr), new GameRef(parts:0x0117r), /*new GameRef(parts:0x00B4r),*/ new GameRef(parts:0x0277r) ); // Pro tunning
  1755. collectObjects( new GameRef(parts:0x0AB4r), new GameRef(parts:0x0BB4r), new GameRef(parts:0x0DB4r) ); // 2.3.0 LE
  1756. collectObjects( new GameRef(parts:0x0CB4r), new GameRef(parts:0x0EB4r), new GameRef(parts:0x0FB4r) ); // 2.3.0 LE
  1757. filter = NO_FILTER;
  1758. }
  1759. if( cmd == CMD_MAIN1_19 )
  1760. {
  1761. pageNumberPrefix="E-XIX/";
  1762. collectObjects( new GameRef(parts:0xF23Cr) ); // Engine Kits
  1763. filter = NO_FILTER;
  1764. }
  1765. }
  1766. else
  1767. if( cmd >= CMD_MAIN2_1 && cmd < CMD_MAIN3_1 ) // body subs
  1768. {
  1769. changeGroup( parts2Group );
  1770. if( cmd == CMD_MAIN2_1 )
  1771. {
  1772. pageNumberPrefix="B-I/";
  1773. collectObjects( new GameRef(parts:0xF242r) ); // Body Panels
  1774. filter = NO_FILTER;
  1775. }
  1776. else
  1777. if( cmd == CMD_MAIN2_2 )
  1778. {
  1779. pageNumberPrefix="B-II/";
  1780. collectObjects( new GameRef(parts:0xF24Fr) ); // Replacement Parts
  1781. filter = NO_FILTER;
  1782. }
  1783. else
  1784. if( cmd == CMD_MAIN2_3 )
  1785. {
  1786. pageNumberPrefix="B-III/";
  1787. collectObjects( new GameRef(parts:0xF24Cr) ); // Lights & Windows
  1788. filter = NO_FILTER;
  1789. }
  1790. else
  1791. if( cmd == CMD_MAIN2_4 )
  1792. {
  1793. pageNumberPrefix="B-IV/";
  1794. collectObjects( new GameRef(parts:0xF266r) ); // Neon Lights
  1795. filter = NO_FILTER;
  1796. }
  1797. else
  1798. if( cmd == CMD_MAIN2_5 )
  1799. {
  1800. pageNumberPrefix="B-V/";
  1801. collectObjects( new GameRef(parts:0xF233r) ); // Areodynamic Tunning
  1802. filter = NO_FILTER;
  1803. }
  1804. else
  1805. if( cmd == CMD_MAIN2_6 )
  1806. {
  1807. pageNumberPrefix="B-VI/";
  1808. collectObjects( new GameRef(parts:0xF228r) ); // Others
  1809. filter = NO_FILTER;
  1810. }
  1811. else
  1812. if( cmd == CMD_MAIN2_7 )
  1813. {
  1814. pageNumberPrefix="B-VII/";
  1815. collectObjects( new GameRef(parts:0xF23Br) ); // Body Kits
  1816. filter = NO_FILTER;
  1817. }
  1818. }
  1819. else
  1820. if( cmd >= CMD_MAIN3_1 && cmd < CMD_MAIN4_1 ) // running gear
  1821. {
  1822. changeGroup( parts3Group );
  1823.  
  1824. if( cmd >= CMD_MAIN3_5_1 && cmd <= CMD_MAIN3_5_10 ) // all rims buttons
  1825. {
  1826. changeGroup( parts7Group );
  1827.  
  1828. collectObjectsBegin();
  1829. collectObjects( new GameRef(parts:0xF235r), new GameRef(parts:0xF23Dr) );
  1830. filter = RIMS_FILTER;
  1831.  
  1832. // Info for RIMS_FILTER
  1833. if( cmd == CMD_MAIN3_5_1 ) rimSize = 13; // Smaller than 14"
  1834. if( cmd == CMD_MAIN3_5_2 ) rimSize = 14;
  1835. if( cmd == CMD_MAIN3_5_3 ) rimSize = 15;
  1836. if( cmd == CMD_MAIN3_5_4 ) rimSize = 16;
  1837. if( cmd == CMD_MAIN3_5_5 ) rimSize = 17;
  1838. if( cmd == CMD_MAIN3_5_6 ) rimSize = 18;
  1839. if( cmd == CMD_MAIN3_5_7 ) rimSize = 19;
  1840. if( cmd == CMD_MAIN3_5_8 ) rimSize = 20;
  1841. if( cmd == CMD_MAIN3_5_9 ) rimSize = 21;
  1842. if( cmd == CMD_MAIN3_5_10) rimSize = 22; // Bigger than 21"
  1843.  
  1844. pageNumberPrefix="R-XIII-"+rimSize+"/";
  1845. }
  1846. else
  1847. if( cmd >= CMD_MAIN3_6_1 && cmd <= CMD_MAIN3_6_10 ) //all Tyres buttons
  1848. {
  1849. changeGroup( parts8Group );
  1850.  
  1851. collectObjectsBegin();
  1852. collectObjects( new GameRef(parts:0xF23Er) );
  1853. filter = TYRES_FILTER;
  1854.  
  1855. // Info for TYRES_FILTER
  1856. if( cmd == CMD_MAIN3_6_1 ) tyreSize = 13; // Smaller than 14"
  1857. if( cmd == CMD_MAIN3_6_2 ) tyreSize = 14;
  1858. if( cmd == CMD_MAIN3_6_3 ) tyreSize = 15;
  1859. if( cmd == CMD_MAIN3_6_4 ) tyreSize = 16;
  1860. if( cmd == CMD_MAIN3_6_5 ) tyreSize = 17;
  1861. if( cmd == CMD_MAIN3_6_6 ) tyreSize = 18;
  1862. if( cmd == CMD_MAIN3_6_7 ) tyreSize = 19;
  1863. if( cmd == CMD_MAIN3_6_8 ) tyreSize = 20;
  1864. if( cmd == CMD_MAIN3_6_9 ) tyreSize = 21;
  1865. if( cmd == CMD_MAIN3_6_10) tyreSize = 22; // Bigger than 21"
  1866.  
  1867. pageNumberPrefix="R-XIV-"+tyreSize+"/";
  1868. }
  1869. else // running gear subsections
  1870. if( cmd == CMD_MAIN3_1 )
  1871. {
  1872. pageNumberPrefix="R-VIII/";
  1873. collectObjects( new GameRef(parts:0xF229r) ); // Suspension
  1874. filter = NO_FILTER;
  1875. }
  1876. else
  1877. if( cmd == CMD_MAIN3_2 )
  1878. {
  1879. pageNumberPrefix="R-IX/";
  1880. collectObjects( new GameRef(parts:0x001Cr)/*, new GameRef(parts:0xF22Br)*/ ); // Shock Absorbers
  1881. filter = NO_FILTER;
  1882. }
  1883. else
  1884. if( cmd == CMD_MAIN3_3 )
  1885. {
  1886. pageNumberPrefix="R-X/";
  1887. collectObjects( new GameRef(parts:0xF22Ar) ); // Springs
  1888. filter = NO_FILTER;
  1889. }
  1890. else
  1891. if( cmd == CMD_MAIN3_4 )
  1892. {
  1893. pageNumberPrefix="R-XI/";
  1894. collectObjects( new GameRef(parts:0xF22Dr) ); // Brakes
  1895. filter = NO_FILTER;
  1896. }
  1897. else
  1898. if( cmd == CMD_MAIN3_7 )
  1899. {
  1900. pageNumberPrefix="R-XII/";
  1901. collectObjects( new GameRef(parts:0x021Fr) ); // Sway Bars
  1902. filter = NO_FILTER;
  1903. }
  1904. else
  1905. if( cmd == CMD_MAIN3_8 )
  1906. {
  1907. pageNumberPrefix="R-VI/";
  1908. collectObjects( new GameRef(parts:0xD120r), new GameRef(parts:0xD121r) ); // Others
  1909. filter = NO_FILTER;
  1910. }
  1911. else
  1912. if( cmd == CMD_MAIN3_9 )
  1913. {
  1914. pageNumberPrefix="R-VII/";
  1915. collectObjects( new GameRef(parts:0xF249r) ); // RG kits
  1916. filter = NO_FILTER;
  1917. }
  1918. else
  1919. if( cmd == CMD_MAIN3_10 )
  1920. {
  1921. pageNumberPrefix="R-I/";
  1922. collectObjects( new GameRef(parts:0x0329r) ); // Factory Suspension
  1923. filter = NO_FILTER;
  1924. }
  1925. else
  1926. if( cmd == CMD_MAIN3_11 )
  1927. {
  1928. pageNumberPrefix="R-II/";
  1929. collectObjects( new GameRef(parts:0x031Cr) ); // Factory Shock Absorbers
  1930. filter = NO_FILTER;
  1931. }
  1932. else
  1933. if( cmd == CMD_MAIN3_12 )
  1934. {
  1935. pageNumberPrefix="R-III/";
  1936. collectObjects( new GameRef(parts:0x032Ar) ); // Factory Springs
  1937. filter = NO_FILTER;
  1938. }
  1939. else
  1940. if( cmd == CMD_MAIN3_13 )
  1941. {
  1942. pageNumberPrefix="R-IV/";
  1943. collectObjects( new GameRef(parts:0x032Dr) ); // Factory Brakes
  1944. filter = NO_FILTER;
  1945. }
  1946. else
  1947. if( cmd == CMD_MAIN3_14 )
  1948. {
  1949. pageNumberPrefix="R-V/";
  1950. collectObjects( new GameRef(parts:0x031Fr) ); // Factory Sway Bars
  1951. filter = NO_FILTER;
  1952. }
  1953. else
  1954. if( cmd == CMD_MAIN3_15 )
  1955. {
  1956. pageNumberPrefix="R-XV/";
  1957. //collectObjects( new GameRef(parts:0x0000r) ); // UR Text Here
  1958. filter = NO_FILTER;
  1959. }
  1960. }
  1961. else
  1962. if( cmd >= CMD_MAIN4_1 && cmd < CMD_MAIN5_1 ) // interior subsection
  1963. {
  1964. changeGroup( parts4Group );
  1965.  
  1966. if( cmd == CMD_MAIN4_1 )
  1967. {
  1968. pageNumberPrefix="I-I/";
  1969. collectObjects( new GameRef(parts:0xF243r) ); //steerwheels
  1970. filter = NO_FILTER;
  1971. }
  1972. else
  1973. if( cmd == CMD_MAIN4_2 )
  1974. {
  1975. pageNumberPrefix="I-II/";
  1976. collectObjects( new GameRef(parts:0xF245r) ); //dashes
  1977. filter = NO_FILTER;
  1978. }
  1979. else
  1980. if( cmd == CMD_MAIN4_3 )
  1981. {
  1982. pageNumberPrefix="I-III/";
  1983. collectObjects( new GameRef(parts:0xF23fr) ); //gearknobs
  1984. filter = NO_FILTER;
  1985. }
  1986. else
  1987. if( cmd == CMD_MAIN4_4 )
  1988. {
  1989. pageNumberPrefix="I-IV/";
  1990. collectObjects( new GameRef(parts:0xF241r) ); //pedals
  1991. filter = NO_FILTER;
  1992. }
  1993. else
  1994. if( cmd == CMD_MAIN4_5 )
  1995. {
  1996. pageNumberPrefix="I-V/";
  1997. collectObjects( new GameRef(parts:0xF244r) ); //gauges
  1998. filter = NO_FILTER;
  1999. }
  2000. else
  2001. if( cmd == CMD_MAIN4_6 )
  2002. {
  2003. pageNumberPrefix="I-VI/";
  2004. collectObjects( new GameRef(parts:0xF246r) ); //seats
  2005. filter = NO_FILTER;
  2006. }
  2007. else
  2008. if( cmd == CMD_MAIN4_7 )
  2009. {
  2010. pageNumberPrefix="I-VII/";
  2011. collectObjects( new GameRef(parts:0xF247r) ); //rollbars
  2012. filter = NO_FILTER;
  2013. }
  2014. else
  2015. if( cmd == CMD_MAIN4_8 )
  2016. {
  2017. pageNumberPrefix="I-VIII/";
  2018. collectObjects( new GameRef(parts:0xF248r) ); //decoration
  2019. filter = NO_FILTER;
  2020. }
  2021. }
  2022. else
  2023. if( cmd >= CMD_MAIN5_1 && cmd < CMD_MAIN6_1 ) // audio subsection
  2024. {
  2025. changeGroup( parts5Group );
  2026. if( cmd == CMD_MAIN5_1 )
  2027. {
  2028. pageNumberPrefix="A-I/";
  2029. collectObjects( new GameRef(parts:0xF240r) ); //head units
  2030. filter = NO_FILTER;
  2031. }
  2032. else
  2033. if( cmd == CMD_MAIN5_2 )
  2034. {
  2035. pageNumberPrefix="A-II/";
  2036. collectObjects( new GameRef(parts:0x0246r) ); // Amplifiers
  2037. filter = NO_FILTER;
  2038. }
  2039. else
  2040. if( cmd == CMD_MAIN5_3 )
  2041. {
  2042. pageNumberPrefix="A-III/";
  2043. collectObjects( new GameRef(parts:0x0247r) ); // Boxes
  2044. filter = NO_FILTER;
  2045. }
  2046. else
  2047. if( cmd == CMD_MAIN5_4 )
  2048. {
  2049. pageNumberPrefix="A-IV/";
  2050. collectObjects( new GameRef(parts:0x0248r) ); // Subwoofers
  2051. filter = NO_FILTER;
  2052. }
  2053. else
  2054. if( cmd == CMD_MAIN5_5 )
  2055. {
  2056. pageNumberPrefix="A-V/";
  2057. collectObjects( new GameRef(parts:0x024Br) ); // Accesories
  2058. filter = NO_FILTER;
  2059. }
  2060. else
  2061. if( cmd == CMD_MAIN5_6 )
  2062. {
  2063. pageNumberPrefix="A-VI/";
  2064. collectObjects( new GameRef(parts:0x025Br) ); // Audio Kits
  2065. filter = NO_FILTER;
  2066. }
  2067. }
  2068.  
  2069. collectObjectsEnd();
  2070. refreshPage();
  2071. }
  2072. }
  2073. }
  2074.  
  2075. //----------------------------------------------------------------------------------------------
  2076. //----------------------------------------------------------------------------------------------
  2077. //----------------------------------------------------------------------------------------------
  2078.  
  2079. public class CatalogInventory extends VisualInventory
  2080. {
  2081. Osd osd; //for da namez
  2082. TextBox[] names;
  2083.  
  2084. Catalog catalog;
  2085.  
  2086. public CatalogInventory( Catalog cat, Player player, float left, float top, float width, float height )
  2087. {
  2088. super(player, left, top, width, height );
  2089. catalog=cat;
  2090. }
  2091.  
  2092. public void initVisuals( float left, float top, float width, float height )
  2093. {
  2094. linesPerPage=2;
  2095. partsPerLine=4;
  2096.  
  2097. //mely itemek lehetnek lathatoak kezdetben?
  2098. cline=0;
  2099. start = cline * partsPerLine;
  2100. stop = start + linesPerPage * partsPerLine;
  2101.  
  2102. //0..1 viewport coordinatarendszerben!
  2103. float itemWidth=0.20, itemHeight=0.15;
  2104. float hSpacing = (width-itemWidth*partsPerLine)/partsPerLine;
  2105. float vSpacing = (height-itemHeight*linesPerPage)/(linesPerPage-1);
  2106.  
  2107. //backObject = new RenderRef( misc.catalog:0x00000020r );
  2108. panels=new InventoryPanel[partsPerLine*linesPerPage];
  2109. names=new TextBox[panels.length];
  2110.  
  2111. //eggyel magasabb pri vp kell, mint maga a katalogus, kulonben eltunnek a szovegek!
  2112. osd = new Osd( 1.0, 0.0, 11 );
  2113. osd.iLevel = Osd.IL_NONE;
  2114.  
  2115. int index;
  2116. float cheight=top;
  2117. for( int i=0; i<linesPerPage; i++ )
  2118. {
  2119. float cwidth=left;
  2120. for( int j=0; j<partsPerLine; j++ )
  2121. {
  2122. if( j == partsPerLine/2 )
  2123. cwidth+=hSpacing;
  2124.  
  2125. index = i*partsPerLine+j;
  2126. panels[index]=new CatalogInventoryPanel( this, index, cwidth, cheight, itemWidth, itemHeight, player );
  2127. names[index]=osd.createTextBox( null, Frontend.smallFont, Text.ALIGN_CENTER, (cwidth)*2-1, ((cheight+itemHeight)*2)-1, itemWidth*2 );
  2128. //kicsit patch, sajnos a fontnak nics olyan propertyje, hogy multicolor-e!
  2129. if( Frontend.smallFont.id() == Text.RID_CONSOLE10 || Frontend.smallFont.id() == Text.RID_CONSOLE5 )
  2130. names[index].changeColor( 0xFF000000 );
  2131.  
  2132. cwidth+=itemWidth+hSpacing;
  2133. }
  2134. cheight+=itemHeight+vSpacing;
  2135. }
  2136. }
  2137.  
  2138. public int upScroll()
  2139. {
  2140. if( cline )
  2141. {
  2142. cline-=linesPerPage;
  2143. update();
  2144. return 1;
  2145. }
  2146. return 0;
  2147. }
  2148.  
  2149. public int downScroll()
  2150. {
  2151. if( cline+linesPerPage < pages()*linesPerPage )
  2152. {
  2153. cline+=linesPerPage;
  2154. update();
  2155. return 1;
  2156. }
  2157. return 0;
  2158. }
  2159.  
  2160. //number of twin pages in a catalog section
  2161. public int pages()
  2162. {
  2163. if( items.size() > 1)
  2164. return (items.size()-1)/(partsPerLine*linesPerPage)+1;
  2165.  
  2166. return 1;
  2167. }
  2168.  
  2169. public void panelLeftClick( int index )
  2170. {
  2171. index += currentLine()*partsPerLine;
  2172.  
  2173. if( index<items.size() )
  2174. {
  2175. InventoryItem item = items.elementAt( index );
  2176.  
  2177. int price = item.getPrice() * Catalog.PRICERATIO;
  2178. if( price <= player.money )
  2179. {
  2180. Dialog d = new BuyCatalogItemDialog( player.controller, Dialog.DF_MODAL|Dialog.DF_DEFAULTBG|Dialog.DF_WIDE, item, price );
  2181.  
  2182. if( d.display() == 0 )
  2183. {
  2184. player.money-= price;
  2185. item.copyToInventory( player.parts );
  2186. catalog.refreshMoneyString();
  2187. //kap egy bonus matricat is, ha spec alkatresz:
  2188. int decalID = item.getLogo();
  2189. if( decalID )
  2190. {
  2191. player.decals.addElement( new Decal( decalID ) );
  2192. }
  2193. }
  2194. }
  2195. else
  2196. {
  2197. new WarningDialog( player.controller, Dialog.DF_MODAL|Dialog.DF_DEFAULTBG, "NOT ENOUGHT MONEY", "You don't have enought money to buy this part!" ).display();
  2198. }
  2199. }
  2200. }
  2201.  
  2202. public void update()
  2203. {
  2204. //hol kapcsolodnak ki a buttonok?
  2205. int begin = start;
  2206. int end = stop;
  2207.  
  2208. //mibol lesznek buttonok?
  2209. start = cline * partsPerLine;
  2210. stop = start + linesPerPage * partsPerLine;
  2211.  
  2212. int i, vis;
  2213.  
  2214. //clear changed ones
  2215. vis=0;
  2216. for( i=begin; i<end; i++ )
  2217. {
  2218. names[vis++].changeText( null );
  2219. }
  2220.  
  2221. //add new ones
  2222. vis=0;
  2223. for( i=start; i<stop; i++ )
  2224. {
  2225. if( i<items.size() )
  2226. {
  2227. InventoryItem item = items.elementAt(i);
  2228. names[vis++].changeText( item.getName() + " $"+ (int)(item.getPrice() * Catalog.PRICERATIO) );
  2229. }
  2230. }
  2231.  
  2232. super.update();
  2233. }
  2234.  
  2235. public void show()
  2236. {
  2237. super.show();
  2238. osd.show();
  2239. }
  2240.  
  2241. public void hide()
  2242. {
  2243. osd.hide();
  2244. super.hide();
  2245. }
  2246. }
  2247.  
  2248. //----------------------------------------------------------------------------------------------
  2249.  
  2250. public class CatalogInventoryPanel extends InventoryPanel
  2251. {
  2252. Player player;
  2253.  
  2254. ResourceRef infoTex0, infoTex1;
  2255. Rectangle infoRect0, infoRect1;
  2256.  
  2257. public CatalogInventoryPanel( CatalogInventory inventory, int index, float left, float top, float width, float height, Player p )
  2258. {
  2259. super( inventory, index, left, top, width, height );
  2260.  
  2261. infoRect0 = inventory.osd.createRectangle( (left+width/2)*2-1, ((top-0.04)*2)-1, 0.1, 0.1, 1.0, -0.5, 0.0, 0, null );
  2262. infoRect1 = inventory.osd.createRectangle( (left+width/2)*2-1, ((top-0.04)*2)-1, 0.1, 0.1, 1.0, 0.5, 0.0, 0, null );
  2263. player = p;
  2264. }
  2265.  
  2266. public void swap( int index_a, int index_b )
  2267. {
  2268. //nincs swap!!
  2269. }
  2270.  
  2271. public void attachItem( InventoryItem invitem )
  2272. {
  2273. ypr = new Ypr( -1.4, -0.7, 0.0 );
  2274.  
  2275. super.attachItem( invitem );
  2276.  
  2277. infoTex0 = infoTex1 = null;
  2278.  
  2279. if( invitem && invitem instanceof InventoryItem_Part)
  2280. {
  2281. ((InventoryItem_Part)invitem).compatibility = 0;
  2282.  
  2283. Part p=invitem.getPart();
  2284. if( player.car )
  2285. if( p.getInfo( p.GII_COMPATIBLE, player.car.id() + "" ) )
  2286. {
  2287. if( p.getInfo( p.GII_INSTALL_OK, player.car.id() + "" ) )
  2288. {
  2289. infoTex0 = Catalog.RR_ICON_CAR_1STEP;
  2290. ((InventoryItem_Part)invitem).compatibility |= 1;
  2291. }
  2292. else
  2293. {
  2294. infoTex0 = Catalog.RR_ICON_CAR_COMP;
  2295. ((InventoryItem_Part)invitem).compatibility |= 2;
  2296. }
  2297. }
  2298.  
  2299.  
  2300. int compatibleParts;
  2301. for( int i=player.parts.size()-1; i>=0; i-- )
  2302. {
  2303. if( player.parts.items.elementAt(i) instanceof InventoryItem_Part )
  2304. if( p.getInfo( p.GII_INSTALL_OK, player.parts.items.elementAt(i).getPart().id() + "" ) )
  2305. {
  2306. compatibleParts++;
  2307. ((InventoryItem_Part)invitem).compatibility |= 4;
  2308. break; //inkabb ne nezzuk tovabb, lassit
  2309. }
  2310. }
  2311.  
  2312. if( compatibleParts )
  2313. infoTex1 = Catalog.RR_ICON_INV_COMP;
  2314.  
  2315. }
  2316.  
  2317. infoRect0.changeTexture( infoTex0 );
  2318. infoRect1.changeTexture( infoTex1 );
  2319. }
  2320.  
  2321. }
  2322.  
  2323. public class BuyCatalogItemDialog extends YesNoDialog
  2324. {
  2325. public BuyCatalogItemDialog( Controller ctrl, int myflags, InventoryItem item, int price )
  2326. {
  2327. super( ctrl, myflags, "BUY PART", genBody( item, price) );
  2328. }
  2329.  
  2330. public String genBody( InventoryItem item, int price )
  2331. {
  2332. String body = "Do you want to buy this " + item.getName() + " for $" + price + " ? \n \n \n" + item.getDescription() + " \n \n Note: ";
  2333. // String body = "Do you want to buy this " + item.getName() + " for $" + price + " ? \n \n Note: ";
  2334.  
  2335. if( item instanceof InventoryItem_Part )
  2336. {
  2337. if( !((InventoryItem_Part)item).compatibility )
  2338. body = body + "NOT compatible with you current car / parts bin!";
  2339. else
  2340. {
  2341. if( ((InventoryItem_Part)item).compatibility & 1 )
  2342. body = body + "installable right away to your car";
  2343. if( ((InventoryItem_Part)item).compatibility & 2 )
  2344. body = body + "interchangeable with your cars parts";
  2345. if( ((InventoryItem_Part)item).compatibility & 4 )
  2346. {
  2347. if( ((InventoryItem_Part)item).compatibility & 3 )
  2348. body = body + " and ";
  2349. body = body + "parts bin compatible";
  2350. }
  2351.  
  2352. }
  2353. }
  2354.  
  2355. return body;
  2356. }
  2357. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement