Beispiel #1
0
CDebugView::CDebugView ( CGUI * pManager, CVector2D & vecPosition ) : CChat ()
{
    CChat * pChat = g_pChat;
    g_pChat = this;

    m_pManager = pManager;    

    CVector2D vecResolution = m_pManager->GetResolution ();
    m_vecScale = CVector2D ( vecResolution.fX / 800.0f, vecResolution.fY / 600.0f );
    vecPosition = vecPosition * vecResolution;
    m_vecBackgroundPosition = vecPosition;

    m_bUseCEGUI = false;
    m_ulChatLineLife = 0;
    m_ulChatLineFadeOut = 0;
    m_bCssStyleText = false;
    m_bCssStyleBackground = false;
    m_bVisible = false;
    m_bInputVisible = false;
    m_uiNumLines = 7;
    m_uiMostRecentLine = 0;
    m_uiScrollOffset = 0;
    m_fSmoothScroll = 0;
    m_fSmoothLastTimeSeconds = 0;
    m_fSmoothAllowAfter = 0;
    m_fSmoothScrollResetTime = 0;
    m_fSmoothRepeatTimer = 0;
    m_pFont = m_pManager->GetBoldFont ();
    m_pDXFont = g_pCore->GetGraphics ()->GetFont ();
    m_fNativeWidth = DEBUGVIEW_WIDTH;
    m_bCanChangeWidth = false;
    m_iScrollingBack = 0;
    m_fCssStyleOverrideAlpha = 0.0f;
    m_fBackgroundAlpha = 0.0f;
    m_fInputBackgroundAlpha = 0.f;
    m_Color = CColor ( 0, 0, 0, 100 );
    m_TextColor = DEBUGVIEW_TEXT_COLOR;
    unsigned long ulBackgroundColor = COLOR_ARGB ( m_Color.A, m_Color.R, m_Color.G, m_Color.B );

    m_pBackground = m_pManager->CreateStaticImage ();
    m_pBackgroundTexture = m_pManager->CreateTexture ();

    m_pBackgroundTexture->LoadFromMemory ( &ulBackgroundColor, 1, 1 );
    m_pBackground->LoadFromTexture ( m_pBackgroundTexture );
    m_pBackground->MoveToBack ();
    m_pBackground->SetPosition ( m_vecBackgroundPosition );
    m_pBackground->SetSize ( m_vecBackgroundSize );
    m_pBackground->SetEnabled ( false );
    m_pBackground->SetVisible ( false );

    m_pInput = NULL;
    m_pInputTexture = NULL;

    g_pChat = pChat;

    UpdateGUI ();
}
Beispiel #2
0
static CVector2D EvaluateSpline(float t, CVector2D a0, CVector2D a1, CVector2D a2, CVector2D a3, float offset)
{
	// Compute position on spline
	CVector2D p = a0*(t*t*t) + a1*(t*t) + a2*t + a3;

	// Compute unit-vector direction of spline
	CVector2D dp = (a0*(3*t*t) + a1*(2*t) + a2).Normalized();

	// Offset position perpendicularly
	return p + CVector2D(dp.Y*-offset, dp.X*offset);
}
CVector2D CGUIElement_Impl::GetPosition ( bool bRelative )
{
    CEGUI::Point CEGUITemp;

	if ( bRelative )
		CEGUITemp = m_pWindow->getPosition ( CEGUI::Relative );
	else
		CEGUITemp = m_pWindow->getPosition ( CEGUI::Absolute );

    return CVector2D ( CEGUITemp.d_x, CEGUITemp.d_y );
}
CVector2D CGUIElement_Impl::GetSize ( bool bRelative )
{
	CEGUI::Size TempSize;

	if ( bRelative )
		TempSize = m_pWindow->getRelativeSize ();
	else
		TempSize = m_pWindow->getAbsoluteSize ();

	return CVector2D ( TempSize.d_width, TempSize.d_height );
}
Beispiel #5
0
void CQuestionBox::Show ( void )
{
    // Layout - Calc how many lines of text
    SString strMsg = m_pMessage->GetText ();
    unsigned int uiNumLines = std::count( strMsg.begin(), strMsg.end(), '\n' ) + 1;

    float fEditHeight = 29.0f;
    float fEditSpacer = 10.0f;

    float fMsgWidth = Max ( 400.f, m_pMessage->GetTextExtent () + 50.f );
    float fMsgHeight = Max < float > ( 3, uiNumLines ) * ( m_pMessage->GetFontHeight () + 1 );
    float fWinWidth = Max ( fMsgWidth, m_uiActiveButtons * ( 112 + 10.f ) );
    float fWinHeight = 50 + fMsgHeight + 50 + 30 + ( m_uiActiveEditboxes * ( fEditHeight + 2*fEditSpacer ) ) ;

    CVector2D resolution = CCore::GetSingleton().GetGUI()->GetResolution();
    m_pWindow->SetPosition ( CVector2D ( resolution.fX / 2 - fWinWidth / 2, resolution.fY / 2 - fWinHeight / 2  ), false );
    m_pWindow->SetSize ( CVector2D ( fWinWidth, fWinHeight + 10  ), false );

    m_pMessage->SetPosition ( CVector2D ( fWinWidth / 2 - fMsgWidth / 2, fWinHeight / 2 - fMsgHeight / 2 - 10  ), false );
    m_pMessage->SetSize ( CVector2D ( fMsgWidth, fMsgHeight ), false );
    m_pMessage->SetHorizontalAlign ( CGUI_ALIGN_HORIZONTALCENTER );

    // One editbox takes the entire width, position them like so
    for ( unsigned int i = 0 ; i < m_EditList.size () ; i++ )
    {
        if ( i < m_uiActiveButtons )
        {
            m_EditList[ i ]->SetPosition ( CVector2D ( 0, (fWinHeight / 2 - fMsgHeight / 2 - 10) + fMsgHeight + (i+1)*fEditSpacer + i*fEditHeight ), false );
            m_EditList[ i ]->SetSize ( CVector2D ( fWinWidth - 20, fEditHeight ), false );
        }
    }

    // Position the buttons evenly across the bottom
    float fSpaceBetween = ( fWinWidth - ( m_uiActiveButtons * 112 ) ) / ( m_uiActiveButtons + 1 ) + m_uiActiveEditboxes ? fEditSpacer : 0;

    for ( unsigned int i = 0 ; i < m_ButtonList.size () ; i++ )
    {
        if ( i < m_uiActiveButtons )
        {
            float fPosX = fWinWidth - ( ( i + 1 ) * fSpaceBetween + i * 112 ) - 112;
            m_ButtonList[ i ]->SetPosition ( CVector2D ( fPosX, fWinHeight - 35  ), false );
            m_ButtonList[ i ]->SetSize ( CVector2D ( 112, 24 ), false );
        }
    }

    m_pWindow->SetVisible ( true );
    m_pWindow->Activate ();
    m_pWindow->SetAlwaysOnTop ( true );
    m_pWindow->BringToFront ();
    g_pCore->RemoveMessageBox ();
}
Beispiel #6
0
CVector2D CEntity::GetScreenCoords( float height )
{
	CCamera &camera = *g_Game->GetView()->GetCamera();

	float sx, sy;
	CVector3D above;
	above.X = m_position.X;
	above.Z = m_position.Z;
	above.Y = GetAnchorLevel(m_position.X, m_position.Z) + height;
	camera.GetScreenCoordinates(above, sx, sy);
	return CVector2D( sx, sy );
}
double
CQIllustratorShape::
getStrokeWidth() const
{
  const CMatrix2D &m = getFlatMatrix();

  double w = getStroke().getWidth();

  CVector2D w1 = m*CVector2D(w, w);

  return w1.length();
}
void CClientWeapon::SetDirection ( CVector & vecDirection )
{
    CVector vecRotation;
    GetRotationRadians ( vecRotation );

    vecRotation.fZ = atan2 ( vecDirection.fY, vecDirection.fX );
    CVector2D vecTemp ( vecDirection.fX, vecDirection.fY );
    float length = vecTemp.Length ();
    vecTemp = CVector2D ( length, vecDirection.fZ );
    vecTemp.Normalize ();
    vecRotation.fY = atan2 ( vecTemp.fX, vecTemp.fY )/* - ConvertDegreesToRadians ( 90 )*/;
    
    SetRotationRadians ( vecRotation );
}
Beispiel #9
0
Noise2D::Noise2D(int f) 
{
	freq = f;
	grads = new CVector2D*[freq];
	for(int i=0; i<freq; i++) 
	{
		grads[i] = new CVector2D[freq];
		for(int j=0; j<freq; j++) 
		{
			float a = randFloat() * 2 * (float)M_PI;
			grads[i][j] = CVector2D(cos(a), sin(a));
		}
	}
}
	/*
		Returns the derivative at the specified grid location.
		By default this function returns central differences.

		Due to the interpolation this function uses it implicitly returs 
		forward/backward differences at the respective grid boundaries.
	*/
	CVector2D CScalarField2D::_getDerivative(float x, float y) const
	{
		static float step = .5f;
		static float div = 2.0f*step;

		/*float f1(_getValue(x-step, y));
		float f2(_getValue(x+step, y));
		float f3(_getValue(x, y-step));
		float f4(_getValue(x, y+step));

		return CVector2D( (f2-f1)/div, (f4-f3)/div );*/

		return CVector2D( (_getValue(x+step, y)-_getValue(x-step, y))/div, (_getValue(x, y+step)-_getValue(x, y-step))/div );
	}
Beispiel #11
0
////////////////////////////////////////////////////
//
//  CNewsBrowser::CreateGUI
//
//
//
////////////////////////////////////////////////////
void CNewsBrowser::CreateGUI(void)
{
    CreateHeadlines();
    CGUI* pManager = g_pCore->GetGUI();

    // Create the window
    m_pWindow = reinterpret_cast<CGUIWindow*>(pManager->CreateWnd(NULL, "NEWS"));
    m_pWindow->SetCloseButtonEnabled(true);
    m_pWindow->SetMovable(true);

    CVector2D resolution = CCore::GetSingleton().GetGUI()->GetResolution();
    float     yoff = resolution.fY > 600 ? resolution.fY / 12 : 0.0f;
    m_pWindow->SetPosition(CVector2D(resolution.fX / 2 - 640.0f / 2, resolution.fY / 2 - 480.0f / 2 + yoff), false);
    m_pWindow->SetSize(CVector2D(640.0f, 480.0f));
    m_pWindow->SetSizingEnabled(false);
    m_pWindow->SetAlwaysOnTop(true);

    // Create buttons
    //  OK button
    m_pButtonOK = reinterpret_cast<CGUIButton*>(pManager->CreateButton(m_pWindow, "OK"));
    m_pButtonOK->SetPosition(CVector2D(560.0f - 60, 480.0f - 30));
    m_pButtonOK->SetZOrderingEnabled(false);

    // Set up the events
    m_pWindow->SetEnterKeyHandler(GUI_CALLBACK(&CNewsBrowser::OnOKButtonClick, this));
    m_pButtonOK->SetClickHandler(GUI_CALLBACK(&CNewsBrowser::OnOKButtonClick, this));

    // Create the tab panel and necessary tabs
    m_pTabPanel = reinterpret_cast<CGUITabPanel*>(pManager->CreateTabPanel(m_pWindow));
    m_pTabPanel->SetPosition(CVector2D(0, 20.0f));
    m_pTabPanel->SetSize(CVector2D(640.0f, 480.0f - 60));

    for (uint i = 0; i < m_NewsitemList.size(); i++)
    {
        AddNewsTab(m_NewsitemList[i]);
    }
}
Beispiel #12
0
void CMainMenu::SetMenuVerticalPosition(int iPosY)
{
    if (m_pHoveredItem)
    {
        m_unhoveredItems.insert(m_pHoveredItem);
        m_pHoveredItem = NULL;
    }

    float fFirstItemSize = m_menuItems.front()->image->GetSize(false).fY;
    int   iMoveY = iPosY - m_menuItems.front()->image->GetPosition(false).fY - fFirstItemSize * 0.5f;

    std::deque<sMenuItem*>::iterator it = m_menuItems.begin();
    for (it; it != m_menuItems.end(); it++)
    {
        CVector2D vOrigPos = (*it)->image->GetPosition(false);
        (*it)->drawPositionY = (*it)->drawPositionY + iMoveY;
        (*it)->image->SetPosition(CVector2D(vOrigPos.fX, vOrigPos.fY + iMoveY), false);
    }

    m_menuAY = m_menuAY + iMoveY;
    m_menuBY = m_menuBY + iMoveY;
    m_pMenuArea->SetPosition(CVector2D(m_menuAX - m_iXOff, m_menuAY - m_iYOff) + BODGE_FACTOR_5, false);
    m_pMenuArea->SetSize(CVector2D(m_menuBX - m_menuAX, m_menuBY - m_menuAY) + BODGE_FACTOR_6, false);
}
Beispiel #13
0
Void CRCMode::RCModelEstimator (UInt n_windowSize)
{
	UInt n_realSize = n_windowSize;
	UInt i;
	for (i = 0; i < n_windowSize; i++) {// find the number of samples which are not rejected
		if (m_rgRejected[i])
			n_realSize--;
	}

	// default RD model estimation results
	Bool estimateX2 = FALSE;
	m_X1 = m_X2 = 0.0;
	Double oneSampleQ = 0.0;
	for (i = 0; i < n_windowSize; i++)	{
		if (!m_rgRejected[i])
			oneSampleQ = m_rgQp[i];
	}
	for (i = 0; i < n_windowSize; i++)	{// if all non-rejected Q are the same, take 1st order model
		if ((m_rgQp[i] != oneSampleQ) && !m_rgRejected[i])
			estimateX2 = TRUE;
		if (!m_rgRejected[i])
			m_X1 += (m_rgQp[i] * m_rgRp[i]) / n_realSize;
	}

	// take 2nd order model to estimate X1 and X2
	if ((n_realSize >= 1) && estimateX2) {
		Double a00 = 0.0, a01 = 0.0, a10 = 0.0, a11 = 0.0, b0 = 0.0, b1 = 0.0;
		for (UInt i = 0; i < n_windowSize; i++) {
			if (!m_rgRejected[i]) {
				a00 = a00 + 1.0;
				a01 += 1.0 / m_rgQp[i];
				a10 = a01;
				a11 += 1.0 / (m_rgQp[i] * m_rgQp[i]);
				b0 += m_rgQp[i] * m_rgRp[i];
				b1 += m_rgRp[i];
			}
		}
		// solve the equation of AX = B
		CMatrix2x2D A = CMatrix2x2D (a00, a01, a10, a11);
		CMatrix2x2D AInv = A.inverse ();
		CVector2D B = CVector2D (b0, b1);
		CVector2D solution = AInv.apply (B);
		if (solution.x != 0.0) {
			m_X1 = solution.x;
			m_X2 = solution.y;
		}	
	}
}
Beispiel #14
0
CMaterial::CMaterial(CXMaterial &m) {
	faceColor = m.faceColor;
	power = m.power;
	specularColor = m.specularColor;
	emissiveColor = m.emissiveColor;
	st = CVector2D(0, 0);
	alpha = 1.0f;
	if (strlen(m.filename)) {
		texture = new CTexture();
		if (!texture->Load(m.filename)) {
			delete texture;
			texture = NULL;
		}
	}
	else {
		texture = NULL;
	}
}
Beispiel #15
0
int CLuaVector2Defs::Unm ( lua_State* luaVM )
{
    CLuaVector2D* pVector = NULL;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pVector );

    if ( !argStream.HasErrors () )
    {
        lua_pushvector ( luaVM, CVector2D () - *pVector );
        return 1;
    }
    else
    {
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
    }

    lua_pushboolean ( luaVM, false );
    return 1;
}
Beispiel #16
0
void CDebugView::Draw ( void )
{
    // Are we visible?
    if ( !m_bVisible )
        return;

    // Make the chat use our data, dirty as you like!
    CChat * pChat = g_pChat;
    g_pChat = this;

    // Force the window on screen
    CVector2D vecPosition ( 0.23f, 0.985f );
    CVector2D vecResolution = m_pManager->GetResolution ();
    float height = m_uiNumLines * GetFontHeight ( 1 ) * m_vecScale.fY;
    m_vecBackgroundPosition = vecPosition * vecResolution - CVector2D ( 0, height );
    m_pBackground->SetPosition ( m_vecBackgroundPosition );

    CChat::Draw ();
    g_pChat = pChat;
}
Beispiel #17
0
void CMainMenu::SetNewsHeadline(int iIndex, const SString& strHeadline, const SString& strDate, bool bIsNew)
{
    if (iIndex < 0 || iIndex > 2)
        return;

    m_pLatestNews->SetVisible(true);

    // Headline
    CGUILabel* pItem = m_pNewsItemLabels[iIndex];
    CGUILabel* pItemShadow = m_pNewsItemShadowLabels[iIndex];
    SColor     color = headlineColors[iIndex];
    pItem->SetTextColor(color.R, color.G, color.B);
    pItem->SetText(strHeadline);
    pItemShadow->SetText(strHeadline);

    // Switch font if it's too big
    if (pItem->GetSize(false).fX < pItem->GetTextExtent())
    {
        const char* szFontName = "default-bold-small";
        for (char i = 0; i < CORE_MTA_NEWS_ITEMS; i++)
        {
            // Try default-bold-small first, if that's too big use default-small
            m_pNewsItemLabels[i]->SetFont(szFontName);
            m_pNewsItemShadowLabels[i]->SetFont(szFontName);
            if (strcmp(szFontName, "default-small") && (m_pNewsItemLabels[i]->GetSize(false).fX < m_pNewsItemLabels[i]->GetTextExtent()))
            {
                szFontName = "default-small";
                i = -1;
            }
        }
    }

    // Set our Date labels
    CGUILabel* pItemDate = m_pNewsItemDateLabels[iIndex];
    pItemDate->SetText(strDate);

    // 'NEW' sticker
    CGUILabel* pNewLabel = m_pNewsItemNEWLabels[iIndex];
    pNewLabel->SetVisible(bIsNew);
    pNewLabel->SetPosition(CVector2D(pItem->GetPosition().fX + 4, pItem->GetPosition().fY - 4));
}
Beispiel #18
0
// Ensure CVars are within reasonable limits
void CClientVariables::ValidateValues ( void )
{
    uint uiViewportWidth = CCore::GetSingleton().GetGraphics ()->GetViewportWidth ();
    uint uiViewportHeight = CCore::GetSingleton().GetGraphics ()->GetViewportHeight ();

    ClampValue ( "console_pos",             CVector2D ( 0, 0 ),         CVector2D ( uiViewportWidth - 32, uiViewportHeight - 32 ) );
    ClampValue ( "console_size",            CVector2D ( 50, 50 ),       CVector2D ( uiViewportWidth - 32, uiViewportHeight - 32 ) );
    ClampValue ( "fps_limit",               0,                          100 );
    ClampValue ( "chat_font",               0,                          3 );
    ClampValue ( "chat_lines",              3,                          62 );
    ClampValue ( "chat_color",              CColor (0,0,0,0),           CColor (255,255,255,255) );
    ClampValue ( "chat_text_color",         CColor (0,0,0,128),         CColor (255,255,255,255) );
    ClampValue ( "chat_input_color",        CColor (0,0,0,0),           CColor (255,255,255,255) );
    ClampValue ( "chat_input_prefix_color", CColor (0,0,0,128),         CColor (255,255,255,255) );
    ClampValue ( "chat_input_text_color",   CColor (0,0,0,128),         CColor (255,255,255,255) );
    ClampValue ( "chat_scale",              CVector2D ( 0.5f, 0.5f ),   CVector2D ( 3, 3 ) );
    ClampValue ( "chat_width",              0.5f,                       4.f );
    ClampValue ( "chat_line_life",          1000,                       120000000 );
    ClampValue ( "chat_line_fade_out",      1000,                       30000000 );
    ClampValue ( "text_scale",              0.8f,                       3.0f );
    ClampValue ( "mtavolume",               0.0f,                       1.0f );
    ClampValue ( "voicevolume",             0.0f,                       1.0f );
    ClampValue ( "mapalpha",                0,                          255 );
}
void CClientVariables::LoadDefaults ( void )
{
    #define DEFAULT(__x,__y)    if(!Exists(__x)) \
                                Set(__x,__y)
    #define _S(__x)             std::string(__x)

    if(!Exists("nick")) 
    {
        DEFAULT ( "nick",                       _S(GenerateNickname()) );       // nickname
        CCore::GetSingleton ().RequestNewNickOnStart();  // Request the user to set a new nickname
    }

    DEFAULT ( "host",                       _S("127.0.0.1") );              // hostname
    DEFAULT ( "port",                       22003 );                        // port
    DEFAULT ( "password",                   _S("") );                       // password
    DEFAULT ( "qc_host",                    _S("127.0.0.1") );              // quick connect hostname
    DEFAULT ( "qc_port",                    22003 );                        // quick connect port
    DEFAULT ( "qc_password",                _S("") );                       // quick connect password
    DEFAULT ( "debugfile",                  _S("") );                       // debug filename
    DEFAULT ( "console_pos",                CVector2D ( 0, 0 ) );           // console position
    DEFAULT ( "console_size",               CVector2D ( 200, 200 ) );       // console size
    DEFAULT ( "serverbrowser_size",         CVector2D ( 720.0f, 495.0f ) ); // serverbrowser size
    DEFAULT ( "fps_limit",                  100 );                          // frame limiter
    DEFAULT ( "chat_font",                  0 );                            // chatbox font type
    DEFAULT ( "chat_lines",                 7 );                            // chatbox lines
    DEFAULT ( "chat_color",                 CColor (0,0,128,100) );         // chatbox color
    DEFAULT ( "chat_text_color",            CColor (172,213,254,255) );     // chatbox text color
    DEFAULT ( "chat_input_color",           CColor (0,0,191,110) );         // chatbox input color
    DEFAULT ( "chat_input_prefix_color",    CColor (172,213,254,255) );     // chatbox prefix input color
    DEFAULT ( "chat_input_text_color",      CColor (172,213,254,255) );     // chatbox text input color
    DEFAULT ( "chat_scale",                 CVector2D ( 1.0f, 1.0f ) );     // chatbox scale
    DEFAULT ( "chat_width",                 1.0f );                         // chatbox width
    DEFAULT ( "chat_css_style_text",        false );                        // chatbox css/hl style text
    DEFAULT ( "chat_css_style_background",  false );                        // chatbox css/hl style background
    DEFAULT ( "chat_line_life",             12000 );                        // chatbox line life time
    DEFAULT ( "chat_line_fade_out",         3000 );                         // chatbox line fade out time
    DEFAULT ( "chat_use_cegui",             false );                        // chatbox uses cegui
    DEFAULT ( "text_scale",                 1.0f );                         // text scale
    DEFAULT ( "invert_mouse",               false );                        // mouse inverting
    DEFAULT ( "fly_with_mouse",             false );                        // flying with mouse controls
    DEFAULT ( "steer_with_mouse",           false );                        // steering with mouse controls
    DEFAULT ( "classic_controls",           false );                        // classic/standard controls
    DEFAULT ( "mtavolume",                  1.0f );                         // custom sound's volume
    DEFAULT ( "voicevolume",                1.0f );                         // voice chat output volume
    DEFAULT ( "mapalpha",                   155 );                          // map alpha
    DEFAULT ( "browser_speed",              2 );                            // Browser speed
    DEFAULT ( "single_download",            0 );                            // Single connection for downloads
    DEFAULT ( "update_build_type",          0 );                            // 0-stable 1-test 2-nightly
    DEFAULT ( "volumetric_shadows",         0 );                            // Enable volumetric shadows
    DEFAULT ( "aspect_ratio",               0 );                            // Display aspect ratio
    DEFAULT ( "hud_match_aspect_ratio",     1 );                            // GTA HUD should match the display aspect ratio
    DEFAULT ( "anisotropic",                0 );                            // Anisotropic filtering
    DEFAULT ( "grass",                      1 );                            // Enable grass
    DEFAULT ( "heat_haze",                  1 );                            // Enable heat haze
    DEFAULT ( "fast_clothes_loading",       1 );                            // 0-off 1-auto 2-on
    DEFAULT ( "allow_screen_upload",        1 );                            // 0-off 1-on
    DEFAULT ( "max_clientscript_log_kb",    5000 );                         // Max size in KB (0-No limit)
    DEFAULT ( "display_fullscreen_style",   0 );                            // 0-standard 1-borderless 2-borderless keep res 3-borderless stretch
    DEFAULT ( "display_windowed",           0 );                            // 0-off 1-on
    DEFAULT ( "multimon_fullscreen_minimize", 1 );                          // 0-off 1-on
    DEFAULT ( "vertical_aim_sensitivity",   0.0015f );                      // 0.0015f is GTA default setting
    DEFAULT ( "process_priority",           0 );                            // 0-normal 1-above normal 2-high
    DEFAULT ( "mute_sfx_when_minimized",    0 );                            // 0-off 1-on
    DEFAULT ( "mute_radio_when_minimized",  0 );                            // 0-off 1-on
    DEFAULT ( "mute_mta_when_minimized",    0 );                            // 0-off 1-on
    DEFAULT ( "mute_voice_when_minimized",  0 );                            // 0-off 1-on

    // We will default this one at CClientGame.cpp, because we need a valid direct3d device to give a proper default value.
#if 0
    DEFAULT ( "streaming_memory",           50 );                           // Streaming memory
#endif
}
CVector2D CGUIElement_Impl::RelativeToAbsolute ( const CVector2D& Vector )
{
    CEGUI::Size TempSize = CEGUI::Size ( Vector.fX, Vector.fY );
    TempSize = m_pWindow->relativeToAbsolute ( TempSize );
    return CVector2D ( TempSize.d_width, TempSize.d_height );
}
CVector2D CGUIElement_Impl::GetMaximumSize ( void )
{
    const CEGUI::Size& TempSize = m_pWindow->getMaximumSize ();
    return CVector2D ( TempSize.d_width, TempSize.d_height );
}
Beispiel #22
0
// This requires m_DistanceHeightmap to be defined properly.
void WaterManager::CreateWaveMeshes()
{
	size_t SideSize = m_MapSize*2;
	CTerrain* terrain = g_Game->GetWorld()->GetTerrain();

	for (WaveObject* const& obj : m_ShoreWaves)
	{
		if (obj->m_VBvertices)
			g_VBMan.Release(obj->m_VBvertices);
		delete obj;
	}
	m_ShoreWaves.clear();

	if (m_ShoreWaves_VBIndices)
	{
		g_VBMan.Release(m_ShoreWaves_VBIndices);
		m_ShoreWaves_VBIndices = NULL;
	}

	if (m_Waviness < 5.0f && m_WaterType != L"ocean")
		return;
		
	// First step: get the points near the coast.
	std::set<int> CoastalPointsSet;
	for (size_t z = 1; z < SideSize-1; ++z)
		for (size_t x = 1; x < SideSize-1; ++x)
			if (fabs(m_DistanceHeightmap[z*SideSize + x]-1.0f) < 0.2f)
				CoastalPointsSet.insert(z*SideSize + x);
	
	// Second step: create chains out of those coastal points.
	static const int around[8][2] = { { -1,-1 }, { -1,0 }, { -1,1 }, { 0,1 }, { 1,1 }, { 1,0 }, { 1,-1 }, { 0,-1 } };

	std::vector<std::deque<CoastalPoint> > CoastalPointsChains;
	while (!CoastalPointsSet.empty())
	{
		int index = *(CoastalPointsSet.begin());
		int x = index % SideSize;
		int y = (index - x ) / SideSize;
		
		std::deque<CoastalPoint> Chain;
		
		Chain.push_front(CoastalPoint(index,CVector2D(x*2,y*2)));
		
		// Erase us.
		CoastalPointsSet.erase(CoastalPointsSet.begin());
		
		// We're our starter points. At most we can have 2 points close to us.
		// We'll pick the first one and look for its neighbors (he can only have one new)
		// Up until we either reach the end of the chain, or ourselves.
		// Then go down the other direction if there is any.
		int neighbours[2] = { -1, -1 };
		int nbNeighb = 0;
		for (int i = 0; i < 8; ++i)
		{
			if (CoastalPointsSet.count(x + around[i][0] + (y + around[i][1])*SideSize))
			{
				if (nbNeighb < 2)
					neighbours[nbNeighb] = x + around[i][0] + (y + around[i][1])*SideSize;
				++nbNeighb;
			}
		}
		if (nbNeighb > 2)
			continue;

		for (int i = 0; i < 2; ++i)
		{
			if (neighbours[i] == -1)
				continue;
			// Move to our neighboring point
			int xx = neighbours[i] % SideSize;
			int yy = (neighbours[i] - xx ) / SideSize;
			int indexx = xx + yy*SideSize;
			int endedChain = false;
			
			if (i == 0)
				Chain.push_back(CoastalPoint(indexx,CVector2D(xx*2,yy*2)));
			else
				Chain.push_front(CoastalPoint(indexx,CVector2D(xx*2,yy*2)));

			// If there's a loop we'll be the "other" neighboring point already so check for that.
			// We'll readd at the end/front the other one to have full squares.
			if (CoastalPointsSet.count(indexx) == 0)
				break;
						
			CoastalPointsSet.erase(indexx);

			// Start checking from there.
			while(!endedChain)
			{
				bool found = false;
				nbNeighb = 0;
				for (int p = 0; p < 8; ++p)
				{
					if (CoastalPointsSet.count(xx+around[p][0] + (yy + around[p][1])*SideSize))
					{
						if (nbNeighb >= 2)
						{
							CoastalPointsSet.erase(xx + yy*SideSize);
							continue;
						}
						++nbNeighb;
						// We've found a new point around us.
						// Move there
						xx = xx + around[p][0];
						yy = yy + around[p][1];
						indexx = xx + yy*SideSize;
						if (i == 0)
							Chain.push_back(CoastalPoint(indexx,CVector2D(xx*2,yy*2)));
						else
							Chain.push_front(CoastalPoint(indexx,CVector2D(xx*2,yy*2)));
						CoastalPointsSet.erase(xx + yy*SideSize);
						found = true;
						break;
					}
				}
				if (!found)
					endedChain = true;
			}
		}
		if (Chain.size() > 10)
			CoastalPointsChains.push_back(Chain);
	}
		
	// (optional) third step: Smooth chains out.
	// This is also really dumb.
	for (size_t i = 0; i < CoastalPointsChains.size(); ++i)
	{
		// Bump 1 for smoother.
		for (int p = 0; p < 3; ++p)
		{
			for (size_t j = 1; j < CoastalPointsChains[i].size()-1; ++j)
			{
				CVector2D realPos = CoastalPointsChains[i][j-1].position + CoastalPointsChains[i][j+1].position;
				
				CoastalPointsChains[i][j].position = (CoastalPointsChains[i][j].position + realPos/2.0f)/2.0f;
			}
		}
	}
	
	// Fourth step: create waves themselves, using those chains. We basically create subchains.
	size_t waveSizes = 14;	// maximal size in width.
	
	// Construct indices buffer (we can afford one for all of them)
	std::vector<GLushort> water_indices;
	for (size_t a = 0; a < waveSizes-1;++a)
	{
		for (size_t rect = 0; rect < 7; ++rect)
		{
			water_indices.push_back(a*9 + rect);
			water_indices.push_back(a*9 + 9 + rect);
			water_indices.push_back(a*9 + 1 + rect);
			water_indices.push_back(a*9 + 9 + rect);
			water_indices.push_back(a*9 + 10 + rect);
			water_indices.push_back(a*9 + 1 + rect);
		}
	}
	// Generic indexes, max-length
	m_ShoreWaves_VBIndices = g_VBMan.Allocate(sizeof(GLushort), water_indices.size(), GL_STATIC_DRAW, GL_ELEMENT_ARRAY_BUFFER);
	m_ShoreWaves_VBIndices->m_Owner->UpdateChunkVertices(m_ShoreWaves_VBIndices, &water_indices[0]);
	
	float diff = (rand() % 50) / 5.0f;
	
	for (size_t i = 0; i < CoastalPointsChains.size(); ++i)
	{
		for (size_t j = 0; j < CoastalPointsChains[i].size()-waveSizes; ++j)
		{
			if (CoastalPointsChains[i].size()- 1 - j < waveSizes)
				break;
			
			size_t width = waveSizes;
			
			// First pass to get some parameters out.
			float outmost = 0.0f;	// how far to move on the shore.
			float avgDepth = 0.0f;
			int sign = 1;
			CVector2D firstPerp(0,0), perp(0,0), lastPerp(0,0);
			for (size_t a = 0; a < waveSizes;++a)
			{
				lastPerp = perp;
				perp = CVector2D(0,0);
				int nb = 0;
				CVector2D pos = CoastalPointsChains[i][j+a].position;
				CVector2D posPlus;
				CVector2D posMinus;
				if (a > 0)
				{
					++nb;
					posMinus = CoastalPointsChains[i][j+a-1].position;
					perp += pos-posMinus;
				}
				if (a < waveSizes-1)
				{
					++nb;
					posPlus = CoastalPointsChains[i][j+a+1].position;
					perp += posPlus-pos;
				}
				perp /= nb;
				perp = CVector2D(-perp.Y,perp.X).Normalized();
				
				if (a == 0)
					firstPerp = perp;
				
				if ( a > 1 && perp.Dot(lastPerp) < 0.90f && perp.Dot(firstPerp) < 0.70f)
				{
					width = a+1;
					break;
				}
				
				if (m_BlurredNormalMap[ (int)(pos.X/4) + (int)(pos.Y/4)*m_MapSize].Y < 0.9)
				{
					width = a-1;
					break;
				}
				
				if (terrain->GetExactGroundLevel(pos.X+perp.X*1.5f, pos.Y+perp.Y*1.5f) > m_WaterHeight)
					sign = -1;
				
				avgDepth += terrain->GetExactGroundLevel(pos.X+sign*perp.X*20.0f, pos.Y+sign*perp.Y*20.0f) - m_WaterHeight;
				
				float localOutmost = -2.0f;
				while (localOutmost < 0.0f)
				{
					float depth = terrain->GetExactGroundLevel(pos.X+sign*perp.X*localOutmost, pos.Y+sign*perp.Y*localOutmost) - m_WaterHeight;
					if (depth < 0.0f || depth > 0.6f)
						localOutmost += 0.2f;
					else
						break;
				}

				outmost += localOutmost;
			}
			if (width < 5)
			{
				j += 6;
				continue;
			}

			outmost /= width;
			
			if (outmost > -0.5f)
			{
				j += 3;
				continue;
			}
			outmost = -0.5f + outmost * m_Waviness/10.0f;

			avgDepth /= width;

			if (avgDepth > -1.3f)
			{
				j += 3;
				continue;
			}
			// we passed the checks, we can create a wave of size "width".
			
			WaveObject* shoreWave = new WaveObject;
			std::vector<SWavesVertex> vertices;

			shoreWave->m_Width = width;
			shoreWave->m_TimeDiff = diff;
			diff += (rand() % 100) / 25.0f + 4.0f;

			for (size_t a = 0; a < width;++a)
			{
				CVector2D perp = CVector2D(0,0);
				int nb = 0;
				CVector2D pos = CoastalPointsChains[i][j+a].position;
				CVector2D posPlus;
				CVector2D posMinus;
				if (a > 0)
				{
					++nb;
					posMinus = CoastalPointsChains[i][j+a-1].position;
					perp += pos-posMinus;
				}
				if (a < waveSizes-1)
				{
					++nb;
					posPlus = CoastalPointsChains[i][j+a+1].position;
					perp += posPlus-pos;
				}
				perp /= nb;
				perp = CVector2D(-perp.Y,perp.X).Normalized();
				
				SWavesVertex point[9];
				
				float baseHeight = 0.04f;
				
				float halfWidth = (width-1.0f)/2.0f;
				float sideNess = sqrtf(clamp( (halfWidth - fabsf(a-halfWidth))/3.0f, 0.0f,1.0f));
				
				point[0].m_UV[0] = a; point[0].m_UV[1] = 8;
				point[1].m_UV[0] = a; point[1].m_UV[1] = 7;
				point[2].m_UV[0] = a; point[2].m_UV[1] = 6;
				point[3].m_UV[0] = a; point[3].m_UV[1] = 5;
				point[4].m_UV[0] = a; point[4].m_UV[1] = 4;
				point[5].m_UV[0] = a; point[5].m_UV[1] = 3;
				point[6].m_UV[0] = a; point[6].m_UV[1] = 2;
				point[7].m_UV[0] = a; point[7].m_UV[1] = 1;
				point[8].m_UV[0] = a; point[8].m_UV[1] = 0;
				
				point[0].m_PerpVect = perp;
				point[1].m_PerpVect = perp;
				point[2].m_PerpVect = perp;
				point[3].m_PerpVect = perp;
				point[4].m_PerpVect = perp;
				point[5].m_PerpVect = perp;
				point[6].m_PerpVect = perp;
				point[7].m_PerpVect = perp;
				point[8].m_PerpVect = perp;
				
				static const float perpT1[9] = { 6.0f, 6.05f, 6.1f, 6.2f, 6.3f, 6.4f, 6.5f, 6.6f, 9.7f };
				static const float perpT2[9] = { 2.0f, 2.1f,  2.2f, 2.3f, 2.4f, 3.0f, 3.3f, 3.6f, 9.5f };
				static const float perpT3[9] = { 1.1f, 0.7f, -0.2f, 0.0f, 0.6f, 1.3f, 2.2f, 3.6f, 9.0f };
				static const float perpT4[9] = { 2.0f, 2.1f,  1.2f, 1.5f, 1.7f, 1.9f, 2.7f, 3.8f, 9.0f };
				
				static const float heightT1[9] = { 0.0f, 0.2f, 0.5f, 0.8f, 0.9f, 0.85f, 0.6f, 0.2f, 0.0 };
				static const float heightT2[9] = { -0.8f, -0.4f, 0.0f, 0.1f, 0.1f, 0.03f, 0.0f, 0.0f, 0.0 };
				static const float heightT3[9] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0 };

				for (size_t t = 0; t < 9; ++t)
				{
					float terrHeight = 0.05f + terrain->GetExactGroundLevel(pos.X+sign*perp.X*(perpT1[t]+outmost),
																			pos.Y+sign*perp.Y*(perpT1[t]+outmost));
					point[t].m_BasePosition = CVector3D(pos.X+sign*perp.X*(perpT1[t]+outmost), baseHeight + heightT1[t]*sideNess + std::max(m_WaterHeight,terrHeight),
														pos.Y+sign*perp.Y*(perpT1[t]+outmost));
				}
				for (size_t t = 0; t < 9; ++t)
				{
					float terrHeight = 0.05f + terrain->GetExactGroundLevel(pos.X+sign*perp.X*(perpT2[t]+outmost),
																			pos.Y+sign*perp.Y*(perpT2[t]+outmost));
					point[t].m_ApexPosition = CVector3D(pos.X+sign*perp.X*(perpT2[t]+outmost), baseHeight + heightT1[t]*sideNess + std::max(m_WaterHeight,terrHeight),
														pos.Y+sign*perp.Y*(perpT2[t]+outmost));
				}
				for (size_t t = 0; t < 9; ++t)
				{
					float terrHeight = 0.05f + terrain->GetExactGroundLevel(pos.X+sign*perp.X*(perpT3[t]+outmost*sideNess),
																			pos.Y+sign*perp.Y*(perpT3[t]+outmost*sideNess));
					point[t].m_SplashPosition = CVector3D(pos.X+sign*perp.X*(perpT3[t]+outmost*sideNess), baseHeight + heightT2[t]*sideNess + std::max(m_WaterHeight,terrHeight), pos.Y+sign*perp.Y*(perpT3[t]+outmost*sideNess));
				}
				for (size_t t = 0; t < 9; ++t)
				{
					float terrHeight = 0.05f + terrain->GetExactGroundLevel(pos.X+sign*perp.X*(perpT4[t]+outmost),
																			pos.Y+sign*perp.Y*(perpT4[t]+outmost));
					point[t].m_RetreatPosition = CVector3D(pos.X+sign*perp.X*(perpT4[t]+outmost), baseHeight + heightT3[t]*sideNess + std::max(m_WaterHeight,terrHeight),
														   pos.Y+sign*perp.Y*(perpT4[t]+outmost));
				}
				
				vertices.push_back(point[8]);
				vertices.push_back(point[7]);
				vertices.push_back(point[6]);
				vertices.push_back(point[5]);
				vertices.push_back(point[4]);
				vertices.push_back(point[3]);
				vertices.push_back(point[2]);
				vertices.push_back(point[1]);
				vertices.push_back(point[0]);
				
				shoreWave->m_AABB += point[8].m_SplashPosition;
				shoreWave->m_AABB += point[8].m_BasePosition;
				shoreWave->m_AABB += point[0].m_SplashPosition;
				shoreWave->m_AABB += point[0].m_BasePosition;
				shoreWave->m_AABB += point[4].m_ApexPosition;
			}

			if (sign == 1)
			{
				// Let's do some fancy reversing.
				std::vector<SWavesVertex> reversed;
				for (int a = width-1; a >= 0; --a)
				{
					for (size_t t = 0; t < 9; ++t)
						reversed.push_back(vertices[a*9+t]);
				}
				vertices = reversed;
			}
			j += width/2-1;
			
			shoreWave->m_VBvertices = g_VBMan.Allocate(sizeof(SWavesVertex), vertices.size(), GL_STATIC_DRAW, GL_ARRAY_BUFFER);
			shoreWave->m_VBvertices->m_Owner->UpdateChunkVertices(shoreWave->m_VBvertices, &vertices[0]);
			
			m_ShoreWaves.push_back(shoreWave);
		}
	}
}
Beispiel #23
0
///////////////////////////////////////////////////////////////////
// Calculate the strength of the wind at a given point on the map.
// This is too slow and should support limited recomputation.
void WaterManager::RecomputeWindStrength()
{
	if (m_WindStrength == NULL)
		m_WindStrength = new float[m_MapSize*m_MapSize];
		
	CTerrain* terrain = g_Game->GetWorld()->GetTerrain();
	float waterLevel = m_WaterHeight;
	
	CVector2D windDir = CVector2D(cos(m_WindAngle),sin(m_WindAngle));
	CVector2D perp = CVector2D(-windDir.Y, windDir.X);

	// Our kernel will sample 5 points going towards the wind (generally).
	int kernel[5][2] = { {(int)windDir.X*2,(int)windDir.Y*2}, {(int)windDir.X*5,(int)windDir.Y*5}, {(int)windDir.X*9,(int)windDir.Y*9}, {(int)windDir.X*16,(int)windDir.Y*16}, {(int)windDir.X*25,(int)windDir.Y*25} };
	
	float* Temp = new float[m_MapSize*m_MapSize];
	std::fill(Temp, Temp + m_MapSize*m_MapSize, 1.0f);

	for (size_t j = 0; j < m_MapSize; ++j)
		for (size_t i = 0; i < m_MapSize; ++i)
		{
			float curHeight = terrain->GetVertexGroundLevel(i,j);
			if (curHeight >= waterLevel)
			{
				Temp[j*m_MapSize + i] = 0.3f;	// blurs too strong otherwise
				continue;
			}
			if (terrain->GetVertexGroundLevel(i + ceil(windDir.X),j + ceil(windDir.Y)) < waterLevel)
				continue;
			
			// Calculate how dampened our waves should be.
			float tendency = 0.0f;
			float oldHeight = std::max(waterLevel,terrain->GetVertexGroundLevel(i+kernel[4][0],j+kernel[4][1]));
			float currentHeight = std::max(waterLevel,terrain->GetVertexGroundLevel(i+kernel[3][0],j+kernel[3][1]));
			float avgheight = oldHeight + currentHeight;
			tendency = currentHeight - oldHeight;
			oldHeight = currentHeight;
			currentHeight = std::max(waterLevel,terrain->GetVertexGroundLevel(i+kernel[2][0],j+kernel[2][1]));
			avgheight += currentHeight;
			tendency += currentHeight - oldHeight;
			oldHeight = currentHeight;
			currentHeight = std::max(waterLevel,terrain->GetVertexGroundLevel(i+kernel[1][0],j+kernel[1][1]));
			avgheight += currentHeight;
			tendency += currentHeight - oldHeight;
			oldHeight = currentHeight;
			currentHeight = std::max(waterLevel,terrain->GetVertexGroundLevel(i+kernel[0][0],j+kernel[0][1]));
			avgheight += currentHeight;
			tendency += currentHeight - oldHeight;
			
			float baseLevel = std::max(0.0f,1.0f - (avgheight/5.0f-waterLevel)/20.0f);
			baseLevel *= baseLevel;
			tendency /= 15.0f;
			baseLevel -= tendency;	// if the terrain was sloping downwards, increase baselevel. Otherwise reduce.
			baseLevel = clamp(baseLevel,0.0f,1.0f);
			
			// Draw on map. This is pretty slow.
			float length = 35.0f * (1.0f-baseLevel/1.8f);
			for (float y = 0; y < length; y += 0.6f)
				{
					int xx = clamp(i - y * windDir.X,0.0f,(float)(m_MapSize-1));
					int yy = clamp(j - y * windDir.Y,0.0f,(float)(m_MapSize-1));
					Temp[yy*m_MapSize + xx] = Temp[yy*m_MapSize + xx] < (0.0f+baseLevel/1.5f) * (1.0f-y/length) + y/length * 1.0f ?
												Temp[yy*m_MapSize + xx] : (0.0f+baseLevel/1.5f) * (1.0f-y/length) + y/length * 1.0f;
				}
		}
	
	int blurKernel[4][2] = { {(int)ceil(windDir.X),(int)ceil(windDir.Y)}, {(int)windDir.X*3,(int)windDir.Y*3}, {(int)ceil(perp.X),(int)ceil(perp.Y)}, {(int)-ceil(perp.X),(int)-ceil(perp.Y)} };
	float blurValue;
	for (size_t j = 2; j < m_MapSize-2; ++j)
		for (size_t i = 2; i < m_MapSize-2; ++i)
		{
			blurValue = Temp[(j+blurKernel[0][1])*m_MapSize + i+blurKernel[0][0]];
			blurValue += Temp[(j+blurKernel[0][1])*m_MapSize + i+blurKernel[0][0]];
			blurValue += Temp[(j+blurKernel[0][1])*m_MapSize + i+blurKernel[0][0]];
			blurValue += Temp[(j+blurKernel[0][1])*m_MapSize + i+blurKernel[0][0]];
			m_WindStrength[j*m_MapSize + i] = blurValue * 0.25f;
		}
	delete[] Temp;
}
Beispiel #24
0
void CEntity::Render()
{
	if( !m_visible ) return;

	if( !m_orderQueue.empty() )
	{
		std::deque<CEntityOrder>::iterator it;
		CBoundingObject* destinationCollisionObject;
		float x0, y0, x, y;

		x = m_orderQueue.front().m_target_location.x;
		y = m_orderQueue.front().m_target_location.y;

		for( it = m_orderQueue.begin(); it < m_orderQueue.end(); it++ )
		{
			if( it->m_type == CEntityOrder::ORDER_PATROL )
				break;
			x = it->m_target_location.x;
			y = it->m_target_location.y;
		}
		destinationCollisionObject = GetContainingObject( CVector2D( x, y ) );

		glShadeModel( GL_FLAT );
		glBegin( GL_LINE_STRIP );

		glVertex3f( m_position.X, m_position.Y + 0.25f, m_position.Z );

		x = m_position.X;
		y = m_position.Z;

		for( it = m_orderQueue.begin(); it < m_orderQueue.end(); it++ )
		{
			x0 = x;
			y0 = y;
			x = it->m_target_location.x;
			y = it->m_target_location.y;
			rayIntersectionResults r;
			CVector2D fwd( x - x0, y - y0 );
			float l = fwd.Length();
			fwd = fwd.Normalize();
			CVector2D rgt = fwd.beta();
			if( GetRayIntersection( CVector2D( x0, y0 ), fwd, rgt, l, m_bounds->m_radius, destinationCollisionObject, &r ) )
			{
				glEnd();
				glBegin( GL_LINES );
				glColor3f( 1.0f, 0.0f, 0.0f );
				glVertex3f( x0 + fwd.x * r.distance, GetAnchorLevel( x0 + fwd.x * r.distance, y0 + fwd.y * r.distance ) + 0.25f, y0 + fwd.y * r.distance );
				glVertex3f( r.position.x, GetAnchorLevel( r.position.x, r.position.y ) + 0.25f, r.position.y );
				glEnd();
				glBegin( GL_LINE_STRIP );
				glVertex3f( x0, GetAnchorLevel( x0, y0 ), y0 );
			}
			switch( it->m_type )
			{
				case CEntityOrder::ORDER_GOTO:
				glColor3f( 1.0f, 0.0f, 0.0f );
				break;
				case CEntityOrder::ORDER_GOTO_COLLISION:
				glColor3f( 1.0f, 0.5f, 0.5f );
				break;
				case CEntityOrder::ORDER_GOTO_NOPATHING:
				case CEntityOrder::ORDER_GOTO_SMOOTHED:
				glColor3f( 0.5f, 0.5f, 0.5f );
				break;
				case CEntityOrder::ORDER_PATROL:
				glColor3f( 0.0f, 1.0f, 0.0f );
				break;
				default:
				continue;
			}

			glVertex3f( x, GetAnchorLevel( x, y ) + 0.25f, y );
		}

		glEnd();
		glShadeModel( GL_SMOOTH );
	}

	glColor3f( 1.0f, 1.0f, 1.0f );
	if( GetCollisionObject( this ) )
		glColor3f( 0.5f, 0.5f, 1.0f );
	m_bounds->Render( GetAnchorLevel( m_position.X, m_position.Z ) + 0.25f ); //m_position.Y + 0.25f );
}
Beispiel #25
0
	CVector2D rot270 () const // rotation 270 degrees
		{return CVector2D (y, -x);} 
Beispiel #26
0
InReaction CTouchInput::HandleEvent(const SDL_Event_* ev)
{
	UNUSED2(ev); // may be unused depending on #ifs

	if (!IsEnabled())
		return IN_PASS;

#if EMULATE_FINGERS_WITH_MOUSE
	switch(ev->ev.type)
	{
	case SDL_MOUSEBUTTONDOWN:
	{
		int button;
		if (ev->ev.button.button == SDL_BUTTON_LEFT)
			button = 0;
		else if (ev->ev.button.button == SDL_BUTTON_RIGHT)
			button = 1;
		else
			return IN_PASS;

		m_MouseEmulateDownPos[button] = CVector2D(ev->ev.button.x, ev->ev.button.y);
		if (m_MouseEmulateState[button] == MOUSE_INACTIVE)
		{
			m_MouseEmulateState[button] = MOUSE_ACTIVATING;
			OnFingerDown(button, ev->ev.button.x, ev->ev.button.y);
		}
		else if (m_MouseEmulateState[button] == MOUSE_ACTIVE_UP)
		{
			m_MouseEmulateState[button] = MOUSE_ACTIVE_DOWN;
		}
		return IN_HANDLED;
	}

	case SDL_MOUSEBUTTONUP:
	{
		int button;
		if (ev->ev.button.button == SDL_BUTTON_LEFT)
			button = 0;
		else if (ev->ev.button.button == SDL_BUTTON_RIGHT)
			button = 1;
		else
			return IN_PASS;

		if (m_MouseEmulateState[button] == MOUSE_ACTIVATING)
		{
			m_MouseEmulateState[button] = MOUSE_ACTIVE_UP;
		}
		else if (m_MouseEmulateState[button] == MOUSE_ACTIVE_DOWN)
		{
			float dist = (m_MouseEmulateDownPos[button] - CVector2D(ev->ev.button.x, ev->ev.button.y)).Length();
			if (dist <= 2)
			{
				m_MouseEmulateState[button] = MOUSE_INACTIVE;
				OnFingerUp(button, ev->ev.button.x, ev->ev.button.y);
			}
			else
			{
				m_MouseEmulateState[button] = MOUSE_ACTIVE_UP;
			}
		}
		return IN_HANDLED;
	}

	case SDL_MOUSEMOTION:
	{
		for (size_t i = 0; i < MAX_MOUSE; ++i)
		{
			if (m_MouseEmulateState[i] == MOUSE_ACTIVE_DOWN)
			{
				OnFingerMotion(i, ev->ev.motion.x, ev->ev.motion.y);
			}
		}
		return IN_HANDLED;
	}
	}
#endif

#if SDL_VERSION_ATLEAST(2, 0, 0)
	switch(ev->ev.type)
	{
	case SDL_FINGERDOWN:
	case SDL_FINGERUP:
	case SDL_FINGERMOTION:
	{
		// Map finger events onto the mouse, for basic testing
		debug_printf(L"finger %s tid=%lld fid=%lld s=%d x=%d y=%d dx=%d dy=%d p=%d\n",
			ev->ev.type == SDL_FINGERDOWN ? "down" :
			ev->ev.type == SDL_FINGERUP ? "up" :
			ev->ev.type == SDL_FINGERMOTION ? "motion" : "?",
			ev->ev.tfinger.touchId, ev->ev.tfinger.fingerId, ev->ev.tfinger.state,
			ev->ev.tfinger.x, ev->ev.tfinger.y, ev->ev.tfinger.dx, ev->ev.tfinger.dy, ev->ev.tfinger.pressure);

		if (ev->ev.type == SDL_FINGERDOWN)
			OnFingerDown(ev->ev.tfinger.fingerId, g_xres * (ev->ev.tfinger.x/32767.0f), g_yres * (ev->ev.tfinger.y/32767.0f));
		else if (ev->ev.type == SDL_FINGERUP)
			OnFingerUp(ev->ev.tfinger.fingerId, g_xres * (ev->ev.tfinger.x/32767.0f), g_yres * (ev->ev.tfinger.y/32767.0f));
		else if (ev->ev.type == SDL_FINGERMOTION)
			OnFingerMotion(ev->ev.tfinger.fingerId, g_xres * (ev->ev.tfinger.x/32767.0f), g_yres * (ev->ev.tfinger.y/32767.0f));
		return IN_HANDLED;
	}
	}
#endif

	return IN_PASS;
}
CGUIMessageBox_Impl::CGUIMessageBox_Impl(CGUI_Impl* pGUI, const char* szTitle, const char* szCaption, unsigned int uiFlags)
{
    // Initialize
    m_bAutoDestroy = true;            // TODO: If any buttons..
    m_pIcon = NULL;
    m_pButton = NULL;
    m_pLabelCaption = NULL;

    // Create window
    CVector2D ScreenSize = pGUI->GetResolution();
    m_pWindow = pGUI->CreateWnd(NULL, szTitle);
    m_pWindow->SetAlwaysOnTop(true);
    m_pWindow->SetCloseButtonEnabled(false);
    m_pWindow->SetSizingEnabled(false);
    m_pWindow->SetPosition(CVector2D(ScreenSize.fX * 0.5f - MESSAGEBOX_WIDTH * 0.5f, ScreenSize.fY * 0.5f - MESSAGEBOX_HEIGHT * 0.5f));
    m_pWindow->SetSize(CVector2D(MESSAGEBOX_WIDTH, MESSAGEBOX_HEIGHT));            // relative 0.35, 0.225

    // Create the icon
    m_pIcon = pGUI->CreateStaticImage(m_pWindow);
    m_pIcon->SetFrameEnabled(false);
    m_pIcon->SetPosition(CVector2D(MESSAGEBOX_SPACER, MESSAGEBOX_HEIGHT / 2 - MESSAGEBOX_ICON_SIZE / 2));
    m_pIcon->SetSize(CVector2D(MESSAGEBOX_ICON_SIZE, MESSAGEBOX_ICON_SIZE));

    if (uiFlags & MB_ICON_INFO)
        m_pIcon->LoadFromFile(CGUI_ICON_MESSAGEBOX_INFO);
    else if (uiFlags & MB_ICON_QUESTION)
        m_pIcon->LoadFromFile(CGUI_ICON_MESSAGEBOX_QUESTION);
    else if (uiFlags & MB_ICON_WARNING)
        m_pIcon->LoadFromFile(CGUI_ICON_MESSAGEBOX_WARNING);
    else if (uiFlags & MB_ICON_ERROR)
        m_pIcon->LoadFromFile(CGUI_ICON_MESSAGEBOX_ERROR);

    // Create caption label
    m_pLabelCaption = pGUI->CreateLabel(m_pWindow, szCaption);
    m_pLabelCaption->SetPosition(CVector2D(MESSAGEBOX_ICON_SIZE + MESSAGEBOX_SPACER * 2, MESSAGEBOX_SPACER));
    m_pLabelCaption->SetSize(CVector2D(MESSAGEBOX_WIDTH - MESSAGEBOX_ICON_SIZE - MESSAGEBOX_SPACER * 3, MESSAGEBOX_HEIGHT - MESSAGEBOX_SPACER * 2));
    m_pLabelCaption->SetHorizontalAlign(CGUI_ALIGN_LEFT_WORDWRAP);
    m_pLabelCaption->SetVerticalAlign(CGUI_ALIGN_VERTICALCENTER);
    m_pLabelCaption->MoveToBack();
    m_pLabelCaption->SetZOrderingEnabled(false);

    // Create buttons
    if (uiFlags & MB_BUTTON_OK)
    {
        m_pButton = pGUI->CreateButton(m_pWindow, _("OK"));
    }
    else if (uiFlags & MB_BUTTON_CANCEL)
    {
        m_pButton = pGUI->CreateButton(m_pWindow, _("Cancel"));
    }
    else if (uiFlags & MB_BUTTON_YES)
    {
        m_pButton = pGUI->CreateButton(m_pWindow, _("Yes"));
    }

    if (m_pButton)
    {
        m_pButton->SetPosition(CVector2D((MESSAGEBOX_WIDTH - 84) / 2, MESSAGEBOX_HEIGHT * 0.76f));
        m_pButton->SetSize(CVector2D(84.0f, 24.0f));
        m_pButton->SetZOrderingEnabled(false);

        SetClickHandler(GUI_CALLBACK(&CGUIMessageBox_Impl::OnResponseHandler, this));
    }

    // Set the KeyDown handler
    m_pWindow->SetEnterKeyHandler(GUI_CALLBACK(&CGUIMessageBox_Impl::OnResponseHandler, this));

    // And finally set the focus to our window
    m_pWindow->Activate();
}
Beispiel #28
0
	CVector2D operator / (Double alpha) const // times scalar
		{return (alpha == 0) ? *this : CVector2D (x / alpha, y / alpha);} 
Beispiel #29
0
void CClientVariables::LoadDefaults ( void )
{
#define DEFAULT(__x,__y)    if(!Exists(__x)) \
                                Set(__x,__y)
#define _S(__x)             std::string(__x)

    if(!Exists("nick"))
    {
        DEFAULT ( "nick",                       _S(CNickGen::GetRandomNickname()) );       // nickname
        CCore::GetSingleton ().RequestNewNickOnStart();  // Request the user to set a new nickname
    }

    DEFAULT ( "host",                       _S("127.0.0.1") );              // hostname
    DEFAULT ( "port",                       22003 );                        // port
    DEFAULT ( "password",                   _S("") );                       // password
    DEFAULT ( "qc_host",                    _S("127.0.0.1") );              // quick connect hostname
    DEFAULT ( "qc_port",                    22003 );                        // quick connect port
    DEFAULT ( "qc_password",                _S("") );                       // quick connect password
    DEFAULT ( "debugfile",                  _S("") );                       // debug filename
    DEFAULT ( "console_pos",                CVector2D ( 0, 0 ) );           // console position
    DEFAULT ( "console_size",               CVector2D ( 200, 200 ) );       // console size
    DEFAULT ( "serverbrowser_size",         CVector2D ( 720.0f, 495.0f ) ); // serverbrowser size
    DEFAULT ( "fps_limit",                  100 );                          // frame limiter
    DEFAULT ( "chat_font",                  0 );                            // chatbox font type
    DEFAULT ( "chat_lines",                 7 );                            // chatbox lines
    DEFAULT ( "chat_color",                 CColor (0,0,128,100) );         // chatbox color
    DEFAULT ( "chat_text_color",            CColor (172,213,254,255) );     // chatbox text color
    DEFAULT ( "chat_input_color",           CColor (0,0,191,110) );         // chatbox input color
    DEFAULT ( "chat_input_prefix_color",    CColor (172,213,254,255) );     // chatbox prefix input color
    DEFAULT ( "chat_input_text_color",      CColor (172,213,254,255) );     // chatbox text input color
    DEFAULT ( "chat_scale",                 CVector2D ( 1.0f, 1.0f ) );     // chatbox scale
    DEFAULT ( "chat_width",                 1.0f );                         // chatbox width
    DEFAULT ( "chat_css_style_text",        false );                        // chatbox css/hl style text
    DEFAULT ( "chat_css_style_background",  false );                        // chatbox css/hl style background
    DEFAULT ( "chat_line_life",             12000 );                        // chatbox line life time
    DEFAULT ( "chat_line_fade_out",         3000 );                         // chatbox line fade out time
    DEFAULT ( "chat_use_cegui",             false );                        // chatbox uses cegui
    DEFAULT ( "chat_nickcompletion",        true );                         // chatbox nick completion
    DEFAULT ( "server_can_flash_window",    true );                         // allow server to flash the window
    DEFAULT ( "text_scale",                 1.0f );                         // text scale
    DEFAULT ( "invert_mouse",               false );                        // mouse inverting
    DEFAULT ( "fly_with_mouse",             false );                        // flying with mouse controls
    DEFAULT ( "steer_with_mouse",           false );                        // steering with mouse controls
    DEFAULT ( "classic_controls",           false );                        // classic/standard controls
    DEFAULT ( "mtavolume",                  1.0f );                         // custom sound's volume
    DEFAULT ( "voicevolume",                1.0f );                         // voice chat output volume
    DEFAULT ( "mapalpha",                   155 );                          // map alpha
    DEFAULT ( "browser_speed",              1 );                            // Browser speed
    DEFAULT ( "single_download",            0 );                            // Single connection for downloads
    DEFAULT ( "packet_tag",                 0 );                            // Tag network packets
    DEFAULT ( "progress_animation",         1 );                            // Progress spinner at the bottom of the screen
    DEFAULT ( "update_build_type",          0 );                            // 0-stable 1-test 2-nightly
    DEFAULT ( "update_auto_install",        1 );                            // 0-off 1-on
    DEFAULT ( "volumetric_shadows",         0 );                            // Enable volumetric shadows
    DEFAULT ( "aspect_ratio",               0 );                            // Display aspect ratio
    DEFAULT ( "hud_match_aspect_ratio",     1 );                            // GTA HUD should match the display aspect ratio
    DEFAULT ( "anisotropic",                0 );                            // Anisotropic filtering
    DEFAULT ( "grass",                      1 );                            // Enable grass
    DEFAULT ( "heat_haze",                  1 );                            // Enable heat haze
    DEFAULT ( "tyre_smoke_enabled",         1 );                            // Enable tyre smoke
    DEFAULT ( "fast_clothes_loading",       1 );                            // 0-off 1-auto 2-on
    DEFAULT ( "allow_screen_upload",        1 );                            // 0-off 1-on
    DEFAULT ( "max_clientscript_log_kb",    5000 );                         // Max size in KB (0-No limit)
    DEFAULT ( "display_fullscreen_style",   0 );                            // 0-standard 1-borderless 2-borderless keep res 3-borderless stretch
    DEFAULT ( "display_windowed",           0 );                            // 0-off 1-on
    DEFAULT ( "multimon_fullscreen_minimize", 1 );                          // 0-off 1-on
    DEFAULT ( "vertical_aim_sensitivity",   0.0015f );                      // 0.0015f is GTA default setting
    DEFAULT ( "process_priority",           0 );                            // 0-normal 1-above normal 2-high
    DEFAULT ( "mute_sfx_when_minimized",    0 );                            // 0-off 1-on
    DEFAULT ( "mute_radio_when_minimized",  0 );                            // 0-off 1-on
    DEFAULT ( "mute_mta_when_minimized",    0 );                            // 0-off 1-on
    DEFAULT ( "mute_voice_when_minimized",  0 );                            // 0-off 1-on
    DEFAULT ( "share_file_cache",           1 );                            // 0-no 1-share client resource file cache with other MTA installs
    DEFAULT ( "show_unsafe_resolutions",    0 );                            // 0-off 1-show resolutions that are higher that the desktop
    DEFAULT ( "fov",                        70 );                           // Camera field of view
    DEFAULT ( "browser_remote_websites",    true );                         // Load remote websites?
    DEFAULT ( "browser_remote_javascript",  true );                         // Execute javascript on remote websites?
    DEFAULT ( "browser_plugins",            false );                         // Enable browser plugins?
    DEFAULT ( "filter_duplicate_log_lines", true );                         // Filter duplicate log lines for debug view and clientscript.log

    if (!Exists("locale"))
    {
        SString strLangCode = GetApplicationSetting ( "locale" );
        Set ( "locale", !strLangCode.empty() ? strLangCode : _S("en_US") );
    }

    // Set default resolution to native resolution
    if ( !Exists ( "display_resolution" ) )
    {
        RECT rect;
        GetWindowRect( GetDesktopWindow (), &rect );
        Set ( "display_resolution", SString ( "%dx%dx32", rect.right, rect.bottom ) );
    }

    // We will default this one at CClientGame.cpp, because we need a valid direct3d device to give a proper default value.
#if 0
    DEFAULT ( "streaming_memory",           50 );                           // Streaming memory
#endif
}
Beispiel #30
0
	CVector2D rot90 () const // rotation 90 degrees
		{return CVector2D (-y, x);}