Exemplo n.º 1
9
int MetaConfig::flushNodeSrvs(TiXmlHandle *meta)
{
	std::vector<NodeService> tmp;
	TiXmlHandle srvs = meta->FirstChildElement("services");
	if(srvs.Element()){
		TiXmlHandle srv = srvs.FirstChildElement("service");
		while(srv.Element()){
			NodeService ns;
			loadInt(&srv, "gid", ns.gid, -1);
			loadString(&srv, "name", ns.service, "");
			loadString(&srv, "ip", ns.ip, "");
			loadInt(&srv, "port", ns.port, -1);

			if(!(ns.gid != -1 && !ns.service.empty() && !ns.ip.empty() && ns.port != -1)){
				std::cerr << "load service error name:" << ns.service << " ip:" << ns.ip << " port:" << ns.port << " node:" << ns.gid<< std::endl;
				return -1;
			}

			tmp.push_back(ns);
			srv = srv.Element()->NextSibling("service");
		}
		std::sort(tmp.begin(), tmp.end());
		std::unique(tmp.begin(), tmp.end());
	}
	boost::mutex::scoped_lock lock(mtx);
	ndSrvs.swap(tmp);
	return 0;
}
Exemplo n.º 2
0
DialogueData* DataLoader::loadDialogueData(FILE *fp) {
    bool dialogueDataNotExists;
    fread(&dialogueDataNotExists, 1, sizeof(bool), fp);

    DialogueData *dialogueData;

    if(dialogueDataNotExists) {
        return NULL;
    } else {
        dialogueData = new DialogueData();

        int itemNumber;
        fread(&itemNumber, 1, sizeof(int), fp);

        for(int i = 0; i < itemNumber; i++) {
            DialogueItemData *dialogueItemData = new DialogueItemData();

            fread(&dialogueItemData->type, 1, sizeof(int), fp);
            if(dialogueItemData->type == DialogueItemData::TYPE_MESSAGE) {
                dialogueItemData->message = std::string(loadString(fp));
                dialogueItemData->associatedImage = std::string(loadString(fp));
                fread(&dialogueItemData->associatedImageAtCenter, 1, sizeof(bool), fp);
            } else {
                fread(&dialogueItemData->procedureId, 1, sizeof(bool), fp);
            }

            dialogueData->dialogueItems.push_back(dialogueItemData);
        }
    }

    return dialogueData;
}
BOOL OMsgs::ask(const ULONG titleID, const ULONG msgID)
{
 if ((loadString(msgID, 2*CCHMAXPATH, Msg)) && (loadString(titleID, 60, Title)))
   return(ask(Title, Msg));
 else
   return(FALSE);
}
Exemplo n.º 4
0
MainWindow::MainWindow(HINSTANCE instance)
:	m_inDialog(false),
	m_parent(nullptr),
	m_instance(instance),
	m_emptyLink(nullptr)
{
	enableLogging(settings::settings()[L"general"][L"log"].asNumber() != 0);

	LOG(L"creating MainWindow");

	registerWindowClass(instance, loadString(instance, IDC_LAUNCHGRID).c_str());

	m_wnd = createMainWindow();

	createFonts();

	LOG(L"creating static controls");
	m_titleLabel = CreateWindow(L"STATIC", loadString(instance, IDS_APP_TITLE).c_str(), WS_CHILD | WS_VISIBLE, 8, 4, 120, 30, m_wnd, nullptr, instance, nullptr);
	SendMessage(m_titleLabel, WM_SETFONT, (WPARAM)m_titleFont, 0);

	m_menu = CreateWindow(L"BUTTON", L"Menu", WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 240 - 8 - 24, 4, 24, 24, m_wnd, nullptr, instance, nullptr);
	SetWindowLong(m_menu, GWL_ID, IDC_MENU);

	createControls();

	LOG(L"showing window");
	ShowWindow(m_wnd, settings::settings()[L"general"][L"bottomWindow"].asNumber() ? SW_SHOWNOACTIVATE : SW_SHOW);
	if (settings::settings()[L"general"][L"bottomWindow"].asNumber())
	{
		LOG(L"moving window to background");
		SetWindowPos(m_wnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
	}
	UpdateWindow(m_wnd);
}
Exemplo n.º 5
0
static Group *_LoadGroupList(FILE *file, Group *parent, int expected_indent,
	struct gcontext *gc) {
    Group *g;
    char *n;
    int i, ch;
    Group **glist=NULL;
    int gmax = 0;

    if ( expected_indent!=gc->found_indent )
return( NULL );

    n = loadString(file,gc);
    if ( n==NULL )
return( NULL );
    g = chunkalloc(sizeof(Group));
    g->parent = parent;
    g->name = n;
    if ( (ch = getc(file))==':' )
	ch = getc(file);
    while ( ch==' ' )
	ch = getc(file);
    if ( ch=='1' )
	g->unique = true;
    else if ( ch!='0' ) {
	GroupFree(g);
return( NULL );
    }
    while ( (ch = getc(file))==' ' );
    if ( ch=='"' ) {
	ungetc(ch,file);
	g->glyphs = loadString(file,gc);
	if ( g->glyphs==NULL ) {
	    GroupFree(g);
return( NULL );
	}
	lineCountIndent(file,gc);
    } else if ( ch=='\n' || ch=='\r' ) {
	ungetc(ch,file);
	lineCountIndent(file,gc);
	for ( i=0 ;; ++i ) {
	    if ( i>=gmax ) {
		gmax += 10;
		glist = realloc(glist,gmax*sizeof(Group *));
	    }
	    glist[i] = _LoadGroupList(file, g, expected_indent+1, gc);
	    if ( glist[i]==NULL )
	break;
	}
	g->kid_cnt = i;
	if ( i!=0 ) {
	    g->kids = malloc(i*sizeof(Group *));
	    memcpy(g->kids,glist,i*sizeof(Group *));
	    free(glist);
	}
    }
return( g );
}
Exemplo n.º 6
0
int Fujimap::load(const char* index){
  ifstream ifs(index);
  if (!ifs){
    what_ << "cannot open " << index << endl;
    return -1;
  }

  uint64_t code2valSize = 0;
  ifs.read((char*)(&code2valSize), sizeof(code2valSize));
  code2val_.resize(code2valSize);
  for (uint64_t i = 0; i < code2valSize; ++i){
    loadString(code2val_[i], ifs);
  }
  for (size_t i = 0; i < code2val_.size(); ++i){
    val2code_[code2val_[i]] = i;
  }

  ifs.read((char*)(&seed_), sizeof(seed_));
  ifs.read((char*)(&fpLen_), sizeof(fpLen_));
  ifs.read((char*)(&tmpN_), sizeof(tmpN_));


  uint64_t tmpEdgeSize = 0;
  ifs.read((char*)(&tmpEdgeSize), sizeof(tmpEdgeSize));

  for (uint64_t i = 0; i < tmpEdgeSize; ++i){
    string s;
    loadString(s, ifs);
    uint32_t code = 0;
    ifs.read((char*)(&code), sizeof(uint32_t));
    tmpEdges_[s] = code;
  }

  uint64_t fbs_Size = 0;
  ifs.read((char*)(&fbs_Size), sizeof(fbs_Size));
  fbs_.resize(fbs_Size);

  for (size_t i = 0; i < fbs_.size(); ++i){
    uint64_t fbs_InSize = 0;
    ifs.read((char*)(&fbs_InSize), sizeof(fbs_InSize));
    fbs_[i].resize(fbs_InSize);
    for (size_t j = 0; j < fbs_[i].size(); ++j){
      fbs_[i][j].load(ifs);
    }
  }

  if (!ifs){
    what_ << "read error " << index << endl;
    return -1;
  }
  
  return 0;
}
Exemplo n.º 7
0
string VM::getCinderDartScript()
{
	if( mCinderDartScriptDataSource )
		return loadString( mCinderDartScriptDataSource );

	for( auto dirIt = mImportSearchDirectories.rbegin(); dirIt != mImportSearchDirectories.rend(); ++dirIt ) {
		auto cinderDartPath = *dirIt / "cinder.dart";
		if( fs::exists( cinderDartPath ) )
			return loadString( loadFile( cinderDartPath ) );
	}

	throw DartException( "no provided cinder.dart script file" );
}
Exemplo n.º 8
0
int main(int argc, char *argv[]) {
  TEST_NAME();

  auto luaScript = LuaScript();

  luaScript.loadString("print('hello world!')");

  luaScript.loadScript("test.lua");

  luaScript.setGlobal("PI", 3.14);
  auto PI_value = luaScript.getGlobal_float("PI");

  TEST_EQUAL(PI_value, 3.14, "global - float");

  luaScript.setGlobal("numChildren", 3);

  auto numChildren = luaScript.getGlobal_int("numChildren");
  
  TEST_EQUAL(numChildren, 3, "global - int");

  luaScript.setGlobal("FirstName", "Benjamin Zaporzan");

  auto firstName = luaScript.getGlobal_string("FirstName");

  TEST_EQUAL(firstName, "Benjamin Zaporzan", "global - string");

  auto floatValues = floatArrayType {1.1, 2.2, 3.3};

  luaScript.setGlobal("Position", floatValues);
  luaScript.loadString("for i,v in ipairs(Position) do print(i,v) end");

  auto floatValues2 = luaScript.getGlobal_floatArray("Position");
  
  TEST_EQUAL(floatValues, floatValues2, "global - float array");

  for (auto i : floatValues2) {
    std::cout << i << std::endl;
  }

  auto intValues = intArrayType { 1, 2, 3 };

  luaScript.setGlobal("oneTwoThree", intValues);
  luaScript.loadString("for i,v in ipairs(oneTwoThree) do print(i,v) end");

  auto intValues2 = luaScript.getGlobal_intArray("oneTwoThree");

  TEST_EQUAL(intValues, intValues2, "global - int array");

  return 0;
}
Exemplo n.º 9
0
char HAttributeGroup::load(AAttributeWrap & wrap)
{
	int t = 0;
	readIntAttr(".attr_typ", &t);
	
	if(t == AAttribute::aNumeric) {
		int tn = 0;
		if(hasNamedAttr(".num_typ")) {
			readIntAttr(".num_typ", &tn);
			loadNumeric( wrap.createNumeric(tn) );
		}
	}
	else if(t == AAttribute::aEnum) {
		loadEnum( wrap.createEnum() );
	}
	else if(t == AAttribute::aString) {
		loadString( wrap.createString() );
	}
	else if(t == AAttribute::aCompound) {
		loadCompound( wrap.createCompound() );
	}
	
	AAttribute * data = wrap.attrib();
	if(!data) return 0;
	
	std::string lnm;
	readStringAttr(".longname", lnm);
	
	data->setLongName(lnm);
	data->setShortName(lastName());
	return 1; 
}
Exemplo n.º 10
0
/**
 * @brief cwRegionLoadTask::loadTeamMember
 * @param protoTeamMember
 * @return
 */
cwTeamMember cwRegionLoadTask::loadTeamMember(const CavewhereProto::TeamMember& protoTeamMember)
{
    cwTeamMember teamMember;
    teamMember.setName(loadString(protoTeamMember.name()));
    teamMember.setJobs(loadStringList(protoTeamMember.jobs()));
    return teamMember;
}
Exemplo n.º 11
0
inline bool addFile(CListCtrl *lFiles, string filename, __int64 size){
	char buffer[16];
	HICON ico = NULL;
	int ico_id;
	CImageList *imgLst = NULL;

	if(size >= (__int64)4*1024*1024*1024){
		MessageBox(0, loadString(IDS_TOO_BIG_FILE), "KGB Archiver", 0);
		return false;
	}

	ico = getIcon(filename);

	if(ico != NULL){
		imgLst = lFiles->GetImageList(LVSIL_SMALL);
		if(imgLst == NULL){
			imgLst = new CImageList();
			imgLst->Create(16, 16, ILC_COLORDDB, 0, INT_MAX);
			imgLst->SetBkColor(0x00FFFFFF);
		}
		ico_id = imgLst->Add(ico);
		lFiles->SetImageList(imgLst, LVSIL_SMALL);
		lFiles->InsertItem(lFiles->GetItemCount(), "", ico_id);
	}else
		lFiles->InsertItem(lFiles->GetItemCount(), ""); 


	lFiles->SetItemText(lFiles->GetItemCount()-1, 0, filename.c_str());
	
	sprintf(buffer, "%s", convertUnits(size));
	lFiles->SetItemText(lFiles->GetItemCount()-1, 1, buffer);

	return true;
}
Exemplo n.º 12
0
/**
 * @brief cwRegionLoadTask::loadNoteStation
 * @param protoNoteStation
 * @return
 */
cwNoteStation cwRegionLoadTask::loadNoteStation(const CavewhereProto::NoteStation& protoNoteStation)
{
    cwNoteStation noteStation;
    noteStation.setName(loadString(protoNoteStation.name()));
    noteStation.setPositionOnNote(loadPointF(protoNoteStation.positiononnote()));
    return noteStation;
}
Exemplo n.º 13
0
static bool loadResourceImaptext(file_t fp)
{
    size_t i;
    U16 u16Temp;

    if (sysfile_read(fp, &u16Temp, sizeof(u16Temp), 1) != 1)
    {
        return false;
    }
    screen_nbr_imaptext = letoh16(u16Temp);

    screen_imaptext = sysmem_push(screen_nbr_imaptext * sizeof(*screen_imaptext));
    if (!screen_imapsteps)
    {
        return false;
    }

    for (i = 0; i < screen_nbr_imaptext; ++i)
    {
        if (!loadString(fp, (char **)(&(screen_imaptext[i])), 0xFE))
        {
            return false;
        }
    }
    return true;
}
Exemplo n.º 14
0
/**
 * @brief cwRegionLoadTask::loadCave
 * @param protoCave
 * @param cave
 */
void cwRegionLoadTask::loadCave(const CavewhereProto::Cave& protoCave, cwCave *cave)
{
    QString name = loadString(protoCave.name());
    cwUnits::LengthUnit lengthUnit = (cwUnits::LengthUnit)protoCave.lengthunit();
    cwUnits::LengthUnit depthUnit = (cwUnits::LengthUnit)protoCave.depthunit();

    QList<cwTrip*> trips;
    trips.reserve(protoCave.trips_size());

    cave->setName(name);
    cave->length()->setUnit(lengthUnit);
    cave->depth()->setUnit(depthUnit);

    for(int i = 0; i < protoCave.trips_size(); i++) {
        cwTrip* trip = new cwTrip();
        loadTrip(protoCave.trips(i), trip);
        cave->addTrip(trip);
    }

    cwStationPositionLookup stationLookup = loadStationPositionLookup(protoCave.stationpositionlookup());
    cave->setStationPositionLookup(stationLookup);

    if(protoCave.has_stationpositionlookup()) {
        cave->setStationPositionLookupStale(protoCave.stationpositionlookupstale());
    }
}
Exemplo n.º 15
0
//--------------------------------------------------------------
void  ofxCameraMove::getNumberOfCamFormXML(string folder){
    
    
    ofDirectory checkDir;
    checkDir.isDirectoryEmpty(folder);
    
    vector<string> xmlPath = loadString(folder);

    for(int a = 0;a< xmlPath.size();a++){
        ofQuaternion startQuat;
        ofVec3f startPos;
        ofxXmlSettings XML;
        XML.loadFile(xmlPath[a]);
        
        startPos.set(ofVec3f(XML.getValue("camera:getGlobalPositionX", 0.0),
                             XML.getValue("camera:getGlobalPositionY",0.0),
                             XML.getValue("camera:getGlobalPositionZ",  0.0)));

        float angle =  XML.getValue("camera:angle", 0.0);
        float x =      XML.getValue("camera:x",  0.0);
        float y =      XML.getValue("camera:y",  0.0);
        float z =      XML.getValue("camera:z",  0.0);

        startQuat.makeRotate(angle, x,y,z);
        target.push_back(&camArray[a]);
        target[a]->setGlobalPosition(startPos);
        target[a]->setGlobalOrientation(startQuat);

    }
    if(xmlPath.size() != 0){

            cutNow(0);
    }
}
Exemplo n.º 16
0
bool CLngRc::getHint(UINT id, LPWSTR lpBuffer, size_t nBufferMax)
{
	if (!gpLng)
	{
		_ASSERTE(gpLng != NULL);
		return loadString(id, lpBuffer, nBufferMax);
	}

	// IDM__MIN_MNU_ITEM_ID
	UINT idDiff = (id < IDM__MIN_MNU_ITEM_ID) ? 0 : IDM__MIN_MNU_ITEM_ID;
	INT_PTR idx = (id - idDiff);
	_ASSERTE(idx >= 0);

	MArray<LngRcItem>& arr = (id < IDM__MIN_MNU_ITEM_ID) ? gpLng->m_CmnHints : gpLng->m_MnuHints;

	if (arr.size() > idx)
	{
		const LngRcItem& item = arr[idx];

		if (item.Processed)
		{
			if (item.Str && *item.Str)
			{
				lstrcpyn(lpBuffer, item.Str, nBufferMax);
				// Succeeded
				return true;
			}
			// No such resource
			goto wrap;
		}
	}

	// Use binary search to find resource
	if (loadString(id, lpBuffer, nBufferMax))
	{
		// Succeeded
		return true;
	}

	// Don't try to load it again
	gpLng->SetResource(arr, idx, NULL, false);

wrap:
	if (lpBuffer && nBufferMax)
		lpBuffer[0] = 0;
	return false;
}
Exemplo n.º 17
0
bool GameData::loadObjectSkills(FILE *fp) {
	for(std::vector<GameObjectClass*>::iterator it = objectList->begin(); it != objectList->end(); ++it) {
		GameObjectClass *gameObject = *it;

		int nroListaHabilidades;

                fread(&nroListaHabilidades, 1, sizeof(int), fp);

		for(int j = 0; j < nroListaHabilidades; j++) {
			SkillData* skillData = new SkillData();

			fread(&skillData->id, 1, sizeof(int), fp);
			fread(&skillData->intensity, 1, sizeof(int), fp);
			fread(&skillData->magicCost, 1, sizeof(int), fp);
			fread(&skillData->level, 1, sizeof(int), fp);


			int idSkill;
			fread(&skillData->nroSkill, 1, sizeof(int), fp);

			fread(&skillData->isMagical, 1, sizeof(int), fp);

			skillData->sound = std::string(loadString(fp));

			int idSkillData;
			fread(&idSkillData, 1, sizeof(int), fp);
			int idSkillProvider;
			fread(&idSkillProvider, 1, sizeof(int), fp);

			if(idSkillData == -1) {
				skillData->skillObject = NULL;
			} else {
				skillData->skillObject = searchGameObjectById(idSkillData);
				if(skillData->skillObject == NULL) {
					printf("Erro na obtenção de um objeto (skillObject) de id: %d\n", idSkillData);
					exit(1);
				}
			}


			if(idSkillProvider == -1) {
				skillData->skillProvider = NULL;
			} else {
				skillData->skillProvider = searchGameObjectById(idSkillProvider);
				if(skillData->skillProvider == NULL) {
					printf("Erro na obtenção de um objeto (skillProvider) de id: %d\n", idSkillProvider);
					exit(1);
				}
			}

			gameObject->listaHabilidades.push_back(skillData);



		}
	}

	return true;
}
Exemplo n.º 18
0
bool TextSymbol::loadImpl(QIODevice* file, int version, Map* map)
{
	int temp;
	file->read((char*)&temp, sizeof(int));
	color = (temp >= 0) ? map->getColor(temp) : NULL;
	loadString(file, font_family);
	file->read((char*)&font_size, sizeof(int));
	file->read((char*)&bold, sizeof(bool));
	file->read((char*)&italic, sizeof(bool));
	file->read((char*)&underline, sizeof(bool));
	file->read((char*)&line_spacing, sizeof(float));
	if (version >= 13)
		file->read((char*)&paragraph_spacing, sizeof(double));
	if (version >= 14)
		file->read((char*)&character_spacing, sizeof(double));
	if (version >= 12)
		file->read((char*)&kerning, sizeof(bool));
	if (version >= 19)
		loadString(file, icon_text);
	if (version >= 20)
	{
		file->read((char*)&framing, sizeof(bool));
		file->read((char*)&temp, sizeof(int));
		framing_color = map->getColor(temp);
		file->read((char*)&framing_mode, sizeof(int));
		file->read((char*)&framing_line_half_width, sizeof(int));
		file->read((char*)&framing_shadow_x_offset, sizeof(int));
		file->read((char*)&framing_shadow_y_offset, sizeof(int));	
	}
	if (version >= 13)
	{
		file->read((char*)&line_below, sizeof(bool));
		file->read((char*)&temp, sizeof(int));
		line_below_color = (temp >= 0) ? map->getColor(temp) : NULL;
		file->read((char*)&line_below_width, sizeof(int));
		file->read((char*)&line_below_distance, sizeof(int));
		int num_custom_tabs;
		file->read((char*)&num_custom_tabs, sizeof(int));
		custom_tabs.resize(num_custom_tabs);
		for (int i = 0; i < num_custom_tabs; ++i)
			file->read((char*)&custom_tabs[i], sizeof(int));
	}
	
	updateQFont();
	return true;
}
Exemplo n.º 19
0
bool TemplateTrack::loadTypeSpecificTemplateConfiguration(QIODevice* stream, int version)
{
	if (version >= 30)
		loadString(stream, track_crs_spec);
	else
		track_crs_spec = QString::fromLatin1("+proj=latlong +datum=WGS84");
	return true;
}
Exemplo n.º 20
0
void GUI_manager::enter_sync_mode(bool verbose) {
	char	b_title1[500];
	char	b_title2[500];
	int		item = ListView_GetItemCount(IMG_list);
	vector<internal_file> TRE_file_list;

	sync_mode = false;
	if( connect(true) == false )
		return;

	SetSelection(IMG_list,0);
	while( remove_IMG() )
		;

	loadString(IDS_SYNC_START,b_title1,sizeof(b_title1));
	loadString(IDS_SYNC_TITLE,b_title2,sizeof(b_title2));

	if( verbose ) {
		if( MessageBox(NULL,b_title1,b_title2,MB_ICONERROR | MB_YESNO) == IDYES ) {
			sync_mode = true;
		}
	} else 
		sync_mode = true;
	
	if( sync_mode ) {
		EnableWindow(GetDlgItem (gui_hwndDlg, IDC_IMG_FILE),FALSE);
		EnableWindow(GetDlgItem (gui_hwndDlg, IDC_EXE_FILE),FALSE);
		EnableWindow(GetDlgItem (gui_hwndDlg, IDC_STORE_FILES),FALSE);
		

		SetCursor (g_hWaitCursor);
			
		if( uploader->download_directory(&TRE_file_list) == true ) {
			item = ListView_GetItemCount(IMG_list);
			for( vector<internal_file>::iterator f = TRE_file_list.begin(); f < TRE_file_list.end(); f++ ) {
				InsertItem(IMG_list, item , LPARAM("%s"),(*f).region_name.c_str());
				SetSubItemText (IMG_list, item, 1, "%s", (*f).TRE_map_name.c_str());
				SetSubItemText (IMG_list, item, 2, "%s", (*f).file_name.c_str());
				SetSubItemText (IMG_list, item, 3, "%s", (*f).get_internal_short_name());
			}
			AutoSizeColumns(IMG_list);
			show_size();
		}
		SetCursor (g_hArrowCursor);
	}
}
Exemplo n.º 21
0
void dCompress::OnClose()
{
	// TODO: Add your message handler code here and/or call default
	if(MessageBox(loadString(IDS_ARE_YOU_SURE_CANCEL), "KGB Archiver", MB_YESNO) == IDNO)
		return;
	EndDialog(IDCANCEL);
	CDialog::OnClose();
}
Exemplo n.º 22
0
void ConfigFile::loadPurpleAccountSettings(Configuration &configuration) {
	if (!m_loaded)
		return;
	if (!g_key_file_has_group(keyfile, "purple"))
		return;

	PurplePlugin *plugin = purple_find_prpl(Transport::instance()->protocol()->protocol().c_str());
	PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
	for (GList *l = prpl_info->protocol_options; l != NULL; l = l->next) {
		PurpleAccountOption *option = (PurpleAccountOption *) l->data;
		PurpleAccountSettingValue v;
		v.type = purple_account_option_get_type(option);
		std::string key(purple_account_option_get_setting(option));

		switch (v.type) {
			case PURPLE_PREF_BOOLEAN:
				if (g_key_file_has_key(keyfile, "purple", key.c_str(), NULL)) {
					loadBoolean(v.b, "purple", key);
					configuration.purple_account_settings[key] = v;
				}
// 				else
// 					v.b = purple_account_option_get_default_bool(option);
				break;

			case PURPLE_PREF_INT:
				if (g_key_file_has_key(keyfile, "purple", key.c_str(), NULL)) {
					loadInteger(v.i, "purple", key);
					configuration.purple_account_settings[key] = v;
				}
// 				else
// 					v.i = purple_account_option_get_default_int(option);
				break;

			case PURPLE_PREF_STRING:
				if (g_key_file_has_key(keyfile, "purple", key.c_str(), NULL)) {
					std::string str;
					loadString(str, "purple", key);
					v.str = g_strdup(str.c_str());
					configuration.purple_account_settings[key] = v;
				}
// 				else {
// 					const char *str = purple_account_option_get_default_string(option);
// 					v.str = str ? g_strdup(str) : NULL;
// 				}
				break;

			case PURPLE_PREF_STRING_LIST:
				if (g_key_file_has_key(keyfile, "purple", key.c_str(), NULL)) {
					loadStringList(v.strlist, "purple", key);
					configuration.purple_account_settings[key] = v;
				}
				break;

			default:
				continue;
		}
	}
}
Exemplo n.º 23
0
bool DataLoader::loadTilesetList(FILE *fp) {
    int num_tilesets;

    fread(&num_tilesets, 1, sizeof(int), fp);
    gameData->tileSetList = new std::vector<TileSet*>();

    int i;
    for(i = 0; i < num_tilesets; i++) {
        TileSet *tileSet = new TileSet();

        fread(&(tileSet->id), 1, sizeof(int), fp);

        tileSet->file = std::string(loadString(fp));
        tileSet->name = std::string(loadString(fp));


        fread(&(tileSet->width), 1, sizeof(int), fp);
        fread(&(tileSet->height), 1, sizeof(int), fp);

        fread(&(tileSet->maxX), 1, sizeof(int), fp);
        fread(&(tileSet->maxY), 1, sizeof(int), fp);

        fread(&(tileSet->tileSize), 1, sizeof(int), fp);


        tileSet->collisionMatrix.resize(boost::extents[tileSet->maxX][tileSet->maxY]);
        int j, k;
        for(j = 0; j < tileSet->maxX; j++) {
            for(k = 0; k < tileSet->maxY; k++) {
                int valor;
                fread(&valor, 1, sizeof(int), fp);
                tileSet->collisionMatrix[j][k] = valor;
            }
        }

        tileSet->reloadTilesetImage();

        gameData->tileSetList->push_back(tileSet);



    }

    return true;
}
Exemplo n.º 24
0
bool connect_to_gps(map_uploader* uploader,bool detect) {
	LRESULT	port;
	LRESULT	speed;
	char	b_port[10];
	char	b_title1[200];
	char	b_title2[200];
	//if( uploader->connetcion_established() && !uploader->is_simulator() )
	//	return true;

	speed = SendMessage(gui_manager.SPEED_list,CB_GETCURSEL , 0, 0);
	if( speed > 0 ) {
		switch( speed ) {
			case 1: uploader->connection_parameter(57600);break;
			case 2: uploader->connection_parameter(38400);break;
			case 3: uploader->connection_parameter(19200);break;
			default: uploader->connection_parameter(9600);break;
		}
	}

	port = SendMessage(gui_manager.PORT_list,CB_GETCURSEL , 0, 0);
	if( port > 0 ) {
		SendMessage(gui_manager.PORT_list,CB_GETLBTEXT , port, LPARAM(b_port));
		if( detect_port(uploader,b_port) ) 
			return true;
		return false;
	}

	if( detect_port(uploader,"usb") ) return true;
	if( detect_port(uploader,"sim",detect) ) return true;
	if( detect_port(uploader,"com1") ) return true;
	if( detect_port(uploader,"com2") ) return true;
	if( detect_port(uploader,"com3") ) return true;
	if( detect_port(uploader,"com4") ) return true;
	if( detect_port(uploader,"com5") ) return true;
	if( detect_port(uploader,"com6") ) return true;
	if( detect_port(uploader,"com7") ) return true;
	if( detect_port(uploader,"com8") ) return true;
	if( detect_port(uploader,"com9") ) return true;

	loadString(IDS_NO_GPS,b_title1,sizeof(b_title1));
	loadString(IDS_NO_GPS_TITLE,b_title2,sizeof(b_title2));

	MessageBox(NULL,b_title1,b_title2,MB_ICONERROR | MB_OK);
	return false;
}
Exemplo n.º 25
0
void readConfigure(const char* name)
{
	loadString();
	FILE* fp = fopen(name, "r");
	if(fp == NULL)
		return;
	fscanf(fp, "%lu %lu %lu", &DefaultGridWidth, &DefaultGridHeight, &DefaultMineNum);
	fclose(fp);
}
Exemplo n.º 26
0
/**
 * @brief cwRegionLoadTask::loadLead
 * @param protoLead
 * @return Return's a lead from the a protoLead
 */
cwLead cwRegionLoadTask::loadLead(const CavewhereProto::Lead &protoLead)
{
    cwLead lead;
    lead.setPositionOnNote(loadPointF(protoLead.positiononnote()));
    lead.setDescription(loadString(protoLead.description()));
    lead.setSize(loadSizeF(protoLead.size()));
    lead.setCompleted(protoLead.completed());
    return lead;
}
Exemplo n.º 27
0
/**
 * @brief cwRegionLoadTask::loadStringList
 * @param protoStringList
 * @return
 */
QStringList cwRegionLoadTask::loadStringList(const QtProto::QStringList &protoStringList)
{
    QStringList list;
    list.reserve(protoStringList.strings_size());
    for(int i = 0; i < protoStringList.strings_size(); i++) {
        list.append(loadString(protoStringList.strings(i)));
    }
    return list;
}
Exemplo n.º 28
0
void setControlText(int id, CWnd *wnd) {
  const String title = getWindowText(wnd);
  if(title.length() > 0 && title[0] == '{') {
    String newTitle = loadString(id);
    wnd->SetWindowText(newTitle.cstr());
  }

  for(CWnd *child = wnd->GetWindow(GW_CHILD); child; child = child->GetNextWindow()) {
//    id = child->GetDlgCtrlID();
    const String text = getWindowText(child);
    if(text.length() > 0 && text[0] == '{') {
      const String label = loadString(child->GetDlgCtrlID());
      if(label.length() > 0) {
        setWindowText(child, label);
      }
    }
  }
}
Exemplo n.º 29
0
int CALLBACK KEY_Dialog(HWND hwndDlg, UINT uMsg,WPARAM wParam, LPARAM lParam) {

	switch (uMsg) {
		case WM_INITDIALOG:
			SendMessage(GetDlgItem (hwndDlg, IDC_EDIT_ENTER_KEY),WM_SETTEXT,0,LPARAM("enter unlock key here"));
			break;
        case WM_COMMAND:
			switch(LOWORD(wParam)) {
				case IDC_ADD:
				{
					char    tmp[1024];
					char	b_title1[500];
					char	b_title2[500];
					GetWindowText(GetDlgItem (hwndDlg, IDC_EDIT_ENTER_KEY),tmp,1000);
					string t_key = tmp;
					while( t_key.find("-") < t_key.size() )
						t_key.erase(t_key.find("-"),1);

					if( t_key.size() != 25 ) {
						loadString(IDS_WRONG_KEY,b_title1,sizeof(b_title1));
						loadString(IDS_WRONG_KEY_TITLE,b_title2,sizeof(b_title2));

						MessageBox(NULL,b_title1,b_title2,MB_ICONERROR | MB_OK);
						return 1;
					} else
						gui_manager.key_list.push_back(t_key.c_str());
					EndDialog(hwndDlg,0);
					key_dialog = NULL;
				}
				break;
				case IDC_EXIT:
				case 2:
					EndDialog(hwndDlg,0);
					key_dialog = NULL;
					return 0;
			}
			break;
		case WM_DESTROY: 
			PostQuitMessage(0); 
			return 0;
	}

	return 0;
}
Exemplo n.º 30
0
//main ()
int main (int argc, char *argv[]) {
//Call syntax check
    if (argc != 3) {
        printf ("Usage: %s Title_list_filename Sequence_list_filename\n", argv[0]);
        exit (1);
    }
//Main variables
    string title, sequence;
    FILE *titleInFile = NULL, *sequenceInFile = NULL, *outFile = NULL;
    int count = 0;
//File creation and checks
    printf ("Opening files..\n");
    createFile (&titleInFile, argv[1], 'r');
    createFile (&sequenceInFile, argv[2], 'r');
    createFile (&outFile, "Combined.fasta", 'w');
//Combine entries
    printf ("File opened.  Combining...\n");
    initializeString (&title);
    initializeString (&sequence);
    while (1) {
//Load the data, break the loop if either list runs out
        loadString (&title, titleInFile);
        loadString (&sequence, sequenceInFile);
        if ((title.str == NULL) || (sequence.str == NULL)) {
            break;
        }
//Print the new fasta entry and reset for the next set
        fprintf (outFile, ">%s\n%s\n", title.str, sequence.str);
        reinitializeString (&title);
        reinitializeString (&sequence);
//A counter so the user has some idea of how long it will take
        if (++count % 1000000 == 0) {
            printf ("%d entries combined...\n", count);
        }
    }
//Close everything and free memory
    printf ("%d entries combined.  Closing files and freeing memory...\n", count);
    free (title.str);
    free (sequence.str);
    fclose (titleInFile);
    fclose (sequenceInFile);
    fclose (outFile);
    return 0;
}