Exemplo n.º 1
0
HRESULT CAdRegion::SaveAsText(CBDynBuffer *Buffer, int Indent) {
	Buffer->PutTextIndent(Indent, "REGION {\n");
	Buffer->PutTextIndent(Indent + 2, "NAME=\"%s\"\n", m_Name);
	Buffer->PutTextIndent(Indent + 2, "CAPTION=\"%s\"\n", GetCaption());
	Buffer->PutTextIndent(Indent + 2, "BLOCKED=%s\n", m_Blocked ? "TRUE" : "FALSE");
	Buffer->PutTextIndent(Indent + 2, "DECORATION=%s\n", m_Decoration ? "TRUE" : "FALSE");
	Buffer->PutTextIndent(Indent + 2, "ACTIVE=%s\n", m_Active ? "TRUE" : "FALSE");
	Buffer->PutTextIndent(Indent + 2, "SCALE=%d\n", (int)m_Zoom);
	Buffer->PutTextIndent(Indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", D3DCOLGetR(m_Alpha), D3DCOLGetG(m_Alpha), D3DCOLGetB(m_Alpha));
	Buffer->PutTextIndent(Indent + 2, "ALPHA = %d\n", D3DCOLGetA(m_Alpha));
	Buffer->PutTextIndent(Indent + 2, "EDITOR_SELECTED=%s\n", m_EditorSelected ? "TRUE" : "FALSE");

	int i;
	for (i = 0; i < m_Scripts.GetSize(); i++) {
		Buffer->PutTextIndent(Indent + 2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename);
	}

	if (m_ScProp) m_ScProp->SaveAsText(Buffer, Indent + 2);

	for (i = 0; i < m_Points.GetSize(); i++) {
		Buffer->PutTextIndent(Indent + 2, "POINT {%d,%d}\n", m_Points[i]->x, m_Points[i]->y);
	}

	CBBase::SaveAsText(Buffer, Indent + 2);

	Buffer->PutTextIndent(Indent, "}\n\n");

	return S_OK;
}
Exemplo n.º 2
0
HRESULT CBSurfaceSDL::DrawSprite(int X, int Y, RECT *Rect, float ZoomX, float ZoomY, uint32 Alpha, bool AlphaDisable, TSpriteBlendMode BlendMode, bool MirrorX, bool MirrorY, int offsetX, int offsetY) {
	CBRenderSDL *renderer = static_cast<CBRenderSDL *>(Game->m_Renderer);

	if (renderer->m_ForceAlphaColor != 0) Alpha = renderer->m_ForceAlphaColor;

	byte r = D3DCOLGetR(Alpha);
	byte g = D3DCOLGetG(Alpha);
	byte b = D3DCOLGetB(Alpha);
	byte a = D3DCOLGetA(Alpha);

	SDL_SetTextureColorMod(m_Texture, r, g, b);
	SDL_SetTextureAlphaMod(m_Texture, a);

	if (AlphaDisable)
		SDL_SetTextureBlendMode(m_Texture, SDL_BLENDMODE_NONE);
	else
		SDL_SetTextureBlendMode(m_Texture, SDL_BLENDMODE_BLEND);

	SDL_Rect srcRect;
	srcRect.x = Rect->left;
	srcRect.y = Rect->top;
	srcRect.w = Rect->right - Rect->left;
	srcRect.h = Rect->bottom - Rect->top;

	SDL_Rect position;
	position.x = X;
	position.y = Y;
	position.w = (float)srcRect.w * ZoomX / 100.f;
	position.h = (float)srcRect.h * ZoomX / 100.f;

	renderer->ModTargetRect(&position);

	position.x += offsetX;
	position.y += offsetY;

	SDL_RenderCopy(renderer->GetSdlRenderer(), m_Texture, &srcRect, &position);


	return S_OK;
}
Exemplo n.º 3
0
void CBFontTT::DrawText(byte  *Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength) {
	if (Text == NULL || strcmp((char *)Text, "") == 0) return;

	WideString text;

	if (Game->m_TextEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text);
	else text = StringUtil::AnsiToWide((char *)Text);

	if (MaxLength >= 0 && text.length() > MaxLength) text = text.substr(0, MaxLength);

	CBRenderSDL *m_Renderer = (CBRenderSDL *)Game->m_Renderer;

	// find cached surface, if exists
	int MinPriority = INT_MAX;
	int MinIndex = -1;
	CBSurface *Surface = NULL;
	int textOffset = 0;

	for (int i = 0; i < NUM_CACHED_TEXTS; i++) {
		if (m_CachedTexts[i] == NULL) {
			MinPriority = 0;
			MinIndex = i;
		} else {
			if (m_CachedTexts[i]->m_Text == text && m_CachedTexts[i]->m_Align == Align && m_CachedTexts[i]->m_Width == Width && m_CachedTexts[i]->m_MaxHeight == MaxHeight && m_CachedTexts[i]->m_MaxLength == MaxLength) {
				Surface = m_CachedTexts[i]->m_Surface;
				textOffset = m_CachedTexts[i]->m_TextOffset;
				m_CachedTexts[i]->m_Priority++;
				m_CachedTexts[i]->m_Marked = true;
				break;
			} else {
				if (m_CachedTexts[i]->m_Priority < MinPriority) {
					MinPriority = m_CachedTexts[i]->m_Priority;
					MinIndex = i;
				}
			}
		}
	}

	// not found, create one
	if (!Surface) {
		Surface = RenderTextToTexture(text, Width, Align, MaxHeight, textOffset);
		if (Surface) {
			// write surface to cache
			if (m_CachedTexts[MinIndex] != NULL) delete m_CachedTexts[MinIndex];
			m_CachedTexts[MinIndex] = new CBCachedTTFontText;

			m_CachedTexts[MinIndex]->m_Surface = Surface;
			m_CachedTexts[MinIndex]->m_Align = Align;
			m_CachedTexts[MinIndex]->m_Width = Width;
			m_CachedTexts[MinIndex]->m_MaxHeight = MaxHeight;
			m_CachedTexts[MinIndex]->m_MaxLength = MaxLength;
			m_CachedTexts[MinIndex]->m_Priority = 1;
			m_CachedTexts[MinIndex]->m_Text = text;
			m_CachedTexts[MinIndex]->m_TextOffset = textOffset;
			m_CachedTexts[MinIndex]->m_Marked = true;
		}
	}


	// and paint it
	if (Surface) {
		RECT rc;
		CBPlatform::SetRect(&rc, 0, 0, Surface->GetWidth(), Surface->GetHeight());
		for (int i = 0; i < m_Layers.GetSize(); i++) {
			uint32 Color = m_Layers[i]->m_Color;
			uint32 OrigForceAlpha = m_Renderer->m_ForceAlphaColor;
			if (m_Renderer->m_ForceAlphaColor != 0) {
				Color = DRGBA(D3DCOLGetR(Color), D3DCOLGetG(Color), D3DCOLGetB(Color), D3DCOLGetA(m_Renderer->m_ForceAlphaColor));
				m_Renderer->m_ForceAlphaColor = 0;
			}
			Surface->DisplayTransOffset(X, Y - textOffset, rc, Color, BLEND_NORMAL, false, false, m_Layers[i]->m_OffsetX, m_Layers[i]->m_OffsetY);

			m_Renderer->m_ForceAlphaColor = OrigForceAlpha;
		}
	}


}
void CBFontTT::DrawTextD3D(BYTE* Text, int X, int Y, int Width, TTextAlign Align, int MaxHeight, int MaxLength)
{
	CBRenderD3D* m_Renderer = (CBRenderD3D*)Game->m_Renderer;

	// find cached surface, if exists
	int MinPriority = INT_MAX;
	int MaxPriority = 0;
	int MinIndex = -1;	
	CBSurface* Surface = NULL;
	for(int i=0; i<NUM_CACHED_TEXTS; i++)
	{
		if(m_CachedTexts[i]==NULL)
		{
			MinPriority = 0;
			MinIndex = i;
		}
		else
		{
			MaxPriority = max(MaxPriority, m_CachedTexts[i]->m_Priority);

			if(strcmp(m_CachedTexts[i]->m_Text, (char*)Text)==0 && m_CachedTexts[i]->m_Align==Align && m_CachedTexts[i]->m_Width==Width && m_CachedTexts[i]->m_MaxHeight==MaxHeight && m_CachedTexts[i]->m_MaxLength==MaxLength)
			{
				Surface = m_CachedTexts[i]->m_Surface;
				m_CachedTexts[i]->m_Priority++;
				break;
			}
			else
			{
				if(m_CachedTexts[i]->m_Priority < MinPriority)
				{
					MinPriority = m_CachedTexts[i]->m_Priority;
					MinIndex = i;
				}
			}
		}
	}

	// not found, create one
	if(!Surface)
	{
		if(FAILED(CreateWinFont())) return;

		HDC hDC = ::CreateCompatibleDC(NULL);
		::SetMapMode(hDC, MM_TEXT);
		
		HFONT OldFont = (HFONT)::SelectObject(hDC, m_HFont);

		::SetTextColor(hDC, RGB(255,255,255));
		::SetBkColor(hDC, 0x00000000);
		
		int TextX = 0;
		SetTextAlign(hDC, Align, Width, &TextX);
		
		BYTE* ConvertedText = CBTextUtils::ConvertToNative(Game->m_TextEncoding, Text, MaxLength);

		//ExtTextOut(hDC, 0, 0, ETO_OPAQUE, NULL, (char*)Text, strlen((char*)Text), NULL);
		int Height = FormatText(TextX, 0, ConvertedText, hDC, Width, MaxHeight);
		Height = max(Height, 1);

		DWORD* BitmapBits;
		BITMAPINFO bmi;
		memset(&bmi, 0, sizeof(BITMAPINFO));
		bmi.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
		bmi.bmiHeader.biWidth       =  (int)Width;
		bmi.bmiHeader.biHeight      = -(int)Height;
		bmi.bmiHeader.biPlanes      = 1;
		bmi.bmiHeader.biCompression = BI_RGB;
		bmi.bmiHeader.biBitCount    = 32;

		HBITMAP hbmBitmap = ::CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, (VOID**)&BitmapBits, NULL, 0);
		HBITMAP OldBitmap = (HBITMAP)::SelectObject(hDC, hbmBitmap);

		FormatText(TextX, 0, ConvertedText, hDC, Width, MaxHeight);

		CBImage* Image = new CBImage(Game);
		Image->CreateFromRaw(BitmapBits, Width, Height);
		Surface = Image->CreateSurface();

		delete Image;

		::SelectObject(hDC, OldBitmap);
		::SelectObject(hDC, OldFont);
		::DeleteObject(hbmBitmap);		
		::DeleteDC(hDC);
		
		DeleteWinFont();

		delete []  ConvertedText;

		// write surface to cache
		if(m_CachedTexts[MinIndex]!=NULL) delete m_CachedTexts[MinIndex];
		m_CachedTexts[MinIndex] = new CBCachedTTFontText;
		
		m_CachedTexts[MinIndex]->m_Surface = Surface;
		m_CachedTexts[MinIndex]->m_Align = Align;
		m_CachedTexts[MinIndex]->m_Width = Width;
		m_CachedTexts[MinIndex]->m_MaxHeight = MaxHeight;
		m_CachedTexts[MinIndex]->m_MaxLength = MaxLength;
		m_CachedTexts[MinIndex]->m_Priority = MaxPriority + 1;
		CBUtils::SetString(&m_CachedTexts[MinIndex]->m_Text, (char*)Text);
	}

	// and paint it
	if(Surface)
	{
		RECT rc;
		SetRect(&rc, 0, 0, Surface->GetWidth(), Surface->GetHeight());
		for(int i=0; i<m_Layers.GetSize(); i++)
		{
			DWORD Color = m_Layers[i]->m_Color;
			DWORD OrigForceAlpha = m_Renderer->m_ForceAlphaColor;
			if(m_Renderer->m_ForceAlphaColor!=0)
			{
				Color = DRGBA(D3DCOLGetR(Color), D3DCOLGetG(Color), D3DCOLGetB(Color), D3DCOLGetA(m_Renderer->m_ForceAlphaColor));
				m_Renderer->m_ForceAlphaColor = 0;
			}
			Surface->DisplayTrans(X+m_Layers[i]->m_OffsetX, Y+m_Layers[i]->m_OffsetY, rc, Color);

			m_Renderer->m_ForceAlphaColor = OrigForceAlpha;
		}
	}
}
HRESULT CUIWindow::SaveAsText(CBDynBuffer* Buffer, int Indent)
{
    Buffer->PutTextIndent(Indent, "WINDOW\n");
    Buffer->PutTextIndent(Indent, "{\n");

    Buffer->PutTextIndent(Indent+2, "NAME=\"%s\"\n", m_Name);
    Buffer->PutTextIndent(Indent+2, "CAPTION=\"%s\"\n", GetCaption());

    Buffer->PutTextIndent(Indent+2, "\n");

    if(m_Back && m_Back->m_Filename)
        Buffer->PutTextIndent(Indent+2, "BACK=\"%s\"\n", m_Back->m_Filename);
    if(m_BackInactive && m_BackInactive->m_Filename)
        Buffer->PutTextIndent(Indent+2, "BACK_INACTIVE=\"%s\"\n", m_BackInactive->m_Filename);

    if(m_Image && m_Image->m_Filename)
        Buffer->PutTextIndent(Indent+2, "IMAGE=\"%s\"\n", m_Image->m_Filename);
    if(m_ImageInactive && m_ImageInactive->m_Filename)
        Buffer->PutTextIndent(Indent+2, "IMAGE_INACTIVE=\"%s\"\n", m_ImageInactive->m_Filename);

    if(m_Font && m_Font->m_Filename)
        Buffer->PutTextIndent(Indent+2, "FONT=\"%s\"\n", m_Font->m_Filename);
    if(m_FontInactive && m_FontInactive->m_Filename)
        Buffer->PutTextIndent(Indent+2, "FONT_INACTIVE=\"%s\"\n", m_FontInactive->m_Filename);

    if(m_Cursor && m_Cursor->m_Filename)
        Buffer->PutTextIndent(Indent+2, "CURSOR=\"%s\"\n", m_Cursor->m_Filename);

    Buffer->PutTextIndent(Indent+2, "\n");

    if(m_Text)
        Buffer->PutTextIndent(Indent+2, "TITLE=\"%s\"\n", m_Text);

    switch(m_TitleAlign)
    {
    case TAL_LEFT:
        Buffer->PutTextIndent(Indent+2, "TITLE_ALIGN=\"%s\"\n", "left");
        break;
    case TAL_RIGHT:
        Buffer->PutTextIndent(Indent+2, "TITLE_ALIGN=\"%s\"\n", "right");
        break;
    case TAL_CENTER:
        Buffer->PutTextIndent(Indent+2, "TITLE_ALIGN=\"%s\"\n", "center");
        break;
    }

    if(!CBPlatform::IsRectEmpty(&m_TitleRect))
    {
        Buffer->PutTextIndent(Indent+2, "TITLE_RECT { %d, %d, %d, %d }\n", m_TitleRect.left, m_TitleRect.top, m_TitleRect.right, m_TitleRect.bottom);
    }

    if(!CBPlatform::IsRectEmpty(&m_DragRect))
    {
        Buffer->PutTextIndent(Indent+2, "DRAG_RECT { %d, %d, %d, %d }\n", m_DragRect.left, m_DragRect.top, m_DragRect.right, m_DragRect.bottom);
    }

    Buffer->PutTextIndent(Indent+2, "\n");

    Buffer->PutTextIndent(Indent+2, "X=%d\n", m_PosX);
    Buffer->PutTextIndent(Indent+2, "Y=%d\n", m_PosY);
    Buffer->PutTextIndent(Indent+2, "WIDTH=%d\n", m_Width);
    Buffer->PutTextIndent(Indent+2, "HEIGHT=%d\n", m_Height);

    Buffer->PutTextIndent(Indent+2, "DISABLED=%s\n", m_Disable?"TRUE":"FALSE");
    Buffer->PutTextIndent(Indent+2, "VISIBLE=%s\n", m_Visible?"TRUE":"FALSE");
    Buffer->PutTextIndent(Indent+2, "PARENT_NOTIFY=%s\n", m_ParentNotify?"TRUE":"FALSE");

    Buffer->PutTextIndent(Indent+2, "TRANSPARENT=%s\n", m_Transparent?"TRUE":"FALSE");
    Buffer->PutTextIndent(Indent+2, "PAUSE_MUSIC=%s\n", m_PauseMusic?"TRUE":"FALSE");
    Buffer->PutTextIndent(Indent+2, "MENU=%s\n", m_IsMenu?"TRUE":"FALSE");
    Buffer->PutTextIndent(Indent+2, "IN_GAME=%s\n", m_InGame?"TRUE":"FALSE");
    Buffer->PutTextIndent(Indent+2, "CLIP_CONTENTS=%s\n", m_ClipContents?"TRUE":"FALSE");

    Buffer->PutTextIndent(Indent+2, "\n");

    if(m_FadeBackground)
    {
        Buffer->PutTextIndent(Indent+2, "FADE_COLOR { %d, %d, %d }\n", D3DCOLGetR(m_FadeColor), D3DCOLGetG(m_FadeColor), D3DCOLGetB(m_FadeColor));
        Buffer->PutTextIndent(Indent+2, "FADE_ALPHA=%d\n", D3DCOLGetA(m_FadeColor));
    }

    Buffer->PutTextIndent(Indent+2, "ALPHA_COLOR { %d, %d, %d }\n", D3DCOLGetR(m_AlphaColor), D3DCOLGetG(m_AlphaColor), D3DCOLGetB(m_AlphaColor));
    Buffer->PutTextIndent(Indent+2, "ALPHA=%d\n", D3DCOLGetA(m_AlphaColor));

    Buffer->PutTextIndent(Indent+2, "\n");

    // scripts
    for(int i=0; i<m_Scripts.GetSize(); i++)
    {
        Buffer->PutTextIndent(Indent+2, "SCRIPT=\"%s\"\n", m_Scripts[i]->m_Filename);
    }

    Buffer->PutTextIndent(Indent+2, "\n");

    // editor properties
    CBBase::SaveAsText(Buffer, Indent+2);

    // controls
    for(int i=0; i<m_Widgets.GetSize(); i++)
        m_Widgets[i]->SaveAsText(Buffer, Indent+2);


    Buffer->PutTextIndent(Indent, "}\n");
    return S_OK;
}
void CViewProps::OnPropChange(CPLProperty *Prop, CPLCategory *Cat)
{
	if(!m_View) return;
	CProjectDoc* Doc = m_View->GetDocument();
	if(!Doc) return;

	Doc->SetModifiedFlag();

	//////////////////////////////////////////////////////////////////////////
	if(Cat->GetID()=="startup"){

		if(Prop->GetID()=="resolution-x"){
			Doc->m_Settings->m_ResolutionWidth = atoi(Prop->GetValue());
		}

		else if(Prop->GetID()=="resolution-y"){
			Doc->m_Settings->m_ResolutionHeight = atoi(Prop->GetValue());
		}
		
		else if(Prop->GetID()=="reg-path"){
			SAFE_DELETE_ARRAY(Doc->m_Settings->m_RegPath);
			Doc->m_Settings->m_RegPath = new char[strlen(Prop->GetValue())+1];
			strcpy(Doc->m_Settings->m_RegPath, Prop->GetValue());
			//CopyStr(Doc->m_Settings->m_RegPath, Prop->GetValue());
		}

		else if(Prop->GetID()=="require-accel"){
			Doc->m_Settings->m_RequireAcceleration = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}

		else if(Prop->GetID()=="require-sound"){
			Doc->m_Settings->m_RequireSound = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}

		else if(Prop->GetID()=="hwtl-mode"){
			Doc->m_Settings->m_TLMode = ((CPLPropertyCombo*)Prop)->GetValueInt();
		}

		else if(Prop->GetID()=="use-d3d9"){
			Doc->m_D3D9 = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}

		else if(Prop->GetID()=="allow-windowed"){
			Doc->m_Settings->m_AllowWindowed = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}

		else if(Prop->GetID()=="allow-desktop-res"){
			Doc->m_Settings->m_AllowDesktopRes = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}

		else if(Prop->GetID()=="allow-advanced"){
			Doc->m_Settings->m_AllowAdvanced = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}
		
		else if(Prop->GetID()=="allow-access-tab"){
			Doc->m_Settings->m_AllowAccessTab = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}

		else if(Prop->GetID()=="allow-about-tab"){
			Doc->m_Settings->m_AllowAboutTab = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}
	}

	//////////////////////////////////////////////////////////////////////////
	else if(Cat->GetID()=="game"){

		if(Prop->GetID()=="caption"){
			Doc->Game->SetCaption((char*)LPCSTR(Prop->GetValue()));
		}

		else if(Prop->GetID()=="name"){
			Doc->Game->SetName((char*)LPCSTR(Prop->GetValue()));
		}

		else if(Prop->GetID()=="subtitles"){
			Doc->m_Settings->m_EdGame->m_Subtitles = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}

		else if(Prop->GetID()=="video-subtitles"){
			Doc->m_Settings->m_EdGame->m_VideoSubtitles = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}

		else if(Prop->GetID()=="subtitles-speed"){
			Doc->m_Settings->m_EdGame->m_SubtitlesSpeed = atoi(Prop->GetValue());
		}

		else if(Prop->GetID()=="talk-skip"){
			if(Prop->GetValue()=="right") Doc->m_Settings->m_EdGame->m_TalkSkipButton = TALK_SKIP_RIGHT;
			else if(Prop->GetValue()=="both") Doc->m_Settings->m_EdGame->m_TalkSkipButton = TALK_SKIP_BOTH;
			else Doc->m_Settings->m_EdGame->m_TalkSkipButton = TALK_SKIP_LEFT;
		}
	
	}

	
	//////////////////////////////////////////////////////////////////////////
	else if(Cat->GetID()=="save"){

		if(Prop->GetID()=="personal-save"){
			Doc->m_Settings->m_EdGame->m_PersonalizedSave = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}

		else if(Prop->GetID()=="save-path"){
			CBUtils::SetString(&Doc->m_Settings->m_EdGame->m_LocalSaveDir, (char*)LPCSTR(Prop->GetValue()));
		}

		else if(Prop->GetID()=="thumbnail-width"){
			Doc->m_Settings->m_EdGame->m_ThumbnailWidth = atoi(Prop->GetValue());
		}

		else if(Prop->GetID()=="thumbnail-height"){
			Doc->m_Settings->m_EdGame->m_ThumbnailHeight = atoi(Prop->GetValue());
		}

		else if(Prop->GetID()=="indicator-x"){
			Doc->m_Settings->m_EdGame->m_IndicatorX = atoi(Prop->GetValue());
		}
		
		else if(Prop->GetID()=="indicator-y"){
			Doc->m_Settings->m_EdGame->m_IndicatorY = atoi(Prop->GetValue());
		}

		else if(Prop->GetID()=="indicator-width"){
			Doc->m_Settings->m_EdGame->m_IndicatorWidth = atoi(Prop->GetValue());
		}

		else if(Prop->GetID()=="indicator-height"){
			Doc->m_Settings->m_EdGame->m_IndicatorHeight = atoi(Prop->GetValue());
		}

		else if(Prop->GetID()=="indicator-color"){
			BYTE r, g, b;
			CPLPropertyColor* ColProp = (CPLPropertyColor*)Prop;
			ColProp->GetRGB(r, g, b);
			Doc->m_Settings->m_EdGame->m_IndicatorColor = DRGBA(r, g, b, D3DCOLGetA(Doc->m_Settings->m_EdGame->m_IndicatorColor));
		}

		else if(Prop->GetID()=="indicator-alpha"){
			Doc->m_Settings->m_EdGame->m_IndicatorColor = DRGBA(D3DCOLGetR(Doc->m_Settings->m_EdGame->m_IndicatorColor), D3DCOLGetG(Doc->m_Settings->m_EdGame->m_IndicatorColor), D3DCOLGetB(Doc->m_Settings->m_EdGame->m_IndicatorColor), atoi(Prop->GetValue()));
		}

		else if(Prop->GetID()=="save-ext"){
			CBUtils::SetString(&Doc->m_Settings->m_SavedGameExt, (char*)LPCSTR(Prop->GetValue()));
		}

		else if(Prop->GetID()=="rich-save"){
			Doc->m_Settings->m_RichSavedGames = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}

	}


	//////////////////////////////////////////////////////////////////////////
	else if(Cat->GetID()=="debug"){

		if(Prop->GetID()=="debug-mode"){
			Doc->m_DebugMode = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}

		else if(Prop->GetID()=="show-fps"){
			Doc->m_ShowFPS = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}

		else if(Prop->GetID()=="allow-windowed"){
			Doc->m_AllowWindowed = (((CPLPropertyCombo*)Prop)->GetValueInt()!=0);
		}

		else if(Prop->GetID()=="console-mode"){
			Doc->m_ConsoleMode = ((CPLPropertyCombo*)Prop)->GetValueInt();
		}

	}


	//////////////////////////////////////////////////////////////////////////
	else if(Cat->GetID()=="package" && m_CurrentPackage){

		if(Prop->GetID()=="description"){
			m_CurrentPackage->m_Description = Prop->GetValue();
		}

		else if(Prop->GetID()=="cd"){
			m_CurrentPackage->m_CD = atoi(Prop->GetValue());
		}

		else if(Prop->GetID()=="priority"){
			m_CurrentPackage->m_Priority = atoi(Prop->GetValue());
		}

	}

}
HRESULT CViewProps::DisplayProps()
{
	if(!m_View) return E_FAIL;

	CProjectDoc* Doc = m_View->GetDocument();
	if(!Doc || !Doc->m_Settings) return E_FAIL;


	CPLPropertyEdit* pEdit;
	CPLPropertyCombo* pCombo;
	CPLPropertyEditEx* pEditEx;
	CPLCategory* cat;
	CPLPropertyColor* pColor;

	CString str;


	//////////////////////////////////////////////////////////////////////////
	cat = m_PropList.AddCategory("startup", LOC("/str0001/Startup settings"));
	
	pEdit = new CPLPropertyEdit("resolution-x", LOC("/str0002/Resolution - width"));
	pEdit->m_HelpFile = "resolution";
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 320, 3000);
	str.Format("%d", Doc->m_Settings->m_ResolutionWidth);
	pEdit->SetValue(str);

	pEdit = new CPLPropertyEdit("resolution-y", LOC("/str0003/Resolution - height"));
	pEdit->m_HelpFile = "resolution";
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 200, 3000);
	str.Format("%d", Doc->m_Settings->m_ResolutionHeight);
	pEdit->SetValue(str);

	pEdit = new CPLPropertyEdit("reg-path", LOC("/str0005/Registry path"));
	m_PropList.AddProperty(cat, pEdit);
	if(Doc->m_Settings->m_RegPath) pEdit->SetValue(Doc->m_Settings->m_RegPath);
	else pEdit->SetValue("");
/*
	pCombo = new CPLPropertyCombo("require-accel", LOC("/str0006/Require 3D accel."));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_RequireAcceleration?LOC("/str1000/Yes"):LOC("/str1001/No"));
*/
	pCombo = new CPLPropertyCombo("require-sound", LOC("/str1144/Require sound"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_RequireSound?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("hwtl-mode", LOC("/str1145/Hardware T&&L"));
	pCombo->AddValue(LOC("/str1146/don't use"), "0");
	pCombo->AddValue(LOC("/str1147/use when available"), "1");
	pCombo->AddValue(LOC("/str1148/ask user"), "2");
	m_PropList.AddProperty(cat,  pCombo);
	switch(Doc->m_Settings->m_TLMode)
	{
	case 0:
		pCombo->SetValue("0");
		break;
	case 2:
		pCombo->SetValue("2");
		break;
	default:
		pCombo->SetValue("1");
	}	

	pCombo = new CPLPropertyCombo("use-d3d9", LOC("/str1149/Use Direct3D 9"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_D3D9?LOC("/str1000/Yes"):LOC("/str1001/No"));


	pCombo = new CPLPropertyCombo("allow-windowed", LOC("/str0007/Allow windowed"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_AllowWindowed?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("allow-advanced", LOC("/str1115/Allow 3D settings"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_AllowAdvanced?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("allow-desktop-res", LOC("/str1186/Allow desktop resolution"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_AllowDesktopRes?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("allow-access-tab", LOC("/str1126/Allow accessibility"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_AllowAccessTab?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("allow-about-tab", LOC("/str1127/Allow about tab"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_AllowAboutTab?LOC("/str1000/Yes"):LOC("/str1001/No"));


	pEditEx = new CPLPropertyEditEx("string-table", LOC("/str0008/String table"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	pEditEx->SetValue(Doc->m_Settings->m_StringTableFilename);


	//////////////////////////////////////////////////////////////////////////
	cat = m_PropList.AddCategory("game", LOC("/str0009/Game settings"));

	pEdit = new CPLPropertyEdit("caption", LOC("/str0010/Caption"));
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValue(Doc->Game->m_Caption[0]);

	pEdit = new CPLPropertyEdit("name", LOC("/str0011/Name"));
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValue(Doc->Game->m_Name);

	pEditEx = new CPLPropertyEditEx("startup-scene", LOC("/str1087/Startup scene"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_StartupScene)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_StartupScene);

	pEditEx = new CPLPropertyEditEx("scripts", LOC("/str0012/Scripts"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonScripts, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->Game->m_Scripts.GetSize()==0) str = LOC("/str0013/[NO SCRIPTS]");
	else{
		str.Format("[%d %s]", Doc->Game->m_Scripts.GetSize(), Doc->Game->m_Scripts.GetSize()>1?LOC("/str0014/scripts"):LOC("/str0015/script"));
	}
	pEditEx->SetValue(str);


	pCombo = new CPLPropertyCombo("subtitles", LOC("/str0017/Speech subtitles"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_EdGame->m_Subtitles?LOC("/str1000/Yes"):LOC("/str1001/No"));


	pCombo = new CPLPropertyCombo("video-subtitles", LOC("/str0018/Video subtitles"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_EdGame->m_VideoSubtitles?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pEdit = new CPLPropertyEdit("subtitles-speed", LOC("/str0019/Subtitles speed"));
	m_PropList.AddProperty(cat, pEdit);
	CString val;
	val.Format("%d", Doc->m_Settings->m_EdGame->m_SubtitlesSpeed);
	pEdit->SetValue(val);

	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 10, 1000);


	pEditEx = new CPLPropertyEditEx("system-font", LOC("/str0020/System font"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_SystemFont)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_SystemFont);

	pEditEx = new CPLPropertyEditEx("video-font", LOC("/str0021/Video font"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_VideoFont)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_VideoFont);

	pEditEx = new CPLPropertyEditEx("cursor", LOC("/str0022/Cursor"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_Cursor)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_Cursor);

	pEditEx = new CPLPropertyEditEx("active-cursor", LOC("/str0023/Active cursor"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_ActiveCursor)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_ActiveCursor);

	pEditEx = new CPLPropertyEditEx("nonint-cursor", LOC("/str0024/Nonint.cursor"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_NoninteractiveCursor)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_NoninteractiveCursor);


	pEditEx = new CPLPropertyEditEx("inventory", LOC("/str0025/Inventory window"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_InventoryFile)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_InventoryFile);


	pEditEx = new CPLPropertyEditEx("response", LOC("/str0026/Response window"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_ResponseFile)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_ResponseFile);


	pEditEx = new CPLPropertyEditEx("items", LOC("/str0027/Items definition"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_ItemsFile)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_ItemsFile);


	pCombo = new CPLPropertyCombo("talk-skip", LOC("/str0028/Talk lines skipped by"));
	pCombo->AddValue(LOC("/str0029/left mouse button"), "left");
	pCombo->AddValue(LOC("/str0030/right mouse button"), "right");
	pCombo->AddValue(LOC("/str0031/both mouse buttons"), "both");
	m_PropList.AddProperty(cat,  pCombo);

	if(Doc->m_Settings->m_EdGame->m_TalkSkipButton==TALK_SKIP_RIGHT)
		pCombo->SetValue("right");
	else if(Doc->m_Settings->m_EdGame->m_TalkSkipButton==TALK_SKIP_BOTH)
		pCombo->SetValue("both");
	else
		pCombo->SetValue("left");


	pEditEx = new CPLPropertyEditEx("viewport", LOC("/str0032/Scene viewport"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonViewport, this);
	m_PropList.AddProperty(cat, pEditEx);

	RECT* rc = &Doc->m_Settings->m_EdGame->m_SceneViewport;
	if(IsRectEmpty(rc)) str = LOC("/str0033/[fullscreen]");
	else{		
		str.Format(CString("[") + LOC("/str0034/Pos:") + "%d,%d  " + LOC("/str0035/Size:") + "%dx%d]", rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top);
	}
	pEditEx->SetValue(str);


	pEditEx = new CPLPropertyEditEx("guid", LOC("/str1151/GUID"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonGUID, this);
	m_PropList.AddProperty(cat, pEditEx);

	if(Doc->m_Settings->m_GameGUID==GUID_NULL) str = "";
	else
	{
		LPOLESTR  olestr;
		StringFromIID(Doc->m_Settings->m_GameGUID, &olestr);
		str = CString(olestr);
		CoTaskMemFree(olestr);
	}
	pEditEx->SetValue(str);


	pEditEx = new CPLPropertyEditEx("compat", LOC("/str1177/Compatibility"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonCompat, this);
	m_PropList.AddProperty(cat, pEditEx);


	//////////////////////////////////////////////////////////////////////////
	cat = m_PropList.AddCategory("save", LOC("/str1091/Saved games"));
	cat->m_Expanded = false;

	pCombo = new CPLPropertyCombo("personal-save", LOC("/str0016/Personal savegames"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_EdGame->m_PersonalizedSave?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pEdit = new CPLPropertyEdit("save-path", LOC("/str1116/Save directory"));
	m_PropList.AddProperty(cat, pEdit);
	if(Doc->m_Settings->m_EdGame->m_LocalSaveDir) pEdit->SetValue(Doc->m_Settings->m_EdGame->m_LocalSaveDir);
	else pEdit->SetValue("");


	pEdit = new CPLPropertyEdit("thumbnail-width", LOC("/str1092/Thumbnail width"));
	pEdit->m_HelpFile = "thumbnail";
	m_PropList.AddProperty(cat, pEdit);	
	val.Format("%d", Doc->m_Settings->m_EdGame->m_ThumbnailWidth);
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 0, 400);


	pEdit = new CPLPropertyEdit("thumbnail-height", LOC("/str1093/Thumbnail height"));
	pEdit->m_HelpFile = "thumbnail";
	m_PropList.AddProperty(cat, pEdit);
	val.Format("%d", Doc->m_Settings->m_EdGame->m_ThumbnailHeight);
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 0, 400);

	pEdit = new CPLPropertyEdit("indicator-x", LOC("/str1097/Indicator X"));
	pEdit->m_HelpFile = "indicator";
	m_PropList.AddProperty(cat, pEdit);
	val.Format("%d", Doc->m_Settings->m_EdGame->m_IndicatorX);
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_SIGNED, false);

	pEdit = new CPLPropertyEdit("indicator-y", LOC("/str1098/Indicator Y"));
	pEdit->m_HelpFile = "indicator";
	m_PropList.AddProperty(cat, pEdit);
	val.Format("%d", Doc->m_Settings->m_EdGame->m_IndicatorY);
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_SIGNED, false);

	pEdit = new CPLPropertyEdit("indicator-width", LOC("/str1099/Indicator Width"));
	pEdit->m_HelpFile = "indicator";
	m_PropList.AddProperty(cat, pEdit);
	val.Format("%d", Doc->m_Settings->m_EdGame->m_IndicatorWidth);
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_SIGNED, false);

	pEdit = new CPLPropertyEdit("indicator-height", LOC("/str1100/Indicator Height"));
	pEdit->m_HelpFile = "indicator";
	m_PropList.AddProperty(cat, pEdit);
	val.Format("%d", Doc->m_Settings->m_EdGame->m_IndicatorHeight);
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_SIGNED, false);

	pColor = new CPLPropertyColor("indicator-color", LOC("/str1101/Indicator Color"));
	pColor->m_HelpFile = "indicator";
	m_PropList.AddProperty(cat, pColor);
	pColor->SetRGB(D3DCOLGetR(Doc->m_Settings->m_EdGame->m_IndicatorColor), D3DCOLGetG(Doc->m_Settings->m_EdGame->m_IndicatorColor), D3DCOLGetB(Doc->m_Settings->m_EdGame->m_IndicatorColor));


	pEdit = new CPLPropertyEdit("indicator-alpha", LOC("/str1102/Indicator Transparency"));
	pEdit->m_HelpFile = "indicator";
	m_PropList.AddProperty(cat, pEdit);
	val.Format("%d", D3DCOLGetA(Doc->m_Settings->m_EdGame->m_IndicatorColor));
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 0, 255);


	pEditEx = new CPLPropertyEditEx("save-load-image", LOC("/str1104/Save/load screen"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonSaveLoad, this);
	m_PropList.AddProperty(cat, pEditEx);

	if(Doc->m_Settings->m_EdGame->m_SaveImageName || Doc->m_Settings->m_EdGame->m_LoadImageName)
		str = LOC("/str1105/<set>");
	else
		str = LOC("/str1106/<not set>");
	pEditEx->SetValue(str);

	pEdit = new CPLPropertyEdit("save-ext", LOC("/str1158/File extension"));
	m_PropList.AddProperty(cat, pEdit);
	if(Doc->m_Settings->m_SavedGameExt) pEdit->SetValue(Doc->m_Settings->m_SavedGameExt);
	else pEdit->SetValue("");


	pCombo = new CPLPropertyCombo("rich-save", LOC("/str1157/Rich saved games"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_RichSavedGames?LOC("/str1000/Yes"):LOC("/str1001/No"));


	//////////////////////////////////////////////////////////////////////////
	cat = m_PropList.AddCategory("debug", LOC("/str0036/Debugging settings"));

	pCombo = new CPLPropertyCombo("debug-mode", LOC("/str0037/Debug mode"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_DebugMode?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("show-fps", LOC("/str0038/Show FPS"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_ShowFPS?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("allow-windowed", LOC("/str0039/Allow windowed"));
	pCombo->m_HelpFile = "allow-windowed-d";
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_AllowWindowed?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("console-mode", LOC("/str1129/Debugging console"));
	pCombo->AddValue(LOC("/str1130/Never"), "0");
	pCombo->AddValue(LOC("/str1131/In windowed mode"), "1");
	pCombo->AddValue(LOC("/str1132/Always"), "2");
	m_PropList.AddProperty(cat,  pCombo);
	switch(Doc->m_ConsoleMode)
	{
		case 0:
			pCombo->SetValue("0");
			break;
		case 2:
			pCombo->SetValue("2");
			break;
		default:
			pCombo->SetValue("1");
	}	

	pEditEx = new CPLPropertyEditEx("startup-scene-d", LOC("/str1087/Startup scene"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_DebugStartupScene)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_DebugStartupScene);


	//////////////////////////////////////////////////////////////////////////
	cat = m_PropList.AddCategory("package", LOC("/str0040/Selected package"));

	pEdit = new CPLPropertyEdit("description", LOC("/str0041/Description"));
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_ANY, true, 0, 100);

	/*
	pEdit = new CPLPropertyEdit("cd", LOC("/str0042/CD"));
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 0, 99);
	*/

	pEdit = new CPLPropertyEdit("priority", LOC("/str0043/Priority"));
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 0, 200);

	m_PropList.ShowCategory("package", false);

	return S_OK;
}