void	intro_out(t_data *d, t_img *i, t_img *l, t_img *p)
{
	static int	fade = 255;

	fade -= INTRO_FADEOUT_SPEED;
	if (fade < 1)
	{
		d->mlx.scene = VM_INIT;
		ft_music_start(&d->vm, 1);
		return ;
	}
	intro_out_fade(i, fade);
	itow(l->img, 0, 0, "intro logo");
	itow(p->img, PRESSANYX, PRESSANYY, "press any key red");
	itow(i->img, 0, 0, "fade out");
}
void UpdateManager::setURLCheck(const StringBuffer& syncURL)
{
    // Get the host & port info
    URL url;
    url.setURL(syncURL.c_str());
    StringBuffer port(":80");
    if (url.port != 0) { 
        port = ":"; 
        port += itow(url.port); 
    }        
            
    // Compose the url
    StringBuffer urlCheck(url.protocol);
    urlCheck += "://"; 
    urlCheck += url.host;
    urlCheck += port;
    urlCheck += UP_URL_RESOURCE;
    
    StringBuffer ss(UP_URL_RESOURCE);
    if (ss.find("http://")  != StringBuffer::npos ||
        ss.find("https://") != StringBuffer::npos ) {
        urlCheck = UP_URL_RESOURCE;
    }

    LOG.debug("Url to check = %s", urlCheck.c_str());
    
    // Save to registry.
    UpdaterConfig& config = ((OutlookConfig*)getConfig())->getUpdaterConfig();
    config.setUrlCheck(urlCheck);
    config.save();
}
Esempio n. 3
0
	vint wtoi_test(const WString& string, bool& success)
	{
		wchar_t* endptr = 0;
		vint result = wcstol(string.Buffer(), &endptr, 10);
		success = endptr == string.Buffer() + string.Length() && itow(result) == string;
		return result;
	}
Esempio n. 4
0
StringBuffer HttpUploader::composeURL() {
    
    // Get the host & port info
    URL url;
    url.setURL(syncUrl.c_str());
    StringBuffer port(":80");
    if (url.port != 0) { 
        port = ":"; 
        port += itow(url.port); 
    }
    
    // Compose the url
    StringBuffer ret(url.protocol);
    ret += "://"; 
    ret += url.host;
    ret += port;
    ret += "/";
    ret += UPLOAD_URL_RESOURCE;
    ret += "/";
    ret += sourceURI;

    // Add parameters
    if (useSessionID && !sessionID.empty()) {
        ret += ";jsession=";
        ret += sessionID; 
    }
    ret += "?action=content-upload";
    
    //LOG.debug("destination url = %s", ret.c_str());

    return ret;
}
void	intro_menu(t_img *i, t_img *l)
{
	static int	fade = 255;
	static int	dir = 6;

	if ((fade += dir) && fade >= 255)
		dir = -6;
	else if (fade <= 1)
		dir = 6;
	fade = (fade < 0) ? 0 : fade;
	fade = (fade > 255) ? 255 : fade;
	i->i = -4;
	while ((i->i += 4) < (i->sl * 22))
		i->str[i->i + 3] = fade;
	itow(l->img, 0, 0, "press any key white");
	itow(i->img, PRESSANYX, PRESSANYY, "press any key blink");
}
void	intro_load(t_dmlx *m, t_img *i, t_img *l)
{
	static int	fade = 0;

	itow(l->img, 0, 0, "intro screen");
	i->i = -4;
	while ((i->i += 4) < (i->sl * WIN_Y))
	{
		i->str[i->i] = 255;
		i->str[i->i + 1] = 255;
		i->str[i->i + 2] = 255;
		i->str[i->i + 3] = fade;
	}
	fade += ((fade + INTRO_FADEIN_SPEED) < 255) ?
	INTRO_FADEIN_SPEED : (fade * -1);
	(fade == 0) ? (m->scene = INTRO_MENU) : 1;
	itow(i->img, 0, 0, "fade in");
}
void	vm_load(t_img *i)
{
	static int	fade = 0;

	fade += VM_FADEIN_SPEED;
	if (fade > 255)
		return ;
	intro_out_fade(i, fade);
	itow(i->img, 0, 0, "fade in");
}
 void UpdateColor()
 {
     vint components[3];
     for(vint i=0;i<3;i++)
     {
         components[i]=trackers[i]->GetPosition();
         labelComponents[i]->SetText(itow(components[i]));
     }
     colorElement->SetColor(Color((unsigned char)components[0], (unsigned char)components[1], (unsigned char)components[2]));
 }
void	display_ctodie_bar(t_dmlx *m, t_dvm *v, double cycle, int pixel)
{
	cycle = ((double)v->ctodiecount / (double)v->ctodie) * 100;
	itow(m->scene_img[VM][3].img
		, BARCTDLEFTX, BARCTDLEFTY, "bar_cycle_left");
	while ((((double)(pixel += 2) / BARCTDSIZE) * 100) < cycle)
		itow(m->scene_img[VM][2].img, (BARCTDLEFTX + pixel)
		, BARCTDLEFTY, "bar_cycle_mid");
	itow(m->scene_img[VM][1].img, (BARCTDLEFTX + pixel)
	, BARCTDLEFTY, "bar_cycle_right");
	if (m->input.mo_x >= BTNCTDPLUSX1 && m->input.mo_x <= BTNCTDPLUSX2
	&& m->input.mo_y >= BTNCTDPLUSY1 && m->input.mo_y <= BTNCTDPLUSY2)
		itow(m->scene_img[VM][4].img, BTNCTDPLUS1X, BTNCTDPLUS1Y
			, "btn_less_over");
	if (m->input.mo_x >= BTNCTDLESSX1 && m->input.mo_x <= BTNCTDLESSX2
	&& m->input.mo_y >= BTNCTDLESSY1 && m->input.mo_y <= BTNCTDLESSY2)
		itow(m->scene_img[VM][5].img, BTNCTDLESS1X, BTNCTDLESS1Y
			, "btn_plus_over");
}
Esempio n. 10
0
void PauseGameState::Render()
{
	ID2D1SolidColorBrush* pBrush = NULL;

	// 绘制背景
	pMainGameState->Render();
	pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(0, 0, 0, 0.5f), &pBrush);
	pRenderTarget->FillGeometry(pRect, pBrush);
	SafeRelease(&pBrush);

	// 绘制菜单
	pMenu->Render(pRenderTarget);

	// 绘制分数
	CoordinateTransformer* pCT = new CoordinateTransformer(pRenderTarget->GetHwnd());
	Vector2D leftTop = Vector2D(-75, 200);
	Vector2D rightBottom = Vector2D(250, 150);
	leftTop = pCT->ToWindowCoordinate(leftTop);
	rightBottom = pCT->ToWindowCoordinate(rightBottom);
	pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Yellow), &pBrush);
	wstring str = L"Score: " + itow(this->score);
	pRenderTarget->DrawTextW(str.c_str(), str.length(), pTitleFormat,
		D2D1::RectF(leftTop.x, leftTop.y, rightBottom.x, rightBottom.y), pBrush);
	SafeRelease(&pBrush);

	// 绘制时间
	leftTop = Vector2D(-75, 150);
	rightBottom = Vector2D(250, 100);
	leftTop = pCT->ToWindowCoordinate(leftTop);
	rightBottom = pCT->ToWindowCoordinate(rightBottom);
	pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::YellowGreen), &pBrush);
	wstring second = itow((int)totalTime % 60);
	if (second.length() < 2) second = L"0" + second;			// 保证秒数是2位
	str = L"Time: " + itow((int)totalTime / 60) + L":" + second;
	pRenderTarget->DrawTextW(str.c_str(), str.length(), pTitleFormat,
		D2D1::RectF(leftTop.x, leftTop.y, rightBottom.x, rightBottom.y), pBrush);
	SafeRelease(&pBrush);
}
Esempio n. 11
0
	GuiCellComposition* CreateButtons(const WString& groupName, const WString& buttonName, bool checkBox, GuiSelectableButton::GroupController* groupController)
	{
		GuiCellComposition* cell=new GuiCellComposition;

		GuiControl* groupBox=g::NewGroupBox();
		groupBox->GetBoundsComposition()->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
		groupBox->GetContainerComposition()->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
		// all child controls should at least 10 pixels away from the group box
		groupBox->GetContainerComposition()->SetInternalMargin(Margin(10, 10, 10, 10));
		// dock the group box to fill the cell
		groupBox->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
		groupBox->SetText(groupName);
		// add the button to the cell
		cell->AddChild(groupBox->GetBoundsComposition());

		// create a stack to layout the 3 buttons from top to bottom shown like a list
		GuiStackComposition* stack=new GuiStackComposition;
		stack->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
		stack->SetDirection(GuiStackComposition::Vertical);
		stack->SetAlignmentToParent(Margin(0, 0, 0, 0));
		stack->SetPadding(6);
		groupBox->GetContainerComposition()->AddChild(stack);

		// create buttons
		for(int i=0;i<3;i++)
		{
			GuiSelectableButton* button=checkBox?g::NewCheckBox():g::NewRadioButton();
			button->SetText(buttonName+itow(i+1));
			button->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
			if(groupController)
			{
				button->SetGroupController(groupController);
			}

			GuiStackItemComposition* stackItem=new GuiStackItemComposition;
			stack->AddChild(stackItem);
			stackItem->AddChild(button->GetBoundsComposition());
		}

		return cell;
	}
Esempio n. 12
0
 TextBoxPage()
 :closeButton(0)
 ,textBox(0)
 {
     // create a table to place a button and a text box
     this->SetText(L"TextBoxPage Sample No."+itow(++pageCounter));
     GuiTableComposition* table=new GuiTableComposition;
     table->SetRowsAndColumns(2, 1);
     table->SetRowOption(0, GuiCellOption::MinSizeOption());
     table->SetRowOption(1, GuiCellOption::PercentageOption(1.0));
     table->SetColumnOption(0, GuiCellOption::PercentageOption(1.0));
     table->SetAlignmentToParent(Margin(0, 0, 0, 0));
     table->SetCellPadding(2);
     
     {
         GuiCellComposition* cell=new GuiCellComposition;
         table->AddChild(cell);
         cell->SetSite(0, 0, 1, 1);
         
         closeButton=g::NewButton();
         closeButton->SetText(L"Close Me!");
         closeButton->Clicked.AttachMethod(this, &TextBoxPage::closeButton_Clicked);
         cell->AddChild(closeButton->GetBoundsComposition());
     }
     
     {
         GuiCellComposition* cell=new GuiCellComposition;
         table->AddChild(cell);
         cell->SetSite(1, 0, 1, 1);
         
         textBox=g::NewMultilineTextBox();
         textBox->GetBoundsComposition()->SetAlignmentToParent(Margin(0, 0, 0, 0));
         textBox->SetText(L"You can input several lines of text here.\r\nThis is a multiple line text box.");
         cell->AddChild(textBox->GetBoundsComposition());
     }
     
     this->GetContainerComposition()->AddChild(table);
 }
Esempio n. 13
0
		void GuiResourceFolder::LoadResourceFolderFromXml(DelayLoadingList& delayLoadings, const WString& containingFolder, Ptr<parsing::xml::XmlElement> folderXml, collections::List<WString>& errors)
		{
			ClearItems();
			ClearFolders();
			FOREACH(Ptr<XmlElement>, element, XmlGetElements(folderXml))
			{
				WString name;
				if(Ptr<XmlAttribute> nameAtt=XmlGetAttribute(element, L"name"))
				{
					name=nameAtt->value.value;
				}
				if(element->name.value==L"Folder")
				{
					if (name == L"")
					{
						errors.Add(L"A resource folder should have a name.");
						errors.Add(
							L"Format: RESOURCE, Row: " + itow(element->codeRange.start.row + 1) +
							L", Column: " + itow(element->codeRange.start.column + 1) +
							L", Message: A resource folder should have a name.");
					}
					else
					{
						Ptr<GuiResourceFolder> folder=new GuiResourceFolder;
						if(AddFolder(name, folder))
						{
							WString newContainingFolder=containingFolder;
							Ptr<XmlElement> newFolderXml=element;
							if(Ptr<XmlAttribute> contentAtt=XmlGetAttribute(element, L"content"))
							{
								if(contentAtt->value.value==L"Link")
								{
									folder->SetFileContentPath(XmlGetValue(element));
									WString filePath = containingFolder + folder->GetFileContentPath();
									WString text;
									if(LoadTextFile(filePath, text))
									{
										if(auto parser=GetParserManager()->GetParser<XmlDocument>(L"XML"))
										{
											if(auto xml=parser->TypedParse(text, errors))
											{
												newContainingFolder=GetFolderPath(filePath);
												newFolderXml=xml->rootElement;
											}
										}
									}
									else
									{
										errors.Add(L"Failed to load file \"" + filePath + L"\".");
									}
								}
							}
							folder->LoadResourceFolderFromXml(delayLoadings, newContainingFolder, newFolderXml, errors);
						}
						else
						{
							errors.Add(L"Duplicated resource folder name \"" + name + L"\".");
						}
					}
				}
				else if(element->name.value.Length() <= 3 || element->name.value.Sub(0, 4) != L"ref.")
				{
					WString relativeFilePath;
					WString filePath;
					if(Ptr<XmlAttribute> contentAtt=XmlGetAttribute(element, L"content"))
					{
						if(contentAtt->value.value==L"File")
						{
							relativeFilePath = XmlGetValue(element);
							filePath = containingFolder + relativeFilePath;
							if(name==L"")
							{
								name=GetFileName(filePath);
							}
						}
					}

					Ptr<GuiResourceItem> item = new GuiResourceItem;
					if(AddItem(name, item))
					{
						WString type = element->name.value;
						IGuiResourceTypeResolver* typeResolver = GetResourceResolverManager()->GetTypeResolver(type);
						IGuiResourceTypeResolver* preloadResolver = typeResolver;

						if(typeResolver)
						{
							if (!typeResolver->DirectLoadXml())
							{
								WString preloadType = typeResolver->IndirectLoad()->GetPreloadType();
								if (preloadType != L"")
								{
									preloadResolver = GetResourceResolverManager()->GetTypeResolver(preloadType);
									if (!preloadResolver)
									{
										errors.Add(L"Unknown resource resolver \"" + preloadType + L"\" of resource type \"" + type + L"\".");
									}
								}
							}
						}
						else
						{
							errors.Add(L"Unknown resource type \"" + type + L"\".");
						}

						if(typeResolver && preloadResolver)
						{
							if (auto directLoad = preloadResolver->DirectLoadXml())
							{
								Ptr<DescriptableObject> resource;
								WString itemType = preloadResolver->GetType();
								if (filePath == L"")
								{
									resource = directLoad->ResolveResource(element, errors);
								}
								else
								{
									item->SetFileContentPath(relativeFilePath);
									resource = directLoad->ResolveResource(filePath, errors);
								}

								if (typeResolver != preloadResolver)
								{
									if (auto indirectLoad = typeResolver->IndirectLoad())
									{
										if(indirectLoad->IsDelayLoad())
										{
											DelayLoading delayLoading;
											delayLoading.type = type;
											delayLoading.workingDirectory = containingFolder;
											delayLoading.preloadResource = item;
											delayLoadings.Add(delayLoading);
										}
										else if(resource)
										{
											resource = indirectLoad->ResolveResource(resource, 0, errors);
											itemType = typeResolver->GetType();
										}
									}
									else
									{
										resource = 0;
										errors.Add(L"Resource type \"" + typeResolver->GetType() + L"\" is not a indirect load resource type.");
									}
								}
								item->SetContent(itemType, resource);
							}
							else
							{
								errors.Add(L"Resource type \"" + preloadResolver->GetType() + L"\" is not a direct load resource type.");
							}
						}

						if(!item->GetContent())
						{
							RemoveItem(name);
						}
					}
					else
					{
						errors.Add(L"Duplicated resource item name \"" + name + L"\".");
					}
				}
			}
Esempio n. 14
0
int main(int argc, char* argv[])
#endif
{
	WString baseDirectory;
	{
#if defined VCZH_MSVC
		wchar_t currentDirectory[MAX_PATH]={0};
		GetCurrentDirectory(MAX_PATH, currentDirectory);
		baseDirectory=currentDirectory;
#elif defined VCZHGCC
		char currentDirectory[1024]={0};
		getcwd(currentDirectory, 1024);
		baseDirectory=atow(currentDirectory);
#endif
		if(baseDirectory[baseDirectory.Length()-1]!=PATH_DELIMITER)
		{
			baseDirectory+=PATH_DELIMITER;
		}
	}


	Regex regexPathSplitter(L"[///\\]");
	Ptr<ParsingGeneralParser> parser=CreateBootstrapStrictParser();

	Console::SetTitle(L"Vczh Parser Generator for C++");
	Console::SetColor(false, true, false, true);
	Console::WriteLine(L"parsing>Files : "+itow(argc-1));
	for(int i=1;i<argc;i++)
	{
		Console::WriteLine(L"------------------------------------------------------------");
#if defined VCZH_MSVC
		WString inputPath=argv[i];
#elif defined VCZH_GCC
		WString inputPath=atow(argv[i]);
#endif
		if(inputPath.Length()<2 || inputPath[1]!=L':')
		{
			inputPath=baseDirectory+inputPath;
		}
		Console::WriteLine(L"parsing>Making : "+inputPath);
		if(inputPath.Length()<11 || inputPath.Right(11)!=L".parser.txt")
		{
			Console::SetColor(true, false, false, true);
			Console::WriteLine(L"error> The extenion name of the input file path must be \".parser.txt\".");
			Console::SetColor(false, true, false, true);
		}
		else
		{
			WString name;
			{
				List<Ptr<RegexMatch>> matches;
				regexPathSplitter.Split(inputPath, true, matches);
				name=matches[matches.Count()-1]->Result().Value();
				name=name.Left(name.Length()-11);
			}
			WString outputMetaPath=inputPath.Left(inputPath.Length()-11);
			WString outputHeaderPath=outputMetaPath+L".h";
			WString outputCppPath=outputMetaPath+L".cpp";
			WString logPath=outputMetaPath+L".log";
			Console::WriteLine(L"parsing>Output header path : "+outputHeaderPath);
			Console::WriteLine(L"parsing>Output cpp path : "+outputCppPath);
			Console::WriteLine(L"parsing>Log path : "+logPath);

			CodegenConfig config;
			WString codeGrammar;
			{
				FileStream fileStream(inputPath, FileStream::ReadOnly);
				if(!fileStream.IsAvailable())
				{
					Console::SetColor(true, false, false, true);
					Console::WriteLine(L"error> Cannot open \""+inputPath+L" for read.");
					Console::SetColor(false, true, false, true);
					goto STOP_PARSING;
				}
				BomDecoder decoder;
				DecoderStream decoderStream(fileStream, decoder);
				StreamReader reader(decoderStream);

				if(!config.ReadConfig(reader))
				{
					goto STOP_PARSING;
				}
				codeGrammar=reader.ReadToEnd();
			}

			Ptr<ParsingDefinition> definition;
			Ptr<ParsingTable> table;
			{
				FileStream fileStream(logPath, FileStream::WriteOnly);
				if(!fileStream.IsAvailable())
				{
					Console::SetColor(true, false, false, true);
					Console::WriteLine(L"error> Cannot open \""+logPath+L" for write.");
					Console::SetColor(false, true, false, true);
					goto STOP_PARSING;
				}
				BomEncoder encoder(BomEncoder::Utf16);
				EncoderStream encoderStream(fileStream, encoder);
				StreamWriter writer(encoderStream);
				
				if(codeGrammar==L"<bootstrap-grammar>")
				{
					definition=CreateParserDefinition();
					MemoryStream bootstrapStream;
					{
						StreamWriter bootstrapWriter(bootstrapStream);
						Log(definition, bootstrapWriter);
					}
					bootstrapStream.SeekFromBegin(0);
					StreamReader bootstrapReader(bootstrapStream);
					codeGrammar=bootstrapReader.ReadToEnd();
				}
				else
				{
					definition=CreateDefinition(parser, codeGrammar, writer);
				}
				if(!definition)
				{
					Console::SetColor(true, false, false, true);
					Console::WriteLine(L"error> Error happened. Open \""+logPath+L" for details.");
					Console::SetColor(false, true, false, true);
					goto STOP_PARSING;
				}

				table=CreateTable(definition, writer, config.ambiguity);
				if(!table)
				{
					Console::SetColor(true, false, false, true);
					Console::WriteLine(L"error> Error happened. Open \""+logPath+L" for details.");
					Console::SetColor(false, true, false, true);
					goto STOP_PARSING;
				}
			}
			{
				FileStream fileStream(outputHeaderPath, FileStream::WriteOnly);
				if(!fileStream.IsAvailable())
				{
					Console::SetColor(true, false, false, true);
					Console::WriteLine(L"error> Cannot open \""+outputHeaderPath+L" for write.");
					Console::SetColor(false, true, false, true);
					goto STOP_PARSING;
				}
				BomEncoder encoder(BomEncoder::Mbcs);
				EncoderStream encoderStream(fileStream, encoder);
				StreamWriter writer(encoderStream);
				WriteHeaderFile(name, definition, table, config, writer);
			}
			{
				FileStream fileStream(outputCppPath, FileStream::WriteOnly);
				if(!fileStream.IsAvailable())
				{
					Console::SetColor(true, false, false, true);
					Console::WriteLine(L"error> Cannot open \""+outputCppPath+L" for write.");
					Console::SetColor(false, true, false, true);
					goto STOP_PARSING;
				}
				BomEncoder encoder(BomEncoder::Mbcs);
				EncoderStream encoderStream(fileStream, encoder);
				StreamWriter writer(encoderStream);
				
				config.includes.Clear();
				config.includes.Add(L"\""+name+L".h\"");
				WriteCppFile(name, codeGrammar, definition, table, config, writer);
			}
		}
	STOP_PARSING:;
	}
	Console::WriteLine(L"Finished!");
	return 0;
}
Esempio n. 15
0
SAFFIRE_METHOD(numerical, conv_string) {
    wchar_t *tmp = itow(self->value);
    RETURN_STRING(tmp);
}