void CHudMessage::MessageScanNextChar( void ) { int srcRed, srcGreen, srcBlue, destRed, destGreen, destBlue; int blend; srcRed = m_parms.pMessage->r1; srcGreen = m_parms.pMessage->g1; srcBlue = m_parms.pMessage->b1; blend = 0; // Pure source switch( m_parms.pMessage->effect ) { // Fade-in / Fade-out case 0: case 1: destRed = destGreen = destBlue = 0; blend = m_parms.fadeBlend; break; case 2: m_parms.charTime += m_parms.pMessage->fadein; if ( m_parms.charTime > m_parms.time ) { srcRed = srcGreen = srcBlue = 0; blend = 0; // pure source } else { float deltaTime = m_parms.time - m_parms.charTime; destRed = destGreen = destBlue = 0; if ( m_parms.time > m_parms.fadeTime ) { blend = m_parms.fadeBlend; } else if ( deltaTime > m_parms.pMessage->fxtime ) blend = 0; // pure dest else { destRed = m_parms.pMessage->r2; destGreen = m_parms.pMessage->g2; destBlue = m_parms.pMessage->b2; blend = 255 - (deltaTime * (1.0/m_parms.pMessage->fxtime) * 255.0 + 0.5); } } break; } if ( blend > 255 ) blend = 255; else if ( blend < 0 ) blend = 0; m_parms.r = ((srcRed * (255-blend)) + (destRed * blend)) >> 8; m_parms.g = ((srcGreen * (255-blend)) + (destGreen * blend)) >> 8; m_parms.b = ((srcBlue * (255-blend)) + (destBlue * blend)) >> 8; if ( m_parms.pMessage->effect == 1 && m_parms.charTime != 0 ) { if ( m_parms.x >= 0 && m_parms.y >= 0 && (m_parms.x + gHUD.m_scrinfo.charWidths[ m_parms.text ]) <= ScreenWidth() ) TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.pMessage->r2, m_parms.pMessage->g2, m_parms.pMessage->b2 ); } }
void CHud :: VidInit( void ) { m_scrinfo.iSize = sizeof(m_scrinfo); GetScreenInfo(&m_scrinfo); // The NS viewport isn't set up yet int theViewPort[4]; theViewPort[0] = theViewPort[1] = 0; theViewPort[2] = this->m_scrinfo.iWidth; theViewPort[3] = this->m_scrinfo.iHeight; gHUD.SetViewport(theViewPort); mFont.Load("sprites/font_arial"); mSmallFont.Load("sprites/font_arialsmall"); // ---------- // Load Sprites // --------- // m_hsprFont = LoadSprite("sprites/%d_font.spr"); m_hsprLogo = 0; m_hsprCursor = 0; if (ScreenWidth() < 640) m_iRes = 320; else m_iRes = 640; // Only load this once if ( !m_pSpriteList ) { // we need to load the hud.txt, and all sprites within m_pSpriteList = SPR_GetList("sprites/hud.txt", &m_iSpriteCountAllRes); if (m_pSpriteList) { // count the number of sprites of the appropriate res m_iSpriteCount = 0; client_sprite_t *p = m_pSpriteList; for ( int j = 0; j < m_iSpriteCountAllRes; j++ ) { if ( p->iRes == m_iRes ) m_iSpriteCount++; p++; } // allocated memory for sprite handle arrays m_rghSprites = new HSPRITE[m_iSpriteCount]; m_rgrcRects = new wrect_t[m_iSpriteCount]; m_rgszSpriteNames = new char[m_iSpriteCount * MAX_SPRITE_NAME_LENGTH]; p = m_pSpriteList; int index = 0; for ( j = 0; j < m_iSpriteCountAllRes; j++ ) { if ( p->iRes == m_iRes ) { char sz[256]; sprintf(sz, "sprites/%s.spr", p->szSprite); m_rghSprites[index] = Safe_SPR_Load(sz); m_rgrcRects[index] = p->rc; strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH ); index++; } p++; } } } else { // we have already have loaded the sprite reference from hud.txt, but // we need to make sure all the sprites have been loaded (we've gone through a transition, or loaded a save game) client_sprite_t *p = m_pSpriteList; int index = 0; for ( int j = 0; j < m_iSpriteCountAllRes; j++ ) { if ( p->iRes == m_iRes ) { char sz[256]; sprintf( sz, "sprites/%s.spr", p->szSprite ); m_rghSprites[index] = Safe_SPR_Load(sz); index++; } p++; } } // assumption: number_1, number_2, etc, are all listed and loaded sequentially m_HUD_number_0 = GetSpriteIndex( "number_0" ); m_iFontHeight = m_rgrcRects[m_HUD_number_0].bottom - m_rgrcRects[m_HUD_number_0].top; m_Ammo.VidInit(); m_Health.VidInit(); m_Spectator.VidInit(); m_Geiger.VidInit(); m_Train.VidInit(); m_Battery.VidInit(); m_Flash.VidInit(); m_Message.VidInit(); m_StatusBar.VidInit(); m_DeathNotice.VidInit(); m_SayText.VidInit(); m_Menu.VidInit(); m_AmmoSecondary.VidInit(); m_TextMessage.VidInit(); m_StatusIcons.VidInit(); GetClientVoiceMgr()->VidInit(); }
void CASW_VGUI_Door_Tooltip::OnThink() { MDLCACHE_CRITICAL_SECTION(); C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer(); if ( pPlayer && m_bShowDoorUnderCursor ) { C_ASW_Door* pDoorUnderCursor = C_ASW_Door::GetDoorNear( ASWInput()->GetCrosshairAimingPos() ); if (pDoorUnderCursor && pDoorUnderCursor->IsOpen()) // don't show open doors pDoorUnderCursor = NULL; SetDoor(pDoorUnderCursor); } // fade in/out as the door changes if (m_bQueuedDoor) { if (GetAlpha() <= 0) { m_hDoor = m_hQueuedDoor; m_hQueuedDoor = NULL; m_bQueuedDoor = false; m_bDoingSlowFade = false; m_fNextUpdateTime = gpGlobals->curtime; if (GetDoor()) vgui::GetAnimationController()->RunAnimationCommand(this, "Alpha", 200, 0, ASW_HEALTH_REPORT_FADE_TIME, vgui::AnimationController::INTERPOLATOR_LINEAR); } else if (GetAlpha() >= 200) { if (m_hQueuedDoor.Get() == NULL) { if (!m_bDoingSlowFade) { m_bDoingSlowFade = true; float delay = 0; // 1.5f vgui::GetAnimationController()->RunAnimationCommand(this, "Alpha", 0, delay, ASW_HEALTH_REPORT_FADE_TIME * 3, vgui::AnimationController::INTERPOLATOR_LINEAR); } } else { vgui::GetAnimationController()->RunAnimationCommand(this, "Alpha", 0, 0, ASW_HEALTH_REPORT_FADE_TIME, vgui::AnimationController::INTERPOLATOR_LINEAR); m_bDoingSlowFade = false; } } // if we're doing a slow fade out but the player has now mouse overed another door, do the fade quickly if (m_bDoingSlowFade && m_hQueuedDoor.Get() != NULL) { vgui::GetAnimationController()->RunAnimationCommand(this, "Alpha", 0, 0, ASW_HEALTH_REPORT_FADE_TIME, vgui::AnimationController::INTERPOLATOR_LINEAR); m_bDoingSlowFade = false; } } // check for updating health C_ASW_Door* pDoor = GetDoor(); if (gpGlobals->curtime >= m_fNextUpdateTime && pDoor) { // set the health label accordingly int health = pDoor->GetHealth(); if (health != m_iOldDoorHealth) { m_iOldDoorHealth = health; m_fDoorHealthFraction = pDoor->GetHealthFraction(m_iDoorType); } m_fNextUpdateTime = gpGlobals->curtime + 0.05f; } // reposition if (pDoor) { int mx, my, iDoorType; if ( pDoor->IsAlive() && pDoor->GetHealthFraction(iDoorType) < 1.0f && !pDoor->IsOpen() && !pDoor->IsDormant() && GetDoorHealthBarPosition( pDoor, mx, my ) ) { mx = clamp(mx, 0, ScreenWidth() - GetWide()); my = clamp(my, 0, ScreenHeight() - GetTall()); SetPos(mx, my); } else { SetDoor( NULL ); return; } } }
static int getScreenWidth(lua_State* inState) { int theScreenWidth = ScreenWidth(); lua_pushnumber(inState, theScreenWidth); return 1; }
void CGraphics_Threaded::DrawVisualObject(int VisualObjectIDX, float *pColor, char** pOffsets, unsigned int *IndicedVertexDrawNum, size_t NumIndicesOffet) { if(NumIndicesOffet == 0) return; //add the VertexArrays and draw CCommandBuffer::SCommand_RenderVertexArray Cmd; Cmd.m_State = m_State; Cmd.m_IndicesDrawNum = NumIndicesOffet; Cmd.m_VisualObjectIDX = m_VertexArrayIndices[VisualObjectIDX]; mem_copy(&Cmd.m_Color, pColor, sizeof(Cmd.m_Color)); float ScreenZoomRatio = ScreenWidth() / (m_State.m_ScreenBR.x - m_State.m_ScreenTL.x); //the number of pixels we would skip in the fragment shader -- basically the LOD float LODFactor = (64.f / (32.f * ScreenZoomRatio)); //log2 gives us the amount of halving the texture for mipmapping int LOD = (int)log2f(LODFactor); //5 because log2(1024/(2^5)) is 5 -- 2^5 = 32 which would mean 2 pixels per tile index if(LOD > 5) LOD = 5; if(LOD < 0) LOD = 0; Cmd.m_LOD = LOD; void *Data = m_pCommandBuffer->AllocData((sizeof(char*) + sizeof(unsigned int))*NumIndicesOffet); if(Data == 0x0) { // kick command buffer and try again KickCommandBuffer(); void *Data = m_pCommandBuffer->AllocData((sizeof(char*) + sizeof(unsigned int))*NumIndicesOffet); if(Data == 0x0) { dbg_msg("graphics", "failed to allocate data for vertices"); return; } } Cmd.m_pIndicesOffsets = (char**)Data; Cmd.m_pDrawCount = (unsigned int*)(((char*)Data) + (sizeof(char*)*NumIndicesOffet)); // check if we have enough free memory in the commandbuffer if(!m_pCommandBuffer->AddCommand(Cmd)) { // kick command buffer and try again KickCommandBuffer(); Data = m_pCommandBuffer->AllocData((sizeof(char*) + sizeof(unsigned int))*NumIndicesOffet); if(Data == 0x0) { dbg_msg("graphics", "failed to allocate data for vertices"); return; } Cmd.m_pIndicesOffsets = (char**)Data; Cmd.m_pDrawCount = (unsigned int*)(((char*)Data) + (sizeof(char*)*NumIndicesOffet)); if(!m_pCommandBuffer->AddCommand(Cmd)) { dbg_msg("graphics", "failed to allocate memory for render command"); return; } } mem_copy(Cmd.m_pIndicesOffsets, pOffsets, sizeof(char*)*NumIndicesOffet); mem_copy(Cmd.m_pDrawCount, IndicedVertexDrawNum, sizeof(unsigned int)*NumIndicesOffet); //todo max indices group check!! }
void DrawCalendar() { int i, j, k; char s[100]; if (GetOrientation() == 0 || GetOrientation() == 3) { months_by_x = 3; months_by_y = 4; dx = cpar->dx_p; dy = cpar->dy_p; sx = cpar->sx_p; sy = cpar->sy_p; aw = cpar->aw; lh = cpar->lh; } else { months_by_x = 4; months_by_y = 3; dx = cpar->dx_l; dy = cpar->dy_l; sx = cpar->sx_l; sy = cpar->sy_l; aw = cpar->aw; lh = cpar->lh; } ClearScreen(); //FillArea(0, 0, 600, 800, BLACK); //FillArea(10, 10, 580, 780, WHITE); SetFont(cal_title_font, BLACK); sprintf(s, "\x11 %d \x12", year); DrawTextRect(0, 5, ScreenWidth(), 30, s, ALIGN_CENTER); HeaderWidth = StringWidth(s); SymbolWidth = CharWidth('A'); for (i=0; i<months_by_y; i++) for (j=0; j<months_by_x; j++) { int mn = i*months_by_x + j; SetFont(cal_month_font, BLACK); DrawTextRect(sx+dx*j, sy-(lh*3)/2+dy*i, dx, 1, GetLangText(MonthName[mn]), ALIGN_CENTER); SetFont(cal_day_font, BLACK); for (k=0; k<6; k++) DrawTextRect(sx+4+dx*j-(IsRTL() ? 10 : 0), sy+lh*k+dy*i, 50, 1, GetLangText(WeekName[k]), ALIGN_LEFT | RTLAUTO); SetFont(cal_day_font, DGRAY); DrawTextRect(sx+4+dx*j-(IsRTL() ? 10 : 0), sy+lh*6+dy*i, 50, 1, GetLangText(WeekName[6]), ALIGN_LEFT | RTLAUTO); for (k=1; k<43; k++) if (calendar[mn][k]>0) { if (k%7!=0) SetFont(cal_date_font, BLACK); else SetFont(cal_date2_font, DGRAY); sprintf(s, "%d", calendar[mn][k]); DrawTextRect(sx+(aw*8)/5+( (int) ((k-1)/7) )*aw+dx*j, sy+lh*((k-1)%7)+dy*i, aw, 1, s, ALIGN_CENTER); } } if (year==CurDate->tm_year+1900) { k=1; while (calendar[CurDate->tm_mon][k]!=CurDate->tm_mday) k++; InvertArea(sx+(aw*8)/5+1+( (int) ((k-1)/7) )*aw+dx*(CurDate->tm_mon%months_by_x), sy+lh*((k-1)%7)+dy*(CurDate->tm_mon/months_by_x), aw-2, lh-1); DrawRect(sx+(aw*8)/5+( (int) ((k-1)/7) )*aw+dx*(CurDate->tm_mon%months_by_x), sy+lh*((k-1)%7)+dy*(CurDate->tm_mon/months_by_x)+1, aw, lh-3, BLACK); } // SetFont(cour32, BLACK); // sprintf(s, "%d %s %d", CurDate->tm_mday, GetLangText(MonthName[CurDate->tm_mon]), CurDate->tm_year+1900); // DrawTextRect(50, 720, 500, 30, s, ALIGN_CENTER); // DitherArea(0, 0, 600, 800, 4, 1); DrawPanel(NULL, CurrentDateStr(), NULL, -1); FullUpdate(); }
void AvHSpriteBeginFrame() { // Compute the camera parameters. Vector origin; if (gEngfuncs.pDemoAPI->IsPlayingback()) { VectorCopy(gPlaybackViewOrigin, origin); } else { VectorCopy(v_origin, origin); } float nearDistance = 12; float aspectRatio = (float)(ScreenHeight()) / ScreenWidth(); float w = nearDistance * tan(M_PI * gHUD.m_iFOV / 360); float h = nearDistance * tan(M_PI * gHUD.m_iFOV / 360) * aspectRatio; Vector forward; Vector right; Vector up; AngleVectors(v_angles, forward, right, up); gViewOrigin = origin + forward * nearDistance - right * w + up * h; gViewXAxis = 2 * w * right / ScreenWidth(); gViewYAxis = -2 * h * up / ScreenHeight(); gViewZAxis = -forward; gRenderMode = kRenderNormal; // Initialize the transform to an identity transform. gTransform[0][0] = 1; gTransform[0][1] = 0; gTransform[0][2] = 0; gTransform[1][0] = 0; gTransform[1][1] = 1; gTransform[1][2] = 0; // Initialize the clipping rectangle to the whole screen. gClipRectX1 = 0; gClipRectY1 = 0; gClipRectX2 = ScreenWidth(); gClipRectY2 = ScreenHeight(); gClippingEnabled = false; gDepth = 0; gDepthOffset = 0; gColor[0] = 1; gColor[1] = 1; gColor[2] = 1; gColor[3] = 1; gDrawMode = kSpriteDrawModeFilled; }
} // добавляем две пустышки с координатами верхнего левого и нижнего правого углов acwordlist[0].word = strdup(""); acwordlist[0].x1 = 0; acwordlist[0].y1 = 0; acwordlist[0].x2 = 0; acwordlist[0].y2 = 0; acwordlist[0].pnum = paragraph; acwordlist[0].wnum = cr.elementIndex(); cr = is_footnote_mode() ? footview->textArea().endCursor() : bookview->textArea().endCursor(); paragraph = !cr.isNull() ? cr.paragraphCursor().index() : 0; acwordlist[1].word = strdup(""); acwordlist[1].x1 = ScreenWidth(); acwordlist[1].y1 = ScreenHeight() - PanelHeight(); acwordlist[1].x2 = ScreenWidth(); acwordlist[1].y2 = ScreenHeight() - PanelHeight(); acwordlist[1].pnum = paragraph; acwordlist[1].wnum = cr.elementIndex(); acwlistcount = 2; } } void new_synopsis_note() { PrepareSynTOC(0); restore_current_position(); mainApplication->refreshWindow();
int MarkerHandler(int type, int par1, int par2) { if (type == EVT_POINTERDOWN) { selectingMarker = true; restore_current_position(); mainApplication->refreshWindow(); bookview->selectionModel().clear(); bookview->selectionModel().activate(par1 - imgposx, par2 - imgposy); SetHardTimer("SelectionTimer", SelectionTimer, 250); selMarkery1 = selMarkery2 = lasty = par2; lastx = par1; usersleep = 0; } else if (type == EVT_POINTERMOVE) { if (++trailMarker > 8) { if (selectingMarker) { lastx = par1; lasty = par2; bookview->selectionModel().extendTo(par1 - imgposx, par2 - imgposy); selMarkery2 = par2; usersleep = 0; } trailMarker = 0; } } else if (type == EVT_POINTERUP) { if (!selectingMarker) return 0; selectingMarker = false; ClearTimer(SelectionTimer); restore_current_position(); mainApplication->refreshWindow(); bookview->selectionModel().extendTo(par1 - imgposx, par2 - imgposy); long long spos, epos; bool clickOnly, emptyText; GetSelectionInfo(&spos, &epos, &emptyText, &clickOnly); if ((clickOnly && SynTOC.GetMarkerByPos(spos) != NULL) || emptyText) { OpenMarkerMenu(SynTOC.GetMarkerByPos(spos)); } else { MergeMarkers(spos, epos); bookview->selectionModel().clear(); repaint_all(-2); ToolBar.OutputPage(BitmapFromScreen(0, 0, ScreenWidth(), ScreenHeight()-PanelHeight()), 2, updMarkerx, updMarkery, updMarkerw, updMarkerh); } } else if (type == EVT_POINTERHOLD || type == EVT_POINTERLONG) { restore_current_position(); mainApplication->refreshWindow(); bookview->selectionModel().extendTo(par1 - imgposx, par2 - imgposy); long long spos, epos; bool clickOnly, emptyText; GetSelectionInfo(&spos, &epos, &emptyText, &clickOnly); if (clickOnly || emptyText) { OpenMarkerMenu(SynTOC.GetMarkerByPos(spos)); } } return 0; }
//----------------------------------------------------------------------------- // Purpose: Draw function for the element //----------------------------------------------------------------------------- void CTargetID::Paint() { C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) return; // No id if still choosing class if ( C_BaseTFPlayer::GetLocalPlayer()->GetClass() == TFCLASS_UNDECIDED ) return; // Get our target's ent index int iEntIndex = C_BaseTFPlayer::GetLocalPlayer()->GetIDTarget(); // Didn't find one? if ( !iEntIndex ) { // Check to see if we should clear our ID if ( m_flLastChangeTime && (gpGlobals->curtime > (m_flLastChangeTime + 0.5)) ) { m_flLastChangeTime = 0; m_sIDString[0] = 0; m_iLastEntIndex = 0; } else { // Keep re-using the old one iEntIndex = m_iLastEntIndex; } } else { m_flLastChangeTime = gpGlobals->curtime; } // Is this an entindex sent by the server? if ( iEntIndex ) { C_BaseTFPlayer *pPlayer = static_cast<C_BaseTFPlayer*>(cl_entitylist->GetEnt( iEntIndex )); C_BaseTFPlayer *pLocalPlayer = C_BaseTFPlayer::GetLocalPlayer(); // Some entities we always want to check, cause the text may change // even while we're looking at it // Is it a player? if ( IsPlayerIndex( iEntIndex ) ) { if ( pPlayer->InSameTeam(pLocalPlayer) ) { // Check distance to other player, and if the player is on the same team float flDistSq = pPlayer->GetRenderOrigin().DistToSqr( pLocalPlayer->GetRenderOrigin() ); if ( flDistSq < PLAYER_HINT_DISTANCE_SQ ) { Q_snprintf( m_sIDString, sizeof(m_sIDString), "%s\nHealth: %.0f percent\nUse to donate resources", pPlayer->GetPlayerName(), ((float)pPlayer->GetHealth() / (float)pPlayer->GetMaxHealth() ) * 100 ); } else { Q_snprintf( m_sIDString, sizeof(m_sIDString), "%s\nHealth: %.0f percent", pPlayer->GetPlayerName(), ((float)pPlayer->GetHealth() / (float)pPlayer->GetMaxHealth() ) * 100 ); } } else if (( pPlayer->GetHealth() == 0) && (pLocalPlayer->GetClass() == TFCLASS_INFILTRATOR) ) { Q_snprintf( m_sIDString, sizeof(m_sIDString), "%s\nUse to disguise as this player", pPlayer->GetPlayerName() ); } else { m_sIDString[0] = 0; m_iLastEntIndex = 0; } } else { // Objects C_BaseEntity *pEnt = cl_entitylist->GetEnt( iEntIndex ); if ( !pEnt || !pEnt->InSameTeam(pLocalPlayer) ) { // This can happen because the object was destroyed m_sIDString[0] = 0; m_iLastEntIndex = 0; } else { // Don't check validity if it's sent by the server Q_strncpy( m_sIDString, pEnt->GetIDString(), sizeof(m_sIDString) ); m_iLastEntIndex = iEntIndex; } } } // Draw our ID string if ( m_sIDString[0] ) { int width, height; int ypos = YRES(300); // Messagechars can't handle multiple line strings, so parse out the \n's and give it one line at a time char *ch = m_sIDString; while ( *ch ) { // Find the next newline char *next_line; for ( next_line = ch; *next_line != '\n' && *next_line != 0; next_line++ ) { } // Stomp the newline char *top = next_line; if ( *top == '\n' ) { *top = 0; } else { top = NULL; } // Draw the line messagechars->GetStringLength( m_hFont, &width, &height, ch ); messagechars->DrawString( m_hFont, (ScreenWidth() - width) / 2, ypos, 255, 255, 245, 255, ch, IMessageChars::MESSAGESTRINGID_NONE ); ypos += height; // Restore the newline if ( top ) { *top = '\n'; } // Move to the next line ch = next_line; if ( *ch == '\n' ) { ch++; } } } }
void CFXDiscreetLine::Draw( double frametime ) { Vector lineDir, viewDir, cross; Vector vecEnd, vecStart; Vector tmp; // Update the effect Update( frametime ); // Calculate our distance along our path float sDistance = m_fVelocity * m_fStartTime; float eDistance = sDistance - m_fLength; //Clip to start sDistance = MAX( 0.0f, sDistance ); eDistance = MAX( 0.0f, eDistance ); if ( ( sDistance == 0.0f ) && ( eDistance == 0.0f ) ) return; // Clip it if ( m_fClipLength != 0.0f ) { sDistance = MIN( sDistance, m_fClipLength ); eDistance = MIN( eDistance, m_fClipLength ); } // Get our delta to calculate the tc offset float dDistance = fabs( sDistance - eDistance ); float dTotal = ( m_fLength != 0.0f ) ? m_fLength : 0.01f; float fOffset = ( dDistance / dTotal ); // Find our points along our path VectorMA( m_vecOrigin, sDistance, m_vecDirection, vecEnd ); VectorMA( m_vecOrigin, eDistance, m_vecDirection, vecStart ); //Setup our info for drawing the line VectorSubtract( vecEnd, vecStart, lineDir ); VectorSubtract( vecEnd, CurrentViewOrigin(), viewDir ); cross = lineDir.Cross( viewDir ); VectorNormalize( cross ); CMeshBuilder meshBuilder; IMesh *pMesh; CMatRenderContextPtr pRenderContext( materials ); // Better, more visible tracers if ( tracer_extra.GetBool() ) { float flScreenWidth = ScreenWidth(); float flHalfScreenWidth = flScreenWidth * 0.5f; float zCoord = CurrentViewForward().Dot( vecStart - CurrentViewOrigin() ); float flScreenSpaceWidth = m_fScale * flHalfScreenWidth / zCoord; float flAlpha; float flScale; if ( flScreenSpaceWidth < 0.5f ) { flAlpha = RemapVal( flScreenSpaceWidth, 0.25f, 2.0f, 0.3f, 1.0f ); flAlpha = clamp( flAlpha, 0.25f, 1.0f ); flScale = 0.5f * zCoord / flHalfScreenWidth; } else { flAlpha = 1.0f; flScale = m_fScale; } //Bind the material pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, m_pMaterial ); meshBuilder.Begin( pMesh, MATERIAL_QUADS, 2 ); float color = (int) 255.0f * flAlpha; //FIXME: for now no coloration VectorMA( vecStart, -flScale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 1.0f, 0.0f ); meshBuilder.Color4ub( color, color, color, 255 ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( vecStart, flScale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.Color4ub( color, color, color, 255 ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( vecEnd, flScale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 0.0f, fOffset ); meshBuilder.Color4ub( color, color, color, 255 ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( vecEnd, -flScale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 1.0f, fOffset ); meshBuilder.Color4ub( color, color, color, 255 ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); flScale = flScale * 2.0f; color = (int) 64.0f * flAlpha; // Soft outline VectorMA( vecStart, -flScale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 1.0f, 0.0f ); meshBuilder.Color4ub( color, color, color, 255 ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( vecStart, flScale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.Color4ub( color, color, color, 255 ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( vecEnd, flScale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 0.0f, fOffset ); meshBuilder.Color4ub( color, color, color, 255 ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( vecEnd, -flScale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 1.0f, fOffset ); meshBuilder.Color4ub( color, color, color, 255 ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); } else { //Bind the material pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, m_pMaterial ); meshBuilder.Begin( pMesh, MATERIAL_QUADS, 1 ); //FIXME: for now no coloration VectorMA( vecStart, -m_fScale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 1.0f, 0.0f ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( vecStart, m_fScale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 0.0f, 0.0f ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( vecEnd, m_fScale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 0.0f, fOffset ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); VectorMA( vecEnd, -m_fScale, cross, tmp ); meshBuilder.Position3fv( tmp.Base() ); meshBuilder.TexCoord2f( 0, 1.0f, fOffset ); meshBuilder.Color4ub( 255, 255, 255, 255 ); meshBuilder.Normal3fv( cross.Base() ); meshBuilder.AdvanceVertex(); } meshBuilder.End(); pMesh->Draw(); }
int CHudBattery::Draw(float flTime) { if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH ) return 1; int r, g, b, x, y, a; wrect_t rc; rc = *m_prc2; int theMaxArmor = gHUD.GetHUDMaxArmor(); float theScalar = 1.0f/theMaxArmor; rc.top += m_iHeight * ((float)(theMaxArmor-(min(theMaxArmor, m_iBat))) * theScalar); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1 gHUD.GetPrimaryHudColor(r, g, b); if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) )) return 1; // Has health changed? Flash the health # if (m_fFade) { if (m_fFade > FADE_TIME) m_fFade = FADE_TIME; m_fFade -= (gHUD.m_flTimeDelta * 20); if (m_fFade <= 0) { a = 128; m_fFade = 0; } // Fade the health number back to dim a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128; } else a = MIN_ALPHA; ScaleColors(r, g, b, a ); int iOffset = (m_prc1->bottom - m_prc1->top)/6; int theInset = 0; if(gHUD.GetIsAlien()) { theInset = ScreenWidth()*kResourceEnergyBarWidth; } int theViewport[4]; gHUD.GetViewport(theViewport); y = theViewport[1] + theViewport[3] - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; x = theViewport[0] + theInset + kArmorLeftInset*ScreenWidth(); // make sure we have the right sprite handles if ( !m_hSprite1 ) m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) ); if ( !m_hSprite2 ) m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) ); SPR_Set(m_hSprite1, r, g, b ); SPR_DrawAdditive( 0, x, y - iOffset, m_prc1); if (rc.bottom > rc.top) { SPR_Set(m_hSprite2, r, g, b ); SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc); } x += (m_prc1->right - m_prc1->left); x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b); return 1; }
void CASW_VGUI_Message_Log::GetMessagePanelSize(int &w, int &t) { w = ScreenWidth() * 0.5f; t = ScreenHeight() * 0.8f; }
void CASW_VGUI_Info_Message::PerformLayout() { int w, t; GetMessagePanelSize(w, t); SetSize(w, t); m_fScale = ScreenWidth() / 1024.0f; // layout lines float panel_y = ScreenHeight() * TEXT_BORDER_Y; char buffer[256]; for (int i=0;i<4;i++) { m_pLine[i]->GetText(buffer, 256); if (buffer[0]!=NULL) { int linew = GetWide()- (ScreenWidth() * TEXT_BORDER_X * 2); m_pLine[i]->SetWide(linew); int w, h; m_pLine[i]->GetTextImage()->GetContentSize(w, h); m_pLine[i]->SetTall(h); //Msg("setting line %d to %d %d\n", i, linew, h); int posx = ScreenWidth() * TEXT_BORDER_X; int posy = panel_y; //Msg(" and pos %d %d\n", posx, posy); m_pLine[i]->SetPos(posx, posy); panel_y += h + ScreenHeight() * 0.015f; } } // if any image, center it below the text if (HasMessageImage()) { int padding = ScreenHeight() * 0.015f; int space_left = 200 * m_fScale; // assume 8:4 image size int image_tall = space_left; int image_wide = space_left * 2; // if image is wider than panel, reduce size overall if (image_wide > (w - (padding * 2))) { image_wide = (w - (padding * 2)); image_tall = image_wide / 2; } int image_y = panel_y + ((space_left * 0.5f) - (image_tall * 0.5f)); m_pMessageImage->SetBounds((w * 0.5f) - (image_wide * 0.5f), image_y, image_wide, image_tall); panel_y = image_y + image_tall; } int button_wide = 190 * m_fScale; int button_high = 40 * m_fScale; int button_y = panel_y + ScreenHeight() * 0.025f; if (m_pLogButton) { m_pOkayButton->SetSize(button_wide, button_high); m_pOkayButton->SetPos((w * 0.75f) - (button_wide * 0.5f), button_y); m_pLogButton->SetSize(button_wide, button_high); m_pLogButton->SetPos((w * 0.25f) - (button_wide * 0.5f), button_y); } else { m_pOkayButton->SetSize(button_wide, button_high); m_pOkayButton->SetPos((w - button_wide) * 0.5f, button_y); } t = button_y + button_high * 1.4f; SetSize( GetWide(), t ); SetPos( (ScreenWidth() * 0.5f) - (w * 0.5f), (ScreenHeight() * 0.5) - (t * 0.5f) ); }
void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) { int i, j, length, width; const char *pText; //unsigned char line[80]; unsigned char line[256]; pText = pMessage->pMessage; ASSERT(pText != NULL); // Count lines m_parms.lines = 1; m_parms.time = time; m_parms.pMessage = pMessage; length = 0; width = 0; m_parms.totalWidth = 0; while ( *pText ) { if ( *pText == '\n' ) { m_parms.lines++; if ( width > m_parms.totalWidth ) m_parms.totalWidth = width; width = 0; } else width += gHUD.m_scrinfo.charWidths[*pText]; pText++; length++; } m_parms.length = length; m_parms.totalHeight = (m_parms.lines * gHUD.m_scrinfo.iCharHeight); m_parms.y = YPosition( pMessage->y, m_parms.totalHeight ); pText = pMessage->pMessage; m_parms.charTime = 0; MessageScanStart(); for ( i = 0; i < m_parms.lines; i++ ) { m_parms.lineLength = 0; m_parms.width = 0; while ( *pText && *pText != '\n' ) { unsigned char c = *pText; line[m_parms.lineLength] = c; m_parms.width += gHUD.m_scrinfo.charWidths[c]; m_parms.lineLength++; pText++; } pText++; // Skip LF line[m_parms.lineLength] = 0; m_parms.x = XPosition( pMessage->x, m_parms.width, m_parms.totalWidth ); for ( j = 0; j < m_parms.lineLength; j++ ) { m_parms.text = line[j]; int next = m_parms.x + gHUD.m_scrinfo.charWidths[ m_parms.text ]; MessageScanNextChar(); if ( m_parms.x >= 0 && m_parms.y >= 0 && next <= ScreenWidth() ) TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.r, m_parms.g, m_parms.b ); m_parms.x = next; } m_parms.y += gHUD.m_scrinfo.iCharHeight; } }
bool UIPanel::SetClassProperties(const TRDescription& inDesc, Panel* inPanel, CSchemeManager* inSchemeManager) { bool theArgOne, theArgTwo; UIComponent::SetClassProperties(inDesc, inPanel, inSchemeManager); // Position (normalized screen coords) float theXPos = UIDefaultXPos; float theYPos = UIDefaultYPos; theArgOne = inDesc.GetTagValue(UITagXPos, theXPos); theArgTwo = inDesc.GetTagValue(UITagYPos, theYPos); if(theArgOne || theArgTwo) { inPanel->setPos(theXPos*ScreenWidth(), theYPos*ScreenHeight()); } // Width and height (normalized screen coords) float theWidth = UIDefaultWidth; float theHeight = UIDefaultHeight; theArgOne = inDesc.GetTagValue(UITagWidth, theWidth); theArgTwo = inDesc.GetTagValue(UITagHeight, theHeight); if(theArgOne || theArgTwo) { inPanel->setSize(theWidth*ScreenWidth(), theHeight*ScreenHeight()); } // Preferred size (normalized screen coords) float thePreferredWidth = UIDefaultPreferredWidth; float thePreferredHeight = UIDefaultPreferredHeight; theArgOne = inDesc.GetTagValue(UITagPreferredWidth, thePreferredWidth); theArgTwo = inDesc.GetTagValue(UITagPreferredHeight, thePreferredHeight); if(theArgOne || theArgTwo) { inPanel->setPreferredSize(thePreferredWidth*ScreenWidth(), thePreferredHeight*ScreenHeight()); } // Background color (rgba) string theColorString; if(inDesc.GetTagValue(UITagBGColor, theColorString)) { Color theColor; UIStringToColor(theColorString, theColor); inPanel->setBgColor(theColor); } // Foreground color (rgba) if(inDesc.GetTagValue(UITagFGColor, theColorString)) { Color theColor; UIStringToColor(theColorString, theColor); inPanel->setFgColor(theColor); } // Default visibility (bool) bool theTempBool = UIDefaultVisibility; if(inDesc.GetTagValue(UITagVisible, theTempBool)) { inPanel->setVisible(theTempBool); } // Remember the comp name this->SetName(inDesc.GetName()); return true; }
int calendar_handler(int type, int par1, int par2) { if (type == EVT_SHOW) { GenerateCalendar(); DrawCalendar(); } if (type == EVT_ORIENTATION) { SetOrientation(par1); GenerateCalendar(); DrawCalendar(); } if (type==EVT_KEYPRESS) switch(par1) { case KEY_LEFT: case KEY_PREV: case KEY_PREV2: if (year>1) { year--; if (year%4==0) LongYear=1; else LongYear=0; if (LongYear && year%100==0 && year%400!=0) LongYear=0; FirstDay=(FirstDay+371-365*(1-LongYear)-366*LongYear)%7; GenerateCalendar(); DrawCalendar(); } break; case KEY_RIGHT: case KEY_NEXT: case KEY_NEXT2: if (year<10000) { if (year%4==0) LongYear=1; else LongYear=0; if (LongYear && year%100==0 && year%400!=0) LongYear=0; FirstDay=(FirstDay+365*(1-LongYear)+366*LongYear)%7; year++; GenerateCalendar(); DrawCalendar(); } break; case KEY_OK: case KEY_BACK: CloseApp(); break; } #ifndef BASIC if (type == EVT_POINTERUP) { if (par1 > (ScreenWidth() - HeaderWidth) / 2 - 10 && par1 < (ScreenWidth() - HeaderWidth) / 2 + SymbolWidth + 10 && par2 > 0 && par2 < 40) { calendar_handler(EVT_KEYPRESS, KEY_LEFT, 0); } if (par1 > (ScreenWidth() + HeaderWidth) / 2 - SymbolWidth - 10 && par1 < (ScreenWidth() + HeaderWidth) / 2 + 10 && par2 > 0 && par2 < 40) { calendar_handler(EVT_KEYPRESS, KEY_RIGHT, 0); } } #endif return 0; }
void C_PropVehicleDriveable::DrawHudElements( ) { CHudTexture *pIcon; int iIconX, iIconY; if (m_bHasGun) { // draw crosshairs for vehicle gun pIcon = gHUD.GetIcon( "gunhair" ); if ( pIcon != NULL ) { float x, y; if( UseVR() ) { C_BasePlayer *pPlayer = (C_BasePlayer *)GetPassenger( VEHICLE_ROLE_DRIVER ); Vector vecStart, vecDirection; pPlayer->EyePositionAndVectors( &vecStart, &vecDirection, NULL, NULL ); Vector vecEnd = vecStart + vecDirection * MAX_TRACE_LENGTH; trace_t tr; UTIL_TraceLine( vecStart, vecEnd, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); Vector screen; screen.Init(); ScreenTransform(tr.endpos, screen); int vx, vy, vw, vh; vgui::surface()->GetFullscreenViewport( vx, vy, vw, vh ); float screenWidth = vw; float screenHeight = vh; x = 0.5f * ( 1.0f + screen[0] ) * screenWidth + 0.5f; y = 0.5f * ( 1.0f - screen[1] ) * screenHeight + 0.5f; } else { Vector screen; x = ScreenWidth()/2; y = ScreenHeight()/2; #if TRIANGULATED_CROSSHAIR ScreenTransform( m_vecGunCrosshair, screen ); x += 0.5 * screen[0] * ScreenWidth() + 0.5; y -= 0.5 * screen[1] * ScreenHeight() + 0.5; #endif } x -= pIcon->Width() / 2; y -= pIcon->Height() / 2; Color clr = ( m_bUnableToFire ) ? gHUD.m_clrCaution : gHUD.m_clrNormal; pIcon->DrawSelf( x, y, clr ); } if ( m_nScannerDisabledWeapons ) { // Draw icons for scanners "weps disabled" pIcon = gHUD.GetIcon( "dmg_bio" ); if ( pIcon ) { iIconY = 467 - pIcon->Height() / 2; iIconX = 385; if ( !m_bScannerWepIcon ) { pIcon->DrawSelf( XRES(iIconX), YRES(iIconY), Color( 0, 0, 255, 255 ) ); m_bScannerWepIcon = true; m_iScannerWepFlashTimer = 0; m_bScannerWepDim = true; } else { pIcon->DrawSelf( XRES(iIconX), YRES(iIconY), Color( 0, 0, GetFlashColorIntensity(55, 255, m_bScannerWepDim, 10, m_iScannerWepFlashTimer), 255 ) ); m_iScannerWepFlashTimer++; m_iScannerWepFlashTimer %= 20; if(!m_iScannerWepFlashTimer) m_bScannerWepDim ^= 1; } } } } if ( m_nScannerDisabledVehicle ) { // Draw icons for scanners "vehicle disabled" pIcon = gHUD.GetIcon( "dmg_bio" ); if ( pIcon ) { iIconY = 467 - pIcon->Height() / 2; iIconX = 410; if ( !m_bScannerVehicleIcon ) { pIcon->DrawSelf( XRES(iIconX), YRES(iIconY), Color( 0, 0, 255, 255 ) ); m_bScannerVehicleIcon = true; m_iScannerVehicleFlashTimer = 0; m_bScannerVehicleDim = true; } else { pIcon->DrawSelf( XRES(iIconX), YRES(iIconY), Color( 0, 0, GetFlashColorIntensity(55, 255, m_bScannerVehicleDim, 10, m_iScannerVehicleFlashTimer), 255 ) ); m_iScannerVehicleFlashTimer++; m_iScannerVehicleFlashTimer %= 20; if(!m_iScannerVehicleFlashTimer) m_bScannerVehicleDim ^= 1; } } } }
int CHudDeathNotice :: Draw( float flTime ) { int x, y, r, g, b; for ( int i = 0; i < MAX_DEATHNOTICES; i++ ) { if ( rgDeathNoticeList[i].iId == 0 ) break; // we've gone through them all if ( rgDeathNoticeList[i].flDisplayTime < flTime ) { // display time has expired // remove the current item from the list memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) ); i--; // continue on the next item; stop the counter getting incremented continue; } rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME ); // Only draw if the viewport will let me if ( gViewPort && gViewPort->AllowedToPrintText() ) { // Draw the death notice //y = DEATHNOTICE_TOP + (20 * i); //!!! int theBaseY = DEATHNOTICE_TOP; // Bring down death messages when in top down or when we're drawing letter box if(gHUD.m_Spectator.IsInOverviewMode()) { // No HUD elements to compensate for } else if(gHUD.GetInTopDownMode()) { theBaseY = .10*ScreenHeight(); } else if(gHUD.GetIsMarine()) { theBaseY = .26*ScreenHeight(); } else if(gHUD.GetIsAlien()) { theBaseY = kHiveNormScreenY*ScreenHeight() + (kMaxHives-1)*((kHiveNormScreenHeight + kHiveNormScreenVerticalSpacing)*ScreenHeight()); } // Lower death messages more when spectating so they don't overlap (due to letterbox) if(g_iUser1 != OBS_NONE) { theBaseY += .06*ScreenHeight(); } y = theBaseY + (20 * i); //!!! int id = (rgDeathNoticeList[i].iId == -1) ? m_HUD_d_skull : rgDeathNoticeList[i].iId; x = ScreenWidth() - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); if ( !rgDeathNoticeList[i].iSuicide ) { x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) ); // Draw killers name if ( rgDeathNoticeList[i].KillerColor ) DrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] ); x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller ); } r = 255; g = 80; b = 0; if ( rgDeathNoticeList[i].iTeamKill ) { r = 10; g = 240; b = 10; // display it in sickly green } // Draw death weapon SPR_Set( gHUD.GetSprite(id), r, g, b ); SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) ); x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); // Draw victims name (if it was a player that was killed) if (rgDeathNoticeList[i].iNonPlayerKill == FALSE) { if ( rgDeathNoticeList[i].VictimColor ) DrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] ); x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim ); } } } return 1; }
void CASW_VGUI_Skip_Intro::PerformLayout() { SetBounds(0, 0, ScreenWidth(), ScreenHeight()); }
#include "cl_dll/studio_util.h" #include "cl_dll/r_studioint.h" #include "mod/AvHMiniMap.h" #include "mod/AvHActionButtons.h" #include "util/STLUtil.h" #include "mod/AvHSharedUtil.h" #include "common/event_api.h" #include "mod/AvHScriptManager.h" #ifdef USE_LUA extern "C" { #include <lua.h> } #endif extern void DrawScaledHUDSprite(int inSpriteHandle, int inMode, int inRowsInSprite = 1, int inX = 0, int inY = 0, int inWidth = ScreenWidth(), int inHeight = ScreenHeight(), int inForceSpriteFrame = -1, float inStartU = 0.0f, float inStartV = 0.0f, float inEndU = 1.0f, float inEndV = 1.0f, float inRotateUVRadians = 0.0f, bool inUVWrapsOverFrames = false); extern vec3_t v_origin; #ifdef USE_LUA static int errormessage(lua_State* inState) { const char *s = lua_tostring(inState, 1); if (s == NULL) s = "(no message)"; char theErrorMessage[2048]; sprintf(theErrorMessage, "Script error: %s\n", s); // Print the message //gEngfuncs.Con_Printf("%s", theErrorMessage); return 0; }
void FadeInPanel::PerformLayout() { SetBounds(0, 0, ScreenWidth() + 1, ScreenHeight() + 1); m_pBlackImage->SetBounds(0, 0, ScreenWidth() + 1, ScreenHeight() + 1); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFFreezePanelCallout::UpdateForGib( int iGib, int iCount ) { if ( !m_pGibLabel ) return; if ( iGib < ARRAYSIZE(pszCalloutGibNames) ) { if ( pszCalloutGibNames[iGib] ) { m_pGibLabel->SetText( pszCalloutGibNames[iGib] ); } else { m_pGibLabel->SetText( pszCalloutRandomGibNames[ RandomInt(0,ARRAYSIZE(pszCalloutRandomGibNames)-1) ] ); } } else { if ( iCount > 1 ) { m_pGibLabel->SetText( "#FreezePanel_Callout3" ); } else if ( iCount == 1 ) { m_pGibLabel->SetText( "#FreezePanel_Callout2" ); } else { m_pGibLabel->SetText( "#FreezePanel_Callout" ); } } #ifndef _X360 int wide, tall; m_pGibLabel->GetContentSize( wide, tall ); // is the text wider than the label? if ( wide > m_pGibLabel->GetWide() ) { int nDiff = wide - m_pGibLabel->GetWide(); int x, y, w, t; // make the label wider m_pGibLabel->GetBounds( x, y, w, t ); m_pGibLabel->SetBounds( x, y, w + nDiff, t ); CTFImagePanel *pBackground = dynamic_cast<CTFImagePanel *>( FindChildByName( "CalloutBG" ) ); if ( pBackground ) { // also adjust the background image pBackground->GetBounds( x, y, w, t ); pBackground->SetBounds( x, y, w + nDiff, t ); } // make ourselves bigger to accommodate the wider children GetBounds( x, y, w, t ); SetBounds( x, y, w + nDiff, t ); // check that we haven't run off the right side of the screen if ( x + GetWide() > ScreenWidth() ) { // push ourselves to the left to fit on the screen nDiff = ( x + GetWide() ) - ScreenWidth(); SetPos( x - nDiff, y ); // push the arrow to the right to offset moving ourselves to the left vgui::ImagePanel *pArrow = dynamic_cast<ImagePanel *>( FindChildByName( "ArrowIcon" ) ); if ( pArrow ) { pArrow->GetBounds( x, y, w, t ); pArrow->SetBounds( x + nDiff, y, w, t ); } } } #endif }
//------------------------------------------------------- // //------------------------------------------------------- BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: { Loaded = false; ConfigOn = false; // do a version check to make sure users dont have older versions of HGooey if (!HGVersionCheck(HGVersion)) return FALSE; // load and create stuff here (ie load extensions, create textures/images/objects/etc) // make sure the no one moved the extension if (GetFileAttributes("HGooey Files/XenDLL/Extensions/Eye_Map/HG_SDK.dll") == 0xFFFFFFFF) return FALSE; // make sure the menu item texture exists if (GetFileAttributes("HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.bmp") == 0xFFFFFFFF) return FALSE; // make sure the menu memory file exists if (GetFileAttributes("HGooey Files/XenDLL/Common/Memory.xml") == 0xFFFFFFFF) return FALSE; /// const char* Data; bool write = false; bool not_found = false; if (Data = ReadConfigItem("Location X", "HGooey Files/XenDLL/Common/Memory.xml")) { // check the location x memory address try { Location_X = (DWORD*)atoi(Data); } catch (...) { return FALSE; } } else { return FALSE; } if (Data = ReadConfigItem("Location Y", "HGooey Files/XenDLL/Common/Memory.xml")) { // check the location y memory address try { Location_Y = (DWORD*)atoi(Data); } catch (...) { return FALSE; } } else { return FALSE; } if (Data = ReadConfigItem("Screen", "HGooey Files/XenDLL/Common/Memory.xml")) { // check the screen memory address try { Screen = (DWORD*)atoi(Data); } catch (...) { return FALSE; } } else { return FALSE; } if (Data = ReadConfigItem("Chatmode", "HGooey Files/XenDLL/Common/Memory.xml")) { // check the chatmode memory address try { Chatmode = (DWORD*)atoi(Data); } catch (...) { return FALSE; } } else { return FALSE; } /// bZoomIN = false; bZoomOUT = false; Eye_Map = CreateExtension(); IDDTexture* texture = CreateIDDTextureFromFile("HGooey Files/Images/list.bmp", COLOR_RED); // set the menu item SetExtensionMenuItem( Eye_Map, CreateIDDTextureFromFile("HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.bmp", COLOR_RED)); /// if (Data = ReadConfigItem("Hide/Show Using DIK_[Key]", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { if ((HIDESHOW_KEY = convertDIK_Name(Data)) == 0x00) not_found = true; } else { not_found = true; } if (not_found) { HIDESHOW_KEY = 0x00; WriteConfigItem("Hide/Show Using DIK_[Key]", "DIK_", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } /// if (Data = ReadConfigItem("MenuItemIO", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { if (strcmp(Data, "true") == 0) SetExtMenuIO(Eye_Map, true); else if (strcmp(Data, "false") == 0) SetExtMenuIO(Eye_Map, false); else { SetExtMenuIO(Eye_Map, false); write = true; } } else { write = true; } if (write) { WriteConfigItem("MenuItemIO", "false", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); write = false; } /// RECT rect; SetRect(&rect, DefaultList_left, DefaultList_top, DefaultList_right, DefaultList_bottom); Background = CreateImage( 1.0f, 1.0f, texture, &rect); if (!AttachObject(Eye_Map, Background)) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } /// ZoomIN = CreateButton(" + ", 1.0f); if (!AttachObject(Background, ZoomIN)) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } /// ZoomOUT = CreateButton(" - ", 1.0f); if (!AttachObject(Background, ZoomOUT)) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } /// ZoomRESET = CreateButton("reset", 1.0f); if (!AttachObject(Background, ZoomRESET)) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } /// MapButtonText[0] = "Main"; MapButtonText[1] = "2"; MapButtonText[2] = "3"; /// // set a default and then read the config file bool DisplayMoveAlways = false; if (Data = ReadConfigItem("DisplayMoveAlways", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { if (_stricmp(Data, "true") == 0) DisplayMoveAlways = true; else if (_stricmp(Data, "false") != 0) write = true; } else { write = true; } if (write) { WriteConfigItem("DisplayMoveAlways", "false", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); write = false; } if (DisplayMoveAlways) Background->SetMoveable(MOVE_ALWAYS); else Background->SetMoveable(MOVE_LIMITED); float DisplaySizeOriginal = 128.0f; DisplaySize = DisplaySizeOriginal; if (Data = ReadConfigItem("DisplaySizeScale", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { DisplaySize *= (float)atof(Data) / 100.0f; } else { char buffer[64]; sprintf_s(buffer, 64, "%f", 100.0f); WriteConfigItem("DisplaySizeScale", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } DisplayInitialScale = DisplaySizeOriginal / DisplaySize; /// if (Data = ReadConfigItem("MapButtonText[0]", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { MapButtonText[0] = restring(Data, 0, strlen(Data)); } else { WriteConfigItem("MapButtonText[0]", MapButtonText[0], "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapFile[0] = "xenmap0.bmp"; if (GetFileAttributes(MapFile[0]) == 0xFFFFFFFF) MapFile[0] = "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.bmp"; if (Data = ReadConfigItem("Map[0] Filename", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { if (GetFileAttributes(Data) != 0xFFFFFFFF) MapFile[0] = restring(Data, 0, strlen(Data)); } else { WriteConfigItem("MapFile[0] Filename", MapFile[0], "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapF2GX[0] = 6.2890625f; if (Data = ReadConfigItem("Map[0] File2Game X", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { MapF2GX[0] = (float)atof(Data); } else { char buffer[64]; sprintf_s(buffer, 64, "%f", MapF2GX[0]); WriteConfigItem("Map[0] File2Game X", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapF2GY[0] = 6.2890625f; if (Data = ReadConfigItem("Map[0] File2Game Y", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { MapF2GY[0] = (float)atof(Data); } else { char buffer[64]; sprintf_s(buffer, 64, "%f", MapF2GY[0]); WriteConfigItem("Map[0] File2Game Y", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapTexture[0] = CreateIDDTextureFromFile(MapFile[0], COLOR_DEFAULT); SetRect(&Zoom, 0, 0, (int)(DisplaySize * DisplayInitialScale), (int)(DisplaySize * DisplayInitialScale)); Map[0] = CreateImage( 1.0f, 1.0f, MapTexture[0], &Zoom); if (!AttachObject(Background, Map[0])) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } /// for (int i = 1; i < 3; i++) { char bufffffer[128]; sprintf_s(bufffffer, 128, "MapButtonText[%d]", i); if (Data = ReadConfigItem(bufffffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { MapButtonText[i] = restring(Data, 0, strlen(Data)); } else { WriteConfigItem(bufffffer, MapButtonText[i], "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapFile[i] = "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.bmp"; sprintf_s(bufffffer, 128, "Map[%d] Filename", i); if (Data = ReadConfigItem(bufffffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { if (GetFileAttributes(Data) != 0xFFFFFFFF) MapFile[i] = restring(Data, 0, strlen(Data)); } else { WriteConfigItem(bufffffer, MapFile[i], "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapF2GX[i] = 0.0f; sprintf_s(bufffffer, 128, "Map[%d] File2Game X", i); if (Data = ReadConfigItem(bufffffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { MapF2GX[i] = (float)atof(Data); } else { char buffer[64]; sprintf_s(buffer, 64, "%f", MapF2GX[i]); WriteConfigItem(bufffffer, buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapF2GY[i] = 0.0f; sprintf_s(bufffffer, 128, "Map[%d] File2Game Y", i); if (Data = ReadConfigItem(bufffffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { MapF2GY[i] = (float)atof(Data); } else { char buffer[64]; sprintf_s(buffer, 64, "%f", MapF2GY[i]); WriteConfigItem(bufffffer, buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapTexture[i] = CreateIDDTextureFromFile(MapFile[i], COLOR_DEFAULT); SetRect(&Zoom, 0, 0, (int)(DisplaySize * DisplayInitialScale), (int)(DisplaySize * DisplayInitialScale)); Map[i] = CreateImage( 1.0f, 1.0f, MapTexture[i], &Zoom); if (!AttachObject(Background, Map[i])) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } } /// for (int i = 0; i < 3; i++) { MapButton[i] = CreateButton(MapButtonText[i], 1.0f); if (!AttachObject(Background, MapButton[i])) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } MapButton[i]->SetStickyIO(true); } MapButton[0]->SetIO(true); /// Location = CreateImage( 1.0f, 1.0f, CreateIDDTextureFromFile("HGooey Files/XenDLL/Extensions/Eye_Map/location.bmp", COLOR_RED)); if (!AttachObject(Background, Location)) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } Location->SetAcceptAction(false); Location->SetCancelClick(false); /// float DisplayBorder = 7.5f * (DisplaySize / DisplaySizeOriginal); float MapButtonBorder = 2.5f * (DisplaySize / DisplaySizeOriginal); for (int i = 0; i < 3; i++) MapButton[i]->ReScale((DisplaySize / 3.0f) / MapButton[i]->GetWidth(), (DisplaySize / 3.0f) / MapButton[i]->GetWidth()); ZoomIN->ReScale((DisplaySize / 3.0f) / ZoomIN->GetWidth(), (DisplaySize / 3.0f) / ZoomIN->GetWidth()); ZoomOUT->ReScale((DisplaySize / 3.0f) / ZoomOUT->GetWidth(), (DisplaySize / 3.0f) / ZoomOUT->GetWidth()); ZoomRESET->ReScale((DisplaySize / 3.0f) / ZoomRESET->GetWidth(), (DisplaySize / 3.0f) / ZoomRESET->GetWidth()); // should all be the same, but... whatever... float largerHeight0 = MapButton[0]->GetHeight(); if (MapButton[1]->GetHeight() > largerHeight0) largerHeight0 = MapButton[1]->GetHeight(); if (MapButton[2]->GetHeight() > largerHeight0) largerHeight0 = MapButton[2]->GetHeight(); float largerHeight1 = ZoomIN->GetHeight(); if (ZoomOUT->GetHeight() > largerHeight1) largerHeight1 = ZoomOUT->GetHeight(); if (ZoomRESET->GetHeight() > largerHeight1) largerHeight1 = ZoomRESET->GetHeight(); float largerHeight2 = largerHeight0 + largerHeight1; Background->ReScale( (DisplaySize + (DisplayBorder*2.0f)) / (float)DefaultList_width, (DisplaySize + (DisplayBorder*2.0f) + MapButtonBorder + largerHeight2) / (float)DefaultList_height); DisplayX = 0.0f; if (Data = ReadConfigItem("DisplayX", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { DisplayX = (float)atof(Data); if (DisplayX < 0.0f) { DisplayX = 0.0f; write = true; } else if ((DisplayX + Background->GetWidth()) * GuiScaleX() > ScreenWidth()) { DisplayX = (ScreenWidth() / GuiScaleX()) - Background->GetWidth(); write = true; } } else { write = true; } if (write) { char buffer[64]; sprintf_s(buffer, 64, "%f", DisplayX); WriteConfigItem("DisplayX", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); write = false; } DisplayY = 0.0f; if (Data = ReadConfigItem("DisplayY", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { DisplayY = (float)atof(Data); if (DisplayY < 0.0f) { DisplayY = 0.0f; write = true; } else if ((DisplayY + Background->GetHeight()) * GuiScaleY() > ScreenHeight()) { DisplayY = (ScreenHeight() / GuiScaleY()) - Background->GetHeight(); write = true; } } else { write = true; } if (write) { char buffer[64]; sprintf_s(buffer, 64, "%f", DisplayY); WriteConfigItem("DisplayY", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); write = false; } Background->MoveBySize( DisplayX, DisplayY); MapButton[0]->MoveBySize( DisplayBorder, DisplayBorder); MapButton[1]->MoveBySize( DisplayBorder + (DisplaySize / 2.0f) - (MapButton[1]->GetWidth() / 2.0f), DisplayBorder); MapButton[2]->MoveBySize( DisplayBorder + DisplaySize - MapButton[2]->GetWidth(), DisplayBorder); ZoomIN->MoveBySize( DisplayBorder, DisplayBorder + largerHeight0); ZoomOUT->MoveBySize( DisplayBorder + (DisplaySize / 2.0f) - (ZoomOUT->GetWidth() / 2.0f), DisplayBorder + largerHeight0); ZoomRESET->MoveBySize( DisplayBorder + DisplaySize - ZoomRESET->GetWidth(), DisplayBorder + largerHeight0); for (int i = 0; i < 3; i++) { Map[i]->MoveBySize( DisplayBorder, DisplayBorder + MapButtonBorder + largerHeight2); } Location->MoveBySize( DisplayBorder, DisplayBorder + MapButtonBorder + largerHeight2); Loaded = true; } break; case DLL_PROCESS_DETACH: { if (!Loaded) return TRUE; Loaded = false; // unload and destroy stuff here (ie unload extensions) char buffer[64]; sprintf_s(buffer, 64, "%f", Background->GetX() / GuiScaleX()); WriteConfigItem("DisplayX", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); sprintf_s(buffer, 64, "%f", Background->GetY() / GuiScaleY()); WriteConfigItem("DisplayY", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); if (CheckExtMenuIO(Eye_Map)) WriteConfigItem("MenuItemIO", "true", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); else WriteConfigItem("MenuItemIO", "false", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); UnloadExtension(Eye_Map); Eye_Map = NULL; } break; } return TRUE; }