diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-20 12:50:26 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-20 12:50:26 +0000 |
commit | 90e5ce7e958418f0d39d38112d33d3190a78baea (patch) | |
tree | 012150b22e971e44d0f7e795ef48384e15392940 /src/gui/gui.cpp | |
parent | 9ca202ae89bbe60f2cd1c8e3249a4fe3f8972a2b (diff) | |
download | mana-client-90e5ce7e958418f0d39d38112d33d3190a78baea.tar.gz mana-client-90e5ce7e958418f0d39d38112d33d3190a78baea.tar.bz2 mana-client-90e5ce7e958418f0d39d38112d33d3190a78baea.tar.xz mana-client-90e5ce7e958418f0d39d38112d33d3190a78baea.zip |
TMW now uses latest Guichan CVS, and doesn't work with Guichan 0.2.0 anymore!
Also fixed a crash on clicking wallpaper in login phase.
Diffstat (limited to 'src/gui/gui.cpp')
-rw-r--r-- | src/gui/gui.cpp | 101 |
1 files changed, 10 insertions, 91 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 5c77f317..1cb7e3f9 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -34,14 +34,15 @@ Graphics *guiGraphics; // Graphics driver gcn::SDLInput *guiInput; // GUI input WindowContainer *guiTop; // The top container -Gui::Gui(Graphics *graphics): - topHasMouse(false) +Gui::Gui(Graphics *graphics) { // Set graphics guiGraphics = graphics; + setGraphics(graphics); // Set input guiInput = new gcn::SDLInput(); + setInput(guiInput); // Set image loader #ifndef USE_OPENGL @@ -58,10 +59,7 @@ Gui::Gui(Graphics *graphics): guiTop->setOpaque(false); guiTop->addMouseListener(this); Window::setWindowContainer(guiTop); - - // Create focus handler - focusHandler = new gcn::FocusHandler(); - guiTop->_setFocusHandler(focusHandler); + setTop(guiTop); // Set global font guiFont = new gcn::ImageFont("./data/core/graphics/gui/fixedfont.png", @@ -80,82 +78,6 @@ Gui::~Gui() delete hostImageLoader; #endif delete guiInput; - delete focusHandler; -} - -void Gui::logic() -{ - while (!guiInput->isMouseQueueEmpty()) - { - gcn::MouseInput mi = guiInput->dequeueMouseInput(); - gcn::Widget* focused = focusHandler->getFocused(); - - if (mi.x > 0 && mi.y > 0 && - guiTop->getDimension().isPointInRect(mi.x, mi.y)) - { - if (!topHasMouse) { - guiTop->_mouseInMessage(); - topHasMouse = true; - } - - gcn::MouseInput mio = mi; - mio.x -= guiTop->getX(); - mio.y -= guiTop->getY(); - - if (!guiTop->hasFocus()) { - guiTop->_mouseInputMessage(mio); - } - } - else { - if (topHasMouse) { - guiTop->_mouseOutMessage(); - topHasMouse = false; - } - } - - if (focusHandler->getFocused() && focused == focusHandler->getFocused()) - { - int xOffset, yOffset; - focused->getAbsolutePosition(xOffset, yOffset); - - gcn::MouseInput mio = mi; - mio.x -= xOffset; - mio.y -= yOffset; - focused->_mouseInputMessage(mio); - } - } - - while (!guiInput->isKeyQueueEmpty()) - { - gcn::KeyInput ki = guiInput->dequeueKeyInput(); - - // Handle tabbing - if (ki.getKey().getValue() == gcn::Key::TAB && - ki.getType() == gcn::KeyInput::PRESS) - { - if (ki.getKey().isShiftPressed()) { - focusHandler->tabPrevious(); - } - else { - focusHandler->tabNext(); - } - } - else { - // Send key inputs to the focused widgets - gcn::Widget* focused = focusHandler->getFocused(); - if (focused) - { - if (focused->isFocusable()) { - focused->_keyInputMessage(ki); - } - else { - focusHandler->focusNone(); - } - } - } - } - - guiTop->logic(); } void Gui::draw() @@ -165,11 +87,6 @@ void Gui::draw() guiGraphics->popClipArea(); } -void Gui::focusNone() -{ - focusHandler->focusNone(); -} - void Gui::mousePress(int mx, int my, int button) { // Mouse pressed on window container (basically, the map) @@ -177,8 +94,10 @@ void Gui::mousePress(int mx, int my, int button) int tiley = my / 32 + camera_y; // Experimental mouse walk support - walk(mx, my, 0); - player_node->setPath(tiledMap->findPath( - player_node->x, player_node->y, - tilex, tiley)); + if (state == GAME) { + walk(mx, my, 0); + player_node->setPath(tiledMap->findPath( + player_node->x, player_node->y, + tilex, tiley)); + } } |