Changeset 125
- Timestamp:
- 08/20/10 20:30:16 (18 months ago)
- Location:
- cafu/branches/cafu_to_wx
- Files:
-
- 6 modified
-
Ca3DE/MainCanvas.cpp (modified) (3 diffs)
-
Ca3DE/MainCanvas.hpp (modified) (2 diffs)
-
CaWE/GuiEditor/ChildFrame.cpp (modified) (2 diffs)
-
Libs/GuiSys/Gui.hpp (modified) (1 diff)
-
Libs/GuiSys/GuiImpl.cpp (modified) (1 diff)
-
Libs/GuiSys/GuiImpl.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cafu/branches/cafu_to_wx/Ca3DE/MainCanvas.cpp
r120 r125 120 120 m_ConByGuiWin(NULL), 121 121 m_Timer(), 122 m_TotalTime(0.0) 122 m_TotalTime(0.0), 123 m_LastMousePos(IN_OTHER_2D_GUI) 123 124 { 124 125 m_GLContext=new wxGLContext(this); … … 553 554 cf::GuiSys::GuiMan->DistributeClockTickEvents(FrameTimeF); 554 555 556 // If the active GUI is the client GUI, see how far the mouse cursor is off center, 557 // derive a mouse event from it, then recenter the mouse cursor. 558 cf::GuiSys::GuiI* ActiveGui=cf::GuiSys::GuiMan->GetTopmostActiveAndInteractive(); 559 560 if (ActiveGui && ActiveGui->GetRootWindow()->Name=="Client") 561 { 562 const wxPoint MousePos =ScreenToClient(wxGetMousePosition()); // Note: ScreenToClient() is a method of wxWindow. 563 const wxSize WinCenter =GetClientSize()/2; 564 const wxPoint MouseDelta=MousePos-WinCenter; 565 566 if (m_LastMousePos==IN_CLIENT_3D_GUI) 567 { 568 CaMouseEventT ME; 569 570 ME.Type =CaMouseEventT::CM_MOVE_X; 571 ME.Amount=MouseDelta.x; // TODO: Factor out screen resolution... 572 if (ME.Amount!=0) ActiveGui->ProcessDeviceEvent(ME); 573 574 ME.Type =CaMouseEventT::CM_MOVE_Y; 575 ME.Amount=MouseDelta.y; // TODO: Factor out screen resolution... 576 if (ME.Amount!=0) ActiveGui->ProcessDeviceEvent(ME); 577 } 578 579 if (MouseDelta.x || MouseDelta.y) WarpPointer(WinCenter.x, WinCenter.y); 580 m_LastMousePos=IN_CLIENT_3D_GUI; 581 } 582 555 583 if (!m_Parent->IsIconized()) 556 584 { … … 584 612 cf::GuiSys::GuiI* Gui=cf::GuiSys::GuiMan->GetTopmostActiveAndInteractive(); 585 613 586 // This is equivalent to (but much easier than) calling cf::GuiSys::GuiMan->ProcessDeviceEvent(MouseEvent). 587 if (Gui) 588 { 589 Gui->SetMousePos(ME.GetX()*(cf::GuiSys::VIRTUAL_SCREEN_SIZE_X/GetSize().x), 590 ME.GetY()*(cf::GuiSys::VIRTUAL_SCREEN_SIZE_Y/GetSize().y)); 614 // This is equivalent to calling cf::GuiSys::GuiMan->ProcessDeviceEvent(MouseEvent), 615 // but computing the amount of mouse movement is much easier (and more precise) like this. 616 if (Gui && Gui->GetRootWindow()->Name!="Client") 617 { 618 float OldMousePosX; 619 float OldMousePosY; 620 621 Gui->GetMousePos(OldMousePosX, OldMousePosY); 622 623 const float NewMousePosX=ME.GetX()*(cf::GuiSys::VIRTUAL_SCREEN_SIZE_X/GetSize().x); 624 const float NewMousePosY=ME.GetY()*(cf::GuiSys::VIRTUAL_SCREEN_SIZE_Y/GetSize().y); 625 626 // This works, but doesn't forward the mouse event to the windows. 627 // Gui->SetMousePos(NewMousePosX, NewMousePosY); 628 629 CaMouseEventT ME; 630 631 ME.Type =CaMouseEventT::CM_MOVE_X; 632 ME.Amount=NewMousePosX-OldMousePosX; 633 if (ME.Amount!=0) Gui->ProcessDeviceEvent(ME); 634 635 ME.Type =CaMouseEventT::CM_MOVE_Y; 636 ME.Amount=NewMousePosY-OldMousePosY; 637 if (ME.Amount!=0) Gui->ProcessDeviceEvent(ME); 638 639 m_LastMousePos=IN_OTHER_2D_GUI; 591 640 } 592 641 } -
cafu/branches/cafu_to_wx/Ca3DE/MainCanvas.hpp
r119 r125 57 57 58 58 enum InitStateT { INIT_REQUIRED, INIT_FAILED, INIT_SUCCESS }; 59 enum LastMousePosT { IN_CLIENT_3D_GUI, IN_OTHER_2D_GUI }; 59 60 60 61 void Initialize(); … … 89 90 TimerT m_Timer; 90 91 double m_TotalTime; 92 LastMousePosT m_LastMousePos; ///< Used to prevent unwanted changes to the players heading and pitch when we're switching back from a 2D GUI to the 3D client view. 91 93 92 94 DECLARE_EVENT_TABLE() -
cafu/branches/cafu_to_wx/CaWE/GuiEditor/ChildFrame.cpp
r124 r125 496 496 void GuiEditor::ChildFrameT::OnMenuEditDelete(wxCommandEvent& CE) 497 497 { 498 SubmitCommand(new CommandDeleteT(m_GuiDocument, m_GuiDocument->GetSelection())); 498 if (m_GuiDocument->GetSelection().Size()>0) 499 SubmitCommand(new CommandDeleteT(m_GuiDocument, m_GuiDocument->GetSelection())); 499 500 } 500 501 … … 698 699 699 700 case ID_TOOLBAR_WINDOW_DELETE: 700 SubmitCommand(new CommandDeleteT(m_GuiDocument, m_GuiDocument->GetSelection())); 701 if (m_GuiDocument->GetSelection().Size()>0) 702 SubmitCommand(new CommandDeleteT(m_GuiDocument, m_GuiDocument->GetSelection())); 701 703 break; 702 704 -
cafu/branches/cafu_to_wx/Libs/GuiSys/Gui.hpp
r36 r125 69 69 /// Returns whether this GUI is fullscreen and fully opaque, i.e. whether this GUI covers everything under it. If true, the GuiSys saves the rendering of the GUIs "below" this one. This can improve the GUI performance significantly if e.g. the player is at a point in the game where the world rendering FPS is low. 70 70 virtual bool GetIsFullCover() const=0; 71 72 /// Returns the position of the mouse cursor. 73 virtual void GetMousePos(float& MousePosX, float& MousePosY) const=0; 71 74 72 75 /// Sets the position of the mouse cursor. -
cafu/branches/cafu_to_wx/Libs/GuiSys/GuiImpl.cpp
r124 r125 291 291 { 292 292 IsInteractive=IsInteractive_; 293 } 294 295 296 void GuiImplT::GetMousePos(float& MousePosX_, float& MousePosY_) const 297 { 298 MousePosX_=MousePosX; 299 MousePosY_=MousePosY; 293 300 } 294 301 -
cafu/branches/cafu_to_wx/Libs/GuiSys/GuiImpl.hpp
r124 r125 76 76 bool GetIsInteractive() const { return IsInteractive; } 77 77 bool GetIsFullCover() const { return IsFullCover; } 78 void GetMousePos(float& MousePosX_, float& MousePosY_) const; 78 79 void SetMousePos(float MousePosX_, float MousePosY_); 79 80 void SetShowMouse(bool ShowMouse_);
