/[projectaxis]/projectaxis/projectAxis/src/visual/mapwindow.cpp
ViewVC logotype

Diff of /projectaxis/projectAxis/src/visual/mapwindow.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by leiavoia, Sat Aug 9 18:23:49 2003 UTC revision 1.4 by leiavoia, Wed Aug 20 18:25:14 2003 UTC
# Line 9  Line 9 
9    
10  #include "renderman.h"  #include "renderman.h"
11    
 #include "../map/map.h"  
12  #include "../pods/pod.h"  #include "../pods/pod.h"
13  #include "uiscreen_main.h"  #include "uiscreen_main.h"
 #include "../core/pointerhub.h"  
14    
 // FIXME KILL ME AFTER 0.0.5 DEMO  
 #include "../map/blotchmaker.h"  
15    
16    
17    
18    
19  //CONSTANTS  //CONSTANTS
20  static const int RECENTER_BUFFER = 4; // the buffer space in tiles that a pod must be outside of to warrant recentering the map  static const int RECENTER_BUFFER = 3; // the buffer space in tiles that a pod must be outside of to warrant recentering the map
21    
22    
23    
# Line 29  static const int RECENTER_BUFFER = 4; // Line 25  static const int RECENTER_BUFFER = 4; //
25  PG_MapWindow::PG_MapWindow(PG_Widget *parent, const PG_Rect &r):  PG_MapWindow::PG_MapWindow(PG_Widget *parent, const PG_Rect &r):
26          PG_Widget(parent, r, 0) // yes we do want an object drawing surface          PG_Widget(parent, r, 0) // yes we do want an object drawing surface
27          {          {
28    
29            // FIXME: variable buffer depending on tilesize: RECENTER_BUFFER = (rm->GetTileSize()==32) ? 2 : 1;
30    
31          bg_y = 0;          bg_y = 0;
32          bg_x = 0;          bg_x = 0;
33          window_h = r.h;          window_h = r.h;
# Line 43  PG_MapWindow::PG_MapWindow(PG_Widget *pa Line 42  PG_MapWindow::PG_MapWindow(PG_Widget *pa
42                  // fill in the new row                  // fill in the new row
43                  for (int y=0; y < rows; y++) {                  for (int y=0; y < rows; y++) {
44                          tile_array[x][y] = new PG_MapTile(this, PG_Rect(x*rm->GetTileSize(), y*rm->GetTileSize(), rm->GetTileSize(), rm->GetTileSize()));                          tile_array[x][y] = new PG_MapTile(this, PG_Rect(x*rm->GetTileSize(), y*rm->GetTileSize(), rm->GetTileSize(), rm->GetTileSize()));
45                            // set an event object for each one of these babies!
46                            tile_array[x][y]->SetEventObject(MSG_BUTTONCLICK, this, (MSG_CALLBACK_OBJ)&PG_MapWindow::handle_forward_tile_click, (void*)tile_array[x][y]);
47                          }                          }
48                  }                  }
49    
# Line 91  void PG_MapWindow::MovePod(int x1, int y Line 92  void PG_MapWindow::MovePod(int x1, int y
92                  tile_array[x2 - bg_x][y2 - bg_y]->SetCoordsAndDraw(x2,y2);                  tile_array[x2 - bg_x][y2 - bg_y]->SetCoordsAndDraw(x2,y2);
93                  }                  }
94    
         // update the minimap too  
         // FIXME: move this up to UISCreen _Main  
         PG_Widget* parent = GetParent();  
         UIScreen_Main* main = dynamic_cast<UIScreen_Main*>(parent);  
         main->GetMiniMap()->DrawMapWithBounds(bg_x, bg_y, bg_x+int(window_w/rm->GetTileSize()), bg_y+int(window_h/rm->GetTileSize()));  
   
95          }          }
96    
97    
# Line 128  void PG_MapWindow::CenterMap(int x, int Line 123  void PG_MapWindow::CenterMap(int x, int
123    
124    
125    
126    
127    
128    
129    
# Line 149  void PG_MapWindow::DrawMap() { Line 144  void PG_MapWindow::DrawMap() {
144  int PG_MapWindow::GetBgX() { return bg_x; }  int PG_MapWindow::GetBgX() { return bg_x; }
145  int PG_MapWindow::GetBgY() { return bg_y; }  int PG_MapWindow::GetBgY() { return bg_y; }
146  void PG_MapWindow::SetBgX(int x) { bg_x = x; }  void PG_MapWindow::SetBgX(int x) { bg_x = x; }
147  void PG_MapWindow::SetBgY(int x) { bg_y = y; }  void PG_MapWindow::SetBgY(int x) { bg_y = x; }
148    int  PG_MapWindow::GetRows() { return rows; }
149    int  PG_MapWindow::GetCols() { return cols; }
   
   
 bool PG_MapWindow::RegenMap() {  
   
         Blotchmaker* blotchmaker = new Blotchmaker;  
   
         // Group vars:  
         blotchmaker->SetHBSize(1);  
         blotchmaker->SetMaxBlotches(20);  
         blotchmaker->SetTypeChances(7,3);  
         blotchmaker->SetAxisPalette(OBST_GREEN, OBST_BLUE, OBST_YELLOW, OBST_RED);  
         blotchmaker->SetMapInit(OBST_BLOCK);  
   
         // SLOT 0  
         blotchmaker->SetBlotchType(0, OBST_EMPTY);  
         blotchmaker->SetTilesPerBlotch(0, 25);  
         blotchmaker->SetModeChances(0, 0, 1, 0, 0);  
         blotchmaker->SetTurnChances(0, 8, 1, 0, 0);  
         blotchmaker->SetBlankShotChance(0, 0);  
         blotchmaker->SetEdgeGrav(0, 0);  
         blotchmaker->SetEdgeDet(0, 0);  
         blotchmaker->SetBrush(0, RE);  
         blotchmaker->SetStep(0, 1);  
   
         // SLOT 1  
         blotchmaker->SetBlotchType(1, OBST_EMPTY);  
         blotchmaker->SetTilesPerBlotch(1, 1);  
         blotchmaker->SetModeChances(1, 0, 1, 0, 0);  
         blotchmaker->SetTurnChances(1, 1, 1, 0, 0);  
         blotchmaker->SetBlankShotChance(1, 0);  
         blotchmaker->SetEdgeGrav(1, 0);  
         blotchmaker->SetEdgeDet(1, 0);  
         blotchmaker->SetBrush(1, MC);  
         blotchmaker->SetStep(1, 1);  
   
         if ( blotchmaker->StartBlotching() ) {  
                 DrawMap();  
                 delete blotchmaker;  
                 return 1;  
                 }  
         else {  
                 DrawMap();  
                 delete blotchmaker;  
                 return 0;  
                 }  
   
         }  
   
   
   
150    
151    
152    
153    // EVENTS ------------------------------------------------
154    
155    
 // EVENTS ------------------------------------------------  
156    
 PARAGUI_CALLBACK(PG_MapWindow::handle_vscroll) {  
         PG_ScrollBar* bar = (PG_ScrollBar*)clientdata;  
         bg_y = bar->GetPosition();  
         DrawMap();  
         return true;  
 }  
157    
158  PARAGUI_CALLBACK(PG_MapWindow::handle_hscroll) {  PARAGUI_CALLBACK(PG_MapWindow::handle_forward_tile_click) {
159          PG_ScrollBar* bar = (PG_ScrollBar*)clientdata;          // decode the calling tile
160          bg_x = bar->GetPosition();          PG_MapTile* tile = (PG_MapTile*)clientdata;
161          DrawMap();          
162          return true;          // update the panel module that displays the tile details
163  }          PG_Widget* temp = GetParent();
164            UIScreen_Main* s = dynamic_cast<UIScreen_Main*>(temp);
165            s->GetPanel()->ReceiveMaptileClick(  tile->GetX(), tile->GetY()  );
166    
167            return true;
168            }
169    
170    
171    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26