Пример #1
0
cRandom_Sound::cRandom_Sound(XmlAttributes& attributes, cSprite_Manager* sprite_manager)
    : cSprite(sprite_manager, "sound")
{
    cRandom_Sound::Init();

    // filename
    Set_Filename(attributes["file"]);

    // position
    Set_Pos(string_to_float(attributes["posx"]), string_to_float(attributes["posy"]), true);

    //
    Set_Continuous(attributes.fetch<bool>("continuous", m_continuous));

    // delay
    Set_Delay_Min(attributes.fetch<int>("delay_min", m_delay_min));
    Set_Delay_Min(attributes.fetch<int>("delay_max", m_delay_max));

    // volume
    Set_Volume_Min(attributes.fetch<float>("volume_min", m_volume_min));
    Set_Volume_Max(attributes.fetch<float>("volume_min", m_volume_max));

    // volume reduction
    Set_Volume_Reduction_Begin(attributes.fetch<float>("volume_reduction_begin", m_volume_reduction_begin));
    Set_Volume_Reduction_End(attributes.fetch<float>("volume_reduction_end", m_volume_reduction_end));
}
Пример #2
0
cRokko::cRokko(XmlAttributes& attributes, cSprite_Manager* sprite_manager)
    : cEnemy(sprite_manager)
{
    cRokko::Init();

    // position
    Set_Pos(string_to_float(attributes["posx"]), string_to_float(attributes["posy"]), true);

    // direction
    Set_Direction(Get_Direction_Id(attributes.fetch("direction", Get_Direction_Name(m_start_direction))));

    // speed
    Set_Speed(string_to_float(attributes.fetch("speed", float_to_string(m_speed))));
}
Пример #3
0
void Box::load_movies_movieClub()
{
	vector<Movie> Club;
	string s;
	float c;
	ifstream file;
	file.open("info//Movie Club.txt");
	if (!file.fail())
	{
		while (!file.eof())
		{
			getline(file, s);
			int i = 1;
			string name;
			do
			{
				name.push_back(s.at(i));
				i++;
			} while (s.at(i) != '\"');
			c = string_to_float(s.substr(i + 2, s.length()));
			Movie temp(name, c);
			Club.push_back(temp);
		}
		file.close();
	}
	movieClub = Club;
}
Пример #4
0
void Box::load_movies_seen()
{
	vector<Movie> Seen;
	string s;
	float c;
	int t;
	ifstream file;
	file.open("info//Seen Movies.txt");
	if (!file.fail())
	{
		while (!file.eof())
		{
			getline(file, s);
			int i = 1;
			string name, aux;
			do
			{
				name.push_back(s.at(i));
				i++;
			} while (s.at(i) != '\"');
			i+=2;
			do
			{
				aux.push_back(s.at(i));
				i++;
			} while (s.at(i) != ' ');
			c = string_to_float(aux);
			t = string_to_int(s.substr(i + 1, s.length()));
			Movie temp(name, c, t);
			Seen.push_back(temp);
		}
		file.close();
	}
	seenMovies = Seen;
}
   float command_line_params::get_value_as_float(const wchar_t* pKey, uint index, float def, float l, float h, uint value_index) const
   {
      param_map_const_iterator it = get_param(pKey, index);
      if ((it == end()) || (value_index >= it->second.m_values.size()))
         return def;

      float val;
      const wchar_t* p = it->second.m_values[value_index].get_ptr();
      if (!string_to_float(p, val))
      {
         crnlib::console::warning(L"Invalid value specified for float parameter \"%s\", using default value of %f", pKey, def);
         return def;
      }

      if (val < l)
      {
         crnlib::console::warning(L"Value %f for parameter \"%s\" is out of range, clamping to %f", val, pKey, l);
         val = l;
      }
      else if (val > h)
      {
         crnlib::console::warning(L"Value %f for parameter \"%s\" is out of range, clamping to %f", val, pKey, h);
         val = h;
      }

      return val;
   }
Пример #6
0
void cBackground::Load_From_Attributes(XmlAttributes& attributes)
{
    Set_Type(static_cast<BackgroundType>(string_to_int(attributes["type"])));

    if (m_type == BG_GR_HOR || m_type == BG_GR_VER) {
        int r, g, b;

        r = string_to_int(attributes["bg_color_1_red"]);
        g = string_to_int(attributes["bg_color_1_green"]);
        b = string_to_int(attributes["bg_color_1_blue"]);
        Set_Color_1(Color(static_cast<Uint8>(r), static_cast<Uint8>(g), static_cast<Uint8>(b)));

        r = string_to_int(attributes["bg_color_2_red"]);
        g = string_to_int(attributes["bg_color_2_green"]);
        b = string_to_int(attributes["bg_color_2_blue"]);
        Set_Color_2(Color(static_cast<Uint8>(r), static_cast<Uint8>(g), static_cast<Uint8>(b)));
    }
    else if (m_type == BG_IMG_BOTTOM || m_type == BG_IMG_TOP || m_type == BG_IMG_ALL) {
        Set_Start_Pos(string_to_float(attributes["posx"]), string_to_float(attributes["posy"]));
        Set_Pos_Z(string_to_float(attributes["posz"]));

        Set_Image(utf8_to_path(attributes["image"]));
        Set_Scroll_Speed(string_to_float(attributes["speedx"]), string_to_float(attributes["speedy"]));
        Set_Const_Velocity_X(string_to_float(attributes["const_velx"]));
        Set_Const_Velocity_Y(string_to_float(attributes["const_vely"]));
    }
}
Пример #7
0
bool cRokko::Editor_Speed_Text_Changed(const CEGUI::EventArgs& event)
{
    const CEGUI::WindowEventArgs& windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>(event);
    std::string str_text = static_cast<CEGUI::Editbox*>(windowEventArgs.window)->getText().c_str();

    Set_Speed(string_to_float(str_text));

    return 1;
}
Пример #8
0
bool cRandom_Sound::Editor_Volume_Reduction_End_Text_Changed(const CEGUI::EventArgs& event)
{
    const CEGUI::WindowEventArgs& windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>(event);
    std::string str_text = static_cast<CEGUI::Editbox*>(windowEventArgs.window)->getText().c_str();

    Set_Volume_Reduction_End(string_to_float(str_text));

    return 1;
}
Пример #9
0
cFlyon::cFlyon(XmlAttributes& attributes, cSprite_Manager* sprite_manager)
    : cEnemy(sprite_manager)
{
    cFlyon::Init();

    // position
    Set_Pos(string_to_float(attributes["posx"]), string_to_float(attributes["posy"]), true);

    // image directory
    Set_Image_Dir(utf8_to_path(attributes.fetch("image_dir", path_to_utf8(m_img_dir))));

    // direction
    Set_Direction(Get_Direction_Id(attributes.fetch("direction", Get_Direction_Name(m_start_direction))));

    // max distance
    Set_Max_Distance(string_to_int(attributes.fetch("max_distance", int_to_string(m_max_distance))));

    // speed
    Set_Speed(string_to_float(attributes.fetch("speed", float_to_string(m_speed))));
}
Пример #10
0
//------------------------------------------------------------------------------
static void ProcessGPGGA(unsigned char *pData)
{
    #define MAXFIELD 10
    unsigned char pField[MAXFIELD];

    //
    // Altitude
    //
    if (GetField(pData, pField, 8, MAXFIELD))
    {
        gps_info.Position.Altitude = string_to_float((unsigned char *)pField);
    }
}
Пример #11
0
bool cStaticEnemy :: Editor_Ice_Resistance_Text_Changed( const CEGUI::EventArgs &event )
{
	const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
	std::string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();

	m_ice_resistance = string_to_float( str_text );

	if( m_ice_resistance > 1.0f )
	{
		m_ice_resistance = 1.0f;
	}
	
	return 1;
}
Пример #12
0
 void cPath_State::Load_From_Savegame(cSave_Level_Object* save_object)
 {
     if (save_object->exists("new_pos_x"))
     {
         pos_x = string_to_float(save_object->Get_Value("new_pos_x"));
     }
     if (save_object->exists("new_pos_y"))
     {
         pos_y = string_to_float(save_object->Get_Value("new_pos_y"));
     }
     
     if (save_object->exists("current_segment"))
     {
         current_segment = string_to_int(save_object->Get_Value("current_segment"));
     }
     if (save_object->exists("current_segment_pos"))
     {
         current_segment_pos = string_to_float(save_object->Get_Value("current_segment_pos"));
     }
     if (save_object->exists("forward"))
     {
         forward = string_to_int(save_object->Get_Value("forward")) > 0;
     }
 }
Пример #13
0
 inline float string_to_type(const std::string& value)
 {
     return string_to_float(value);
 }
Пример #14
0
xcmd_object_t *io_read_input(const char *filepath)
{
    FILE *fp = NULL;
    if ((fp = fopen(filepath, "r")) == NULL) {
        return NULL;
    }
    
    xcmd_object_t *object = NULL;
    
    char buf[1024];
    char key[64];
    char val[256];
    float tx = 0.0;
    float ty = 0.0;
    float tz = 0.0;
    char atom[2];
    int k = 0;
    float temp = 0.0;
    int nsteps = 0;
    float steptime = 0.0;
    float box = 0.0;
    float equiltime = 0.0;
    float sigma = 0.0;
    float epsilon = 0.0;
    float cutoff = 0.0;
    float nu = 0.0;
    char *fout = NULL;
    char *vout = NULL;
    char *pout = NULL;
    
    // First pass to get all the options.
    while (fgets(buf, sizeof(buf), fp) != NULL) {
        if (buf[0] == '&' && sscanf(&buf[1], "%s %s", key, val) == 2) {
            if (strcmp(key, MD_KEYS[MD_ATOM_NUM]) == 0) {
                object = xcmd_init_object(string_to_int(val, 10));
            } else if (strcmp(key, MD_KEYS[TEMPERATURE]) == 0) {
                temp = string_to_float(val);
            } else if (strcmp(key, MD_KEYS[MD_MAX_STEPS]) == 0) {
                nsteps = string_to_int(val, 10);
            } else if (strcmp(key, MD_KEYS[MD_TIMESTEP]) == 0) {
                steptime = string_to_float(val);
            } else if (strcmp(key, MD_KEYS[MD_BOX]) == 0) {
                box = string_to_float(val);
            } else if (strcmp(key, MD_KEYS[MD_EQUIL_TIME]) == 0) {
                equiltime = string_to_float(val);
            } else if (strcmp(key, MD_KEYS[MD_SIGMA]) == 0) {
                sigma = string_to_float(val);
            } else if (strcmp(key, MD_KEYS[MD_EPSILON]) == 0) {
                epsilon = string_to_float(val);
            } else if (strcmp(key, MD_KEYS[MD_NU]) == 0) {
                nu = string_to_float(val);
            } else if (strcmp(key, MD_KEYS[MD_CUTOFF]) == 0) {
                cutoff = string_to_float(val);
            } else if (strcmp(key, MD_KEYS[MD_POUT]) == 0) {
                pout = strdup(val);
            } else if (strcmp(key, MD_KEYS[MD_VOUT]) == 0) {
                vout = strdup(val);
            } else if (strcmp(key, MD_KEYS[MD_FOUT]) == 0) {
                fout = strdup(val);
            }
        }
    }
    rewind(fp);
    
    // Check
    if (object == NULL) {
        fprintf(xcmdout, "Error: the ATOM_NUMBER can not be found!\n");
        abort();
    }
    
    // Set the options for the MD simulation
    object->temp = temp;
    object->timestep = steptime;
    object->nsteps = nsteps;
    object->epsilon = epsilon;
    object->box = box;
    object->sigma = sigma;
    object->tequil = equiltime;
    object->nu = nu;
    
    // Calculate the cutoff energy
    float hbox = 0.5 * box;
    float rc = hbox < cutoff ? hbox : cutoff;
    object->rc2 = rc * rc;
    object->ecut = 4.0 * epsilon * (pow(sigma/rc, 12.0) - pow(sigma/rc, 6.0));
    
    // Open the three output FILE streams.
    _io_remove_file(pout);
    object->pout = fopen(pout, "a+");
    if (object->pout == NULL) {
        fprintf(xcmdout, "Failed to create file %s.\n", pout);
        abort();
    }
    free(pout);
    
    _io_remove_file(fout);
    object->fout = fopen(fout, "a+");
    if (object->fout == NULL) {
        fprintf(xcmdout, "Failed to create file %s.\n", fout);
        abort();
    }
    free(fout);
    
    _io_remove_file(vout);
    object->vout = fopen(vout, "a+");
    if (object->vout == NULL) {
        fprintf(xcmdout, "Failed to create file %s.\n", vout);
        abort();
    }
    free(vout);
    
    // Second pass to get the initial coordinates.
    while (fgets(buf, sizeof(buf), fp) != NULL) {
        if (sscanf(buf, "%s %f %f %f", atom, &tx, &ty, &tz) == 4) {
            object->px[k] = tx;
            object->py[k] = ty;
            object->pz[k] = tz;
            k ++;
        }
    }
    
    fclose(fp);
    return object;
}
Пример #15
0
//------------------------------------------------------------------------------
static void ProcessGPRMC(unsigned char *pData)
{
    #define MAXFIELD 10
    unsigned char pField[MAXFIELD];

    // Time
    if (GPS_LED==0)GPS_LED = 1;
    //
    if (GetField(pData, pField, 0, MAXFIELD))
    {
    // Hour
        gps_info.time_pack.hour = (pField[0]-'0')*10 + pField[1]-'0';

    // minute
        gps_info.time_pack.min = (pField[2]-'0')*10 + pField[3]-'0';

    // Second
        gps_info.time_pack.sec = (pField[4]-'0')*10 + pField[5]-'0';
    }

    //
    // Data valid
    //
    if (GetField(pData, pField, 1, MAXFIELD) && pField[0] == 'A')
    {
        gps_info.fix_valid = TRUE;
        gps_info.time_valid = TRUE;
        //GPS_LED = 2;
        memcpy(&cool_pack_recv, &CT, sizeof(SYSTEMTIME));
    }
    else
    {
        gps_info.fix_valid = FALSE;
        gps_info.time_valid = FALSE;
        //
        memcpy(&bad_pack_recv, &CT, sizeof(SYSTEMTIME));

    }
    //
    // Latitude
    //
    if (GetField(pData, pField, 2, MAXFIELD))
    {
        gps_info.Position.Latitude = string_to_float((unsigned char *)pField+2)/60.0;
        gps_info.Position.Latitude += (float)((pField[0]-'0')*10+(pField[1]-'0'));
    }
    if (GetField(pData, pField, 3, MAXFIELD))
    {
        if (pField[0] == 'S')
	gps_info.Position.Latitude = -gps_info.Position.Latitude;
    }

    //
    // Longitude
    //
    if (GetField(pData, pField, 4, MAXFIELD))
    {
        gps_info.Position.Longitude =  string_to_float((unsigned char *)pField+3)/60.0;
        gps_info.Position.Longitude += (float)((pField[0]-'0')*100 + (pField[1]-'0')*10 + (pField[2]-'0'));
    }

    if (GetField(pData, pField, 5, MAXFIELD))
    {
        if (pField[0] == 'W')
	gps_info.Position.Longitude = -gps_info.Position.Longitude;
    }

    //
    // Ground speed
    //
    if (GetField(pData, pField, 6, MAXFIELD))
    {
        gps_info.Velocity.Velocity = string_to_float((unsigned char *)pField)*0.5144444;
    }
    else
    {
        gps_info.Velocity.Velocity = 0.0;
    }

    //
    // course over ground, degrees true
    //
    if (GetField(pData, pField, 7, MAXFIELD))
    {
        gps_info.Velocity.Course = string_to_float((unsigned char *)pField);
    }
    else
    {
        gps_info.Velocity.Course = 0.0;
    }

    //
    // Date
    //
    if (GetField(pData, pField, 8, MAXFIELD))
    {
        // Day
        gps_info.time_pack.date = (pField[0]-'0')*10 + pField[1]-'0';

        // Month
        gps_info.time_pack.month = (pField[2]-'0')*10 + pField[3]-'0';

        // Year (Only two digits. I wonder why?)
        gps_info.time_pack.year = (pField[4]-'0')*10 + pField[5]-'0';

    }

}
Пример #16
0
//TODO(Vidar): Bounds check! IMPORTANT!
static int32_t handler(void* user_data, const char* section, const char* name,
                   const char* value)
{
    WeaveData *data = (WeaveData*)user_data;
    WarpOrWeftData *wdata = 0;
    if(strcmp("WARP",section)==0){
        wdata = &data->warp;
    }
    if(strcmp("WEFT",section)==0){
        wdata = &data->weft;
    }
    if(wdata){
        if(strcmp("Threads",name)==0){
            wdata->num_threads = (uint32_t)atoi(value);
        }
        if(strcmp("Spacing",name)==0){
            if(!string_to_float(value,&wdata->spacing)){
                printf("could not read %s in [%s]!\n",name,section);
                return 0;
            }
        }
        if(strcmp("Thickness",name)==0){
            if(!string_to_float(value,&wdata->thickness)){
                printf("could not read %s in [%s]!\n",name,section);
                return 0;
            }
        }
    }
    if(strcmp("WEAVING",section)==0){
        if(strcmp("Shafts",name)==0){
            data->num_shafts = (uint32_t)atoi(value);
        }
        if(strcmp("Treadles",name)==0){
            data->num_treadles = (uint32_t)atoi(value);
        }
    }
    if(strcmp("TIEUP",section)==0){
        const char *p;
        uint32_t x;
        uint32_t num_tieup_entries = data->num_treadles * data->num_shafts;
        if(num_tieup_entries <= 0){
            printf("Tieup section appeared before specification of "
                    "Shafts and Treadles!\n");
            return 0;
        }
        if(data->tieup == 0){
            data->tieup = (uint8_t*)calloc(num_tieup_entries,sizeof(uint8_t));
        }
        x = data->num_treadles - (uint32_t)atoi(name);
        for(p = value; p != NULL;
                p = (const char*)strchr(p, ','), p = (p == NULL)? NULL: p+1) {
            uint32_t y = data->num_shafts - (uint32_t)atoi(p);
            data->tieup[x + y*data->num_treadles] = 1;
        }
    }
    if(strcmp("THREADING",section)==0){
        uint32_t w = data->warp.num_threads ;
        if(w <= 0){
            printf("ERROR! Threading section appeared before specification of "
                    "warp threads!\n");
            return 0;
        }
        if(data->threading == 0){
            data->threading = (uint32_t*)calloc(w,sizeof(uint32_t));
        }
        data->threading[((uint32_t)atoi(name)-1)] = data->num_shafts
            - (uint32_t)atoi(value);
    }
    if(strcmp("TREADLING",section)==0){
        uint32_t w = data->weft.num_threads ;
        if(w <= 0){
            printf("ERROR! Treadling section appeared before specification of "
                    "weft threads!\n");
            return 0;
        }
        if(data->treadling == 0){
            data->treadling = (uint32_t*)calloc(w,sizeof(uint32_t));
        }
        data->treadling[((uint32_t)atoi(name)-1)] = data->num_treadles
            - (uint32_t)atoi(value);
    }
    if(strcmp("COLOR PALETTE",section)==0){
        if(strcmp("Entries",name)==0){
            data->num_colors = (uint32_t)atoi(value);
        }
    }
    if(strcmp("COLOR TABLE",section)==0){
        if(data->num_colors==0){
            printf("ERROR! COLOR TABLE appeared before specification of "
                    "COLOR PALETTE\n");
            return 0;
        }
        if(data->colors == 0){
            data->colors = (float*)calloc(data->num_colors,sizeof(float)*3);
        }
        uint32_t i = (uint32_t)atoi(name)-1;
        //TODO(Vidar):Make sure all entries exist, handle different formats
        const char *p = value;
        data->colors[i*3+0] = (float)(atoi(p))/255.0f;
        p = strchr(p, ',')+1;
        data->colors[i*3+1] = (float)(atoi(p))/255.0f;
        p = strchr(p, ',')+1;
        data->colors[i*3+2] = (float)(atoi(p))/255.0f;
    }
    if(strcmp("WARP COLORS",section)==0){
        uint32_t w = data->warp.num_threads ;
        if(w <= 0){
            printf("ERROR! WARP COLORS section appeared before specification of "
                    "warp threads!\n");
            return 0;
        }
        if(data->warp.colors == 0){
            data->warp.colors = (uint32_t*)calloc(w,sizeof(uint32_t));
        }
        data->warp.colors[((uint32_t)atoi(name)-1)] = (uint32_t)atoi(value)-1;
    }
    if(strcmp("WEFT COLORS",section)==0){
        //TODO(Vidar): Join with the case above...
        uint32_t w = data->weft.num_threads ;
        if(w <= 0){
            printf("ERROR! WEFT COLORS section appeared before specification of "
                    "weft threads!\n");
            return 0;
        }
        if(data->weft.colors == 0){
            data->weft.colors = (uint32_t*)calloc(w,sizeof(uint32_t));
        }
        data->weft.colors[((uint32_t)atoi(name)-1)] = (uint32_t)atoi(value)-1;
    }
    return 1;
}
Пример #17
0
bool cKeyboard :: Key_Down( SDLKey key )
{
	// input was processed by the gui system
	if( CEGUI_Handle_Key_Down( key ) )
	{
		return 1;
	}

	// set key to 1
	m_keys[key] = 1;

	// ## first the internal keys

	// game exit
	if( key == SDLK_F4 && pKeyboard->Is_Alt_Down() )
	{
		game_exit = 1;
		return 1;
	}
	// fullscreen toggle
	else if( key == SDLK_RETURN && pKeyboard->Is_Alt_Down() )
	{
		pVideo->Toggle_Fullscreen();
		return 1;
	}
	// GUI copy
	else if( key == SDLK_c && pKeyboard->Is_Ctrl_Down() )
	{
		if( GUI_Copy_To_Clipboard() )
		{
			return 1;
		}
	}
	// GUI cut
	else if( key == SDLK_x && pKeyboard->Is_Ctrl_Down() )
	{
		if( GUI_Copy_To_Clipboard( 1 ) )
		{
			return 1;
		}
	}
	// GUI paste
	else if( key == SDLK_v && pKeyboard->Is_Ctrl_Down() )
	{
		if( GUI_Paste_From_Clipboard() )
		{
			return 1;
		}
	}

	// handle key in the current mode
	if( Game_Mode == MODE_LEVEL )
	{
		// processed by the level
		if( pActive_Level->Key_Down( key ) )
		{
			return 1;
		}
	}
	else if( Game_Mode == MODE_OVERWORLD )
	{
		// processed by the overworld
		if( pActive_Overworld->Key_Down( key ) )
		{
			return 1;
		}
	}
	else if( Game_Mode == MODE_MENU )
	{
		// processed by the menu
		if( pMenuCore->Key_Down( key ) )
		{
			return 1;
		}
	}
	else if( Game_Mode == MODE_LEVEL_SETTINGS )
	{
		// processed by the level settings
		if( pLevel_Editor->m_settings_screen->Key_Down( key ) )
		{
			return 1;
		}
	}

	// set fixed speed factor mode
	if( key == SDLK_F6 )
	{
		float fixed_speedfactor = string_to_float( Box_Text_Input( float_to_string( pFramerate->m_force_speed_factor, 2 ), "Set Fixed Speedfactor", 1 ) );

		// disable
		if( Is_Float_Equal( fixed_speedfactor, 0.0f ) )
		{
			pFramerate->Set_Fixed_Speedfacor( 0.0f );
			pHud_Debug->Set_Text( "Fixed speed factor disabled" );
		}
		// below minimum
		else if( fixed_speedfactor <= 0.04f )
		{
			pHud_Debug->Set_Text( "Fixed speed factor must be greater than 0.04" );
		}
		// enable
		else
		{
			pFramerate->Set_Fixed_Speedfacor( fixed_speedfactor );
			pHud_Debug->Set_Text( "Fixed speed factor enabled" );
		}
	}
	// take a screenshot
	else if( key == pPreferences->m_key_screenshot )
	{
		pVideo->Save_Screenshot();
	}
	// pause the game
	else if( key == SDLK_PAUSE )
	{
		Draw_Static_Text( "Pause", &yellow, &lightgreyalpha64 );
	}
	// load a level
	else if( key == SDLK_l && pKeyboard->Is_Ctrl_Down() && !( Game_Mode == MODE_OVERWORLD && pOverworld_Manager->m_debug_mode ) && Game_Mode != MODE_LEVEL_SETTINGS )
	{
		pLevel_Editor->Function_Load();
	}
	// load an overworld
	else if( key == SDLK_w && pKeyboard->Is_Ctrl_Down() && !( Game_Mode == MODE_OVERWORLD && pOverworld_Manager->m_debug_mode ) && Game_Mode != MODE_LEVEL_SETTINGS )
	{
		pWorld_Editor->Function_Load();
	}
	// sound toggle
	else if( key == SDLK_F10 )
	{
		pAudio->Toggle_Sounds();

		if( !pAudio->m_sound_enabled )
		{
			pHud_Debug->Set_Text( "Sound disabled" );
		}
		else
		{
			pHud_Debug->Set_Text( "Sound enabled" );
		}
	}
	// music toggle
	else if( key == SDLK_F11 )
	{
		pAudio->Toggle_Music();

		if( !pAudio->m_music_enabled )
		{
			pHud_Debug->Set_Text( "Music disabled" );
		}
		else
		{
			pHud_Debug->Set_Text( "Music enabled" );
		}
	}
	// debug mode
	else if( key == SDLK_d && pKeyboard->Is_Ctrl_Down() )
	{
		if( game_debug )
		{
			pHud_Debug->Set_Text( "Debug mode disabled" );
		}
		else
		{
			pFramerate->m_fps_worst = 100000;
			pFramerate->m_fps_best = 0;
			pHud_Debug->Set_Text( "Debug mode enabled" );
		}

		game_debug = !game_debug;
	}
	// performance mode
	else if( key == SDLK_p && pKeyboard->Is_Ctrl_Down() )
	{
		if( game_debug_performance )
		{
			pHud_Debug->Set_Text( "Performance debug mode disabled" );
		}
		else
		{
			pFramerate->m_fps_worst = 100000;
			pFramerate->m_fps_best = 0;
			pHud_Debug->Set_Text( "Performance debug mode enabled" );
		}

		game_debug_performance = !game_debug_performance;
	}

	return 0;
}
Пример #18
0
void string_to_float_for_eus(char* in, double* buf){
  buf[0] = string_to_float(in) ;
}
Пример #19
0
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
      static int i=0;

  switch(__even_in_range(UCA0IV,4))
  {
  case 0:break;                             // Vector 0 - no interrupt
  case 2:                                   // Vector 2 - RXIFG
    while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?
    UCA0TXBUF = UCA0RXBUF;                  // TX -> RXed character
    //save string
    if(RX_flag == 0)  //进中断则不是完成接受状态
    {
        if(UCA0RXBUF!='\n')
        {
            a[i++]=UCA0RXBUF;
        }
        else
        {
            a[i]='\0';
            i=0;
            RX_flag = 1;
            strp = str;
        }

    }


      if(RX_flag == 1)
      {
              RX_flag = 0;
              //function switch
//            if(strcmp("on",str)==0)
//            {
//                SET_flag = 1;
//            }
              if(strcmp("slp",str)==0)
              {
                  function = 3;
    //            set_ack_flag = 1;
                  state = 0;
                  mode = 0;
                  fct_stc_flag = 1;
//                OLED_Clear(0x00);
//                OLED_OFF();
                  __bic_SR_register_on_exit(LPM3_bits);
              }
              else if(strcmp("out",str)==0)
              {
                  function = 1;
                  mode = 0;
//                OLED_ShowStr(0,0,"Current_bt",11,1); //6*8
                  SET_flag = 1;
                  fct_stc_flag = 1;
                  __bic_SR_register_on_exit(LPM3_bits);
    //            state = 0;
              }
              else if(strcmp("test",str)==0)
              {
                  function = 2;
//                OLED_ShowStr(0,0,"R_test",11,1); //6*8
                  fct_stc_flag = 1;
    //            state = 0;
                  __bic_SR_register_on_exit(LPM3_bits);
              }
              else if(strcmp("off",str)==0)
              {
                  function = 0;
    //            set_ack_flag = 1;
                  state = 0;
                  mode = 0;
                  fct_stc_flag = 1;
//                OLED_Clear(0x00);
//                OLED_OFF();
                  __bic_SR_register_on_exit(LPM3_bits);

              }



              if(SET_flag)
              {
                  switch(function)
                  {
                  //Done nothing
                    case 0:
                    {
                        ;
                    }
                    break;

                    //output current
                    case 1:
                    {
                          if(strcmp("I:",str)==0)
                          {
                            state = 1;
    //                      __bic_SR_register_on_exit(LPM3_bits);
                            break;
                          }
                          else if(strcmp("Sts",str)==0 | strcmp("sts",str)==0)
                          {
                            state = 2;
    //                      __bic_SR_register_on_exit(LPM3_bits);
                            break;
                          }

                          if(state == 1) //wait for current
                          {
                              Datai = atof(str);
                              I_flag = 1;

                          }
                          else if(state == 2)
                          {
                              stalls = (int)(string_to_float(str));
                              stalls_flag = 1;
    //                        state = 201;
                          }

                          if(stalls_flag!=0 & I_flag!=0)
                          {
                              stalls_flag = 0;
                              I_flag = 0;

                              switch(stalls)
                              {
                                  case 0:
                                      break;
                                  case 1:
                                  {
    //                                state = 101;
                                      Datavin= Datai*30.03; // 不同的档位输入给定不同
                                      state = 0;
                                      SET_flag= 0;
                                      set_ack_flag = 1;
                                      __bic_SR_register_on_exit(LPM3_bits);
                                  }
                                  break;

                                  case 2:
                                  {
                                      state = 0;
                                      SET_flag = 0;
                                      set_ack_flag = 1;
                                      __bic_SR_register_on_exit(LPM3_bits);
                                  }
                                  break;

                                  case 3:
                                  {
                                      state = 0;
                                      SET_flag = 0;
                                      set_ack_flag = 1;
                                      __bic_SR_register_on_exit(LPM3_bits);
                                  }
                                  break;
                              }

                          }
                    }
                    break;
                    //end of output current

                    case 2:   //R_test
                    {

                        __bic_SR_register_on_exit(LPM3_bits);
                    }
                    break;

                    case 3:
                    {
                        ;  //shouldn't excute to this place
                    }
                    break;

                  }
              }
              //end of set
      }//end of receive


    break;
  case 4:break;                             // Vector 4 - TXIFG
  default: break;  
  }
}