netpanzer-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netPanzer-CVS] netpanzer/src/NetPanzer Views/Game/MiniMapView....


From: Hankin Chick
Subject: [netPanzer-CVS] netpanzer/src/NetPanzer Views/Game/MiniMapView....
Date: Mon, 24 Nov 2003 08:14:57 -0500

CVSROOT:        /cvsroot/netpanzer
Module name:    netpanzer
Branch:         
Changes by:     Hankin Chick <address@hidden>   03/11/24 08:14:56

Modified files:
        src/NetPanzer/Views/Game: MiniMapView.cpp MiniMapView.hpp 
        src/NetPanzer/Interfaces: MiniMapInterface.cpp 

Log message:
        added scale/shade/dotsize buttons on the minimap
        maybe it needs some graphics here.

Patches:
Index: netpanzer/src/NetPanzer/Interfaces/MiniMapInterface.cpp
diff -u netpanzer/src/NetPanzer/Interfaces/MiniMapInterface.cpp:1.12 
netpanzer/src/NetPanzer/Interfaces/MiniMapInterface.cpp:1.13
--- netpanzer/src/NetPanzer/Interfaces/MiniMapInterface.cpp:1.12        Sat Nov 
22 04:46:40 2003
+++ netpanzer/src/NetPanzer/Interfaces/MiniMapInterface.cpp     Mon Nov 24 
08:14:56 2003
@@ -26,6 +26,7 @@
 #include "PathScheduler.hpp"
 #include "ObjectiveInterface.hpp"
 #include "GameConfig.hpp"
+#include "MiniMapView.hpp"
 
 fXY MiniMapInterface::scale_factor;
 bool MiniMapInterface::pathing_debug_mode = false;
@@ -88,7 +89,7 @@
 
     while( UnitInterface::unitPositionEnumeration( 
&unit_dispostion,&unit_state ) ) {
         map_loc.x = int(float(unit_state->location.x) / scale_factor.x);
-        map_loc.y = int(float(unit_state->location.y) / scale_factor.y);
+        map_loc.y = int(float(unit_state->location.y) / 
scale_factor.y)+MiniMapView::buttonSize.y;
 
         if (gameconfig->radar_unitsize == _mini_map_unit_size_large) {
             unitRect = iRect(map_loc, map_loc + iXY(1,1));
@@ -169,6 +170,8 @@
         map_rect.min.y = int(float(world_rect.min.y) / scale_factor.y);
         map_rect.max.x = int(float(world_rect.max.x) / scale_factor.x);
         map_rect.max.y = int(float(world_rect.max.y) / scale_factor.y);
+        map_rect.min.y+=MiniMapView::buttonSize.y;
+        map_rect.max.y+=MiniMapView::buttonSize.y;
 
         // Removed black borders to the text.
         if (gameconfig->radar_objectivedrawmode == 
_mini_map_objective_draw_mode_solid_rect) {
@@ -200,6 +203,8 @@
 
               src.x  = int(float(obj_state->location.x) / scale_factor.x);
               src.y  = int(float(obj_state->location.y) / scale_factor.y);
+              src.y+=MiniMapView::buttonSize.y;
+              dest.y+=MiniMapView::buttonSize.y;
               map_surface.drawLine(src.x, src.y, dest.x, dest.y, color);
             }
         }
Index: netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp
diff -u netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp:1.24 
netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp:1.25
--- netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp:1.24     Sat Nov 22 
07:38:23 2003
+++ netpanzer/src/NetPanzer/Views/Game/MiniMapView.cpp  Mon Nov 24 08:14:55 2003
@@ -26,13 +26,17 @@
 #include "ScreenSurface.hpp"
 #include "WorldInputCmdProcessor.hpp"
 #include "GameConfig.hpp"
+#include "GameViewGlobals.hpp"
+#include "Util/Log.hpp"
 
-MiniMapView miniMapView;
 
 
 float MiniMapView::scaleDelta   = 400.0f;
 int   MiniMapView::decreaseSize = 0;
 int   MiniMapView::increaseSize = 0;
+iXY   MiniMapView::buttonSize(12,12);
+
+MiniMapView miniMapView;
 
 // MiniMapView
 //---------------------------------------------------------------------------
@@ -52,6 +56,27 @@
     add(CLOSE_VIEW_BUTTON);
     add(MINMAX_VIEW_BUTTON);
 
+    iXY pos(1,1);
+    scaleDownButton.setLabel("<"); 
+    scaleDownButton.setBounds(iRect(pos, pos + buttonSize)); 
+    add(&scaleDownButton);
+    pos.x+=buttonSize.x;
+
+    scaleUpButton.setLabel(">"); 
+    scaleUpButton.setBounds(iRect(pos, pos + buttonSize)); 
+    add(&scaleUpButton);
+    pos.x+=buttonSize.x;
+
+    shadeButton.setLabel("o"); 
+    shadeButton.setBounds(iRect(pos, pos + buttonSize)); 
+    add(&shadeButton);
+    pos.x+=buttonSize.x;
+
+    dotSizeButton.setLabel("."); 
+    dotSizeButton.setBounds(iRect(pos, pos + buttonSize)); 
+    add(&dotSizeButton);
+    pos.x+=buttonSize.x;
+
     resize(100, 100);
 } // end MiniMapView::MiniMapView
 
@@ -63,19 +88,18 @@
     miniMap = MiniMapInterface::getMiniMap();
 
     //iXY size = miniMap->getPix();
-    iXY size(((const iXY &)gameconfig->minimapsize)+iXY(2,2));
+    iXY size(((const iXY &)gameconfig->minimapsize)+iXY(2,2+buttonSize.y));
     resize(size);
 
     if(gameconfig->minimapposition.isDefaultValue()) {
         gameconfig->minimapposition = iXY(0, screen->getPix().y - 196);
     }
     moveTo(gameconfig->minimapposition);
-    checkArea(screen->getPix());
 
     //int xOffset = size.x;
     //int yOffset = 0;
 
-    MiniMapInterface::setMapScale(getSize() - iXY(2,2));
+    setMapScale();
     checkArea(screen->getPix());
 
     minMapSize =  64;
@@ -114,6 +138,13 @@
     Surface *miniMap;
     miniMap = MiniMapInterface::getMiniMap();
 
+    iRect r(iXY(0,0), getSize());
+    iRect buttonsRect(r);
+
+    buttonsRect.max.y=buttonSize.y+1;
+    r.min.y+=buttonSize.y;
+    bltBlendRect(viewArea,buttonsRect);
+
     if (needScale) {
         scaleGroupWait += dt;
 
@@ -121,7 +152,7 @@
             miniMapSurface.create(getSize(), getSize().x , 1);
 
             //miniMapSurface.scale(getViewRect().getSize());
-            iRect r(iXY(0, 0), getSize());
+//            iRect r(iXY(0, 0), getSize());
 
             miniMapSurface.bltScale(*miniMap, r);
 
@@ -130,7 +161,6 @@
         }
     }
 
-    iRect r(iXY(0,0), getSize());
 
     int mapDrawType=gameconfig->minimapdrawtype;
     if (needScale) {
@@ -182,7 +212,7 @@
 
     // Draw the world view box.
     iRect boxpos = MiniMapInterface::getWorldWindow();
-    boxpos.translate(iXY(1,1));                           
+    boxpos.translate(iXY(1,1+buttonSize.y));
     
     clientArea.bltLookup(boxpos, Palette::darkGray256.getColorArray());
     // Draw the units and such on the minimap.
@@ -192,7 +222,7 @@
 
     // If the mouse is over the client area, then change the cursor.
     if (getClientRect().contains(getScreenToClientPos(mouse.getScreenPos()))) {
-        if (selectionAnchor) {
+        if (selectionAnchor && mouse.getScreenPos().y>=buttonSize.y) {
             // Since we are selecting units, draw the selection box.
             clientArea.drawRect(selectionAnchorDownPos, selectionAnchorCurPos, 
Color::white);
         } else {
@@ -236,7 +266,9 @@
     iXY   pos(getScreenToClientPos(mouse.getScreenPos()));
 
     //dest.drawRect(pos - size - 1, pos + size - 1, Color::yellow);
-    dest.drawBoxCorners(pos - size - iXY(1,1), iXY(pos.x + size.x - 1, pos.y + 
size.y), 5, Color::red);
+    if(pos.y>=buttonSize.y) {
+        dest.drawBoxCorners(pos - size - iXY(1,1), iXY(pos.x + size.x - 1, 
pos.y + size.y), 5, Color::red);
+    }
 
 } // end MiniMapView::drawMouseBox
 
@@ -249,15 +281,44 @@
 {
     assert(this != 0);
 
-    if (getClientRect().contains(getScreenToClientPos(mouse.getScreenPos()))) {
-        if (!selectionAnchor) {
-            setViewWindow(pos);
+    if(!setViewWindowFromMouse(pos)) {
+        GameTemplateView::lMouseDown(pos);
+    }
+} // end MiniMapView::lMouseDown
+
+bool MiniMapView::setViewWindowFromMouse(const iXY &pos)
+{
+    if (pos.y>=buttonSize.y) {
+        if(getClientRect().contains(getScreenToClientPos(mouse.getScreenPos()))
+            && !selectionAnchor) {
+            setViewWindow(pos-iXY(0,buttonSize.y));
         }
+        return true;
     }
+    return false;
+}
 
-    GameTemplateView::lMouseDown(pos);
 
-} // end MiniMapView::lMouseDown
+void MiniMapView::actionPerformed(mMouseEvent me)
+{
+    assert(this != 0);
+
+
+    if (me.getID() == mMouseEvent::MOUSE_EVENT_CLICKED) {
+        if (me.getSource(shadeButton)) {
+            int newtype=(gameconfig->minimapdrawtype+1)%MAP_DRAW_TYPES_MAX;
+            setMapDrawType(newtype);
+        } else if (me.getSource(scaleUpButton)) {
+            increaseSize = -1;
+        } else if (me.getSource(scaleDownButton)) {
+            decreaseSize = -1;
+        } else if (me.getSource(dotSizeButton)) {
+            gameconfig->radar_unitsize = 
gameconfig->radar_unitsize==_mini_map_unit_size_large?_mini_map_unit_size_small:_mini_map_unit_size_large;
+        }
+    }
+    GameTemplateView::actionPerformed(me);
+}
+
 
 // rMouseDown
 //--------------------------------------------------------------------------
@@ -267,7 +328,7 @@
 
 } // end MiniMapView::rMouseDown
 
-void MiniMapView::setMapDrawType(MAP_DRAW_TYPES type)
+void MiniMapView::setMapDrawType(int type)
 {
     gameconfig->minimapdrawtype=type;
 }
@@ -309,6 +370,13 @@
 
 } // end MiniMapView::rMouseDrag
 
+
+void MiniMapView::setMapScale()
+{
+    MiniMapInterface::setMapScale(getSize() - iXY(2,2+buttonSize.y));
+}
+
+
 // doIncreaseSize
 //--------------------------------------------------------------------------
 void MiniMapView::doIncreaseSize(int value)
@@ -379,7 +447,7 @@
         }
     }
 
-    MiniMapInterface::setMapScale(getSize() - iXY(2,2));
+    setMapScale();
 
     needScale      = true;
     scaleGroupWait = 0.0f;
@@ -406,7 +474,7 @@
         resize(iXY(minMapSize, minMapSize));
     }
 
-    MiniMapInterface::setMapScale(getSize() - iXY(2,2));
+    setMapScale();
 
     needScale      = true;
     scaleGroupWait = 0.0f;
@@ -493,6 +561,8 @@
 //--------------------------------------------------------------------------
 void MiniMapView::lMouseDrag(const iXY &downPos, const iXY &prevPos, const iXY 
&newPos)
 {
-    lMouseDown(newPos);
+//    lMouseDown(newPos);
+    setViewWindowFromMouse(newPos);
 
 } // end MiniMapView::lMouseDrag
+
Index: netpanzer/src/NetPanzer/Views/Game/MiniMapView.hpp
diff -u netpanzer/src/NetPanzer/Views/Game/MiniMapView.hpp:1.6 
netpanzer/src/NetPanzer/Views/Game/MiniMapView.hpp:1.7
--- netpanzer/src/NetPanzer/Views/Game/MiniMapView.hpp:1.6      Sat Nov 22 
10:43:45 2003
+++ netpanzer/src/NetPanzer/Views/Game/MiniMapView.hpp  Mon Nov 24 08:14:56 2003
@@ -21,6 +21,7 @@
 #include "View.hpp"
 #include "2D/Surface.hpp"
 #include "GameTemplateView.hpp"
+#include "Button.hpp"
 
 
 enum MAP_DRAW_TYPES
@@ -33,6 +34,7 @@
     MAP_BLEND_GREEN,
     MAP_BLACK,
     MAP_TRANSPARENT,
+    MAP_DRAW_TYPES_MAX
 };
 
 //---------------------------------------------------------------------------
@@ -48,6 +50,10 @@
     bool    selectionAnchor;
     iXY     selectionAnchorDownPos;
     iXY     selectionAnchorCurPos;
+    Button  scaleUpButton;
+    Button  scaleDownButton;
+    Button  dotSizeButton;
+    Button  shadeButton;
 
     void doDecreaseSize(int value);
     void doIncreaseSize(int value);
@@ -63,14 +69,18 @@
     virtual void lMouseDrag(const iXY &downPos, const iXY &prevPos, const iXY 
&newPos);
     virtual void rMouseDrag(const iXY &downPos, const iXY &prevPos, const iXY 
&newPos);
     virtual void rMouseDown(const iXY &pos);
+    virtual void actionPerformed(mMouseEvent me);
     virtual void mouseMove(const iXY &prevPos, const iXY &newPos);
 
+    void setMapScale();
     void drawMouseBox(Surface &dest);
     void setViewWindow(const iXY &pos);
-    void setMapDrawType(MAP_DRAW_TYPES type);
+    void setMapDrawType(int type);
+    bool setViewWindowFromMouse(const iXY &pos);
 
     static float          scaleDelta;
 
+    static iXY     buttonSize;
     static int decreaseSize;
     static int increaseSize;
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]