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

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

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

revision 1.1 by leiavoia, Fri Jul 25 21:16:31 2003 UTC revision 1.2 by leiavoia, Fri Aug 8 01:49:15 2003 UTC
# Line 5  uiscreen_main.cpp Line 5  uiscreen_main.cpp
5  */  */
6    
7    
8    
9    
   
 #include "uiscreen.h"  
10  #include "uiscreen_main.h"  #include "uiscreen_main.h"
11  #include "renderman.h"  #include "renderman.h"
12    
13  #include <SDL/SDL.h>  #include <SDL/SDL.h>
14  #include <SDL/SDL_image.h>  #include <SDL/SDL_image.h>
15    
16    #include "pgminimap.h"
17  #include "mapwindow.h"  #include "mapwindow.h"
18  #include "paragui.h"  #include "paragui.h"
19  #include "pgscrollbar.h"  #include "pgscrollbar.h"
# Line 23  uiscreen_main.cpp Line 23  uiscreen_main.cpp
23  #include "pgthemewidget.h"  #include "pgthemewidget.h"
24    
25    
26    #include "../core/pointerhub.h"
27    
28    
29    
30    
31  //  FIXME KILL ME AFTER FOOTBALL DEMO ?  //  FIXME KILL ME AFTER FOOTBALL DEMO ?
32  #include "../pods/pod.h"  #include "../pods/pod.h"
33    
34    
35  // UISCREEN_MAIN ---------------\/----------------  // UISCREEN_MAIN ---------------\/----------------
36  UIScreen_Main::UIScreen_Main(PG_Widget* parent, const PG_Rect &r): UIScreen(parent, r) {  UIScreen_Main::UIScreen_Main(PG_Widget* parent, const PG_Rect &r) :PG_ThemeWidget(parent, r, "ThemeWidget") {
37    
38    
39    
40          // the panel window          // the panel window
41          panel = new PG_Window(this, PG_Rect(0,0,240,768), "", WF_DEFAULT, "", 0);          panel = new PG_ThemeWidget(this, PG_Rect(0,0,240,768), 1);
42          panel->SetBackground("graphics/UI/screen_main/panel_bg.png", BKMODE_TILE);          panel->SetBackground("graphics/UI/screen_main/panel_bg.png", BKMODE_TILE);
         panel->Show();  
43    
44    
45            // panel divs:
46            PG_Point pt;
47    
48            pt.x=0; pt.y=52;
49            panel_div_a = new PG_Image(panel, pt, "graphics/UI/screen_main/panel_div.png");
50    
51          /*          pt.x=0; pt.y=528;
52          PG_Button* ba = new PG_Button(panel, 201, PG_Rect(15,15,32,32), "");          panel_div_a = new PG_Image(panel, pt, "graphics/UI/screen_main/panel_div.png");
53    
54    
55            // top UI navigation buttons
56            ba = new PG_Button(panel, 201, PG_Rect(15,15,32,32), "");
57          ba->SetIcon2("graphics/UI/buttons/square-norm.png", "graphics/UI/buttons/square-down.png", "graphics/UI/buttons/square-over.png");          ba->SetIcon2("graphics/UI/buttons/square-norm.png", "graphics/UI/buttons/square-down.png", "graphics/UI/buttons/square-over.png");
58          ba->LoadThemeStyle("Button","ImgButton");          ba->LoadThemeStyle("Button","ImgButton");
59          ba->SetBorderSize(0,0,0);          ba->SetBorderSize(0,0,0);
         ba->Show();  
60    
61          PG_Button* bb = new PG_Button(panel, 202, PG_Rect(50,15,32,32), "");          bb = new PG_Button(panel, 202, PG_Rect(50,15,32,32), "");
         bb->SetIcon2("graphics/UI/buttons/triangle-norm.png", "graphics/UI/buttons/triangle-down.png", "graphics/UI/buttons/triangle-over.png");  
62          bb->LoadThemeStyle("Button","ImgButton");          bb->LoadThemeStyle("Button","ImgButton");
63            bb->SetIcon2("graphics/UI/buttons/triangle-norm.png", "graphics/UI/buttons/triangle-down.png", "graphics/UI/buttons/triangle-over.png");
64    
65          bb->SetBorderSize(0,0,0);          bb->SetBorderSize(0,0,0);
         bb->Show();  
66    
67          PG_Button* bc = new PG_Button(panel, 203, PG_Rect(85,15,32,32), "");          bc = new PG_Button(panel, 203, PG_Rect(85,15,32,32), "");
68          bc->SetIcon2("graphics/UI/buttons/circle-norm.png", "graphics/UI/buttons/circle-down.png", "graphics/UI/buttons/circle-over.png");          bc->SetIcon2("graphics/UI/buttons/circle-norm.png", "graphics/UI/buttons/circle-down.png", "graphics/UI/buttons/circle-over.png");
69          bc->LoadThemeStyle("Button","ImgButton");          bc->LoadThemeStyle("Button","ImgButton");
70          bc->SetBorderSize(0,0,0);          bc->SetBorderSize(0,0,0);
71          bc->Show();  
72          */          bd = new PG_Button(panel, 204, PG_Rect(120,15,32,32), "");
73    
74    
75    
76    
77    
78          // regenerate map button:          // regenerate map button:
79          b1 = new PG_Button(panel, 100, PG_Rect(15,100,150, 25), "Regenerate Map");          b1 = new PG_Button(panel, 100, PG_Rect(15,100,150, 25), "Regenerate Map");
80          b1->Show(true);  
   
81          // play football button          // play football button
82          b2 = new PG_Button(panel, 101, PG_Rect(15,130,150, 25), "Play Football");          b2 = new PG_Button(panel, 101, PG_Rect(15,130,150, 25), "Play Football");
         b2->Show(true);  
83    
84          //go back to start button          // tileset swap
85          b3 = new PG_Button(panel, 102, PG_Rect(15,650,150, 25), "Back To Start");          tileswap = new PG_Button(panel, 103, PG_Rect(15,160,150, 25), "Swap TileSets");
86          b3->Show(true);  
87            // go back to start button
88            b3 = new PG_Button(panel, 102, PG_Rect(15,190,150, 25), "Back To Start");
89    
90            // the minimap
91            minimap = new PG_MiniMap(panel, PG_Rect(20, 548, 200, 200));
92    
93    
94    
         /*  
         PG_Label lab1(&panel, PG_Rect(15,90,200,20), "This Is A Label");  
         lab1.Show();  
         */  
95    
96    
97          // the status bar          // the status bar
98          statbar = new PG_Window(this, PG_Rect(240,0,784,48), "", WF_DEFAULT, "", 0);          statbar = new PG_ThemeWidget(this, PG_Rect(240,0,784,48));
99          statbar->SetBackground("graphics/UI/screen_main/statusbar_bg.png", BKMODE_TILE);          statbar->SetBackground("graphics/UI/screen_main/statusbar_bg.png", BKMODE_TILE);
         statbar->Show();  
100    
101          status_label = new PG_Label(statbar, PG_Rect(10,10,784,28), "> READY");          status_label = new PG_Label(statbar, PG_Rect(10,10,784,28), "> READY");
102          status_label->SetIndent(5);          status_label->SetIndent(5);
103          status_label->SetID(200);          status_label->SetID(200);
104          status_label->Show();          status_label->LoadThemeStyle("Label", "StatusLabel");
105    
106            next_turn = new PG_Button(statbar, 210, PG_Rect(672, 12, 100, 24), "Next Turn");
107    
108    
109    
110    
111    
112          // the map window          // the map window
# Line 94  UIScreen_Main::UIScreen_Main(PG_Widget* Line 114  UIScreen_Main::UIScreen_Main(PG_Widget*
114          map_window->Show();          map_window->Show();
115    
116          v = new PG_ScrollBar(this, 2, PG_Rect(1008,48,16,720), PG_SB_VERTICAL);          v = new PG_ScrollBar(this, 2, PG_Rect(1008,48,16,720), PG_SB_VERTICAL);
117          v->SetRange(0, themap->GetRows() - int(704/32)  );          v->SetRange(0, themap->GetRows() - int(704/rm->GetTileSize())  );
         v->SetTransparency(0);  
118          v->SetPosition(0);          v->SetPosition(0);
         v->Show();  
119    
120          h = new PG_ScrollBar(this, 3, PG_Rect(240,752,768,16), PG_SB_HORIZONTAL);          h = new PG_ScrollBar(this, 3, PG_Rect(240,752,768,16), PG_SB_HORIZONTAL);
121          h->SetRange(0, themap->GetCols() - int(768/32)  );          h->SetRange(0, themap->GetCols() - int(768/rm->GetTileSize())  );
         h->SetTransparency(0);  
122          h->SetPosition(0);          h->SetPosition(0);
         h->Show(0);  
123    
124          //connect scrollbars with map window  
125    
126            // EVENTS
127          h->SetEventObject(MSG_SCROLLTRACK, map_window, (MSG_CALLBACK_OBJ)&PG_MapWindow::handle_hscroll, (void*)h);          h->SetEventObject(MSG_SCROLLTRACK, map_window, (MSG_CALLBACK_OBJ)&PG_MapWindow::handle_hscroll, (void*)h);
128          v->SetEventObject(MSG_SCROLLTRACK, map_window, (MSG_CALLBACK_OBJ)&PG_MapWindow::handle_vscroll, (void*)v);          v->SetEventObject(MSG_SCROLLTRACK, map_window, (MSG_CALLBACK_OBJ)&PG_MapWindow::handle_vscroll, (void*)v);
129          b1->SetEventObject(MSG_BUTTONCLICK, this, (MSG_CALLBACK_OBJ)&UIScreen_Main::handle_regen_map, (void*)b1);          b1->SetEventObject(MSG_BUTTONCLICK, this, (MSG_CALLBACK_OBJ)&UIScreen_Main::handle_regen_map, (void*)b1);
130          b2->SetEventObject(MSG_BUTTONCLICK, this, (MSG_CALLBACK_OBJ)&UIScreen_Main::handle_play_football, (void*)b2);          b2->SetEventObject(MSG_BUTTONCLICK, this, (MSG_CALLBACK_OBJ)&UIScreen_Main::handle_play_football, (void*)b2);
131          b3->SetEventObject(MSG_BUTTONCLICK, rm, (MSG_CALLBACK_OBJ)&RenderMan::handle_go_to_start, (void*)b3);          b3->SetEventObject(MSG_BUTTONCLICK, rm, (MSG_CALLBACK_OBJ)&RenderMan::handle_go_to_start, (void*)b3);
132            tileswap->SetEventObject(MSG_BUTTONCLICK, rm, (MSG_CALLBACK_OBJ)&RenderMan::handle_swap_tilesets, (void*)tileswap);
133            ba->SetEventObject(MSG_BUTTONCLICK, rm, (MSG_CALLBACK_OBJ)&RenderMan::handle_go_to_bm, (void*)ba);
134          }          }
135    
136    
# Line 120  UIScreen_Main::UIScreen_Main(PG_Widget* Line 139  UIScreen_Main::UIScreen_Main(PG_Widget*
139    
140  UIScreen_Main::~UIScreen_Main() {  UIScreen_Main::~UIScreen_Main() {
141    
         panel->RemoveAllChilds();  
         delete panel;  
   
         statbar->RemoveAllChilds();  
         delete statbar;  
   
         map_window->RemoveAllChilds();  
         delete map_window;  
   
         delete v;  
         delete h;  
   
142          }          }
143    
144    
# Line 139  UIScreen_Main::~UIScreen_Main() { Line 146  UIScreen_Main::~UIScreen_Main() {
146    
147    
148    
149  void UIScreen_Main::SetStatus(string &s) {  // GET FUNCTIONS
150          //status_label->SetString(s);  PG_Button* UIScreen_Main::GetB1() { return b1; }
151          }  PG_Button* UIScreen_Main::GetB2() { return b2; }
152    PG_Button* UIScreen_Main::GetB3() { return b3; }
153    PG_ThemeWidget* UIScreen_Main::GetPanel() { return panel; }
154    PG_Button* UIScreen_Main::GetTileSwapButton() { return tileswap; }
155    PG_ThemeWidget* UIScreen_Main::GetStatusBar() { return statbar; }
156    PG_Label* UIScreen_Main::GetStatusLabel() { return status_label; }
157    PG_MapWindow* UIScreen_Main::GetMapWindow() { return map_window; }
158    PG_ScrollBar* UIScreen_Main::GetVScroll() { return v; }
159    PG_ScrollBar* UIScreen_Main::GetHScroll() { return h; }
160    PG_MiniMap* UIScreen_Main::GetMiniMap() { return minimap; }
161    
162    
163    
# Line 160  PARAGUI_CALLBACK(UIScreen_Main::handle_r Line 175  PARAGUI_CALLBACK(UIScreen_Main::handle_r
175                  status_label->SetText("New map created (but was bad)");                  status_label->SetText("New map created (but was bad)");
176                  }                  }
177    
178            minimap->DrawMap();
179    
180          return true;          return true;
181  }  }
182    
# Line 182  PARAGUI_CALLBACK(UIScreen_Main::handle_p Line 199  PARAGUI_CALLBACK(UIScreen_Main::handle_p
199    
200          // set opponants          // set opponants
201          Pod* another_pod = new Pod(1);          Pod* another_pod = new Pod(1);
202          another_pod->Place(14,3);          another_pod->Place(0,10);
203          another_pod->AddMission(PATROL, 0);          another_pod->AddMission(PATROL, 0);
204    
205          Pod* another_pod2 = new Pod(1);          Pod* another_pod2 = new Pod(1);
# Line 193  PARAGUI_CALLBACK(UIScreen_Main::handle_p Line 210  PARAGUI_CALLBACK(UIScreen_Main::handle_p
210          another_pod3->Place(6,11);          another_pod3->Place(6,11);
211          another_pod3->AddMission(PATROL, 0);          another_pod3->AddMission(PATROL, 0);
212    
213            /* THIS IS HOW YOU CAST MISSION POINTERS
214            // get the mission ptr
215            Mission* mx = another_pod->Misn(0);
216            Patrol* p = dynamic_cast<Patrol*>(mx);
217            p->SetRad(10);
218    
219            cout << "Radius: " << p->GetRad() << endl;
220            */
221    
222    
223          // run the main loop          // run the main loop
224          for(int i=0; i<10; i++) {          for(int i=0; i<10; i++) {
225                  a_pod->Move();                  a_pod->Move();
# Line 216  PARAGUI_CALLBACK(UIScreen_Main::handle_p Line 243  PARAGUI_CALLBACK(UIScreen_Main::handle_p
243    
244    
245    
   
   
 void UIScreen_Main::MovePod(int x1, int y1, int x2, int y2) { // from where to where  
   
         // TODO update status bar  
   
         map_window->MovePod(x1, y1, x2, y2);  
   
         }  

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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