WorldSim  inDev
2D tile-based sandbox RPG with procedurally generated fantasy world simulator 🌏
World_Viewer.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef WORLDSIM_WORLD_VIEWER_HPP
3 #define WORLDSIM_WORLD_VIEWER_HPP
4 
5 /* WorldSim: WorldViewer
6  #include "World_Viewer.hpp"
7 
8  Code for rendering the player's view of the world. It is able to render the global (world map) view, and additionally
9  any local maps which have been loaded in.
10 
11  To do this it makes use of doubles. The main number tracks the global rendering coordinates, and the mantissa tracks
12  the local tile rendering coordinates. There's probably a better way of doing this but it's the only way I know and it
13  gets the job done.
14 
15  The World Viewer also takes mouse and keyboard input to control panning and zooming.
16 
17  It provides coordinates (both local and absolute) for the tile the mouse
18  is hovering over.
19 
20  It needs some cleanup and optimization. There are probably many things which could be done to improve performance,
21  this thing can be slow on older computers when zoomed out too far. Also a lot of calculations should be moved out of
22  the render function. It's worth noting that this is not a standard tile renderer. Most RPGs will render maybe a field
23  of 20x20 tiles and therefore optimisation is not a concern. This one in some cases needs to render more tiles than
24  there are screen pixels.
25 
26  This class could technically be moved into Wildcat but it's not likely to be used for much else so it's not a big
27  deal for now.
28 
29  We should be able to significantly improve render efficiency by building an array or vector of textures to draw.
30 
31  Then we draw each texture, only binding them once. Texture binding seems to be expensive so I think this will save
32  a lot of render time.
33 
34 */
35 
36 #include <Device/Display/DisplayInterface.hpp>
37 #include <Device/Mouse/MouseInterface.hpp>
38 #include <Graphics/Render/Renderer.hpp>
39 #include <Game/WorldGenerator/Biome.hpp> // For rendering biomes. Needs to be fixed
40 #include "WorldObjectGlobal.hpp"
41 #include "Creature.hpp"
42 #include "Tribe.hpp"
43 
44 // Raindrops that are rendered over screen to indicate rain.
45 // Should start at top of screen and travel down. Should not render on sheltered tiles
46 class RainDrop
47 {
48  public:
49  int x, y;
50 
52  {
53  x=0;
54  y=0;
55  }
56  void drop(int amount)
57  {
58  y-=amount;
59  }
60  void render()
61  {
62  Renderer::placeColour4a(60,60,255,255,x,y,x+3,y+4);
63  }
64 };
65 
67 {
68  private:
69  RandomNonStatic rand;
70 
71  Vector <RainDrop*> vRainDrop;
72 
73  World* world;
74 
75  int x1, x2;
76  int y1, y2;
77  int MAX_RAIN;
78  int RAIN_PER_FRAME;
79 
80  public:
81 
83 
84  void init (int _x1, int _y1, int _x2, int _y2, World* _world, int _maxRain=10000, double _rainPercentOfX=0.005)
85  {
86  x1=_x1;
87  y1=_y1;
88  x2=_x2;
89  y2=_y2;
90  MAX_RAIN = _maxRain;
91  RAIN_PER_FRAME = _rainPercentOfX*(x2-x1);
92 
93  world = _world;
94 
95  rand.seed();
96  }
97 
98  void updateRain()
99  {
100  // This should be moved out of the render call and threaded.
101  if ( world->isRaining && vRainDrop.size() < MAX_RAIN )
102  {
103  for (int i=0;i<RAIN_PER_FRAME;++i)
104  {
105  RainDrop* rain = new RainDrop;
106  rain->y = y2-rand.randomInt(20);
107 
108  rain->x = rand.randomInt(x2-x1);
109  rain->x+=x1;
110  vRainDrop.push(rain);
111  }
112  }
113  for (int i=0;i<vRainDrop.size();++i)
114  {
115  vRainDrop(i)->drop(rand.randomInt(3)+18);
116  if (vRainDrop(i)->y < y1)
117  {
118  delete vRainDrop(i);
119  vRainDrop.removeSlot(i);
120  }
121  }
122  }
123  void render();
124 
125 };
126 
127 class WorldViewer: public DisplayInterface, public MouseInterface
128 {
129  private:
130 
131  /* Rendering coordinates.
132  These should be updated to use the standard GUI panel system */
133  int mainViewX1, mainViewX2, mainViewY1, mainViewY2;
134  int mainViewNX, mainViewNY;
135 
136  double localTileMantissa;
137 
138  // Here is what we should really be drawing, rather than deciding during the render call.
139  // Ideally this should also be running in a thread, locking when render is called.
140  ArrayS2 <Vector <Texture* > > aScene;
141 
142  public:
143  //RAIN
145 
146  bool active;
147 
148  int tileSize; /* How big to render the tiles, in pixels. */
149 
150  /* The tile at the center of the screen.
151  Note that the mantissa is used to center on local tiles.
152  This must be a double due to the required level of precision.
153  */
154  double centerTileX, centerTileY;
155 
156  /* The first tile rendered, and the pixel coordinates where it is rendered */
157  /* We store this for other functions to use. */
158  int firstTileX, firstTileY;
159  unsigned long int firstTileAbsX, firstTileAbsY; /* (0,0) absolute of the above */
160  int firstPixelX, firstPixelY;
161 
162  // Temp: Local tile to render.
163  int centerLocalX, centerLocalY;
165 
166 
167  /* Store the last position of the mouse, so we can figure out which tile the mouse is on. */
168  short int lastMouseX, lastMouseY;
169 
172 
173  bool panning;
174  float panX, panY; /* Stores the last mouse position when panning. Needs to be a double. */
175 
177 
178  /* The current tile that the mouse is hovering over. Set to -1 if the mouse is not hovering over a tile. */
179  int hoveredXTile, hoveredYTile;
180  int hoveredXTileLocal, hoveredYTileLocal;
181  unsigned long int hoveredAbsoluteX, hoveredAbsoluteY;
183 
185 
189  bool landMode; // Show only landmasses
190 
191  // If true, game will randomly scroll around.
192  // In the future, the title screen will probably be scrolling around a map.
193  bool demoMode;
194  double demoScroll;
195 
197  {
198  tileSize=8;
199  tilesToSkip=0;
200  pixelsPerLocalTile = ((double)tileSize/LOCAL_MAP_SIZE);
201  localTileMantissa = (double)1/(double)LOCAL_MAP_SIZE;
202 
203  centerTileX=0; centerTileY=0;
204  world=0;
205  mainViewX1=0; mainViewX2=0;
206  mainViewY1=0; mainViewY2=0;
207  mainViewNX=0; mainViewNY=0;
208  active=false;
209 
210  panX=0; panY=0;
211 
212  panning=false;
213  alternateTile=0;
214 
215  lastMouseX=0;
216  lastMouseY=0;
217 
218  hoveredXTile=0;
219  hoveredYTile=0;
220  hoveredXTileLocal=0;
221  hoveredYTileLocal=0;
222  hoveredAbsoluteX=ABSOLUTE_COORDINATE_NULL;
223  hoveredAbsoluteY=ABSOLUTE_COORDINATE_NULL;
224 
225  showHoveredTile=false;
226 
227  centerLocalX=LOCAL_MAP_SIZE/2;
228  centerLocalY=LOCAL_MAP_SIZE/2;
229 
230  firstTileX=0;
231  firstTileY=0;
232  firstPixelX=0;
233  firstPixelY=0;
234  firstTileAbsX=0;
235  firstTileAbsY=0;
236 
237  territoryView = false;
238  tilesetMode = true;
239  landMode = false;
240  subterraneanMode = false;
241 
242  demoMode = false;
243  demoScroll = 0.1;
244 
245  rainManager.init(0,0,0,0,0);
246  }
247 
248  // Center the view on the middle of the world. Good for initializing.
249  void centerView()
250  {
251  if (world==0)
252  { return; }
253 
254  centerTileX = world->nX/2;
255  centerTileY = world->nY/2;
256 
257  centerTileX+=0.5;
258  centerTileY+=0.5;
259  }
260 
261  bool keyboardEvent( Keyboard* _keyboard )
262  {
263  //zoomIn();
264  //return false;
265  // Zoom the main map in by one step. (Can use either top row or numpad)
266  if(_keyboard->isPressed(Keyboard::EQUALS) || _keyboard->isPressed(Keyboard::PLUS))
267  {
268  if (_keyboard->keyWasPressed)
269  {
270  zoomIn();
271  }
272  }
273  /* Zoom the main map out by one step. */
274  if(_keyboard->isPressed(Keyboard::MINUS))
275  {
276  if (_keyboard->keyWasPressed)
277  {
278  zoomOut();
279  }
280  }
281 
282  return false;
283  }
284 
285  void zoomIn()
286  {
287  if ( tilesToSkip > 0 )
288  { --tilesToSkip; }
289  else
290  {
291  tileSize*=2;
292  if(tileSize>2000000)
293  { tileSize=2000000; }
294  }
295  pixelsPerLocalTile = ((double)tileSize/LOCAL_MAP_SIZE);
296  }
297 
298  void zoomOut()
299  {
300  tileSize/=2;
301 
302  if(tileSize<1)
303  { tileSize=1; ++tilesToSkip; }
304  pixelsPerLocalTile = ((double)tileSize/LOCAL_MAP_SIZE);
305  }
306 
307  void setTileSize(const int _tileSize)
308  {
309  tileSize=_tileSize;
310  tilesToSkip=0;
311  pixelsPerLocalTile = ((double)tileSize/LOCAL_MAP_SIZE);
312  }
313 
314  void switchTarget(World_Local* _worldLocal)
315  {
316  worldLocal=_worldLocal;
317  }
318 
319 
320  /* Keep the map visible on the screen so the player can't accidentally move it off screen and lose it. */
322  {
323  if ( centerTileX < 0 )
324  {
325  centerTileX=0;
326  }
327  if ( centerTileY < 0 )
328  {
329  centerTileY=0;
330  }
331  if ( centerTileX > world->nX )
332  {
333  centerTileX = world->nX;
334  }
335  if ( centerTileY > world->nY )
336  {
337  centerTileY = world->nY;
338  }
339  }
340 
341  bool mouseEvent ( Mouse* mouse )
342  {
343  if ( world==0 ) { return false; }
344 
345  lastMouseX=mouse->x;
346  lastMouseY=mouse->y;
347 
348  if(panning==true)
349  {
350  /* The view can be panned by holding down the middle mouse button
351  and moving the mouse to drag the map. */
352  centerTileX+=(panX-mouse->x)/((float)tileSize/(tilesToSkip+1));
353  centerTileY+=(panY-mouse->y)/((float)tileSize/(tilesToSkip+1));
354  panX=mouse->x;
355  panY=mouse->y;
356  }
357 
358  if(mouse->isMiddleClick==false)
359  {
360  panning=false;
361  }
362  if ( mouse->isMiddleClick)
363  {
364  panning=true;
365  /* Set initial pan coordinates. */
366  panX=mouse->x;
367  panY=mouse->y;
368  }
369 
370  if(mouse->isWheelDown)
371  {
372  zoomOut();
373  mouse->isWheelDown=false;
374  }
375  if(mouse->isWheelUp)
376  {
377  zoomIn();
378  mouse->isWheelUp=false;
379  }
380 
381  normaliseCoordinates();
382 
383  if ( mouse->isLeftClick == true )
384  {
385  world->queryTile(hoveredXTile,hoveredYTile);
386  world->queryTileLocal(hoveredXTileLocal,hoveredYTileLocal);
387  }
388 
389  if (mouse->isRightClick)
390  {
391  world->generateLocal(hoveredXTile,hoveredYTile);
392  DEBUG_X=hoveredXTile;
393  DEBUG_Y=hoveredYTile;
394  }
395  return false;
396  }
397 
398  void setPanel( const int _x1, const int _y1, const int _x2, const int _y2)
399  {
400  // Todo: Update class to use standard GUI panel system.
401  mainViewX1 = _x1;
402  mainViewY1 = _y1;
403  mainViewX2 = _x2;
404  mainViewY2 = _y2;
405 
406  mainViewNX = mainViewX2-mainViewX1;
407  mainViewNY = mainViewY2-mainViewY1;
408 
409  pixelsPerLocalTile = ((double)tileSize/LOCAL_MAP_SIZE);
410 
411  rainManager.init(_x1,_y1,_x2,_y2,world);
412  }
413 
414  inline void setCenterTile (const double _centerTileX, const double _centerTileY,
415  const int _subTileX=LOCAL_MAP_SIZE/2, const int _subTileY=LOCAL_MAP_SIZE/2)
416  {
417  centerTileX = _centerTileX;
418  centerTileY = _centerTileY;
419 
420  centerTileX += (_subTileX * localTileMantissa)+localTileMantissa/2;
421  centerTileY += (_subTileY * localTileMantissa)+localTileMantissa/2;
422  }
423 
424  /* Convert tile coordinates to screen (pixel) coordinates. */
425  void toScreenCoords(const int _tileX, const int _tileY, int * _pixelX, int * _pixelY)
426  {
427  float centerTileXDecimal = centerTileX - (int)centerTileX;
428  float centerTileYDecimal = centerTileY - (int)centerTileY;
429 
430  float centerTileXPixels = centerTileXDecimal*tileSize;
431  float centerTileYPixels = centerTileYDecimal*tileSize;
432 
433 
434  //double pixelOffsetX = tileSize*centerTileXDecimal;
435  //double pixelOffsetY = tileSize*centerTileYDecimal;
436 
437  const int iCenterTileX = centerTileX;
438 
439 
440  const int tilesToDrawX = (mainViewNX/tileSize) + 1;
441  const int tilesToDrawY = (mainViewNY/tileSize) + 1;
442 
443  int tileX=centerTileX;
444  int pixelTileX = mainViewX1+(mainViewNX/2) - centerTileXPixels;
445  while(pixelTileX>=mainViewX1)
446  {
447  --tileX;
448  tileX-=tilesToSkip;
449  pixelTileX-=tileSize;
450  }
451  const int revertTileX = tileX;
452 
453  int tileY=centerTileY;
454  int pixelTileY = mainViewY1 + (mainViewNY/2) - centerTileYPixels;
455  while(pixelTileY>=0)
456  {
457  --tileY;
458  tileY-=tilesToSkip;
459  pixelTileY-=tileSize;
460  }
461 
462 
463  int nExtraXTiles = _tileX - tileX;
464  int nExtraYTiles = _tileY - tileY;
465 
466  if ( nExtraXTiles>=0 && nExtraYTiles>=0 )
467  {
468  *_pixelX = pixelTileX + (tileSize * nExtraXTiles);
469  *_pixelY = pixelTileY + (tileSize * nExtraYTiles);
470  }
471  else
472  {
473  *_pixelX = -1000;
474  *_pixelY = -1000;
475  }
476  }
477 
478  // Take the given pixels and calculate what tile they are. This is in absolute coordinates.
479  // I need to add a version which can do relative coords.
480  void toTileCoords(int pixelX, int pixelY, unsigned long int * absX, unsigned long int * absY)
481  {
482  if (absX==0 || absY==0) {return;}
483 
484  if (pixelX<0 || pixelY<0 || pixelsPerLocalTile == 0)
485  {
488  }
489 
490  int pixelDistanceX = pixelX - firstPixelX;
491  int pixelDistanceY = pixelY - firstPixelY;
492 
493  if ( pixelDistanceX < 0 || pixelDistanceY < 0 )
494  {
495  *absX=0;
496  *absY=0;
497  return;
498  }
499 
500  *absX = firstTileAbsX + ((double)pixelDistanceX/pixelsPerLocalTile);
501  *absY = firstTileAbsY + ((double)pixelDistanceY/pixelsPerLocalTile);
502  }
503 
504  /* HERE I RENDER THE GRAPHICAL ICONS WHICH ARE PRESENT ON THE WORLD MAP, FOR EXAMPLE: CITIES AND ARMIES. */
505  /* ONLY A SMALL NUMBER OF WORLD TILES WILL HAVE AN ICON ON THEM, SO I WILL USE A DIFFERENT TECHNIQUE. */
507  {
508  if (active == false)
509  { return; }
510  if(world==0)
511  {
512  std::cout<<"ABORT: No world to render.\n";
513  return;
514  }
515 
516  // set viewport to panel
517  Renderer::saveViewPort();
518  Renderer::resizeViewPort(mainViewX1,mainViewY1,mainViewX2,mainViewY2);
519 
520  // some pixel coordinate calculations
521  // needs to be cleaned up
522 
523  float centerTileXDecimal = centerTileX - (int)centerTileX;
524  float centerTileYDecimal = centerTileY - (int)centerTileY;
525 
526  float pixelOffsetX = tileSize*centerTileXDecimal;
527  float pixelOffsetY = tileSize*centerTileYDecimal;
528 
529  const int iCenterTileX = centerTileX;
530 
531  const int tilesToDrawX = (mainViewNX/tileSize) + 1;
532  const int tilesToDrawY = (mainViewNY/tileSize) + 1;
533 
534  int tileX=centerTileX;
535  int pixelTile = mainViewNX/2;
536 
537  // this is bad but I'm too tired to figure out how to fix it rn
538  while(pixelTile>=0)
539  {
540  --tileX;
541  pixelTile-=tileSize;
542  }
543  const int revertTileX = tileX;
544 
545  int tileY=centerTileY;
546  pixelTile = mainViewNY/2;
547  while(pixelTile>=0)
548  {
549  --tileY;
550  pixelTile-=tileSize;
551  }
552 
553  Renderer::setTextureMode();
554 
555  // Draw global world objects
556  // Basically stuff like armies, fleets, tribes
557  for (int i=0;i<world->vWorldObjectGlobal.size();++i)
558  {
559  WorldObjectGlobal* wog = world->vWorldObjectGlobal(i);
560 
561  // Check if we're supposed to render a local map on this tile.
562  // If so, don't draw world icons over it.
563  if ( tileSize > 4 && world->isSafe(tileX,tileY) )
564  {
565  for ( int i2=0;i2<world->vWorldLocal.size();++i2)
566  {
567  if ( world->vWorldLocal(i2)->globalX == wog->worldX
568  && world->vWorldLocal(i2)->globalY == wog->worldY )
569  {
570  wog = 0;
571  break;
572  }
573  }
574  }
575 
576  if ( wog == 0 ) { continue; }
577 
578  int wogPixelX=-1;
579  int wogPixelY=-1;
580 
581  toScreenCoords(wog->worldX,wog->worldY,&wogPixelX,&wogPixelY);
582 
583  // I NEED TO DO A CHECK TO SEE IF THE OBJECT IS VISIBLE WITHIN THE CURRENT VIEW.
584  if ( wogPixelX != -1000 && wogPixelY != -1000 )
585  {
586  Renderer::placeTexture4(wogPixelX,wogPixelY,wogPixelX+tileSize,wogPixelY+tileSize
587  ,wog->currentTexture(),false);
588  }
589  }
590  /* RESTORE THE VIEWPORT TO THE PREVIOUS SETTING (PROBABLY THE WHOLE PANEL). */
591  Renderer::restoreViewPort();
592  }
593 
594  // This function should run in the background and basically constantly build and update the array of textures to render.
595  // We need code to build the world view, and code to build the local map view.
596  // We can start with just the global view because it's less complicated.
597  // The scene should not update more than once per frame. Otherwise we're going to be constantly loading and unloading
598  // arrays for nothing.
599  void updateScene()
600  {
601  }
602 
603  void render()
604  {
605  if (active == false || world==0)
606  { return; }
607 
608  if ( demoMode )
609  {
610  if ( centerTileX < 10 && demoScroll < 0 )
611  {
612  demoScroll = demoScroll * -1;
613  }
614  else if ( centerTileX > world->nX - 10 && demoScroll > 0 )
615  {
616  demoScroll = demoScroll * -1;
617  }
618  centerTileX += demoScroll;
619  }
620 
621  // I don't know why this has to be here but it do
622  pixelsPerLocalTile = ((double)tileSize/LOCAL_MAP_SIZE);
623 
624  hoveredAbsoluteX = ABSOLUTE_COORDINATE_NULL;
625  hoveredAbsoluteY = ABSOLUTE_COORDINATE_NULL;
626 
627  Renderer::saveViewPort();
628  Renderer::resizeViewPort(mainViewX1,mainViewY1,mainViewX2,mainViewY2);
629 
630  /* The World Viewer is passed centre coordinates because typically the camera needs to be centered on something.
631  However from this we must calculate what coordinates to start rendering from in the top-left.
632  Therefore we take the centre coordinates and work back to the top-left. This is done for both the tile (array)
633  coordinates, and the rendering (pixel) coordinates. */
634 
635  float centerTileXDecimal = centerTileX - (int)centerTileX;
636  float centerTileYDecimal = centerTileY - (int)centerTileY;
637  float centerTileXPixels = centerTileXDecimal*tileSize;
638  float centerTileYPixels = centerTileYDecimal*tileSize;
639 
640  const int iCenterTileX = centerTileX;
641 
642  const int tilesToDrawX = (mainViewNX/tileSize) + 1;
643  const int tilesToDrawY = (mainViewNY/tileSize) + 1;
644 
645  int tileX=centerTileX;
646  int pixelTileX = mainViewX1+(mainViewNX/2) - centerTileXPixels;
647  while(pixelTileX>=mainViewX1)
648  {
649  --tileX;
650  tileX-=tilesToSkip;
651  pixelTileX-=tileSize;
652  }
653  const int revertTileX = tileX;
654 
655  int tileY=centerTileY;
656  int pixelTileY = mainViewY1 + (mainViewNY/2) - centerTileYPixels;
657  while(pixelTileY>=0)
658  {
659  --tileY;
660  tileY-=tilesToSkip;
661  pixelTileY-=tileSize;
662  }
663  //We need to store the top-left coordinates for other functions to use.
664  firstTileX=tileX;
665  firstTileY=tileY;
666  if (world->isSafe(tileX,tileY))
667  {
668  firstTileAbsX=tileX*LOCAL_MAP_SIZE;
669  firstTileAbsY=tileY*LOCAL_MAP_SIZE;
670  }
671  else
672  {
673  firstTileAbsX=ABSOLUTE_COORDINATE_NULL;
674  firstTileAbsY=ABSOLUTE_COORDINATE_NULL;
675  }
676  firstPixelX=pixelTileX;
677  firstPixelY=pixelTileY;
678 
679  /* UPDATE HOVERED TILE COORDS. */
680  /* MAKE SURE MOUSE IS WITHIN THE RENDERING VIEW */
681  if (lastMouseX >= mainViewX1 && lastMouseX <= mainViewX2
682  && lastMouseY >= mainViewY1 && lastMouseY <= mainViewY2 )
683  {
684  const int startingPX = pixelTileX;
685  const int startingPY = pixelTileY;
686 
687  int diffX = (lastMouseX - startingPX)/tileSize;
688  int diffY = (lastMouseY - startingPY)/tileSize;
689 
690  /* UPDATE THE COORDS OF THE HOVERED TILE. */
691  hoveredXTile = tileX + diffX;
692  hoveredYTile = tileY + diffY;
693  }
694  else
695  {
696  hoveredXTile=-1;
697  hoveredYTile=-1;
698  }
699 
700  if ( tilesetMode == false )
701  {
702  renderColourMode(tileX,tileY,pixelTileX,pixelTileY);
703  }
704  else // Render in texture mode
705  {
706  renderTextureMode(tileX,tileY,pixelTileX,pixelTileY);
707  }
708  if(subterraneanMode==false)
709  {
710  rainManager.render();
711  }
712 
713  Renderer::restoreViewPort();
714  // Now render the icons on the world map.
715  renderWorldIcons();
716  normaliseCoordinates();
717  }
718 
719  // Render the local map for this world tile. This is most likely because
720  // the player is active in this tile and looking at it.
721  void renderLocalMap(World_Local* localMap, int currentX, int currentY)
722  {
723  float currentSubY = currentY;
724  float nextSubY = currentY + pixelsPerLocalTile;
725 
726  int subTileSize = pixelsPerLocalTile;
727  if (subTileSize < 1) { subTileSize = 1; }
728 
729  const enumBiome localBaseBiome = localMap->baseBiome;
730 
731  // this needs to be fixed, we should simply be asking
732  // the local map and local tile what to draw.
733  for (int localYTile = 0; localYTile<LOCAL_MAP_SIZE;++localYTile)
734  {
735  if ( nextSubY>=mainViewY1 && currentSubY <= mainViewY2 && floor(currentSubY) != floor(nextSubY) )
736  {
737  float currentPixel = currentX;
738  float nextPixel = currentX+pixelsPerLocalTile;
739  for (int localXTile = 0; localXTile<LOCAL_MAP_SIZE;++localXTile)
740  {
741  if ( nextPixel>=mainViewX1 && currentPixel <= mainViewX2 && floor(currentPixel) != floor(nextPixel) )
742  {
743  // Render subterranean mode
744  if ( subterraneanMode && localMap->dataSubterranean)
745  {
746  // render order:
747  // terrain
748  // static
749  // objects
750  // fog
751  // overlay
752 
753  glColor4ub(255,255,255,255);
754  //Very basic player line of sight check here (only if we're in Adventure mode)
755  // Unseen tiles
757  && playerCharacter->hasSeen(localMap, localXTile,localYTile,true) == 0 )
758  {
759  }
760  //Previously seen tiles
762  && playerCharacter->hasSeen(localMap, localXTile,localYTile,true) == 1 )
763  {
764  //Draw tile very dark to symbolise fog of war
765  LocalTile* localTile = &localMap->dataSubterranean->aSubterranean(localXTile,localYTile);
766 
767  Vector <Texture*> * vText = localTile->currentTextures();
768  if ( vText != 0)
769  {
770  for (int i=0;i<vText->size();++i)
771  {
772  Renderer::placeTexture4(currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY),
773  (*vText)(i), false);
774  }
775  }
776  delete vText;
777  }
778  else /* DRAW VISIBLE TILES */
779  {
780  LocalTile* localTile = &localMap->dataSubterranean->aSubterranean(localXTile,localYTile);
781  Vector <Texture*> * vText = localTile->currentTextures();
782  if ( vText != 0)
783  {
784  for (int i=0;i<vText->size();++i)
785  {
786  Renderer::placeTexture4(currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY),
787  (*vText)(i), false);
788  }
789  }
790  for(int i=0;i<localMap->dataSubterranean->aSubterranean(localXTile,localYTile).vObject.size();++i)
791  {
792  Renderer::placeTexture4(currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY),
793  localMap->dataSubterranean->aSubterranean
794  (localXTile,localYTile).vObject(i)->currentTexture(), false);
795  }
796  delete vText;
797  }
798  }
799  // Render non-subterranean mode
800  else
801  {
802  //Very basic player line of sight check here (only if we're in Adventure mode)
803  // Render tiles we have never seen before (basically leave them black)
805  && playerCharacter->hasSeen(localMap, localXTile,localYTile) == 0 )
806  {
807  }
808  // Render tiles seen before but not currently seen.
810  && playerCharacter->hasSeen(localMap, localXTile,localYTile) == 1 )
811  {
812  //Draw tile very dark to symbolise fog of war
813  LocalTile* localTile = &localMap->data->aLocalTile(localXTile,localYTile);
814 
815  unsigned char lightValue = 80;
816  glColor3ub(lightValue,lightValue,lightValue);
817  //Renderer::placeTexture4(currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY), localTile->currentTexture(), false);
818 
819  Vector <Texture*> * vText = localTile->currentTextures();
820  if ( vText != 0)
821  {
822  for (int i=0;i<vText->size();++i)
823  {
824  Renderer::placeTexture4(currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY),
825  (*vText)(i), false);
826  }
827  }
828  delete vText;
829 
830  glColor3ub(255,255,255);
831  }
832  // Render tiles we can currently see
833  else
834  {
835  LocalTile* localTile = &localMap->data->aLocalTile(localXTile,localYTile);
836 
837  // this belongs in World.
838  // Due to increase in height levels we will remove the height shading and replace it with
839  // height shading relative to player's height. This obviously will only work when a player
840  // exists
841 
842  /* This is an absolute shading system. It allows for 127 shades of height, and then wraps back
843  down to the lowest. This seems to be a reasonably effective way of showing absolute heights
844  which exceed 127, as the player can simply count out how many "rings" of wrapping there are to
845  get a good idea of the elevation. */
846 
847  unsigned char lightValue = localTile->height+127;
848  if ( lightValue < 127 ) { lightValue += 127; }
849  //unsigned char lightValue = 255;
850 
851  int currentSecond = world->calendar.second;
852  int sunsetCounter = currentSecond-50;
853 
854  int currentMinute = world->calendar.minute;
855  int currentHour = world->calendar.hour;
856 
857  // This is a bad implementation. We should overlay a colour over the whole playfield instead.
858  glColor3ub(lightValue,lightValue,lightValue);
859  // NIGHT
860  if (currentHour < 6 || currentHour > 19)
861  {
862  //glColor3ub(50+lightValue,50+lightValue,50+lightValue);
863  //glColor3ub(lightValue,lightValue,lightValue);
864  }
865  else if (currentHour == 6) // SUNRISE
866  {
867  //glColor3ub(110+lightValue,100+lightValue,120+lightValue);
868  }
869  else if (currentHour == 19) // SUNSET
870  {
871  //glColor3ub(130+lightValue,100+lightValue,100+lightValue);
872  }
873  else
874  {
875  //glColor3ub(180+lightValue,180+lightValue,180+lightValue);
876  //glColor3ub(80+(lightValue/2),80+(lightValue/2),80+(lightValue/2));
877  //if (currentSecond > 50 )
878  //{
879  //glColor3ub(80+(sunsetCounter*9)+(lightValue/2),80+(sunsetCounter*9)+(lightValue/2),
880  //80+(sunsetCounter*10)+(lightValue/2));
881  //}
882  }
883 
884  // draw all textures for this tile
885  // in future this should be copied to an array for later smart rendering, preferably outside of render function.
886  Vector <Texture*> * vText = localTile->currentTextures();
887  if ( vText != 0)
888  {
889  for (int i=0;i<vText->size();++i)
890  {
891  Renderer::placeTexture4
892  (currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY), (*vText)(i), false);
893  }
894  }
895  delete vText;
896 
897  glColor3ub(255,255,255);
898 
899  // Draw wall if necessary.
900  // Move this to static
901  // this is bad, needs to account for multiple blockers
902  if (localTile->bWall != 0 )
903  {
904  if ( (localTile->bWall & 0b10001000) == 0b10001000) // NORTH
905  {
906  Renderer::placeTexture4RotatedDegrees
907  (currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY),
909  }
910  if ( (localTile->bWall & 0b00010001) == 0b00010001) // WEST
911  {
912  Renderer::placeTexture4RotatedDegrees
913  (currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY),
915  }
916  if ( (localTile->bWall & 0b01000100) == 0b01000100) // EAST
917  {
918  Renderer::placeTexture4RotatedDegrees
919  (currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY),
921  }
922  if ( (localTile->bWall & 0b00100010) == 0b00100010) // SOUTH
923  {
924  Renderer::placeTexture4
925  (currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY),
926  &TEX_WALL_GREYBRICK_SOUTH, false);
927  }
928  // else if ( localTile->bWall == 0b01100110) // SE
929  // {
930  // Renderer::placeTexture4
931  // (currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY),
932  // &TEX_WALL_GREYBRICK_SE, false);
933  // }
934  // else if ( localTile->bWall == 0b00110011) // SW
935  // {
936  // Renderer::placeTexture4RotatedDegrees
937  // (currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY), &TEX_WALL_GREYBRICK_SE, 90);
938  // }
939  // else if ( localTile->bWall == 0b10011001) // NW
940  // {
941  // Renderer::placeTexture4RotatedDegrees
942  // (currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY), &TEX_WALL_GREYBRICK_SE, 180);
943  // }
944  // else if ( localTile->bWall == 0b11001100) // NE
945  // {
946  // Renderer::placeTexture4RotatedDegrees
947  // (currentPixel, currentSubY, ceil(nextPixel), ceil(nextSubY), &TEX_WALL_GREYBRICK_SE, 270);
948  // }
949  }
950  }
951  }
952 
953  // UPDATE LOCAL TILE HOVERED AND ABSOLUTE COORDS
954  // ALSO OPTIONALLY RENDER A SELECTION TEXTURE
955  if ( lastMouseX > currentPixel && lastMouseX < ceil(nextPixel) && lastMouseY > currentSubY && lastMouseY < ceil(nextSubY) )
956  {
957  hoveredXTileLocal = localXTile;
958  hoveredAbsoluteX = hoveredXTile * LOCAL_MAP_SIZE + localXTile;
959  hoveredYTileLocal = localYTile;
960  hoveredAbsoluteY = hoveredYTile * LOCAL_MAP_SIZE + localYTile;
961 
962  if ( showHoveredTile )
963  {
964  //The lines get overwritten if you don't -1. Do not add -1 anywhere else because it causes artifacts.
965  Renderer::placeBorder4(255,0,0,currentPixel, currentSubY, ceil(nextPixel)-1, ceil(nextSubY)-1);
966  Renderer::setTextureMode();
967  }
968  }
969  }
970  currentPixel=nextPixel;
971  nextPixel+=pixelsPerLocalTile;
972  }
973  }
974  currentSubY=nextSubY;
975  nextSubY+=pixelsPerLocalTile;
976  }
977  }
978 
979  // render the world using the texture system.
980  void renderTextureMode(int tileX, int tileY, float pixelTileX, float pixelTileY)
981  {
982  Renderer::setTextureMode();
983  const int revertTileX = tileX;
984 
985  for (int currentY = pixelTileY; currentY<mainViewNY; currentY+=tileSize)
986  {
987  //initial case
988  glColor3ub(255,255,255);
989 
990  for (int currentX = pixelTileX; currentX<mainViewNX+tileSize; currentX+=tileSize)
991  {
992  if (world->isSafe(tileX,tileY))
993  {
994 
995  // Check if we're supposed to render a local map on this tile.
996  World_Local * localMap = 0;
997  if ( tileSize >= 12 )
998  {
999  for ( int i=0;i<world->vWorldLocal.size();++i)
1000  {
1001  if ( world->vWorldLocal(i)->globalX == tileX && world->vWorldLocal(i)->globalY == tileY )
1002  {
1003  localMap = world->vWorldLocal(i);
1004  break;
1005  }
1006  }
1007  }
1008 
1009  // This tile needs to be rendered as a local map.
1010  //if (tileSize > 4 && localX == tileX && localY == tileY && world->isSafe(tileX,tileY))
1011  if ( localMap != 0 && localMap->data != 0 && localMap->initialized && tileSize > LOCAL_MAP_SIZE*2)
1012  {
1013  renderLocalMap(localMap,currentX,currentY);
1014  }
1015  else if (landMode)
1016  {
1017  // only render grassland and ocean tiles.
1018  if(world->isLand(tileX,tileY)==false)
1019  {
1020  Renderer::placeTexture4(currentX, currentY, currentX+tileSize, currentY+tileSize,
1021  &TEX_WORLD_TERRAIN_OCEAN_00, false);
1022  }
1023  else if(world->isLand(tileX,tileY)==true)
1024  {
1025  Renderer::placeTexture4(currentX, currentY, currentX+tileSize, currentY+tileSize,
1026  &TEX_WORLD_TERRAIN_GRASS_00, false);
1027  }
1028  }
1029  // Render this tile as a world tile.
1030  else
1031  {
1032  /* Textures are chosen here rather than from tile objects because it is highly dependent on
1033  neighboring tiles. It would be possible to delegate texture handling to tile objects, but would take
1034  too much memory maintaining pointers to neighbours. In future I should probably write a class
1035  which returns joining textures based on neighbors. */
1036 
1037  // Todo:
1038  // tile should just return vector of textures tbh
1039 
1040  // UPDATE: Textures should be assigned to World_Local at generation/modification, to save cycles on
1041  // render time.
1042  World_Local * tile = &(world->aWorldTile(tileX,tileY));
1043  if (tile)
1044  {
1045  Renderer::placeTexture4(currentX, currentY, currentX+tileSize, currentY+tileSize,
1046  tile->currentTexture(), false);
1047  }
1048 
1049  // DRAW IMPROVEMENTS (FOREST, RIVER)
1050  // Improvements can layer over base terrain, and each other.
1051  // For example a tile may have a river and forest.
1052  // This should be handled by the tile
1053  if(world->isLand(tileX,tileY) && world->aWorldTile(tileX,tileY).baseBiome == FOREST)
1054  {
1055  Renderer::placeTexture4
1056  (currentX, currentY, currentX+tileSize, currentY+tileSize,
1058  }
1059  else if(world->isLand(tileX,tileY) &&world->aWorldTile(tileX,tileY).baseBiome == JUNGLE)
1060  {
1061  Renderer::placeTexture4
1062  (currentX, currentY, currentX+tileSize, currentY+tileSize, &TEX_WORLD_TERRAIN_JUNGLE, false);
1063  }
1064  if(world->isLand(tileX,tileY) && world->aWorldTile(tileX,tileY).baseBiome == MOUNTAIN &&
1065  world->aWorldTile(tileX,tileY).active==false)
1066  {
1067  Renderer::placeTexture4
1068  (currentX, currentY, currentX+tileSize, currentY+tileSize,
1070  }
1071  if(world->isLand(tileX,tileY) && world->aWorldTile(tileX,tileY).baseBiome == HILLY)
1072  {
1073  Renderer::placeTexture4
1074  (currentX, currentY, currentX+tileSize, currentY+tileSize, &TEX_WORLD_TERRAIN_HILL, false);
1075  }
1076  if(world->isLand(tileX,tileY) && world->aRiverID(tileX,tileY) != -1)
1077  {
1078  Renderer::placeTexture4
1079  (currentX, currentY, currentX+tileSize, currentY+tileSize, &TEX_WORLD_TERRAIN_RIVER_FULL, false);
1080  }
1081 
1082  // Render tribe territory colour if necessary
1083  if (territoryView)
1084  {
1085  //Renderer::setColourMode();
1086  // Get territory colour of dominant tribe on this tile and draw it as a transparent overlay
1087  const Tribe* dominantTribe = world->aWorldTile(tileX,tileY).getDominantInfluence();
1088  if (dominantTribe!=0)
1089  {
1090  Renderer::placeColour4a(dominantTribe->colourRed,dominantTribe->colourGreen,
1091  dominantTribe->colourBlue, 150, currentX, currentY, currentX+tileSize, currentY+tileSize);
1092  }
1093  //Renderer::setTextureMode();
1094  }
1095  }
1096  }
1097  ++tileX;
1098  tileX+=tilesToSkip;
1099  }
1100  tileX=revertTileX;
1101  ++tileY;
1102  tileY+=tilesToSkip;
1103  }
1104  }
1105 
1106  // render the world using the old colour system. Generally not used.
1107  void renderColourMode(int tileX, int tileY, float pixelTileX, float pixelTileY)
1108  {
1109  // Pixel coords for leftmost tile.
1110  Renderer::setColourMode();
1111 
1112  const int revertTileX = tileX;
1113 
1114  for (int currentY = pixelTileY; currentY<mainViewNY; currentY+=tileSize)
1115  {
1116  glBegin(GL_QUAD_STRIP);
1117 
1118  // initial case
1119  glColor3ub(0,0,0);
1120 
1121  for (int currentX = pixelTileX; currentX<mainViewNX+tileSize; currentX+=tileSize)
1122  {
1123  if(world->isSafe(tileX,tileY)==true)
1124  {
1125  glVertex2s(currentX,currentY);
1126  glVertex2s(currentX,currentY+tileSize);
1127 
1128  // Territory view
1129  if (territoryView)
1130  {
1131  const Tribe* dominantTribe = world->aWorldTile(tileX,tileY).getDominantInfluence();
1132  if (dominantTribe!=0)
1133  {
1134  glColor3ub(dominantTribe->colourRed,dominantTribe->colourGreen,dominantTribe->colourBlue);
1135  }
1136  else
1137  {
1138  glColor3ub(world->aTopoMap(tileX,tileY,0),world->aTopoMap(tileX,tileY,1),
1139  world->aTopoMap(tileX,tileY,2));
1140  }
1141  }
1142  else if (landMode)
1143  {
1144  // only draw land and ocean textures.
1145  if(world->isLand(tileX,tileY)==false)
1146  {
1147  glColor3ub(TEX_WORLD_TERRAIN_OCEAN_00.averageRed,TEX_WORLD_TERRAIN_OCEAN_00.averageGreen,
1148  TEX_WORLD_TERRAIN_OCEAN_00.averageBlue);
1149  }
1150  else if(world->isLand(tileX,tileY)==true)
1151  {
1152  glColor3ub(TEX_WORLD_TERRAIN_GRASS_00.averageRed,TEX_WORLD_TERRAIN_GRASS_00.averageGreen,
1153  TEX_WORLD_TERRAIN_GRASS_00.averageBlue);
1154  }
1155  }
1156  // draw normal colour mode
1157  else
1158  {
1159  // Cool feature where we keep track of the average colour of a texture and just draw that colour
1160  // in colour mode. Could also be adapted for distant rendering.
1161  // it allows for much smoother transition between texture and colur mode
1162  if(world->isSafe(tileX,tileY)==true && world->isLand(tileX,tileY)==false)
1163  {
1164  glColor3ub(TEX_WORLD_TERRAIN_OCEAN_00.averageRed,TEX_WORLD_TERRAIN_OCEAN_00.averageGreen,
1165  TEX_WORLD_TERRAIN_OCEAN_00.averageBlue);
1166  }
1167  else if(world->isSafe(tileX,tileY)==true && world->isLand(tileX,tileY)==true)
1168  {
1169  //glColor3ub(TEX_WORLD_TERRAIN_GRASS_00.averageRed,TEX_WORLD_TERRAIN_GRASS_00.averageGreen,
1170  //TEX_WORLD_TERRAIN_GRASS_00.averageBlue);
1171  Texture * tex = world->aWorldTile(tileX,tileY).currentTexture();
1172  if ( tex )
1173  {
1174  glColor3ub(tex->averageRed,tex->averageGreen,tex->averageBlue);
1175  }
1176  }
1177  else
1178  {
1179  //glColor3ub(world->aTopoMap(tileX,tileY,0),world->aTopoMap(tileX,tileY,1),
1180  //world->aTopoMap(tileX,tileY,2));
1181  }
1182  }
1183  }
1184 
1185  // final case
1186  else if(world->isSafe(tileX-1,tileY)==true)
1187  {
1188  glVertex2s(currentX,currentY);
1189  glVertex2s(currentX,currentY+tileSize);
1190  }
1191  ++tileX;
1192  tileX+=tilesToSkip;
1193  }
1194  glEnd();
1195 
1196  tileX=revertTileX;
1197  ++tileY;
1198  tileY+=tilesToSkip;
1199  }
1200  }
1201 
1202  // return the maximum number of tiles that fit on the current panel along X axis
1203  inline double getTilesNX()
1204  {
1205  return mainViewNX/tileSize;
1206  }
1207  // return the maximum number of tiles that fit on the current panel along Y axis
1208  inline double getTilesNY()
1209  {
1210  return mainViewNY/tileSize;
1211  }
1212 
1213 };
1215 
1216 
1218 {
1219  if (world==0 || worldViewer.pixelsPerLocalTile < 1)
1220  {return;}
1221 
1222  unsigned long int bX,bY;
1223  worldViewer.toTileCoords(0,0,&bX,&bY);
1224 
1225  Renderer::setColourMode();
1226  glColor3ub(0,0,220);
1227  for (int i=0;i<vRainDrop.size();++i)
1228  {
1229  int rX = vRainDrop(i)->x;
1230  int rY = vRainDrop(i)->y;
1231  unsigned long int aX,aY;
1232 
1233  worldViewer.toTileCoords(rX,rY,&aX,&aY);
1234 
1235  if ( world->isGenerated(aX,aY) )
1236  {
1237  if ( (*world)(aX,aY)->hasFloor == 0 )
1238  {
1239  vRainDrop(i)->render();
1240  }
1241  }
1242  else
1243  {
1244  vRainDrop(i)->render();
1245  }
1246  }
1247  glColor3ub(255,255,255);
1248  Renderer::setTextureMode();
1249 }
1250 
1251 #endif
Texture TEX_WORLD_TERRAIN_JUNGLE
Definition: Driver_TextureList.hpp:123
Definition: World_Viewer.hpp:66
World_Local * worldLocal
Definition: World_Viewer.hpp:171
unsigned char colourRed
Definition: Tribe.hpp:32
char hasSeen(World_Local *, int, int, bool isSubterranean=false)
Definition: Character.cpp:632
void drop(int amount)
Definition: World_Viewer.hpp:56
virtual Vector< Texture * > * currentTextures()
Definition: LocalTile.cpp:247
int DEBUG_Y
Definition: Driver_Settings.cpp:239
Definition: World_Viewer.hpp:127
int firstPixelY
Definition: World_Viewer.hpp:160
RainManager()
Definition: World_Viewer.hpp:82
World * world
Definition: World_Viewer.hpp:170
const int LOCAL_MAP_SIZE
Definition: Driver_Settings.cpp:168
bool alternateTile
Definition: World_Viewer.hpp:176
WorldViewer()
Definition: World_Viewer.hpp:196
void toScreenCoords(const int _tileX, const int _tileY, int *_pixelX, int *_pixelY)
Definition: World_Viewer.hpp:425
Definition: World_Viewer.hpp:46
unsigned long int firstTileAbsY
Definition: World_Viewer.hpp:159
unsigned char bWall
Definition: LocalTile.hpp:55
Definition: World.hpp:46
int tileSize
Definition: World_Viewer.hpp:148
World world
Definition: Driver.cpp:43
bool FOG_OF_WAR
Definition: Driver_Settings.cpp:126
void toTileCoords(int pixelX, int pixelY, unsigned long int *absX, unsigned long int *absY)
Definition: World_Viewer.hpp:480
Vector< WorldObjectGlobal * > vWorldObjectGlobal
Definition: World.hpp:100
int centerLocalY
Definition: World_Viewer.hpp:163
void setCenterTile(const double _centerTileX, const double _centerTileY, const int _subTileX=LOCAL_MAP_SIZE/2, const int _subTileY=LOCAL_MAP_SIZE/2)
Definition: World_Viewer.hpp:414
bool tilesetMode
Definition: World_Viewer.hpp:187
bool isRaining
Definition: World.hpp:135
void render()
Definition: World_Viewer.hpp:603
Texture TEX_WORLD_TERRAIN_MOUNTAIN_00
Definition: Driver_TextureList.hpp:148
Definition: WorldObjectGlobal.hpp:17
void switchTarget(World_Local *_worldLocal)
Definition: World_Viewer.hpp:314
Definition: Driver_Settings.cpp:111
WorldViewer worldViewer
Definition: World_Viewer.hpp:1214
void setTileSize(const int _tileSize)
Definition: World_Viewer.hpp:307
ArrayS2< World_Local > aWorldTile
Definition: World.hpp:103
void queryTileLocal(int hoveredXTile, int hoveredYTile)
Definition: World.cpp:1986
int nY
Definition: World.hpp:65
int x
Definition: World_Viewer.hpp:49
ArrayS3< unsigned char > aTopoMap
Definition: World.hpp:97
int DEBUG_X
Definition: Driver_Settings.cpp:238
RainManager rainManager
Definition: World_Viewer.hpp:144
bool isGenerated(unsigned long int _absoluteX, unsigned long int _absoluteY)
Definition: World.cpp:481
RainDrop()
Definition: World_Viewer.hpp:51
int worldY
Definition: WorldObjectGlobal.hpp:22
Definition: World_Local.hpp:58
unsigned long int hoveredAbsoluteY
Definition: World_Viewer.hpp:181
void renderColourMode(int tileX, int tileY, float pixelTileX, float pixelTileY)
Definition: World_Viewer.hpp:1107
Texture TEX_WORLD_TERRAIN_GRASS_00
Definition: Driver_TextureList.hpp:74
Texture TEX_WORLD_TERRAIN_HILL
Definition: Driver_TextureList.hpp:151
void renderWorldIcons()
Definition: World_Viewer.hpp:506
int tilesToSkip
Definition: World_Viewer.hpp:184
Character * playerCharacter
Definition: Driver_Settings.cpp:105
void updateRain()
Definition: World_Viewer.hpp:98
unsigned char colourGreen
Definition: Tribe.hpp:33
int worldX
Definition: WorldObjectGlobal.hpp:22
#define ABSOLUTE_COORDINATE_NULL
Definition: Driver_Settings.cpp:218
double demoScroll
Definition: World_Viewer.hpp:194
short int lastMouseY
Definition: World_Viewer.hpp:168
int firstTileY
Definition: World_Viewer.hpp:158
bool panning
Definition: World_Viewer.hpp:173
bool landMode
Definition: World_Viewer.hpp:189
enumMenu activeMenu
Definition: Driver_Settings.cpp:113
bool showHoveredTile
Definition: World_Viewer.hpp:182
void renderLocalMap(World_Local *localMap, int currentX, int currentY)
Definition: World_Viewer.hpp:721
unsigned char colourBlue
Definition: Tribe.hpp:34
void setPanel(const int _x1, const int _y1, const int _x2, const int _y2)
Definition: World_Viewer.hpp:398
float panY
Definition: World_Viewer.hpp:174
short int height
Definition: LocalTile.hpp:62
bool territoryView
Definition: World_Viewer.hpp:186
void render()
Definition: World_Viewer.hpp:60
int nX
Definition: World.hpp:65
double getTilesNX()
Definition: World_Viewer.hpp:1203
double pixelsPerLocalTile
Definition: World_Viewer.hpp:164
bool isSafe(int _x, int _y)
Definition: World.cpp:470
double getTilesNY()
Definition: World_Viewer.hpp:1208
bool mouseEvent(Mouse *mouse)
Definition: World_Viewer.hpp:341
Definition: Tribe.hpp:21
Definition: LocalTile.hpp:34
Data_Subterranean * dataSubterranean
Definition: World_Local.hpp:155
enumBiome baseBiome
Definition: World_Local.hpp:247
void updateScene()
Definition: World_Viewer.hpp:599
ArrayS2< int > aRiverID
Definition: World.hpp:109
int y
Definition: World_Viewer.hpp:49
std::atomic< bool > initialized
Definition: World_Local.hpp:176
Data * data
Definition: World_Local.hpp:154
void zoomOut()
Definition: World_Viewer.hpp:298
bool active
Definition: World_Viewer.hpp:146
void render()
Definition: World_Viewer.hpp:1217
bool isLand(int _x, int _y)
Definition: World.cpp:1182
Texture TEX_WALL_GREYBRICK_SOUTH
Definition: Driver_TextureList.hpp:224
int hoveredYTile
Definition: World_Viewer.hpp:179
Texture TEX_WORLD_TERRAIN_OCEAN_00
Definition: Driver_TextureList.hpp:103
bool keyboardEvent(Keyboard *_keyboard)
Definition: World_Viewer.hpp:261
int hoveredYTileLocal
Definition: World_Viewer.hpp:180
void normaliseCoordinates()
Definition: World_Viewer.hpp:321
void init(int _x1, int _y1, int _x2, int _y2, World *_world, int _maxRain=10000, double _rainPercentOfX=0.005)
Definition: World_Viewer.hpp:84
Texture TEX_WORLD_TERRAIN_RIVER_FULL
Definition: Driver_TextureList.hpp:92
bool subterraneanMode
Definition: World_Viewer.hpp:188
void renderTextureMode(int tileX, int tileY, float pixelTileX, float pixelTileY)
Definition: World_Viewer.hpp:980
virtual Texture * currentTexture()
Definition: World_Local.cpp:2832
Vector< World_Local * > vWorldLocal
Definition: World.hpp:105
double centerTileY
Definition: World_Viewer.hpp:154
Texture TEX_WORLD_TERRAIN_FOREST_TREES
Definition: Driver_TextureList.hpp:120
void queryTile(int hoveredXTile, int hoveredYTile)
Definition: World.cpp:1977
bool demoMode
Definition: World_Viewer.hpp:193
void centerView()
Definition: World_Viewer.hpp:249
Calendar calendar
Definition: World.hpp:131
void generateLocal(const int, const int)
Definition: World.cpp:1636
void zoomIn()
Definition: World_Viewer.hpp:285