TraceColor enum

master
krzys-h 2015-07-14 13:42:47 +02:00
parent fdc0081bb8
commit 4506a4b8bd
14 changed files with 196 additions and 141 deletions

View File

@ -192,6 +192,7 @@ set(BASE_SOURCES
object/task/taskturn.cpp object/task/taskturn.cpp
object/task/taskwait.cpp object/task/taskwait.cpp
object/tool_type.cpp object/tool_type.cpp
object/trace_color.cpp
object/subclass/exchange_post.cpp object/subclass/exchange_post.cpp
object/subclass/static_object.cpp object/subclass/static_object.cpp
physics/physics.cpp physics/physics.cpp

View File

@ -798,35 +798,35 @@ bool CBrain::EventProcess(const Event &event)
} }
if ( action == EVENT_OBJECT_PEN1 ) // black if ( action == EVENT_OBJECT_PEN1 ) // black
{ {
err = StartTaskPen(true, 1); err = StartTaskPen(true, TraceColor::Black);
} }
if ( action == EVENT_OBJECT_PEN2 ) // yellow if ( action == EVENT_OBJECT_PEN2 ) // yellow
{ {
err = StartTaskPen(true, 8); err = StartTaskPen(true, TraceColor::Yellow);
} }
if ( action == EVENT_OBJECT_PEN3 ) // orange if ( action == EVENT_OBJECT_PEN3 ) // orange
{ {
err = StartTaskPen(true, 7); err = StartTaskPen(true, TraceColor::Orange);
} }
if ( action == EVENT_OBJECT_PEN4 ) // red if ( action == EVENT_OBJECT_PEN4 ) // red
{ {
err = StartTaskPen(true, 4); err = StartTaskPen(true, TraceColor::Red);
} }
if ( action == EVENT_OBJECT_PEN5 ) // violet if ( action == EVENT_OBJECT_PEN5 ) // violet
{ {
err = StartTaskPen(true, 6); err = StartTaskPen(true, TraceColor::Purple);
} }
if ( action == EVENT_OBJECT_PEN6 ) // blue if ( action == EVENT_OBJECT_PEN6 ) // blue
{ {
err = StartTaskPen(true, 14); err = StartTaskPen(true, TraceColor::Blue);
} }
if ( action == EVENT_OBJECT_PEN7 ) // green if ( action == EVENT_OBJECT_PEN7 ) // green
{ {
err = StartTaskPen(true, 12); err = StartTaskPen(true, TraceColor::Green);
} }
if ( action == EVENT_OBJECT_PEN8 ) // brown if ( action == EVENT_OBJECT_PEN8 ) // brown
{ {
err = StartTaskPen(true, 10); err = StartTaskPen(true, TraceColor::Brown);
} }
if ( action == EVENT_OBJECT_REC ) // registered? if ( action == EVENT_OBJECT_REC ) // registered?
@ -1156,12 +1156,12 @@ Error CBrain::StartTaskTerraform()
// Change pencil. // Change pencil.
Error CBrain::StartTaskPen(bool down, int color) Error CBrain::StartTaskPen(bool down, TraceColor color)
{ {
auto motionVehicle = dynamic_cast<CMotionVehicle*>(m_motion); auto motionVehicle = dynamic_cast<CMotionVehicle*>(m_motion);
assert(motionVehicle != nullptr); assert(motionVehicle != nullptr);
if (color == -1) if (color == TraceColor::Default)
color = motionVehicle->GetTraceColor(); color = motionVehicle->GetTraceColor();
motionVehicle->SetTraceDown(down); motionVehicle->SetTraceDown(down);
@ -2267,7 +2267,6 @@ void CBrain::UpdateInterface()
Ui::CButton* pb; Ui::CButton* pb;
Ui::CSlider* ps; Ui::CSlider* ps;
Ui::CColor* pc; Ui::CColor* pc;
int color;
bool bEnable, bFly, bRun; bool bEnable, bFly, bRun;
char title[100]; char title[100];
@ -2485,46 +2484,46 @@ void CBrain::UpdateInterface()
pb->ClearState(Ui::STATE_CHECK); pb->ClearState(Ui::STATE_CHECK);
} }
color = motionVehicle->GetTraceColor(); TraceColor color = motionVehicle->GetTraceColor();
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN1)); pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN1));
if ( pc != 0 ) if ( pc != 0 )
{ {
pc->SetState(Ui::STATE_CHECK, color==1); pc->SetState(Ui::STATE_CHECK, color == TraceColor::Black);
} }
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN2)); pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN2));
if ( pc != 0 ) if ( pc != 0 )
{ {
pc->SetState(Ui::STATE_CHECK, color==8); pc->SetState(Ui::STATE_CHECK, color == TraceColor::Yellow);
} }
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN3)); pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN3));
if ( pc != 0 ) if ( pc != 0 )
{ {
pc->SetState(Ui::STATE_CHECK, color==7); pc->SetState(Ui::STATE_CHECK, color == TraceColor::Orange);
} }
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN4)); pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN4));
if ( pc != 0 ) if ( pc != 0 )
{ {
pc->SetState(Ui::STATE_CHECK, color==4); pc->SetState(Ui::STATE_CHECK, color == TraceColor::Red);
} }
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN5)); pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN5));
if ( pc != 0 ) if ( pc != 0 )
{ {
pc->SetState(Ui::STATE_CHECK, color==6); pc->SetState(Ui::STATE_CHECK, color == TraceColor::Purple);
} }
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN6)); pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN6));
if ( pc != 0 ) if ( pc != 0 )
{ {
pc->SetState(Ui::STATE_CHECK, color==14); pc->SetState(Ui::STATE_CHECK, color == TraceColor::Blue);
} }
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN7)); pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN7));
if ( pc != 0 ) if ( pc != 0 )
{ {
pc->SetState(Ui::STATE_CHECK, color==12); pc->SetState(Ui::STATE_CHECK, color == TraceColor::Green);
} }
pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN8)); pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN8));
if ( pc != 0 ) if ( pc != 0 )
{ {
pc->SetState(Ui::STATE_CHECK, color==10); pc->SetState(Ui::STATE_CHECK, color == TraceColor::Brown);
} }
} }
else else
@ -2930,7 +2929,7 @@ void CBrain::TraceRecordStart()
} }
else // pen up? else // pen up?
{ {
m_traceColor = -1; m_traceColor = TraceColor::Default;
} }
delete[] m_traceRecordBuffer; delete[] m_traceRecordBuffer;
@ -2945,7 +2944,6 @@ void CBrain::TraceRecordFrame()
TraceOper oper = TO_STOP; TraceOper oper = TO_STOP;
Math::Vector pos; Math::Vector pos;
float angle, len, speed; float angle, len, speed;
int color;
CMotionVehicle* motionVehicle = dynamic_cast<CMotionVehicle*>(m_motion); CMotionVehicle* motionVehicle = dynamic_cast<CMotionVehicle*>(m_motion);
assert(motionVehicle != nullptr); assert(motionVehicle != nullptr);
@ -2957,14 +2955,11 @@ void CBrain::TraceRecordFrame()
speed = m_physics->GetCirMotionY(MO_REASPEED); speed = m_physics->GetCirMotionY(MO_REASPEED);
if ( speed != 0.0f ) oper = TO_TURN; if ( speed != 0.0f ) oper = TO_TURN;
TraceColor color = TraceColor::Default;
if ( motionVehicle->GetTraceDown() ) // pencil down? if ( motionVehicle->GetTraceDown() ) // pencil down?
{ {
color = motionVehicle->GetTraceColor(); color = motionVehicle->GetTraceColor();
} }
else // pen up?
{
color = -1;
}
if ( oper != m_traceOper || if ( oper != m_traceOper ||
color != m_traceColor ) color != m_traceColor )

View File

@ -31,6 +31,7 @@
#include "object/task/taskmanip.h" #include "object/task/taskmanip.h"
#include "object/task/taskflag.h" #include "object/task/taskflag.h"
#include "object/task/taskshield.h" #include "object/task/taskshield.h"
#include "object/trace_color.h"
#include <vector> #include <vector>
@ -155,7 +156,7 @@ public:
int GetProgramIndex(Program* program); int GetProgramIndex(Program* program);
protected: protected:
Error StartTaskPen(bool down, int color = -1); Error StartTaskPen(bool down, TraceColor color = TraceColor::Default);
bool EventFrame(const Event &event); bool EventFrame(const Event &event);
@ -236,8 +237,7 @@ protected:
TraceOper m_traceOper; TraceOper m_traceOper;
Math::Vector m_tracePos; Math::Vector m_tracePos;
float m_traceAngle; float m_traceAngle;
int m_traceColor; TraceColor m_traceColor;
int m_traceRecordIndex; int m_traceRecordIndex;
TraceRecord* m_traceRecordBuffer; TraceRecord* m_traceRecordBuffer;
}; };

View File

@ -68,7 +68,7 @@ CMotionVehicle::CMotionVehicle(COldObject* object) : CMotion(object)
m_bFlyFix = false; m_bFlyFix = false;
m_bTraceDown = false; m_bTraceDown = false;
m_traceColor = 1; // black m_traceColor = TraceColor::Black; // black
m_traceWidth = 0.5f; m_traceWidth = 0.5f;
} }
@ -1909,12 +1909,12 @@ void CMotionVehicle::SetTraceDown(bool bDown)
m_bTraceDown = bDown; m_bTraceDown = bDown;
} }
int CMotionVehicle::GetTraceColor() TraceColor CMotionVehicle::GetTraceColor()
{ {
return m_traceColor; return m_traceColor;
} }
void CMotionVehicle::SetTraceColor(int color) void CMotionVehicle::SetTraceColor(TraceColor color)
{ {
m_traceColor = color; m_traceColor = color;
} }
@ -1928,4 +1928,3 @@ void CMotionVehicle::SetTraceWidth(float width)
{ {
m_traceWidth = width; m_traceWidth = width;
} }

View File

@ -17,12 +17,11 @@
* along with this program. If not, see http://gnu.org/licenses * along with this program. If not, see http://gnu.org/licenses
*/ */
// motionvehicle.h
#pragma once #pragma once
#include "object/motion/motion.h" #include "object/motion/motion.h"
#include "object/trace_color.h"
@ -38,8 +37,8 @@ public:
bool GetTraceDown(); bool GetTraceDown();
void SetTraceDown(bool bDown); void SetTraceDown(bool bDown);
int GetTraceColor(); TraceColor GetTraceColor();
void SetTraceColor(int color); void SetTraceColor(TraceColor color);
float GetTraceWidth(); float GetTraceWidth();
void SetTraceWidth(float width); void SetTraceWidth(float width);
@ -66,7 +65,6 @@ protected:
Math::Vector m_posKey; Math::Vector m_posKey;
bool m_bFlyFix; bool m_bFlyFix;
bool m_bTraceDown; bool m_bTraceDown;
int m_traceColor; TraceColor m_traceColor;
float m_traceWidth; float m_traceWidth;
}; };

View File

@ -156,7 +156,7 @@ Error CTaskManager::StartTaskTerraform()
// Changes the pencil. // Changes the pencil.
Error CTaskManager::StartTaskPen(bool bDown, int color) Error CTaskManager::StartTaskPen(bool bDown, TraceColor color)
{ {
m_task = new CTaskPen(m_object); m_task = new CTaskPen(m_object);
return (static_cast<CTaskPen*>(m_task))->Start(bDown, color); return (static_cast<CTaskPen*>(m_task))->Start(bDown, color);
@ -263,4 +263,3 @@ bool CTaskManager::Abort()
if ( m_task == 0 ) return false; if ( m_task == 0 ) return false;
return m_task->Abort(); return m_task->Abort();
} }

View File

@ -27,6 +27,7 @@
#include "object/task/taskgoto.h" #include "object/task/taskgoto.h"
#include "object/task/taskshield.h" #include "object/task/taskshield.h"
#include "object/task/taskflag.h" #include "object/task/taskflag.h"
#include "object/trace_color.h"
@ -48,7 +49,7 @@ public:
Error StartTaskDeleteMark(); Error StartTaskDeleteMark();
Error StartTaskInfo(const char *name, float value, float power, bool bSend); Error StartTaskInfo(const char *name, float value, float power, bool bSend);
Error StartTaskTerraform(); Error StartTaskTerraform();
Error StartTaskPen(bool bDown, int color); Error StartTaskPen(bool bDown, TraceColor color);
Error StartTaskRecover(); Error StartTaskRecover();
Error StartTaskShield(TaskShieldMode mode, float delay); Error StartTaskShield(TaskShieldMode mode, float delay);
Error StartTaskFire(float delay); Error StartTaskFire(float delay);
@ -67,4 +68,3 @@ protected:
COldObject* m_object; COldObject* m_object;
bool m_bPilot; bool m_bPilot;
}; };

View File

@ -129,7 +129,7 @@ bool CTaskPen::EventProcess(const Event &event)
// Assigns the goal has achieved. // Assigns the goal has achieved.
Error CTaskPen::Start(bool bDown, int color) Error CTaskPen::Start(bool bDown, TraceColor color)
{ {
Math::Vector pos; Math::Vector pos;
Math::Matrix* mat; Math::Matrix* mat;
@ -262,26 +262,28 @@ int CTaskPen::AngleToRank(float angle)
// Converting a color to the angle of carousel of pencils. // Converting a color to the angle of carousel of pencils.
float CTaskPen::ColorToAngle(int color) float CTaskPen::ColorToAngle(TraceColor color)
{ {
return -45.0f*Math::PI/180.0f*ColorToRank(color); return -45.0f*Math::PI/180.0f*ColorToRank(color);
} }
// Converting a color number to the pencil (0 .. 7). // Converting a color number to the pencil (0 .. 7).
int CTaskPen::ColorToRank(int color) int CTaskPen::ColorToRank(TraceColor color)
{ {
if ( color == 8 ) return 1; // yellow if ( color == TraceColor::Yellow ) return 1; // yellow
if ( color == 7 ) return 2; // orange if ( color == TraceColor::Orange ) return 2; // orange
if ( color == 5 ) return 2; // pink if ( color == TraceColor::Pink ) return 2; // pink
if ( color == 4 ) return 3; // red if ( color == TraceColor::Red ) return 3; // red
if ( color == 6 ) return 4; // purple if ( color == TraceColor::Purple ) return 4; // purple
if ( color == 14 ) return 5; // blue if ( color == TraceColor::Blue ) return 5; // blue
if ( color == 15 ) return 5; // light blue if ( color == TraceColor::LightBlue ) return 5; // light blue
if ( color == 12 ) return 6; // green if ( color == TraceColor::Green ) return 6; // green
if ( color == 13 ) return 6; // light green if ( color == TraceColor::LightGreen ) return 6; // light green
if ( color == 10 ) return 7; // brown if ( color == TraceColor::Brown ) return 7; // brown
if ( color == 9 ) return 7; // beige if ( color == TraceColor::Beige ) return 7; // beige
if ( color == TraceColor::RedArrow ) return 3; // red
return 0; // black return 0; // black
} }

View File

@ -23,6 +23,7 @@
#include "object/task/task.h" #include "object/task/task.h"
#include "object/trace_color.h"
#include "math/vector.h" #include "math/vector.h"
@ -44,15 +45,15 @@ public:
bool EventProcess(const Event &event); bool EventProcess(const Event &event);
Error Start(bool bDown, int color); Error Start(bool bDown, TraceColor color);
Error IsEnded(); Error IsEnded();
bool Abort(); bool Abort();
protected: protected:
void SoundManip(float time, float amplitude, float frequency); void SoundManip(float time, float amplitude, float frequency);
int AngleToRank(float angle); int AngleToRank(float angle);
float ColorToAngle(int color); float ColorToAngle(TraceColor color);
int ColorToRank(int color); int ColorToRank(TraceColor color);
protected: protected:
bool m_bError; bool m_bError;
@ -68,4 +69,3 @@ protected:
float m_newAngle; float m_newAngle;
float m_timeDown; float m_timeDown;
}; };

View File

@ -0,0 +1,44 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#include "object/trace_color.h"
std::string TraceColorName(TraceColor color)
{
switch(color) {
case TraceColor::White: return "White"; break;
case TraceColor::Black: return "Black"; break;
case TraceColor::Gray: return "Gray"; break;
case TraceColor::LightGray: return "LightGray"; break;
case TraceColor::Red: return "Red"; break;
case TraceColor::Pink: return "Pink"; break;
case TraceColor::Purple: return "Purple"; break;
case TraceColor::Orange: return "Orange"; break;
case TraceColor::Yellow: return "Yellow"; break;
case TraceColor::Beige: return "Beige"; break;
case TraceColor::Brown: return "Brown"; break;
case TraceColor::Skin: return "Skin"; break;
case TraceColor::Green: return "Green"; break;
case TraceColor::LightGreen: return "LightGreen"; break;
case TraceColor::Blue: return "Blue"; break;
case TraceColor::LightBlue: return "LightBlue"; break;
case TraceColor::RedArrow: return "RedArrow"; break;
case TraceColor::BlackArrow: return "BlackArrow"; break;
default: return ""; break;
}
}

47
src/object/trace_color.h Normal file
View File

@ -0,0 +1,47 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://gnu.org/licenses
*/
#pragma once
#include <string>
enum class TraceColor : int {
Default = -1,
White = 0,
Black = 1,
Gray = 2,
LightGray = 3,
Red = 4,
Pink = 5,
Purple = 6,
Orange = 7,
Yellow = 8,
Beige = 9,
Brown = 10,
Skin = 11,
Green = 12,
LightGreen = 13,
Blue = 14,
LightBlue = 15,
RedArrow = 16,
BlackArrow = 17,
Max,
};
std::string TraceColorName(TraceColor c);

View File

@ -2423,7 +2423,7 @@ void CPhysics::FloorAdapt(float aTime, float rTime,
} }
else else
{ {
WheelParticle(-1, 0.0f); WheelParticle(TraceColor::Default, 0.0f);
} }
} }
@ -3748,7 +3748,7 @@ void CPhysics::WaterParticle(float aTime, Math::Vector pos, ObjectType type,
// Creates the trace under the robot. // Creates the trace under the robot.
void CPhysics::WheelParticle(int color, float width) void CPhysics::WheelParticle(TraceColor color, float width)
{ {
Math::Matrix* mat; Math::Matrix* mat;
Math::Vector goal1, goal2, wheel1, wheel2; Math::Vector goal1, goal2, wheel1, wheel2;
@ -3758,11 +3758,11 @@ void CPhysics::WheelParticle(int color, float width)
mat = m_object->GetWorldMatrix(0); mat = m_object->GetWorldMatrix(0);
// Draw a trace on the ground. // Draw a trace on the ground.
if ( color >= 0 && color <= 17 ) if ( color != TraceColor::Default )
{ {
parti = static_cast<Gfx::ParticleType>(Gfx::PARTITRACE0+color); parti = static_cast<Gfx::ParticleType>(Gfx::PARTITRACE0+static_cast<int>(color));
step = 2.0f; step = 2.0f;
if ( color >= 16 ) step = 4.0f; // arrow? if ( static_cast<int>(color) >= static_cast<int>(TraceColor::RedArrow) ) step = 4.0f; // arrow?
step /= m_engine->GetTracePrecision(); step /= m_engine->GetTracePrecision();
goal1.x = step/2.0f; goal1.x = step/2.0f;
@ -3892,4 +3892,3 @@ float CPhysics::GetFallDamageFraction()
{ {
return m_fallDamageFraction; return m_fallDamageFraction;
} }

View File

@ -30,6 +30,7 @@
#include "math/vector.h" #include "math/vector.h"
#include "object/object_type.h" #include "object/object_type.h"
#include "object/trace_color.h"
class CObject; class CObject;
@ -205,7 +206,7 @@ protected:
void CrashParticle(float crash); void CrashParticle(float crash);
void MotorParticle(float aTime, float rTime); void MotorParticle(float aTime, float rTime);
void WaterParticle(float aTime, Math::Vector pos, ObjectType type, float floor, float advance, float turn); void WaterParticle(float aTime, Math::Vector pos, ObjectType type, float floor, float advance, float turn);
void WheelParticle(int color, float width); void WheelParticle(TraceColor color, float width);
void SetFalling(); void SetFalling();
protected: protected:
@ -268,4 +269,3 @@ protected:
float m_fallDamageFraction; float m_fallDamageFraction;
float m_minFallingHeight; float m_minFallingHeight;
}; };

View File

@ -36,6 +36,7 @@
#include "object/brain.h" #include "object/brain.h"
#include "object/object.h" #include "object/object.h"
#include "object/object_manager.h" #include "object/object_manager.h"
#include "object/trace_color.h"
#include "object/robotmain.h" #include "object/robotmain.h"
#include "object/task/taskmanager.h" #include "object/task/taskmanager.h"
#include "object/subclass/exchange_post.h" #include "object/subclass/exchange_post.h"
@ -1642,6 +1643,11 @@ bool CScriptFunctions::rProduce(CBotVar* var, CBotVar* result, int& exception, v
result->SetValInt(1); // error result->SetValInt(1); // error
return true; return true;
} }
if(type == OBJECT_MOBILEdr)
{
assert(object->Implements(ObjectInterfaceType::Old)); // TODO: temporary hack
dynamic_cast<COldObject*>(object)->SetManual(true);
}
script->m_main->CreateShortcuts(); script->m_main->CreateShortcuts();
} }
@ -2934,30 +2940,30 @@ bool CScriptFunctions::rPenDown(CBotVar* var, CBotVar* result, int& exception, v
CMotionVehicle* motionVehicle = dynamic_cast<CMotionVehicle*>(pThis->GetMotion()); CMotionVehicle* motionVehicle = dynamic_cast<CMotionVehicle*>(pThis->GetMotion());
assert(motionVehicle != nullptr); assert(motionVehicle != nullptr);
exception = 0;
if ( var != 0 )
{
color = var->GetValInt();
if ( color < 0 ) color = 0;
if ( color > static_cast<int>(TraceColor::Max) ) color = static_cast<int>(TraceColor::Max);
motionVehicle->SetTraceColor(static_cast<TraceColor>(color));
var = var->GetNext();
if ( var != 0 )
{
width = var->GetValFloat();
if ( width < 0.1f ) width = 0.1f;
if ( width > 1.0f ) width = 1.0f;
motionVehicle->SetTraceWidth(width);
}
}
motionVehicle->SetTraceDown(true);
if ( pThis->GetType() == OBJECT_MOBILEdr ) if ( pThis->GetType() == OBJECT_MOBILEdr )
{ {
exception = 0;
if ( script->m_primaryTask == 0 ) // no task in progress? if ( script->m_primaryTask == 0 ) // no task in progress?
{ {
if ( var != 0 )
{
color = var->GetValInt();
if ( color < 0 ) color = 0;
if ( color > 17 ) color = 17;
motionVehicle->SetTraceColor(color);
var = var->GetNext();
if ( var != 0 )
{
width = var->GetValFloat();
if ( width < 0.1f ) width = 0.1f;
if ( width > 1.0f ) width = 1.0f;
motionVehicle->SetTraceWidth(width);
}
}
motionVehicle->SetTraceDown(true);
script->m_primaryTask = new CTaskManager(script->m_object); script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskPen(motionVehicle->GetTraceDown(), motionVehicle->GetTraceColor()); err = script->m_primaryTask->StartTaskPen(motionVehicle->GetTraceDown(), motionVehicle->GetTraceColor());
if ( err != ERR_OK ) if ( err != ERR_OK )
@ -2977,24 +2983,6 @@ bool CScriptFunctions::rPenDown(CBotVar* var, CBotVar* result, int& exception, v
} }
else else
{ {
if ( var != 0 )
{
color = var->GetValInt();
if ( color < 0 ) color = 0;
if ( color > 17 ) color = 17;
motionVehicle->SetTraceColor(color);
var = var->GetNext();
if ( var != 0 )
{
width = var->GetValFloat();
if ( width < 0.1f ) width = 0.1f;
if ( width > 1.0f ) width = 1.0f;
motionVehicle->SetTraceWidth(width);
}
}
motionVehicle->SetTraceDown(true);
return true; return true;
} }
} }
@ -3010,10 +2998,12 @@ bool CScriptFunctions::rPenUp(CBotVar* var, CBotVar* result, int& exception, voi
CMotionVehicle* motionVehicle = dynamic_cast<CMotionVehicle*>(pThis->GetMotion()); CMotionVehicle* motionVehicle = dynamic_cast<CMotionVehicle*>(pThis->GetMotion());
assert(motionVehicle != nullptr); assert(motionVehicle != nullptr);
exception = 0;
motionVehicle->SetTraceDown(false);
if ( pThis->GetType() == OBJECT_MOBILEdr ) if ( pThis->GetType() == OBJECT_MOBILEdr )
{ {
exception = 0;
if ( script->m_primaryTask == 0 ) // no task in progress? if ( script->m_primaryTask == 0 ) // no task in progress?
{ {
motionVehicle->SetTraceDown(false); motionVehicle->SetTraceDown(false);
@ -3037,7 +3027,6 @@ bool CScriptFunctions::rPenUp(CBotVar* var, CBotVar* result, int& exception, voi
} }
else else
{ {
motionVehicle->SetTraceDown(false);
return true; return true;
} }
} }
@ -3054,17 +3043,17 @@ bool CScriptFunctions::rPenColor(CBotVar* var, CBotVar* result, int& exception,
CMotionVehicle* motionVehicle = dynamic_cast<CMotionVehicle*>(pThis->GetMotion()); CMotionVehicle* motionVehicle = dynamic_cast<CMotionVehicle*>(pThis->GetMotion());
assert(motionVehicle != nullptr); assert(motionVehicle != nullptr);
exception = 0;
color = var->GetValInt();
if ( color < 0 ) color = 0;
if ( color > static_cast<int>(TraceColor::Max) ) color = static_cast<int>(TraceColor::Max);
motionVehicle->SetTraceColor(static_cast<TraceColor>(color));
if ( pThis->GetType() == OBJECT_MOBILEdr ) if ( pThis->GetType() == OBJECT_MOBILEdr )
{ {
exception = 0;
if ( script->m_primaryTask == 0 ) // no task in progress? if ( script->m_primaryTask == 0 ) // no task in progress?
{ {
color = var->GetValInt();
if ( color < 0 ) color = 0;
if ( color > 17 ) color = 17;
motionVehicle->SetTraceColor(color);
script->m_primaryTask = new CTaskManager(script->m_object); script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskPen(motionVehicle->GetTraceDown(), motionVehicle->GetTraceColor()); err = script->m_primaryTask->StartTaskPen(motionVehicle->GetTraceDown(), motionVehicle->GetTraceColor());
if ( err != ERR_OK ) if ( err != ERR_OK )
@ -3084,11 +3073,6 @@ bool CScriptFunctions::rPenColor(CBotVar* var, CBotVar* result, int& exception,
} }
else else
{ {
color = var->GetValInt();
if ( color < 0 ) color = 0;
if ( color > 17 ) color = 17;
motionVehicle->SetTraceColor(color);
return true; return true;
} }
} }
@ -3676,24 +3660,11 @@ void CScriptFunctions::Init()
} }
CBotProgram::DefineNum("Any", OBJECT_NULL); CBotProgram::DefineNum("Any", OBJECT_NULL);
CBotProgram::DefineNum("White", 0); for (int i = 0; i < static_cast<int>(TraceColor::Max); i++)
CBotProgram::DefineNum("Black", 1); {
CBotProgram::DefineNum("Gray", 2); TraceColor color = static_cast<TraceColor>(i);
CBotProgram::DefineNum("LightGray", 3); CBotProgram::DefineNum(TraceColorName(color).c_str(), static_cast<int>(color));
CBotProgram::DefineNum("Red", 4); }
CBotProgram::DefineNum("Pink", 5);
CBotProgram::DefineNum("Purple", 6);
CBotProgram::DefineNum("Orange", 7);
CBotProgram::DefineNum("Yellow", 8);
CBotProgram::DefineNum("Beige", 9);
CBotProgram::DefineNum("Brown", 10);
CBotProgram::DefineNum("Skin", 11);
CBotProgram::DefineNum("Green", 12);
CBotProgram::DefineNum("LightGreen", 13);
CBotProgram::DefineNum("Blue", 14);
CBotProgram::DefineNum("LightBlue", 15);
CBotProgram::DefineNum("BlackArrow", 16);
CBotProgram::DefineNum("RedArrow", 17);
CBotProgram::DefineNum("InFront", TMA_FFRONT); CBotProgram::DefineNum("InFront", TMA_FFRONT);
CBotProgram::DefineNum("Behind", TMA_FBACK); CBotProgram::DefineNum("Behind", TMA_FBACK);