little tinkering
authorPerttu Ahola <celeron55@gmail.com>
Thu, 23 Dec 2010 15:32:21 +0000 (17:32 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Thu, 23 Dec 2010 15:32:21 +0000 (17:32 +0200)
src/guiTextInputMenu.cpp
src/guiTextInputMenu.h
src/main.cpp
src/servermain.cpp

index 8a9da3489b1f67a196f8d08215bc1a5347dd76aa..0668aa7b33ac1916d993adf2eafff76f9e9aae6d 100644 (file)
@@ -120,6 +120,20 @@ void GUITextInputMenu::drawMenu()
        gui::IGUIElement::draw();
 }
 
+void GUITextInputMenu::acceptInput()
+{
+       if(m_dest)
+       {
+               gui::IGUIElement *e = getElementFromId(256);
+               if(e != NULL)
+               {
+                       m_dest->gotText(e->getText());
+               }
+               delete m_dest;
+               m_dest = NULL;
+       }
+}
+
 bool GUITextInputMenu::OnEvent(const SEvent& event)
 {
        if(event.EventType==EET_KEY_INPUT_EVENT)
@@ -129,6 +143,12 @@ bool GUITextInputMenu::OnEvent(const SEvent& event)
                        quitMenu();
                        return true;
                }
+               if(event.KeyInput.Key==KEY_RETURN && event.KeyInput.PressedDown)
+               {
+                       acceptInput();
+                       quitMenu();
+                       return true;
+               }
        }
        if(event.EventType==EET_GUI_EVENT)
        {
@@ -148,15 +168,7 @@ bool GUITextInputMenu::OnEvent(const SEvent& event)
                        switch(event.GUIEvent.Caller->getID())
                        {
                        case 257:
-                               if(m_dest)
-                               {
-                                       gui::IGUIElement *e = getElementFromId(256);
-                                       if(e != NULL)
-                                       {
-                                               m_dest->gotText(e->getText());
-                                       }
-                                       delete m_dest;
-                               }
+                               acceptInput();
                                quitMenu();
                                break;
                        }
index 2efc190cafc1c041474042b739d81ea62a99849c..5db10a529bc723a8800aecf7661105eba1d045c6 100644 (file)
@@ -48,6 +48,8 @@ public:
 
        void drawMenu();
 
+       void acceptInput();
+
        bool OnEvent(const SEvent& event);
        
 private:
index fe0bfb09cdd4407f1afe718408083ce8f098eb59..da727811e96bc69998164c600069de6f6ebf02cc 100644 (file)
@@ -2245,14 +2245,7 @@ int main(int argc, char *argv[])
                {\r
                //TimeTaker timer9("auxiliary drawings");\r
                // 0ms\r
-\r
-               driver->draw2DLine(displaycenter - core::vector2d<s32>(10,0),\r
-                               displaycenter + core::vector2d<s32>(10,0),\r
-                               video::SColor(255,255,255,255));\r
-               driver->draw2DLine(displaycenter - core::vector2d<s32>(0,10),\r
-                               displaycenter + core::vector2d<s32>(0,10),\r
-                               video::SColor(255,255,255,255));\r
-\r
+               \r
                //timer9.stop();\r
                //TimeTaker //timer10("//timer10");\r
                \r
@@ -2274,6 +2267,16 @@ int main(int argc, char *argv[])
                        driver->draw3DBox(*i, video::SColor(255,0,0,0));\r
                }\r
 \r
+               /*\r
+                       Draw crosshair\r
+               */\r
+               driver->draw2DLine(displaycenter - core::vector2d<s32>(10,0),\r
+                               displaycenter + core::vector2d<s32>(10,0),\r
+                               video::SColor(255,255,255,255));\r
+               driver->draw2DLine(displaycenter - core::vector2d<s32>(0,10),\r
+                               displaycenter + core::vector2d<s32>(0,10),\r
+                               video::SColor(255,255,255,255));\r
+\r
                }\r
 \r
                //timer10.stop();\r
index 24d3b24e8f8d99f788ad0771f09c4ff99f546805..c2d697cfeef340573a93dfd37880b16f31cd4425 100644 (file)
@@ -138,6 +138,7 @@ int main(int argc, char *argv[])
        allowed_options.insert("port", ValueSpec(VALUETYPE_STRING));
        allowed_options.insert("disable-unittests", ValueSpec(VALUETYPE_FLAG));
        allowed_options.insert("enable-unittests", ValueSpec(VALUETYPE_FLAG));
+       allowed_options.insert("map-dir", ValueSpec(VALUETYPE_STRING));
 
        Settings cmd_args;
        
@@ -298,8 +299,13 @@ int main(int argc, char *argv[])
        std::cout<<"Running dedicated server"<<std::endl;
        std::cout<<"========================"<<std::endl;
        std::cout<<std::endl;
-
-       Server server("../map", hm_params, map_params);
+       
+       // Figure out path to map
+       std::string map_dir = "../map";
+       if(cmd_args.exists("map-dir"))
+               map_dir = cmd_args.get("map-dir");
+       
+       Server server(map_dir.c_str(), hm_params, map_params);
        server.start(port);
 
        for(;;)