From: <ka...@us...> - 2011-03-26 04:19:07
|
Revision: 5444 http://paintown.svn.sourceforge.net/paintown/?rev=5444&view=rev Author: kazzmir Date: 2011-03-26 04:19:01 +0000 (Sat, 26 Mar 2011) Log Message: ----------- use standardLoop in the server Modified Paths: -------------- trunk/src/paintown-engine/network/server.cpp trunk/src/util/input/text-input.cpp trunk/src/util/input/text-input.h Modified: trunk/src/paintown-engine/network/server.cpp =================================================================== --- trunk/src/paintown-engine/network/server.cpp 2011-03-25 17:25:39 UTC (rev 5443) +++ trunk/src/paintown-engine/network/server.cpp 2011-03-26 04:19:01 UTC (rev 5444) @@ -2,6 +2,7 @@ #include "util/bitmap.h" #include "util/trans-bitmap.h" +#include "util/events.h" #include "chat_server.h" #include "factory/font_render.h" @@ -70,16 +71,73 @@ background.BlitToScreen(); } - bool done = false; /* TODO: add filter for numbers */ TextInput input("7887"); - input.addBlockingHandle(Keyboard::Key_ENTER, set_to_true, &done); input.addBlockingHandle(Keyboard::Key_ESC, do_quit, NULL); - input.enable(); - Graphics::Bitmap work(200, 25); + class Logic: public Util::Logic { + public: + Logic(TextInput & input, bool & draw): + input(input), + is_done(false), + draw(draw){ + input.addBlockingHandle(Keyboard::Key_ENTER, set_to_true, &is_done); + input.enable(); + } + TextInput & input; + bool is_done; + bool & draw; + + bool done(){ + return is_done; + } + + double ticks(double system){ + return system; + } + + void run(){ + draw = input.doInput(); + } + }; + + class Draw: public Util::Draw { + public: + Draw(const Graphics::Bitmap & background, const TextInput & input, int drawY, bool & need_draw): + work(200, 25), + background(background), + input(input), + drawY(drawY), + need_draw(need_draw){ + } + + Graphics::Bitmap work; + const Graphics::Bitmap & background; + const TextInput & input; + int drawY; + bool & need_draw; + + void draw(){ + if (need_draw){ + work.clear(); + const Font & font = Font::getFont(Global::DEFAULT_FONT, 20, 20 ); + font.printf(0, 0, Graphics::makeColor(255, 255, 255), work, input.getText(), 0); + work.Blit(100, drawY, background); + background.BlitToScreen(); + } + } + }; + bool draw = true; + Logic logic(input, draw); + Draw drawer(background, input, drawY, draw); + drawer.draw(); + + Util::standardLoop(logic, drawer); + +#if 0 + bool draw = true; Global::speed_counter2 = 0; while (! done){ while (Global::speed_counter2 > 0){ @@ -102,6 +160,7 @@ Util::rest(1); } } +#endif istringstream str(input.getText()); int port; Modified: trunk/src/util/input/text-input.cpp =================================================================== --- trunk/src/util/input/text-input.cpp 2011-03-25 17:25:39 UTC (rev 5443) +++ trunk/src/util/input/text-input.cpp 2011-03-26 04:19:01 UTC (rev 5444) @@ -117,7 +117,7 @@ Keyboard::popRepeatState(); } -string TextInput::getText(){ +string TextInput::getText() const { return text.str(); } Modified: trunk/src/util/input/text-input.h =================================================================== --- trunk/src/util/input/text-input.h 2011-03-25 17:25:39 UTC (rev 5443) +++ trunk/src/util/input/text-input.h 2011-03-26 04:19:01 UTC (rev 5444) @@ -39,7 +39,7 @@ blockingKeys = true; } - std::string getText(); + std::string getText() const; void setText(const std::string & text); void clearInput(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |