Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/ObjectTypes/CMiniMap.cpp
Show First 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | |||||
void CMiniMap::HandleMessage(SGUIMessage& Message) | void CMiniMap::HandleMessage(SGUIMessage& Message) | ||||
{ | { | ||||
IGUIObject::HandleMessage(Message); | IGUIObject::HandleMessage(Message); | ||||
switch (Message.type) | switch (Message.type) | ||||
{ | { | ||||
case GUIM_MOUSE_PRESS_LEFT: | case GUIM_MOUSE_PRESS_LEFT: | ||||
if (m_MouseHovering) | if (m_MouseHovering) | ||||
{ | { | ||||
if (!CMiniMap::FireWorldClickEvent(SDL_BUTTON_LEFT, 1)) | |||||
{ | |||||
SetCameraPos(); | SetCameraPos(); | ||||
m_Clicking = true; | m_Clicking = true; | ||||
} | } | ||||
} | |||||
break; | break; | ||||
case GUIM_MOUSE_RELEASE_LEFT: | case GUIM_MOUSE_RELEASE_LEFT: | ||||
if (m_MouseHovering && m_Clicking) | if (m_MouseHovering && m_Clicking) | ||||
SetCameraPos(); | SetCameraPos(); | ||||
m_Clicking = false; | m_Clicking = false; | ||||
break; | break; | ||||
case GUIM_MOUSE_DBLCLICK_LEFT: | case GUIM_MOUSE_DBLCLICK_LEFT: | ||||
if (m_MouseHovering && m_Clicking) | if (m_MouseHovering && m_Clicking) | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
float CMiniMap::GetAngle() const | float CMiniMap::GetAngle() const | ||||
{ | { | ||||
CVector3D cameraIn = m_Camera->GetOrientation().GetIn(); | CVector3D cameraIn = m_Camera->GetOrientation().GetIn(); | ||||
return -atan2(cameraIn.X, cameraIn.Z); | return -atan2(cameraIn.X, cameraIn.Z); | ||||
} | } | ||||
void CMiniMap::FireWorldClickEvent(int UNUSED(button), int UNUSED(clicks)) | bool CMiniMap::FireWorldClickEvent(int button, int UNUSED(clicks)) | ||||
{ | { | ||||
JSContext* cx = g_GUI->GetActiveGUI()->GetScriptInterface()->GetContext(); | JSContext* cx = g_GUI->GetActiveGUI()->GetScriptInterface()->GetContext(); | ||||
JSAutoRequest rq(cx); | JSAutoRequest rq(cx); | ||||
float x, z; | float x, z; | ||||
GetMouseWorldCoordinates(x, z); | GetMouseWorldCoordinates(x, z); | ||||
JS::RootedValue coords(cx); | JS::RootedValue coords(cx); | ||||
ScriptInterface::CreateObject(cx, &coords, "x", x, "z", z); | ScriptInterface::CreateObject(cx, &coords, "x", x, "z", z); | ||||
JS::RootedValue buttonJs(cx); | |||||
ScriptInterface::ToJSVal(cx, &buttonJs, button); | |||||
JS::AutoValueVector paramData(cx); | JS::AutoValueVector paramData(cx); | ||||
paramData.append(coords); | paramData.append(coords); | ||||
paramData.append(buttonJs); | |||||
ScriptEvent(EventNameWorldClick, paramData); | return ScriptEventWithReturn(EventNameWorldClick, paramData); | ||||
} | } | ||||
// This sets up and draws the rectangle on the minimap | // This sets up and draws the rectangle on the minimap | ||||
// which represents the view of the camera in the world. | // which represents the view of the camera in the world. | ||||
void CMiniMap::DrawViewRect(CMatrix3D transform) const | void CMiniMap::DrawViewRect(CMatrix3D transform) const | ||||
{ | { | ||||
// Compute the camera frustum intersected with a fixed-height plane. | // Compute the camera frustum intersected with a fixed-height plane. | ||||
// Use the water height as a fixed base height, which should be the lowest we can go | // Use the water height as a fixed base height, which should be the lowest we can go | ||||
▲ Show 20 Lines • Show All 451 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator