void CUIWindow::Update() { if (GetUICursor()->IsVisible()) { bool cursor_on_window; Fvector2 temp = GetUICursor()->GetCursorPosition(); Frect r; GetAbsoluteRect (r); cursor_on_window = !!r.in(temp); // RECEIVE and LOST focus if(m_bCursorOverWindow != cursor_on_window) { if(cursor_on_window) OnFocusReceive(); else OnFocusLost(); } } for(WINDOW_LIST_it it = m_ChildWndList.begin(); m_ChildWndList.end()!=it; ++it){ if(!(*it)->IsShown()) continue; (*it)->Update(); } }
bool CUIScrollBox::OnMouse(float x, float y, EUIMessages mouse_action) { bool cursor_over; if(x>=-10.0f && x<GetWidth()+10.0f && y>=-10.0f && y<GetHeight()+10.0f) cursor_over = true; else cursor_over = false; bool im_capturer = (GetParent()->GetMouseCapturer()==this); if(mouse_action == WINDOW_LBUTTON_DOWN) { GetParent()->SetCapture(this, true); } else if(mouse_action == WINDOW_LBUTTON_UP) { GetParent()->SetCapture(this, false); } else if(im_capturer && mouse_action == WINDOW_MOUSE_MOVE && cursor_over) { Fvector2 pos = GetWndPos(); Fvector2 delta = GetUICursor()->GetPosDelta(); if(m_bIsHorizontal) pos.x += delta.x; else pos.y += delta.y; SetWndPos (pos); GetMessageTarget()->SendMessage(this, SCROLLBOX_MOVE); } return true; }
void CUISequenceSimpleItem::Update () { float gt = float(Device.dwTimeContinual)/1000.0f; SubItemVecIt _I = m_subitems.begin(); SubItemVecIt _E = m_subitems.end(); for(;_I!=_E;++_I){ SSubItem& s = *_I; bool bPlaying = (gt>(m_time_start+s.m_start-EPS))&&(gt<(m_time_start+s.m_start+s.m_length+EPS)); if (true==bPlaying&&(false==s.m_visible)) s.Start (); else if ((false==bPlaying)&&(true==s.m_visible)) s.Stop (); } if (g_pGameLevel){ CUIGameSP* ui_game_sp = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame()); if(ui_game_sp) { if(!m_pda_section || 0 == xr_strlen(m_pda_section) ) if ( ui_game_sp->PdaMenu().IsShown() || ui_game_sp->ActorMenu().IsShown() || ui_game_sp->TalkMenu->IsShown() || ui_game_sp->UIChangeLevelWnd->IsShown() ) m_UIWindow->Show (false); else m_UIWindow->Show (true); } } if(m_desired_cursor_pos.x && m_desired_cursor_pos.y) GetUICursor()->SetUICursorPosition(m_desired_cursor_pos); }
bool CUITradeWnd::OnItemFocusedUpdate(CUICellItem* itm) { if ( itm ) { #ifdef INV_FLOAT_ITEM_INFO Fvector2 c_pos = GetUICursor()->GetCursorPosition(); Frect vis_rect; vis_rect.set (0,0,UI_BASE_WIDTH, UI_BASE_HEIGHT); Frect r; r.set (0.0f, 0.0f, m_uidata->UIItemInfo.GetWidth(), m_uidata->UIItemInfo.GetHeight()); r.add (c_pos.x, c_pos.y); r.sub (0.0f,r.height()); if (false==((vis_rect.x1<r.x1)&&(vis_rect.x2>r.x2)&&(vis_rect.y1<r.y1)&&(vis_rect.y2>r.y2))) r.sub (r.width(),0.0f); if (false==((vis_rect.x1<r.x1)&&(vis_rect.x2>r.x2)&&(vis_rect.y1<r.y1)&&(vis_rect.y2>r.y2))) r.add (0.0f,r.height()); if (false==((vis_rect.x1<r.x1)&&(vis_rect.x2>r.x2)&&(vis_rect.y1<r.y1)&&(vis_rect.y2>r.y2))) r.add (r.width(), 45.0f); m_uidata->UIItemInfo.SetWndPos(r.lt); SetCurrentItem (itm); #endif } return true; }
void CUICellItem::Update() { if (m_pParentList) EnableHeading(m_pParentList->GetVerticalPlacement()); if(Heading()) { SetHeading ( 90.0f * (PI/180.0f) ); SetHeadingPivot (Fvector2().set(0.0f,0.0f), Fvector2().set(0.0f,GetWndSize().y), true); }else ResetHeadingPivot (); inherited::Update(); if ( CursorOverWindow() ) { Frect clientArea; m_pParentList->GetClientArea(clientArea); Fvector2 cp = GetUICursor()->GetCursorPosition(); if(clientArea.in(cp)) GetMessageTarget()->SendMessage(this, DRAG_DROP_ITEM_FOCUSED_UPDATE, NULL); } m_b_already_drawn=false; }
CUIDragItem* CUICellItem::CreateDragItem() { CUIDragItem* tmp; tmp = xr_new<CUIDragItem>(this); Frect r; GetAbsoluteRect(r); if( m_UIStaticItem.GetFixedLTWhileHeading() ) { float w, h; w = r.width(); h = r.height(); if (Heading()) { // исправление пропорций w = w / m_cell_size.x * m_cell_size.y; h = h / m_cell_size.y * m_cell_size.x; } Fvector2 cp = GetUICursor()->GetCursorPosition(); // поворот на 90 градусов, и центрирование по курсору мыша r.x1 = (cp.x - h / 2.0f); r.y1 = (cp.y - w / 2.0f); r.x2 = r.x1 + h; r.y2 = r.y1 + w; } tmp->Init(GetShader(),r,GetUIStaticItem().GetOriginalRect()); return tmp; }
void CDialogHolder::StopMenu (CUIDialogWnd* pDialog) { R_ASSERT( pDialog->IsShown() ); if( MainInputReceiver()==pDialog ) { if(UseIndicators()) { bool b = !!m_input_receivers.back().m_flags.test(recvItem::eCrosshair); psHUD_Flags.set (HUD_CROSSHAIR_RT, b); b = !!m_input_receivers.back().m_flags.test(recvItem::eIndicators); if(b) HUD().GetUI()->ShowGameIndicators(); else HUD().GetUI()->HideGameIndicators(); } RemoveDialogToRender (pDialog); SetMainInputReceiver (NULL,false); pDialog->SetHolder (NULL); pDialog->Hide (); }else{ RemoveDialogToRender (pDialog); SetMainInputReceiver (pDialog, true); pDialog->SetHolder (NULL); pDialog->Hide (); } if(!MainInputReceiver() || !MainInputReceiver()->NeedCursor() ) GetUICursor()->Hide(); }
void CUIButton::Update() { CUIStatic::Update(); if(CursorOverWindow() && m_hint_text.size() && !g_btnHint->Owner() && Device.dwTimeGlobal>m_dwFocusReceiveTime+500) { g_btnHint->SetHintText (this,*m_hint_text); Fvector2 c_pos = GetUICursor()->GetCursorPosition(); Frect vis_rect; vis_rect.set (0,0,UI_BASE_WIDTH, UI_BASE_HEIGHT); //select appropriate position Frect r; r.set (0.0f, 0.0f, g_btnHint->GetWidth(), g_btnHint->GetHeight()); r.add (c_pos.x, c_pos.y); r.sub (0.0f,r.height()); if (false==is_in2(vis_rect,r)) r.sub (r.width(),0.0f); if (false==is_in2(vis_rect,r)) r.add (0.0f,r.height()); if (false==is_in2(vis_rect,r)) r.add (r.width(), 45.0f); g_btnHint->SetWndPos(r.lt); } }
bool CUIScrollBar::OnKeyboardHold(int dik) { if(dik==MOUSE_1 && (last_hold_time+100)<Device.dwTimeContinual) { Fvector2 cursor_pos = GetUICursor()->GetCursorPosition(); Frect dec_rect; Frect inc_rect; m_DecButton->GetAbsoluteRect(dec_rect); m_IncButton->GetAbsoluteRect(inc_rect); if(dec_rect.in(cursor_pos)) { TryScrollDec (); last_hold_time = Device.dwTimeContinual; return true; }else if(inc_rect.in(cursor_pos)) { TryScrollInc (); last_hold_time = Device.dwTimeContinual; return true; } } return false; }
bool CUIWindow::AlignHintWndPos( Frect const& vis_rect, float border, float dx16pos ) //this = hint wnd { float const cursor_height = 43.0f; Fvector2 cursor_pos = GetUICursor()->GetCursorPosition(); if ( UI()->is_16_9_mode() ) { cursor_pos.x -= dx16pos; } if ( !vis_rect.in(cursor_pos) ) { return false; } Frect rect; rect.set( -border, -border, GetWidth() - 2.0f*border, GetHeight() - 2.0f*border ); rect.add( cursor_pos.x, cursor_pos.y ); rect.sub( 0.0f, rect.height() - border ); if ( !is_in( vis_rect, rect ) ) { rect.sub( rect.width() - border, 0.0f ); } if ( !is_in( vis_rect, rect ) ) { rect.add( 0.0f , rect.height() - border ); } if ( !is_in( vis_rect, rect ) ) { rect.add( rect.width() - border, cursor_height ); } float yn = rect.top - vis_rect.height() + rect.height( ) - border + cursor_height; if ( !is_in( vis_rect, rect ) ) { rect.sub( 0.0f , yn ); } if ( !is_in( vis_rect, rect ) ) { rect.sub( rect.width() - border, 0.0f ); } SetWndPos( rect.lt ); return true; }
bool CUIDialogWnd::IR_OnKeyboardRelease(int dik) { if(!IR_process()) return false; //mouse click if(dik==MOUSE_1 || dik==MOUSE_2 || dik==MOUSE_3) { Fvector2 cp = GetUICursor()->GetPos(); EUIMessages action = (dik==MOUSE_1)?WINDOW_LBUTTON_UP :(dik==MOUSE_2)?WINDOW_RBUTTON_UP:WINDOW_CBUTTON_UP; if (OnMouse(cp.x, cp.y, action)) return true; } if (OnKeyboard(dik, WINDOW_KEY_RELEASED)) return true; if( !StopAnyMove() && g_pGameLevel ){ CObject* O = Level().CurrentEntity(); if( O ){ IInputReceiver* IR = smart_cast<IInputReceiver*>( smart_cast<CGameObject*>(O) ); if (!IR) return (false); IR->IR_OnKeyboardRelease(get_binded_action(dik)); } } return false; }
void CDialogHolder::CleanInternals() { while( !m_input_receivers.empty() ) m_input_receivers.pop_back(); m_dialogsToRender.clear (); GetUICursor()->Hide (); }
void CUISequenceSimpleItem::Start() { inherited::Start (); m_flags.set (etiStoredPauseState, Device.Paused()); if(m_flags.test(etiNeedPauseOn) && !m_flags.test(etiStoredPauseState)){ Device.Pause (TRUE, TRUE, FALSE, "simpleitem_start"); bShowPauseString = FALSE; } if(m_flags.test(etiNeedPauseOff) && m_flags.test(etiStoredPauseState)) Device.Pause (FALSE, TRUE, FALSE, "simpleitem_start"); if(m_flags.test(etiNeedPauseSound)) Device.Pause (TRUE, FALSE, TRUE, "simpleitem_start"); GetUICursor()->SetUICursorPosition (m_desired_cursor_pos); m_time_start = float(Device.dwTimeContinual)/1000.0f; m_owner->MainWnd()->AttachChild (m_UIWindow); if (m_sound._handle()) m_sound.play(NULL, sm_2D); if (g_pGameLevel){ bool bShowPda = false; CUIGameSP* ui_game_sp = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame()); if(!stricmp(m_pda_section,"pda_contacts")){ ui_game_sp->PdaMenu->SetActiveSubdialog(eptContacts); bShowPda = true; }else{ if(!stricmp(m_pda_section,"pda_map")){ ui_game_sp->PdaMenu->SetActiveSubdialog(eptMap); bShowPda = true; }else if(!stricmp(m_pda_section,"pda_quests")){ ui_game_sp->PdaMenu->SetActiveSubdialog(eptQuests); bShowPda = true; }else if(!stricmp(m_pda_section,"pda_diary")){ ui_game_sp->PdaMenu->SetActiveSubdialog(eptDiary); bShowPda = true; }else if(!stricmp(m_pda_section,"pda_ranking")){ ui_game_sp->PdaMenu->SetActiveSubdialog(eptRanking); bShowPda = true; }else if(!stricmp(m_pda_section,"pda_statistics")){ ui_game_sp->PdaMenu->SetActiveSubdialog(eptActorStatistic); bShowPda = true; }else if(!stricmp(m_pda_section,"pda_encyclopedia")){ ui_game_sp->PdaMenu->SetActiveSubdialog(eptEncyclopedia); bShowPda = true; } } if(ui_game_sp) { if( (!ui_game_sp->PdaMenu->IsShown() && bShowPda) || (ui_game_sp->PdaMenu->IsShown() && !bShowPda)) HUD().GetUI()->StartStopMenu (ui_game_sp->PdaMenu,true); } } }
void CUIDragItem::Draw() { Fvector2 tmp; tmp.sub (GetWndPos(), GetUICursor().GetCursorPosition()); tmp.sub (m_pos_offset); tmp.mul (-1.0f); MoveWndDelta (tmp); inherited::Draw (); if(m_custom_draw) m_custom_draw->OnDraw(this); }
bool CUIDialogWnd::IR_OnMouseWheel (int direction) { if(!IR_process()) return false; Fvector2 pos = GetUICursor()->GetPos(); if(direction>0) OnMouse(pos.x,pos.y,WINDOW_MOUSE_WHEEL_UP); else OnMouse(pos.x,pos.y,WINDOW_MOUSE_WHEEL_DOWN); return true; }
void CUIDragItem::Init(const ui_shader& sh, const Frect& rect, const Frect& text_rect) { SetWndRect (rect); m_static.SetShader (sh); m_static.SetTextureRect (text_rect); m_static.SetWndPos (Fvector2().set(0.0f,0.0f)); m_static.SetWndSize (GetWndSize()); m_static.TextureOn (); m_static.SetTextureColor (color_rgba(255,255,255,170)); m_static.SetStretchTexture (true); m_pos_offset.sub (rect.lt, GetUICursor().GetCursorPosition()); }
void CUIDragItem::Init(const ref_shader& sh, const Frect& rect, const Frect& text_rect) { SetWndRect (rect); m_static.SetShader (sh); m_static.SetOriginalRect (text_rect); m_static.SetWndPos (0.0f,0.0f); m_static.SetWndSize (GetWndSize()); m_static.TextureAvailable (true); m_static.TextureOn (); m_static.SetColor (color_rgba(255,255,255,170)); m_static.SetStretchTexture (true); m_pos_offset.sub (rect.lt, GetUICursor()->GetCursorPosition()); }
void CUIDragItem::Draw() { Fvector2 tmp; tmp.sub (GetWndPos(), GetUICursor()->GetCursorPosition()); tmp.sub (m_pos_offset); tmp.mul (-1.0f); MoveWndDelta (tmp); UI()->PushScissor (UI()->ScreenRect(),true); inherited::Draw(); UI()->PopScissor(); }
bool CUIDialogWnd::IR_OnMouseMove(int dx, int dy) { if(!IR_process()) return false; if (GetUICursor()->IsVisible()) { GetUICursor()->MoveBy(float(dx), float(dy)); Fvector2 cPos = GetUICursor()->GetPos(); OnMouse(cPos.x, cPos.y , WINDOW_MOUSE_MOVE); } else if( !StopAnyMove() && g_pGameLevel ){ CObject* O = Level().CurrentEntity(); if( O ){ IInputReceiver* IR = smart_cast<IInputReceiver*>( smart_cast<CGameObject*>(O) ); if (!IR) return (false); IR->IR_OnMouseMove(dx,dy); } }; return true; }
bool CUIScrollBox::OnMouseAction(float x, float y, EUIMessages mouse_action) { Fvector2 border; border.x = 512.0f; // :) border.y = 512.0f; bool over_x = ( x >= -border.x && x < (GetWidth() + border.x) ); bool over_y = ( y >= -border.y && y < (GetHeight() + border.y) ); bool cursor_over = false; if(over_x && over_y) { cursor_over = true; } bool im_capturer = (GetParent()->GetMouseCapturer() == this); if(mouse_action == WINDOW_LBUTTON_DOWN || mouse_action == WINDOW_LBUTTON_DB_CLICK) { GetParent()->SetCapture(this, true); return true; } if(mouse_action == WINDOW_LBUTTON_UP) { GetParent()->SetCapture(this, false); return true; } if(im_capturer && mouse_action == WINDOW_MOUSE_MOVE && cursor_over) { Fvector2 pos = GetWndPos(); Fvector2 delta = GetUICursor().GetCursorPositionDelta(); if(IsHorizontal()) pos.x += delta.x; else pos.y += delta.y; SetWndPos (pos); GetMessageTarget()->SendMessage(this, SCROLLBOX_MOVE); } if( !cursor_over ) { GetParent()->SetCapture(this, false); } return true; }
void CUISequenceSimpleItem::Start() { m_time_start = -3.0f; inherited::Start (); m_flags.set (etiStoredPauseState, Device.Paused()); if(m_flags.test(etiNeedPauseOn) && !m_flags.test(etiStoredPauseState)) { Device.Pause (TRUE, TRUE, FALSE, "simpleitem_start"); bShowPauseString = FALSE; } if(m_flags.test(etiNeedPauseOff) && m_flags.test(etiStoredPauseState)) Device.Pause (FALSE, TRUE, FALSE, "simpleitem_start"); if(m_flags.test(etiNeedPauseSound)) Device.Pause (TRUE, FALSE, TRUE, "simpleitem_start"); if(m_desired_cursor_pos.x && m_desired_cursor_pos.y) GetUICursor().SetUICursorPosition(m_desired_cursor_pos); m_owner->MainWnd()->AttachChild (m_UIWindow); if (m_sound._handle()) m_sound.play(NULL, sm_2D); if (g_pGameLevel) { bool bShowPda = false; CUIGameSP* ui_game_sp = smart_cast<CUIGameSP*>(CurrentGameUI()); if ( !stricmp( m_pda_section, "pda_tasks" ) ) {ui_game_sp->PdaMenu().SetActiveSubdialog("eptTasks"); bShowPda = true; } else if( !stricmp( m_pda_section, "pda_ranking" ) ) {ui_game_sp->PdaMenu().SetActiveSubdialog("eptRanking"); bShowPda = true; } else if( !stricmp( m_pda_section, "pda_logs" ) ) {ui_game_sp->PdaMenu().SetActiveSubdialog("eptLogs"); bShowPda = true; } else if( !stricmp( m_pda_section, "pda_show_second_task_wnd" ) ) { ui_game_sp->PdaMenu().Show_SecondTaskWnd(true); bShowPda = true; } if ( ui_game_sp ) { if ( ( !ui_game_sp->PdaMenu().IsShown() && bShowPda ) || ( ui_game_sp->PdaMenu().IsShown() && !bShowPda ) ) { ui_game_sp->PdaMenu().HideDialog(); } } } }
void CUICarBodyWnd::ActivatePropertiesBox() { if(m_pInventoryBox) return; m_pUIPropertiesBox->RemoveAll(); //. CWeaponMagazined* pWeapon = smart_cast<CWeaponMagazined*>(CurrentIItem()); CEatableItem* pEatableItem = smart_cast<CEatableItem*>(CurrentIItem()); CMedkit* pMedkit = smart_cast<CMedkit*> (CurrentIItem()); CAntirad* pAntirad = smart_cast<CAntirad*> (CurrentIItem()); CBottleItem* pBottleItem = smart_cast<CBottleItem*> (CurrentIItem()); bool b_show = false; LPCSTR _action = NULL; if(pMedkit || pAntirad) { _action = "st_use"; b_show = true; } else if(pEatableItem) { if(pBottleItem) _action = "st_drink"; else _action = "st_eat"; b_show = true; } if(_action) m_pUIPropertiesBox->AddItem(_action, NULL, INVENTORY_EAT_ACTION); if(b_show){ m_pUIPropertiesBox->AutoUpdateSize (); m_pUIPropertiesBox->BringAllToTop (); Fvector2 cursor_pos; Frect vis_rect; GetAbsoluteRect (vis_rect); GetUICursor()->GetPos (cursor_pos.x, cursor_pos.y); cursor_pos.sub (vis_rect.lt); m_pUIPropertiesBox->Show (vis_rect, cursor_pos); } }
bool CUILevelMap::OnMouse (float x, float y, EUIMessages mouse_action) { if (inherited::OnMouse(x,y,mouse_action)) return true; if (MapWnd()->GlobalMap()->Locked()) return true; /* if (MapWnd()->m_flags.is_any(CUIMapWnd::lmZoomIn+CUIMapWnd::lmZoomOut)) return false; if (mouse_action == WINDOW_LBUTTON_DOWN) { if (MapWnd()->m_flags.test(CUIMapWnd::lmUserSpotAdd) ) MapWnd()->AddUserSpot(this); else if(fsimilar(MapWnd()->GlobalMap()->GetCurrentZoom(), MapWnd()->GlobalMap()->GetMinZoom(),EPS_L) ) MapWnd()->SetTargetMap( this, true ); return true; }; */ // Real Wolf: Колбек с позицией и названием карты при клике по самой карте. 03.08.2014. if (mouse_action == WINDOW_LBUTTON_DOWN) { Fvector2 cursor_pos = GetUICursor()->GetCursorPosition(); Fvector2 _p; GetAbsolutePos (_p); cursor_pos.sub (_p); Fvector2 p = ConvertLocalToReal(cursor_pos); Fvector pos; pos.set (p.x, 0.0f, p.y); g_actor->callback(GameObject::eUIMapClick)(pos, MapName().c_str() ); } if(mouse_action==WINDOW_MOUSE_MOVE && (FALSE==pInput->iGetAsyncBtnState(0)) ) { if( MapWnd() ) { MapWnd()->Hint (MapName()); return true; } } return false; }
void CUIDragDropReferenceList::OnItemDrop(CUIWindow* w, void* pData) { OnItemSelected(w, pData); CUICellItem* itm = smart_cast<CUICellItem*>(w); VERIFY(itm->OwnerList() == itm->OwnerList()); if(m_f_item_drop && m_f_item_drop(itm)) { DestroyDragItem(); return; } CUIDragDropListEx* old_owner = itm->OwnerList(); CUIDragDropListEx* new_owner = m_drag_item->BackList(); if(old_owner && new_owner && old_owner!=new_owner) { inherited::OnItemDrop(w, pData); return; } CActor* actor = smart_cast<CActor*>(Level().CurrentViewEntity()); if(actor) { Ivector2 vec = PickCell(GetUICursor().GetCursorPosition()); if(vec.x!=-1&&vec.y!=-1) { Ivector2 vec2 = m_container->GetItemPos(itm); if(vec2.x!=-1&&vec2.y!=-1) { u8 index = u8(vec2.x); shared_str tmp = ACTOR_DEFS::g_quick_use_slots[vec.x]; xr_strcpy(ACTOR_DEFS::g_quick_use_slots[vec.x], ACTOR_DEFS::g_quick_use_slots[index]); xr_strcpy(ACTOR_DEFS::g_quick_use_slots[index], tmp.c_str()); ReloadReferences(actor); return; } } } DestroyDragItem(); }
void CUISequenceSimpleItem::Update() { inherited::Update(); float _start = (m_time_start<0.0f)? (float(Device.dwTimeContinual)/1000.0f) : m_time_start; float gt = float(Device.dwTimeContinual)/1000.0f; SubItemVecIt _I = m_subitems.begin(); SubItemVecIt _E = m_subitems.end(); for(;_I!=_E;++_I) { SSubItem& s = *_I; bool bPlaying = (gt>(_start+s.m_start-EPS))&&(gt<(_start+s.m_start+s.m_length+EPS)); if (true==bPlaying&&(false==s.m_visible)) s.Start (); else if ((false==bPlaying)&&(true==s.m_visible)) s.Stop (); } if(g_pGameLevel && (!m_pda_section || 0 == xr_strlen(m_pda_section)) ) { CUIGameSP* ui_game_sp = smart_cast<CUIGameSP*>(CurrentGameUI()); if(ui_game_sp) { if ( ui_game_sp->PdaMenu().IsShown() || ui_game_sp->ActorMenu().IsShown() || ui_game_sp->TalkMenu->IsShown() || ui_game_sp->UIChangeLevelWnd->IsShown() || (MainMenu()->IsActive() && !m_owner->m_flags.test(CUISequencer::etsOverMainMenu) ) ) m_UIWindow->Show (false); else m_UIWindow->Show (true); } } if(m_desired_cursor_pos.x && m_desired_cursor_pos.y) GetUICursor().SetUICursorPosition(m_desired_cursor_pos); }
void CUICellItem::Update() { EnableHeading(m_pParentList->GetVerticalPlacement()); if(Heading()) { SetHeading ( 90.0f * (PI/180.0f) ); SetHeadingPivot (Fvector2().set(0.0f,0.0f), Fvector2().set(0.0f,GetWndSize().y), true); }else ResetHeadingPivot (); inherited::Update(); if ( CursorOverWindow() ) { Frect clientArea; m_pParentList->GetClientArea(clientArea); Fvector2 cp = GetUICursor().GetCursorPosition(); if(clientArea.in(cp)) GetMessageTarget()->SendMessage(this, DRAG_DROP_ITEM_FOCUSED_UPDATE, NULL); } PIItem item = (PIItem)m_pData; if ( item ) { m_has_upgrade = item->has_any_upgrades(); // Fvector2 size = GetWndSize(); // Fvector2 up_size = m_upgrade->GetWndSize(); // pos.x = size.x - up_size.x - 4.0f; Fvector2 pos; pos.set( m_upgrade_pos ); if ( ChildsCount() ) { pos.x += m_text->GetWndSize().x + 2.0f; } m_upgrade->SetWndPos( pos ); } m_upgrade->Show( m_has_upgrade ); }
CUIDragItem* CUICellItem::CreateDragItem() { CUIDragItem* tmp; tmp = xr_new<CUIDragItem>(this); Frect r; GetAbsoluteRect(r); if( m_UIStaticItem.GetFixedLTWhileHeading() ) { float t1,t2; t1 = r.width(); t2 = r.height()*UI().get_current_kx(); Fvector2 cp = GetUICursor().GetCursorPosition(); r.x1 = (cp.x-t2/2.0f); r.y1 = (cp.y-t1/2.0f); r.x2 = r.x1 + t2; r.y2 = r.y1 + t1; } tmp->Init(GetShader(), r, GetUIStaticItem().GetTextureRect()); return tmp; }
void CDialogHolder::StartMenu (CUIDialogWnd* pDialog, bool bDoHideIndicators) { R_ASSERT ( !pDialog->IsShown() ); AddDialogToRender (pDialog); SetMainInputReceiver (pDialog, false); if(UseIndicators()) { bool b = !!psHUD_Flags.test(HUD_CROSSHAIR_RT); m_input_receivers.back().m_flags.set(recvItem::eCrosshair, b); b = HUD().GetUI()->GameIndicatorsShown(); m_input_receivers.back().m_flags.set(recvItem::eIndicators, b); if(bDoHideIndicators){ psHUD_Flags.set (HUD_CROSSHAIR_RT, FALSE); HUD().GetUI ()->HideGameIndicators(); } } pDialog->SetHolder (this); pDialog->Show (); if( pDialog->NeedCursor() ) GetUICursor()->Show(); if(g_pGameLevel){ CActor* A = smart_cast<CActor*>( Level().CurrentViewEntity() ); if ( A && pDialog->StopAnyMove() ) { A->StopAnyMove (); A->PickupModeOff (); }; if(A) A->IR_OnKeyboardRelease (kWPN_ZOOM); } }
Fvector2 CUIDragItem::GetPosition() { return Fvector2().add(m_pos_offset, GetUICursor()->GetCursorPosition()); }
void CUITrackBar::UpdatePosRelativeToMouse() { float _bkf = 0.0f; int _bki = 0; if(m_b_is_float) { _bkf = m_f_val; }else { _bki = m_i_val; } float btn_width = m_pSlider->GetWidth(); float window_width = GetWidth(); //float fpos = cursor_pos.x; // Start.Real Wolf.06.11.14. Fvector2 pos; GetAbsolutePos(pos); float fpos = GetUICursor()->GetCursorPosition().x - pos.x; // Finish.Real Wolf.06.11.14. if( GetInvert() ) fpos = window_width - fpos; if (fpos < btn_width/2) fpos = btn_width/2; else if (fpos > window_width - btn_width/2) fpos = window_width - btn_width/2; float __fval; float __fmax = (m_b_is_float)?m_f_max:(float)m_i_max; float __fmin = (m_b_is_float)?m_f_min:(float)m_i_min; float __fstep = (m_b_is_float)?m_f_step:(float)m_i_step; __fval = (__fmax - __fmin)*(fpos - btn_width/2)/(window_width - btn_width)+ __fmin; float _d = (__fval-__fmin); float _v = _d/__fstep; int _vi = iFloor(_v); float _vf = __fstep*_vi; if(_d-_vf>__fstep/2.0f) _vf += __fstep; __fval = __fmin+_vf; clamp (__fval, __fmin, __fmax); if(m_b_is_float) m_f_val = __fval; else m_i_val = iFloor(__fval); bool b_ch = false; if(m_b_is_float) { b_ch = !fsimilar(_bkf, m_f_val); }else { b_ch = (_bki != m_i_val); } if(b_ch) GetMessageTarget()->SendMessage(this, BUTTON_CLICKED, NULL); UpdatePos (); }