Ejemplo n.º 1
0
static bool parselimit(const struct Limit *resource, rlim_t *limit, char *s) {
	char *t;
	int len = strlen(s);
	const struct Suffix *suf = resource->suffix;

	*limit = 1;
	if (streq(s, "unlimited")) {
		*limit = RLIM_INFINITY;
		return TRUE;
	}
	if (suf == TIMESUF && (t = strchr(s, ':')) != NULL) {
		int min, sec;
		*t++ = '\0';
		min = a2u(s); sec = a2u(t);
		if (min == -1 || sec == -1) return FALSE;
		*limit = 60 * min + sec;
	} else {
		int n;
		for (; suf != NULL; suf = suf->next)
			if (streq(suf->name, s + len - strlen(suf->name))) {
				s[len - strlen(suf->name)] = '\0';
				*limit *= suf->amount;
				break;
			}
		n = a2u(s);
		if (n == -1) return FALSE;
		*limit *= n;
	}
	return TRUE;
}
Ejemplo n.º 2
0
void SparDiskPanel::onRefine(cocos2d::Ref *ref, Widget::TouchEventType touchType)
{
	if (touchType == Widget::TouchEventType::ENDED) 
	{
		auto typeId = _introSpar;
		if(typeId <= 0)return;
		auto spar = _sparDisk->getSpar(typeId);
		auto owner = dynamic_cast<Player*>(_sparDisk->getOwner());
		if(owner == nullptr) return;
		auto sparPatchNum = owner->getItemBag()->getPropSizeByType(2002005);
		if(sparPatchNum >= spar->getCostPatchNum())
		{
			PopPanel::getInstance()->confirm("upConfirm","type:Text---text:"+spar->getUpConfirm(),PromptPanel::TYPE_DONE_CANCEL,[=](){
				owner->usePropByType(2002005,spar->getCostPatchNum());
				PopPanel::getInstance()->note("cantUpConfirm","type:Text---text:"+a2u("¹§Ï²Ä㣬¾§Ê¯ÌáÁ¶³É¹¦"), 1.0f, false, true);
				spar->upLevel();
				_sparDisk->updateAddData();
				updateIntro();
			},nullptr,true,true);
		}
		else
		{
			PopPanel::getInstance()->note("cantUpConfirm","type:Text---text:"+a2u("ËéƬÊýÁ¿²»×ã")+cocos2d::Value(spar->getCostPatchNum()).asString()+a2u("¸ö"), 1.0f, false, true);
		}
	}
}
Ejemplo n.º 3
0
static int addKeyBinding(KEYBINDINGDESC *desc) {
	int i, len;
	TCHAR *sectionName;
	TCHAR *actionName;
	KeyBindingItem *item = (KeyBindingItem *)mir_alloc(sizeof(KeyBindingItem));
	ZeroMemory(item, sizeof(KeyBindingItem));
	if (desc->flags & KBDF_UNICODE) {
		#ifdef _UNICODE
		sectionName = mir_tstrdup(desc->ptszSection);
		actionName = mir_tstrdup(desc->ptszActionName);
		#else
			sectionName = u2a(desc->pwszSection);
			actionName = u2a(desc->pwszActionName);
		#endif
	} else {
		#ifdef _UNICODE
			sectionName = a2u(desc->pszSection);
			actionName = a2u(desc->pszActionName);
		#else
		sectionName = mir_tstrdup(desc->ptszSection);
		actionName = mir_tstrdup(desc->ptszActionName);
		#endif
	}
	len = _tcslen(sectionName) + _tcslen(actionName) + 2;
	item->fullActionName  = (TCHAR *)mir_alloc(len * sizeof(TCHAR));
	_tcscpy(item->fullActionName, sectionName);
	_tcscat(item->fullActionName, _T("/"));
	_tcscat(item->fullActionName, actionName);
	item->actionName = actionName;
	mir_free(sectionName);
	item->actionGroupName = mir_strdup(desc->pszActionGroup);
	item->action = desc->action;
	for (i = 0; i < 5; i++) {
		item->defaultKey[i] = desc->key[i];
		item->key[i] = desc->key[i];
	}

	item->next = keyBindingList;
	keyBindingList = item;
	if (item->next != NULL)
		item->next->prev = item;
	{
		DBVARIANT dbv;
		char *paramName = mir_t2a(item->fullActionName);
		if ( !DBGetContactSettingString(NULL, "KeyBindings", paramName, &dbv )) {
			for (i = 0; i < 5; i++)
				item->key[i] = 0;
			sscanf(dbv.pszVal, "%X,%X,%X,%X,%X", &item->key[0],&item->key[1],&item->key[2],&item->key[3],&item->key[4]);
			DBFreeVariant(&dbv);
		}
		mir_free(paramName);
	}
	return 0;
}
Ejemplo n.º 4
0
void ShopPanel::selectedItemEvent(Ref *pSender, ListView::EventType type)
{
	switch (type)
	{
	case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_START:
		{
			ListView* listView = static_cast<ListView*>(pSender);
			CC_UNUSED_PARAM(listView);
			CCLOG("select child start index = %ld", listView->getCurSelectedIndex());
			//auto tag = listView->getItem(listView->getCurSelectedIndex())->getTag();
			//auto goodUnit = _goodsUnit.at(listView->getCurSelectedIndex());

			break;
		}
	case cocos2d::ui::ListView::EventType::ON_SELECTED_ITEM_END:
		{
			ListView* listView = static_cast<ListView*>(pSender);
			CC_UNUSED_PARAM(listView);
			CCLOG("select child end index = %ld", listView->getCurSelectedIndex());
			auto goodUnit = _goodsUnit.at(listView->getCurSelectedIndex());
			auto good = goodUnit->getGood();
			PopPanel::getInstance()->confirm("buy","type:Text---text:"+ a2u("确定要花费 ") + cocos2d::Value(goodUnit->getPrice()).asString() + a2u("元 购买 ") + cocos2d::Value(goodUnit->getNum()).asString() + a2u("个") + good->getNickName() + a2u(" 吗?"),PromptPanel::TYPE_DONE_CANCEL,[=](){
				// 加速药水
				if(good->getTypeId() == 2003011 && Detect::shareDetect()->getUser()->getBuffByTypeId(4001001) != nullptr)
				{
					PopPanel::getInstance()->note("treaMap","type:Text---text:"+ a2u("已拥有该效果"),2.0f,false,true);
				}
				else
				{
					#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
					//确定购买
					JniMethodInfo jmi;
					if(JniHelper::getStaticMethodInfo(jmi ,"IAP/IAPJni" ,"orderGood" ,"(I)V"))
					{
						jmi.env->CallStaticVoidMethod(jmi.classID , jmi.methodID, listView->getCurSelectedIndex());
					}
					#else
					JniTest::getInstance()->orderSuccess(listView->getCurSelectedIndex());
					#endif
				}
			},nullptr,true,true);

			break;
		}
	default:
		break;
	}
}
Ejemplo n.º 5
0
void GoodUnit::updateView()
{
	if(_good == nullptr)
		return;
	auto intro = static_cast<Text*>(Helper::seekWidgetByName(_view, "Label_intro"));
	auto name = static_cast<Text*>(Helper::seekWidgetByName(_view, "Label_name"));
	auto price = static_cast<Text*>(Helper::seekWidgetByName(_view, "Label_price"));
	
	auto goodPan = static_cast<Layout*>(Helper::seekWidgetByName(_view, "Panel_item"));
	auto button = static_cast<Button*>(Helper::seekWidgetByName(_view, "Button_item"));
	auto image = static_cast<ImageView*>(Helper::seekWidgetByName(_view, "Image_item"));
	auto imageBg = static_cast<ImageView*>(Helper::seekWidgetByName(_view, "Image_bg"));
	auto num = static_cast<TextAtlas*>(Helper::seekWidgetByName(_view, "AtlasLabel"));

	_view->setContentSize(imageBg->getContentSize());
	num->setString(cocos2d::Value(_num).asString());
	auto view = _good->getView();
	view->retain();
	view->removeFromParent();
	view->setAnchorPoint(Vec2(0.16,0));
	image->addChild(view);
	view->release();

	name->setString(_good->getNickName());
	intro->setString(_good->getModelByName("introduce").asString());
	price->setString(/*a2u("价格: ")+*/cocos2d::Value(_price).asString()+a2u("元"));
	
}
Ejemplo n.º 6
0
static void b_shift(char **av) {
	int shift = (av[1] == NULL ? 1 : a2u(av[1]));
	List *s, *dollarzero;
	if (av[1] != NULL && av[2] != NULL) {
		arg_count("shift");
		return;
	}
	if (shift < 0) {
		badnum(av[1]);
		return;
	}
	s = varlookup("*")->n;
	dollarzero = varlookup("0");
	while (s != NULL && shift != 0) {
		s = s->n;
		--shift;
	}
	if (s == NULL && shift != 0) {
		fprint(2, "cannot shift\n");
		set(FALSE);
	} else {
		varassign("*", append(dollarzero, s), FALSE);
		set(TRUE);
	}
}
Ejemplo n.º 7
0
// mir_free() the return value
TCHAR* s2t(const void *pszStr,DWORD fUnicode,BOOL fMirCp)
{

	if(fUnicode) return mir_wstrdup((WCHAR*)pszStr);
	return a2u((char*)pszStr,fMirCp);

}
Ejemplo n.º 8
0
Archivo: glom.c Proyecto: muennich/rc3
extern void assign(List *s1, List *s2, bool stack) {
	List *val = s2;
	if (s1 == NULL)
		rc_error("null variable name");
	if (s1->n != NULL)
		rc_error("multi-word variable name");
	if (*s1->w == '\0')
		rc_error("zero-length variable name");
	if (a2u(s1->w) != -1)
		rc_error("numeric variable name");
	if (strchr(s1->w, '=') != NULL)
		rc_error("'=' in variable name");
	if (*s1->w == '*' && s1->w[1] == '\0')
		val = append(varlookup("0"), s2); /* preserve $0 when * is assigned explicitly */
	if (s2 != NULL || stack) {
		if (dashex)
			prettyprint_var(2, s1->w, val);
		varassign(s1->w, val, stack);
		alias(s1->w, varlookup(s1->w), stack);
	} else {
		if (dashex)
			prettyprint_var(2, s1->w, NULL);
		varrm(s1->w, stack);
	}
}
Ejemplo n.º 9
0
static LONG RestoreRegTree(HKEY hKey,const char *pszSubKey,const char *pszDbPrefix)
{
	char **ppszSettings,*pszSuffix;
	int nSettingsCount,i;
	char *pslash=NULL,*pnext,*pkeys;
	char *pszValName;
	WCHAR *pwszValName;
	HKEY hSubKey;
	DWORD dwType,cbData;
	BYTE *pData;

	int nDbPrefixLen = (int)mir_strlen(pszDbPrefix);
	int nPrefixWithSubKeyLen = nDbPrefixLen + (int)mir_strlen(pszSubKey) + 1;
	char *pszPrefixWithSubKey = (char*)mir_alloc(nPrefixWithSubKeyLen+1);
	if (pszPrefixWithSubKey == NULL)
		return ERROR_OUTOFMEMORY;
	
	mir_strcat(mir_strcat(mir_strcpy(pszPrefixWithSubKey,pszDbPrefix),pszSubKey),"\\"); /* buffer safe */
	LONG res=ERROR_NO_MORE_ITEMS;
	if (pszPrefixWithSubKey!=NULL) {
		if (EnumDbPrefixSettings("AssocMgr",pszPrefixWithSubKey,&ppszSettings,&nSettingsCount)) {
			for(i=0;i<nSettingsCount;++i) {
				pszSuffix=&ppszSettings[i][nDbPrefixLen];
				/* key hierachy */
				pkeys=mir_strcpy((char*)_alloca(mir_strlen(pszSuffix)+1),pszSuffix);
				pnext=pkeys;
				while((pnext=strchr(pnext+1,_T('\\')))!=NULL) pslash=pnext;
				if (pslash!=NULL) {
					/* create subkey */
					*(pslash++)=0;
					hSubKey=hKey;
					if (pslash!=pkeys+1)
						if ((res=RegCreateKeyExA(hKey,pkeys,0,NULL,0,KEY_SET_VALUE,NULL,&hSubKey,NULL))!=ERROR_SUCCESS)
							break;
					pszValName=pslash;
					/* read data */
					if (ReadDbBackupData(ppszSettings[i],&dwType,&pData,&cbData)) {
						/* set value */
						if (!(dwType&REGF_ANSI)) {
							pwszValName=a2u(pszValName,FALSE);
							if (pwszValName!=NULL) res=RegSetValueExW(hSubKey,pwszValName,0,dwType,pData,cbData);
							else res=ERROR_NOT_ENOUGH_MEMORY;
							mir_free(pwszValName); /* does NULL check */
						} else res=RegSetValueExA(hSubKey,pszValName,0,dwType&~REGF_ANSI,pData,cbData);
						mir_free(pData);
					} else res=ERROR_INVALID_DATA;
					if (res) break;
					db_unset(NULL,"AssocMgr",ppszSettings[i]);
					if (hSubKey!=hKey) RegCloseKey(hSubKey);
				}
				mir_free(ppszSettings[i]);
			}
			mir_free(ppszSettings);
		}
		mir_free(pszPrefixWithSubKey);
	}
	return res;
}
Ejemplo n.º 10
0
void SparDiskPanel::updateIntro()
{
	auto typeId = _selectSparBox->getSpar();
	_introSpar = typeId;
	if(typeId <= 0)
	{
		setSelectSparBox(nullptr);
		return;
	}
	
	auto spar = _sparDisk->getSpar(typeId);
	if(spar == nullptr) return;
	auto owner = dynamic_cast<Player*>(_sparDisk->getOwner());
	if(owner == nullptr) return;
	auto sparPatchNum = owner->getItemBag()->getPropSizeByType(2002005);
	_patchNumLab->setString(a2u("ËéƬ:")+cocos2d::Value(sparPatchNum).asString()+a2u("  Éý¼¶ÏûºÄ:")+cocos2d::Value(spar->getCostPatchNum()).asString());

	std::string nickName;
	std::string introduce;
	nickName = spar->getNickName();
	introduce = spar->getModelByName("introduce").asString();

	stringReplace(introduce, "%rate", cocos2d::Value(int(spar->getRate() * 100)).asString()+"%");
	stringReplace(introduce, "%drate", cocos2d::Value(int(spar->getDrate() * 100)).asString()+"%");

	_nickNameLab->setString(nickName);
	_introLab->setString(introduce);

	if(spar->getRate() >= spar->getMaxRate() || spar->getDrate() >= spar->getMaxDrate())
	{
		_completeLab->setVisible(true);
		_refineBtn->setVisible(false);
	}
	else
	{
		_completeLab->setVisible(false);
		_refineBtn->setVisible(true);
	}
}
Ejemplo n.º 11
0
void User::getShareReward(int index)
{
	if(getShareRewardsLock(index - 1) == 1)
	{
		PopPanel::getInstance()->note("shareReward","type:Text---text:"+ a2u("已经获得该奖励"),1.0f,false,true);
		return;
	}
	
	auto name = "shareReward" + cocos2d::Value(index).asString();
	
	ValueVector rewards;
	ValueVector rewardVec;
	stringToValueVector(PlotScript::sharedHD()->getLuaVarString("script/Test.lua", name.c_str()),"###",rewardVec);
	for(auto pair:rewardVec)
	{
		ValueMap rewardMap;
		stringToValueMap(pair.asString(), rewardMap);
		rewards.push_back(cocos2d::Value(rewardMap));
	}

	// 默认只有一个奖品
	auto rewardMap = rewards.at(0).asValueMap();
	int typeId = rewardMap["typeId"].asInt();
	int num = rewardMap["num"].asInt();

	for(int i = 0; i < num; i ++)
	{
		auto prop = Prop::create(typeId);
		// 获得奖励
		auto player = Detect::shareDetect()->getPlayer();
		player->addProp(prop);
	}

	auto prop = Prop::create(typeId);
	PopPanel::getInstance()->note("cantEquip","type:Text---text:"+ a2u("恭喜获得 ###") + "type:Text---text:"+ prop->getNickName() + "|color:{255,0,0}");

	setShareRewardsLock(index - 1, 1);
}
Ejemplo n.º 12
0
void FilePanel::onFileUnitsClicked(cocos2d::Ref *ref, Widget::TouchEventType touchType)
{
	if (touchType == Widget::TouchEventType::ENDED) 
	{
		auto pan = static_cast<Layout*>(ref);
		auto tag = pan->getTag();
		if(_type == FilePanel::SAVE)
		{
			_units.at(tag)->save();
		}
		else if(_type == FilePanel::LOAD)
		{
			if(_units.at(tag)->getIsExist() == false)
			{
				PopPanel::getInstance()->note("noFile","type:Text---text:"+ a2u("空存档"),1.0f,false,true);
				return;
			}
			PopPanel::getInstance()->confirm("saveConfirm","type:Text---text:"+ a2u("确定要读取存档?"),PromptPanel::TYPE_DONE_CANCEL,[=](){
				destroy();
				_units.at(tag)->load();
			},nullptr,true,true);
		}
	}
}
Ejemplo n.º 13
0
void FileUnit::save()
{
	auto loadMap = FileUtils::getInstance()->getValueMapFromFile(_path);
	if(!loadMap["exist"].isNull() && loadMap["exist"].asBool() == true)
	{
		PopPanel::getInstance()->confirm("saveConfirm","type:Text---text:"+ a2u("确定要覆盖当前存档吗?"),PromptPanel::TYPE_DONE_CANCEL,[=](){
			saveModel();
		},nullptr,true,true);
	}
	else
	{
		saveModel();
	}
	_view->runAction(Sequence::create(DelayTime::create(1),CallFunc::create([=](){updateView();}),nullptr));
}
Ejemplo n.º 14
0
bool HelpLayer::init()
{
	if (!CCLayer::init())  
    {  
        return false;  
    }
      
    CCSize s = CCDirector::sharedDirector()->getWinSize();

	//bg
	CCSprite* bg = CCSprite::create(PIC_MAIN_BACKGROUND);
	bg->setAnchorPoint(ccp(0,0));
	addChild(bg);

	//text
	CCLabelTTF* text = CCLabelTTF::create(a2u(s_helpText).c_str(), "Arial", 40.0f, CCSizeMake(500,700), kCCTextAlignmentLeft);
	text->setPosition(ccp(s.width*0.5, s.height*0.5));
	addChild(text);	
	
	text = CCLabelTTF::create(a2u("北京天普教育").c_str(), "Arial", 30.0f);
	text->setPosition(ccp(450, 250));
	addChild(text);	

	//quit menu
	CCMenuItemImage* quit = CCMenuItemImage::create(
            PIC_BUTTON_BACK,
            PIC_BUTTON_BACK_SELECTED,
            this,
            menu_selector(HelpLayer::quit));
	CCMenu* menu = CCMenu::create(quit, NULL);
	menu->setPosition(ccp(s.width*0.5, 120));
	this->addChild(menu);

	return true;

}
Ejemplo n.º 15
0
static void b_wait(char **av) {
	int status;
	pid_t pid;
	if (av[1] == NULL) {
		waitforall();
		return;
	}
	if (av[2] != NULL) {
		arg_count("wait");
		return;
	}
	if ((pid = a2u(av[1])) < 0) {
		badnum(av[1]);
		return;
	}
	if (rc_wait4(pid, &status, FALSE) > 0)
		setstatus(pid, status);
	else
		set(FALSE);
	sigchk();
}
Ejemplo n.º 16
0
void FilePanel::onButtonClicked(cocos2d::Ref *ref, Widget::TouchEventType touchType)
{
	if (touchType == Widget::TouchEventType::ENDED) 
	{
		auto button = static_cast<Button*>(ref);
		auto tag = button->getTag();
		switch(tag)
		{
		case CLOSE:
			{
				destroy();
			}
			break;
		case RESTART:
			{
				PopPanel::getInstance()->confirm("prompt","type:Text---text:"+ a2u("确定要重新开始游戏吗?"),PromptPanel::TYPE_DONE_CANCEL,[=](){
					Detect::shareDetect()->load = false;
					auto gameScene = dynamic_cast<GameScene*>(Director::getInstance()->getRunningScene());
					if(gameScene != nullptr)
					{
						gameScene->resetInstance();
						auto scene = GameScene::create();
						Director::getInstance()->replaceScene(scene);
					}
					else
					{
						auto s = GameScene::create();
						auto scene = TransitionFade::create(1.0f, s, Color3B::BLACK);
						if (scene)
						{
							Director::getInstance()->replaceScene(scene);
						}
					}
				},nullptr,true,true);
				destroy();
			}
			break;
		}
	}
}
Ejemplo n.º 17
0
int speech(char* msg)
{
#ifdef _WIN32
	int size = MultiByteToWideChar(CP_ACP, 0, msg, -1, NULL, 0);
	LPWSTR converted[65536];
	memset(converted, 0, sizeof(LPWSTR)*size);
	MultiByteToWideChar(CP_ACP, 0, msg, strlen(msg), converted, size);
	wchar_t* message;
	message = a2u(msg);
	sayString(message, true);
#else
if(spd_sayf(conn, SPD_MESSAGE, msg))
{
return 1;
}
else
{
return 0;
}
#endif
return 0;
}
Ejemplo n.º 18
0
void FileUnit::updateView()
{
	auto info = static_cast<Text*>(Helper::seekWidgetByName(_view, "Label_info"));
	auto date = static_cast<Text*>(Helper::seekWidgetByName(_view, "Label_date"));

	auto loadMap = FileUtils::getInstance()->getValueMapFromFile(_path);
	if(!loadMap["exist"].isNull() && loadMap["exist"].asBool() == true)
	{
		auto loadMap = FileUtils::getInstance()->getValueMapFromFile(_path);
		auto map = loadMap["label"].asValueMap();
		auto infoStr = map["info"].asString();
		auto dateStr = map["date"].asString();
		info->setString(infoStr);
		date->setString(dateStr);
		_isExist = true;
	}
	else
	{
		info->setString(a2u("空存档"));
		date->setString("");
		_isExist = false;
	}
}
Ejemplo n.º 19
0
Archivo: glom.c Proyecto: muennich/rc3
extern List *varsub(List *var, List *subs) {
	List *r, *top;
	int n = listnel(var);
	for (top = r = NULL; subs != NULL; subs = subs->n) {
		int i = a2u(subs->w);
		if (i < 1)
			rc_error("bad subscript");
		if (i <= n) {
			List *sub = var;
			while (--i)
				sub = sub->n; /* loop until sub == var(i) */
			if (top == NULL)
				top = r = nnew(List);
			else
				r = r->n = nnew(List);
			r->w = sub->w;
			r->m = sub->m;
		}
	}
	if (top != NULL)
		r->n = NULL;
	return top;
}
Ejemplo n.º 20
0
extern void ssetstatus(char **av) {
	int i, j, k, l;
	bool found;
	for (l = 0; av[l] != NULL; l++)
		; /* count up array length */
	--l;
	for (i = 0; av[i] != NULL; i++) {
		j = a2u(av[i]);
		if (j >= 0) {
			statuses[l - i] = j << 8;
			continue;
		}
		found = FALSE;
		for (k = 0; k < NUMOFSIGNALS; k++) {
			if (streq(signals[k].name, av[i])) {
				statuses[l - i] = k;
				found = TRUE;
				break;
			} 
			else {
				SIZE_T len = strlen(signals[k].name);
				if (strncmp(signals[k].name, av[i], len) == 0 && streq(av[i] + len, "+core")) {
					statuses[l - i] = k + 0x80;
					found = TRUE;
					break;
				}
			}
		}
		if (!found) {
			fprint(2, "bad status\n");
			set(FALSE);
			return;
		}
	}
	pipelength = i;
}
Ejemplo n.º 21
0
INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	ModuleAndContact *mac = (ModuleAndContact *)GetWindowLongPtr(hwnd,GWLP_USERDATA);
	if (msg == WM_INITDIALOG)
	{
		int index, loaded;
		char szProto[256];
		for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
			if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto)))
				loaded = IsProtocolLoaded(szProto);
			else
				loaded = 0;

			// filter
			if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED))
				continue;

			// contacts name
			DBVARIANT dbv ={0};
			WCHAR nick[256];
			WCHAR protoW[256]; // unicode proto

			if (szProto[0])
				a2u(szProto, protoW, SIZEOF(protoW));
			else
				protoW[0] = 0;

			if (!szProto[0] || !loaded) {
				if (protoW) {
					if (Order)
						mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)");
					else
						mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)");
				}
				else wcscpy(nick, nick_unknownW);
			}
			else {
				if (Order)
					mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s", protoW, GetContactName(hContact, szProto, 1));
				else
					mir_snwprintf(nick, SIZEOF(nick), L"%s (%s)", GetContactName(hContact, szProto, 1), protoW);
			}

			index = SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)nick);
			SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, hContact);
		}

		index = (int)SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_INSERTSTRING, 0, (LPARAM)(char*)Translate("Settings"));
		SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, 0);
		SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETCURSEL, index, 0);

		SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam);
		TranslateDialogDefault(hwnd);
	}
	else if (msg == WM_COMMAND)
	{
		switch(LOWORD(wParam)) {
		case CHK_COPY2ALL:
			EnableWindow(GetDlgItem(hwnd, IDC_CONTACTS),!IsDlgButtonChecked(hwnd,CHK_COPY2ALL));
			break;

		case IDOK:
			if (!IsDlgButtonChecked(hwnd,CHK_COPY2ALL)) {
				MCONTACT hContact = (MCONTACT)SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETITEMDATA, SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETCURSEL, 0, 0), 0);
				copyModule(mac->module, mac->hContact, hContact);
			}
			else {
				SetCursor(LoadCursor(NULL,IDC_WAIT));
				for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
					copyModule(mac->module, mac->hContact, hContact);

				SetCursor(LoadCursor(NULL,IDC_ARROW));
			}
			mir_free(mac);
			refreshTree(1);
			DestroyWindow(hwnd);
			break;

		case IDCANCEL:
			mir_free(mac);
			DestroyWindow(hwnd);
			break;
		}
	}
	return 0;
}
Ejemplo n.º 22
0
int doContacts(HWND hwnd2Tree, HTREEITEM contactsRoot, ModuleSettingLL *modlist, MCONTACT hSelectedContact, char *SelectedModule, char *SelectedSetting)
{
	TVINSERTSTRUCT tvi;
	HTREEITEM contact;
	ModuleTreeInfoStruct *lParam;
	ModSetLinkLinkItem *module;
	int count = CallService(MS_DB_CONTACT_GETCOUNT, 0, 0);
	int itemscount = 0;
	int loaded, i = 0, icon = 0;
	HWND hwnd = GetParent(hwnd2Tree);
	int hItem = -1;

	SetWindowText(hwnd2mainWindow, Translate("Loading contacts..."));

	tvi.hInsertAfter = TVI_SORT;
	tvi.item.cChildren = 1;

	for (MCONTACT hContact = db_find_first(); hContact && hwnd2mainWindow; hContact = db_find_next(hContact)) {
		char szProto[100];
		if (DBGetContactSettingStringStatic(hContact, "Protocol", "p", szProto, SIZEOF(szProto))) {
			icon = GetProtoIcon(szProto);
			loaded = (icon != DEF_ICON);
		}
		else {
			icon = DEF_ICON;
			loaded = 0;
		}

		i++;

		// filter
		if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED))
			continue;

		// add the contact
		lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct));
		lParam->hContact = hContact;
		lParam->type = CONTACT;
		tvi.item.mask = TVIF_TEXT | TVIF_CHILDREN | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
		tvi.item.lParam = (LPARAM)lParam;
		tvi.hParent = contactsRoot;

		if (hSelectedContact != hContact)
			lParam->type |= EMPTY;

		// contacts name
		DBVARIANT dbv = {0};
		WCHAR nick[256];
		WCHAR protoW[256]; // unicode proto

		if (szProto)
			a2u(szProto, protoW, SIZEOF(protoW));
		else
			protoW[0] = 0;

		if (!szProto || !loaded) {
			tvi.item.iSelectedImage = (tvi.item.iImage = 4);

			if (protoW) {
				if (Order)
					mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)");
				else
					mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)");
			}
			else
				wcscpy(nick, nick_unknownW);
		}
		else {
			tvi.item.iSelectedImage = (tvi.item.iImage = icon); //GetProtoIcon(szProto, 7));
			if (Order)
				mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s", protoW, GetContactName(hContact, szProto, 1));
			else
				mir_snwprintf(nick, SIZEOF(nick), L"%s (%s)", GetContactName(hContact, szProto, 1), protoW);
		}

		tvi.item.pszText = (char *)nick;
		contact = TreeView_InsertItemW(hwnd2Tree, &tvi);

		itemscount++;

		if (hSelectedContact == hContact) {
			module = modlist->first;
			while (module && hwnd2mainWindow) {
				if (module->name[0] && !IsModuleEmpty(hContact, module->name)) {
					tvi.hParent = contact;
					tvi.hInsertAfter = TVI_SORT;
					tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
					tvi.item.pszText = module->name;

					lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct));
					lParam->hContact = hContact;

					tvi.item.iImage = 1;
					tvi.item.iSelectedImage = 2;
					lParam->type = KNOWN_MODULE;

					tvi.item.lParam = (LPARAM)lParam;
					TreeView_InsertItem(hwnd2Tree, &tvi);
				}
				module = (ModSetLinkLinkItem *)module->next;
			}

			hItem = findItemInTree(hwnd2Tree, hSelectedContact, SelectedModule);
		}
	}

	if (hItem != -1) {
		TreeView_SelectItem(hwnd2Tree, (HTREEITEM)hItem);
		TreeView_Expand(hwnd2Tree, hItem, TVE_EXPAND);
		if (SelectedSetting[0])
			SelectSetting(SelectedSetting);
	}

	return itemscount;
}
Ejemplo n.º 23
0
void HudPanel::onButtonClicked(cocos2d::Ref *ref, Widget::TouchEventType touchType)
{
	if(_plotBlock == true)
		return;
	if (touchType == Widget::TouchEventType::ENDED) 
	{
		auto button = static_cast<Button*>(ref);
		auto tag = button->getTag();
		switch(tag)
		{
		case SHOP:
			{
				if(_popPanel->hasPanelByName("shop") != nullptr)
				{
					_popPanel->removePanelByName("shop");
				}
				else
				{
					_popPanel->removeAllPanelsByOrder(1);
					_popPanel->addPanelByName("shop",1);
				}
			}			
			break;
		case BAG:
			{
				if(_popPanel->hasPanelByName("itemBag") != nullptr)
				{
					_popPanel->removePanelByName("itemBag");
				}
				else
				{
					_popPanel->removeAllPanelsByOrder(1);
					_popPanel->addPanelByName("itemBag",1);
				}
			}
			break;
		case TRANS:
			{
				if(_popPanel->hasPanelByName("convey") != nullptr)
				{
					_popPanel->removePanelByName("convey");
				}
				else
				{
					_popPanel->removeAllPanelsByOrder(1);
					auto player = Detect::shareDetect()->getPlayer();
					auto device = player->getItemBag()->getSpecialByType(2007003);
					if(device == nullptr)
					{
						PopPanel::getInstance()->note("conveyNote","type:Text---text:"+ a2u("没有传送装置"));
						return;
					}
					if(conditions["conveyClose"].intValue() == 1)
					{
						PopPanel::getInstance()->note("conveyNote","type:Text---text:"+ a2u("魔法空间紊乱,无法传送"));
						return;
					}
					if(Detect::shareDetect()->getCurTower()->getCanConvey() == false)
					{
						PopPanel::getInstance()->note("conveyNote","type:Text---text:"+ a2u("此处无法传送"));
						return;
					}
					auto floor = Detect::shareDetect()->getCurFloor();
					int typeIds[] = {2005007,2005008};
					bool nearConvey = floor->getNearByTypeId(player->getSite(),SquareVecs,9,typeIds,2) != nullptr ? true:false;
					// convey debug
					nearConvey = true;

					if(nearConvey == true)
					{
						_popPanel->addPanelByName("convey",1);
					}
					else
					{
						PopPanel::getInstance()->note("conveyNote","type:Text---text:"+ a2u("只能在楼梯口附近传送"),1.2f,false);
					}
				}
			}
			break;
		case BOOK:
			{
				if(_popPanel->hasPanelByName("book") != nullptr)
				{
					_popPanel->removePanelByName("book");
				}
				else
				{
					_popPanel->removeAllPanelsByOrder(1);

					auto player = Detect::shareDetect()->getPlayer();
					auto device = player->getItemBag()->getSpecialByType(2007004);
					if(device == nullptr)
					{
						PopPanel::getInstance()->note("conveyNote","type:Text---text:"+ a2u("没有怪物手册,无法查看"),1.2f,false);
						return;
					}
					_popPanel->addPanelByName("book",1);
				}
			}
			break;
		case PAUSE:
			{
				if(_popPanel->hasPanelByName("pause") != nullptr)
				{
					_popPanel->removePanelByName("pause");
				}
				else
				{
					_popPanel->removeAllPanelsByOrder(1);
					_popPanel->addPanelByName("pause",1);
				}
			}
			break;
		}
		//CC_SAFE_RETAIN(this); 
		//this->removeFromParentAndCleanup(true);
	}
}