dev-ui
Zaba999 2012-10-11 23:10:07 +02:00
commit 7575ffd49b
34 changed files with 7069 additions and 841 deletions

20
.gitignore vendored
View File

@ -1,9 +1,19 @@
# Ignore the documentation folder # Ignore the documentation folder
/doc /doc
# Ignore the CMake build files # We don't want anyone to checkin /data folder
/CMakeFiles /data
/CMakeCache.txt
/cmake_install.cmake
/Makefile
# Ignore local data
/colobot.ini
/savegame
# Ignore the CMake build files
CMakeFiles
CMakeCache.txt
cmake_install.cmake
Makefile
/install_manifest.txt
/Testing
/CTestTestfile.cmake
/src/CBot/tests/CBot_console/bin/

View File

@ -134,3 +134,5 @@ endif()
# Subdirectory with sources # Subdirectory with sources
add_subdirectory(src bin) add_subdirectory(src bin)
INSTALL_FILES(/share/games/colobot ../data)

View File

@ -100,7 +100,7 @@ const std::map<EID,const char *> CBotString::s_keywordString =
{ID_DEC, "--"}, {ID_DEC, "--"},
{ID_LO, "<"}, {ID_LO, "<"},
{ID_HI, ">"}, {ID_HI, ">"},
{ID_LS, "<<"}, {ID_LS, "<="},
{ID_HS, ">="}, {ID_HS, ">="},
{ID_EQ, "=="}, {ID_EQ, "=="},
{ID_NE, "!="}, {ID_NE, "!="},

View File

@ -17,3 +17,5 @@ if(${CBOT_STATIC})
else() else()
add_library(CBot SHARED ${SOURCES}) add_library(CBot SHARED ${SOURCES})
endif() endif()
INSTALL_TARGETS(/lib CBot)

View File

@ -193,3 +193,5 @@ link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot)
add_executable(colobot ${SOURCES}) add_executable(colobot ${SOURCES})
target_link_libraries(colobot ${LIBS}) target_link_libraries(colobot ${LIBS})
INSTALL_TARGETS(/games colobot)

View File

@ -38,7 +38,7 @@
class CInstanceManager; class CInstanceManager;
class CEvent; class CEventQueue;
class CRobotMain; class CRobotMain;
class CSoundInterface; class CSoundInterface;

View File

@ -105,7 +105,7 @@ static void PutKeyName(char* dst, const char* src)
{ {
if ( SearchKey(src+s+5, key) ) if ( SearchKey(src+s+5, key) )
{ {
res = CRobotMain::GetInstancePointer()->GetInputBinding(key).key; res = CRobotMain::GetInstancePointer()->GetInputBinding(key).primary;
if (res != KEY_INVALID) if (res != KEY_INVALID)
{ {
if ( GetResource(RES_KEY, res, name) ) if ( GetResource(RES_KEY, res, name) )
@ -172,7 +172,9 @@ static const char* GetResourceBase(ResType type, int num)
case RES_KEY: case RES_KEY:
if (num == VIRTUAL_KMOD_CTRL) if (num == KEY_INVALID)
return "";
else if (num == VIRTUAL_KMOD_CTRL)
return "Ctrl"; return "Ctrl";
else if (num == VIRTUAL_KMOD_SHIFT) else if (num == VIRTUAL_KMOD_SHIFT)
return "Shift"; return "Shift";

View File

@ -14,7 +14,7 @@ ${GTEST_DIR}/include
add_executable(image_test ../image.cpp image_test.cpp) add_executable(image_test ../image.cpp image_test.cpp)
target_link_libraries(image_test ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${PNG_LIBRARIES}) target_link_libraries(image_test ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${PNG_LIBRARIES})
add_executable(profile_test ../profile.cpp ../logger.cpp profile_test.cpp) #add_executable(profile_test ../profile.cpp ../logger.cpp profile_test.cpp)
target_link_libraries(profile_test gtest ${Boost_LIBRARIES}) #target_link_libraries(profile_test gtest ${Boost_LIBRARIES})
add_test(profile_test ./profile_test) #add_test(profile_test ./profile_test)

View File

@ -107,6 +107,14 @@ inline IntColor ColorToIntColor(Color color)
static_cast<unsigned char>(color.a * 255.0f)); static_cast<unsigned char>(color.a * 255.0f));
} }
inline Color IntensityToColor(float intensity)
{
if (intensity <= 0.0f) return Color(0.0f, 0.0f, 0.0f, 0.0f);
if (intensity >= 1.0f) return Color(1.0f, 1.0f, 1.0f, 1.0f);
return Color(intensity, intensity, intensity, intensity);
}
/** /**
* \struct ColorHSV * \struct ColorHSV
* \brief HSV color * \brief HSV color

View File

@ -72,7 +72,7 @@ struct DeviceConfig
size = Math::IntPoint(800, 600); size = Math::IntPoint(800, 600);
bpp = 32; bpp = 32;
fullScreen = false; fullScreen = false;
resizeable = true; resizeable = false;
doubleBuf = true; doubleBuf = true;
noFrame = false; noFrame = false;
} }

View File

@ -68,7 +68,7 @@ struct Light
float attenuation1; float attenuation1;
//! Quadratic attenuation factor //! Quadratic attenuation factor
float attenuation2; float attenuation2;
//! Angle of spotlight cone (0-90 degrees) //! Angle of spotlight cone (0-PI/2 radians)
float spotAngle; float spotAngle;
//! Intensity of spotlight (0 = uniform; 128 = most intense) //! Intensity of spotlight (0 = uniform; 128 = most intense)
@ -91,7 +91,7 @@ struct Light
direction = Math::Vector(0.0f, 0.0f, 1.0f); direction = Math::Vector(0.0f, 0.0f, 1.0f);
attenuation0 = 1.0f; attenuation0 = 1.0f;
attenuation1 = attenuation2 = 0.0f; attenuation1 = attenuation2 = 0.0f;
spotAngle = 90.0f; spotAngle = Math::PI/2.0f;
spotIntensity = 0.0f; spotIntensity = 0.0f;
} }
}; };

View File

@ -272,6 +272,7 @@ bool CEngine::Create()
m_planet = new CPlanet(m_iMan, this); m_planet = new CPlanet(m_iMan, this);
m_lightMan->SetDevice(m_device); m_lightMan->SetDevice(m_device);
m_particle->SetDevice(m_device);
m_text->SetDevice(m_device); m_text->SetDevice(m_device);
if (! m_text->Create()) if (! m_text->Create())

View File

@ -961,9 +961,6 @@ public:
bool GetFog(); bool GetFog();
//@} //@}
//! Indicates whether it is possible to give a color SetState
bool GetStateColor();
//@{ //@{
//! Management of the global mode of secondary texturing //! Management of the global mode of secondary texturing
void SetSecondTexture(int texNum); void SetSecondTexture(int texNum);

View File

@ -19,6 +19,17 @@
#include "graphics/engine/lightning.h" #include "graphics/engine/lightning.h"
#include "common/logger.h" #include "common/logger.h"
#include "common/iman.h"
#include "graphics/core/device.h"
#include "graphics/engine/camera.h"
#include "graphics/engine/terrain.h"
#include "object/object.h"
#include "object/auto/autopara.h"
#include "math/geometry.h"
// Graphics module namespace // Graphics module namespace
@ -27,68 +38,380 @@ namespace Gfx {
CLightning::CLightning(CInstanceManager* iMan, CEngine* engine) CLightning::CLightning(CInstanceManager* iMan, CEngine* engine)
{ {
GetLogger()->Trace("CLightning::CLightning() stub!\n"); m_iMan = iMan;
// TODO! m_iMan->AddInstance(CLASS_BLITZ, this);
m_engine = engine;
m_terrain = nullptr;
m_camera = nullptr;
m_sound = nullptr;
Flush();
} }
CLightning::~CLightning() CLightning::~CLightning()
{ {
GetLogger()->Trace("CLightning::~CLightning() stub!\n");
// TODO!
} }
void CLightning::Flush() void CLightning::Flush()
{ {
GetLogger()->Trace("CLightning::Flush() stub!\n"); m_lightningExists = false;
// TODO! m_phase = LP_WAIT;
m_speed = 0.0f;
m_progress = 0.0f;
for (int i = 0; i < FLASH_SEGMENTS; i++)
{
m_shift[i] = Math::Point(0.0f, 0.0f);
m_width[i] = 1.0f;
}
} }
bool CLightning::EventProcess(const Event &event) bool CLightning::EventProcess(const Event &event)
{ {
GetLogger()->Trace("CLightning::EventProcess() stub!\n"); if (event.type == EVENT_FRAME)
// TODO! return EventFrame(event);
return true;
}
bool CLightning::EventFrame(const Event &event)
{
if (m_engine->GetPause()) return true;
if (m_engine->GetMovieLock()) return true;
m_progress += event.rTime*m_speed;
if (m_phase == LP_WAIT)
{
if (m_progress >= 1.0f)
{
m_pos.x = (Math::Rand()-0.5f)*(3200.0f-200.0f);
m_pos.z = (Math::Rand()-0.5f)*(3200.0f-200.0f);
m_pos.y = 0.0f;
CObject* obj = SearchObject(m_pos);
if (obj == nullptr)
{
m_terrain->AdjustToFloor(m_pos, true);
}
else
{
m_pos = obj->GetPosition(0);
m_terrain->AdjustToFloor(m_pos, true);
ObjectType type = obj->GetType();
if (type == OBJECT_BASE)
{
m_pos.y += 120.0f; // top of the rocket
}
else if (type == OBJECT_PARA)
{
CAutoPara* automat = dynamic_cast<CAutoPara*>(obj->GetAuto());
if (automat != nullptr)
automat->StartLightning();
m_pos.y += 67.0f; // top of lightning rod
}
else
{
obj->ExploObject(EXPLO_BOUM, 1.0f);
}
}
Math::Vector eye = m_engine->GetEyePt();
float dist = Math::Distance(m_pos, eye);
float deep = m_engine->GetDeepView();
if (dist < deep)
{
Math::Vector pos = eye+((m_pos-eye)*0.2f); // like so close!
m_sound->Play(SOUND_BLITZ, pos);
m_camera->StartOver(CAM_OVER_EFFECT_LIGHTNING, m_pos, 1.0f);
m_phase = LP_FLASH;
m_progress = 0.0f;
m_speed = 1.0f;
}
}
}
if (m_phase == LP_FLASH)
{
if (m_progress < 1.0f)
{
float max = 5.0f;
for (int i = 0; i < FLASH_SEGMENTS; i++)
{
max += 0.4f;
m_shift[i].x += (Math::Rand()-0.5f)*max*2.0f;
if ( m_shift[i].x < -max ) m_shift[i].x = -max;
if ( m_shift[i].x > max ) m_shift[i].x = max;
m_shift[i].y += (Math::Rand()-0.5f)*max*2.0f;
if ( m_shift[i].y < -max ) m_shift[i].y = -max;
if ( m_shift[i].y > max ) m_shift[i].y = max;
m_width[i] += (Math::Rand()-0.5f)*2.0f;
if ( m_width[i] < 1.0f ) m_width[i] = 1.0f;
if ( m_width[i] > 6.0f ) m_width[i] = 6.0f;
}
m_shift[0].x = 0.0f;
m_shift[0].y = 0.0f;
m_width[0] = 0.0f;
}
else
{
m_phase = LP_WAIT;
m_progress = 0.0f;
m_speed = 1.0f / (1.0f+Math::Rand()*m_delay);
}
}
return true; return true;
} }
bool CLightning::Create(float sleep, float delay, float magnetic) bool CLightning::Create(float sleep, float delay, float magnetic)
{ {
GetLogger()->Trace("CLightning::Create() stub!\n"); m_lightningExists = true;
// TODO! if (sleep < 1.0f) sleep = 1.0f;
return true; m_sleep = sleep;
m_delay = delay;
m_magnetic = magnetic;
m_phase = LP_WAIT;
m_progress = 0.0f;
m_speed = 1.0f / m_sleep;
if (m_terrain == nullptr)
m_terrain = static_cast<CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
if (m_camera == nullptr)
m_camera = static_cast<CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
if (m_sound == nullptr)
m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
return false;
} }
bool CLightning::GetStatus(float &sleep, float &delay, float &magnetic, float &progress) bool CLightning::GetStatus(float &sleep, float &delay, float &magnetic, float &progress)
{ {
GetLogger()->Trace("CLightning::GetStatus() stub!\n"); if (! m_lightningExists) return false;
// TODO!
sleep = m_sleep;
delay = m_delay;
magnetic = m_magnetic;
progress = m_progress;
return true; return true;
} }
bool CLightning::SetStatus(float sleep, float delay, float magnetic, float progress) bool CLightning::SetStatus(float sleep, float delay, float magnetic, float progress)
{ {
GetLogger()->Trace("CLightning::SetStatus() stub!\n"); m_lightningExists = true;
// TODO!
m_sleep = sleep;
m_delay = delay;
m_magnetic = magnetic;
m_progress = progress;
m_phase = LP_WAIT;
m_speed = 1.0f/m_sleep;
return true; return true;
} }
void CLightning::Draw() void CLightning::Draw()
{ {
GetLogger()->Trace("CLightning::Draw() stub!\n"); if (!m_lightningExists) return;
// TODO! if (m_phase != LP_FLASH) return;
}
bool CLightning::EventFrame(const Event &event) CDevice* device = m_engine->GetDevice();
{
GetLogger()->Trace("CLightning::EventFrame() stub!\n"); Math::Matrix mat;
// TODO! mat.LoadIdentity();
return true; device->SetTransform(TRANSFORM_WORLD, mat);
m_engine->SetTexture("effect00.png");
m_engine->SetState(ENG_RSTATE_TTEXTURE_BLACK);
Math::Point texInf;
texInf.x = 64.5f/256.0f;
texInf.y = 33.0f/256.0f;
Math::Point texSup;
texSup.x = 95.5f/256.0f;
texSup.y = 34.0f/256.0f; // blank
Math::Vector p1 = m_pos;
Math::Vector eye = m_engine->GetEyePt();
float a = Math::RotateAngle(eye.x-p1.x, eye.z-p1.z);
Math::Vector n = Math::Normalize(p1-eye);
Math::Vector corner[4];
Vertex vertex[4];
for (int i = 0; i < FLASH_SEGMENTS-1; i++)
{
Math::Vector p2 = p1;
p2.y += 8.0f+0.2f*i;
Math::Point rot;
Math::Vector p = p1;
p.x += m_width[i];
rot = Math::RotatePoint(Math::Point(p1.x, p1.z), a+Math::PI/2.0f, Math::Point(p.x, p.z));
corner[0].x = rot.x+m_shift[i].x;
corner[0].y = p1.y;
corner[0].z = rot.y+m_shift[i].y;
rot = Math::RotatePoint(Math::Point(p1.x, p1.z), a-Math::PI/2.0f, Math::Point(p.x, p.z));
corner[1].x = rot.x+m_shift[i].x;
corner[1].y = p1.y;
corner[1].z = rot.y+m_shift[i].y;
p = p2;
p.x += m_width[i+1];
rot = Math::RotatePoint(Math::Point(p2.x, p2.z), a+Math::PI/2.0f, Math::Point(p.x, p.z));
corner[2].x = rot.x+m_shift[i+1].x;
corner[2].y = p2.y;
corner[2].z = rot.y+m_shift[i+1].y;
rot = Math::RotatePoint(Math::Point(p2.x, p2.z), a-Math::PI/2.0f, Math::Point(p.x, p.z));
corner[3].x = rot.x+m_shift[i+1].x;
corner[3].y = p2.y;
corner[3].z = rot.y+m_shift[i+1].y;
if (p2.y < p1.y)
{
vertex[0] = Vertex(corner[1], n, Math::Point(texSup.x, texSup.y));
vertex[1] = Vertex(corner[0], n, Math::Point(texInf.x, texSup.y));
vertex[2] = Vertex(corner[3], n, Math::Point(texSup.x, texInf.y));
vertex[3] = Vertex(corner[2], n, Math::Point(texInf.x, texInf.y));
}
else
{
vertex[0] = Vertex(corner[0], n, Math::Point(texSup.x, texSup.y));
vertex[1] = Vertex(corner[1], n, Math::Point(texInf.x, texSup.y));
vertex[2] = Vertex(corner[2], n, Math::Point(texSup.x, texInf.y));
vertex[3] = Vertex(corner[3], n, Math::Point(texInf.x, texInf.y));
}
device->DrawPrimitive(PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
m_engine->AddStatisticTriangle(2);
p1 = p2;
}
} }
CObject* CLightning::SearchObject(Math::Vector pos) CObject* CLightning::SearchObject(Math::Vector pos)
{ {
GetLogger()->Trace("CLightning::SearchObject() stub!\n"); // Lightning conductors
// TODO! std::vector<CObject*> paraObj;
return nullptr; paraObj.reserve(100);
std::vector<Math::Vector> paraObjPos;
paraObjPos.reserve(100);
// Seeking the object closest to the point of impact of lightning.
CObject* bestObj = 0;
float min = 100000.0f;
for (int i = 0; i < 1000000; i++)
{
CObject* obj = static_cast<CObject*>( m_iMan->SearchInstance(CLASS_OBJECT, i) );
if (obj == nullptr) break;
if (!obj->GetActif()) continue; // inactive object?
if (obj->GetTruck() != nullptr) continue; // object transported?
ObjectType type = obj->GetType();
if ( type == OBJECT_BASE ||
type == OBJECT_PARA ) // building a lightning effect?
{
paraObj.push_back(obj);
paraObjPos.push_back(obj->GetPosition(0));
}
float detect = 0.0f;
if ( type == OBJECT_BASE ||
type == OBJECT_DERRICK ||
type == OBJECT_FACTORY ||
type == OBJECT_REPAIR ||
type == OBJECT_DESTROYER||
type == OBJECT_STATION ||
type == OBJECT_CONVERT ||
type == OBJECT_TOWER ||
type == OBJECT_RESEARCH ||
type == OBJECT_RADAR ||
type == OBJECT_INFO ||
type == OBJECT_ENERGY ||
type == OBJECT_LABO ||
type == OBJECT_NUCLEAR ||
type == OBJECT_PARA ||
type == OBJECT_SAFE ||
type == OBJECT_HUSTON )
{
detect = m_magnetic;
}
if ( type == OBJECT_METAL ||
type == OBJECT_POWER ||
type == OBJECT_ATOMIC )
{
detect = m_magnetic*0.3f;
}
if ( type == OBJECT_MOBILEfa ||
type == OBJECT_MOBILEta ||
type == OBJECT_MOBILEwa ||
type == OBJECT_MOBILEia ||
type == OBJECT_MOBILEfc ||
type == OBJECT_MOBILEtc ||
type == OBJECT_MOBILEwc ||
type == OBJECT_MOBILEic ||
type == OBJECT_MOBILEfi ||
type == OBJECT_MOBILEti ||
type == OBJECT_MOBILEwi ||
type == OBJECT_MOBILEii ||
type == OBJECT_MOBILEfs ||
type == OBJECT_MOBILEts ||
type == OBJECT_MOBILEws ||
type == OBJECT_MOBILEis ||
type == OBJECT_MOBILErt ||
type == OBJECT_MOBILErc ||
type == OBJECT_MOBILErr ||
type == OBJECT_MOBILErs ||
type == OBJECT_MOBILEsa ||
type == OBJECT_MOBILEft ||
type == OBJECT_MOBILEtt ||
type == OBJECT_MOBILEwt ||
type == OBJECT_MOBILEit ||
type == OBJECT_MOBILEdr )
{
detect = m_magnetic*0.5f;
}
if (detect == 0.0f) continue;
Math::Vector oPos = obj->GetPosition(0);
float dist = Math::DistanceProjected(oPos, pos);
if (dist > detect) continue;
if (dist < min)
{
min = dist;
bestObj = obj;
}
}
if (bestObj == nullptr)
return nullptr; // nothing found
// Under the protection of a lightning conductor?
Math::Vector oPos = bestObj->GetPosition(0);
for (int i = paraObj.size()-1; i >= 0; i--)
{
float dist = Math::DistanceProjected(oPos, paraObjPos[i]);
if (dist <= LTNG_PROTECTION_RADIUS)
return paraObj[i];
}
return bestObj;
} }

View File

@ -30,7 +30,7 @@
class CInstanceManager; class CInstanceManager;
class CObject; class CObject;
class CSound; class CSoundInterface;
// Graphics module namespace // Graphics module namespace
@ -40,21 +40,15 @@ class CEngine;
class CTerrain; class CTerrain;
class CCamera; class CCamera;
//! Radius of lightning protection
const float LTNG_PROTECTION_RADIUS = 200.0f;
const float BLITZPARA = 200.0f; // radius of lightning protection
const short BLITZMAX = 50;
enum BlitzPhase
{
BPH_WAIT,
BPH_BLITZ,
};
/** /**
* \class CLightning * \class CLightning
* \brief Lightning effect renderer * \brief Lightning effect renderer
* *
* Functions are only stubs for now. * TODO: documentation
*/ */
class CLightning class CLightning
{ {
@ -62,35 +56,55 @@ public:
CLightning(CInstanceManager* iMan, CEngine* engine); CLightning(CInstanceManager* iMan, CEngine* engine);
~CLightning(); ~CLightning();
void Flush(); //! Triggers lightning
bool EventProcess(const Event &event);
bool Create(float sleep, float delay, float magnetic); bool Create(float sleep, float delay, float magnetic);
//! Removes lightning
void Flush();
//! Gives the status of lightning
bool GetStatus(float &sleep, float &delay, float &magnetic, float &progress); bool GetStatus(float &sleep, float &delay, float &magnetic, float &progress);
//! Specifies the status of lightning
bool SetStatus(float sleep, float delay, float magnetic, float progress); bool SetStatus(float sleep, float delay, float magnetic, float progress);
//! Management of an event
bool EventProcess(const Event &event);
//! Draws lightning
void Draw(); void Draw();
protected: protected:
//! Updates lightning
bool EventFrame(const Event &event); bool EventFrame(const Event &event);
//! Seeks for the object closest to the lightning
CObject* SearchObject(Math::Vector pos); CObject* SearchObject(Math::Vector pos);
protected: protected:
CInstanceManager* m_iMan; CInstanceManager* m_iMan;
CEngine* m_engine; CEngine* m_engine;
CTerrain* m_terrain; CTerrain* m_terrain;
CCamera* m_camera; CCamera* m_camera;
CSound* m_sound; CSoundInterface* m_sound;
bool m_bBlitzExist; bool m_lightningExists;
float m_sleep; float m_sleep;
float m_delay; float m_delay;
float m_magnetic; float m_magnetic;
BlitzPhase m_phase;
float m_time;
float m_speed; float m_speed;
float m_progress; float m_progress;
Math::Vector m_pos; Math::Vector m_pos;
Math::Point m_shift[BLITZMAX];
float m_width[BLITZMAX]; enum LightningPhase
{
LP_WAIT,
LP_FLASH,
};
LightningPhase m_phase;
static const short FLASH_SEGMENTS = 50;
Math::Point m_shift[FLASH_SEGMENTS];
float m_width[FLASH_SEGMENTS];
}; };

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@
/** /**
* \file graphics/engine/particle.h * \file graphics/engine/particle.h
* \brief Particle rendering - CParticle class (aka particule) * \brief Particle rendering - CParticle class (aka particle)
*/ */
#pragma once #pragma once
@ -46,7 +46,7 @@ const short MAXWHEELTRACE = 1000;
const short SH_WORLD = 0; // particle in the world in the interface const short SH_WORLD = 0; // particle in the world in the interface
const short SH_FRONT = 1; // particle in the world on the interface const short SH_FRONT = 1; // particle in the world on the interface
const short SH_INTERFACE = 2; // particle in the interface const short SH_INTERFACE = 2; // particle in the interface
const short SH_MAX = 3; const short SH_MAX = 3;
// type == 0 -> triangles // type == 0 -> triangles
@ -58,145 +58,145 @@ const short SH_MAX = 3;
enum ParticleType enum ParticleType
{ {
PARTIEXPLOT = 1, // technology explosion PARTIEXPLOT = 1, //! < technology explosion
PARTIEXPLOO = 2, // organic explosion PARTIEXPLOO = 2, //! < organic explosion
PARTIMOTOR = 3, // the engine exhaust gas PARTIMOTOR = 3, //! < the engine exhaust gas
PARTIGLINT = 4, // reflection PARTIGLINT = 4, //! < reflection
PARTIBLITZ = 5, // lightning recharging battery PARTIBLITZ = 5, //! < lightning recharging battery
PARTICRASH = 6, // dust after fall PARTICRASH = 6, //! < dust after fall
PARTIGAS = 7, // gas from the reactor PARTIGAS = 7, //! < gas from the reactor
PARTIFIRE = 9, // fireball shrinks PARTIFIRE = 9, //! < fireball shrinks
PARTIFIREZ = 10, // fireball grows PARTIFIREZ = 10, //! < fireball grows
PARTIBLUE = 11, // blue ball PARTIBLUE = 11, //! < blue ball
PARTISELY = 12, // yellow selection PARTISELY = 12, //! < yellow selection
PARTISELR = 13, // red selection PARTISELR = 13, //! < red selection
PARTIGUN1 = 18, // a bullet (fireball) PARTIGUN1 = 18, //! < a bullet (fireball)
PARTIGUN2 = 19, // bullet 2 (ant) PARTIGUN2 = 19, //! < bullet 2 (ant)
PARTIGUN3 = 20, // bullet 3 (spider) PARTIGUN3 = 20, //! < bullet 3 (spider)
PARTIGUN4 = 21, // bullet 4 (orgaball) PARTIGUN4 = 21, //! < bullet 4 (orgaball)
PARTIFRAG = 22, // triangular fragment PARTIFRAG = 22, //! < triangular fragment
PARTIQUEUE = 23, // inflamed tail PARTIQUEUE = 23, //! < inflamed tail
PARTIORGANIC1 = 24, // organic ball mother PARTIORGANIC1 = 24, //! < organic ball mother
PARTIORGANIC2 = 25, // organic ball daughter PARTIORGANIC2 = 25, //! < organic ball daughter
PARTISMOKE1 = 26, // black smoke PARTISMOKE1 = 26, //! < black smoke
PARTISMOKE2 = 27, // black smoke PARTISMOKE2 = 27, //! < black smoke
PARTISMOKE3 = 28, // black smoke PARTISMOKE3 = 28, //! < black smoke
PARTISMOKE4 = 29, // black smoke PARTISMOKE4 = 29, //! < black smoke
PARTIBLOOD = 30, // human blood PARTIBLOOD = 30, //! < human blood
PARTIBLOODM = 31, // blood laying PARTIBLOODM = 31, //! < blood laying
PARTIVAPOR = 32, // steam PARTIVAPOR = 32, //! < steam
PARTIVIRUS1 = 33, // virus 1 PARTIVIRUS1 = 33, //! < virus 1
PARTIVIRUS2 = 34, // virus 2 PARTIVIRUS2 = 34, //! < virus 2
PARTIVIRUS3 = 35, // virus 3 PARTIVIRUS3 = 35, //! < virus 3
PARTIVIRUS4 = 36, // virus 4 PARTIVIRUS4 = 36, //! < virus 4
PARTIVIRUS5 = 37, // virus 5 PARTIVIRUS5 = 37, //! < virus 5
PARTIVIRUS6 = 38, // virus 6 PARTIVIRUS6 = 38, //! < virus 6
PARTIVIRUS7 = 39, // virus 7 PARTIVIRUS7 = 39, //! < virus 7
PARTIVIRUS8 = 40, // virus 8 PARTIVIRUS8 = 40, //! < virus 8
PARTIVIRUS9 = 41, // virus 9 PARTIVIRUS9 = 41, //! < virus 9
PARTIVIRUS10 = 42, // virus 10 PARTIVIRUS10 = 42, //! < virus 10
PARTIRAY1 = 43, // ray 1 (turn) PARTIRAY1 = 43, //! < ray 1 (turn)
PARTIRAY2 = 44, // ray 2 (electric arc) PARTIRAY2 = 44, //! < ray 2 (electric arc)
PARTIRAY3 = 45, // ray 3 PARTIRAY3 = 45, //! < ray 3
PARTIRAY4 = 46, // ray 4 PARTIRAY4 = 46, //! < ray 4
PARTIFLAME = 47, // flame PARTIFLAME = 47, //! < flame
PARTIBUBBLE = 48, // bubble PARTIBUBBLE = 48, //! < bubble
PARTIFLIC = 49, // circles in the water PARTIFLIC = 49, //! < circles in the water
PARTIEJECT = 50, // ejection from the reactor PARTIEJECT = 50, //! < ejection from the reactor
PARTISCRAPS = 51, // waste from the reactor PARTISCRAPS = 51, //! < waste from the reactor
PARTITOTO = 52, // reactor of tot PARTITOTO = 52, //! < reactor of tot
PARTIERROR = 53, // toto says no PARTIERROR = 53, //! < toto says no
PARTIWARNING = 54, // foo says blah PARTIWARNING = 54, //! < foo says blah
PARTIINFO = 54, // toto says yes PARTIINFO = 54, //! < toto says yes
PARTIQUARTZ = 55, // reflection crystal PARTIQUARTZ = 55, //! < reflection crystal
PARTISPHERE0 = 56, // explosion sphere PARTISPHERE0 = 56, //! < explosion sphere
PARTISPHERE1 = 57, // energy sphere PARTISPHERE1 = 57, //! < energy sphere
PARTISPHERE2 = 58, // analysis sphere PARTISPHERE2 = 58, //! < analysis sphere
PARTISPHERE3 = 59, // shield sphere PARTISPHERE3 = 59, //! < shield sphere
PARTISPHERE4 = 60, // information sphere (emit) PARTISPHERE4 = 60, //! < information sphere (emit)
PARTISPHERE5 = 61, // botanical sphere (gravity root) PARTISPHERE5 = 61, //! < botanical sphere (gravity root)
PARTISPHERE6 = 62, // information sphere (receive) PARTISPHERE6 = 62, //! < information sphere (receive)
PARTISPHERE7 = 63, // sphere PARTISPHERE7 = 63, //! < sphere
PARTISPHERE8 = 64, // sphere PARTISPHERE8 = 64, //! < sphere
PARTISPHERE9 = 65, // sphere PARTISPHERE9 = 65, //! < sphere
PARTIGUNDEL = 66, // bullet destroyed by shield PARTIGUNDEL = 66, //! < bullet destroyed by shield
PARTIPART = 67, // object part PARTIPART = 67, //! < object part
PARTITRACK1 = 68, // drag 1 PARTITRACK1 = 68, //! < drag 1
PARTITRACK2 = 69, // drag 2 PARTITRACK2 = 69, //! < drag 2
PARTITRACK3 = 70, // drag 3 PARTITRACK3 = 70, //! < drag 3
PARTITRACK4 = 71, // drag 4 PARTITRACK4 = 71, //! < drag 4
PARTITRACK5 = 72, // drag 5 PARTITRACK5 = 72, //! < drag 5
PARTITRACK6 = 73, // drag 6 PARTITRACK6 = 73, //! < drag 6
PARTITRACK7 = 74, // drag 7 PARTITRACK7 = 74, //! < drag 7
PARTITRACK8 = 75, // drag 8 PARTITRACK8 = 75, //! < drag 8
PARTITRACK9 = 76, // drag 9 PARTITRACK9 = 76, //! < drag 9
PARTITRACK10 = 77, // drag 10 PARTITRACK10 = 77, //! < drag 10
PARTITRACK11 = 78, // drag 11 PARTITRACK11 = 78, //! < drag 11
PARTITRACK12 = 79, // drag 12 PARTITRACK12 = 79, //! < drag 12
PARTITRACK13 = 80, // drag 13 PARTITRACK13 = 80, //! < drag 13
PARTITRACK14 = 81, // drag 14 PARTITRACK14 = 81, //! < drag 14
PARTITRACK15 = 82, // drag 15 PARTITRACK15 = 82, //! < drag 15
PARTITRACK16 = 83, // drag 16 PARTITRACK16 = 83, //! < drag 16
PARTITRACK17 = 84, // drag 17 PARTITRACK17 = 84, //! < drag 17
PARTITRACK18 = 85, // drag 18 PARTITRACK18 = 85, //! < drag 18
PARTITRACK19 = 86, // drag 19 PARTITRACK19 = 86, //! < drag 19
PARTITRACK20 = 87, // drag 20 PARTITRACK20 = 87, //! < drag 20
PARTIGLINTb = 88, // blue reflection PARTIGLINTb = 88, //! < blue reflection
PARTIGLINTr = 89, // red reflection PARTIGLINTr = 89, //! < red reflection
PARTILENS1 = 90, // brilliance 1 (orange) PARTILENS1 = 90, //! < brilliance 1 (orange)
PARTILENS2 = 91, // brilliance 2 (yellow) PARTILENS2 = 91, //! < brilliance 2 (yellow)
PARTILENS3 = 92, // brilliance 3 (red) PARTILENS3 = 92, //! < brilliance 3 (red)
PARTILENS4 = 93, // brilliance 4 (violet) PARTILENS4 = 93, //! < brilliance 4 (violet)
PARTICONTROL = 94, // reflection on button PARTICONTROL = 94, //! < reflection on button
PARTISHOW = 95, // shows a place PARTISHOW = 95, //! < shows a place
PARTICHOC = 96, // shock wave PARTICHOC = 96, //! < shock wave
PARTIGFLAT = 97, // shows if the ground is flat PARTIGFLAT = 97, //! < shows if the ground is flat
PARTIRECOVER = 98, // blue ball recycler PARTIRECOVER = 98, //! < blue ball recycler
PARTIROOT = 100, // gravity root smoke PARTIROOT = 100, //! < gravity root smoke
PARTIPLOUF0 = 101, // splash PARTIPLOUF0 = 101, //! < splash
PARTIPLOUF1 = 102, // splash PARTIPLOUF1 = 102, //! < splash
PARTIPLOUF2 = 103, // splash PARTIPLOUF2 = 103, //! < splash
PARTIPLOUF3 = 104, // splash PARTIPLOUF3 = 104, //! < splash
PARTIPLOUF4 = 105, // splash PARTIPLOUF4 = 105, //! < splash
PARTIDROP = 106, // drop PARTIDROP = 106, //! < drop
PARTIFOG0 = 107, // fog 0 PARTIFOG0 = 107, //! < fog 0
PARTIFOG1 = 108, // fog 1 PARTIFOG1 = 108, //! < fog 1
PARTIFOG2 = 109, // fog 2 PARTIFOG2 = 109, //! < fog 2
PARTIFOG3 = 110, // fog 3 PARTIFOG3 = 110, //! < fog 3
PARTIFOG4 = 111, // fog 4 PARTIFOG4 = 111, //! < fog 4
PARTIFOG5 = 112, // fog 5 PARTIFOG5 = 112, //! < fog 5
PARTIFOG6 = 113, // fog 6 PARTIFOG6 = 113, //! < fog 6
PARTIFOG7 = 114, // fog 7 PARTIFOG7 = 114, //! < fog 7
PARTIFOG8 = 115, // fog 8 PARTIFOG8 = 115, //! < fog 8
PARTIFOG9 = 116, // fog 9 PARTIFOG9 = 116, //! < fog 9
PARTILIMIT1 = 117, // shows the limits 1 PARTILIMIT1 = 117, //! < shows the limits 1
PARTILIMIT2 = 118, // shows the limits 2 PARTILIMIT2 = 118, //! < shows the limits 2
PARTILIMIT3 = 119, // shows the limits 3 PARTILIMIT3 = 119, //! < shows the limits 3
PARTILIMIT4 = 120, // shows the limits 4 PARTILIMIT4 = 120, //! < shows the limits 4
PARTIWATER = 121, // drop of water PARTIWATER = 121, //! < drop of water
PARTIEXPLOG1 = 122, // ball explosion 1 PARTIEXPLOG1 = 122, //! < ball explosion 1
PARTIEXPLOG2 = 123, // ball explosion 2 PARTIEXPLOG2 = 123, //! < ball explosion 2
PARTIBASE = 124, // gases of spaceship PARTIBASE = 124, //! < gases of spaceship
PARTITRACE0 = 140, // trace PARTITRACE0 = 140, //! < trace
PARTITRACE1 = 141, // trace PARTITRACE1 = 141, //! < trace
PARTITRACE2 = 142, // trace PARTITRACE2 = 142, //! < trace
PARTITRACE3 = 143, // trace PARTITRACE3 = 143, //! < trace
PARTITRACE4 = 144, // trace PARTITRACE4 = 144, //! < trace
PARTITRACE5 = 145, // trace PARTITRACE5 = 145, //! < trace
PARTITRACE6 = 146, // trace PARTITRACE6 = 146, //! < trace
PARTITRACE7 = 147, // trace PARTITRACE7 = 147, //! < trace
PARTITRACE8 = 148, // trace PARTITRACE8 = 148, //! < trace
PARTITRACE9 = 149, // trace PARTITRACE9 = 149, //! < trace
PARTITRACE10 = 150, // trace PARTITRACE10 = 150, //! < trace
PARTITRACE11 = 151, // trace PARTITRACE11 = 151, //! < trace
PARTITRACE12 = 152, // trace PARTITRACE12 = 152, //! < trace
PARTITRACE13 = 153, // trace PARTITRACE13 = 153, //! < trace
PARTITRACE14 = 154, // trace PARTITRACE14 = 154, //! < trace
PARTITRACE15 = 155, // trace PARTITRACE15 = 155, //! < trace
PARTITRACE16 = 156, // trace PARTITRACE16 = 156, //! < trace
PARTITRACE17 = 157, // trace PARTITRACE17 = 157, //! < trace
PARTITRACE18 = 158, // trace PARTITRACE18 = 158, //! < trace
PARTITRACE19 = 159, // trace PARTITRACE19 = 159, //! < trace
}; };
enum ParticlePhase enum ParticlePhase
@ -262,7 +262,7 @@ struct WheelTrace
* \class CParticle * \class CParticle
* \brief Particle engine * \brief Particle engine
* *
* Functions are only stubs for now. * TODO: documentation
*/ */
class CParticle class CParticle
{ {
@ -270,28 +270,49 @@ public:
CParticle(CInstanceManager* iMan, CEngine* engine); CParticle(CInstanceManager* iMan, CEngine* engine);
~CParticle(); ~CParticle();
//! Sets the device to use
void SetDevice(CDevice* device); void SetDevice(CDevice* device);
//! Removes all particles
void FlushParticle(); void FlushParticle();
//! Removes all particles of a sheet
void FlushParticle(int sheet); void FlushParticle(int sheet);
//! Creates a new particle
int CreateParticle(Math::Vector pos, Math::Vector speed, Math::Point dim, int CreateParticle(Math::Vector pos, Math::Vector speed, Math::Point dim,
ParticleType type, float duration=1.0f, float mass=0.0f, ParticleType type, float duration = 1.0f, float mass = 0.0f,
float windSensitivity=1.0f, int sheet=0); float windSensitivity = 1.0f, int sheet = 0);
int CreateFrag(Math::Vector pos, Math::Vector speed, EngineTriangle *triangle,
ParticleType type, float duration=1.0f, float mass=0.0f, //! Creates a new triangular particle (debris)
float windSensitivity=1.0f, int sheet=0); int CreateFrag(Math::Vector pos, Math::Vector speed, EngineTriangle* triangle,
ParticleType type, float duration = 1.0f, float mass = 0.0f,
float windSensitivity = 1.0f, int sheet = 0);
//! Creates a new particle being a part of object
int CreatePart(Math::Vector pos, Math::Vector speed, ParticleType type, int CreatePart(Math::Vector pos, Math::Vector speed, ParticleType type,
float duration=1.0f, float mass=0.0f, float weight=0.0f, float duration = 1.0f, float mass = 0.0f, float weight = 0.0f,
float windSensitivity=1.0f, int sheet=0); float windSensitivity = 1.0f, int sheet = 0);
//! Creates a new linear particle (radius)
int CreateRay(Math::Vector pos, Math::Vector goal, ParticleType type, Math::Point dim, int CreateRay(Math::Vector pos, Math::Vector goal, ParticleType type, Math::Point dim,
float duration=1.0f, int sheet=0); float duration = 1.0f, int sheet = 0);
//! Creates a particle with a trail
int CreateTrack(Math::Vector pos, Math::Vector speed, Math::Point dim, ParticleType type, int CreateTrack(Math::Vector pos, Math::Vector speed, Math::Point dim, ParticleType type,
float duration=1.0f, float mass=0.0f, float length=10.0f, float width=1.0f); float duration = 1.0f, float mass = 0.0f, float length = 10.0f, float width = 1.0f);
//! Creates a tire mark
void CreateWheelTrace(const Math::Vector &p1, const Math::Vector &p2, const Math::Vector &p3, void CreateWheelTrace(const Math::Vector &p1, const Math::Vector &p2, const Math::Vector &p3,
const Math::Vector &p4, ParticleType type); const Math::Vector &p4, ParticleType type);
//! Removes all particles of a given type
void DeleteParticle(ParticleType type); void DeleteParticle(ParticleType type);
//! Removes all particles of a given channel
void DeleteParticle(int channel); void DeleteParticle(int channel);
//! Specifies the object to which the particle is bound
void SetObjectLink(int channel, CObject *object); void SetObjectLink(int channel, CObject *object);
//! Specifies the parent object that created the particle
void SetObjectFather(int channel, CObject *object); void SetObjectFather(int channel, CObject *object);
void SetPosition(int channel, Math::Vector pos); void SetPosition(int channel, Math::Vector pos);
void SetDimension(int channel, Math::Point dim); void SetDimension(int channel, Math::Point dim);
@ -300,31 +321,53 @@ public:
void SetIntensity(int channel, float intensity); void SetIntensity(int channel, float intensity);
void SetParam(int channel, Math::Vector pos, Math::Point dim, float zoom, float angle, float intensity); void SetParam(int channel, Math::Vector pos, Math::Point dim, float zoom, float angle, float intensity);
void SetPhase(int channel, ParticlePhase phase, float duration); void SetPhase(int channel, ParticlePhase phase, float duration);
//! Returns the position of the particle
bool GetPosition(int channel, Math::Vector &pos); bool GetPosition(int channel, Math::Vector &pos);
Color GetFogColor(Math::Vector pos); //! Returns the color if you're in the fog or black if you're not
Color GetFogColor(Math::Vector pos);
//! Indicates whether a sheet is updated or not
void SetFrameUpdate(int sheet, bool update); void SetFrameUpdate(int sheet, bool update);
//! Updates all the particles.
void FrameParticle(float rTime); void FrameParticle(float rTime);
//! Draws all the particles
void DrawParticle(int sheet); void DrawParticle(int sheet);
//! Writes a file containing all the tire tracks
bool WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur); bool WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur);
protected: protected:
//! Removes a particle of given rank
void DeleteRank(int rank); void DeleteRank(int rank);
//! Check a channel number
bool CheckChannel(int &channel); bool CheckChannel(int &channel);
//! Draws a triangular particle
void DrawParticleTriangle(int i); void DrawParticleTriangle(int i);
//! Draw a normal particle
void DrawParticleNorm(int i); void DrawParticleNorm(int i);
//! Draw a particle flat (horizontal)
void DrawParticleFlat(int i); void DrawParticleFlat(int i);
//! Draw a particle to a flat sheet of fog
void DrawParticleFog(int i); void DrawParticleFog(int i);
//! Draw a particle in the form of radius
void DrawParticleRay(int i); void DrawParticleRay(int i);
//! Draws a spherical particle
void DrawParticleSphere(int i); void DrawParticleSphere(int i);
//! Draws a cylindrical particle
void DrawParticleCylinder(int i); void DrawParticleCylinder(int i);
//! Draws a tire mark
void DrawParticleWheel(int i); void DrawParticleWheel(int i);
//! Seeks if an object collided with a bullet
CObject* SearchObjectGun(Math::Vector old, Math::Vector pos, ParticleType type, CObject *father); CObject* SearchObjectGun(Math::Vector old, Math::Vector pos, ParticleType type, CObject *father);
//! Seeks if an object collided with a ray
CObject* SearchObjectRay(Math::Vector pos, Math::Vector goal, ParticleType type, CObject *father); CObject* SearchObjectRay(Math::Vector pos, Math::Vector goal, ParticleType type, CObject *father);
//! Sounded one
void Play(Sound sound, Math::Vector pos, float amplitude); void Play(Sound sound, Math::Vector pos, float amplitude);
//! Moves a drag; returns true if the drag is finished
bool TrackMove(int i, Math::Vector pos, float progress); bool TrackMove(int i, Math::Vector pos, float progress);
//! Draws a drag
void TrackDraw(int i, ParticleType type); void TrackDraw(int i, ParticleType type);
protected: protected:
@ -336,12 +379,12 @@ protected:
CRobotMain* m_main; CRobotMain* m_main;
CSoundInterface* m_sound; CSoundInterface* m_sound;
Particle m_particule[MAXPARTICULE*MAXPARTITYPE]; Particle m_particle[MAXPARTICULE*MAXPARTITYPE];
EngineTriangle m_triangle[MAXPARTICULE]; // triangle if PartiType == 0 EngineTriangle m_triangle[MAXPARTICULE]; // triangle if PartiType == 0
Track m_track[MAXTRACK]; Track m_track[MAXTRACK];
int m_wheelTraceTotal; int m_wheelTraceTotal;
int m_wheelTraceIndex; int m_wheelTraceIndex;
WheelTrace m_wheelTrace[MAXWHEELTRACE]; WheelTrace m_wheelTrace[MAXWHEELTRACE];
int m_totalInterface[MAXPARTITYPE][SH_MAX]; int m_totalInterface[MAXPARTITYPE][SH_MAX];
bool m_frameUpdate[SH_MAX]; bool m_frameUpdate[SH_MAX];
int m_fogTotal; int m_fogTotal;

File diff suppressed because it is too large Load Diff

View File

@ -33,10 +33,13 @@
class CInstanceManager; class CInstanceManager;
class CObject; class CObject;
class CDisplayText;
class CRobotMain; class CRobotMain;
class CSoundInterface; class CSoundInterface;
namespace Ui {
class CDisplayText;
}
// Graphics module namespace // Graphics module namespace
namespace Gfx { namespace Gfx {
@ -48,33 +51,37 @@ class CParticle;
class CLight; class CLight;
/**
* \enum PyroType
* \brief Type of pyro effect
*/
enum PyroType enum PyroType
{ {
PT_NULL = 0, PT_NULL = 0,
PT_FRAGT = 1, // fragmentation of technical object PT_FRAGT = 1, //! < fragmentation of technical object
PT_FRAGO = 2, // fragmentation of organic object PT_FRAGO = 2, //! < fragmentation of organic object
PT_FRAGW = 4, // fragmentation of object under water PT_FRAGW = 4, //! < fragmentation of object under water
PT_EXPLOT = 5, // explosion of technical object PT_EXPLOT = 5, //! < explosion of technical object
PT_EXPLOO = 6, // explosion of organic object PT_EXPLOO = 6, //! < explosion of organic object
PT_EXPLOW = 8, // explosion of object under water PT_EXPLOW = 8, //! < explosion of object under water
PT_SHOTT = 9, // hit technical object PT_SHOTT = 9, //! < hit technical object
PT_SHOTH = 10, // hit human PT_SHOTH = 10, //! < hit human
PT_SHOTM = 11, // hit queen PT_SHOTM = 11, //! < hit queen
PT_SHOTW = 12, // hit under water PT_SHOTW = 12, //! < hit under water
PT_EGG = 13, // break the egg PT_EGG = 13, //! < break the egg
PT_BURNT = 14, // burning of technical object PT_BURNT = 14, //! < burning of technical object
PT_BURNO = 15, // burning of organic object PT_BURNO = 15, //! < burning of organic object
PT_SPIDER = 16, // spider explosion PT_SPIDER = 16, //! < spider explosion
PT_FALL = 17, // cargo falling PT_FALL = 17, //! < cargo falling
PT_WPCHECK = 18, // indicator reaches PT_WPCHECK = 18, //! < indicator reaches
PT_FLCREATE = 19, // flag create PT_FLCREATE = 19, //! < flag create
PT_FLDELETE = 20, // flag destroy PT_FLDELETE = 20, //! < flag destroy
PT_RESET = 21, // reset position of the object PT_RESET = 21, //! < reset position of the object
PT_WIN = 22, // fireworks PT_WIN = 22, //! < fireworks
PT_LOST = 23, // black smoke PT_LOST = 23, //! < black smoke
PT_DEADG = 24, // shooting death PT_DEADG = 24, //! < shooting death
PT_DEADW = 25, // drowning death PT_DEADW = 25, //! < drowning death
PT_FINDING = 26, // object discovered PT_FINDING = 26, //! < object discovered
}; };
@ -89,8 +96,8 @@ struct PyroBurnPart
struct PyroLightOper struct PyroLightOper
{ {
float progress; float progress;
float intensity; float intensity;
Color color; Color color;
}; };
@ -99,7 +106,7 @@ struct PyroLightOper
* \class CPyro * \class CPyro
* \brief Fire effect renderer * \brief Fire effect renderer
* *
* Functions are only stubs for now. * TODO: documentation
*/ */
class CPyro class CPyro
{ {
@ -107,70 +114,98 @@ public:
CPyro(CInstanceManager* iMan); CPyro(CInstanceManager* iMan);
~CPyro(); ~CPyro();
void DeleteObject(bool all=false); //! Creates pyrotechnic effect
bool Create(PyroType type, CObject* pObj, float force=1.0f); bool Create(PyroType type, CObject* obj, float force=1.0f);
bool EventProcess(const Event &event); //! Destroys the object
void DeleteObject();
//! Indicates whether the pyrotechnic effect is complete
Error IsEnded(); Error IsEnded();
void CutObjectLink(CObject* pObj);
//! Indicates that the object binds to the effect no longer exists, without deleting it
void CutObjectLink(CObject* obj);
//! Management of an event
bool EventProcess(const Event& event);
protected: protected:
void DisplayError(PyroType type, CObject* pObj); //! Displays the error or eventual information
bool CreateLight(Math::Vector pos, float height); //! Information can be linked to the destruction of an insect, a vehicle or building
void DisplayError(PyroType type, CObject* obj);
//! Creates light to accompany a pyrotechnic effect
void CreateLight(Math::Vector pos, float height);
//! Removes the binding to a pyrotechnic effect
void DeleteObject(bool primary, bool secondary); void DeleteObject(bool primary, bool secondary);
void CreateTriangle(CObject* pObj, ObjectType oType, int part); //! Creates an explosion with triangular form of particles
void CreateTriangle(CObject* obj, ObjectType type, int part);
//! Starts the explosion of a vehicle
void ExploStart(); void ExploStart();
//! Ends the explosion of a vehicle
void ExploTerminate(); void ExploTerminate();
//! Starts a vehicle fire
void BurnStart(); void BurnStart();
//! Adds a part move
void BurnAddPart(int part, Math::Vector pos, Math::Vector angle); void BurnAddPart(int part, Math::Vector pos, Math::Vector angle);
//! Advances of a vehicle fire
void BurnProgress(); void BurnProgress();
//! Indicates whether a part should be retained
bool BurnIsKeepPart(int part); bool BurnIsKeepPart(int part);
//! Ends the fire of an insect or a vehicle
void BurnTerminate(); void BurnTerminate();
//! Start of an object freight falling
void FallStart(); void FallStart();
//! Seeks an object to explode by the falling ball of bees
CObject* FallSearchBeeExplo(); CObject* FallSearchBeeExplo();
//! Fall of an object's freight
void FallProgress(float rTime); void FallProgress(float rTime);
//! Indicates whether the fall is over
Error FallIsEnded(); Error FallIsEnded();
//! Empty the table of operations of animation of light
void LightOperFlush(); void LightOperFlush();
//! Adds an animation operation of the light
void LightOperAdd(float progress, float intensity, float r, float g, float b); void LightOperAdd(float progress, float intensity, float r, float g, float b);
//! Updates the associated light
void LightOperFrame(float rTime); void LightOperFrame(float rTime);
protected: protected:
CInstanceManager* m_iMan; CInstanceManager* m_iMan;
CEngine* m_engine; CEngine* m_engine;
CTerrain* m_terrain; CTerrain* m_terrain;
CCamera* m_camera; CCamera* m_camera;
CParticle* m_particule; CParticle* m_particle;
CLightManager* m_lightMan; CLightManager* m_lightMan;
CObject* m_object; CObject* m_object;
CDisplayText* m_displayText; Ui::CDisplayText* m_displayText;
CRobotMain* m_main; CRobotMain* m_main;
CSoundInterface* m_sound; CSoundInterface* m_sound;
Math::Vector m_pos; // center of the effect Math::Vector m_pos; // center of the effect
Math::Vector m_posPower; // center of the battery Math::Vector m_posPower; // center of the battery
bool m_power; // battery exists? bool m_power; // battery exists?
PyroType m_type; PyroType m_type;
float m_force; float m_force;
float m_size; float m_size;
float m_progress; float m_progress;
float m_speed; float m_speed;
float m_time; float m_time;
float m_lastParticule; float m_lastParticle;
float m_lastParticuleSmoke; float m_lastParticleSmoke;
int m_soundChannel; int m_soundChannel;
int m_lightRank; int m_lightRank;
int m_lightOperTotal; int m_lightOperTotal;
PyroLightOper m_lightOper[10]; PyroLightOper m_lightOper[10];
float m_lightHeight; float m_lightHeight;
ObjectType m_burnType; ObjectType m_burnType;
int m_burnPartTotal; int m_burnPartTotal;
PyroBurnPart m_burnPart[10]; PyroBurnPart m_burnPart[10];
int m_burnKeepPart[10]; int m_burnKeepPart[10];
float m_burnFall; float m_burnFall;

View File

@ -309,7 +309,7 @@ void CGLDevice::SetLight(int index, const Light &light)
if (light.type == LIGHT_SPOT) if (light.type == LIGHT_SPOT)
{ {
glLightf(GL_LIGHT0 + index, GL_SPOT_CUTOFF, light.spotAngle); glLightf(GL_LIGHT0 + index, GL_SPOT_CUTOFF, light.spotAngle * Math::RAD_TO_DEG);
glLightf(GL_LIGHT0 + index, GL_SPOT_EXPONENT, light.spotIntensity); glLightf(GL_LIGHT0 + index, GL_SPOT_EXPONENT, light.spotIntensity);
} }
else else

View File

@ -203,8 +203,8 @@ bool CBrain::EventProcess(const Event &event)
action = EVENT_NULL; action = EVENT_NULL;
if ( event.type == EVENT_KEY_DOWN && if ( event.type == EVENT_KEY_DOWN &&
(event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).key || (event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).primary ||
event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).joy ) && event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).secondary ) &&
!m_main->GetEditLock() ) !m_main->GetEditLock() )
{ {
pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));

View File

@ -2264,7 +2264,7 @@ bool CObject::CreateShadowLight(float height, Gfx::Color color)
light.attenuation0 = 1.0f; light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f; light.attenuation1 = 0.0f;
light.attenuation2 = 0.0f; light.attenuation2 = 0.0f;
light.spotAngle = 90; light.spotAngle = 90.0f*Math::PI/180.0f;
m_shadowLight = m_lightMan->CreateLight(); m_shadowLight = m_lightMan->CreateLight();
if ( m_shadowLight == -1 ) return false; if ( m_shadowLight == -1 ) return false;
@ -2307,7 +2307,7 @@ bool CObject::CreateEffectLight(float height, Gfx::Color color)
light.attenuation0 = 1.0f; light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f; light.attenuation1 = 0.0f;
light.attenuation2 = 0.0f; light.attenuation2 = 0.0f;
light.spotAngle = 90; light.spotAngle = 90.0f*Math::PI/180.0f;
m_effectLight = m_lightMan->CreateLight(); m_effectLight = m_lightMan->CreateLight();
if ( m_effectLight == -1 ) return false; if ( m_effectLight == -1 ) return false;
@ -2995,7 +2995,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_character.posPower = Math::Vector(5.0f, 3.0f, 0.0f); m_character.posPower = Math::Vector(5.0f, 3.0f, 0.0f);
CreateShadowCircle(6.0f, 1.0f); CreateShadowCircle(6.0f, 1.0f);
m_showLimitRadius = Gfx::BLITZPARA; m_showLimitRadius = Gfx::LTNG_PROTECTION_RADIUS;
} }
if ( m_type == OBJECT_NUCLEAR ) if ( m_type == OBJECT_NUCLEAR )
@ -3048,7 +3048,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 20.0f); SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 20.0f);
CreateShadowCircle(21.0f, 1.0f); CreateShadowCircle(21.0f, 1.0f);
m_showLimitRadius = Gfx::BLITZPARA; m_showLimitRadius = Gfx::LTNG_PROTECTION_RADIUS;
} }
if ( m_type == OBJECT_SAFE ) if ( m_type == OBJECT_SAFE )

View File

@ -730,7 +730,7 @@ CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app)
g_build = 0; g_build = 0;
g_researchDone = 0; // no research done g_researchDone = 0; // no research done
g_researchEnable = 0; g_researchEnable = 0;
g_unit = 4.0f; g_unit = UNIT;
m_gamerName[0] = 0; m_gamerName[0] = 0;
/* TODO: profile /* TODO: profile
@ -878,7 +878,7 @@ void CRobotMain::SetDefaultInputBindings()
{ {
for (int i = 0; i < INPUT_SLOT_MAX; i++) for (int i = 0; i < INPUT_SLOT_MAX; i++)
{ {
m_inputBindings[i].key = m_inputBindings[i].joy = KEY_INVALID; m_inputBindings[i].primary = m_inputBindings[i].secondary = KEY_INVALID;
} }
for (int i = 0; i < JOY_AXIS_SLOT_MAX; i++) for (int i = 0; i < JOY_AXIS_SLOT_MAX; i++)
@ -887,34 +887,34 @@ void CRobotMain::SetDefaultInputBindings()
m_joyAxisBindings[i].invert = false; m_joyAxisBindings[i].invert = false;
} }
m_inputBindings[INPUT_SLOT_LEFT ].key = KEY(LEFT); m_inputBindings[INPUT_SLOT_LEFT ].primary = KEY(LEFT);
m_inputBindings[INPUT_SLOT_RIGHT ].key = KEY(RIGHT); m_inputBindings[INPUT_SLOT_RIGHT ].primary = KEY(RIGHT);
m_inputBindings[INPUT_SLOT_UP ].key = KEY(UP); m_inputBindings[INPUT_SLOT_UP ].primary = KEY(UP);
m_inputBindings[INPUT_SLOT_DOWN ].key = KEY(DOWN); m_inputBindings[INPUT_SLOT_DOWN ].primary = KEY(DOWN);
m_inputBindings[INPUT_SLOT_GUP ].key = VIRTUAL_KMOD(SHIFT); m_inputBindings[INPUT_SLOT_GUP ].primary = VIRTUAL_KMOD(SHIFT);
m_inputBindings[INPUT_SLOT_GDOWN ].key = VIRTUAL_KMOD(CTRL); m_inputBindings[INPUT_SLOT_GDOWN ].primary = VIRTUAL_KMOD(CTRL);
m_inputBindings[INPUT_SLOT_CAMERA ].key = KEY(SPACE); m_inputBindings[INPUT_SLOT_CAMERA ].primary = KEY(SPACE);
m_inputBindings[INPUT_SLOT_CAMERA ].joy = VIRTUAL_JOY(2); m_inputBindings[INPUT_SLOT_CAMERA ].secondary = VIRTUAL_JOY(2);
m_inputBindings[INPUT_SLOT_DESEL ].key = KEY(KP0); m_inputBindings[INPUT_SLOT_DESEL ].primary = KEY(KP0);
m_inputBindings[INPUT_SLOT_DESEL ].joy = VIRTUAL_JOY(6); m_inputBindings[INPUT_SLOT_DESEL ].secondary = VIRTUAL_JOY(6);
m_inputBindings[INPUT_SLOT_ACTION ].key = KEY(RETURN); m_inputBindings[INPUT_SLOT_ACTION ].primary = KEY(RETURN);
m_inputBindings[INPUT_SLOT_ACTION ].joy = VIRTUAL_JOY(1); m_inputBindings[INPUT_SLOT_ACTION ].secondary = VIRTUAL_JOY(1);
m_inputBindings[INPUT_SLOT_NEAR ].key = KEY(KP_PLUS); m_inputBindings[INPUT_SLOT_NEAR ].primary = KEY(KP_PLUS);
m_inputBindings[INPUT_SLOT_NEAR ].joy = VIRTUAL_JOY(5); m_inputBindings[INPUT_SLOT_NEAR ].secondary = VIRTUAL_JOY(5);
m_inputBindings[INPUT_SLOT_AWAY ].key = KEY(KP_MINUS); m_inputBindings[INPUT_SLOT_AWAY ].primary = KEY(KP_MINUS);
m_inputBindings[INPUT_SLOT_AWAY ].joy = VIRTUAL_JOY(4); m_inputBindings[INPUT_SLOT_AWAY ].secondary = VIRTUAL_JOY(4);
m_inputBindings[INPUT_SLOT_NEXT ].key = KEY(TAB); m_inputBindings[INPUT_SLOT_NEXT ].primary = KEY(TAB);
m_inputBindings[INPUT_SLOT_NEXT ].joy = VIRTUAL_JOY(3); m_inputBindings[INPUT_SLOT_NEXT ].secondary = VIRTUAL_JOY(3);
m_inputBindings[INPUT_SLOT_HUMAN ].key = KEY(HOME); m_inputBindings[INPUT_SLOT_HUMAN ].primary = KEY(HOME);
m_inputBindings[INPUT_SLOT_HUMAN ].joy = VIRTUAL_JOY(7); m_inputBindings[INPUT_SLOT_HUMAN ].secondary = VIRTUAL_JOY(7);
m_inputBindings[INPUT_SLOT_QUIT ].key = KEY(ESCAPE); m_inputBindings[INPUT_SLOT_QUIT ].primary = KEY(ESCAPE);
m_inputBindings[INPUT_SLOT_HELP ].key = KEY(F1); m_inputBindings[INPUT_SLOT_HELP ].primary = KEY(F1);
m_inputBindings[INPUT_SLOT_PROG ].key = KEY(F2); m_inputBindings[INPUT_SLOT_PROG ].primary = KEY(F2);
m_inputBindings[INPUT_SLOT_CBOT ].key = KEY(F3); m_inputBindings[INPUT_SLOT_CBOT ].primary = KEY(F3);
m_inputBindings[INPUT_SLOT_VISIT ].key = KEY(KP_PERIOD); m_inputBindings[INPUT_SLOT_VISIT ].primary = KEY(KP_PERIOD);
m_inputBindings[INPUT_SLOT_SPEED10].key = KEY(F4); m_inputBindings[INPUT_SLOT_SPEED10].primary = KEY(F4);
m_inputBindings[INPUT_SLOT_SPEED15].key = KEY(F5); m_inputBindings[INPUT_SLOT_SPEED15].primary = KEY(F5);
m_inputBindings[INPUT_SLOT_SPEED20].key = KEY(F6); m_inputBindings[INPUT_SLOT_SPEED20].primary = KEY(F6);
m_joyAxisBindings[JOY_AXIS_SLOT_X].axis = 0; m_joyAxisBindings[JOY_AXIS_SLOT_X].axis = 0;
m_joyAxisBindings[JOY_AXIS_SLOT_Y].axis = 1; m_joyAxisBindings[JOY_AXIS_SLOT_Y].axis = 1;
@ -1214,33 +1214,33 @@ bool CRobotMain::EventProcess(Event &event)
if (event.type == EVENT_KEY_DOWN) if (event.type == EVENT_KEY_DOWN)
{ {
if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).key) m_keyMotion.y = 1.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).primary) m_keyMotion.y = 1.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).joy) m_keyMotion.y = 1.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).secondary) m_keyMotion.y = 1.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).key) m_keyMotion.y = -1.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).primary) m_keyMotion.y = -1.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).joy) m_keyMotion.y = -1.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).secondary) m_keyMotion.y = -1.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).key) m_keyMotion.x = -1.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).primary) m_keyMotion.x = -1.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).joy) m_keyMotion.x = -1.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).secondary) m_keyMotion.x = -1.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).key) m_keyMotion.x = 1.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).primary) m_keyMotion.x = 1.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).joy) m_keyMotion.x = 1.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).secondary) m_keyMotion.x = 1.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).key) m_keyMotion.z = 1.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).primary) m_keyMotion.z = 1.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).joy) m_keyMotion.z = 1.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).secondary) m_keyMotion.z = 1.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).key) m_keyMotion.z = -1.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).primary) m_keyMotion.z = -1.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).joy) m_keyMotion.z = -1.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).secondary) m_keyMotion.z = -1.0f;
} }
else if (event.type == EVENT_KEY_UP) else if (event.type == EVENT_KEY_UP)
{ {
if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).key) m_keyMotion.y = 0.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).primary) m_keyMotion.y = 0.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).joy) m_keyMotion.y = 0.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).secondary) m_keyMotion.y = 0.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).key) m_keyMotion.y = 0.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).primary) m_keyMotion.y = 0.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).joy) m_keyMotion.y = 0.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).secondary) m_keyMotion.y = 0.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).key) m_keyMotion.x = 0.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).primary) m_keyMotion.x = 0.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).joy) m_keyMotion.x = 0.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).secondary) m_keyMotion.x = 0.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).key) m_keyMotion.x = 0.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).primary) m_keyMotion.x = 0.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).joy) m_keyMotion.x = 0.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).secondary) m_keyMotion.x = 0.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).key) m_keyMotion.z = 0.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).primary) m_keyMotion.z = 0.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).joy) m_keyMotion.z = 0.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).secondary) m_keyMotion.z = 0.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).key) m_keyMotion.z = 0.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).primary) m_keyMotion.z = 0.0f;
if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).joy) m_keyMotion.z = 0.0f; if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).secondary) m_keyMotion.z = 0.0f;
} }
else if (event.type == EVENT_JOY_AXIS) else if (event.type == EVENT_JOY_AXIS)
{ {
@ -1356,10 +1356,10 @@ bool CRobotMain::EventProcess(Event &event)
if (event.type == EVENT_KEY_DOWN) if (event.type == EVENT_KEY_DOWN)
{ {
if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key || if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy || event.key.key == GetInputBinding(INPUT_SLOT_HELP).secondary ||
event.key.key == GetInputBinding(INPUT_SLOT_PROG).key || event.key.key == GetInputBinding(INPUT_SLOT_PROG).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy || event.key.key == GetInputBinding(INPUT_SLOT_PROG).secondary ||
event.key.key == KEY(ESCAPE)) event.key.key == KEY(ESCAPE))
{ {
StopDisplayInfo(); StopDisplayInfo();
@ -1394,14 +1394,14 @@ bool CRobotMain::EventProcess(Event &event)
} }
if (m_editLock) // current edition? if (m_editLock) // current edition?
{ {
if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key || if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy) event.key.key == GetInputBinding(INPUT_SLOT_HELP).secondary)
{ {
StartDisplayInfo(SATCOM_HUSTON, false); StartDisplayInfo(SATCOM_HUSTON, false);
return false; return false;
} }
if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).key || if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy) event.key.key == GetInputBinding(INPUT_SLOT_PROG).secondary)
{ {
StartDisplayInfo(SATCOM_PROG, false); StartDisplayInfo(SATCOM_PROG, false);
return false; return false;
@ -1410,8 +1410,8 @@ bool CRobotMain::EventProcess(Event &event)
} }
if (m_movieLock) // current movie? if (m_movieLock) // current movie?
{ {
if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key || if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy || event.key.key == GetInputBinding(INPUT_SLOT_QUIT).secondary ||
event.key.key == KEY(ESCAPE)) event.key.key == KEY(ESCAPE))
{ {
AbortMovie(); AbortMovie();
@ -1420,21 +1420,21 @@ bool CRobotMain::EventProcess(Event &event)
} }
if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT) if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT)
{ {
if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).key || if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_VISIT).joy) event.key.key == GetInputBinding(INPUT_SLOT_VISIT).secondary)
{ {
StartDisplayVisit(EVENT_NULL); StartDisplayVisit(EVENT_NULL);
} }
if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key || if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy || event.key.key == GetInputBinding(INPUT_SLOT_QUIT).secondary ||
event.key.key == KEY(ESCAPE)) event.key.key == KEY(ESCAPE))
{ {
StopDisplayVisit(); StopDisplayVisit();
} }
return false; return false;
} }
if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key || if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy) event.key.key == GetInputBinding(INPUT_SLOT_QUIT).secondary)
{ {
if (m_movie->IsExist()) if (m_movie->IsExist())
StartDisplayInfo(SATCOM_HUSTON, false); StartDisplayInfo(SATCOM_HUSTON, false);
@ -1454,55 +1454,55 @@ bool CRobotMain::EventProcess(Event &event)
ChangePause(!m_engine->GetPause()); ChangePause(!m_engine->GetPause());
} }
} }
if (event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).key || if (event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).joy) event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).secondary)
{ {
ChangeCamera(); ChangeCamera();
} }
if (event.key.key == GetInputBinding(INPUT_SLOT_DESEL).key || if (event.key.key == GetInputBinding(INPUT_SLOT_DESEL).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_DESEL).joy) event.key.key == GetInputBinding(INPUT_SLOT_DESEL).secondary)
{ {
if (m_shortCut) if (m_shortCut)
DeselectObject(); DeselectObject();
} }
if (event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).key || if (event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).joy) event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).secondary)
{ {
SelectHuman(); SelectHuman();
} }
if (event.key.key == GetInputBinding(INPUT_SLOT_NEXT).key || if (event.key.key == GetInputBinding(INPUT_SLOT_NEXT).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_NEXT).joy) event.key.key == GetInputBinding(INPUT_SLOT_NEXT).secondary)
{ {
if (m_shortCut) if (m_shortCut)
m_short->SelectNext(); m_short->SelectNext();
} }
if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key || if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy) event.key.key == GetInputBinding(INPUT_SLOT_HELP).secondary)
{ {
StartDisplayInfo(SATCOM_HUSTON, true); StartDisplayInfo(SATCOM_HUSTON, true);
} }
if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).key || if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy) event.key.key == GetInputBinding(INPUT_SLOT_PROG).secondary)
{ {
StartDisplayInfo(SATCOM_PROG, true); StartDisplayInfo(SATCOM_PROG, true);
} }
if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).key || if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_VISIT).joy) event.key.key == GetInputBinding(INPUT_SLOT_VISIT).secondary)
{ {
StartDisplayVisit(EVENT_NULL); StartDisplayVisit(EVENT_NULL);
} }
if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).key || if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).joy) event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).secondary)
{ {
SetSpeed(1.0f); SetSpeed(1.0f);
} }
if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).key || if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).joy) event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).secondary)
{ {
SetSpeed(1.5f); SetSpeed(1.5f);
} }
if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).key || if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).joy) event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).secondary)
{ {
SetSpeed(2.0f); SetSpeed(2.0f);
} }
@ -1956,6 +1956,17 @@ void CRobotMain::ExecuteCmd(char *cmd)
return; return;
} }
if (strcmp(cmd, "speed4") == 0) {
SetSpeed(4.0f);
UpdateSpeedLabel();
return;
}
if (strcmp(cmd, "speed8") == 0) {
SetSpeed(8.0f);
UpdateSpeedLabel();
return;
}
if (m_phase == PHASE_SIMUL) if (m_phase == PHASE_SIMUL)
m_displayText->DisplayError(ERR_CMD, Math::Vector(0.0f,0.0f,0.0f)); m_displayText->DisplayError(ERR_CMD, Math::Vector(0.0f,0.0f,0.0f));
} }
@ -3098,26 +3109,26 @@ void CRobotMain::KeyCamera(EventType type, unsigned int key)
if (type == EVENT_KEY_UP) if (type == EVENT_KEY_UP)
{ {
if (key == GetInputBinding(INPUT_SLOT_LEFT).key || if (key == GetInputBinding(INPUT_SLOT_LEFT).primary ||
key == GetInputBinding(INPUT_SLOT_LEFT).joy) key == GetInputBinding(INPUT_SLOT_LEFT).secondary)
{ {
m_cameraPan = 0.0f; m_cameraPan = 0.0f;
} }
if (key == GetInputBinding(INPUT_SLOT_RIGHT).key || if (key == GetInputBinding(INPUT_SLOT_RIGHT).primary ||
key == GetInputBinding(INPUT_SLOT_RIGHT).joy) key == GetInputBinding(INPUT_SLOT_RIGHT).secondary)
{ {
m_cameraPan = 0.0f; m_cameraPan = 0.0f;
} }
if (key == GetInputBinding(INPUT_SLOT_UP).key || if (key == GetInputBinding(INPUT_SLOT_UP).primary ||
key == GetInputBinding(INPUT_SLOT_UP).joy) key == GetInputBinding(INPUT_SLOT_UP).secondary)
{ {
m_cameraZoom = 0.0f; m_cameraZoom = 0.0f;
} }
if (key == GetInputBinding(INPUT_SLOT_DOWN).key || if (key == GetInputBinding(INPUT_SLOT_DOWN).primary ||
key == GetInputBinding(INPUT_SLOT_DOWN).joy) key == GetInputBinding(INPUT_SLOT_DOWN).secondary)
{ {
m_cameraZoom = 0.0f; m_cameraZoom = 0.0f;
} }
@ -3133,26 +3144,26 @@ void CRobotMain::KeyCamera(EventType type, unsigned int key)
if (type == EVENT_KEY_DOWN) if (type == EVENT_KEY_DOWN)
{ {
if (key == GetInputBinding(INPUT_SLOT_LEFT).key || if (key == GetInputBinding(INPUT_SLOT_LEFT).primary ||
key == GetInputBinding(INPUT_SLOT_LEFT).joy) key == GetInputBinding(INPUT_SLOT_LEFT).secondary)
{ {
m_cameraPan = -1.0f; m_cameraPan = -1.0f;
} }
if (key == GetInputBinding(INPUT_SLOT_RIGHT).key || if (key == GetInputBinding(INPUT_SLOT_RIGHT).primary ||
key == GetInputBinding(INPUT_SLOT_RIGHT).joy) key == GetInputBinding(INPUT_SLOT_RIGHT).secondary)
{ {
m_cameraPan = 1.0f; m_cameraPan = 1.0f;
} }
if (key == GetInputBinding(INPUT_SLOT_UP).key || if (key == GetInputBinding(INPUT_SLOT_UP).primary ||
key == GetInputBinding(INPUT_SLOT_UP).joy) key == GetInputBinding(INPUT_SLOT_UP).secondary)
{ {
m_cameraZoom = -1.0f; m_cameraZoom = -1.0f;
} }
if (key == GetInputBinding(INPUT_SLOT_DOWN).key || if (key == GetInputBinding(INPUT_SLOT_DOWN).primary ||
key == GetInputBinding(INPUT_SLOT_DOWN).joy) key == GetInputBinding(INPUT_SLOT_DOWN).secondary)
{ {
m_cameraZoom = 1.0f; m_cameraZoom = 1.0f;
} }
@ -3889,8 +3900,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "DeepView") && !resetObject) if (Cmd(line, "DeepView") && !resetObject)
{ {
m_engine->SetDeepView(OpFloat(line, "air", 500.0f)*UNIT, 0, true); m_engine->SetDeepView(OpFloat(line, "air", 500.0f)*g_unit, 0, true);
m_engine->SetDeepView(OpFloat(line, "water", 100.0f)*UNIT, 1, true); m_engine->SetDeepView(OpFloat(line, "water", 100.0f)*g_unit, 1, true);
} }
if (Cmd(line, "FogStart") && !resetObject) if (Cmd(line, "FogStart") && !resetObject)
@ -3951,7 +3962,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_terrain->Generate(OpInt(line, "mosaic", 20), m_terrain->Generate(OpInt(line, "mosaic", 20),
OpInt(line, "brick", 3), OpInt(line, "brick", 3),
OpFloat(line, "size", 20.0f), OpFloat(line, "size", 20.0f),
OpFloat(line, "vision", 500.0f)*UNIT, OpFloat(line, "vision", 500.0f)*g_unit,
OpInt(line, "depth", 2), OpInt(line, "depth", 2),
OpFloat(line, "hard", 0.5f)); OpFloat(line, "hard", 0.5f));
} }
@ -3983,7 +3994,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
name, name,
OpColor(line, "diffuse", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), OpColor(line, "diffuse", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)),
OpColor(line, "ambient", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), OpColor(line, "ambient", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)),
OpFloat(line, "level", 100.0f)*UNIT, OpFloat(line, "level", 100.0f)*g_unit,
OpFloat(line, "glint", 1.0f), OpFloat(line, "glint", 1.0f),
pos); pos);
m_colorNewWater = OpColor(line, "color", m_colorRefWater); m_colorNewWater = OpColor(line, "color", m_colorRefWater);
@ -3999,14 +4010,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_cloud->Create(name, m_cloud->Create(name,
OpColor(line, "diffuse", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), OpColor(line, "diffuse", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)),
OpColor(line, "ambient", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)), OpColor(line, "ambient", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)),
OpFloat(line, "level", 500.0f) * UNIT); OpFloat(line, "level", 500.0f) * g_unit);
} }
if (Cmd(line, "TerrainBlitz") && !resetObject) if (Cmd(line, "TerrainBlitz") && !resetObject)
{ {
m_lightning->Create(OpFloat(line, "sleep", 0.0f), m_lightning->Create(OpFloat(line, "sleep", 0.0f),
OpFloat(line, "delay", 3.0f), OpFloat(line, "delay", 3.0f),
OpFloat(line, "magnetic", 50.0f) * UNIT); OpFloat(line, "magnetic", 50.0f) * g_unit);
} }
if (Cmd(line, "TerrainInitTextures") && !resetObject) if (Cmd(line, "TerrainInitTextures") && !resetObject)
@ -4059,8 +4070,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
} }
m_terrain->GenerateMaterials(id, m_terrain->GenerateMaterials(id,
OpFloat(line, "min", 0.0f)*UNIT, OpFloat(line, "min", 0.0f)*g_unit,
OpFloat(line, "max", 100.0f)*UNIT, OpFloat(line, "max", 100.0f)*g_unit,
OpFloat(line, "slope", 5.0f), OpFloat(line, "slope", 5.0f),
OpFloat(line, "freq", 100.0f), OpFloat(line, "freq", 100.0f),
OpPos(line, "center")*g_unit, OpPos(line, "center")*g_unit,
@ -6615,9 +6626,20 @@ void CRobotMain::ChangePause(bool pause)
//! Changes game speed //! Changes game speed
void CRobotMain::SetSpeed(float speed) void CRobotMain::SetSpeed(float speed)
{ {
// TODO: m_app->SetSimulationSpeed(speed); m_app->SetSimulationSpeed(speed);
UpdateSpeedLabel();
}
float CRobotMain::GetSpeed()
{
return m_app->GetSimulationSpeed();
}
void CRobotMain::UpdateSpeedLabel()
{
Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_SPEED)); Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_SPEED));
float speed = m_app->GetSimulationSpeed();
if (pb != nullptr) if (pb != nullptr)
{ {
if (speed == 1.0f) if (speed == 1.0f)
@ -6632,11 +6654,7 @@ void CRobotMain::SetSpeed(float speed)
pb->SetState(Ui::STATE_VISIBLE); pb->SetState(Ui::STATE_VISIBLE);
} }
} }
}
float CRobotMain::GetSpeed()
{
return m_app->GetSimulationSpeed();
} }

View File

@ -148,12 +148,12 @@ const int SATCOM_MAX = 6;
*/ */
struct InputBinding struct InputBinding
{ {
//! Keyboard binding code (can be regular or virtual) //! Primary and secondary bindings
unsigned int key; //! Can be regular key, virtual key or virtual joystick button
//! Joystick binding code (virtual) unsigned int primary, secondary;
unsigned int joy;
InputBinding() : key(KEY_INVALID), joy(KEY_INVALID) {} InputBinding(unsigned int p = KEY_INVALID, unsigned int s = KEY_INVALID)
: primary(p), secondary(s) {}
}; };
/** /**
@ -383,6 +383,7 @@ protected:
void StopDisplayVisit(); void StopDisplayVisit();
void ExecuteCmd(char *cmd); void ExecuteCmd(char *cmd);
bool TestGadgetQuantity(int rank); bool TestGadgetQuantity(int rank);
void UpdateSpeedLabel();
protected: protected:
CInstanceManager* m_iMan; CInstanceManager* m_iMan;

View File

@ -153,8 +153,7 @@ void CTaskBuild::CreateLight()
light.attenuation0 = 1.0f; light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f; light.attenuation1 = 0.0f;
light.attenuation2 = 0.0f; light.attenuation2 = 0.0f;
//TODO Is this value correct light.spotAngle = 90.0f*Math::PI/180.0f;
light.spotAngle = 90;
m_lightMan->SetLight(m_lightRank[i], light); m_lightMan->SetLight(m_lightRank[i], light);
color.r = -1.0f; color.r = -1.0f;

View File

@ -499,7 +499,7 @@ bool CTaskShield::CreateLight(Math::Vector pos)
light.attenuation0 = 1.0f; light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f; light.attenuation1 = 0.0f;
light.attenuation2 = 0.0f; light.attenuation2 = 0.0f;
light.spotAngle = 90; light.spotAngle = 90.0f*Math::PI/180.0f;
m_effectLight = m_lightMan->CreateLight(); m_effectLight = m_lightMan->CreateLight();
if ( m_effectLight == -1 ) return false; if ( m_effectLight == -1 ) return false;

View File

@ -19,6 +19,7 @@
#include "script/script.h" #include "script/script.h"
#include "app/app.h"
#include "common/global.h" #include "common/global.h"
#include "common/iman.h" #include "common/iman.h"
#include "common/restext.h" #include "common/restext.h"

View File

@ -1794,7 +1794,7 @@ bool CEdit::ReadText(const char *filename, int addSize)
if ( SearchKey(buffer+i+5, slot) ) if ( SearchKey(buffer+i+5, slot) )
{ {
CRobotMain* main = CRobotMain::GetInstancePointer(); CRobotMain* main = CRobotMain::GetInstancePointer();
res = main->GetInputBinding(slot).key; res = main->GetInputBinding(slot).primary;
if ( res != 0 ) if ( res != 0 )
{ {
if ( GetResource(RES_KEY, res, iName) ) if ( GetResource(RES_KEY, res, iName) )
@ -1813,7 +1813,7 @@ bool CEdit::ReadText(const char *filename, int addSize)
m_format[j] = font; m_format[j] = font;
j ++; j ++;
res = main->GetInputBinding(slot).joy; res = main->GetInputBinding(slot).secondary;
if ( res != 0 ) if ( res != 0 )
{ {
if ( GetResource(RES_KEY, res, iName) ) if ( GetResource(RES_KEY, res, iName) )

View File

@ -15,65 +15,48 @@
// * You should have received a copy of the GNU General Public License // * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/. // * along with this program. If not, see http://www.gnu.org/licenses/.
// key.cpp
#include "ui/key.h" #include "ui/key.h"
#include <string.h> #include "common/global.h"
#include <cstring>
namespace Ui { namespace Ui {
void GetKeyName(char *name, int key)
void GetKeyName(char* name, unsigned int key)
{ {
if ( !GetResource(RES_KEY, key, name) ) { if (!GetResource(RES_KEY, key, name))
if (isalnum(key)) { sprintf(name, "Code %d", key);
name[0] = key;
name[1] = 0;
}
else {
sprintf(name, "Code %d", key);
}
}
} }
// Object's constructor.
CKey::CKey() : CControl() CKey::CKey() : CControl()
{ {
m_key[0] = 0; m_catch = false;
m_key[1] = 0;
m_bCatch = false;
m_app = CApplication::GetInstancePointer(); m_robotMain = CRobotMain::GetInstancePointer();
} }
// Object's destructor.
CKey::~CKey() CKey::~CKey()
{ {
m_robotMain = nullptr;
} }
// Creates a new button.
bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{ {
char name[100];
if (eventMsg == EVENT_NULL) if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType(); eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg); CControl::Create(pos, dim, icon, eventMsg);
char name[100];
GetResource(RES_EVENT, eventMsg, name); GetResource(RES_EVENT, eventMsg, name);
SetName(std::string(name)); SetName(std::string(name));
return true; return true;
} }
// Management of an event.
bool CKey::EventProcess(const Event &event) bool CKey::EventProcess(const Event &event)
{ {
if (m_state & STATE_DEAD) if (m_state & STATE_DEAD)
@ -81,24 +64,31 @@ bool CKey::EventProcess(const Event &event)
CControl::EventProcess(event); CControl::EventProcess(event);
if (event.type == EVENT_MOUSE_BUTTON_DOWN) { if (event.type == EVENT_MOUSE_BUTTON_DOWN)
{
if (event.mouseButton.button == MOUSE_BUTTON_LEFT) // left if (event.mouseButton.button == MOUSE_BUTTON_LEFT) // left
m_bCatch = Detect(event.mousePos); m_catch = Detect(event.mousePos);
} }
if (event.type == EVENT_KEY_DOWN && m_bCatch) { if (event.type == EVENT_KEY_DOWN && m_catch)
m_bCatch = false; {
m_catch = false;
if ( TestKey(event.key.key) ) { // impossible ? if (TestKey(event.key.key)) // impossible ?
{
m_sound->Play(SOUND_TZOING); m_sound->Play(SOUND_TZOING);
} else { }
// TODO: test for virtual, joystick, etc. else
if ( event.key.key == m_key[0] || event.key.key == m_key[1] ) { {
m_key[0] = event.key.key; if (event.key.key == m_binding.primary || event.key.key == m_binding.secondary)
m_key[1] = 0; {
} else { m_binding.secondary = KEY_INVALID;
m_key[1] = m_key[0]; m_binding.primary = event.key.key;
m_key[0] = event.key.key; }
else
{
m_binding.secondary = m_binding.primary;
m_binding.primary = event.key.key;
} }
m_sound->Play(SOUND_CLICK); m_sound->Play(SOUND_CLICK);
@ -112,96 +102,88 @@ bool CKey::EventProcess(const Event &event)
return true; return true;
} }
bool CKey::TestKey(unsigned int key)
// Seeks when a key is already used.
bool CKey::TestKey(int key)
{ {
if ( key == KEY(PAUSE) || key == KEY(PRINT) ) return true; // blocked key if (key == KEY(PAUSE) || key == KEY(PRINT)) return true; // blocked key
/* TODO: input bindings for (int i = 0; i < INPUT_SLOT_MAX; i++)
for (int i = 0; i < 20; i++) { {
for (int j = 0; j < 2; j++) { InputSlot slot = static_cast<InputSlot>(i);
if (key == m_app->GetKey(i, j) ) // key used? InputBinding b = m_robotMain->GetInputBinding(slot);
m_app->SetKey(i, j, 0); // nothing! if (key == b.primary || key == b.secondary)
} m_robotMain->SetInputBinding(slot, InputBinding()); // nothing!
if ( m_app->GetKey(i, 0) == 0 ) { // first free option? if (b.primary == KEY_INVALID) // first free option?
m_app->SetKey(i, 0, m_app->GetKey(i, 1)); // shift m_robotMain->SetInputBinding(slot, InputBinding(b.secondary, b.primary)); // shift
m_app->SetKey(i, 1, 0); }
}
} */
return false; // not used return false; // not used
} }
// Draws button.
void CKey::Draw() void CKey::Draw()
{ {
Math::Point iDim, pos; if ((m_state & STATE_VISIBLE) == 0)
float zoomExt, zoomInt, h;
int icon;
char text[100];
if ( (m_state & STATE_VISIBLE) == 0 )
return; return;
iDim = m_dim; Math::Point iDim = m_dim;
m_dim.x = 200.0f/640.0f; m_dim.x = 200.0f/640.0f;
if ( m_state & STATE_SHADOW ) if (m_state & STATE_SHADOW)
DrawShadow(m_pos, m_dim); DrawShadow(m_pos, m_dim);
m_engine->SetTexture("button1.png"); m_engine->SetTexture("button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); // was D3DSTATENORMAL m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); // was D3DSTATENORMAL
zoomExt = 1.00f; float zoomExt = 1.00f;
zoomInt = 0.95f; float zoomInt = 0.95f;
icon = 2; int icon = 2;
if ( m_key[0] == 0 && m_key[1] == 0 ) // no shortcut? if (m_binding.primary == KEY_INVALID && m_binding.secondary == KEY_INVALID) // no shortcut?
icon = 3; icon = 3;
if ( m_state & STATE_DEFAULT ) { if (m_state & STATE_DEFAULT)
{
DrawPart(23, 1.3f, 0.0f); DrawPart(23, 1.3f, 0.0f);
zoomExt *= 1.15f; zoomExt *= 1.15f;
zoomInt *= 1.15f; zoomInt *= 1.15f;
} }
if ( m_state & STATE_HILIGHT ) if (m_state & STATE_HILIGHT)
icon = 1; icon = 1;
if ( m_state & STATE_CHECK ) if (m_state & STATE_CHECK)
icon = 0; icon = 0;
if ( m_state & STATE_PRESS ) { if (m_state & STATE_PRESS)
{
icon = 3; icon = 3;
zoomInt *= 0.9f; zoomInt *= 0.9f;
} }
if ( (m_state & STATE_ENABLE) == 0 ) if ((m_state & STATE_ENABLE) == 0)
icon = 7; icon = 7;
if ( m_state & STATE_DEAD ) if (m_state & STATE_DEAD)
icon = 17; icon = 17;
if ( m_bCatch ) if (m_catch)
icon = 23; icon = 23;
DrawPart(icon, zoomExt, 8.0f / 256.0f); // draws the button DrawPart(icon, zoomExt, 8.0f / 256.0f); // draws the button
h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f; float h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f;
GetKeyName(text, m_key[0]); char text[100];
if ( m_key[1] != 0 ) { GetKeyName(text, m_binding.primary);
if (m_binding.secondary != KEY_INVALID)
{
GetResource(RES_TEXT, RT_KEY_OR, text+strlen(text)); GetResource(RES_TEXT, RT_KEY_OR, text+strlen(text));
GetKeyName(text+strlen(text), m_key[1]); GetKeyName(text+strlen(text), m_binding.secondary);
} }
Math::Point pos;
pos.x = m_pos.x + m_dim.x * 0.5f; pos.x = m_pos.x + m_dim.x * 0.5f;
pos.y = m_pos.y + m_dim.y * 0.5f; pos.y = m_pos.y + m_dim.y * 0.5f;
pos.y -= h; pos.y -= h;
@ -209,7 +191,7 @@ void CKey::Draw()
m_dim = iDim; m_dim = iDim;
if ( m_state & STATE_DEAD ) if (m_state & STATE_DEAD)
return; return;
// Draws the name. // Draws the name.
@ -219,20 +201,15 @@ void CKey::Draw()
m_engine->GetText()->DrawText(std::string(m_name), m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_LEFT, 0); m_engine->GetText()->DrawText(std::string(m_name), m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_LEFT, 0);
} }
void CKey::SetBinding(InputBinding b)
void CKey::SetKey(int option, int key)
{ {
if ( option < 0 || option > 1 ) return; m_binding = b;
m_key[option] = key;
} }
int CKey::GetKey(int option) InputBinding CKey::GetBinding()
{ {
if ( option < 0 || option > 1 ) return 0; return m_binding;
return m_key[option];
} }
}
} // namespace Ui

View File

@ -15,13 +15,13 @@
// * You should have received a copy of the GNU General Public License // * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/. // * along with this program. If not, see http://www.gnu.org/licenses/.
// key.h /**
* \file ui/key.h
* \brief Key slot control
*/
#pragma once #pragma once
#include <cctype>
#include <string>
#include "ui/control.h" #include "ui/control.h"
#include "common/iman.h" #include "common/iman.h"
@ -29,33 +29,40 @@
#include "common/restext.h" #include "common/restext.h"
#include "common/key.h" #include "common/key.h"
#include "app/app.h"
namespace Ui { namespace Ui {
class CKey : public CControl class CKey : public CControl
{ {
public: public:
CKey(); CKey();
virtual ~CKey(); virtual ~CKey();
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg); //! Creates a new key slot button
bool EventProcess(const Event &event); bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
//! Management of an event
bool EventProcess(const Event &event);
void Draw(); //! Draws button
void Draw();
void SetKey(int option, int key); //! Management of binding
int GetKey(int option); //@{
void SetBinding(InputBinding b);
InputBinding GetBinding();
//@}
protected: protected:
bool TestKey(int key); //! Checks if a key is already used
bool TestKey(unsigned int key);
unsigned int m_key[2]; protected:
bool m_bCatch; CRobotMain* m_robotMain;
CApplication *m_app; InputBinding m_binding;
bool m_catch;
}; };
} } // namespace Ui

View File

@ -8,7 +8,7 @@
// * // *
// * This program is distributed in the hope that it will be useful, // * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of // * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A Gfx::PARTICULAR PURPOSE. See the // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details. // * GNU General Public License for more details.
// * // *
// * You should have received a copy of the GNU General Public License // * You should have received a copy of the GNU General Public License
@ -5476,7 +5476,6 @@ void CMainDialog::SetupMemorize()
{ {
float fValue; float fValue;
int iValue, i, j; int iValue, i, j;
char key[500];
char num[10]; char num[10];
GetProfile().SetLocalProfileString("Directory", "scene", m_sceneDir); GetProfile().SetLocalProfileString("Directory", "scene", m_sceneDir);
@ -5518,21 +5517,16 @@ void CMainDialog::SetupMemorize()
// GetProfile()->SetLocalProfileInt("Setup", "UseJoystick", m_engine->GetJoystick()); // GetProfile()->SetLocalProfileInt("Setup", "UseJoystick", m_engine->GetJoystick());
// GetProfile()->SetLocalProfileInt("Setup", "MidiVolume", m_sound->GetMidiVolume()); // GetProfile()->SetLocalProfileInt("Setup", "MidiVolume", m_sound->GetMidiVolume());
// key[0] = 0; std::stringstream key;
// for ( i=0 ; i<100 ; i++ ) for (int i = 0; i < INPUT_SLOT_MAX; i++)
// { {
// if ( m_engine->GetKey(i, 0) == 0 ) break; InputBinding b = m_main->GetInputBinding(static_cast<InputSlot>(i));
// for ( j=0 ; j<2 ; j++ ) key << b.primary << " ";
// { key << b.secondary << " ";
// iValue = m_engine->GetKey(i, j); }
// sprintf(num, "%d%c", iValue, j==0?'+':' ');
// strcat(key, num);
// }
// }
/* TODO: profile GetProfile().SetLocalProfileString("Setup", "KeyMap", key.str());
SetLocalProfileString("Setup", "KeyMap", key); */
#if _NET #if _NET
if ( m_accessEnable ) if ( m_accessEnable )
@ -5556,9 +5550,8 @@ void CMainDialog::SetupMemorize()
void CMainDialog::SetupRecall() void CMainDialog::SetupRecall()
{ {
float fValue; float fValue;
int iValue, i, j; int iValue;
std::string key; std::string key;
char* p;
if ( GetProfile().GetLocalProfileString("Directory", "scene", key) ) if ( GetProfile().GetLocalProfileString("Directory", "scene", key) )
{ {
@ -5747,22 +5740,18 @@ void CMainDialog::SetupRecall()
m_engine->SetEditIndentValue(iValue); m_engine->SetEditIndentValue(iValue);
} }
// if ( GetLocalProfileString("Setup", "KeyMap", key, 500) ) if (GetProfile().GetLocalProfileString("Setup", "KeyMap", key))
// { {
// p = key; std::stringstream skey;
// for ( i=0 ; i<100 ; i++ ) skey.str(key);
// { for (int i = 0; i < INPUT_SLOT_MAX; i++)
// if ( p[0] == 0 ) break; {
InputBinding b;
// for ( j=0 ; j<2 ; j++ ) skey >> b.primary;
// { skey >> b.secondary;
// sscanf(p, "%d", &iValue); m_main->SetInputBinding(static_cast<InputSlot>(i), b);
// m_engine->SetKey(i, j, iValue); }
// while ( *p >= '0' && *p <= '9' ) p++; }
// while ( *p == ' ' || *p == '+' ) p++;
// }
// }
// }
#if _NET #if _NET
if ( m_accessEnable ) if ( m_accessEnable )
@ -5837,7 +5826,7 @@ void CMainDialog::ChangeSetupQuality(int quality)
// Redefinable keys: // Redefinable keys:
static int key_table[KEY_TOTAL] = static InputSlot key_table[KEY_TOTAL] =
{ {
INPUT_SLOT_LEFT, INPUT_SLOT_LEFT,
INPUT_SLOT_RIGHT, INPUT_SLOT_RIGHT,
@ -5891,37 +5880,30 @@ static EventType key_event[KEY_TOTAL] =
void CMainDialog::UpdateKey() void CMainDialog::UpdateKey()
{ {
CWindow* pw; CWindow* pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
CScroll* ps; if (pw == nullptr) return;
CKey* pk;
Math::Point pos, dim;
int first, i;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); CScroll* ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
if ( pw == 0 ) return; if (ps == nullptr) return;
ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL)); int first = static_cast<int>(ps->GetVisibleValue()*(KEY_TOTAL-KEY_VISIBLE));
if ( ps == 0 ) return;
first = static_cast<int>(ps->GetVisibleValue()*(KEY_TOTAL-KEY_VISIBLE)); for (int i = 0; i < KEY_TOTAL; i++)
for ( i=0 ; i<KEY_TOTAL ; i++ )
{
pw->DeleteControl(key_event[i]); pw->DeleteControl(key_event[i]);
}
Math::Point dim;
dim.x = 400.0f/640.0f; dim.x = 400.0f/640.0f;
dim.y = 20.0f/480.0f; dim.y = 20.0f/480.0f;
Math::Point pos;
pos.x = 110.0f/640.0f; pos.x = 110.0f/640.0f;
pos.y = 168.0f/480.0f + dim.y*(KEY_VISIBLE-1); pos.y = 168.0f/480.0f + dim.y*(KEY_VISIBLE-1);
for ( i=0 ; i<KEY_VISIBLE ; i++ ) for (int i = 0; i < KEY_VISIBLE; i++)
{ {
pw->CreateKey(pos, dim, -1, key_event[first+i]); pw->CreateKey(pos, dim, -1, key_event[first+i]);
pk = static_cast<CKey*>(pw->SearchControl(key_event[first+i])); CKey* pk = static_cast<CKey*>(pw->SearchControl(key_event[first+i]));
if ( pk == 0 ) break; if (pk == nullptr) break;
/* TODO: set input bindings
pk->SetKey(0, m_engine->GetKey(key_table[first+i], 0)); pk->SetBinding(m_main->GetInputBinding(key_table[first+i]));
pk->SetKey(1, m_engine->GetKey(key_table[first+i], 1)); */
pos.y -= dim.y; pos.y -= dim.y;
} }
} }
@ -5930,26 +5912,20 @@ void CMainDialog::UpdateKey()
void CMainDialog::ChangeKey(EventType event) void CMainDialog::ChangeKey(EventType event)
{ {
CWindow* pw; CWindow* pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
CScroll* ps; if (pw == nullptr) return;
CKey* pk;
int i;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); CScroll* ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
if ( pw == 0 ) return; if (ps == nullptr) return;
ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL)); for (int i = 0; i < KEY_TOTAL; i++)
if ( ps == 0 ) return;
for ( i=0 ; i<KEY_TOTAL ; i++ )
{ {
if ( key_event[i] == event ) if ( key_event[i] == event )
{ {
pk = static_cast<CKey*>(pw->SearchControl(key_event[i])); CKey* pk = static_cast<CKey*>(pw->SearchControl(key_event[i]));
if ( pk == 0 ) break; if (pk == nullptr) break;
/* TODO: set key binding
m_engine->SetKey(key_table[i], 0, pk->GetKey(0)); m_main->SetInputBinding(key_table[i], pk->GetBinding());
m_engine->SetKey(key_table[i], 1, pk->GetKey(1)); */
} }
} }
} }
@ -6803,4 +6779,3 @@ bool CMainDialog::NextMission()
} // namespace Ui } // namespace Ui

View File

@ -30,7 +30,7 @@ CMainShort::CMainShort()
m_iMan->AddInstance(CLASS_SHORT, this); m_iMan->AddInstance(CLASS_SHORT, this);
m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE)); m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
m_event = static_cast<CEvent*>(m_iMan->SearchInstance(CLASS_EVENT)); m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE)); m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN)); m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));

View File

@ -47,7 +47,7 @@ class CMainShort
protected: protected:
CInstanceManager* m_iMan; CInstanceManager* m_iMan;
CEvent* m_event; CEventQueue* m_event;
Gfx::CEngine* m_engine; Gfx::CEngine* m_engine;
CInterface* m_interface; CInterface* m_interface;
CRobotMain* m_main; CRobotMain* m_main;

View File

@ -241,8 +241,8 @@ bool CStudio::EventProcess(const Event &event)
if ( event.type == EVENT_KEY_DOWN ) if ( event.type == EVENT_KEY_DOWN )
{ {
if ( event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).key || if ( event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).primary ||
event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).joy ) event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).secondary )
{ {
if ( m_helpFilename.length() > 0 ) if ( m_helpFilename.length() > 0 )
{ {