Merge branch 'lua_versions' into main/rendor-staging
[ryzomcore.git] / snowballs2 / client / src / radar.cpp
blob1bfacb132d1fd1bcfdbbe6334c4c29730f28389c
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 // Includes
21 #include <nel/misc/types_nl.h>
23 #include <vector>
25 #include <nel/misc/vector.h>
26 #include <nel/misc/matrix.h>
27 #include <nel/misc/command.h>
29 #include <nel/3d/u_material.h>
30 #include <nel/3d/u_camera.h>
31 #include <nel/3d/u_driver.h>
32 #include <nel/3d/u_text_context.h>
33 #include <nel/3d/u_texture.h>
35 #include "camera.h"
36 #include "snowballs_client.h"
37 #include "commands.h"
38 #include "mouse_listener.h"
39 #include "entities.h"
42 // Namespaces
45 using namespace NLMISC;
46 using namespace NL3D;
47 using namespace std;
49 namespace SBCLIENT {
52 // Variables
55 // These variables are automatically set with the config file
57 static float RadarPosX, RadarPosY, RadarWidth, RadarHeight;
58 static uint RadarMinDistance, RadarMaxDistance;
59 static CRGBA RadarBackColor, RadarFrontColor, RadarSelfColor, RadarOtherColor, RadarPlaceColor;
60 static float RadarEntitySize;
61 static uint RadarFontSize;
62 static float RadarLittlePosX, RadarLittlePosY, RadarLittleRadius;
63 static NL3D::UMaterial RadarMaterial = NULL;
65 uint RadarState;
66 uint RadarDistance;
69 // Functions
72 // Structure for particular places
73 struct RadarParticularPlace
75 RadarParticularPlace (float X, float Y, string Name) : x(X), y(Y), name(Name) { }
76 float x, y;
77 string name;
80 // Container for the particular places (automatically filled by the config file)
81 vector<RadarParticularPlace> RadarParticularPlaces;
84 /*********************************************************\
85 displayRadar()
86 \*********************************************************/
87 void displayRadar ()
89 float xLeft = RadarPosX;
90 float xRight = RadarPosX + RadarWidth;
91 float yTop = RadarPosY + RadarHeight;
92 float yBottom = RadarPosY;
93 float xCenter = RadarPosX + RadarWidth/2.0f;
94 float yCenter = RadarPosY + RadarHeight/2.0f;
96 Driver->setMatrixMode2D11 ();
98 // Background
99 RadarMaterial.setColor(RadarBackColor);
100 CQuad quad;
101 quad.V0.set(xLeft,yBottom,0);
102 quad.V1.set(xRight,yBottom,0);
103 quad.V2.set(xRight,yTop,0);
104 quad.V3.set(xLeft,yTop,0);
105 Driver->drawQuad (quad, RadarMaterial);
107 // Print radar's range
108 TextContext->setHotSpot(UTextContext::TopRight);
109 TextContext->setColor(RadarFrontColor);
110 TextContext->setFontSize(RadarFontSize);
111 TextContext->printfAt(xRight-0.01f,yTop-0.01f,"%d m",RadarDistance);
113 // Radar unit
114 float stepV = 50.0f;
115 float stepH = stepV*3.f/4.f;
116 // Changing scale
117 stepV = 0.8f*stepV/RadarDistance;
118 stepH = 0.8f*stepH/RadarDistance;
120 // Drawing radar's lines
121 float gapV = stepV/2;
122 float gapH = stepH/2;
124 CLine line;
125 RadarMaterial.setColor(RadarFrontColor);
126 while(gapH<=RadarWidth/2.0)
128 // v lines
129 line.V0.set(xCenter+gapH, yTop, 0);
130 line.V1.set(xCenter+gapH, yBottom, 0);
131 Driver->drawLine(line, RadarMaterial);
132 //Driver->drawLine (xCenter+gapH,yTop,xCenter+gapH,yBottom,RadarFrontColor);
133 line.V0.set(xCenter-gapH, yTop, 0);
134 line.V1.set(xCenter-gapH, yBottom, 0);
135 Driver->drawLine(line, RadarMaterial);
136 //Driver->drawLine (xCenter-gapH,yTop,xCenter-gapH,yBottom,RadarFrontColor);
138 gapH += stepH;
141 while(gapV<=RadarHeight/2.0)
143 // h lines
144 line.V0.set(xLeft, yCenter+gapV, 0);
145 line.V1.set(xRight, yCenter+gapV, 0);
146 Driver->drawLine(line, RadarMaterial);
147 //Driver->drawLine (xLeft,yCenter+gapV,xRight,yCenter+gapV,RadarFrontColor);
148 line.V0.set(xLeft, yCenter-gapV, 0);
149 line.V1.set(xRight, yCenter-gapV, 0);
150 Driver->drawLine(line, RadarMaterial);
151 //Driver->drawLine (xLeft,yCenter-gapV,xRight,yCenter-gapV,RadarFrontColor);
153 gapV += stepV;
156 float scale = 1.0f;
158 float xscreen = xCenter;
159 float yscreen = yCenter;
161 Driver->setFrustum (CFrustum(0.f, 1.0f, 0.f, 1.f, -1.f, 1.f, false));
163 // distance between user and neighbour player
164 float myPosx = Self->Position.x;
165 float myPosy = Self->Position.y;
167 // Quads size
168 float radius = RadarEntitySize;
170 // Arrow in center (user)
171 RadarMaterial.setColor(RadarSelfColor);
172 CTriangle triangle;
173 triangle.V0.set(xscreen-2*radius, yscreen-2*radius, 0);
174 triangle.V1.set(xscreen, yscreen-radius, 0);
175 triangle.V2.set(xscreen, yscreen+2*radius, 0);
176 Driver->drawTriangle(triangle, RadarMaterial);
177 //Driver->drawTriangle(xscreen-2*radius,yscreen-2*radius, xscreen,yscreen-radius, xscreen,yscreen+2*radius, RadarSelfColor);
178 triangle.V0.set(xscreen, yscreen-radius, 0);
179 triangle.V1.set(xscreen+2*radius, yscreen-2*radius, 0);
180 triangle.V2.set(xscreen, yscreen+2*radius, 0);
181 Driver->drawTriangle(triangle, RadarMaterial);
182 //Driver->drawTriangle(xscreen,yscreen-radius, xscreen+2*radius,yscreen-2*radius, xscreen,yscreen+2*radius, RadarSelfColor);
184 TextContext->setColor(RadarOtherColor);
185 RadarMaterial.setColor(RadarOtherColor);
187 for(EIT eit=Entities.begin(); eit!=Entities.end(); eit++)
189 if((*eit).second.Type == CEntity::Other)
191 CVector playerPos = (*eit).second.Position;
193 // position of neighbour
194 float posx = playerPos.x;
195 float posy = playerPos.y;
197 // relative position
198 posx = (posx-myPosx)*0.4f/RadarDistance;
199 posy = (posy-myPosy)*0.4f/RadarDistance;
201 float dist = (float) sqrt((posx*posx)+(posy*posy));
203 // Display a quad to show a player
204 float an;
205 float az;
206 float x;
207 float y;
208 az = MouseListener->getOrientation ();
209 if(posx==0)
211 if(posy==0)
213 x = xscreen;
214 y = yscreen;
216 else
218 if(posy>0)
220 x = (float) (xscreen - dist*cos(Pi-az)*3.f/4.f);
221 y = (float) (yscreen - dist*sin(Pi-az));
223 else
225 x = (float) (xscreen - dist*cos(-az)*3.f/4.f);
226 y = (float) (yscreen - dist*sin(-az));
230 else
232 an = (float) atan(posy/posx);
233 if(posx<0) an = an + (float)Pi;
234 x = (float) (xscreen - dist*cos(-Pi/2 + an-az)*3.f/4.f);
235 y = (float) (yscreen - dist*sin(-Pi/2 + an-az));
238 // Players out of range are not displayed
239 if(x<xLeft || x>xRight || y>yTop || y<yBottom) continue;
241 TextContext->setColor(RadarOtherColor);
243 quad.V0.set(x-radius, y+radius, 0);
244 quad.V1.set(x+radius, y+radius, 0);
245 quad.V2.set(x+radius, y-radius, 0);
246 quad.V3.set(x-radius, y-radius, 0);
247 Driver->drawQuad(quad, RadarMaterial);
248 //Driver->drawQuad (x-radius,y-radius, x+radius,y+radius,RadarOtherColor);
250 // Print his name
251 TextContext->setFontSize(RadarFontSize);
252 if(x>=xCenter)
254 if(y>=yCenter)
256 TextContext->setHotSpot(UTextContext::BottomLeft);
257 TextContext->printfAt(x+2*radius, y+2*radius, (*eit).second.Name.c_str());
259 else
261 TextContext->setHotSpot(UTextContext::TopLeft);
262 TextContext->printfAt(x+2*radius, y-2*radius, (*eit).second.Name.c_str());
265 else
267 if(y>=yCenter)
269 TextContext->setHotSpot(UTextContext::BottomRight);
270 TextContext->printfAt(x-2*radius, y+2*radius, (*eit).second.Name.c_str());
272 else
274 TextContext->setHotSpot(UTextContext::TopRight);
275 TextContext->printfAt(x-2*radius, y-2*radius, (*eit).second.Name.c_str());
281 // display particular places
282 RadarMaterial.setColor(RadarPlaceColor);
283 for(uint i = 0; i < RadarParticularPlaces.size(); i++)
285 // relative position
286 float posx = (RadarParticularPlaces[i].x-myPosx)*0.4f/RadarDistance;
287 float posy = (RadarParticularPlaces[i].y-myPosy)*0.4f/RadarDistance;
289 float dist = (float) sqrt((posx*posx)+(posy*posy));
291 // Display a quad to show a player
292 float an;
293 float az;
294 float x;
295 float y;
296 az = MouseListener->getOrientation ();
297 if(posx==0)
299 if(posy==0)
301 x = xscreen;
302 y = yscreen;
304 else
306 if(posy>0)
308 x = (float) (xscreen - dist*cos(Pi-az)*3.f/4.f);
309 y = (float) (yscreen - dist*sin(Pi-az));
311 else
313 x = (float) (xscreen - dist*cos(-az)*3.f/4.f);
314 y = (float) (yscreen - dist*sin(-az));
318 else
320 an = (float) atan(posy/posx);
321 if(posx<0) an = an + (float)Pi;
322 x = (float) (xscreen - dist*cos(-Pi/2 + an-az)*3.f/4.f);
323 y = (float) (yscreen - dist*sin(-Pi/2 + an-az));
327 if(x<xLeft || x>xRight || y>yTop || y<yBottom)
329 continue;
332 triangle.V0.set(x-radius, y-radius, 0);
333 triangle.V1.set(x+radius, y-radius, 0);
334 triangle.V2.set(x, y+radius, 0);
335 Driver->drawTriangle(triangle, RadarMaterial);
336 //Driver->drawTriangle(x-radius,y-radius, x+radius,y-radius, x,y+radius, RadarPlaceColor);
338 TextContext->setFontSize(RadarFontSize);
339 TextContext->setColor(RadarPlaceColor);
341 if(x>=xCenter)
343 if(y>=yCenter)
345 TextContext->setHotSpot(UTextContext::BottomLeft);
346 TextContext->printfAt(x+2*radius, y+2*radius, RadarParticularPlaces[i].name.c_str());
348 else
350 TextContext->setHotSpot(UTextContext::TopLeft);
351 TextContext->printfAt(x+2*radius, y-2*radius, RadarParticularPlaces[i].name.c_str());
354 else
356 if(y>=yCenter)
358 TextContext->setHotSpot(UTextContext::BottomRight);
359 TextContext->printfAt(x-2*radius, y+2*radius, RadarParticularPlaces[i].name.c_str());
361 else
363 TextContext->setHotSpot(UTextContext::TopRight);
364 TextContext->printfAt(x-2*radius, y-2*radius, RadarParticularPlaces[i].name.c_str());
370 /*********************************************************\
371 displayLittleRadar()
372 \*********************************************************/
373 void displayLittleRadar()
375 float radius = RadarLittleRadius;
377 float xLeft = RadarLittlePosX - radius*3.f/4.f;
378 float yBottom = RadarLittlePosY - radius;
380 float xRight = RadarLittlePosX + radius*3.f/4.f;
381 float yTop = RadarLittlePosY + radius;
383 Driver->setMatrixMode2D11 ();
385 // Background
386 RadarMaterial.setColor(RadarBackColor);
387 CQuad quad;
388 quad.V0.set(xLeft,yBottom,0);
389 quad.V1.set(xRight,yBottom,0);
390 quad.V2.set(xRight,yTop,0);
391 quad.V3.set(xLeft,yTop,0);
393 //Driver->drawQuad (xLeft,yBottom,xRight,yTop,RadarBackColor);
394 Driver->drawQuad(quad, RadarMaterial);
396 // Print radar's range
397 TextContext->setHotSpot(UTextContext::MiddleBottom);
398 TextContext->setColor(RadarFrontColor);
399 TextContext->setFontSize(RadarFontSize);
400 TextContext->printfAt(xLeft+radius*3.f/4.f,yTop+0.01f,"%d m",RadarDistance);
402 // Radar unit
403 float stepV = 50.0f;
404 float stepH = stepV*3.f/4.f;
405 // Changing scale
406 stepV = radius*stepV/RadarDistance;
407 stepH = radius*stepH/RadarDistance;
409 // Drawing radar's lines
410 // h lines
411 RadarMaterial.setColor(RadarFrontColor);
412 CLine line;
413 line.V0.set(xLeft, yTop, 0);
414 line.V1.set(xRight, yTop, 0);
415 Driver->drawLine(line, RadarMaterial);
416 line.V0.set(xLeft, yBottom+radius, 0);
417 line.V1.set(xRight, yBottom+radius, 0);
418 Driver->drawLine(line, RadarMaterial);
419 line.V0.set(xLeft, yBottom, 0);
420 line.V1.set(xRight, yBottom, 0);
421 Driver->drawLine(line, RadarMaterial);
422 //Driver->drawLine (xLeft, yTop, xRight, yTop, RadarFrontColor);
423 //Driver->drawLine (xLeft, yBottom+radius,xRight, yBottom+radius, RadarFrontColor);
424 //Driver->drawLine (xLeft, yBottom, xRight, yBottom, RadarFrontColor);
426 // v lines (assuming 4:3 screen)
427 line.V0.set(xLeft, yTop, 0);
428 line.V1.set(xLeft, yBottom, 0);
429 Driver->drawLine(line, RadarMaterial);
430 line.V0.set(xLeft + radius*0.75f, yTop, 0);
431 line.V1.set(xLeft + radius*0.75f, yBottom, 0);
432 Driver->drawLine(line, RadarMaterial);
433 line.V0.set(xRight, yTop, 0);
434 line.V1.set(xRight, yBottom, 0);
435 Driver->drawLine(line, RadarMaterial);
436 //Driver->drawLine (xLeft, yTop, xLeft, yBottom, RadarFrontColor);
437 //Driver->drawLine (xLeft+radius*3.f/4.f, yTop, xLeft+radius*3.f/4.f, yBottom, RadarFrontColor);
438 //Driver->drawLine (xRight, yTop, xRight, yBottom, RadarFrontColor);
440 float scale = 1.0f;
442 float xscreen = xLeft + radius*3.f/4.f;
443 float yscreen = yBottom + radius;
445 Driver->setFrustum (CFrustum(0.f, 1.0f, 0.f, 1.f, -1.f, 1.f, false));
447 // distance between user and neighbour player
448 float myPosx = Self->Position.x;
449 float myPosy = Self->Position.y;
451 // Quads size
452 float entitySize = RadarEntitySize/2.0f;
454 TextContext->setColor(RadarOtherColor);
456 for(EIT eit=Entities.begin(); eit!=Entities.end(); eit++)
458 if((*eit).second.Type == CEntity::Other)
460 CVector playerPos = (*eit).second.Position;
462 // position of neighbour
463 float posx = playerPos.x;
464 float posy = playerPos.y;
466 // relative position
467 posx = (posx-myPosx)*radius/RadarDistance;
468 posy = (posy-myPosy)*radius/RadarDistance;
470 float dist = (float) sqrt((posx*posx)+(posy*posy));
472 // Display a quad to show a player
473 float an;
474 float az;
475 float x;
476 float y;
477 az = MouseListener->getOrientation ();
478 if(posx==0)
480 if(posy==0)
482 x = xscreen;
483 y = yscreen;
485 else
487 if(posy>0)
489 x = (float) (xscreen - dist*cos(Pi-az)*3.f/4.f);
490 y = (float) (yscreen - dist*sin(Pi-az));
492 else
494 x = (float) (xscreen - dist*cos(-az)*3.f/4.f);
495 y = (float) (yscreen - dist*sin(-az));
499 else
501 an = (float) atan(posy/posx);
502 if(posx<0) an = an + (float)Pi;
503 x = (float) (xscreen - dist*cos(-Pi/2 + an-az)*3.f/4.f);
504 y = (float) (yscreen - dist*sin(-Pi/2 + an-az));
507 // Players out of range are not displayed
508 if(x<xLeft || x>xRight || y>yTop || y<yBottom) continue;
510 TextContext->setColor(RadarOtherColor);
512 quad.V0.set(x-entitySize, y+entitySize, 0);
513 quad.V1.set(x+entitySize, y+entitySize, 0);
514 quad.V2.set(x+entitySize, y-entitySize, 0);
515 quad.V3.set(x-entitySize, y-entitySize, 0);
516 RadarMaterial.setColor(RadarOtherColor);
517 Driver->drawQuad(quad, RadarMaterial);
518 //Driver->drawQuad (x-entitySize,y-entitySize,x+entitySize,y+entitySize,RadarOtherColor);
523 // display particular places
524 CTriangle triangle;
525 for(uint i = 0; i < RadarParticularPlaces.size(); i++)
527 // relative position
528 float posx = (RadarParticularPlaces[i].x-myPosx)*radius/RadarDistance;
529 float posy = (RadarParticularPlaces[i].y-myPosy)*radius/RadarDistance;
531 float dist = (float) sqrt((posx*posx)+(posy*posy));
533 // Display a quad to show a player
534 float an;
535 float az;
536 float x;
537 float y;
538 az = MouseListener->getOrientation ();
539 if(posx==0)
541 if(posy==0)
543 x = xscreen;
544 y = yscreen;
546 else
548 if(posy>0)
550 x = (float) (xscreen - dist*cos(Pi-az)*3.f/4.f);
551 y = (float) (yscreen - dist*sin(Pi-az));
553 else
555 x = (float) (xscreen - dist*cos(-az)*3.f/4.f);
556 y = (float) (yscreen - dist*sin(-az));
560 else
562 an = (float) atan(posy/posx);
563 if(posx<0) an = an + (float)Pi;
564 x = (float) (xscreen - dist*cos(-Pi/2 + an-az)*3.f/4.f);
565 y = (float) (yscreen - dist*sin(-Pi/2 + an-az));
569 if(x<xLeft || x>xRight || y>yTop || y<yBottom)
571 continue;
574 triangle.V0.set(x-entitySize, y-entitySize, 0);
575 triangle.V1.set(x+entitySize, y-entitySize, 0);
576 triangle.V2.set(x, y+entitySize, 0);
577 RadarMaterial.setColor(RadarPlaceColor);
578 Driver->drawTriangle(triangle, RadarMaterial);
579 //Driver->drawTriangle(x-entitySize,y-entitySize, x+entitySize,y-entitySize, x,y+entitySize, RadarPlaceColor);
583 void cbUpdateRadar (CConfigFile::CVar &var)
585 if (var.Name == "RadarPosX") RadarPosX = var.asFloat ();
586 else if (var.Name == "RadarPosY") RadarPosY = var.asFloat ();
587 else if (var.Name == "RadarWidth") RadarWidth = var.asFloat ();
588 else if (var.Name == "RadarHeight") RadarHeight = var.asFloat ();
589 else if (var.Name == "RadarBackColor") RadarBackColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
590 else if (var.Name == "RadarFrontColor") RadarFrontColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
591 else if (var.Name == "RadarSelfColor") RadarSelfColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
592 else if (var.Name == "RadarOtherColor") RadarOtherColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
593 else if (var.Name == "RadarPlaceColor") RadarPlaceColor.set (var.asInt(0), var.asInt(1), var.asInt(2), var.asInt(3));
594 else if (var.Name == "RadarEntitySize") RadarEntitySize = var.asFloat ();
595 else if (var.Name == "RadarState") RadarState = var.asInt ();
596 else if (var.Name == "RadarDistance") RadarDistance = var.asInt ();
597 else if (var.Name == "RadarMinDistance") RadarMinDistance = var.asInt ();
598 else if (var.Name == "RadarMaxDistance") RadarMaxDistance = var.asInt ();
599 else if (var.Name == "RadarParticularPlaces")
601 RadarParticularPlaces.clear ();
602 for (uint i = 0; i < var.size(); i += 3)
604 RadarParticularPlaces.push_back (RadarParticularPlace(var.asFloat(i), var.asFloat(i+1), var.asString(i+2)));
607 else if (var.Name == "RadarFontSize") RadarFontSize = var.asInt ();
608 else if (var.Name == "RadarLittlePosX") RadarLittlePosX = var.asFloat ();
609 else if (var.Name == "RadarLittlePosY") RadarLittlePosY = var.asFloat ();
610 else if (var.Name == "RadarLittleRadius") RadarLittleRadius = var.asFloat ();
611 else nlwarning ("Unknown variable update %s", var.Name.c_str());
614 void initRadar ()
616 ConfigFile->setCallback ("RadarPosX", cbUpdateRadar);
617 ConfigFile->setCallback ("RadarPosY", cbUpdateRadar);
618 ConfigFile->setCallback ("RadarWidth", cbUpdateRadar);
619 ConfigFile->setCallback ("RadarHeight", cbUpdateRadar);
620 ConfigFile->setCallback ("RadarBackColor", cbUpdateRadar);
621 ConfigFile->setCallback ("RadarFrontColor", cbUpdateRadar);
622 ConfigFile->setCallback ("RadarSelfColor", cbUpdateRadar);
623 ConfigFile->setCallback ("RadarOtherColor", cbUpdateRadar);
624 ConfigFile->setCallback ("RadarPlaceColor", cbUpdateRadar);
625 ConfigFile->setCallback ("RadarEntitySize", cbUpdateRadar);
626 ConfigFile->setCallback ("RadarState", cbUpdateRadar);
627 ConfigFile->setCallback ("RadarDistance", cbUpdateRadar);
628 ConfigFile->setCallback ("RadarMinDistance", cbUpdateRadar);
629 ConfigFile->setCallback ("RadarMaxDistance", cbUpdateRadar);
630 ConfigFile->setCallback ("RadarParticularPlaces", cbUpdateRadar);
631 ConfigFile->setCallback ("RadarFontSize", cbUpdateRadar);
632 ConfigFile->setCallback ("RadarLittlePosX", cbUpdateRadar);
633 ConfigFile->setCallback ("RadarLittlePosY", cbUpdateRadar);
634 ConfigFile->setCallback ("RadarLittleRadius", cbUpdateRadar);
636 cbUpdateRadar (ConfigFile->getVar ("RadarPosX"));
637 cbUpdateRadar (ConfigFile->getVar ("RadarPosY"));
638 cbUpdateRadar (ConfigFile->getVar ("RadarWidth"));
639 cbUpdateRadar (ConfigFile->getVar ("RadarHeight"));
640 cbUpdateRadar (ConfigFile->getVar ("RadarFrontColor"));
641 cbUpdateRadar (ConfigFile->getVar ("RadarBackColor"));
642 cbUpdateRadar (ConfigFile->getVar ("RadarSelfColor"));
643 cbUpdateRadar (ConfigFile->getVar ("RadarOtherColor"));
644 cbUpdateRadar (ConfigFile->getVar ("RadarPlaceColor"));
645 cbUpdateRadar (ConfigFile->getVar ("RadarEntitySize"));
646 cbUpdateRadar (ConfigFile->getVar ("RadarState"));
647 cbUpdateRadar (ConfigFile->getVar ("RadarDistance"));
648 cbUpdateRadar (ConfigFile->getVar ("RadarMinDistance"));
649 cbUpdateRadar (ConfigFile->getVar ("RadarMaxDistance"));
650 cbUpdateRadar (ConfigFile->getVar ("RadarParticularPlaces"));
651 cbUpdateRadar (ConfigFile->getVar ("RadarFontSize"));
652 cbUpdateRadar (ConfigFile->getVar ("RadarLittlePosX"));
653 cbUpdateRadar (ConfigFile->getVar ("RadarLittlePosY"));
654 cbUpdateRadar (ConfigFile->getVar ("RadarLittleRadius"));
656 RadarMaterial = Driver->createMaterial ();
657 RadarMaterial.initUnlit ();
658 RadarMaterial.setBlendFunc (UMaterial::srcalpha, UMaterial::invsrcalpha);
659 RadarMaterial.setBlend(true);
662 void updateRadar ()
664 if (RadarDistance > RadarMaxDistance) RadarDistance = RadarMaxDistance;
665 else if (RadarDistance < RadarMinDistance) RadarDistance = RadarMinDistance;
667 switch (RadarState)
669 case 0:
670 break;
671 case 1:
672 displayRadar ();
673 break;
674 case 2:
675 displayLittleRadar();
676 break;
680 void releaseRadar ()
682 ConfigFile->setCallback ("RadarPosX", NULL);
683 ConfigFile->setCallback ("RadarPosY", NULL);
684 ConfigFile->setCallback ("RadarWidth", NULL);
685 ConfigFile->setCallback ("RadarHeight", NULL);
686 ConfigFile->setCallback ("RadarBackColor", NULL);
687 ConfigFile->setCallback ("RadarFrontColor", NULL);
688 ConfigFile->setCallback ("RadarSelfColor", NULL);
689 ConfigFile->setCallback ("RadarOtherColor", NULL);
690 ConfigFile->setCallback ("RadarPlaceColor", NULL);
691 ConfigFile->setCallback ("RadarEntitySize", NULL);
692 ConfigFile->setCallback ("RadarState", NULL);
693 ConfigFile->setCallback ("RadarDistance", NULL);
694 ConfigFile->setCallback ("RadarMinDistance", NULL);
695 ConfigFile->setCallback ("RadarMaxDistance", NULL);
696 ConfigFile->setCallback ("RadarParticularPlaces", NULL);
697 ConfigFile->setCallback ("RadarFontSize", NULL);
698 ConfigFile->setCallback ("RadarLittlePosX", NULL);
699 ConfigFile->setCallback ("RadarLittlePosY", NULL);
700 ConfigFile->setCallback ("RadarLittleRadius", NULL);
701 Driver->deleteMaterial(RadarMaterial); RadarMaterial = NULL;
704 NLMISC_COMMAND(go,"change position of the player with a player name or location","<player_name>|<location_name>")
706 // check args, if there s not the right number of parameter, return bad
707 if (args.size() == 1)
709 bool gotoplayer = true;
711 vector<RadarParticularPlace>::iterator itpp;
712 for(itpp = RadarParticularPlaces.begin(); itpp != RadarParticularPlaces.end(); itpp++)
714 if((*itpp).name==args[0])
716 string cmd = "goto " + toString ((*itpp).x) + " " + toString ((*itpp).y);
717 ICommand::execute (cmd, CommandsLog);
719 gotoplayer = false;
720 break;
724 if(gotoplayer)
726 EIT itre;
727 for(itre=Entities.begin(); itre!=Entities.end(); itre++)
729 if((*itre).second.Type != CEntity::Snowball)
731 if((*itre).second.Name == args[0])
733 string cmd = "goto " + toString ((*itre).second.Position.x) + " " + toString ((*itre).second.Position.y);
734 ICommand::execute (cmd, CommandsLog);
736 break;
742 else
743 return false;
746 return true;
749 } /* namespace SBCLIENT */
751 /* end of file */