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
/doc
# Ignore the CMake build files
/CMakeFiles
/CMakeCache.txt
/cmake_install.cmake
/Makefile
# We don't want anyone to checkin /data folder
/data
# 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
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_LO, "<"},
{ID_HI, ">"},
{ID_LS, "<<"},
{ID_LS, "<="},
{ID_HS, ">="},
{ID_EQ, "=="},
{ID_NE, "!="},

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,7 @@ ${GTEST_DIR}/include
add_executable(image_test ../image.cpp image_test.cpp)
target_link_libraries(image_test ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${PNG_LIBRARIES})
add_executable(profile_test ../profile.cpp ../logger.cpp profile_test.cpp)
target_link_libraries(profile_test gtest ${Boost_LIBRARIES})
#add_executable(profile_test ../profile.cpp ../logger.cpp profile_test.cpp)
#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));
}
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
* \brief HSV color

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -309,7 +309,7 @@ void CGLDevice::SetLight(int index, const Light &light)
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);
}
else

View File

@ -203,8 +203,8 @@ bool CBrain::EventProcess(const Event &event)
action = EVENT_NULL;
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).joy ) &&
(event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).primary ||
event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).secondary ) &&
!m_main->GetEditLock() )
{
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.attenuation1 = 0.0f;
light.attenuation2 = 0.0f;
light.spotAngle = 90;
light.spotAngle = 90.0f*Math::PI/180.0f;
m_shadowLight = m_lightMan->CreateLight();
if ( m_shadowLight == -1 ) return false;
@ -2307,7 +2307,7 @@ bool CObject::CreateEffectLight(float height, Gfx::Color color)
light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f;
light.attenuation2 = 0.0f;
light.spotAngle = 90;
light.spotAngle = 90.0f*Math::PI/180.0f;
m_effectLight = m_lightMan->CreateLight();
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);
CreateShadowCircle(6.0f, 1.0f);
m_showLimitRadius = Gfx::BLITZPARA;
m_showLimitRadius = Gfx::LTNG_PROTECTION_RADIUS;
}
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);
CreateShadowCircle(21.0f, 1.0f);
m_showLimitRadius = Gfx::BLITZPARA;
m_showLimitRadius = Gfx::LTNG_PROTECTION_RADIUS;
}
if ( m_type == OBJECT_SAFE )

View File

@ -730,7 +730,7 @@ CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app)
g_build = 0;
g_researchDone = 0; // no research done
g_researchEnable = 0;
g_unit = 4.0f;
g_unit = UNIT;
m_gamerName[0] = 0;
/* TODO: profile
@ -878,7 +878,7 @@ void CRobotMain::SetDefaultInputBindings()
{
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++)
@ -887,34 +887,34 @@ void CRobotMain::SetDefaultInputBindings()
m_joyAxisBindings[i].invert = false;
}
m_inputBindings[INPUT_SLOT_LEFT ].key = KEY(LEFT);
m_inputBindings[INPUT_SLOT_RIGHT ].key = KEY(RIGHT);
m_inputBindings[INPUT_SLOT_UP ].key = KEY(UP);
m_inputBindings[INPUT_SLOT_DOWN ].key = KEY(DOWN);
m_inputBindings[INPUT_SLOT_GUP ].key = VIRTUAL_KMOD(SHIFT);
m_inputBindings[INPUT_SLOT_GDOWN ].key = VIRTUAL_KMOD(CTRL);
m_inputBindings[INPUT_SLOT_CAMERA ].key = KEY(SPACE);
m_inputBindings[INPUT_SLOT_CAMERA ].joy = VIRTUAL_JOY(2);
m_inputBindings[INPUT_SLOT_DESEL ].key = KEY(KP0);
m_inputBindings[INPUT_SLOT_DESEL ].joy = VIRTUAL_JOY(6);
m_inputBindings[INPUT_SLOT_ACTION ].key = KEY(RETURN);
m_inputBindings[INPUT_SLOT_ACTION ].joy = VIRTUAL_JOY(1);
m_inputBindings[INPUT_SLOT_NEAR ].key = KEY(KP_PLUS);
m_inputBindings[INPUT_SLOT_NEAR ].joy = VIRTUAL_JOY(5);
m_inputBindings[INPUT_SLOT_AWAY ].key = KEY(KP_MINUS);
m_inputBindings[INPUT_SLOT_AWAY ].joy = VIRTUAL_JOY(4);
m_inputBindings[INPUT_SLOT_NEXT ].key = KEY(TAB);
m_inputBindings[INPUT_SLOT_NEXT ].joy = VIRTUAL_JOY(3);
m_inputBindings[INPUT_SLOT_HUMAN ].key = KEY(HOME);
m_inputBindings[INPUT_SLOT_HUMAN ].joy = VIRTUAL_JOY(7);
m_inputBindings[INPUT_SLOT_QUIT ].key = KEY(ESCAPE);
m_inputBindings[INPUT_SLOT_HELP ].key = KEY(F1);
m_inputBindings[INPUT_SLOT_PROG ].key = KEY(F2);
m_inputBindings[INPUT_SLOT_CBOT ].key = KEY(F3);
m_inputBindings[INPUT_SLOT_VISIT ].key = KEY(KP_PERIOD);
m_inputBindings[INPUT_SLOT_SPEED10].key = KEY(F4);
m_inputBindings[INPUT_SLOT_SPEED15].key = KEY(F5);
m_inputBindings[INPUT_SLOT_SPEED20].key = KEY(F6);
m_inputBindings[INPUT_SLOT_LEFT ].primary = KEY(LEFT);
m_inputBindings[INPUT_SLOT_RIGHT ].primary = KEY(RIGHT);
m_inputBindings[INPUT_SLOT_UP ].primary = KEY(UP);
m_inputBindings[INPUT_SLOT_DOWN ].primary = KEY(DOWN);
m_inputBindings[INPUT_SLOT_GUP ].primary = VIRTUAL_KMOD(SHIFT);
m_inputBindings[INPUT_SLOT_GDOWN ].primary = VIRTUAL_KMOD(CTRL);
m_inputBindings[INPUT_SLOT_CAMERA ].primary = KEY(SPACE);
m_inputBindings[INPUT_SLOT_CAMERA ].secondary = VIRTUAL_JOY(2);
m_inputBindings[INPUT_SLOT_DESEL ].primary = KEY(KP0);
m_inputBindings[INPUT_SLOT_DESEL ].secondary = VIRTUAL_JOY(6);
m_inputBindings[INPUT_SLOT_ACTION ].primary = KEY(RETURN);
m_inputBindings[INPUT_SLOT_ACTION ].secondary = VIRTUAL_JOY(1);
m_inputBindings[INPUT_SLOT_NEAR ].primary = KEY(KP_PLUS);
m_inputBindings[INPUT_SLOT_NEAR ].secondary = VIRTUAL_JOY(5);
m_inputBindings[INPUT_SLOT_AWAY ].primary = KEY(KP_MINUS);
m_inputBindings[INPUT_SLOT_AWAY ].secondary = VIRTUAL_JOY(4);
m_inputBindings[INPUT_SLOT_NEXT ].primary = KEY(TAB);
m_inputBindings[INPUT_SLOT_NEXT ].secondary = VIRTUAL_JOY(3);
m_inputBindings[INPUT_SLOT_HUMAN ].primary = KEY(HOME);
m_inputBindings[INPUT_SLOT_HUMAN ].secondary = VIRTUAL_JOY(7);
m_inputBindings[INPUT_SLOT_QUIT ].primary = KEY(ESCAPE);
m_inputBindings[INPUT_SLOT_HELP ].primary = KEY(F1);
m_inputBindings[INPUT_SLOT_PROG ].primary = KEY(F2);
m_inputBindings[INPUT_SLOT_CBOT ].primary = KEY(F3);
m_inputBindings[INPUT_SLOT_VISIT ].primary = KEY(KP_PERIOD);
m_inputBindings[INPUT_SLOT_SPEED10].primary = KEY(F4);
m_inputBindings[INPUT_SLOT_SPEED15].primary = KEY(F5);
m_inputBindings[INPUT_SLOT_SPEED20].primary = KEY(F6);
m_joyAxisBindings[JOY_AXIS_SLOT_X].axis = 0;
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.key.key == GetInputBinding(INPUT_SLOT_UP ).key) 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_DOWN ).key) 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_LEFT ).key) 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_RIGHT).key) 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_GUP ).key) 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_GDOWN).key) 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_UP ).primary) 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 ).primary) 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 ).primary) 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).primary) 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 ).primary) 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).primary) 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)
{
if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).key) 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_DOWN ).key) 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_LEFT ).key) 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_RIGHT).key) 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_GUP ).key) 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_GDOWN).key) 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_UP ).primary) 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 ).primary) 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 ).primary) 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).primary) 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 ).primary) 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).primary) 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)
{
@ -1356,10 +1356,10 @@ bool CRobotMain::EventProcess(Event &event)
if (event.type == EVENT_KEY_DOWN)
{
if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key ||
event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy ||
event.key.key == GetInputBinding(INPUT_SLOT_PROG).key ||
event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy ||
if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_HELP).secondary ||
event.key.key == GetInputBinding(INPUT_SLOT_PROG).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_PROG).secondary ||
event.key.key == KEY(ESCAPE))
{
StopDisplayInfo();
@ -1394,14 +1394,14 @@ bool CRobotMain::EventProcess(Event &event)
}
if (m_editLock) // current edition?
{
if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key ||
event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_HELP).secondary)
{
StartDisplayInfo(SATCOM_HUSTON, false);
return false;
}
if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).key ||
event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_PROG).secondary)
{
StartDisplayInfo(SATCOM_PROG, false);
return false;
@ -1410,8 +1410,8 @@ bool CRobotMain::EventProcess(Event &event)
}
if (m_movieLock) // current movie?
{
if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key ||
event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy ||
if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_QUIT).secondary ||
event.key.key == KEY(ESCAPE))
{
AbortMovie();
@ -1420,21 +1420,21 @@ bool CRobotMain::EventProcess(Event &event)
}
if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT)
{
if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).key ||
event.key.key == GetInputBinding(INPUT_SLOT_VISIT).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_VISIT).secondary)
{
StartDisplayVisit(EVENT_NULL);
}
if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key ||
event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy ||
if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_QUIT).secondary ||
event.key.key == KEY(ESCAPE))
{
StopDisplayVisit();
}
return false;
}
if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key ||
event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_QUIT).secondary)
{
if (m_movie->IsExist())
StartDisplayInfo(SATCOM_HUSTON, false);
@ -1454,55 +1454,55 @@ bool CRobotMain::EventProcess(Event &event)
ChangePause(!m_engine->GetPause());
}
}
if (event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).key ||
event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).secondary)
{
ChangeCamera();
}
if (event.key.key == GetInputBinding(INPUT_SLOT_DESEL).key ||
event.key.key == GetInputBinding(INPUT_SLOT_DESEL).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_DESEL).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_DESEL).secondary)
{
if (m_shortCut)
DeselectObject();
}
if (event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).key ||
event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).secondary)
{
SelectHuman();
}
if (event.key.key == GetInputBinding(INPUT_SLOT_NEXT).key ||
event.key.key == GetInputBinding(INPUT_SLOT_NEXT).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_NEXT).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_NEXT).secondary)
{
if (m_shortCut)
m_short->SelectNext();
}
if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key ||
event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_HELP).secondary)
{
StartDisplayInfo(SATCOM_HUSTON, true);
}
if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).key ||
event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_PROG).secondary)
{
StartDisplayInfo(SATCOM_PROG, true);
}
if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).key ||
event.key.key == GetInputBinding(INPUT_SLOT_VISIT).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_VISIT).secondary)
{
StartDisplayVisit(EVENT_NULL);
}
if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).key ||
event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).secondary)
{
SetSpeed(1.0f);
}
if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).key ||
event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).secondary)
{
SetSpeed(1.5f);
}
if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).key ||
event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).joy)
if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).primary ||
event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).secondary)
{
SetSpeed(2.0f);
}
@ -1956,6 +1956,17 @@ void CRobotMain::ExecuteCmd(char *cmd)
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)
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 (key == GetInputBinding(INPUT_SLOT_LEFT).key ||
key == GetInputBinding(INPUT_SLOT_LEFT).joy)
if (key == GetInputBinding(INPUT_SLOT_LEFT).primary ||
key == GetInputBinding(INPUT_SLOT_LEFT).secondary)
{
m_cameraPan = 0.0f;
}
if (key == GetInputBinding(INPUT_SLOT_RIGHT).key ||
key == GetInputBinding(INPUT_SLOT_RIGHT).joy)
if (key == GetInputBinding(INPUT_SLOT_RIGHT).primary ||
key == GetInputBinding(INPUT_SLOT_RIGHT).secondary)
{
m_cameraPan = 0.0f;
}
if (key == GetInputBinding(INPUT_SLOT_UP).key ||
key == GetInputBinding(INPUT_SLOT_UP).joy)
if (key == GetInputBinding(INPUT_SLOT_UP).primary ||
key == GetInputBinding(INPUT_SLOT_UP).secondary)
{
m_cameraZoom = 0.0f;
}
if (key == GetInputBinding(INPUT_SLOT_DOWN).key ||
key == GetInputBinding(INPUT_SLOT_DOWN).joy)
if (key == GetInputBinding(INPUT_SLOT_DOWN).primary ||
key == GetInputBinding(INPUT_SLOT_DOWN).secondary)
{
m_cameraZoom = 0.0f;
}
@ -3133,26 +3144,26 @@ void CRobotMain::KeyCamera(EventType type, unsigned int key)
if (type == EVENT_KEY_DOWN)
{
if (key == GetInputBinding(INPUT_SLOT_LEFT).key ||
key == GetInputBinding(INPUT_SLOT_LEFT).joy)
if (key == GetInputBinding(INPUT_SLOT_LEFT).primary ||
key == GetInputBinding(INPUT_SLOT_LEFT).secondary)
{
m_cameraPan = -1.0f;
}
if (key == GetInputBinding(INPUT_SLOT_RIGHT).key ||
key == GetInputBinding(INPUT_SLOT_RIGHT).joy)
if (key == GetInputBinding(INPUT_SLOT_RIGHT).primary ||
key == GetInputBinding(INPUT_SLOT_RIGHT).secondary)
{
m_cameraPan = 1.0f;
}
if (key == GetInputBinding(INPUT_SLOT_UP).key ||
key == GetInputBinding(INPUT_SLOT_UP).joy)
if (key == GetInputBinding(INPUT_SLOT_UP).primary ||
key == GetInputBinding(INPUT_SLOT_UP).secondary)
{
m_cameraZoom = -1.0f;
}
if (key == GetInputBinding(INPUT_SLOT_DOWN).key ||
key == GetInputBinding(INPUT_SLOT_DOWN).joy)
if (key == GetInputBinding(INPUT_SLOT_DOWN).primary ||
key == GetInputBinding(INPUT_SLOT_DOWN).secondary)
{
m_cameraZoom = 1.0f;
}
@ -3889,8 +3900,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "DeepView") && !resetObject)
{
m_engine->SetDeepView(OpFloat(line, "air", 500.0f)*UNIT, 0, true);
m_engine->SetDeepView(OpFloat(line, "water", 100.0f)*UNIT, 1, true);
m_engine->SetDeepView(OpFloat(line, "air", 500.0f)*g_unit, 0, true);
m_engine->SetDeepView(OpFloat(line, "water", 100.0f)*g_unit, 1, true);
}
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),
OpInt(line, "brick", 3),
OpFloat(line, "size", 20.0f),
OpFloat(line, "vision", 500.0f)*UNIT,
OpFloat(line, "vision", 500.0f)*g_unit,
OpInt(line, "depth", 2),
OpFloat(line, "hard", 0.5f));
}
@ -3983,7 +3994,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
name,
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)),
OpFloat(line, "level", 100.0f)*UNIT,
OpFloat(line, "level", 100.0f)*g_unit,
OpFloat(line, "glint", 1.0f),
pos);
m_colorNewWater = OpColor(line, "color", m_colorRefWater);
@ -3999,14 +4010,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_cloud->Create(name,
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)),
OpFloat(line, "level", 500.0f) * UNIT);
OpFloat(line, "level", 500.0f) * g_unit);
}
if (Cmd(line, "TerrainBlitz") && !resetObject)
{
m_lightning->Create(OpFloat(line, "sleep", 0.0f),
OpFloat(line, "delay", 3.0f),
OpFloat(line, "magnetic", 50.0f) * UNIT);
OpFloat(line, "magnetic", 50.0f) * g_unit);
}
if (Cmd(line, "TerrainInitTextures") && !resetObject)
@ -4059,8 +4070,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
}
m_terrain->GenerateMaterials(id,
OpFloat(line, "min", 0.0f)*UNIT,
OpFloat(line, "max", 100.0f)*UNIT,
OpFloat(line, "min", 0.0f)*g_unit,
OpFloat(line, "max", 100.0f)*g_unit,
OpFloat(line, "slope", 5.0f),
OpFloat(line, "freq", 100.0f),
OpPos(line, "center")*g_unit,
@ -6615,9 +6626,20 @@ void CRobotMain::ChangePause(bool pause)
//! Changes game 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));
float speed = m_app->GetSimulationSpeed();
if (pb != nullptr)
{
if (speed == 1.0f)
@ -6632,11 +6654,7 @@ void CRobotMain::SetSpeed(float speed)
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
{
//! Keyboard binding code (can be regular or virtual)
unsigned int key;
//! Joystick binding code (virtual)
unsigned int joy;
//! Primary and secondary bindings
//! Can be regular key, virtual key or virtual joystick button
unsigned int primary, secondary;
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 ExecuteCmd(char *cmd);
bool TestGadgetQuantity(int rank);
void UpdateSpeedLabel();
protected:
CInstanceManager* m_iMan;

View File

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

View File

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

View File

@ -19,6 +19,7 @@
#include "script/script.h"
#include "app/app.h"
#include "common/global.h"
#include "common/iman.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) )
{
CRobotMain* main = CRobotMain::GetInstancePointer();
res = main->GetInputBinding(slot).key;
res = main->GetInputBinding(slot).primary;
if ( res != 0 )
{
if ( GetResource(RES_KEY, res, iName) )
@ -1813,7 +1813,7 @@ bool CEdit::ReadText(const char *filename, int addSize)
m_format[j] = font;
j ++;
res = main->GetInputBinding(slot).joy;
res = main->GetInputBinding(slot).secondary;
if ( res != 0 )
{
if ( GetResource(RES_KEY, res, iName) )

View File

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

View File

@ -15,13 +15,13 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
// key.h
/**
* \file ui/key.h
* \brief Key slot control
*/
#pragma once
#include <cctype>
#include <string>
#include "ui/control.h"
#include "common/iman.h"
@ -29,33 +29,40 @@
#include "common/restext.h"
#include "common/key.h"
#include "app/app.h"
namespace Ui {
class CKey : public CControl
{
public:
CKey();
virtual ~CKey();
public:
CKey();
virtual ~CKey();
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
bool EventProcess(const Event &event);
//! Creates a new key slot button
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);
int GetKey(int option);
//! Management of binding
//@{
void SetBinding(InputBinding b);
InputBinding GetBinding();
//@}
protected:
bool TestKey(int key);
protected:
//! Checks if a key is already used
bool TestKey(unsigned int key);
unsigned int m_key[2];
bool m_bCatch;
protected:
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,
// * 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.
// *
// * You should have received a copy of the GNU General Public License
@ -5476,7 +5476,6 @@ void CMainDialog::SetupMemorize()
{
float fValue;
int iValue, i, j;
char key[500];
char num[10];
GetProfile().SetLocalProfileString("Directory", "scene", m_sceneDir);
@ -5518,21 +5517,16 @@ void CMainDialog::SetupMemorize()
// GetProfile()->SetLocalProfileInt("Setup", "UseJoystick", m_engine->GetJoystick());
// GetProfile()->SetLocalProfileInt("Setup", "MidiVolume", m_sound->GetMidiVolume());
// key[0] = 0;
// for ( i=0 ; i<100 ; i++ )
// {
// if ( m_engine->GetKey(i, 0) == 0 ) break;
std::stringstream key;
for (int i = 0; i < INPUT_SLOT_MAX; i++)
{
InputBinding b = m_main->GetInputBinding(static_cast<InputSlot>(i));
// for ( j=0 ; j<2 ; j++ )
// {
// iValue = m_engine->GetKey(i, j);
// sprintf(num, "%d%c", iValue, j==0?'+':' ');
// strcat(key, num);
// }
// }
key << b.primary << " ";
key << b.secondary << " ";
}
/* TODO: profile
SetLocalProfileString("Setup", "KeyMap", key); */
GetProfile().SetLocalProfileString("Setup", "KeyMap", key.str());
#if _NET
if ( m_accessEnable )
@ -5556,9 +5550,8 @@ void CMainDialog::SetupMemorize()
void CMainDialog::SetupRecall()
{
float fValue;
int iValue, i, j;
int iValue;
std::string key;
char* p;
if ( GetProfile().GetLocalProfileString("Directory", "scene", key) )
{
@ -5747,22 +5740,18 @@ void CMainDialog::SetupRecall()
m_engine->SetEditIndentValue(iValue);
}
// if ( GetLocalProfileString("Setup", "KeyMap", key, 500) )
// {
// p = key;
// for ( i=0 ; i<100 ; i++ )
// {
// if ( p[0] == 0 ) break;
// for ( j=0 ; j<2 ; j++ )
// {
// sscanf(p, "%d", &iValue);
// m_engine->SetKey(i, j, iValue);
// while ( *p >= '0' && *p <= '9' ) p++;
// while ( *p == ' ' || *p == '+' ) p++;
// }
// }
// }
if (GetProfile().GetLocalProfileString("Setup", "KeyMap", key))
{
std::stringstream skey;
skey.str(key);
for (int i = 0; i < INPUT_SLOT_MAX; i++)
{
InputBinding b;
skey >> b.primary;
skey >> b.secondary;
m_main->SetInputBinding(static_cast<InputSlot>(i), b);
}
}
#if _NET
if ( m_accessEnable )
@ -5837,7 +5826,7 @@ void CMainDialog::ChangeSetupQuality(int quality)
// Redefinable keys:
static int key_table[KEY_TOTAL] =
static InputSlot key_table[KEY_TOTAL] =
{
INPUT_SLOT_LEFT,
INPUT_SLOT_RIGHT,
@ -5891,37 +5880,30 @@ static EventType key_event[KEY_TOTAL] =
void CMainDialog::UpdateKey()
{
CWindow* pw;
CScroll* ps;
CKey* pk;
Math::Point pos, dim;
int first, i;
CWindow* pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if (pw == nullptr) return;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
CScroll* ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
if (ps == nullptr) return;
ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
if ( ps == 0 ) return;
int first = static_cast<int>(ps->GetVisibleValue()*(KEY_TOTAL-KEY_VISIBLE));
first = static_cast<int>(ps->GetVisibleValue()*(KEY_TOTAL-KEY_VISIBLE));
for ( i=0 ; i<KEY_TOTAL ; i++ )
{
for (int i = 0; i < KEY_TOTAL; i++)
pw->DeleteControl(key_event[i]);
}
Math::Point dim;
dim.x = 400.0f/640.0f;
dim.y = 20.0f/480.0f;
Math::Point pos;
pos.x = 110.0f/640.0f;
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]);
pk = static_cast<CKey*>(pw->SearchControl(key_event[first+i]));
if ( pk == 0 ) break;
/* TODO: set input bindings
pk->SetKey(0, m_engine->GetKey(key_table[first+i], 0));
pk->SetKey(1, m_engine->GetKey(key_table[first+i], 1)); */
CKey* pk = static_cast<CKey*>(pw->SearchControl(key_event[first+i]));
if (pk == nullptr) break;
pk->SetBinding(m_main->GetInputBinding(key_table[first+i]));
pos.y -= dim.y;
}
}
@ -5930,26 +5912,20 @@ void CMainDialog::UpdateKey()
void CMainDialog::ChangeKey(EventType event)
{
CWindow* pw;
CScroll* ps;
CKey* pk;
int i;
CWindow* pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if (pw == nullptr) return;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
CScroll* ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
if (ps == nullptr) return;
ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
if ( ps == 0 ) return;
for ( i=0 ; i<KEY_TOTAL ; i++ )
for (int i = 0; i < KEY_TOTAL; i++)
{
if ( key_event[i] == event )
{
pk = static_cast<CKey*>(pw->SearchControl(key_event[i]));
if ( pk == 0 ) break;
/* TODO: set key binding
m_engine->SetKey(key_table[i], 0, pk->GetKey(0));
m_engine->SetKey(key_table[i], 1, pk->GetKey(1)); */
CKey* pk = static_cast<CKey*>(pw->SearchControl(key_event[i]));
if (pk == nullptr) break;
m_main->SetInputBinding(key_table[i], pk->GetBinding());
}
}
}
@ -6803,4 +6779,3 @@ bool CMainDialog::NextMission()
} // namespace Ui

View File

@ -30,7 +30,7 @@ CMainShort::CMainShort()
m_iMan->AddInstance(CLASS_SHORT, this);
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_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));

View File

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

View File

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