home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 February / maximum-cd-2009-02.iso / DiscContents / SMC_1.6_win32.exe / src / enemies / gee.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2008-07-03  |  16.9 KB  |  754 lines

  1. /***************************************************************************
  2.  * gee.cpp  -  Electro, Lava or Gift monster
  3.  *
  4.  * Copyright (C) 2006 - 2008 Florian Richter
  5.  ***************************************************************************/
  6. /*
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 3 of the License, or
  10.    (at your option) any later version.
  11.    
  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  14. */
  15.  
  16. #include "../enemies/gee.h"
  17. #include "../core/game_core.h"
  18. #include "../core/camera.h"
  19. #include "../video/animation.h"
  20. #include "../player/player.h"
  21. #include "../gui/hud.h"
  22. #include "../input/mouse.h"
  23. #include "../core/i18n.h"
  24.  
  25. /* *** *** *** *** *** *** cGee *** *** *** *** *** *** *** *** *** *** *** */
  26.  
  27. cGee :: cGee( float x, float y )
  28. : cEnemy( x, y )
  29. {
  30.     cGee::Init();
  31. }
  32.  
  33. cGee :: cGee( CEGUI::XMLAttributes &attributes )
  34. : cEnemy()
  35. {
  36.     cGee::Init();
  37.     cGee::Create_from_Stream( attributes );
  38. }
  39.  
  40. cGee :: ~cGee( void )
  41. {
  42.     //
  43. }
  44.  
  45. void cGee :: Init( void  )
  46. {
  47.     type = TYPE_GEE;
  48.     player_range = 1000;
  49.     posz = 0.088f;
  50.  
  51.     state = STA_STAY;
  52.     dest_velx = 0;
  53.     dest_vely = 0;
  54.     Set_Max_Distance( 400 );
  55.     always_fly = 0;
  56.     wait_time = 2;
  57.     fly_distance = 400;
  58.  
  59.     Set_Direction( DIR_HORIZONTAL );
  60.     color_type = COL_DEFAULT;
  61.     Set_Color( COL_YELLOW );
  62.  
  63.     kill_sound = "enemy/gee/die.ogg";
  64.  
  65.     walk_count = static_cast<float>( rand() % 4 );
  66.  
  67.     wait_time_counter = 0;
  68.     fly_distance_counter = 0;
  69.     clouds_counter = 0;
  70. }
  71.  
  72. cGee *cGee :: Copy( void )
  73. {
  74.     cGee *gee = new cGee( startposx, startposy );
  75.     gee->Set_Direction( start_direction );
  76.     gee->Set_Max_Distance( max_distance );
  77.     gee->always_fly = always_fly;
  78.     gee->wait_time = wait_time;
  79.     gee->fly_distance = fly_distance;
  80.     gee->Set_Color( color_type );
  81.  
  82.     return gee;
  83. }
  84.  
  85. void cGee :: Create_from_Stream( CEGUI::XMLAttributes &attributes )
  86. {
  87.     // position
  88.     Set_Pos( static_cast<float>(attributes.getValueAsInteger( "posx" )), static_cast<float>(attributes.getValueAsInteger( "posy" )), 1 );
  89.     // direction
  90.     Set_Direction( Get_Direction_Id( attributes.getValueAsString( "direction", Get_Direction_Name( start_direction ) ).c_str() ) );
  91.     // max distance
  92.     Set_Max_Distance( attributes.getValueAsInteger( "max_distance", max_distance ) );
  93.     // always fly
  94.     always_fly = attributes.getValueAsBool( "always_fly", always_fly );
  95.     // wait time
  96.     wait_time = attributes.getValueAsFloat( "wait_time", wait_time );
  97.     // fly distance
  98.     fly_distance = attributes.getValueAsInteger( "fly_distance", fly_distance );
  99.     // color
  100.     Set_Color( (DefaultColor)Get_Color_Id( attributes.getValueAsString( "color", Get_Color_Name( color_type ) ).c_str() ) );
  101. }
  102.  
  103. void cGee :: Save_to_Stream( ofstream &file )
  104. {
  105.     // begin enemy
  106.     file << "\t<enemy>" << std::endl;
  107.  
  108.     // name
  109.     file << "\t\t<Property name=\"type\" value=\"gee\" />" << std::endl;
  110.     // position
  111.     file << "\t\t<Property name=\"posx\" value=\"" << static_cast<int>(startposx) << "\" />" << std::endl;
  112.     file << "\t\t<Property name=\"posy\" value=\"" << static_cast<int>(startposy) << "\" />" << std::endl;
  113.     // direction
  114.     file << "\t\t<Property name=\"direction\" value=\"" << Get_Direction_Name( start_direction ) << "\" />" << std::endl;
  115.     // max distance
  116.     file << "\t\t<Property name=\"max_distance\" value=\"" << static_cast<int>(max_distance) << "\" />" << std::endl;
  117.     // always fly
  118.     file << "\t\t<Property name=\"always_fly\" value=\"" << always_fly << "\" />" << std::endl;
  119.     // wait time
  120.     file << "\t\t<Property name=\"wait_time\" value=\"" << wait_time << "\" />" << std::endl;
  121.     // fly distance
  122.     file << "\t\t<Property name=\"fly_distance\" value=\"" << static_cast<int>(fly_distance) << "\" />" << std::endl;
  123.     // color
  124.     file << "\t\t<Property name=\"color\" value=\"" << Get_Color_Name( color_type ) << "\" />" << std::endl;
  125.  
  126.     // end enemy
  127.     file << "\t</enemy>" << std::endl;
  128. }
  129.  
  130. void cGee :: Load_from_Savegame( cSave_Level_Object *save_object )
  131. {
  132.     cEnemy::Load_from_Savegame( save_object );
  133.  
  134.     Update_Rotation_Hor_velx();
  135. }
  136.  
  137. void cGee :: Set_Direction( ObjectDirection dir )
  138. {
  139.     // already set
  140.     if( direction == dir )
  141.     {
  142.         return;
  143.     }
  144.  
  145.     // horizontal
  146.     if( dir == DIR_HORIZONTAL || dir == DIR_LEFT || dir == DIR_RIGHT )
  147.     {
  148.         dir = DIR_HORIZONTAL;
  149.         dest_vely = 0;
  150.         dest_velx = 3;
  151.     }
  152.     // vertical
  153.     else
  154.     {
  155.         dir = DIR_VERTICAL;
  156.         dest_vely = 3;
  157.         dest_velx = 0;
  158.     }
  159.  
  160.     cEnemy::Set_Direction( dir, 1 );
  161.  
  162.     if( velx )
  163.     {
  164.         Update_Rotation_Hor_velx( 1 );
  165.     }
  166.     else
  167.     {
  168.         Update_Rotation_Hor_vely( 1 );
  169.     }
  170.  
  171.     Create_Name();
  172. }
  173.  
  174. void cGee :: Set_Max_Distance( int nmax_distance )
  175. {
  176.     max_distance = nmax_distance;
  177.  
  178.     if( max_distance < 0 )
  179.     {
  180.         max_distance = 0;
  181.     }
  182. }
  183.  
  184. void cGee :: Set_Color( DefaultColor col )
  185. {
  186.     // already set
  187.     if( color_type == col )
  188.     {
  189.         return;
  190.     }
  191.  
  192.     // clear old images
  193.     Clear_Images();
  194.  
  195.     color_type = col;
  196.  
  197.     string filename_dir;
  198.  
  199.     // Electro
  200.     if( color_type == COL_YELLOW )
  201.     {
  202.         filename_dir = "electro";
  203.         kill_points = 50;
  204.  
  205.         fire_resistant = 0;
  206.     }
  207.     // Lava
  208.     else if( color_type == COL_RED )
  209.     {
  210.         filename_dir = "lava";
  211.  
  212.         if( dest_velx )
  213.         {
  214.             dest_velx = 4;
  215.         }
  216.         if( dest_vely )
  217.         {
  218.             dest_vely = 4;
  219.         }
  220.         kill_points = 100;
  221.  
  222.         fire_resistant = 1;
  223.     }
  224.     // Venom
  225.     else if( color_type == COL_GREEN )
  226.     {
  227.         filename_dir = "venom";
  228.         if( dest_velx )
  229.         {
  230.             dest_velx = 5;
  231.         }
  232.         if( dest_vely )
  233.         {
  234.             dest_vely = 5;
  235.         }
  236.         kill_points = 200;
  237.  
  238.         fire_resistant = 0;
  239.     }
  240.  
  241.     Create_Name();
  242.  
  243.     images.push_back( pVideo->Get_Surface( "enemy/gee/" + filename_dir + "/1.png" ) );
  244.     images.push_back( pVideo->Get_Surface( "enemy/gee/" + filename_dir + "/2.png" ) );
  245.     images.push_back( pVideo->Get_Surface( "enemy/gee/" + filename_dir + "/3.png" ) );
  246.     images.push_back( pVideo->Get_Surface( "enemy/gee/" + filename_dir + "/4.png" ) );
  247.     images.push_back( pVideo->Get_Surface( "enemy/gee/" + filename_dir + "/5.png" ) );
  248.     images.push_back( pVideo->Get_Surface( "enemy/gee/" + filename_dir + "/6.png" ) );
  249.     images.push_back( pVideo->Get_Surface( "enemy/gee/" + filename_dir + "/7.png" ) );
  250.     images.push_back( pVideo->Get_Surface( "enemy/gee/" + filename_dir + "/8.png" ) );
  251.     images.push_back( pVideo->Get_Surface( "enemy/gee/" + filename_dir + "/9.png" ) );
  252.     images.push_back( pVideo->Get_Surface( "enemy/gee/" + filename_dir + "/10.png" ) );
  253.  
  254.     Set_Image( 5, 1 );
  255. }
  256.  
  257. void cGee :: DownGrade( bool force /* = 0 */ )
  258. {
  259.     Set_Dead( 1 );
  260.     massivetype = MASS_PASSIVE;
  261.     counter = 0;
  262.     velx = 0;
  263.     vely = 0;
  264.  
  265.     if( !force )
  266.     {
  267.         for( unsigned int i = 0; i < 20; i++ )
  268.         {
  269.             Generate_Particles();
  270.         }
  271.     }
  272.     else
  273.     {
  274.         Set_Rotation_Z( 180 );
  275.     }
  276. }
  277.  
  278. void cGee :: DieStep( void )
  279. {
  280.     counter += pFramerate->speedfactor;
  281.  
  282.     // default death
  283.     if( rotz != 180 )
  284.     {
  285.         Set_Visible( 0 );
  286.     }
  287.     // falling death
  288.     else
  289.     {
  290.         // a little bit upwards first
  291.         if( counter < 5 )
  292.         {
  293.             Move( 0, -5 );
  294.         }
  295.         // if not below the screen fall
  296.         else if( posy < game_res_h + col_rect.h )
  297.         {
  298.             Move( 0, 20 );
  299.         }
  300.         // if below disable
  301.         else
  302.         {
  303.             rotz = 0;
  304.             Set_Visible( 0 );
  305.         }
  306.     }
  307. }
  308.  
  309. void cGee :: Update( void )
  310. {
  311.     cEnemy::Update();
  312.  
  313.     if( !valid_update || !is_Player_range() )
  314.     {
  315.         return;
  316.     }
  317.  
  318.     // staying
  319.     if( state == STA_STAY )
  320.     {
  321.         wait_time_counter += pFramerate->speedfactor;
  322.  
  323.         // if wait time reached or always fly
  324.         if( wait_time_counter > wait_time * speedfactor_fps || always_fly )
  325.         {
  326.             Activate();
  327.         }
  328.     }
  329.     // moving
  330.     else
  331.     {
  332.         Col_Move( velx, vely, 0, 1, 0 );
  333.  
  334.         // update fly distance counter
  335.         if( velx > 0 )
  336.         {
  337.             fly_distance_counter += velx * pFramerate->speedfactor;
  338.         }
  339.         else if( velx < 0 )
  340.         {
  341.             fly_distance_counter -= velx * pFramerate->speedfactor;
  342.         }
  343.         if( vely > 0 )
  344.         {
  345.             fly_distance_counter += vely * pFramerate->speedfactor;
  346.         }
  347.         else if( vely < 0 )
  348.         {
  349.             fly_distance_counter -= vely * pFramerate->speedfactor;
  350.         }
  351.  
  352.         // check out of map screen
  353.         if( direction == DIR_DOWN )
  354.         {
  355.             // if below screen move back
  356.             if( rect.y + col_rect.h > game_res_h )
  357.             {
  358.                 Turn_Around( DIR_DOWN );
  359.             }
  360.         }
  361.         // check out of max distance
  362.         if( !Check_Max_Distance() )
  363.         {
  364.             Stop();
  365.         }
  366.  
  367.         // generate particle clouds
  368.         clouds_counter += pFramerate->speedfactor * 0.4f;
  369.  
  370.         while( clouds_counter > 0 )
  371.         {
  372.             Generate_Particles();
  373.  
  374.             clouds_counter--;
  375.         }
  376.  
  377.         // walk_distance reached
  378.         if( !always_fly && fly_distance_counter > fly_distance )
  379.         {
  380.             Stop();
  381.         }
  382.     }
  383.  
  384.     walk_count += pFramerate->speedfactor * 0.3f;
  385.  
  386.     if( walk_count >= 10 )
  387.     {
  388.         walk_count = 0;
  389.     }
  390.  
  391.     Set_Image( static_cast<int>(walk_count) );
  392. }
  393.  
  394. void cGee :: Draw( cSurfaceRequest *request /* = NULL */ )
  395. {
  396.     if( !valid_draw )
  397.     {
  398.         return;
  399.     }
  400.  
  401.     // draw distance rect
  402.     if( editor_level_enabled )
  403.     {
  404.         if( start_direction == DIR_HORIZONTAL )
  405.         {
  406.             pVideo->Draw_Rect( startposx - pActive_Camera->x - max_distance, startposy + ( rect.h * 0.5f ) - 5 - pActive_Camera->y, col_rect.w + ( max_distance * 2 ), 10, posz - 0.000001f, &whitealpha128 );
  407.         }
  408.         else if( start_direction == DIR_VERTICAL )
  409.         {
  410.             pVideo->Draw_Rect( startposx + ( rect.w * 0.5f ) - 5 - pActive_Camera->x, startposy - pActive_Camera->y - max_distance, 10, col_rect.h + ( max_distance * 2 ), posz - 0.000001f, &whitealpha128 );
  411.         }
  412.     }
  413.  
  414.     cEnemy::Draw( request );
  415. }
  416.  
  417. void cGee :: Activate( void )
  418. {
  419.     // if empty maximum or walk distance
  420.     if( !max_distance || !fly_distance )
  421.     {
  422.         return;
  423.     }
  424.  
  425.     wait_time_counter = 0;
  426.     state = STA_WALK;
  427.  
  428.     // set velocity
  429.     velx = dest_velx;
  430.     vely = dest_vely;
  431.  
  432.     // random direction
  433.     if( rand() % 2 != 1 )
  434.     {
  435.         velx *= -1;
  436.     }
  437.     if( rand() % 2 != 1 )
  438.     {
  439.         vely *= -1;
  440.     }
  441.  
  442.     Update_Direction();
  443.  
  444.     // check max distance
  445.     if( !Check_Max_Distance() )
  446.     {
  447.         Turn_Around();
  448.  
  449.         if( velx )
  450.         {
  451.             Update_Rotation_Hor_velx();
  452.         }
  453.         else
  454.         {
  455.             Update_Rotation_Hor_vely();
  456.         }
  457.     }
  458. }
  459.  
  460. void cGee :: Stop( void )
  461. {
  462.     fly_distance_counter = 0;
  463.     state = STA_STAY;
  464.     velx = 0;
  465.     vely = 0;
  466. }
  467.  
  468. void cGee :: Generate_Particles( void )
  469. {
  470.     cParticle_Emitter *anim = new cParticle_Emitter();
  471.     anim->Set_Pos( posx + 15 + ( rand() % static_cast<int>( col_rect.w / 2 ) ), posy + ( ( rand() % static_cast<int>( col_rect.h / 2 ) ) ) );
  472.     anim->Set_Quota( 4 );
  473.     anim->Set_Image( pVideo->Get_Surface( "animation/particles/cloud.png" ) );
  474.  
  475.     if( !dead )
  476.     {
  477.         anim->Set_Speed( 0.3f, 0.2f );
  478.  
  479.         // direction
  480.         if( direction == DIR_LEFT )
  481.         {
  482.             anim->Set_Direction_Range( 90, 180 );
  483.         }
  484.         else
  485.         {
  486.             anim->Set_Direction_Range( 270, 180 );
  487.         }
  488.     }
  489.     else
  490.     {
  491.         anim->Set_Speed( 0.1f, 0.6f );
  492.     }
  493.  
  494.     anim->Set_Scale( 0.5f, 0.3f );
  495.  
  496.     // color
  497.     if( color_type == COL_YELLOW )
  498.     {
  499.         anim->Set_Color( yellow );
  500.     }
  501.     else if( color_type == COL_RED )
  502.     {
  503.         anim->Set_Color( lightred );
  504.     }
  505.     else if( color_type == COL_GREEN )
  506.     {
  507.         anim->Set_Color( lightgreen );
  508.     }
  509.     anim->Set_Time_to_Live( 2 );
  510.     anim->Set_Fading_Alpha( 1 );
  511.     anim->Set_Blending( BLEND_ADD );
  512.     pAnimation_Manager->Add( anim );
  513. }
  514.  
  515. bool cGee :: Check_Max_Distance( void )
  516. {
  517.     if( direction == DIR_UP )
  518.     {
  519.         if( posy - startposy < -max_distance )
  520.         {
  521.             return 0;
  522.         }
  523.     }
  524.     else if( direction == DIR_DOWN )
  525.     {
  526.         if( posy - startposy > max_distance )
  527.         {
  528.             return 0;
  529.         }
  530.     }
  531.     else if( direction == DIR_LEFT )
  532.     {
  533.         if( posx - startposx < -max_distance )
  534.         {
  535.             return 0;
  536.         }
  537.     }
  538.     else if( direction == DIR_RIGHT )
  539.     {
  540.         if( posx - startposx > max_distance )
  541.         {
  542.             return 0;
  543.         }
  544.     }
  545.  
  546.     return 1;
  547. }
  548.  
  549. bool cGee :: Is_Update_Valid( void )
  550. {
  551.     if( dead || freeze_counter )
  552.     {
  553.         return 0;
  554.     }
  555.  
  556.     return 1;
  557. }
  558.  
  559. bool cGee :: Is_Draw_Valid( void )
  560. {
  561.     if( cEnemy::Is_Draw_Valid() == 1 )
  562.     {
  563.         return 1;
  564.     }
  565.  
  566.     // if not editor enabled or not active mouse object
  567.     if( !editor_enabled || pMouseCursor->active_object != this )
  568.     {
  569.         return 0;
  570.     }
  571.  
  572.     return 1;
  573. }
  574.  
  575.  
  576. unsigned int cGee :: Validate_Collision( cSprite *obj )
  577. {
  578.     if( obj->type == TYPE_PLAYER )
  579.     {
  580.         return 1;
  581.     }
  582.     if( obj->type == TYPE_BALL )
  583.     {
  584.         return 2;
  585.     }
  586.  
  587.     return 0;
  588. }
  589.  
  590. void cGee :: Handle_Collision_Player( cObjectCollision *collision )
  591. {
  592.     // unknown direction
  593.     if( collision->direction == DIR_UNDEFINED )
  594.     {
  595.         return;
  596.     }
  597.  
  598.     if( collision->direction == DIR_TOP && pPlayer->state != STA_FLY )
  599.     {
  600.         pAudio->Play_Sound( kill_sound );
  601.  
  602.         DownGrade();
  603.         pPlayer->Action_Jump( 1 );
  604.  
  605.         pointsdisplay->Add_Points( kill_points, pPlayer->posx, pPlayer->posy, "", static_cast<Uint8>(255), 1 );
  606.         pPlayer->Add_Kill_Multiplier();
  607.     }
  608.     else if( !pPlayer->invincible )
  609.     {
  610.         if( pPlayer->maryo_type != MARYO_SMALL )
  611.         {
  612.             // todo : create again
  613.             //pAudio->PlaySound( "player/maryo_au.ogg", RID_MARYO_AU );
  614.  
  615.             if( collision->direction == DIR_BOTTOM  )
  616.             {
  617.                 pPlayer->Action_Jump( 1 );
  618.             }
  619.             else if( collision->direction == DIR_LEFT )
  620.             {
  621.                 pPlayer->velx = -7;
  622.             }
  623.             else if( collision->direction == DIR_RIGHT )
  624.             {
  625.                 pPlayer->velx = 7;
  626.             }
  627.         }
  628.  
  629.         pPlayer->DownGrade();
  630.         Turn_Around( collision->direction );
  631.     }
  632. }
  633.  
  634. void cGee :: Editor_Activate( void )
  635. {
  636.     CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
  637.  
  638.     // max distance
  639.     CEGUI::Editbox *editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_gee_max_distance" ));
  640.     Editor_Add( UTF8_("Distance"), UTF8_("Movable distance"), editbox, 90 );
  641.  
  642.     editbox->setText( int_to_string( max_distance ) );
  643.     editbox->subscribeEvent( CEGUI::Editbox::EventKeyUp, CEGUI::Event::Subscriber( &cGee::Editor_Max_Distance_Key, this ) );
  644.  
  645.     // always fly
  646.     CEGUI::Combobox *combobox = static_cast<CEGUI::Combobox *>(wmgr.createWindow( "TaharezLook/Combobox", "editor_gee_always_fly" ));
  647.     Editor_Add( UTF8_("Always fly"), UTF8_("Move without stopping at the fly distance"), combobox, 120, 80 );
  648.  
  649.     combobox->addItem( new CEGUI::ListboxTextItem( UTF8_("Enabled") ) );
  650.     combobox->addItem( new CEGUI::ListboxTextItem( UTF8_("Disabled") ) );
  651.  
  652.     if( always_fly )
  653.     {
  654.         combobox->setText( UTF8_("Enabled") );
  655.     }
  656.     else
  657.     {
  658.         combobox->setText( UTF8_("Disabled") );
  659.     }
  660.  
  661.     combobox->subscribeEvent( CEGUI::Combobox::EventListSelectionAccepted, CEGUI::Event::Subscriber( &cGee::Editor_Always_Fly_Select, this ) );
  662.  
  663.     // wait time
  664.     editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_gee_wait_time" ));
  665.     Editor_Add( UTF8_("Wait time"), UTF8_("Time to wait until moving again after a stop"), editbox, 90 );
  666.  
  667.     editbox->setText( float_to_string( wait_time ) );
  668.     editbox->subscribeEvent( CEGUI::Editbox::EventKeyUp, CEGUI::Event::Subscriber( &cGee::Editor_Wait_Time_Key, this ) );
  669.  
  670.     // fly distance
  671.     editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_gee_fly_distance" ));
  672.     Editor_Add( UTF8_("Fly distance"), UTF8_("The distance to move each time"), editbox, 90 );
  673.  
  674.     editbox->setText( int_to_string( fly_distance ) );
  675.     editbox->subscribeEvent( CEGUI::Editbox::EventKeyUp, CEGUI::Event::Subscriber( &cGee::Editor_Fly_Distance_Key, this ) );
  676.  
  677.     // init
  678.     Editor_Init();
  679. }
  680.  
  681. bool cGee :: Editor_Max_Distance_Key( const CEGUI::EventArgs &event )
  682. {
  683.     const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
  684.     string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
  685.  
  686.     Set_Max_Distance( string_to_int( str_text ) );
  687.  
  688.     return 1;
  689. }
  690.  
  691. bool cGee :: Editor_Always_Fly_Select( const CEGUI::EventArgs &event )
  692. {
  693.     const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
  694.     CEGUI::ListboxItem *item = static_cast<CEGUI::Combobox *>( windowEventArgs.window )->getSelectedItem();
  695.  
  696.     if( item->getText().compare( UTF8_("Enabled") ) == 0 )
  697.     {
  698.         always_fly = 1;
  699.     }
  700.     else
  701.     {
  702.         always_fly = 0;
  703.     }
  704.  
  705.     return 1;
  706. }
  707.  
  708. bool cGee :: Editor_Wait_Time_Key( const CEGUI::EventArgs &event )
  709. {
  710.     const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
  711.     string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
  712.  
  713.     wait_time = string_to_float( str_text );
  714.  
  715.     return 1;
  716. }
  717.  
  718. bool cGee :: Editor_Fly_Distance_Key( const CEGUI::EventArgs &event )
  719. {
  720.     const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
  721.     string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
  722.  
  723.     fly_distance = string_to_int( str_text );
  724.  
  725.     return 1;
  726. }
  727.  
  728. void cGee :: Create_Name( void )
  729. {
  730.     name = "Gee";
  731.  
  732.     if( color_type == COL_YELLOW )
  733.     {
  734.         name += "lectro";
  735.     }
  736.     else if( color_type == COL_RED )
  737.     {
  738.         name += "lava";
  739.     }
  740.     else if( color_type == COL_GREEN )
  741.     {
  742.         name += "venom";
  743.     }
  744.  
  745.     if( start_direction == DIR_HORIZONTAL )
  746.     {
  747.         name += " Hor";
  748.     }
  749.     else if( start_direction == DIR_VERTICAL )
  750.     {
  751.         name += " Ver";
  752.     }
  753. }
  754.