2004-07-20 21:30:35 +02:00
|
|
|
#include "precompiled.h"
|
2005-05-18 07:32:09 +02:00
|
|
|
|
2006-06-09 18:44:16 +02:00
|
|
|
#include "Interact.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
|
2006-06-09 18:44:16 +02:00
|
|
|
#include "graphics/GameView.h"
|
|
|
|
#include "graphics/HFTracer.h"
|
|
|
|
#include "graphics/Model.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
#include "graphics/ModelDef.h"
|
2006-06-09 18:44:16 +02:00
|
|
|
#include "graphics/Terrain.h"
|
|
|
|
#include "graphics/Unit.h"
|
|
|
|
#include "graphics/UnitManager.h"
|
2006-01-21 12:04:09 +01:00
|
|
|
#include "gui/CGUI.h"
|
|
|
|
#include "gui/MiniMap.h"
|
2006-06-09 18:44:16 +02:00
|
|
|
#include "lib/input.h"
|
|
|
|
#include "lib/res/graphics/unifont.h"
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "lib/timer.h"
|
2006-06-09 18:44:16 +02:00
|
|
|
#include "maths/MathUtil.h"
|
2006-08-26 22:25:37 +02:00
|
|
|
#include "network/NetMessage.h"
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
#include "ps/Game.h"
|
|
|
|
#include "ps/Globals.h"
|
|
|
|
#include "ps/Hotkey.h"
|
2006-06-09 18:44:16 +02:00
|
|
|
#include "ps/Player.h"
|
|
|
|
#include "ps/VFSUtil.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
#include "ps/World.h"
|
2006-06-09 18:44:16 +02:00
|
|
|
#include "renderer/Renderer.h"
|
|
|
|
#include "scripting/GameEvents.h"
|
|
|
|
#include "simulation/BoundingObjects.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
#include "simulation/Collision.h"
|
|
|
|
#include "simulation/Entity.h"
|
2006-03-31 05:30:34 +02:00
|
|
|
#include "simulation/EntityFormation.h"
|
2006-06-09 20:32:00 +02:00
|
|
|
#include "simulation/EntityManager.h"
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
#include "simulation/EntityTemplate.h"
|
|
|
|
#include "simulation/EntityTemplateCollection.h"
|
|
|
|
#include "simulation/EventHandlers.h"
|
2006-03-31 05:30:34 +02:00
|
|
|
#include "simulation/FormationManager.h"
|
2006-06-09 18:44:16 +02:00
|
|
|
#include "simulation/Simulation.h"
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
#include "simulation/TerritoryManager.h"
|
2004-07-20 21:30:35 +02:00
|
|
|
|
2006-04-03 23:08:58 +02:00
|
|
|
#include "ps/CLogger.h"
|
|
|
|
#define LOG_CATEGORY "world"
|
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
extern CStr g_CursorName;
|
2006-01-21 12:04:09 +01:00
|
|
|
extern float g_xres, g_yres;
|
2004-07-20 21:30:35 +02:00
|
|
|
|
2005-06-18 01:14:06 +02:00
|
|
|
static const double SELECT_DBLCLICK_RATE = 0.5;
|
2004-11-07 22:30:47 +01:00
|
|
|
const int ORDER_DELAY = 5;
|
2004-07-20 21:30:35 +02:00
|
|
|
|
2005-05-18 07:32:09 +02:00
|
|
|
bool customSelectionMode=false;
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::AddSelection( HEntity entity )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-08-03 01:14:54 +02:00
|
|
|
m_group = -1;
|
2007-05-02 14:07:08 +02:00
|
|
|
debug_assert( !IsSelected( entity ) );
|
2004-07-20 21:30:35 +02:00
|
|
|
m_selected.push_back( entity );
|
|
|
|
entity->m_selected = true;
|
2004-11-11 08:09:32 +01:00
|
|
|
m_selectionChanged = true;
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::RemoveSelection( HEntity entity )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-08-03 01:14:54 +02:00
|
|
|
m_group = -1;
|
2007-05-02 14:07:08 +02:00
|
|
|
debug_assert( IsSelected( entity ) );
|
2004-07-20 21:30:35 +02:00
|
|
|
entity->m_selected = false;
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
|
|
|
{
|
2006-04-21 05:06:57 +02:00
|
|
|
if( (*it) == entity )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
m_selected.erase( it );
|
2004-11-11 08:09:32 +01:00
|
|
|
m_selectionChanged = true;
|
2004-07-20 21:30:35 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::RenderSelectionOutlines()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderSelectionOutline();
|
2004-07-20 21:30:35 +02:00
|
|
|
|
2004-08-03 01:14:54 +02:00
|
|
|
if( m_group_highlight != -1 )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderSelectionOutline( 0.5f );
|
2004-07-20 21:30:35 +02:00
|
|
|
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::RenderBars()
|
2006-07-16 21:32:48 +02:00
|
|
|
{
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderBars();
|
2006-07-16 21:32:48 +02:00
|
|
|
|
|
|
|
/*if( m_group_highlight != -1 )
|
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderBars();
|
2006-07-16 21:32:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}*/
|
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::RenderAuras()
|
2006-08-25 08:04:33 +02:00
|
|
|
{
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
glEnable(GL_BLEND);
|
2006-07-16 21:32:48 +02:00
|
|
|
|
2006-08-25 08:04:33 +02:00
|
|
|
for ( it = m_selected.begin(); it != m_selected.end(); ++it )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderAuras();
|
2006-08-25 08:04:33 +02:00
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::RenderHealthBars()
|
2005-09-05 23:45:26 +02:00
|
|
|
{
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderHealthBar();
|
2005-09-05 23:45:26 +02:00
|
|
|
|
|
|
|
if( m_group_highlight != -1 )
|
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderHealthBar();
|
2005-09-05 23:45:26 +02:00
|
|
|
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2005-09-05 23:45:26 +02:00
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::RenderStaminaBars()
|
2006-01-16 11:56:12 +01:00
|
|
|
{
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderStaminaBar();
|
2006-01-16 11:56:12 +01:00
|
|
|
|
|
|
|
if( m_group_highlight != -1 )
|
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderStaminaBar();
|
2006-01-16 11:56:12 +01:00
|
|
|
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::RenderBarBorders()
|
2006-04-09 00:34:54 +02:00
|
|
|
{
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderBarBorders();
|
2006-04-09 00:34:54 +02:00
|
|
|
|
|
|
|
if( m_group_highlight != -1 )
|
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderBarBorders();
|
2006-04-09 00:34:54 +02:00
|
|
|
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::RenderRanks()
|
2006-03-31 05:30:34 +02:00
|
|
|
{
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderRank();
|
2006-03-31 05:30:34 +02:00
|
|
|
|
|
|
|
if( m_group_highlight != -1 )
|
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderRank();
|
2006-03-31 05:30:34 +02:00
|
|
|
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-05 23:45:26 +02:00
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::RenderOverlays()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-07-31 17:57:18 +02:00
|
|
|
CTerrain *pTerrain=g_Game->GetWorld()->GetTerrain();
|
|
|
|
CCamera *pCamera=g_Game->GetView()->GetCamera();
|
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
glPushMatrix();
|
|
|
|
glEnable( GL_TEXTURE_2D );
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
|
|
|
{
|
2004-08-03 01:14:54 +02:00
|
|
|
if( (*it)->m_grouped != -1 )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-11-15 23:30:01 +01:00
|
|
|
if( !(*it)->m_bounds ) continue;
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
glLoadIdentity();
|
|
|
|
float x, y;
|
2004-07-31 17:57:18 +02:00
|
|
|
CVector3D labelpos = (*it)->m_graphics_position - pCamera->m_Orientation.GetLeft() * (*it)->m_bounds->m_radius;
|
2004-07-20 21:30:35 +02:00
|
|
|
#ifdef SELECTION_TERRAIN_CONFORMANCE
|
2007-05-02 14:07:08 +02:00
|
|
|
labelpos.Y = pTerrain->GetExactGroundLevel( labelpos.X, labelpos.Z );
|
2004-07-20 21:30:35 +02:00
|
|
|
#endif
|
2004-07-31 17:57:18 +02:00
|
|
|
pCamera->GetScreenCoordinates( labelpos, x, y );
|
2004-07-20 21:30:35 +02:00
|
|
|
glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
|
|
|
glTranslatef( x, g_Renderer.GetHeight() - y, 0.0f );
|
|
|
|
glScalef( 1.0f, -1.0f, 1.0f );
|
2004-08-09 18:32:01 +02:00
|
|
|
glwprintf( L"%d", (i32) (*it)->m_grouped );
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
}
|
2004-08-03 01:14:54 +02:00
|
|
|
if( m_group_highlight != -1 )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
|
|
|
{
|
2004-11-15 23:30:01 +01:00
|
|
|
if( !(*it)->m_bounds ) continue;
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
glLoadIdentity();
|
|
|
|
float x, y;
|
2004-07-31 17:57:18 +02:00
|
|
|
CVector3D labelpos = (*it)->m_graphics_position - pCamera->m_Orientation.GetLeft() * (*it)->m_bounds->m_radius;
|
2004-07-20 21:30:35 +02:00
|
|
|
#ifdef SELECTION_TERRAIN_CONFORMANCE
|
2007-05-02 14:07:08 +02:00
|
|
|
labelpos.Y = pTerrain->GetExactGroundLevel( labelpos.X, labelpos.Z );
|
2004-07-20 21:30:35 +02:00
|
|
|
#endif
|
2004-07-31 17:57:18 +02:00
|
|
|
pCamera->GetScreenCoordinates( labelpos, x, y );
|
2004-07-20 21:30:35 +02:00
|
|
|
glColor4f( 1.0f, 1.0f, 1.0f, 0.5f );
|
|
|
|
glTranslatef( x, g_Renderer.GetHeight() - y, 0.0f );
|
|
|
|
glScalef( 1.0f, -1.0f, 1.0f );
|
2004-08-09 18:32:01 +02:00
|
|
|
glwprintf( L"%d", (i32) (*it)->m_grouped );
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
|
|
|
|
2005-04-22 09:12:55 +02:00
|
|
|
/*
|
2004-07-20 21:30:35 +02:00
|
|
|
glLoadIdentity();
|
2005-01-23 18:41:01 +01:00
|
|
|
glTranslatef( (float)( g_mouse_x + 16 ), (float)( g_Renderer.GetHeight() - g_mouse_y - 8 ), 0.0f );
|
2004-07-20 21:30:35 +02:00
|
|
|
glScalef( 1.0f, -1.0f, 1.0f );
|
|
|
|
glColor4f( 1.0f, 1.0f, 1.0f, 0.5f );
|
2005-04-22 09:12:55 +02:00
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
switch( m_contextOrder )
|
|
|
|
{
|
|
|
|
case CEntityOrder::ORDER_GOTO:
|
|
|
|
glwprintf( L"Go to" );
|
|
|
|
break;
|
|
|
|
case CEntityOrder::ORDER_PATROL:
|
|
|
|
glwprintf( L"Patrol to" );
|
|
|
|
break;
|
2004-11-11 08:09:32 +01:00
|
|
|
case CEntityOrder::ORDER_ATTACK_MELEE:
|
|
|
|
glwprintf( L"Attack" );
|
|
|
|
break;
|
2005-04-15 06:23:33 +02:00
|
|
|
case CEntityOrder::ORDER_GATHER:
|
|
|
|
glwprintf( L"Gather" );
|
|
|
|
break;
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
2005-04-22 09:12:55 +02:00
|
|
|
*/
|
2004-07-20 21:30:35 +02:00
|
|
|
|
|
|
|
glDisable( GL_TEXTURE_2D );
|
|
|
|
glPopMatrix();
|
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::RenderRallyPoints()
|
2006-06-22 00:37:31 +02:00
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderRallyPoint();
|
2004-07-20 21:30:35 +02:00
|
|
|
|
2006-06-22 00:37:31 +02:00
|
|
|
if( m_group_highlight != -1 )
|
|
|
|
{
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
for( it = m_groups[m_group_highlight].begin(); it < m_groups[m_group_highlight].end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
(*it)->RenderRallyPoint();
|
2006-06-22 00:37:31 +02:00
|
|
|
}
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::SetSelection( HEntity entity )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-08-03 01:14:54 +02:00
|
|
|
m_group = -1;
|
2007-05-02 14:07:08 +02:00
|
|
|
ClearSelection();
|
2004-07-20 21:30:35 +02:00
|
|
|
m_selected.push_back( entity );
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::ClearSelection()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-08-03 01:14:54 +02:00
|
|
|
m_group = -1;
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
|
|
|
(*it)->m_selected = false;
|
|
|
|
m_selected.clear();
|
2004-11-11 08:09:32 +01:00
|
|
|
m_selectionChanged = true;
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::RemoveAll( HEntity entity )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
// Remove a reference to an entity from everywhere
|
|
|
|
// (for use when said entity is being destroyed)
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
|
|
|
{
|
2006-04-21 05:06:57 +02:00
|
|
|
if( (*it) == entity )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
m_selected.erase( it );
|
2004-11-11 08:09:32 +01:00
|
|
|
m_selectionChanged = true;
|
2004-07-20 21:30:35 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-10-07 21:23:35 +02:00
|
|
|
for( u8 group = 0; group < MAX_GROUPS; group++ )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
for( it = m_groups[group].begin(); it < m_groups[group].end(); it++ )
|
|
|
|
{
|
2006-04-21 05:06:57 +02:00
|
|
|
if( (*it) == entity )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
m_groups[group].erase( it );
|
2004-11-11 08:09:32 +01:00
|
|
|
m_selectionChanged = true;
|
2004-07-20 21:30:35 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
CVector3D CSelectedEntities::GetSelectionPosition()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
CVector3D avg;
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
|
|
|
avg += (*it)->m_graphics_position;
|
|
|
|
return( avg * ( 1.0f / m_selected.size() ) );
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::SaveGroup( i8 groupid )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
// Clear all entities in the group...
|
|
|
|
for( it = m_groups[groupid].begin(); it < m_groups[groupid].end(); it++ )
|
2004-08-03 01:14:54 +02:00
|
|
|
(*it)->m_grouped = -1;
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
m_groups[groupid].clear();
|
|
|
|
// Remove selected entities from each group they're in, and flag them as
|
|
|
|
// members of the new group
|
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
|
|
|
{
|
2004-08-03 01:14:54 +02:00
|
|
|
if( (*it)->m_grouped != -1 )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>& group = m_groups[(*it)->m_grouped];
|
|
|
|
std::vector<HEntity>::iterator it2;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it2 = group.begin(); it2 < group.end(); it2++ )
|
|
|
|
{
|
|
|
|
if( (*it2) == &(**it) )
|
|
|
|
{
|
|
|
|
group.erase( it2 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
(*it)->m_grouped = groupid;
|
|
|
|
}
|
|
|
|
// Copy the group across
|
|
|
|
m_groups[groupid] = m_selected;
|
|
|
|
// Set the group selection memory
|
|
|
|
m_group = groupid;
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::AddToGroup( i8 groupid, HEntity entity )
|
2004-08-03 01:14:54 +02:00
|
|
|
{
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-08-03 01:14:54 +02:00
|
|
|
|
|
|
|
// Remove selected entities from each group they're in, and flag them as
|
|
|
|
// members of the new group
|
|
|
|
if( entity->m_grouped != -1 )
|
|
|
|
{
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>& group = m_groups[(*it)->m_grouped];
|
|
|
|
std::vector<HEntity>::iterator it2;
|
2004-08-03 01:14:54 +02:00
|
|
|
for( it2 = group.begin(); it2 < group.end(); it2++ )
|
|
|
|
{
|
|
|
|
if( (*it2) == entity )
|
|
|
|
{
|
|
|
|
group.erase( it2 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
entity->m_grouped = groupid;
|
|
|
|
|
|
|
|
m_groups[groupid].push_back( entity );
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::LoadGroup( i8 groupid )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-11-11 08:09:32 +01:00
|
|
|
if( m_group == groupid )
|
|
|
|
return;
|
|
|
|
|
2005-07-02 23:42:55 +02:00
|
|
|
if( groupid >= MAX_GROUPS )
|
|
|
|
{
|
|
|
|
debug_warn( "Invalid group id" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
ClearSelection();
|
2004-07-20 21:30:35 +02:00
|
|
|
m_selected = m_groups[groupid];
|
2004-11-11 08:09:32 +01:00
|
|
|
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
|
|
|
(*it)->m_selected = true;
|
|
|
|
m_group = groupid;
|
2004-11-11 08:09:32 +01:00
|
|
|
|
|
|
|
m_selectionChanged = true;
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::AddGroup( i8 groupid )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it = m_groups[groupid].begin(); it < m_groups[groupid].end(); it++ )
|
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
if( !IsSelected( *it ) )
|
|
|
|
AddSelection( *it );
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
|
|
|
(*it)->m_selected = true;
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::ChangeGroup( HEntity entity, i8 groupid )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
// Remove from current group
|
2004-08-09 18:32:01 +02:00
|
|
|
i32 current = entity->m_grouped;
|
2004-08-03 01:14:54 +02:00
|
|
|
if( current != -1 )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it = m_groups[current].begin(); it < m_groups[current].end(); it++ )
|
|
|
|
{
|
2006-04-21 05:06:57 +02:00
|
|
|
if( (*it) == entity )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
m_groups[current].erase( it );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-08-03 01:14:54 +02:00
|
|
|
if( groupid != -1 )
|
2004-07-20 21:30:35 +02:00
|
|
|
m_groups[groupid].push_back( entity );
|
|
|
|
entity->m_grouped = groupid;
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
bool CSelectedEntities::IsSelected( HEntity entity )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
|
|
|
{
|
2006-04-21 05:06:57 +02:00
|
|
|
if( (*it) == entity )
|
2004-07-20 21:30:35 +02:00
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::HighlightGroup( i8 groupid )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-08-03 01:14:54 +02:00
|
|
|
if( m_group_highlight != -1 )
|
2004-07-20 21:30:35 +02:00
|
|
|
return;
|
2007-05-02 14:07:08 +02:00
|
|
|
if( !GetGroupCount( groupid ) )
|
2004-07-20 21:30:35 +02:00
|
|
|
return;
|
|
|
|
m_group_highlight = groupid;
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Game->GetView()->PushCameraTarget( GetGroupPosition( groupid ) );
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::HighlightNone()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-08-03 01:14:54 +02:00
|
|
|
|
|
|
|
if( m_group_highlight != -1 )
|
2004-07-31 17:57:18 +02:00
|
|
|
g_Game->GetView()->PopCameraTarget();
|
2004-08-03 01:14:54 +02:00
|
|
|
m_group_highlight = -1;
|
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
int CSelectedEntities::GetGroupCount( i8 groupid )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
return( (int)m_groups[groupid].size() );
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
CVector3D CSelectedEntities::GetGroupPosition( i8 groupid )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
CVector3D avg;
|
2004-10-07 21:23:35 +02:00
|
|
|
std::vector<HEntity>::iterator it;
|
2004-07-20 21:30:35 +02:00
|
|
|
for( it = m_groups[groupid].begin(); it < m_groups[groupid].end(); it++ )
|
|
|
|
avg += (*it)->m_graphics_position;
|
|
|
|
return( avg * ( 1.0f / m_groups[groupid].size() ) );
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::Update()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2005-04-22 09:12:55 +02:00
|
|
|
static std::vector<HEntity> lastSelection;
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2005-05-18 07:32:09 +02:00
|
|
|
// Drop out immediately if we're in some special interaction mode
|
|
|
|
if (customSelectionMode)
|
|
|
|
return;
|
2005-04-22 09:12:55 +02:00
|
|
|
|
|
|
|
if( !( m_selected == lastSelection ) )
|
|
|
|
{
|
|
|
|
g_JSGameEvents.FireSelectionChanged( m_selectionChanged );
|
2006-04-21 05:06:57 +02:00
|
|
|
lastSelection = m_selected;
|
2005-04-22 09:12:55 +02:00
|
|
|
}
|
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
if( m_selectionChanged || g_Mouseover.m_targetChanged )
|
|
|
|
{
|
|
|
|
// Can't order anything off the map
|
2007-05-02 14:07:08 +02:00
|
|
|
if( !g_Game->GetWorld()->GetTerrain()->IsOnMap( g_Mouseover.m_worldposition ) )
|
2004-11-11 08:09:32 +01:00
|
|
|
{
|
2005-05-18 07:32:09 +02:00
|
|
|
m_defaultCommand = -1;
|
2006-01-16 11:56:12 +01:00
|
|
|
m_secondaryCommand = -1;
|
2004-11-11 08:09:32 +01:00
|
|
|
return;
|
|
|
|
}
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
// Quick count to see which is the modal default order.
|
|
|
|
|
2005-05-18 07:32:09 +02:00
|
|
|
const int numCommands=NMT_COMMAND_LAST - NMT_COMMAND_FIRST;
|
|
|
|
int defaultPoll[numCommands];
|
|
|
|
std::map<CStrW, int, CStrW_hash_compare> defaultCursor[numCommands];
|
2005-12-29 09:42:44 +01:00
|
|
|
std::map<int, int> defaultAction[numCommands];
|
2005-04-22 09:12:55 +02:00
|
|
|
|
2006-01-16 11:56:12 +01:00
|
|
|
int secondaryPoll[numCommands];
|
|
|
|
std::map<CStrW, int, CStrW_hash_compare> secondaryCursor[numCommands];
|
|
|
|
std::map<int, int> secondaryAction[numCommands];
|
|
|
|
|
|
|
|
int t, vote, secvote;
|
2005-05-18 07:32:09 +02:00
|
|
|
for( t = 0; t < numCommands; t++ )
|
2006-01-16 11:56:12 +01:00
|
|
|
{
|
2004-11-11 08:09:32 +01:00
|
|
|
defaultPoll[t] = 0;
|
2006-01-16 11:56:12 +01:00
|
|
|
secondaryPoll[t] = 0;
|
|
|
|
}
|
2004-11-11 08:09:32 +01:00
|
|
|
|
|
|
|
std::vector<HEntity>::iterator it;
|
|
|
|
for( it = m_selected.begin(); it < m_selected.end(); it++ )
|
|
|
|
{
|
2005-04-22 09:12:55 +02:00
|
|
|
CEventTargetChanged evt( g_Mouseover.m_target );
|
|
|
|
(*it)->DispatchEvent( &evt );
|
2005-12-29 09:42:44 +01:00
|
|
|
vote = evt.m_defaultOrder - NMT_COMMAND_FIRST;
|
2006-01-16 11:56:12 +01:00
|
|
|
secvote = evt.m_secondaryOrder - NMT_COMMAND_FIRST;
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2005-05-18 07:32:09 +02:00
|
|
|
if( ( vote >= 0 ) && ( vote < numCommands ) )
|
2005-04-22 09:12:55 +02:00
|
|
|
{
|
2004-11-11 08:09:32 +01:00
|
|
|
defaultPoll[vote]++;
|
2005-04-22 09:12:55 +02:00
|
|
|
defaultCursor[vote][evt.m_defaultCursor]++;
|
2005-12-29 09:42:44 +01:00
|
|
|
defaultAction[vote][evt.m_defaultAction]++;
|
2005-04-22 09:12:55 +02:00
|
|
|
}
|
2006-01-16 11:56:12 +01:00
|
|
|
if( ( secvote >= 0 ) && ( secvote < numCommands ) )
|
|
|
|
{
|
|
|
|
secondaryPoll[secvote]++;
|
|
|
|
secondaryCursor[secvote][evt.m_secondaryCursor]++;
|
|
|
|
secondaryAction[secvote][evt.m_secondaryAction]++;
|
|
|
|
}
|
2004-11-11 08:09:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
vote = -1;
|
2006-01-16 11:56:12 +01:00
|
|
|
secvote = -1;
|
2005-05-18 07:32:09 +02:00
|
|
|
for( t = 0; t < numCommands; t++ )
|
2004-11-11 08:09:32 +01:00
|
|
|
{
|
|
|
|
if( ( vote == -1 ) || ( defaultPoll[t] > defaultPoll[vote] ) )
|
|
|
|
vote = t;
|
2006-01-16 11:56:12 +01:00
|
|
|
if( ( secvote == -1 ) || ( secondaryPoll[t] > secondaryPoll[secvote] ) )
|
|
|
|
secvote = t;
|
2004-11-11 08:09:32 +01:00
|
|
|
}
|
|
|
|
|
2005-04-22 09:12:55 +02:00
|
|
|
std::map<CStrW, int, CStrW_hash_compare>::iterator itv;
|
2005-12-29 09:42:44 +01:00
|
|
|
std::map<int, int>::iterator iti;
|
2005-05-18 07:32:09 +02:00
|
|
|
m_defaultCommand = vote + NMT_COMMAND_FIRST;
|
2006-01-16 11:56:12 +01:00
|
|
|
m_secondaryCommand = secvote + NMT_COMMAND_FIRST;
|
2005-04-22 09:12:55 +02:00
|
|
|
|
|
|
|
// Now find the most appropriate cursor
|
|
|
|
t = 0;
|
|
|
|
for( itv = defaultCursor[vote].begin(); itv != defaultCursor[vote].end(); itv++ )
|
2005-12-29 09:42:44 +01:00
|
|
|
{
|
2005-04-22 09:12:55 +02:00
|
|
|
if( itv->second > t )
|
|
|
|
{
|
|
|
|
t = itv->second;
|
|
|
|
g_CursorName = itv->first;
|
|
|
|
}
|
2005-12-29 09:42:44 +01:00
|
|
|
}
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2006-01-16 11:56:12 +01:00
|
|
|
/*
|
|
|
|
TODO: provide secondary cursor name?
|
|
|
|
|
|
|
|
t = 0;
|
|
|
|
for( itv = secondaryCursor[secvote].begin(); itv != secondaryCursor[secvote].end(); itv++ )
|
|
|
|
{
|
|
|
|
if( itv->second > t )
|
|
|
|
{
|
|
|
|
t = itv->second;
|
|
|
|
g_CursorName = itv->first;
|
|
|
|
}
|
2006-04-21 05:06:57 +02:00
|
|
|
}*/
|
2005-12-29 09:42:44 +01:00
|
|
|
|
|
|
|
// Find the most appropriate action parameter too
|
|
|
|
t = 0;
|
|
|
|
for( iti = defaultAction[vote].begin(); iti != defaultAction[vote].end(); iti++ )
|
|
|
|
{
|
|
|
|
if( iti->second > t )
|
|
|
|
{
|
|
|
|
t = iti->second;
|
|
|
|
m_defaultAction = iti->first;
|
|
|
|
}
|
|
|
|
}
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2006-01-16 11:56:12 +01:00
|
|
|
t = 0;
|
|
|
|
for( iti = secondaryAction[secvote].begin(); iti != secondaryAction[secvote].end(); iti++ )
|
|
|
|
{
|
|
|
|
if( iti->second > t )
|
|
|
|
{
|
|
|
|
t = iti->second;
|
|
|
|
m_secondaryAction = iti->first;
|
|
|
|
}
|
|
|
|
}
|
2004-11-11 08:09:32 +01:00
|
|
|
|
|
|
|
m_selectionChanged = false;
|
|
|
|
g_Mouseover.m_targetChanged = false;
|
|
|
|
}
|
2004-08-03 01:14:54 +02:00
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
if( ( m_group_highlight != -1 ) && GetGroupCount( m_group_highlight ) )
|
|
|
|
g_Game->GetView()->SetCameraTarget( GetGroupPosition( m_group_highlight ) );
|
2004-08-03 01:14:54 +02:00
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::Update( float timestep )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-07-31 17:57:18 +02:00
|
|
|
CCamera *pCamera=g_Game->GetView()->GetCamera();
|
2005-08-09 17:55:44 +02:00
|
|
|
//CTerrain *pTerrain=g_Game->GetWorld()->GetTerrain();
|
2004-07-31 17:57:18 +02:00
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
CVector3D origin, dir;
|
2004-07-31 17:57:18 +02:00
|
|
|
pCamera->BuildCameraRay( origin, dir );
|
2004-07-20 21:30:35 +02:00
|
|
|
|
2007-01-08 02:56:46 +01:00
|
|
|
CUnit* hit = g_Game->GetWorld()->GetUnitManager().PickUnit( origin, dir, true );
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2006-09-10 22:38:39 +02:00
|
|
|
m_worldposition = pCamera->GetWorldCoordinates(true);
|
2004-08-03 01:14:54 +02:00
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
if( hit && hit->GetEntity() && hit->GetEntity()->m_extant )
|
2004-10-07 21:23:35 +02:00
|
|
|
{
|
|
|
|
m_target = hit->GetEntity()->me;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_target = HEntity();
|
|
|
|
|
2004-11-11 08:09:32 +01:00
|
|
|
if( m_target != m_lastTarget )
|
|
|
|
{
|
|
|
|
m_targetChanged = true;
|
|
|
|
m_lastTarget = m_target;
|
|
|
|
}
|
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
if( m_viewall )
|
|
|
|
{
|
|
|
|
// 'O' key. Show selection outlines for all player units on screen
|
|
|
|
// (as if bandboxing them all).
|
|
|
|
// These aren't selectable; clicking when 'O' is pressed won't select
|
|
|
|
// all units on screen.
|
|
|
|
|
|
|
|
m_mouseover.clear();
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
std::vector<HEntity> onscreen;
|
|
|
|
g_EntityManager.GetMatchingAsHandles( onscreen, IsOnScreen );
|
|
|
|
for(std::vector<HEntity>::iterator it = onscreen.begin(); it < onscreen.end(); it++ )
|
|
|
|
{
|
|
|
|
HEntity entity = *it;
|
|
|
|
if( entity->m_extant && ( entity->GetPlayer() == g_Game->GetLocalPlayer() ) )
|
|
|
|
m_mouseover.push_back( SMouseoverFader( entity, m_fademaximum, false ) );
|
|
|
|
}
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
else if( m_bandbox )
|
|
|
|
{
|
2005-01-23 18:41:01 +01:00
|
|
|
m_x2 = g_mouse_x;
|
|
|
|
m_y2 = g_mouse_y;
|
2004-07-20 21:30:35 +02:00
|
|
|
// Here's the fun bit:
|
|
|
|
// Get the screen-space coordinates of all onscreen entities
|
|
|
|
// then find the ones falling within the box.
|
|
|
|
//
|
|
|
|
// Fade in the ones in the box at (in+out) speed, then fade everything
|
|
|
|
// out at (out) speed.
|
2007-05-02 14:07:08 +02:00
|
|
|
std::vector<HEntity> onscreen;
|
|
|
|
g_EntityManager.GetMatchingAsHandles( onscreen, IsOnScreen );
|
2004-07-20 21:30:35 +02:00
|
|
|
|
|
|
|
// Reset active flags on everything...
|
2007-05-02 14:07:08 +02:00
|
|
|
for(std::vector<SMouseoverFader>::iterator it2 = m_mouseover.begin(); it2 < m_mouseover.end(); it2++ )
|
2004-07-20 21:30:35 +02:00
|
|
|
it2->isActive = false;
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
for(std::vector<HEntity>::iterator it = onscreen.begin(); it < onscreen.end(); it++ )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
HEntity entity = *it;
|
|
|
|
if( !entity->m_extant )
|
2004-11-11 08:09:32 +01:00
|
|
|
continue;
|
|
|
|
|
2005-03-30 18:14:19 +02:00
|
|
|
// Can only bandbox units the local player controls.
|
2007-05-02 14:07:08 +02:00
|
|
|
if( entity->GetPlayer() != g_Game->GetLocalPlayer() )
|
2005-03-30 18:14:19 +02:00
|
|
|
continue;
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
CVector3D worldspace = entity->m_graphics_position;
|
2004-07-20 21:30:35 +02:00
|
|
|
|
|
|
|
float x, y;
|
2004-07-31 17:57:18 +02:00
|
|
|
pCamera->GetScreenCoordinates( worldspace, x, y );
|
2004-07-20 21:30:35 +02:00
|
|
|
|
|
|
|
bool inBox;
|
|
|
|
if( m_x1 < m_x2 )
|
|
|
|
{
|
|
|
|
inBox = ( x >= m_x1 ) && ( x < m_x2 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inBox = ( x >= m_x2 ) && ( x < m_x1 );
|
|
|
|
}
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
if( m_y1 < m_y2 )
|
|
|
|
{
|
|
|
|
inBox &= ( y >= m_y1 ) && ( y < m_y2 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inBox &= ( y >= m_y2 ) && ( y < m_y1 );
|
|
|
|
}
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
if( inBox )
|
|
|
|
{
|
|
|
|
bool found = false;
|
2007-05-02 14:07:08 +02:00
|
|
|
for(std::vector<SMouseoverFader>::iterator it2 = m_mouseover.begin(); it2 < m_mouseover.end(); it2++ )
|
2004-07-20 21:30:35 +02:00
|
|
|
if( it2->entity == &(**it) )
|
|
|
|
{
|
|
|
|
found = true;
|
|
|
|
it2->fade += ( m_fadeinrate + m_fadeoutrate ) * timestep;
|
|
|
|
it2->isActive = true;
|
|
|
|
}
|
|
|
|
if( !found )
|
2004-10-07 21:23:35 +02:00
|
|
|
m_mouseover.push_back( SMouseoverFader( *it, ( m_fadeinrate + m_fadeoutrate ) * timestep ) );
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
}
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
for(std::vector<SMouseoverFader>::iterator it2 = m_mouseover.begin(); it2 < m_mouseover.end(); )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
it2->fade -= m_fadeoutrate * timestep;
|
|
|
|
if( it2->fade > m_fademaximum ) it2->fade = m_fademaximum;
|
|
|
|
if( it2->fade < 0.0f )
|
|
|
|
{
|
|
|
|
it2 = m_mouseover.erase( it2 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
it2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
for(std::vector<SMouseoverFader>::iterator it = m_mouseover.begin(); it < m_mouseover.end(); )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
if( it->entity == m_target )
|
|
|
|
{
|
|
|
|
found = true;
|
|
|
|
it->fade += m_fadeinrate * timestep;
|
|
|
|
if( it->fade > m_fademaximum ) it->fade = m_fademaximum;
|
|
|
|
it->isActive = true;
|
|
|
|
it++; continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
it->fade -= m_fadeoutrate * timestep;
|
|
|
|
if( it->fade <= 0.0f )
|
|
|
|
{
|
|
|
|
it = m_mouseover.erase( it ); continue;
|
|
|
|
}
|
|
|
|
it++; continue;
|
|
|
|
}
|
|
|
|
}
|
2004-10-07 21:23:35 +02:00
|
|
|
if( !found && (bool)m_target )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
float initial = m_fadeinrate * timestep;
|
|
|
|
if( initial > m_fademaximum ) initial = m_fademaximum;
|
|
|
|
m_mouseover.push_back( SMouseoverFader( m_target, initial ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::AddSelection()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2005-03-30 18:14:19 +02:00
|
|
|
// Rules for shift-click selection:
|
|
|
|
|
2006-04-21 05:06:57 +02:00
|
|
|
// If selecting a non-allied unit, you can only select one. You can't
|
2005-03-30 18:14:19 +02:00
|
|
|
// select a mix of allied and non-allied units. Therefore:
|
|
|
|
// Forbid shift-click of enemy units unless the selection is empty
|
|
|
|
// Forbid shift-click of allied units if the selection contains one
|
|
|
|
// or more enemy units.
|
|
|
|
|
|
|
|
if( ( m_mouseover.size() != 0 ) &&
|
2006-04-21 05:06:57 +02:00
|
|
|
( m_mouseover.front().entity->GetPlayer() != g_Game->GetLocalPlayer() ) &&
|
2005-03-30 18:14:19 +02:00
|
|
|
( g_Selection.m_selected.size() != 0 ) )
|
|
|
|
return;
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2005-03-30 18:14:19 +02:00
|
|
|
if( ( g_Selection.m_selected.size() != 0 ) &&
|
|
|
|
( g_Selection.m_selected.front()->GetPlayer() != g_Game->GetLocalPlayer() ) )
|
|
|
|
return;
|
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
std::vector<SMouseoverFader>::iterator it;
|
|
|
|
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
if( it->isActive && !g_Selection.IsSelected( it->entity ) )
|
|
|
|
g_Selection.AddSelection( it->entity );
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::RemoveSelection()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
std::vector<SMouseoverFader>::iterator it;
|
|
|
|
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
if( it->isActive && g_Selection.IsSelected( it->entity ) )
|
|
|
|
g_Selection.RemoveSelection( it->entity );
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::SetSelection()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Selection.ClearSelection();
|
|
|
|
AddSelection();
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::ExpandAcrossScreen()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
std::vector<HEntity> activeset;
|
|
|
|
g_EntityManager.GetMatchingAsHandles(
|
|
|
|
activeset,
|
|
|
|
CEntityManager::EntityPredicateLogicalAnd<IsMouseoverType,IsOnScreen>
|
|
|
|
);
|
2004-07-20 21:30:35 +02:00
|
|
|
m_mouseover.clear();
|
2007-05-02 14:07:08 +02:00
|
|
|
for(std::vector<HEntity>::iterator it = activeset.begin(); it < activeset.end(); it++ )
|
|
|
|
{
|
|
|
|
HEntity entity = *it;
|
|
|
|
if( entity->m_extant )
|
|
|
|
m_mouseover.push_back( SMouseoverFader( entity ) );
|
|
|
|
}
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::ExpandAcrossWorld()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
std::vector<HEntity> activeset;
|
|
|
|
g_EntityManager.GetMatchingAsHandles( activeset, IsMouseoverType );
|
2004-07-20 21:30:35 +02:00
|
|
|
m_mouseover.clear();
|
2007-05-02 14:07:08 +02:00
|
|
|
for(std::vector<HEntity>::iterator it = activeset.begin(); it < activeset.end(); it++ )
|
|
|
|
{
|
|
|
|
HEntity entity = *it;
|
|
|
|
if( entity->m_extant )
|
|
|
|
m_mouseover.push_back( SMouseoverFader( entity ) );
|
|
|
|
}
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::RenderSelectionOutlines()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
|
|
|
|
std::vector<SMouseoverFader>::iterator it;
|
|
|
|
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
2006-10-08 19:39:46 +02:00
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
if( !g_Selection.IsSelected(it->entity) )
|
|
|
|
it->entity->RenderSelectionOutline( it->fade );
|
2006-10-08 19:39:46 +02:00
|
|
|
}
|
2004-07-20 21:30:35 +02:00
|
|
|
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::RenderAuras()
|
2006-08-25 08:04:33 +02:00
|
|
|
{
|
|
|
|
std::vector<SMouseoverFader>::iterator it;
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
glEnable(GL_BLEND);
|
2004-07-20 21:30:35 +02:00
|
|
|
|
2006-08-25 08:04:33 +02:00
|
|
|
for ( it = m_mouseover.begin(); it != m_mouseover.end(); ++it )
|
2006-10-08 19:39:46 +02:00
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
if( !g_Selection.IsSelected(it->entity) )
|
|
|
|
it->entity->RenderAuras();
|
2006-10-08 19:39:46 +02:00
|
|
|
}
|
2006-08-25 08:04:33 +02:00
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::RenderBars()
|
2006-07-16 21:32:48 +02:00
|
|
|
{
|
|
|
|
std::vector<SMouseoverFader>::iterator it;
|
|
|
|
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
2006-10-08 19:39:46 +02:00
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
if( !g_Selection.IsSelected(it->entity) )
|
|
|
|
it->entity->RenderBars();
|
2006-10-08 19:39:46 +02:00
|
|
|
}
|
2006-07-16 21:32:48 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::RenderHealthBars()
|
2005-09-05 23:45:26 +02:00
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
|
|
|
|
std::vector<SMouseoverFader>::iterator it;
|
|
|
|
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
it->entity->RenderHealthBar();
|
2005-09-05 23:45:26 +02:00
|
|
|
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::RenderStaminaBars()
|
2006-01-16 11:56:12 +01:00
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
|
|
|
|
std::vector<SMouseoverFader>::iterator it;
|
|
|
|
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
it->entity->RenderStaminaBar();
|
2006-01-16 11:56:12 +01:00
|
|
|
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::RenderRanks()
|
2006-03-31 05:30:34 +02:00
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
2006-01-16 11:56:12 +01:00
|
|
|
|
2006-03-31 05:30:34 +02:00
|
|
|
std::vector<SMouseoverFader>::iterator it;
|
|
|
|
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
it->entity->RenderRank();
|
2006-03-31 05:30:34 +02:00
|
|
|
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::RenderBarBorders()
|
2006-04-09 00:34:54 +02:00
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-04-09 00:34:54 +02:00
|
|
|
std::vector<SMouseoverFader>::iterator it;
|
|
|
|
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
it->entity->RenderBarBorders();
|
2006-03-31 05:30:34 +02:00
|
|
|
|
2006-04-09 00:34:54 +02:00
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::RenderRallyPoints()
|
2006-06-22 00:37:31 +02:00
|
|
|
{
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
|
|
|
|
std::vector<SMouseoverFader>::iterator it;
|
|
|
|
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
2007-05-02 14:07:08 +02:00
|
|
|
it->entity->RenderRallyPoint();
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2006-06-22 00:37:31 +02:00
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
// Helper function for CSelectedEntities::LoadUnitUiTextures
|
2006-04-09 00:34:54 +02:00
|
|
|
static void LoadUnitUIThunk( const char* path, const DirEnt* UNUSED(ent), void* context )
|
2006-03-31 05:30:34 +02:00
|
|
|
{
|
2006-04-09 00:34:54 +02:00
|
|
|
std::map<CStr, Handle>* textures = (std::map<CStr, Handle>*) context;
|
|
|
|
CStr name(path);
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2006-04-09 00:34:54 +02:00
|
|
|
if ( !tex_is_known_extension(path) )
|
|
|
|
return;
|
|
|
|
Handle tmp = ogl_tex_load(path);
|
|
|
|
if (tmp <= 0)
|
2006-04-21 05:06:57 +02:00
|
|
|
{
|
2006-04-13 23:50:44 +02:00
|
|
|
LOG(ERROR, LOG_CATEGORY, "Rank Textures", "loadRankTextures failed on \"%s\"", path);
|
2006-04-09 00:34:54 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
name.Remove("art/textures/ui/session/icons/"); //Names are relative to this directory
|
|
|
|
(*textures)[name] = tmp;
|
|
|
|
ogl_tex_upload(tmp);
|
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
int CSelectedEntities::LoadUnitUiTextures()
|
2006-04-09 00:34:54 +02:00
|
|
|
{
|
2006-04-14 08:32:05 +02:00
|
|
|
THROW_ERR( vfs_dir_enum( "art/textures/ui/session/icons/", VFS_DIR_RECURSIVE,
|
2006-04-09 00:34:54 +02:00
|
|
|
NULL, LoadUnitUIThunk, &m_unitUITextures ) );
|
2006-03-31 05:30:34 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
void CSelectedEntities::DestroyUnitUiTextures()
|
2006-03-31 05:30:34 +02:00
|
|
|
{
|
2006-04-09 00:34:54 +02:00
|
|
|
for ( std::map<CStr, Handle>::iterator it=m_unitUITextures.begin(); it != m_unitUITextures.end(); it++ )
|
2006-03-31 05:30:34 +02:00
|
|
|
{
|
|
|
|
ogl_tex_free(it->second);
|
|
|
|
it->second = 0;
|
|
|
|
}
|
|
|
|
}
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::RenderOverlays()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-07-31 17:57:18 +02:00
|
|
|
CCamera *pCamera=g_Game->GetView()->GetCamera();
|
|
|
|
CTerrain *pTerrain=g_Game->GetWorld()->GetTerrain();
|
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
glLoadIdentity();
|
|
|
|
glDisable( GL_TEXTURE_2D );
|
|
|
|
if( m_bandbox )
|
|
|
|
{
|
|
|
|
//glPushMatrix();
|
|
|
|
glColor3f( 1.0f, 1.0f, 1.0f );
|
|
|
|
glBegin( GL_LINE_LOOP );
|
|
|
|
glVertex2i( m_x1, g_Renderer.GetHeight() - m_y1 );
|
|
|
|
glVertex2i( m_x2, g_Renderer.GetHeight() - m_y1 );
|
|
|
|
glVertex2i( m_x2, g_Renderer.GetHeight() - m_y2 );
|
|
|
|
glVertex2i( m_x1, g_Renderer.GetHeight() - m_y2 );
|
|
|
|
glEnd();
|
|
|
|
//glPopMatrix();
|
|
|
|
}
|
|
|
|
glEnable( GL_TEXTURE_2D );
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2004-07-20 21:30:35 +02:00
|
|
|
std::vector<SMouseoverFader>::iterator it;
|
|
|
|
for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ )
|
|
|
|
{
|
2004-08-03 01:14:54 +02:00
|
|
|
if( it->entity->m_grouped != -1 )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-11-15 23:30:01 +01:00
|
|
|
if( !it->entity->m_bounds ) continue;
|
2004-07-20 21:30:35 +02:00
|
|
|
glPushMatrix();
|
|
|
|
glEnable( GL_TEXTURE_2D );
|
|
|
|
glLoadIdentity();
|
|
|
|
float x, y;
|
2004-07-31 17:57:18 +02:00
|
|
|
CVector3D labelpos = it->entity->m_graphics_position - pCamera->m_Orientation.GetLeft() * it->entity->m_bounds->m_radius;
|
2004-07-20 21:30:35 +02:00
|
|
|
#ifdef SELECTION_TERRAIN_CONFORMANCE
|
2007-05-02 14:07:08 +02:00
|
|
|
labelpos.Y = pTerrain->GetExactGroundLevel( labelpos.X, labelpos.Z );
|
2004-07-20 21:30:35 +02:00
|
|
|
#endif
|
2004-07-31 17:57:18 +02:00
|
|
|
pCamera->GetScreenCoordinates( labelpos, x, y );
|
2004-07-20 21:30:35 +02:00
|
|
|
glColor4f( 1.0f, 1.0f, 1.0f, it->fade );
|
|
|
|
glTranslatef( x, g_Renderer.GetHeight() - y, 0.0f );
|
|
|
|
glScalef( 1.0f, -1.0f, 1.0f );
|
2004-08-09 18:32:01 +02:00
|
|
|
glwprintf( L"%d", (i32) it->entity->m_grouped );
|
2004-07-20 21:30:35 +02:00
|
|
|
glDisable( GL_TEXTURE_2D );
|
|
|
|
glPopMatrix();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::StartBandbox( u16 x, u16 y )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
m_bandbox = true;
|
|
|
|
m_x1 = x; m_y1 = y;
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CMouseoverEntities::StopBandbox()
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
m_bandbox = false;
|
|
|
|
}
|
|
|
|
|
2005-05-18 07:32:09 +02:00
|
|
|
void FireWorldClickEvent(uint button, int clicks)
|
|
|
|
{
|
2005-06-20 17:14:36 +02:00
|
|
|
//debug_printf("FireWorldClickEvent: button %d, clicks %d\n", button, clicks);
|
2006-01-21 12:04:09 +01:00
|
|
|
//If we're clicking on the minimap, use its world click handler
|
|
|
|
|
|
|
|
if ( g_Selection.m_mouseOverMM )
|
|
|
|
return;
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2005-05-18 07:32:09 +02:00
|
|
|
g_JSGameEvents.FireWorldClick(
|
|
|
|
button,
|
|
|
|
clicks,
|
|
|
|
g_Selection.m_defaultCommand,
|
2005-12-29 09:42:44 +01:00
|
|
|
g_Selection.m_defaultAction,
|
2006-01-16 11:56:12 +01:00
|
|
|
g_Selection.m_secondaryCommand, // FIXME Secondary order, depends entity scripts etc
|
|
|
|
g_Selection.m_secondaryAction, // FIXME Secondary action, depends entity scripts etc
|
2005-05-18 07:32:09 +02:00
|
|
|
g_Mouseover.m_target,
|
|
|
|
(uint)g_Mouseover.m_worldposition.x,
|
|
|
|
(uint)g_Mouseover.m_worldposition.y);
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2006-03-31 05:30:34 +02:00
|
|
|
//Reset duplication flag- after this, it isn't the same order
|
|
|
|
std::vector<HEntity>::iterator it=g_Selection.m_selected.begin();
|
|
|
|
for ( ; it != g_Selection.m_selected.end(); it++ )
|
|
|
|
{
|
|
|
|
if ( (*it)->m_formation >= 0)
|
|
|
|
(*it)->GetFormation()->SetDuplication(false);
|
|
|
|
}
|
2005-05-18 07:32:09 +02:00
|
|
|
}
|
|
|
|
|
2006-08-26 23:52:18 +02:00
|
|
|
void MouseButtonUpHandler(const SDL_Event_* ev, int clicks)
|
2005-05-18 07:32:09 +02:00
|
|
|
{
|
2006-08-26 23:52:18 +02:00
|
|
|
FireWorldClickEvent(ev->ev.button.button, clicks);
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2006-08-26 23:52:18 +02:00
|
|
|
switch( ev->ev.button.button )
|
2005-05-18 07:32:09 +02:00
|
|
|
{
|
|
|
|
case SDL_BUTTON_LEFT:
|
2005-09-05 21:48:28 +02:00
|
|
|
if( g_BuildingPlacer.m_active )
|
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
g_BuildingPlacer.MouseReleased();
|
2005-09-05 21:48:28 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-05-18 07:32:09 +02:00
|
|
|
if (customSelectionMode)
|
|
|
|
break;
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2005-05-18 07:32:09 +02:00
|
|
|
if( g_Mouseover.m_viewall )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( clicks == 2 )
|
|
|
|
{
|
|
|
|
// Double click
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Mouseover.ExpandAcrossScreen();
|
2005-05-18 07:32:09 +02:00
|
|
|
}
|
|
|
|
else if( clicks == 3 )
|
|
|
|
{
|
|
|
|
// Triple click
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Mouseover.ExpandAcrossWorld();
|
2005-05-18 07:32:09 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Mouseover.StopBandbox();
|
2005-05-18 07:32:09 +02:00
|
|
|
if( hotkeys[HOTKEY_SELECTION_ADD] )
|
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Mouseover.AddSelection();
|
2005-05-18 07:32:09 +02:00
|
|
|
}
|
|
|
|
else if( hotkeys[HOTKEY_SELECTION_REMOVE] )
|
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Mouseover.RemoveSelection();
|
2005-05-18 07:32:09 +02:00
|
|
|
}
|
|
|
|
else
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Mouseover.SetSelection();
|
2005-05-18 07:32:09 +02:00
|
|
|
break;
|
2005-09-05 21:48:28 +02:00
|
|
|
case SDL_BUTTON_RIGHT:
|
|
|
|
if( g_BuildingPlacer.m_active )
|
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
g_BuildingPlacer.Deactivate();
|
2005-09-05 21:48:28 +02:00
|
|
|
break;
|
|
|
|
}
|
2005-05-18 07:32:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
InReaction InteractInputHandler( const SDL_Event_* ev )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2005-10-31 19:36:36 +01:00
|
|
|
if (!g_app_has_focus || !g_Game)
|
2005-10-20 19:44:56 +02:00
|
|
|
return IN_PASS;
|
2004-08-05 15:07:51 +02:00
|
|
|
|
2004-07-31 17:57:18 +02:00
|
|
|
CGameView *pView=g_Game->GetView();
|
2005-08-09 17:55:44 +02:00
|
|
|
//CCamera *pCamera=pView->GetCamera();
|
|
|
|
//CTerrain *pTerrain=g_Game->GetWorld()->GetTerrain();
|
2004-07-31 17:57:18 +02:00
|
|
|
|
2005-06-20 17:14:36 +02:00
|
|
|
// One entry for each mouse button
|
2005-10-24 02:06:08 +02:00
|
|
|
// note: to store these in an array, we make assumptions as to the
|
|
|
|
// SDL_BUTTON_* values; these are verified at compile time.
|
|
|
|
cassert(SDL_BUTTON_LEFT == 1 && SDL_BUTTON_MIDDLE == 2 && SDL_BUTTON_RIGHT == 3 && \
|
|
|
|
SDL_BUTTON_WHEELUP == 4 && SDL_BUTTON_WHEELDOWN == 5);
|
2006-11-12 05:02:36 +01:00
|
|
|
const int SDL_BUTTON_INDEX_COUNT = 6;
|
2005-06-20 17:14:36 +02:00
|
|
|
static double lastclicktime[SDL_BUTTON_INDEX_COUNT];
|
|
|
|
static HEntity lastclickobject[SDL_BUTTON_INDEX_COUNT];
|
|
|
|
static u8 clicks[SDL_BUTTON_INDEX_COUNT];
|
2004-07-20 21:30:35 +02:00
|
|
|
|
2005-06-20 17:14:36 +02:00
|
|
|
ONCE(
|
|
|
|
for (int i=0;i<SDL_BUTTON_INDEX_COUNT;i++)
|
|
|
|
{
|
|
|
|
lastclicktime[i] = 0.0f;
|
|
|
|
clicks[i] = 0;
|
|
|
|
});
|
|
|
|
// These refer to the left mouse button
|
2004-07-20 21:30:35 +02:00
|
|
|
static u16 button_down_x, button_down_y;
|
2005-05-18 23:19:56 +02:00
|
|
|
static double button_down_time;
|
2004-07-20 21:30:35 +02:00
|
|
|
static bool button_down = false;
|
2005-09-06 10:25:41 +02:00
|
|
|
static bool right_button_down = false;
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2006-08-26 23:52:18 +02:00
|
|
|
if (customSelectionMode && ev->ev.type != SDL_MOUSEBUTTONUP)
|
2005-10-20 19:44:56 +02:00
|
|
|
return IN_PASS;
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2006-08-26 23:52:18 +02:00
|
|
|
switch( ev->ev.type )
|
2006-04-21 05:06:57 +02:00
|
|
|
{
|
2004-07-23 12:56:52 +02:00
|
|
|
case SDL_HOTKEYDOWN:
|
2006-08-26 23:52:18 +02:00
|
|
|
switch( ev->ev.user.code )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-07-23 12:56:52 +02:00
|
|
|
case HOTKEY_HIGHLIGHTALL:
|
|
|
|
g_Mouseover.m_viewall = true;
|
|
|
|
break;
|
|
|
|
case HOTKEY_SELECTION_SNAP:
|
|
|
|
if( g_Selection.m_selected.size() )
|
2007-05-02 14:07:08 +02:00
|
|
|
pView->SetCameraTarget( g_Selection.GetSelectionPosition() );
|
2004-07-23 12:56:52 +02:00
|
|
|
break;
|
2005-12-06 21:16:50 +01:00
|
|
|
case HOTKEY_CAMERA_UNIT_VIEW:
|
2005-12-06 07:46:16 +01:00
|
|
|
{
|
|
|
|
if ( pView->IsAttached() )
|
|
|
|
break; //Should only exit unit view through unit view hotkey
|
|
|
|
if ( pView->IsUnitView() )
|
|
|
|
{
|
|
|
|
//If already in unit view, exit it
|
|
|
|
pView->ToUnitView( NULL, NULL );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( g_Selection.m_selected.empty() )
|
|
|
|
break;
|
2005-12-06 21:16:50 +01:00
|
|
|
|
2005-12-06 07:46:16 +01:00
|
|
|
std::vector<CModel::Prop>& Props = g_Selection.m_selected.front()->m_actor->GetModel()->GetProps();
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2005-12-06 21:16:50 +01:00
|
|
|
for (size_t x=0; x<Props.size(); x++)
|
|
|
|
{
|
2005-12-06 07:46:16 +01:00
|
|
|
if( Props[x].m_Point->m_Name == "head" )
|
|
|
|
{
|
2005-12-06 21:16:50 +01:00
|
|
|
pView->ToUnitView( g_Selection.m_selected.front(), Props[x].m_Model);
|
2005-12-06 07:46:16 +01:00
|
|
|
break;
|
2005-12-06 21:16:50 +01:00
|
|
|
}
|
2005-12-06 07:46:16 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-12-06 21:16:50 +01:00
|
|
|
case HOTKEY_CAMERA_UNIT_ATTACH:
|
2005-12-06 07:46:16 +01:00
|
|
|
{
|
|
|
|
if ( pView->IsUnitView() )
|
|
|
|
break; //Should only exit unit view through unit view hotkey
|
|
|
|
if ( pView->IsAttached() )
|
|
|
|
{
|
|
|
|
//If already in unit view, exit it
|
|
|
|
pView->AttachToUnit( NULL );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( g_Selection.m_selected.empty() )
|
|
|
|
break;
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2005-12-06 21:16:50 +01:00
|
|
|
pView->AttachToUnit( g_Selection.m_selected.front() );
|
|
|
|
break;
|
2005-12-06 07:46:16 +01:00
|
|
|
}
|
2005-12-06 21:16:50 +01:00
|
|
|
|
2004-07-23 12:56:52 +02:00
|
|
|
default:
|
2006-08-26 23:52:18 +02:00
|
|
|
if( ( ev->ev.user.code >= HOTKEY_SELECTION_GROUP_0 ) && ( ev->ev.user.code <= HOTKEY_SELECTION_GROUP_19 ) )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-07-24 16:04:40 +02:00
|
|
|
// The above test limits it to 20 groups, so don't worry about overflowing
|
2004-08-03 01:14:54 +02:00
|
|
|
|
2006-08-26 23:52:18 +02:00
|
|
|
i8 id = (i8)( ev->ev.user.code - HOTKEY_SELECTION_GROUP_0 );
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2004-07-22 18:18:12 +02:00
|
|
|
if( hotkeys[HOTKEY_SELECTION_GROUP_ADD] )
|
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Selection.AddGroup( id );
|
2004-07-22 18:18:12 +02:00
|
|
|
}
|
|
|
|
else if( hotkeys[HOTKEY_SELECTION_GROUP_SAVE] )
|
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Selection.SaveGroup( id );
|
2004-07-22 18:18:12 +02:00
|
|
|
}
|
|
|
|
else if( hotkeys[HOTKEY_SELECTION_GROUP_SNAP] )
|
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Selection.HighlightGroup( id );
|
2004-07-22 18:18:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
if( ( g_Selection.m_group == id ) && g_Selection.GetGroupCount( id ) )
|
2004-07-22 18:18:12 +02:00
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
pView->SetCameraTarget( g_Selection.GetGroupPosition( id ) );
|
2004-07-22 18:18:12 +02:00
|
|
|
}
|
|
|
|
else
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Selection.LoadGroup( id );
|
2004-07-22 18:18:12 +02:00
|
|
|
}
|
2005-10-20 19:44:56 +02:00
|
|
|
return( IN_HANDLED );
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
2005-12-06 21:16:50 +01:00
|
|
|
|
2005-10-20 19:44:56 +02:00
|
|
|
return( IN_PASS );
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
2005-10-20 19:44:56 +02:00
|
|
|
return( IN_HANDLED );
|
2004-07-21 18:34:07 +02:00
|
|
|
case SDL_HOTKEYUP:
|
2006-08-26 23:52:18 +02:00
|
|
|
switch( ev->ev.user.code )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-07-21 18:34:07 +02:00
|
|
|
case HOTKEY_SELECTION_GROUP_SNAP:
|
2004-08-03 01:14:54 +02:00
|
|
|
if( g_Selection.m_group_highlight != -1 )
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Selection.HighlightNone();
|
2004-07-20 21:30:35 +02:00
|
|
|
break;
|
2004-07-21 18:34:07 +02:00
|
|
|
case HOTKEY_HIGHLIGHTALL:
|
2004-07-20 21:30:35 +02:00
|
|
|
g_Mouseover.m_viewall = false;
|
|
|
|
break;
|
2004-08-03 01:14:54 +02:00
|
|
|
default:
|
2005-10-20 19:44:56 +02:00
|
|
|
return( IN_PASS );
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
2005-10-20 19:44:56 +02:00
|
|
|
return( IN_HANDLED );
|
2004-07-20 21:30:35 +02:00
|
|
|
case SDL_MOUSEBUTTONUP:
|
2005-05-18 07:32:09 +02:00
|
|
|
{
|
2006-08-26 23:52:18 +02:00
|
|
|
int button = ev->ev.button.button;
|
2005-05-18 07:32:09 +02:00
|
|
|
// Only process buttons within the range for which we have button state
|
|
|
|
// arrays above.
|
2005-06-20 17:14:36 +02:00
|
|
|
if (button >= 0 && button < SDL_BUTTON_INDEX_COUNT)
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2005-06-18 01:14:06 +02:00
|
|
|
double time = get_time();
|
2004-07-20 21:30:35 +02:00
|
|
|
// Reset clicks counter if too slow or if the cursor's
|
|
|
|
// hovering over something else now.
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2005-05-18 07:32:09 +02:00
|
|
|
if( time - lastclicktime[button] >= SELECT_DBLCLICK_RATE )
|
|
|
|
clicks[button] = 0;
|
|
|
|
if( g_Mouseover.m_target != lastclickobject[button] )
|
|
|
|
clicks[button] = 0;
|
|
|
|
clicks[button]++;
|
2004-07-20 21:30:35 +02:00
|
|
|
|
2005-05-18 07:32:09 +02:00
|
|
|
lastclicktime[button] = time;
|
|
|
|
lastclickobject[button] = g_Mouseover.m_target;
|
2004-07-20 21:30:35 +02:00
|
|
|
|
2006-08-26 23:52:18 +02:00
|
|
|
if(ev->ev.button.button == SDL_BUTTON_LEFT )
|
2005-05-18 07:32:09 +02:00
|
|
|
button_down = false;
|
2006-08-26 23:52:18 +02:00
|
|
|
if(ev->ev.button.button == SDL_BUTTON_RIGHT )
|
2005-09-06 10:25:41 +02:00
|
|
|
right_button_down = false;
|
2005-05-18 07:32:09 +02:00
|
|
|
|
|
|
|
MouseButtonUpHandler(ev, clicks[button]);
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
break;
|
2005-05-18 07:32:09 +02:00
|
|
|
}
|
2004-07-20 21:30:35 +02:00
|
|
|
case SDL_MOUSEBUTTONDOWN:
|
2006-08-26 23:52:18 +02:00
|
|
|
switch( ev->ev.button.button )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
case SDL_BUTTON_LEFT:
|
|
|
|
button_down = true;
|
2006-08-26 23:52:18 +02:00
|
|
|
button_down_x = ev->ev.button.x;
|
|
|
|
button_down_y = ev->ev.button.y;
|
2005-05-18 07:32:09 +02:00
|
|
|
button_down_time = get_time();
|
2005-09-05 21:48:28 +02:00
|
|
|
if( g_BuildingPlacer.m_active )
|
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
g_BuildingPlacer.MousePressed();
|
2005-09-05 21:48:28 +02:00
|
|
|
}
|
2004-07-20 21:30:35 +02:00
|
|
|
break;
|
2005-09-06 10:25:41 +02:00
|
|
|
case SDL_BUTTON_RIGHT:
|
|
|
|
right_button_down = true;
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SDL_MOUSEMOTION:
|
2007-05-02 14:07:08 +02:00
|
|
|
if( !g_Mouseover.IsBandbox() && button_down && !g_BuildingPlacer.m_active && !right_button_down )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2006-08-26 23:52:18 +02:00
|
|
|
int deltax = ev->ev.motion.x - button_down_x;
|
|
|
|
int deltay = ev->ev.motion.y - button_down_y;
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
if( abs( deltax ) > 2 || abs( deltay ) > 2 )
|
2007-05-02 14:07:08 +02:00
|
|
|
g_Mouseover.StartBandbox( button_down_x, button_down_y );
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2005-10-20 19:44:56 +02:00
|
|
|
return( IN_PASS );
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
bool IsOnScreen( CEntity* e, void* UNUSED(userdata) )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
2004-07-31 17:57:18 +02:00
|
|
|
CCamera *pCamera=g_Game->GetView()->GetCamera();
|
|
|
|
|
|
|
|
CFrustum frustum = pCamera->GetFrustum();
|
2005-03-18 23:30:23 +01:00
|
|
|
|
2006-08-26 23:52:18 +02:00
|
|
|
if( e->m_actor )
|
|
|
|
return( frustum.IsBoxVisible( CVector3D(), e->m_actor->GetModel()->GetBounds() ) );
|
2005-03-18 23:30:23 +01:00
|
|
|
else
|
|
|
|
// If there's no actor, just treat the entity as a point
|
2006-08-26 23:52:18 +02:00
|
|
|
return( frustum.IsBoxVisible( e->m_graphics_position, CBound() ) );
|
2004-07-20 21:30:35 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
bool IsMouseoverType( CEntity* e, void* UNUSED(userdata) )
|
2004-07-20 21:30:35 +02:00
|
|
|
{
|
|
|
|
std::vector<SMouseoverFader>::iterator it;
|
|
|
|
for( it = g_Mouseover.m_mouseover.begin(); it < g_Mouseover.m_mouseover.end(); it++ )
|
|
|
|
{
|
2006-08-26 23:52:18 +02:00
|
|
|
if( it->isActive && ( (CEntityTemplate*)it->entity->m_base == (CEntityTemplate*)e->m_base )
|
|
|
|
&& ( it->entity->GetPlayer() == e->GetPlayer() ) )
|
2004-07-20 21:30:35 +02:00
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
return( false );
|
2005-05-18 07:32:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void StartCustomSelection()
|
|
|
|
{
|
|
|
|
customSelectionMode = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetInteraction()
|
|
|
|
{
|
|
|
|
customSelectionMode = false;
|
|
|
|
}
|
2005-09-05 21:48:28 +02:00
|
|
|
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
bool CBuildingPlacer::Activate(CStrW& templateName)
|
2005-09-05 21:48:28 +02:00
|
|
|
{
|
|
|
|
if(m_active)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_templateName = templateName;
|
|
|
|
m_active = true;
|
|
|
|
m_clicked = false;
|
|
|
|
m_dragged = false;
|
|
|
|
m_angle = 0;
|
|
|
|
m_timeSinceClick = 0;
|
2005-09-06 10:25:41 +02:00
|
|
|
m_totalTime = 0;
|
|
|
|
m_valid = false;
|
2005-09-06 01:44:21 +02:00
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
m_template = g_EntityTemplateCollection.GetTemplate( m_templateName );
|
2005-09-06 10:25:41 +02:00
|
|
|
|
2006-07-10 01:12:37 +02:00
|
|
|
if( !m_template )
|
2005-12-15 22:59:48 +01:00
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
Deactivate();
|
2005-12-15 22:59:48 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-09-06 10:25:41 +02:00
|
|
|
// m_actor
|
2006-07-10 01:12:37 +02:00
|
|
|
CStr actorName ( m_template->m_actorName ); // convert CStrW->CStr8
|
2006-03-17 04:59:49 +01:00
|
|
|
|
2006-07-30 00:02:11 +02:00
|
|
|
std::set<CStr8> selections;
|
2007-01-08 02:56:46 +01:00
|
|
|
m_actor = g_Game->GetWorld()->GetUnitManager().CreateUnit( actorName, 0, selections );
|
2006-08-08 05:45:13 +02:00
|
|
|
m_actor->SetPlayerID( g_Game->GetLocalPlayer()->GetPlayerID() );
|
2006-04-21 05:06:57 +02:00
|
|
|
|
2005-09-06 10:25:41 +02:00
|
|
|
// m_bounds
|
2006-07-10 01:12:37 +02:00
|
|
|
if( m_template->m_bound_type == CBoundingObject::BOUND_CIRCLE )
|
2005-09-06 10:25:41 +02:00
|
|
|
{
|
2006-07-10 01:12:37 +02:00
|
|
|
m_bounds = new CBoundingCircle( 0, 0, m_template->m_bound_circle );
|
2005-09-06 10:25:41 +02:00
|
|
|
}
|
2006-07-10 01:12:37 +02:00
|
|
|
else if( m_template->m_bound_type == CBoundingObject::BOUND_OABB )
|
2005-09-06 10:25:41 +02:00
|
|
|
{
|
2006-07-10 01:12:37 +02:00
|
|
|
m_bounds = new CBoundingBox( 0, 0, CVector2D(1, 0), m_template->m_bound_box );
|
2005-09-06 10:25:41 +02:00
|
|
|
}
|
2005-09-06 01:44:21 +02:00
|
|
|
|
2005-09-05 21:48:28 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CBuildingPlacer::MousePressed()
|
2005-09-05 21:48:28 +02:00
|
|
|
{
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
CCamera &camera=*g_Game->GetView()->GetCamera();
|
2006-07-10 01:12:37 +02:00
|
|
|
if( m_template->m_socket == L"" )
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
clickPos = camera.GetWorldCoordinates();
|
2005-09-05 21:48:28 +02:00
|
|
|
m_clicked = true;
|
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CBuildingPlacer::MouseReleased()
|
2005-09-05 21:48:28 +02:00
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
Deactivate(); // do it first in case we fail for any reason
|
2005-09-06 01:44:21 +02:00
|
|
|
|
2006-07-10 01:12:37 +02:00
|
|
|
if( m_valid )
|
2005-09-06 10:25:41 +02:00
|
|
|
{
|
2006-07-10 01:12:37 +02:00
|
|
|
// issue a place object command accross the network
|
2006-05-04 09:40:31 +02:00
|
|
|
CPlaceObject *msg = new CPlaceObject();
|
2006-08-25 06:24:06 +02:00
|
|
|
msg->m_IsQueued = hotkeys[HOTKEY_ORDER_QUEUE];
|
2006-05-04 09:40:31 +02:00
|
|
|
msg->m_Entities = g_Selection.m_selected;
|
|
|
|
msg->m_Template = m_templateName;
|
|
|
|
msg->m_X = (u32) (clickPos.X * 1000);
|
|
|
|
msg->m_Y = (u32) (clickPos.Y * 1000);
|
|
|
|
msg->m_Z = (u32) (clickPos.Z * 1000);
|
|
|
|
msg->m_Angle = (u32) (m_angle * 1000);
|
|
|
|
g_Game->GetSimulation()->QueueLocalCommand(msg);
|
2005-09-06 10:25:41 +02:00
|
|
|
}
|
2006-10-06 16:21:16 +02:00
|
|
|
|
|
|
|
if( hotkeys[HOTKEY_ORDER_QUEUE] )
|
|
|
|
{
|
2007-05-02 14:07:08 +02:00
|
|
|
Activate( m_templateName ); // reactivate so we can place more buildings of the same type
|
2006-10-06 16:21:16 +02:00
|
|
|
}
|
2005-09-05 21:48:28 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CBuildingPlacer::Deactivate()
|
2005-09-05 21:48:28 +02:00
|
|
|
{
|
|
|
|
m_active = false;
|
2007-01-08 02:56:46 +01:00
|
|
|
g_Game->GetWorld()->GetUnitManager().RemoveUnit( m_actor );
|
2005-09-06 01:44:21 +02:00
|
|
|
delete m_actor;
|
|
|
|
m_actor = 0;
|
2005-09-06 10:25:41 +02:00
|
|
|
delete m_bounds;
|
|
|
|
m_bounds = 0;
|
2005-09-05 21:48:28 +02:00
|
|
|
}
|
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
void CBuildingPlacer::Update( float timeStep )
|
2005-09-05 21:48:28 +02:00
|
|
|
{
|
|
|
|
if(!m_active)
|
|
|
|
return;
|
|
|
|
|
2005-09-06 10:25:41 +02:00
|
|
|
m_totalTime += timeStep;
|
|
|
|
|
2006-07-10 01:12:37 +02:00
|
|
|
if( m_clicked && m_template->m_socket == L"" )
|
2005-09-05 21:48:28 +02:00
|
|
|
{
|
2006-07-10 01:12:37 +02:00
|
|
|
// Rotate object
|
2005-09-05 21:48:28 +02:00
|
|
|
m_timeSinceClick += timeStep;
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
CCamera &camera = *g_Game->GetView()->GetCamera();
|
|
|
|
CVector3D mousePos = camera.GetWorldCoordinates();
|
2005-09-06 10:25:41 +02:00
|
|
|
CVector3D dif = mousePos - clickPos;
|
2005-09-05 21:48:28 +02:00
|
|
|
float x = dif.X, z = dif.Z;
|
|
|
|
if(x*x + z*z < 3*3) {
|
2006-04-21 05:06:57 +02:00
|
|
|
if(m_dragged || m_timeSinceClick > 0.2f)
|
2005-09-05 21:48:28 +02:00
|
|
|
{
|
|
|
|
m_angle += timeStep * PI;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_dragged = true;
|
|
|
|
m_angle = atan2(x, z);
|
|
|
|
}
|
|
|
|
}
|
2005-09-06 01:44:21 +02:00
|
|
|
|
|
|
|
CVector3D pos;
|
2006-07-10 01:12:37 +02:00
|
|
|
if( m_clicked )
|
2005-09-06 01:44:21 +02:00
|
|
|
{
|
|
|
|
pos = clickPos;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 19:36:42 +02:00
|
|
|
CCamera &camera = *g_Game->GetView()->GetCamera();
|
|
|
|
pos = camera.GetWorldCoordinates();
|
2005-09-06 01:44:21 +02:00
|
|
|
}
|
|
|
|
|
2006-07-10 01:12:37 +02:00
|
|
|
bool onSocket = false;
|
|
|
|
if( m_template->m_socket != L"" )
|
|
|
|
{
|
|
|
|
// If we're on a socket of our type, remember that and snap ourselves to it
|
2007-05-02 14:07:08 +02:00
|
|
|
m_bounds->SetPosition(pos.X, pos.Z); // first, move bounds to mouse pos
|
|
|
|
CEntity* ent = GetCollisionEntity( m_bounds, 0 ); // now, check what we intersect
|
2006-07-10 01:12:37 +02:00
|
|
|
if( ent && ent->m_classes.IsMember( m_template->m_socket ) ) // if it's a socket, snap to it
|
|
|
|
{
|
|
|
|
onSocket = true;
|
|
|
|
m_angle = atan2f( ent->m_ahead.x, ent->m_ahead.y );
|
|
|
|
pos = ent->m_position;
|
|
|
|
clickPos = ent->m_position;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set position and angle to the location we decided on
|
|
|
|
|
2005-09-06 01:44:21 +02:00
|
|
|
CMatrix3D m;
|
2007-01-17 04:25:20 +01:00
|
|
|
m.SetYRotation(m_angle + PI);
|
|
|
|
m.Translate(pos);
|
2005-09-06 01:44:21 +02:00
|
|
|
m_actor->GetModel()->SetTransform( m );
|
2005-09-06 10:25:41 +02:00
|
|
|
|
2007-05-02 14:07:08 +02:00
|
|
|
m_bounds->SetPosition(pos.X, pos.Z);
|
2005-09-06 10:25:41 +02:00
|
|
|
|
2006-07-10 01:12:37 +02:00
|
|
|
if( m_bounds->m_type == CBoundingObject::BOUND_OABB )
|
2005-09-06 10:25:41 +02:00
|
|
|
{
|
|
|
|
CBoundingBox* box = (CBoundingBox*) m_bounds;
|
2007-05-02 14:07:08 +02:00
|
|
|
box->SetOrientation( m_angle );
|
2005-09-06 10:25:41 +02:00
|
|
|
}
|
|
|
|
|
2006-08-08 18:00:47 +02:00
|
|
|
// Check whether the placement location is valid (look at whether we're
|
|
|
|
// on the map, who owns the territory, whether we are on a socket, and
|
2007-01-17 04:25:20 +01:00
|
|
|
// whether we are colliding with anything).
|
2005-09-06 10:25:41 +02:00
|
|
|
CTerrain *pTerrain=g_Game->GetWorld()->GetTerrain();
|
2007-05-02 14:07:08 +02:00
|
|
|
if( pTerrain->IsOnMap( pos.X, pos.Z ) )
|
2006-08-08 05:45:13 +02:00
|
|
|
{
|
|
|
|
// Check that we are being placed in a valid territory; currently, m_territoryRestriction
|
2006-09-17 04:49:29 +02:00
|
|
|
// can be either "Allied" for placing in allied territories, or nothing.
|
|
|
|
// Special case: If the territory has no centre unit, that means the map contains no
|
|
|
|
// Settlements; for testing purposes, let us build anywhere.
|
2006-08-08 05:45:13 +02:00
|
|
|
CTerritory* territory = g_Game->GetWorld()->GetTerritoryManager()->GetTerritory( pos.X, pos.Z );
|
2006-09-18 20:38:29 +02:00
|
|
|
if( m_template->m_territoryRestriction == L"Allied" && (bool)territory->centre
|
2006-09-17 04:49:29 +02:00
|
|
|
&& territory->owner != g_Game->GetLocalPlayer() )
|
2006-08-08 05:45:13 +02:00
|
|
|
{
|
|
|
|
m_valid = false;
|
|
|
|
}
|
2006-08-08 18:00:47 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// It's valid to place the object here if the position is unobstructed by
|
|
|
|
// anything except possibly our socket (which we find out by passing an
|
2007-05-02 14:07:08 +02:00
|
|
|
// ignoreClass to GetCollisionObject); also, if we are a socketed object,
|
2006-08-08 18:00:47 +02:00
|
|
|
// we check that we are actually on a socket, using onSocket (set above).
|
|
|
|
m_valid = ( m_template->m_socket == L"" || onSocket )
|
2007-05-02 14:07:08 +02:00
|
|
|
&& ( GetCollisionObject( m_bounds, 0, &m_template->m_socket ) == 0 );
|
2006-08-08 18:00:47 +02:00
|
|
|
}
|
2006-08-08 05:45:13 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_valid = false;
|
|
|
|
}
|
2006-07-10 01:12:37 +02:00
|
|
|
|
|
|
|
// Flash our actor red if the position is invalid.
|
2005-09-06 10:25:41 +02:00
|
|
|
|
|
|
|
CColor col;
|
2006-07-10 01:12:37 +02:00
|
|
|
if( m_valid )
|
2005-09-06 10:25:41 +02:00
|
|
|
{
|
|
|
|
col = CColor(1.0f, 1.0f, 1.0f, 1.0f);
|
|
|
|
}
|
2006-04-21 05:06:57 +02:00
|
|
|
else
|
2005-09-06 10:25:41 +02:00
|
|
|
{
|
2006-07-10 01:12:37 +02:00
|
|
|
float add = ( sin(4*PI*m_totalTime) + 1.0f ) * 0.08f;
|
|
|
|
col = CColor( 1.4f+add, 0.4f+add, 0.4f+add, 1.0f );
|
2005-09-06 10:25:41 +02:00
|
|
|
}
|
2006-07-10 01:12:37 +02:00
|
|
|
m_actor->GetModel()->SetShadingColor( col );
|
2005-10-07 17:24:29 +02:00
|
|
|
}
|