r129 - trunk/src

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Aug 31 16:41:43 EDT 2005


Author: jonas
Date: 2005-08-31 16:41:43 -0400 (Wed, 31 Aug 2005)
New Revision: 129

Modified:
   trunk/src/common.cpp
   trunk/src/common.h
   trunk/src/editor.cpp
   trunk/src/gfxeng.cpp
   trunk/src/input.cpp
   trunk/src/lost_penguins.cpp
   trunk/src/menu.cpp
   trunk/src/physics.cpp
Log:
show cursor when appropriate, allow to disable animations (faster), always reloadMap before placing a unit

Modified: trunk/src/common.cpp
===================================================================
--- trunk/src/common.cpp	2005-08-31 15:44:55 UTC (rev 128)
+++ trunk/src/common.cpp	2005-08-31 20:41:43 UTC (rev 129)
@@ -37,3 +37,30 @@
     if (a>=0) return a=max(0,a+b);
     else return a=min(0,a-b);
 }
+
+void setGameMode(Uint8 newmode) {
+    game_mode=newmode;
+    if (game_mode&GAME_EDIT && !(game_mode&GAME_MENU)) {
+        SDL_ShowCursor(SDL_ENABLE);
+    } else {
+        SDL_ShowCursor(SDL_DISABLE);
+    }
+}
+
+void addGameMode(Uint8 addmode) {
+    game_mode|=addmode;
+    if (game_mode&GAME_EDIT && !(game_mode&GAME_MENU)) {
+        SDL_ShowCursor(SDL_ENABLE);
+    } else {
+        SDL_ShowCursor(SDL_DISABLE);
+    }
+}
+
+void removeGameMode(Uint8 rmmode) {
+    game_mode&=~rmmode;
+    if (game_mode&GAME_EDIT && !(game_mode&GAME_MENU)) {
+        SDL_ShowCursor(SDL_ENABLE);
+    } else {
+        SDL_ShowCursor(SDL_DISABLE);
+    }
+}

Modified: trunk/src/common.h
===================================================================
--- trunk/src/common.h	2005-08-31 15:44:55 UTC (rev 128)
+++ trunk/src/common.h	2005-08-31 20:41:43 UTC (rev 129)
@@ -65,8 +65,9 @@
 
 #define GAME_PAUSED         0x00000001
 #define GAME_PLAY           0x00000002
-#define GAME_EDIT           0x00000004
-#define GAME_MENU           0x00000008
+#define GAME_MENU           0x00000004
+#define GAME_EDIT           0x00000008
+#define GAME_EDIT_NOANIM    0x00000010
 
 enum ConfigKey {
     KEY_START,
@@ -85,7 +86,8 @@
     KEY_FPS,
     KEY_BAR,
     KEY_FULL,
-    KEY_QUIT
+    KEY_QUIT,
+    KEY_NOANIM
 };
 
 /**\brief Collision type
@@ -143,6 +145,12 @@
 /// Helper function boost that increases/decreases the absolute value
 int boost(int,int);
 
+/// Set game mode
+void setGameMode(Uint8);
+/// Add game mode
+void addGameMode(Uint8);
+/// Remove game mode
+void removeGameMode(Uint8);
 /// Set the current menu
 Menu* setMenu(Menu* newmenu);
 /// Close the current menus

Modified: trunk/src/editor.cpp
===================================================================
--- trunk/src/editor.cpp	2005-08-31 15:44:55 UTC (rev 128)
+++ trunk/src/editor.cpp	2005-08-31 20:41:43 UTC (rev 129)
@@ -3,6 +3,7 @@
 #include "objectpools.h"
 #include "menu.h"
 #include "font.h"
+#include "gfxeng.h"
 #include "editor.h"
 
 
@@ -19,6 +20,7 @@
 }
 
 void Editor::run_action(Uint32 action, Uint16 x, Uint16 y) {
+    gfxeng->update(UPDATE_ALL);
     if (action&EDIT_RESET_ACTIONS) {
         for (Uint8 i=0; i<6; i++) {
             action_mouse_pressed[i]=NOTHING;
@@ -32,6 +34,7 @@
     } else if (action&EDIT_ACT_BOX) {
         if (box) box->act(box->getCurrentEntry(x,y));
     } else if (action&EDIT_PLACE_OBJECT) {
+        scenario->reloadMap();
         string next_name=scenario->pool->getNextObjectName(place_name);
         if (scenario->pool->addObjectbyName(place_name,place_image,x,y,next_name)) {
             appendtoBuf(place_name+" "+place_image+" "+itos(x)+" "+itos(y)+" "+next_name);
@@ -73,10 +76,12 @@
 }
 
 Box* Editor::setBox(Box* newbox) {
+    gfxeng->update(UPDATE_ALL);
     return box=newbox;   
 }
  
 void Editor::closeBox() {
+    gfxeng->update(UPDATE_ALL);
     if (box) delete box;
     box=NULL;
 }
@@ -95,6 +100,7 @@
 }
  
 void Box::act(Sint8) {
+    gfxeng->update(UPDATE_ALL);
     editor->closeBox();
 }
  
@@ -130,6 +136,7 @@
 }
  
 void Box::update() {
+    gfxeng->update(UPDATE_ALL);
     if (surface==NULL) {
         getArea();
         SDL_Surface* tmp=SDL_CreateRGBSurface(vflags, area.w, area.h, 32, rmask, gmask, bmask, amask);
@@ -200,6 +207,7 @@
 }
 
 void EditBox::act(Sint8 curentry) {
+    gfxeng->update(UPDATE_ALL);
     if (curentry==-1 || curentry >= (Sint8)entries.size()) {
         editor->closeBox();
     } else {

Modified: trunk/src/gfxeng.cpp
===================================================================
--- trunk/src/gfxeng.cpp	2005-08-31 15:44:55 UTC (rev 128)
+++ trunk/src/gfxeng.cpp	2005-08-31 20:41:43 UTC (rev 129)
@@ -71,9 +71,11 @@
     } else if (game_mode&GAME_EDIT) {
         if (show_fps) toggleFPS();
         if (show_bar) togglePlayerBar();
-        drawScene();
-        drawBox();
-        updatetype=UPDATE_ALL;
+        if (!(game_mode&GAME_EDIT_NOANIM) || updatetype==UPDATE_ALL) {
+            drawScene();
+            drawBox();
+            updatetype=UPDATE_ALL;
+        }
     } else return;
     //This is the most time consuming operation
     if (updatetype!=UPDATE_NOTHING) SDL_Flip(screen);

Modified: trunk/src/input.cpp
===================================================================
--- trunk/src/input.cpp	2005-08-31 15:44:55 UTC (rev 128)
+++ trunk/src/input.cpp	2005-08-31 20:41:43 UTC (rev 129)
@@ -109,7 +109,7 @@
                 if (key==config.keybind[KEY_SWITCH]) {
                      scenario->pool->switchPlayer();
                 } else if (key==config.keybind[KEY_PAUSE]) {
-                     game_mode&=~GAME_PAUSED;
+                     removeGameMode(GAME_PAUSED);
                      sfxeng->resumeMusic();
                 } else if (key==config.keybind[KEY_MENU]) {
                      sfxeng->pauseMusic();
@@ -151,7 +151,7 @@
                 if (key==config.keybind[KEY_SWITCH]) {
                      scenario->pool->switchPlayer();
                 } else if (key==config.keybind[KEY_PAUSE]) {  
-                     game_mode|=GAME_PAUSED;
+                     addGameMode(GAME_PAUSED);
                      sfxeng->playWAV(au_pause);
                      sfxeng->pauseMusic();
                 } else if (key==config.keybind[KEY_MENU]) {
@@ -204,13 +204,21 @@
                 SDLKey key=event.key.keysym.sym;
                 keypressed[key]=true;
                 if (key==config.keybind[KEY_FULL]) {
-                     gfxeng->toggleFullScreen();
+                    gfxeng->toggleFullScreen();
                 } else if (key==config.keybind[KEY_MENU]) {
-                     sfxeng->pauseMusic();
-                     setMenu(new EditMenu());
-                     gfxeng->update(UPDATE_ALL);
+                    sfxeng->pauseMusic();
+                    setMenu(new EditMenu());
+                    gfxeng->update(UPDATE_ALL);
                 } else if (key==config.keybind[KEY_QUIT]) {
-                     quitGame(0);
+                    quitGame(0);
+                } else if (key==config.keybind[KEY_NOANIM]) {
+                    gfxeng->update(UPDATE_ALL);
+                    if (game_mode&GAME_EDIT_NOANIM) {
+                        removeGameMode(GAME_EDIT_NOANIM);
+                    } else {
+                        scenario->reloadMap();
+                        addGameMode(GAME_EDIT_NOANIM);
+                    }
                 }
                 break;
             }

Modified: trunk/src/lost_penguins.cpp
===================================================================
--- trunk/src/lost_penguins.cpp	2005-08-31 15:44:55 UTC (rev 128)
+++ trunk/src/lost_penguins.cpp	2005-08-31 20:41:43 UTC (rev 129)
@@ -32,7 +32,7 @@
         cout << "Couldn't initialize SDL!\n";
         exit(-1);
     }
-    SDL_ShowCursor(SDL_ENABLE);
+    SDL_ShowCursor(SDL_DISABLE);
     //Change directory to datadir
 
     cout << "ImageCache...\n";
@@ -113,6 +113,7 @@
     config.keybind[KEY_SWITCH]  = SDLK_LCTRL;
     config.keybind[KEY_PAUSE]   = SDLK_TAB;
     config.keybind[KEY_MENU]    = SDLK_ESCAPE;
+    config.keybind[KEY_NOANIM]  = SDLK_F3;
     config.keybind[KEY_FPS]     = SDLK_F2;
     config.keybind[KEY_BAR]     = SDLK_F1;
     config.keybind[KEY_FULL]    = SDLK_f;

Modified: trunk/src/menu.cpp
===================================================================
--- trunk/src/menu.cpp	2005-08-31 15:44:55 UTC (rev 128)
+++ trunk/src/menu.cpp	2005-08-31 20:41:43 UTC (rev 129)
@@ -11,8 +11,8 @@
     if (menu) gfxeng->update(UPDATE_MENU);
     else gfxeng->update(UPDATE_ALL);
     newmenu->setLast(menu);
-    if (newmenu) game_mode|=GAME_MENU;
-    else game_mode&=~GAME_MENU;
+    if (newmenu) addGameMode(GAME_MENU);
+    else removeGameMode(GAME_MENU);
     return menu=newmenu;   
 }
  
@@ -22,8 +22,8 @@
         Menu* tmp=menu->getLast();
         delete menu;
         if (!tmp) gfxeng->update(UPDATE_ALL);
-        if (tmp) game_mode|=GAME_MENU;
-        else game_mode&=~GAME_MENU;
+        if (tmp) addGameMode(GAME_MENU);
+        else removeGameMode(GAME_MENU);
         return menu=tmp;
     } else {
         gfxeng->update(UPDATE_ALL);
@@ -66,7 +66,7 @@
     case 0: {
         if ((config.map!="") && (scenario->loadMap(config.map)==0)) {
             closeMenu();
-            game_mode|=GAME_PLAY;
+            addGameMode(GAME_PLAY);
             cout << "Starting game...\n" << endl;
         } else {
             cout << "Select a valid map first...\n" << endl;
@@ -78,7 +78,7 @@
         if ((config.map!="") && (scenario->loadMap(config.map)==0)) {
             closeMenu();
             cout << "Starting editor...\n" << endl;
-            game_mode|=GAME_EDIT;
+            addGameMode(GAME_EDIT);
             if (!editor) editor=new Editor();
         } else {
             cout << "Select a valid map first...\n" << endl;

Modified: trunk/src/physics.cpp
===================================================================
--- trunk/src/physics.cpp	2005-08-31 15:44:55 UTC (rev 128)
+++ trunk/src/physics.cpp	2005-08-31 20:41:43 UTC (rev 129)
@@ -38,6 +38,7 @@
         reset_time=false;
         tcurrent=SDL_GetTicks();
         updateGame();
+    } else if (game_mode&GAME_EDIT_NOANIM) {
     } else if (game_mode&GAME_EDIT) {
         if (reset_time) {
             dt=0;




More information about the lostpenguins-commits mailing list