Mouse pos setting, low cpu mode, stats display
parent
7b6bbf79c4
commit
bd36d76b31
|
@ -15,16 +15,18 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
// app.cpp
|
||||
|
||||
#include "app/app.h"
|
||||
|
||||
#include "app/system.h"
|
||||
|
||||
#include "common/logger.h"
|
||||
#include "common/iman.h"
|
||||
#include "common/image.h"
|
||||
#include "common/key.h"
|
||||
|
||||
#include "graphics/opengl/gldevice.h"
|
||||
|
||||
#include "object/robotmain.h"
|
||||
|
||||
|
||||
|
@ -35,6 +37,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <libintl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
template<> CApplication* CSingleton<CApplication>::mInstance = nullptr;
|
||||
|
@ -116,6 +119,8 @@ CApplication::CApplication()
|
|||
|
||||
m_joystickEnabled = false;
|
||||
|
||||
m_mouseMode = MOUSE_SYSTEM;
|
||||
|
||||
m_kmodState = 0;
|
||||
m_mouseButtonsState = 0;
|
||||
m_trackedKeys = 0;
|
||||
|
@ -123,6 +128,8 @@ CApplication::CApplication()
|
|||
m_dataPath = "./data";
|
||||
|
||||
m_language = LANG_ENGLISH;
|
||||
|
||||
m_lowCPU = true;
|
||||
}
|
||||
|
||||
CApplication::~CApplication()
|
||||
|
@ -649,8 +656,7 @@ void CApplication::UpdateMouse()
|
|||
{
|
||||
Math::IntPoint pos;
|
||||
SDL_GetMouseState(&pos.x, &pos.y);
|
||||
m_systemMousePos = m_engine->WindowToInterfaceCoords(pos);
|
||||
m_engine->SetMousePos(m_systemMousePos);
|
||||
m_mousePos = m_engine->WindowToInterfaceCoords(pos);
|
||||
}
|
||||
|
||||
int CApplication::Run()
|
||||
|
@ -661,6 +667,8 @@ int CApplication::Run()
|
|||
GetCurrentTimeStamp(m_lastTimeStamp);
|
||||
GetCurrentTimeStamp(m_curTimeStamp);
|
||||
|
||||
MoveMouse(Math::Point(0.5f, 0.5f)); // center mouse on start
|
||||
|
||||
while (true)
|
||||
{
|
||||
// To be sure no old event remains
|
||||
|
@ -752,6 +760,11 @@ int CApplication::Run()
|
|||
|
||||
// Update simulation state
|
||||
StepSimulation();
|
||||
|
||||
if (m_lowCPU)
|
||||
{
|
||||
usleep(20000); // should still give plenty of fps
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -889,25 +902,12 @@ bool CApplication::ProcessEvent(Event &event)
|
|||
CLogger *l = GetLogger();
|
||||
|
||||
event.trackedKeys = m_trackedKeys;
|
||||
if (GetSystemMouseVisibile())
|
||||
event.mousePos = m_systemMousePos;
|
||||
else
|
||||
event.mousePos = m_engine->GetMousePos();
|
||||
event.mousePos = m_mousePos;
|
||||
|
||||
if (event.type == EVENT_ACTIVE)
|
||||
{
|
||||
if (m_debugMode)
|
||||
l->Info("Focus change: active = %s\n", event.active.gain ? "true" : "false");
|
||||
|
||||
/*if (m_active != event.active.gain)
|
||||
{
|
||||
m_active = event.active.gain;
|
||||
|
||||
if (m_active)
|
||||
ResumeSimulation();
|
||||
else
|
||||
SuspendSimulation();
|
||||
}*/
|
||||
}
|
||||
else if (event.type == EVENT_KEY_DOWN)
|
||||
{
|
||||
|
@ -1268,27 +1268,31 @@ bool CApplication::GetGrabInput()
|
|||
return result == SDL_GRAB_ON;
|
||||
}
|
||||
|
||||
void CApplication::SetSystemMouseVisible(bool visible)
|
||||
void CApplication::SetMouseMode(MouseMode mode)
|
||||
{
|
||||
SDL_ShowCursor(visible ? SDL_ENABLE : SDL_DISABLE);
|
||||
m_mouseMode = mode;
|
||||
if ((m_mouseMode == MOUSE_SYSTEM) || (m_mouseMode == MOUSE_BOTH))
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
else
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
}
|
||||
|
||||
bool CApplication::GetSystemMouseVisibile()
|
||||
MouseMode CApplication::GetMouseMode()
|
||||
{
|
||||
int result = SDL_ShowCursor(SDL_QUERY);
|
||||
return result == SDL_ENABLE;
|
||||
return m_mouseMode;
|
||||
}
|
||||
|
||||
void CApplication::SetSystemMousePos(Math::Point pos)
|
||||
Math::Point CApplication::GetMousePos()
|
||||
{
|
||||
return m_mousePos;
|
||||
}
|
||||
|
||||
void CApplication::MoveMouse(Math::Point pos)
|
||||
{
|
||||
m_mousePos = pos;
|
||||
|
||||
Math::IntPoint windowPos = m_engine->InterfaceToWindowCoords(pos);
|
||||
SDL_WarpMouse(windowPos.x, windowPos.y);
|
||||
m_systemMousePos = pos;
|
||||
}
|
||||
|
||||
Math::Point CApplication::GetSystemMousePos()
|
||||
{
|
||||
return m_systemMousePos;
|
||||
}
|
||||
|
||||
std::vector<JoystickDevice> CApplication::GetJoystickList()
|
||||
|
@ -1349,3 +1353,13 @@ void CApplication::SetLanguage(Language language)
|
|||
{
|
||||
m_language = language;
|
||||
}
|
||||
|
||||
void CApplication::SetLowCPU(bool low)
|
||||
{
|
||||
m_lowCPU = low;
|
||||
}
|
||||
|
||||
bool CApplication::GetLowCPU()
|
||||
{
|
||||
return m_lowCPU;
|
||||
}
|
||||
|
|
|
@ -22,12 +22,15 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "common/global.h"
|
||||
#include "common/singleton.h"
|
||||
|
||||
#include "graphics/core/device.h"
|
||||
#include "graphics/engine/engine.h"
|
||||
#include "graphics/opengl/gldevice.h"
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -98,6 +101,18 @@ enum ParseArgsStatus
|
|||
PARSE_ARGS_HELP = 3 //! < -help requested
|
||||
};
|
||||
|
||||
/**
|
||||
* \enum MouseMode
|
||||
* \brief Mode of mouse cursor
|
||||
*/
|
||||
enum MouseMode
|
||||
{
|
||||
MOUSE_SYSTEM, //! < system cursor visible; in-game cursor hidden
|
||||
MOUSE_ENGINE, //! < in-game cursor visible; system cursor hidden
|
||||
MOUSE_BOTH, //! < both cursors visible (only for debug)
|
||||
MOUSE_NONE, //! < no cursor visible
|
||||
};
|
||||
|
||||
struct ApplicationPrivate;
|
||||
|
||||
/**
|
||||
|
@ -250,17 +265,17 @@ public:
|
|||
bool GetGrabInput();
|
||||
//@}
|
||||
|
||||
//! Management of the visiblity of system mouse cursor
|
||||
//! Management of mouse mode
|
||||
//@{
|
||||
void SetSystemMouseVisible(bool visible);
|
||||
bool GetSystemMouseVisibile();
|
||||
void SetMouseMode(MouseMode mode);
|
||||
MouseMode GetMouseMode();
|
||||
//@}
|
||||
|
||||
//! Management of the position of system mouse cursor (in interface coords)
|
||||
//@{
|
||||
void SetSystemMousePos(Math::Point pos);
|
||||
Math::Point GetSystemMousePos();
|
||||
//@}
|
||||
//! Returns the position of mouse cursor (in interface coords)
|
||||
Math::Point GetMousePos();
|
||||
|
||||
//! Moves (warps) the mouse cursor to the specified position (in interface coords)
|
||||
void MoveMouse(Math::Point pos);
|
||||
|
||||
//! Management of debug mode (prints more info in logger)
|
||||
//@{
|
||||
|
@ -277,6 +292,12 @@ public:
|
|||
void SetLanguage(Language language);
|
||||
//@}
|
||||
|
||||
//! Management of sleep in main loop (lowers CPU usage)
|
||||
//@{
|
||||
void SetLowCPU(bool low);
|
||||
bool GetLowCPU();
|
||||
//@}
|
||||
|
||||
protected:
|
||||
//! Creates the window's SDL_Surface
|
||||
bool CreateVideoSurface();
|
||||
|
@ -357,8 +378,10 @@ protected:
|
|||
//! Current state of mouse buttons (mask of button indexes)
|
||||
unsigned int m_mouseButtonsState;
|
||||
|
||||
//! Current system mouse position
|
||||
Math::Point m_systemMousePos;
|
||||
//! Current mode of mouse
|
||||
MouseMode m_mouseMode;
|
||||
//! Current position of mouse cursor
|
||||
Math::Point m_mousePos;
|
||||
|
||||
//! Info about current joystick device
|
||||
JoystickDevice m_joystick;
|
||||
|
@ -374,5 +397,8 @@ protected:
|
|||
|
||||
//! Application language
|
||||
Language m_language;
|
||||
|
||||
//! Low cpu mode
|
||||
bool m_lowCPU;
|
||||
};
|
||||
|
||||
|
|
|
@ -116,6 +116,8 @@ CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
|
|||
m_sound = nullptr;
|
||||
m_terrain = nullptr;
|
||||
|
||||
m_showStats = false;
|
||||
|
||||
m_focus = 0.75f;
|
||||
|
||||
m_rankView = 0;
|
||||
|
@ -137,7 +139,6 @@ CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
|
|||
m_groundSpotVisible = true;
|
||||
m_dirty = true;
|
||||
m_fog = true;
|
||||
m_speed = 1.0f;
|
||||
m_secondTexNum = 0;
|
||||
m_eyeDirH = 0.0f;
|
||||
m_eyeDirV = 0.0f;
|
||||
|
@ -171,7 +172,7 @@ CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
|
|||
m_lensMode = true;
|
||||
m_waterMode = true;
|
||||
m_skyMode = true;
|
||||
m_backForce = false; // TODO: change to true?
|
||||
m_backForce = true;
|
||||
m_planetMode = true;
|
||||
m_lightMode = true;
|
||||
m_editIndentMode = true;
|
||||
|
@ -203,9 +204,11 @@ CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
|
|||
m_mice[ENG_MOUSE_SCROLLD] = EngineMouse(30, 31, 46, ENG_RSTATE_TTEXTURE_BLACK, ENG_RSTATE_TTEXTURE_WHITE, Math::Point( 9.0f, 17.0f));
|
||||
|
||||
m_mouseSize = Math::Point(0.04f, 0.04f * (800.0f / 600.0f));
|
||||
m_mousePos = Math::Point(0.5f, 0.5f);
|
||||
m_mouseType = ENG_MOUSE_NORM;
|
||||
m_mouseVisible = false;
|
||||
|
||||
m_fpsCounter = 0;
|
||||
m_lastFrameTime = CreateTimeStamp();
|
||||
m_currentFrameTime = CreateTimeStamp();
|
||||
|
||||
m_texPath = "textures/";
|
||||
m_defaultTexParams.format = TEX_IMG_AUTO;
|
||||
|
@ -226,6 +229,11 @@ CEngine::~CEngine()
|
|||
m_device = nullptr;
|
||||
m_sound = nullptr;
|
||||
m_terrain = nullptr;
|
||||
|
||||
DestroyTimeStamp(m_lastFrameTime);
|
||||
m_lastFrameTime = nullptr;
|
||||
DestroyTimeStamp(m_currentFrameTime);
|
||||
m_currentFrameTime = nullptr;
|
||||
}
|
||||
|
||||
void CEngine::SetDevice(CDevice *device)
|
||||
|
@ -288,6 +296,9 @@ bool CEngine::Create()
|
|||
params.mipmap = false;
|
||||
m_miceTexture = LoadTexture("mouse.png", params);
|
||||
|
||||
GetCurrentTimeStamp(m_currentFrameTime);
|
||||
GetCurrentTimeStamp(m_lastFrameTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -326,18 +337,8 @@ bool CEngine::ProcessEvent(const Event &event)
|
|||
{
|
||||
if (event.type == EVENT_KEY_DOWN)
|
||||
{
|
||||
// !! Debug, to be removed later !!
|
||||
|
||||
if (event.key.key == KEY(F1))
|
||||
{
|
||||
m_mouseVisible = !m_mouseVisible;
|
||||
m_app->SetSystemMouseVisible(! m_app->GetSystemMouseVisibile());
|
||||
}
|
||||
else if (event.key.key == KEY(F2))
|
||||
{
|
||||
int index = static_cast<int>(m_mouseType);
|
||||
m_mouseType = static_cast<EngineMouseType>( (index + 1) % ENG_MOUSE_COUNT );
|
||||
}
|
||||
if (event.key.key == KEY(F12))
|
||||
m_showStats = !m_showStats;
|
||||
}
|
||||
|
||||
// By default, pass on all events
|
||||
|
@ -346,6 +347,27 @@ bool CEngine::ProcessEvent(const Event &event)
|
|||
|
||||
void CEngine::FrameUpdate()
|
||||
{
|
||||
m_fpsCounter++;
|
||||
|
||||
GetCurrentTimeStamp(m_currentFrameTime);
|
||||
float diff = TimeStampDiff(m_lastFrameTime, m_currentFrameTime, STU_SEC);
|
||||
if (diff > 1.0f)
|
||||
{
|
||||
CopyTimeStamp(m_lastFrameTime, m_currentFrameTime);
|
||||
|
||||
m_fps = m_fpsCounter / diff;
|
||||
|
||||
if (m_showStats)
|
||||
{
|
||||
std::stringstream str;
|
||||
str << "FPS: ";
|
||||
str.precision(2);
|
||||
str.setf(std::ios_base::fixed);
|
||||
str << m_fps;
|
||||
m_fpsText = str.str();
|
||||
}
|
||||
}
|
||||
|
||||
float rTime = m_app->GetRelTime();
|
||||
|
||||
m_lightMan->UpdateProgression(rTime);
|
||||
|
@ -2664,26 +2686,6 @@ float CEngine::GetTracePrecision()
|
|||
return m_tracePrecision;
|
||||
}
|
||||
|
||||
void CEngine::SetMouseVisible(bool visible)
|
||||
{
|
||||
m_mouseVisible = visible;
|
||||
}
|
||||
|
||||
bool CEngine::GetMouseVisible()
|
||||
{
|
||||
return m_mouseVisible;
|
||||
}
|
||||
|
||||
void CEngine::SetMousePos(Math::Point pos)
|
||||
{
|
||||
m_mousePos = pos;
|
||||
}
|
||||
|
||||
Math::Point CEngine::GetMousePos()
|
||||
{
|
||||
return m_mousePos;
|
||||
}
|
||||
|
||||
void CEngine::SetMouseType(EngineMouseType type)
|
||||
{
|
||||
m_mouseType = type;
|
||||
|
@ -3167,9 +3169,10 @@ void CEngine::DrawInterface()
|
|||
if (m_overFront)
|
||||
DrawOverColor();
|
||||
|
||||
// Mouse & highlight at the end
|
||||
// At the end to not overlap
|
||||
DrawMouse();
|
||||
DrawHighlight();
|
||||
DrawStats();
|
||||
}
|
||||
|
||||
void CEngine::UpdateGroundSpotTextures()
|
||||
|
@ -3668,10 +3671,8 @@ void CEngine::DrawHighlight()
|
|||
// Status: TESTED, VERIFIED
|
||||
void CEngine::DrawMouse()
|
||||
{
|
||||
if (! m_mouseVisible)
|
||||
return;
|
||||
|
||||
if (m_app->GetSystemMouseVisibile())
|
||||
MouseMode mode = m_app->GetMouseMode();
|
||||
if (mode != MOUSE_ENGINE && mode != MOUSE_BOTH)
|
||||
return;
|
||||
|
||||
Material material;
|
||||
|
@ -3683,9 +3684,9 @@ void CEngine::DrawMouse()
|
|||
|
||||
int index = static_cast<int>(m_mouseType);
|
||||
|
||||
Math::Point pos = m_mousePos;
|
||||
pos.x = m_mousePos.x - (m_mice[index].hotPoint.x * m_mouseSize.x) / 32.0f;
|
||||
pos.y = m_mousePos.y - ((32.0f - m_mice[index].hotPoint.y) * m_mouseSize.y) / 32.0f;
|
||||
Math::Point pos = m_app->GetMousePos();
|
||||
pos.x = pos.x - (m_mice[index].hotPoint.x * m_mouseSize.x) / 32.0f;
|
||||
pos.y = pos.y - ((32.0f - m_mice[index].hotPoint.y) * m_mouseSize.y) / 32.0f;
|
||||
|
||||
Math::Point shadowPos;
|
||||
shadowPos.x = pos.x + (4.0f/800.0f);
|
||||
|
@ -3731,11 +3732,47 @@ void CEngine::DrawMouseSprite(Math::Point pos, Math::Point size, int icon)
|
|||
Vertex(Math::Vector(p2.x, p2.y, 0.0f), normal, Math::Point(u2, v1))
|
||||
};
|
||||
|
||||
m_device->SetRenderState(RENDER_STATE_DEPTH_TEST, false);
|
||||
m_device->SetRenderState(RENDER_STATE_DEPTH_WRITE, false);
|
||||
m_device->DrawPrimitive(PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
|
||||
AddStatisticTriangle(2);
|
||||
}
|
||||
|
||||
void CEngine::DrawStats()
|
||||
{
|
||||
if (!m_showStats)
|
||||
return;
|
||||
|
||||
std::stringstream str;
|
||||
str << "Triangles: ";
|
||||
str << m_statisticTriangle;
|
||||
std::string triangleText = str.str();
|
||||
|
||||
float height = m_text->GetAscent(FONT_COLOBOT, 12.0f);
|
||||
float width = 0.15f;
|
||||
|
||||
Math::Point pos(0.04f, 0.04f + height);
|
||||
|
||||
SetState(ENG_RSTATE_OPAQUE_COLOR);
|
||||
|
||||
Gfx::Color black(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
VertexCol vertex[4] =
|
||||
{
|
||||
VertexCol(Math::Vector(pos.x , pos.y - height, 0.0f), black),
|
||||
VertexCol(Math::Vector(pos.x , pos.y + height, 0.0f), black),
|
||||
VertexCol(Math::Vector(pos.x + width, pos.y - height, 0.0f), black),
|
||||
VertexCol(Math::Vector(pos.x + width, pos.y + height, 0.0f), black)
|
||||
};
|
||||
|
||||
m_device->DrawPrimitive(PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
|
||||
|
||||
SetState(ENG_RSTATE_TEXT);
|
||||
|
||||
m_text->DrawText(triangleText, FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0);
|
||||
|
||||
pos.y -= height;
|
||||
|
||||
m_text->DrawText(m_fpsText, FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Gfx
|
||||
|
|
|
@ -53,6 +53,7 @@ class CSoundInterface;
|
|||
// Graphics module namespace
|
||||
namespace Gfx {
|
||||
|
||||
|
||||
class CDevice;
|
||||
class CLightManager;
|
||||
class CText;
|
||||
|
@ -143,11 +144,11 @@ struct EngineTriangle
|
|||
//! Material
|
||||
Material material;
|
||||
//! Render state
|
||||
int state;
|
||||
int state;
|
||||
//! 1st texture
|
||||
std::string tex1Name;
|
||||
std::string tex1Name;
|
||||
//! 2nd texture
|
||||
std::string tex2Name;
|
||||
std::string tex2Name;
|
||||
|
||||
EngineTriangle()
|
||||
{
|
||||
|
@ -245,10 +246,10 @@ struct EngineObjLevel4;
|
|||
*/
|
||||
struct EngineObjLevel4
|
||||
{
|
||||
bool used;
|
||||
bool used;
|
||||
EngineTriangleType type;
|
||||
Material material;
|
||||
int state;
|
||||
int state;
|
||||
std::vector<VertexTex2> vertices;
|
||||
|
||||
EngineObjLevel4(bool used = false,
|
||||
|
@ -263,9 +264,9 @@ struct EngineObjLevel4
|
|||
*/
|
||||
struct EngineObjLevel3
|
||||
{
|
||||
bool used;
|
||||
float min;
|
||||
float max;
|
||||
bool used;
|
||||
float min;
|
||||
float max;
|
||||
std::vector<EngineObjLevel4> next;
|
||||
|
||||
EngineObjLevel3(bool used = false, float min = 0.0f, float max = 0.0f);
|
||||
|
@ -277,8 +278,8 @@ struct EngineObjLevel3
|
|||
*/
|
||||
struct EngineObjLevel2
|
||||
{
|
||||
bool used;
|
||||
int objRank;
|
||||
bool used;
|
||||
int objRank;
|
||||
std::vector<EngineObjLevel3> next;
|
||||
|
||||
EngineObjLevel2(bool used = false, int objRank = -1);
|
||||
|
@ -290,10 +291,10 @@ struct EngineObjLevel2
|
|||
*/
|
||||
struct EngineObjLevel1
|
||||
{
|
||||
bool used;
|
||||
std::string tex1Name;
|
||||
bool used;
|
||||
std::string tex1Name;
|
||||
Texture tex1;
|
||||
std::string tex2Name;
|
||||
std::string tex2Name;
|
||||
Texture tex2;
|
||||
std::vector<EngineObjLevel2> next;
|
||||
|
||||
|
@ -1122,21 +1123,9 @@ public:
|
|||
float GetTracePrecision();
|
||||
//@}
|
||||
|
||||
//@{
|
||||
//! Management of mouse cursor visibility
|
||||
void SetMouseVisible(bool show);
|
||||
bool GetMouseVisible();
|
||||
//@}
|
||||
|
||||
//@{
|
||||
//! Management of mouse cursor position
|
||||
void SetMousePos(Math::Point pos);
|
||||
Math::Point GetMousePos();
|
||||
//@}
|
||||
|
||||
//@{
|
||||
//! Management of mouse cursor type
|
||||
void SetMouseType(EngineMouseType type);
|
||||
void SetMouseType(EngineMouseType type);
|
||||
EngineMouseType GetMouseType();
|
||||
//@}
|
||||
|
||||
|
@ -1188,6 +1177,8 @@ protected:
|
|||
void DrawMouse();
|
||||
//! Draw part of mouse cursor sprite
|
||||
void DrawMouseSprite(Math::Point pos, Math::Point dim, int icon);
|
||||
//! Draw statistic texts
|
||||
void DrawStats();
|
||||
|
||||
//! Creates new tier 1 object
|
||||
EngineObjLevel1& AddLevel1(const std::string& tex1Name, const std::string& tex2Name);
|
||||
|
@ -1225,27 +1216,31 @@ protected:
|
|||
void UpdateGeometry();
|
||||
|
||||
protected:
|
||||
CInstanceManager* m_iMan;
|
||||
CApplication* m_app;
|
||||
CSoundInterface* m_sound;
|
||||
CDevice* m_device;
|
||||
CText* m_text;
|
||||
CLightManager* m_lightMan;
|
||||
CParticle* m_particle;
|
||||
CWater* m_water;
|
||||
CCloud* m_cloud;
|
||||
CLightning* m_lightning;
|
||||
CPlanet* m_planet;
|
||||
CTerrain* m_terrain;
|
||||
CInstanceManager* m_iMan;
|
||||
CApplication* m_app;
|
||||
CSoundInterface* m_sound;
|
||||
CDevice* m_device;
|
||||
CText* m_text;
|
||||
CLightManager* m_lightMan;
|
||||
CParticle* m_particle;
|
||||
CWater* m_water;
|
||||
CCloud* m_cloud;
|
||||
CLightning* m_lightning;
|
||||
CPlanet* m_planet;
|
||||
CTerrain* m_terrain;
|
||||
|
||||
//! Last encountered error
|
||||
std::string m_error;
|
||||
|
||||
SystemTimeStamp* m_lastFrameTime;
|
||||
SystemTimeStamp* m_currentFrameTime;
|
||||
int m_fpsCounter;
|
||||
float m_fps;
|
||||
|
||||
//! Whether to show stats (FPS, etc)
|
||||
bool m_showStats;
|
||||
std::string m_fpsText;
|
||||
|
||||
//! Speed of animation
|
||||
float m_speed;
|
||||
//! Pause mode
|
||||
bool m_pause;
|
||||
//! Rendering enabled?
|
||||
|
@ -1290,12 +1285,12 @@ protected:
|
|||
float m_eyeDirH;
|
||||
float m_eyeDirV;
|
||||
int m_rankView;
|
||||
Color m_ambientColor[2];
|
||||
Color m_backColor[2];
|
||||
Color m_fogColor[2];
|
||||
Color m_ambientColor[2];
|
||||
Color m_backColor[2];
|
||||
Color m_fogColor[2];
|
||||
float m_deepView[2];
|
||||
float m_fogStart[2];
|
||||
Color m_waterAddColor;
|
||||
Color m_waterAddColor;
|
||||
int m_statisticTriangle;
|
||||
bool m_updateGeometry;
|
||||
int m_alphaMode;
|
||||
|
@ -1310,16 +1305,16 @@ protected:
|
|||
bool m_backgroundFull;
|
||||
Math::Point m_backgroundScale;
|
||||
std::string m_backgroundName;
|
||||
Texture m_backgroundTex;
|
||||
Color m_backgroundColorUp;
|
||||
Color m_backgroundColorDown;
|
||||
Color m_backgroundCloudUp;
|
||||
Color m_backgroundCloudDown;
|
||||
Texture m_backgroundTex;
|
||||
Color m_backgroundColorUp;
|
||||
Color m_backgroundColorDown;
|
||||
Color m_backgroundCloudUp;
|
||||
Color m_backgroundCloudDown;
|
||||
bool m_overFront;
|
||||
Color m_overColor;
|
||||
Color m_overColor;
|
||||
int m_overMode;
|
||||
std::string m_foregroundName;
|
||||
Texture m_foregroundTex;
|
||||
Texture m_foregroundTex;
|
||||
bool m_drawWorld;
|
||||
bool m_drawFront;
|
||||
float m_limitLOD[2];
|
||||
|
@ -1373,22 +1368,18 @@ protected:
|
|||
//! Texture with mouse cursors
|
||||
Texture m_miceTexture;
|
||||
//! Size of mouse cursor
|
||||
Math::Point m_mouseSize;
|
||||
Math::Point m_mouseSize;
|
||||
//! Type of mouse cursor
|
||||
EngineMouseType m_mouseType;
|
||||
//! Position of mouse in interface coords
|
||||
Math::Point m_mousePos;
|
||||
//! Is mouse visible?
|
||||
bool m_mouseVisible;
|
||||
|
||||
//! Last engine render state (-1 at the beginning of frame)
|
||||
int m_lastState;
|
||||
//! Last color set with render state
|
||||
Color m_lastColor;
|
||||
Color m_lastColor;
|
||||
//! Last texture names for 2 used texture stages
|
||||
std::string m_lastTexture[2];
|
||||
//! Last material
|
||||
Material m_lastMaterial;
|
||||
Material m_lastMaterial;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,12 +22,14 @@
|
|||
#include "CBot/CBotDll.h"
|
||||
|
||||
#include "app/app.h"
|
||||
|
||||
#include "common/event.h"
|
||||
#include "common/global.h"
|
||||
#include "common/iman.h"
|
||||
#include "common/misc.h"
|
||||
#include "common/profile.h"
|
||||
#include "common/restext.h"
|
||||
|
||||
#include "graphics/engine/camera.h"
|
||||
#include "graphics/engine/cloud.h"
|
||||
#include "graphics/engine/engine.h"
|
||||
|
@ -40,8 +42,10 @@
|
|||
#include "graphics/engine/terrain.h"
|
||||
#include "graphics/engine/text.h"
|
||||
#include "graphics/engine/water.h"
|
||||
|
||||
#include "math/const.h"
|
||||
#include "math/geometry.h"
|
||||
|
||||
#include "object/auto/auto.h"
|
||||
#include "object/auto/autobase.h"
|
||||
#include "object/brain.h"
|
||||
|
@ -53,11 +57,15 @@
|
|||
#include "object/task/task.h"
|
||||
#include "object/task/taskbuild.h"
|
||||
#include "object/task/taskmanip.h"
|
||||
|
||||
#include "physics/physics.h"
|
||||
|
||||
#include "script/cbottoken.h"
|
||||
#include "script/cmdtoken.h"
|
||||
#include "script/script.h"
|
||||
|
||||
#include "sound/sound.h"
|
||||
|
||||
#include "ui/button.h"
|
||||
#include "ui/displayinfo.h"
|
||||
#include "ui/displaytext.h"
|
||||
|
@ -983,6 +991,8 @@ void CRobotMain::ChangePhase(Phase phase)
|
|||
m_dialog->WriteGamerInfo();
|
||||
}
|
||||
|
||||
m_app->SetLowCPU(true); // doesn't use much CPU in interface phases
|
||||
|
||||
DeleteAllObjects(); // removes all the current 3D Scene
|
||||
|
||||
m_phase = phase;
|
||||
|
@ -1078,19 +1088,14 @@ void CRobotMain::ChangePhase(Phase phase)
|
|||
|
||||
if (m_phase == PHASE_INIT)
|
||||
{
|
||||
// TODO: replace with new textures once done
|
||||
m_engine->DeleteTexture("generna.png");
|
||||
m_engine->DeleteTexture("genernb.png");
|
||||
m_engine->DeleteTexture("genernc.png");
|
||||
m_engine->DeleteTexture("genernd.png");
|
||||
m_engine->DeleteTexture("generic.png");
|
||||
}
|
||||
|
||||
if (m_phase == PHASE_SIMUL)
|
||||
{
|
||||
m_engine->DeleteTexture("inter01a.png");
|
||||
m_engine->DeleteTexture("inter01b.png");
|
||||
m_engine->DeleteTexture("inter01c.png");
|
||||
m_engine->DeleteTexture("inter01d.png");
|
||||
m_engine->DeleteTexture("interface.png");
|
||||
|
||||
m_app->SetLowCPU(false); // high CPU for simulation
|
||||
|
||||
char* read = m_dialog->GetSceneRead();
|
||||
bool loading = (read[0] != 0);
|
||||
|
@ -1193,9 +1198,9 @@ void CRobotMain::ChangePhase(Phase phase)
|
|||
}
|
||||
|
||||
if (m_phase == PHASE_LOADING)
|
||||
m_engine->SetMouseVisible(false);
|
||||
m_app->SetMouseMode(MOUSE_NONE);
|
||||
else
|
||||
m_engine->SetMouseVisible(true);
|
||||
m_app->SetMouseMode(MOUSE_ENGINE);
|
||||
|
||||
m_engine->LoadAllTextures();
|
||||
}
|
||||
|
@ -2862,7 +2867,7 @@ void CRobotMain::HiliteObject(Math::Point pos)
|
|||
if (m_fixScene && m_phase != PHASE_PERSO) return;
|
||||
if (m_movieLock) return;
|
||||
if (m_movie->IsExist()) return;
|
||||
if (!m_engine->GetMouseVisible()) return;
|
||||
if (m_app->GetMouseMode() == MOUSE_NONE) return;
|
||||
|
||||
ClearInterface(); // removes setting evidence and tooltip
|
||||
|
||||
|
@ -3171,7 +3176,7 @@ void CRobotMain::AbortMovie()
|
|||
automat->Abort();
|
||||
}
|
||||
|
||||
m_engine->SetMouseVisible(true);
|
||||
m_app->SetMouseMode(MOUSE_ENGINE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -6623,7 +6628,11 @@ void CRobotMain::SetMovieLock(bool lock)
|
|||
CreateShortcuts();
|
||||
m_map->ShowMap(!m_movieLock && m_mapShow);
|
||||
if (m_movieLock) HiliteClear();
|
||||
m_engine->SetMouseVisible(! m_movieLock);
|
||||
|
||||
if (m_movieLock)
|
||||
m_app->SetMouseMode(MOUSE_NONE);
|
||||
else
|
||||
m_app->SetMouseMode(MOUSE_ENGINE);
|
||||
}
|
||||
|
||||
bool CRobotMain::GetMovieLock()
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "common/global.h"
|
||||
#include "common/event.h"
|
||||
#include "common/logger.h"
|
||||
#include "common/misc.h"
|
||||
#include "common/profile.h"
|
||||
#include "common/iman.h"
|
||||
|
@ -2035,7 +2036,7 @@ void CMainDialog::ChangePhase(Phase phase)
|
|||
|
||||
|
||||
// Processing an event.
|
||||
// Geturns false if the event has been processed completely.
|
||||
// Returns false if the event has been processed completely.
|
||||
|
||||
bool CMainDialog::EventProcess(const Event &event)
|
||||
{
|
||||
|
@ -2207,7 +2208,7 @@ bool CMainDialog::EventProcess(const Event &event)
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( /*TODO: m_engine->GetMouseVisible() &&*/
|
||||
if ( /* m_engine->GetMouseVisible() && TODO: WTF ?! */
|
||||
!m_interface->EventProcess(event) )
|
||||
{
|
||||
return false;
|
||||
|
@ -2784,8 +2785,11 @@ bool CMainDialog::EventProcess(const Event &event)
|
|||
break;
|
||||
|
||||
case EVENT_INTERFACE_MOUSE:
|
||||
m_engine->SetMouseVisible(!m_engine->GetMouseVisible());
|
||||
// TODO: system mouse visible
|
||||
if (m_app->GetMouseMode() == MOUSE_ENGINE)
|
||||
m_app->SetMouseMode(MOUSE_SYSTEM);
|
||||
else if (m_app->GetMouseMode() == MOUSE_SYSTEM)
|
||||
m_app->SetMouseMode(MOUSE_ENGINE);
|
||||
|
||||
ChangeSetupButtons();
|
||||
UpdateSetupButtons();
|
||||
break;
|
||||
|
@ -3241,7 +3245,7 @@ void CMainDialog::GlintMove()
|
|||
}
|
||||
|
||||
|
||||
// Geturns the position for a sound.
|
||||
// Returns the position for a sound.
|
||||
|
||||
Math::Vector SoundPos(Math::Point pos)
|
||||
{
|
||||
|
@ -3254,7 +3258,7 @@ Math::Vector SoundPos(Math::Point pos)
|
|||
return s;
|
||||
}
|
||||
|
||||
// Geturns a random position for a sound.
|
||||
// Returns a random position for a sound.
|
||||
|
||||
Math::Vector SoundRand()
|
||||
{
|
||||
|
@ -3641,7 +3645,7 @@ void CMainDialog::BuildResumeName(char *filename, char *base, int rank)
|
|||
sprintf(filename, "Scene %s %d", base, rank);
|
||||
}
|
||||
|
||||
// Geturns the name of the file or save the files.
|
||||
// Returns the name of the file or save the files.
|
||||
|
||||
char* CMainDialog::GetFilesDir()
|
||||
{
|
||||
|
@ -4666,7 +4670,7 @@ bool CMainDialog::IOReadScene()
|
|||
}
|
||||
|
||||
|
||||
// Geturns the number of accessible chapters.
|
||||
// Returns the number of accessible chapters.
|
||||
|
||||
int CMainDialog::GetChapPassed()
|
||||
{
|
||||
|
@ -6578,7 +6582,7 @@ void CMainDialog::SetSceneRead(const char* name)
|
|||
strcpy(m_sceneRead, name);
|
||||
}
|
||||
|
||||
// Geturns the name of the scene to read.
|
||||
// Returns the name of the scene to read.
|
||||
|
||||
char* CMainDialog::GetSceneRead()
|
||||
{
|
||||
|
@ -6592,7 +6596,7 @@ void CMainDialog::SetStackRead(const char* name)
|
|||
strcpy(m_stackRead, name);
|
||||
}
|
||||
|
||||
// Geturns the name of the scene to read.
|
||||
// Returns the name of the scene to read.
|
||||
|
||||
char* CMainDialog::GetStackRead()
|
||||
{
|
||||
|
@ -6606,7 +6610,7 @@ void CMainDialog::SetSceneName(const char* name)
|
|||
strcpy(m_sceneName, name);
|
||||
}
|
||||
|
||||
// Geturns the name of the chosen to play scene.
|
||||
// Returns the name of the chosen to play scene.
|
||||
|
||||
char* CMainDialog::GetSceneName()
|
||||
{
|
||||
|
@ -6620,14 +6624,14 @@ void CMainDialog::SetSceneRank(int rank)
|
|||
m_sceneRank = rank;
|
||||
}
|
||||
|
||||
// Geturns the rank of the chosen to play scene.
|
||||
// Returns the rank of the chosen to play scene.
|
||||
|
||||
int CMainDialog::GetSceneRank()
|
||||
{
|
||||
return m_sceneRank;
|
||||
}
|
||||
|
||||
// Geturns folder name of the scene that user selected to play.
|
||||
// Returns folder name of the scene that user selected to play.
|
||||
|
||||
char* CMainDialog::GetSceneDir()
|
||||
{
|
||||
|
@ -6646,14 +6650,14 @@ bool CMainDialog::GetSceneSoluce()
|
|||
return m_bSceneSoluce;
|
||||
}
|
||||
|
||||
// Geturns the name of the folder to save.
|
||||
// Returns the name of the folder to save.
|
||||
|
||||
char* CMainDialog::GetSavegameDir()
|
||||
{
|
||||
return m_savegameDir;
|
||||
}
|
||||
|
||||
// Geturns the name of public folder.
|
||||
// Returns the name of public folder.
|
||||
|
||||
char* CMainDialog::GetPublicDir()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue