56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
|
|
#include "Cursor.h"
|
|||
|
|
#include "SquirrelClassEx.h"
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void SetCursorGameLogic() {
|
|||
|
|
WindowPtr window = Application::GetInstance().GetWindow();
|
|||
|
|
int X = window->GetPosX();
|
|||
|
|
int MaxX = window->GetWidth() + X;
|
|||
|
|
|
|||
|
|
int Y = window->GetPosY();
|
|||
|
|
int MaxY = window->GetHeight() + Y;
|
|||
|
|
|
|||
|
|
|
|||
|
|
POINT pt = { 0, 0 };
|
|||
|
|
GetCursorPos(&pt);
|
|||
|
|
|
|||
|
|
if (pt.x >= X && pt.x <= MaxX && pt.y >= Y && pt.y <= MaxY /*&& GetForegroundWindow() == window->GetHandle()*/) {
|
|||
|
|
ShowCursor(FALSE);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Cursor::Cursor()
|
|||
|
|
{
|
|||
|
|
this->SetName("GameCursorObject");
|
|||
|
|
this->Retain();
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void Cursor::OnUpdate(Duration dt)
|
|||
|
|
{
|
|||
|
|
static bool Init = false;
|
|||
|
|
if (!Init) {
|
|||
|
|
TexturePtr ImageBuf = SquirrelClassEx::GetTexturePtrByImg("sprite/interface/cursor.img",0);
|
|||
|
|
this->SetFrame(ImageBuf);
|
|||
|
|
Init = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
////<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
Input& input = Input::GetInstance();
|
|||
|
|
|
|||
|
|
////<2F><><EFBFBD><EFBFBD>"<22><><EFBFBD><EFBFBD>"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
this->SetPosition(input.GetMousePos());
|
|||
|
|
|
|||
|
|
//std::cout << (int)GetCursor() << std::endl;
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD>
|
|||
|
|
if ((int)GetCursor() == 65541) {
|
|||
|
|
SetCursorGameLogic();
|
|||
|
|
this->SetVisible(true);
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
this->SetVisible(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|