Revision: 2365
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2365&view=rev
Author:   rorthomas
Date:     2012-01-27 17:29:13 +0000 (Fri, 27 Jan 2012)
Log Message:
-----------
bugfix for arcade controls
added HighScoreWindow
fixed crash when using online API

Modified Paths:
--------------
    trunk/source/main/gameplay/RoRFrameListener.cpp
    trunk/source/main/gui/Console.cpp
    trunk/source/main/gui/Console.h
    trunk/source/main/gui/SelectorWindow.cpp
    trunk/source/main/scripting/GameScript.cpp

Added Paths:
-----------
    trunk/source/main/gui/HighScoreWindow.cpp
    trunk/source/main/gui/HighScoreWindow.h

Modified: trunk/source/main/gameplay/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/gameplay/RoRFrameListener.cpp     2012-01-27 16:15:27 UTC 
(rev 2364)
+++ trunk/source/main/gameplay/RoRFrameListener.cpp     2012-01-27 17:29:13 UTC 
(rev 2365)
@@ -2496,7 +2496,8 @@
                                                        }
 
                                                        // when in automatic 
mode: shift as well
-                                                       if 
(fabs(curr_truck->WheelSpeed) <= 0.1f && curr_truck->engine && 
curr_truck->engine->getAutoMode() == AUTOMATIC)
+                                                       // only when the truck 
really is not moving anymore
+                                                       if 
(fabs(curr_truck->WheelSpeed) <= 0.1f && curr_truck->nodes[0].Velocity.length() 
< 0.2f && curr_truck->engine && curr_truck->engine->getAutoMode() == AUTOMATIC)
                                                        {
                                                                // switching 
point, does the user want to drive forward from backward or the other way 
round? change gears?
                                                                if(brake > 0.5f 
&& accval < 0.5f && curr_truck->engine->getGear() > 0)

Modified: trunk/source/main/gui/Console.cpp
===================================================================
--- trunk/source/main/gui/Console.cpp   2012-01-27 16:15:27 UTC (rev 2364)
+++ trunk/source/main/gui/Console.cpp   2012-01-27 17:29:13 UTC (rev 2365)
@@ -27,6 +27,7 @@
 #include "gui_menu.h"
 #include "OverlayWrapper.h"
 #include "ChatSystem.h"
+#include "HighScoreWindow.h"
 
 #include "Settings.h"
 #include "RoRFrameListener.h"
@@ -900,6 +901,13 @@
        {
                for (int i = 0; i < results; i++, r++)
                {
+                       if(tmpWaitingMessages[i].type == 
CONSOLE_MSGTYPE_HIGHSCORE)
+                       {
+                               // special :)
+                               
HighScoreWindow::getInstance().show(tmpWaitingMessages[i].txt);
+                               continue;
+                       }
+
                        // copy over to our storage
                        messages[message_counter] = tmpWaitingMessages[i];
                

Modified: trunk/source/main/gui/Console.h
===================================================================
--- trunk/source/main/gui/Console.h     2012-01-27 16:15:27 UTC (rev 2364)
+++ trunk/source/main/gui/Console.h     2012-01-27 17:29:13 UTC (rev 2365)
@@ -65,7 +65,7 @@
 
        void frameEntered(float dt);
 
-       enum {CONSOLE_MSGTYPE_LOG, CONSOLE_MSGTYPE_INFO, 
CONSOLE_MSGTYPE_SCRIPT, CONSOLE_MSGTYPE_NETWORK, CONSOLE_MSGTYPE_FLASHMESSAGE};
+       enum {CONSOLE_MSGTYPE_LOG, CONSOLE_MSGTYPE_INFO, 
CONSOLE_MSGTYPE_SCRIPT, CONSOLE_MSGTYPE_NETWORK, CONSOLE_MSGTYPE_FLASHMESSAGE, 
CONSOLE_MSGTYPE_HIGHSCORE};
        
        enum {
                // detailed message type identifier, mostly used for message 
filtering

Added: trunk/source/main/gui/HighScoreWindow.cpp
===================================================================
--- trunk/source/main/gui/HighScoreWindow.cpp                           (rev 0)
+++ trunk/source/main/gui/HighScoreWindow.cpp   2012-01-27 17:29:13 UTC (rev 
2365)
@@ -0,0 +1,73 @@
+/*
+This source file is part of Rigs of Rods
+Copyright 2005-2012 Pierre-Michel Ricordel
+Copyright 2007-2012 Thomas Fischer
+
+For more information, see http://www.rigsofrods.com/
+
+Rigs of Rods is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 3, as
+published by the Free Software Foundation.
+
+Rigs of Rods is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Rigs of Rods.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifdef USE_MYGUI
+
+#include "HighScoreWindow.h"
+#include "gui_manager.h"
+#include "language.h"
+#include "utils.h"
+
+HighScoreWindow::HighScoreWindow()
+{
+       initialiseByAttributes(this);
+
+       ((MyGUI::Window*)mMainWidget)->setCaption(_L("Highscores"));
+       ((MyGUI::Window*)mMainWidget)->eventWindowButtonPressed += 
MyGUI::newDelegate(this, &HighScoreWindow::notifyWindowPressed);
+}
+
+HighScoreWindow::~HighScoreWindow()
+{
+}
+
+void HighScoreWindow::show(Ogre::UTFString &txt)
+{
+       ((MyGUI::Window*)mMainWidget)->setVisibleSmooth(true);
+
+       int width = 300;
+       int height = MyGUI::Gui::getInstance().getViewSize().height - 120;
+       int left = MyGUI::Gui::getInstance().getViewSize().width - width;
+       int top = 60;
+
+       ((MyGUI::Window*)mMainWidget)->setPosition(left, top);
+       ((MyGUI::Window*)mMainWidget)->setSize(width, height);
+
+       try
+       {
+               mTxt->setCaption(convertToMyGUIString(txt));
+       } catch(...)
+       {
+               mTxt->setCaption("ENCODING ERROR");
+       }
+
+}
+
+void HighScoreWindow::hide()
+{
+       ((MyGUI::Window*)mMainWidget)->setVisibleSmooth(false);
+}
+
+void HighScoreWindow::notifyWindowPressed(MyGUI::Window* _widget, const 
std::string& _name)
+{
+       MyGUI::WindowPtr window = _widget->castType<MyGUI::Window>();
+       if (_name == "close")
+               hide();
+}
+#endif //MYGUI
+

Added: trunk/source/main/gui/HighScoreWindow.h
===================================================================
--- trunk/source/main/gui/HighScoreWindow.h                             (rev 0)
+++ trunk/source/main/gui/HighScoreWindow.h     2012-01-27 17:29:13 UTC (rev 
2365)
@@ -0,0 +1,55 @@
+/*
+This source file is part of Rigs of Rods
+Copyright 2005-2012 Pierre-Michel Ricordel
+Copyright 2007-2012 Thomas Fischer
+
+For more information, see http://www.rigsofrods.com/
+
+Rigs of Rods is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 3, as
+published by the Free Software Foundation.
+
+Rigs of Rods is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Rigs of Rods.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifdef USE_MYGUI
+
+#ifndef __HIGHSCORE_WINDOW_H__
+#define __HIGHSCORE_WINDOW_H__
+
+#include "RoRPrerequisites.h"
+#include "Singleton.h"
+#include "mygui/BaseLayout.h"
+#include <Ogre.h>
+#include "skin.h"
+
+
+ATTRIBUTE_CLASS_LAYOUT(HighScoreWindow, "HighScoreWindow.layout");
+
+class HighScoreWindow :
+       public wraps::BaseLayout,
+       public Singleton2<HighScoreWindow>
+{
+       friend class Singleton2<HighScoreWindow>;
+       HighScoreWindow();
+       ~HighScoreWindow();
+public:
+       void show(Ogre::UTFString &str);
+       void hide();
+
+private:
+       ATTRIBUTE_FIELD_WIDGET_NAME(HighScoreWindow, mTxt, "highscore_txt");
+       MyGUI::TextBox* mTxt;
+       
+       void notifyWindowPressed(MyGUI::Window* _widget, const std::string& 
_name);
+
+};
+
+#endif // __HIGHSCORE_WINDOW_H__
+
+#endif //MYGUI

Modified: trunk/source/main/gui/SelectorWindow.cpp
===================================================================
--- trunk/source/main/gui/SelectorWindow.cpp    2012-01-27 16:15:27 UTC (rev 
2364)
+++ trunk/source/main/gui/SelectorWindow.cpp    2012-01-27 17:29:13 UTC (rev 
2365)
@@ -866,8 +866,6 @@
        // reset all keys
        INPUTENGINE.resetKeys();
        LoadingWindow::get()->hide();
-       // show mouse cursor
-       //MyGUI::PointerManager::getInstance().setVisible(true);
        // focus main mMainWidget (for key input)
        mTruckConfigs.clear();
        MyGUI::InputManager::getInstance().setKeyFocusWidget(mMainWidget);

Modified: trunk/source/main/scripting/GameScript.cpp
===================================================================
--- trunk/source/main/scripting/GameScript.cpp  2012-01-27 16:15:27 UTC (rev 
2364)
+++ trunk/source/main/scripting/GameScript.cpp  2012-01-27 17:29:13 UTC (rev 
2365)
@@ -680,15 +680,7 @@
 #ifdef USE_MYGUI
        Console *con = Console::getInstancePtrNoCreation();
        if(con) 
-       {
-               Ogre::StringVector lines = StringUtil::split(result, "\n");
-               for(Ogre::StringVector::iterator it = lines.begin(); 
it!=lines.end(); it++)
-               {
-                       Ogre::StringVector args = StringUtil::split(result, 
"|");
-                       if(args.size() != 2) continue;
-                       con->putMessage(Console::CONSOLE_MSGTYPE_INFO, 
Console::CONSOLE_SYSTEM_NOTICE, ANSI_TO_UTF(args[0]), args[1]);
-               }
-       }
+               con->putMessage(Console::CONSOLE_MSGTYPE_HIGHSCORE, 
Console::CONSOLE_SYSTEM_NOTICE, ANSI_TO_UTF(result));
 #endif // USE_MYGUI
 #endif //USE_CURL
        return 0;
@@ -715,16 +707,31 @@
        if(con) con->putMessage(Console::CONSOLE_MSGTYPE_INFO, 
Console::CONSOLE_SYSTEM_NOTICE, _L("using Online API..."), "information.png", 
2000);
 #endif // USE_MYGUI
 
+       // fix the string objects in the dict
+       // why we need to do this: when we copy the std::map (dict) over, we 
calso jsut copy the pointers to string in it.
+       // when this continues and forks, AS releases the strings.
+       // so we will allocate new strings that are persistent.
+       std::map<std::string, 
AngelScript::CScriptDictionary::valueStruct>::iterator it;
+       for(it = params->dict->dict.begin(); it != params->dict->dict.end(); 
it++)
+       {
+               int typeId = it->second.typeId;
+               if(typeId == mse->getEngine()->GetTypeIdByDecl("string"))
+               {
+                       // its a string, copy it over
+                       std::string *str = (std::string *)it->second.valueObj;
+                       it->second.valueObj = (void *)new string(*str);
+               }
+       }
+
        // create the thread
        LOG("creating thread for online API usage...");
-       // THREADING: BROKEN!!!
-       int rc = useOnlineAPIDirectly(*params);
-       //int rc = pthread_create(&apiThread, NULL, onlineAPIThread, (void 
*)params);
+       int rc = pthread_create(&apiThread, NULL, onlineAPIThread, (void 
*)params);
        if(rc)
        {
                LOG("useOnlineAPI/pthread error code: " + TOSTRING(rc));
                return 1;
        }
+
        return 0;
 }
 

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


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Rigsofrods-devel mailing list
Rigsofrods-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to