Revision: 2609
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2609&view=rev
Author:   ulteq
Date:     2012-05-20 03:11:29 +0000 (Sun, 20 May 2012)
Log Message:
-----------
-Bugfix: Survey map (WIP)
added windowResized() method

Modified Paths:
--------------
    trunk/source/main/gameplay/RoRFrameListener.cpp
    trunk/source/main/gui/MapControl.cpp
    trunk/source/main/gui/MapControl.h

Modified: trunk/source/main/gameplay/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.cpp     2012-05-20 02:22:22 UTC 
(rev 2608)
+++ trunk/source/main/gameplay/RoRFrameListener.cpp     2012-05-20 03:11:29 UTC 
(rev 2609)
@@ -5631,6 +5631,7 @@
        screenHeight = height;
 
        if (ow) ow->windowResized(rw);
+       if (surveyMap) surveyMap->windowResized(rw);
 
        //update mouse area
        INPUTENGINE.windowResized(rw);

Modified: trunk/source/main/gui/MapControl.cpp
===================================================================
--- trunk/source/main/gui/MapControl.cpp        2012-05-20 02:22:22 UTC (rev 
2608)
+++ trunk/source/main/gui/MapControl.cpp        2012-05-20 03:11:29 UTC (rev 
2609)
@@ -29,25 +29,16 @@
 
 MapControl::MapControl(int mapsizex, int mapsizez) :
          mMapWidth(mapsizex)
-       , mMapHeight(mapsizez)
+       , mMapLength(mapsizez)
        , mAlpha(1.0f)
        , mScale(1.0f)
+       , mX(0)
+       , mY(0)
 {
        initialiseByAttributes(this);
        setVisibility(false);
 }
 
-void MapControl::setMapTexture(String name)
-{
-       mMapTexture->setImageTexture(name);
-}
-
-void MapControl::setWorldSize(int x, int z)
-{
-       mMapWidth = x;
-       mMapHeight = z;
-}
-
 MapEntity *MapControl::createMapEntity(String type)
 {
        MapEntity *entity = new MapEntity(this, type, mMapTexture);
@@ -62,6 +53,11 @@
        return entity;
 }
 
+void MapControl::deleteMapEntity(MapEntity *entity)
+{
+       mMapEntities.erase(entity);
+}
+
 MapEntity *MapControl::getEntityByName(String name)
 {
        if (mNamedEntities.find(name) != mNamedEntities.end())
@@ -71,54 +67,46 @@
        return NULL;
 }
 
-String MapControl::getTypeByDriveable(int driveable)
+Vector2 MapControl::getMapSize()
 {
-       switch (driveable)
-       {
-       case NOT_DRIVEABLE:
-               return "load";
-       case TRUCK:
-               return "truck";
-       case AIRPLANE:
-               return "airplane";
-       case BOAT:
-               return "boat";
-       case MACHINE:
-               return "machine";
-       default:
-               return "unknown";
-       }
+       return Vector2(mMapWidth, mMapLength);
 }
 
-void MapControl::deleteMapEntity(MapEntity *entity)
+bool MapControl::getVisibility()
 {
-       mMapEntities.erase(entity);
+       return mMainWidget->getVisible();
 }
 
-bool MapControl::getVisibility()
+void MapControl::setAlpha(float value)
 {
-       return mMainWidget->getVisible();
+       mAlpha = value;
+       mMainWidget->setAlpha(value);
 }
 
-void MapControl::setVisibility(bool value)
+void MapControl::setEntitiesVisibility(bool value)
 {
-       mMainWidget->setVisible(value);
+       for (std::set<MapEntity *>::iterator it = mMapEntities.begin(); it != 
mMapEntities.end(); it++)
+       {
+               (*it)->setVisibility(value);
+       }
 }
 
-void MapControl::setAlpha(float value)
+void MapControl::setMapTexture(String name)
 {
-       mAlpha = value;
-       mMainWidget->setAlpha(value);
+       mMapTexture->setImageTexture(name);
 }
 
-void MapControl::setPosition(int x, int y, float size, Ogre::RenderWindow* rw)
+void MapControl::setPosition(int x, int y, float size, Ogre::RenderWindow *rw)
 {
+       int realx, realy, realw, realh;
+
+       mScale = size;
+       mX = x;
+       mY = y;
+
        updateRenderMetrics(rw);
-
-       int realx, realy, realw, realh;
        
        realw = realh = size * std::min(rWinWidth, rWinHeight);
-       mScale = size;
 
        if (x == -1)
        {
@@ -143,22 +131,50 @@
        }
 
        mMainWidget->setCoord(realx, realy, realw, realh);
+
        updateEntityPositions();
 }
 
-void MapControl::updateEntityPositions()
+void MapControl::setVisibility(bool value)
 {
-       for (std::set<MapEntity *>::iterator it = mMapEntities.begin(); it != 
mMapEntities.end(); it++)
+       mMainWidget->setVisible(value);
+}
+
+void MapControl::setWorldSize(int width, int length)
+{
+       mMapWidth = width;
+       mMapLength = length;
+}
+
+void MapControl::windowResized(Ogre::RenderWindow *rw)
+{
+       setPosition(mX, mY, mScale, rw);
+}
+
+String MapControl::getTypeByDriveable(int driveable)
+{
+       switch (driveable)
        {
-               (*it)->update();
+       case NOT_DRIVEABLE:
+               return "load";
+       case TRUCK:
+               return "truck";
+       case AIRPLANE:
+               return "airplane";
+       case BOAT:
+               return "boat";
+       case MACHINE:
+               return "machine";
+       default:
+               return "unknown";
        }
 }
 
-void MapControl::setEntitiesVisibility(bool value)
+void MapControl::updateEntityPositions()
 {
        for (std::set<MapEntity *>::iterator it = mMapEntities.begin(); it != 
mMapEntities.end(); it++)
        {
-               (*it)->setVisibility(value);
+               (*it)->update();
        }
 }
 

Modified: trunk/source/main/gui/MapControl.h
===================================================================
--- trunk/source/main/gui/MapControl.h  2012-05-20 02:22:22 UTC (rev 2608)
+++ trunk/source/main/gui/MapControl.h  2012-05-20 03:11:29 UTC (rev 2609)
@@ -36,10 +36,11 @@
 
        MapEntity *createMapEntity(Ogre::String type);
        MapEntity *createNamedMapEntity(Ogre::String name, Ogre::String type);
+       
+       void deleteMapEntity(MapEntity *ent);
 
-       
        MapEntity *getEntityByName(Ogre::String name);
-       Ogre::Vector2 getMapSize(){ return Ogre::Vector2(mMapWidth, 
mMapHeight); }
+       Ogre::Vector2 getMapSize();
        bool getVisibility();
        float getAlpha() { return mAlpha; }
        float getWindowScale() { return mScale; }
@@ -47,27 +48,32 @@
        void setAlpha(float value);
        void setEntitiesVisibility(bool value);
        void setMapTexture(Ogre::String name);
-       void setPosition(int x, int y, float size, Ogre::RenderWindow* rw);
+       void setPosition(int x, int y, float size, Ogre::RenderWindow *rw);
        void setVisibility(bool value);
-       void setWorldSize(int x, int z);
+       void setWorldSize(int width, int length);
 
-       void deleteMapEntity(MapEntity *ent);
+       void windowResized(Ogre::RenderWindow *rw);
 
        static Ogre::String getTypeByDriveable(int driveable);
 
 protected:
 
+       float mAlpha, mScale;
+       int mX, mY;
+
+       int mMapWidth, mMapLength;
+
        ATTRIBUTE_FIELD_WIDGET_NAME(MapControl, mMapTexture, "mMapTexture");
        MyGUI::StaticImage* mMapTexture;
 
-       float mAlpha, mScale;
-       int mMapWidth, mMapHeight;
-       int rWinLeft, rWinTop;
-       unsigned int rWinWidth, rWinHeight, rWinDepth;
        std::map<Ogre::String, MapEntity *> mNamedEntities;
        std::set<MapEntity *> mMapEntities;
 
        void updateEntityPositions();
+
+       int rWinLeft, rWinTop;
+       unsigned int rWinWidth, rWinHeight, rWinDepth;
+
        void updateRenderMetrics(Ogre::RenderWindow* win);
 };
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Rigsofrods-devel mailing list
Rigsofrods-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to