diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-29 20:41:14 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-29 20:41:14 +0000 |
commit | 7cf46d715e08b8a355ef9ea7be5421a2710d65fc (patch) | |
tree | 7aa0166030af099fd82b2d080229497d466009aa | |
parent | 9ddc6e0d5208820a374f3bc9b9c5678e013535b2 (diff) | |
download | mana-client-7cf46d715e08b8a355ef9ea7be5421a2710d65fc.tar.gz mana-client-7cf46d715e08b8a355ef9ea7be5421a2710d65fc.tar.bz2 mana-client-7cf46d715e08b8a355ef9ea7be5421a2710d65fc.tar.xz mana-client-7cf46d715e08b8a355ef9ea7be5421a2710d65fc.zip |
Ported the npc text dialog and some other small updates.
-rwxr-xr-x | docs/.cvsignore | 2 | ||||
-rw-r--r-- | docs/INSTALL/debian.txt | 20 | ||||
-rw-r--r-- | docs/INSTALL/linux.txt | 85 | ||||
-rw-r--r-- | docs/INSTALL/win32.txt | 9 | ||||
-rw-r--r-- | file.list | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/game.cpp | 36 | ||||
-rw-r--r-- | src/graphic/graphic.cpp | 39 | ||||
-rw-r--r-- | src/graphic/graphic.h | 2 | ||||
-rw-r--r-- | src/gui/npc.cpp | 8 | ||||
-rw-r--r-- | src/gui/npc.h | 9 | ||||
-rw-r--r-- | src/gui/npc_text.cpp | 75 | ||||
-rw-r--r-- | src/gui/npc_text.h | 78 | ||||
-rw-r--r-- | src/gui/passwordfield.cpp | 2 | ||||
-rw-r--r-- | src/gui/slider.cpp | 1 | ||||
-rw-r--r-- | src/gui/textfield.cpp | 2 | ||||
-rw-r--r-- | src/gui/window.cpp | 27 |
17 files changed, 242 insertions, 155 deletions
diff --git a/docs/.cvsignore b/docs/.cvsignore new file mode 100755 index 00000000..9e73aeb9 --- /dev/null +++ b/docs/.cvsignore @@ -0,0 +1,2 @@ +chatlog.txt +tmw.log diff --git a/docs/INSTALL/debian.txt b/docs/INSTALL/debian.txt index 50fdbd1e..8b0c10c6 100644 --- a/docs/INSTALL/debian.txt +++ b/docs/INSTALL/debian.txt @@ -17,23 +17,17 @@ IRC: irc.freenode.net / #manaworld 1. Installing The Mana World Dependancies ============================================= -The Mana World Debian Package can be installed under the Debian Testing and Unstable (Sarge/Cid). -In order to have Mana World working, you'll need the following packages that are situed in : +The Mana World Debian Package can be installed under the Debian Testing and +Unstable (Sarge/Cid). In order to have Mana World working, you'll need packages +for Allegro, SDL, SDL_mixer and Guichan. -- JGMod : -http://themanaworld.sourceforge.net/files/jgmod_0.99_i386.deb -- AlFont : -http://themanaworld.sourceforge.net/files/libalfont_1.9.2_i386.deb +To install liballegro4.1, you can do type (as root): + apt-get install liballegro4.1 -Note : If the packages names mismatches, check the page : http://themanaworld.sourceforge.net/files/ -to look for the latest version of these packages. +Also make sure you install the other required packages. -When you've grabbed them, install them (as root) with the commands : - dpkg -i jgmod_0.99_i386.deb - dpkg -i libalfont_1.9.2_i386.deb +(incompletely updated by Hammerbear) -liballegro4.1 must be installed before doing the previous commands, you can do install it by typing (as root) : - apt-get install liballegro4.1 2. Make the latest Mana World Debian Package and install it ========================================================== diff --git a/docs/INSTALL/linux.txt b/docs/INSTALL/linux.txt index 3ed33055..2035d123 100644 --- a/docs/INSTALL/linux.txt +++ b/docs/INSTALL/linux.txt @@ -1,8 +1,6 @@ How to compile and install TMW on my GNU/Linux Box ================================================== -Thanks to hardskinone for writing the 'Installing JGmod' part - The Mana World project ====================== Homepage: themanaworld.sourceforge.net @@ -10,10 +8,10 @@ IRC: irc.freenode.net / #manaworld 1) Requirements 2) Installing the Allegro library -3) Installing the Alfont library -4) Installing the JGmod library -5) Installing The Mana World -6) Notes +3) Installing other libraries +4) Installing The Mana World +5) Notes + 1. Requirements =============== @@ -33,23 +31,25 @@ both first. Those should be included in any distribution. To get The Mana World to compile, some libraries are needed: 1) Allegro 4.1+ -2) Alfont 1.91 -3) JGmod 0.99 +2) SDL +3) SDL_mixer +4) Guichan + -2) Installing the Allegro Libraries -=================================== +2. Installing the Allegro Library +================================= Look for a package for the distribution you run first and if you find a version of Allegro 4.1 or higher you can save the time to go through the next steps and skip to section 3. If not read ahead! Download Allegro: - http://prdownloads.sourceforge.net/alleg/allegro-4.1.14.tar.gz?download + http://prdownloads.sourceforge.net/alleg/allegro-4.1.17.tar.gz?download Follow the steps: 1) cd into the path you donwloaded the tarball to -2) run "tar xzf allegro-4.1.14.tar.gz" -3) cd into "allegro-4.1.14" +2) run "tar xzf allegro-4.1.17.tar.gz" +3) cd into "allegro-4.1.17" 4) run "./configure && make" 5) then make sure you are the superuser and run "make install" 6) run "ldconfig -v | grep allegro" @@ -62,58 +62,17 @@ Allegro should now be installed on your system. If libraries are missing or something else doesn't work out please correspond to Allegros installation manual: http://alleg.sourceforge.net/ - -3) Installing the Alfont library -================================ -NOTE: if you're using Debian check this package http://themanaworl.sourceforge.net/files/jgmod_0.99_i386.deb -This is most likely not included in any distribution out there. So download -the source from here: - http://nekros.freeshell.org/delirium/alfont.php - -1) extract the archive, i recommend unzip :-) -2) cd into the directory -3) edit "Makefile" so it looks like this: - - [..] - # Makefile for AllegroFont using FreeType 2 - - # select (uncomment) one target and comment DJGPP if you are not aiming - # for that platform - #TARGET=DJGPP_STATIC - #TARGET=MINGW32_STATIC - #TARGET=MINGW32_DLL - TARGET=LINUX_STATIC - [..] -4) run "sh fixunix.sh" -5) run "make" -6) make sure you're the superuser and do the following: - cp lib/linux/libalfont.a /usr/lib - cp include/* /usr/include - ldconfig -7) this should finish the Alfont installation - -4) Installing the JGmod library -================================ - -NOTE: if you're using Debian check this package http://themanaworl.sourceforge.net/files/libalfont_1.9.2_i386.deb - -This is not included in any distribution. Download source package from here: -http://www.geocities.com/jeffery_guan/jgmod/jgmod.zip +3. Installing other libraries +============================= + +Make sure you also have SDL, SDL_mixer and Guichan installed. + +(incompletely updated by Hammerbear) + -1) extract archive and 'cd' into the directory -2) run 'sh fixunix.sh' -3) cd in 'src' subdirectory -4) run 'make' and 'make install as root -5) now you should have following files: - /usr/local/lib/libjgmod.so - /usr/local/include/jgmod.h - -*Note for GNU/Gentoo user: - It's possible that 'make install' command create a file named /usr/local/include instead. To fix rename it 'jgmod.h', create a dir '/usr/local/include/' and put in that file. - -5. Installing The Mana World +4. Installing The Mana World ============================ The final step... I assume you have already downloaded the latest tarball @@ -127,7 +86,7 @@ or checked out a recent version from the CVS. In any case follow the last the TMW forums: http://themanaworld.sourceforge.net/phpBB2/index.php -6. Notes +5. Notes ======== I only tested this on Archlinux Current (13th July 2004) and Debian Sid diff --git a/docs/INSTALL/win32.txt b/docs/INSTALL/win32.txt index 2d4eac83..0da02670 100644 --- a/docs/INSTALL/win32.txt +++ b/docs/INSTALL/win32.txt @@ -26,7 +26,8 @@ doing, so best stick with Dev-C++. Besides a C++ compiler, TMW depends on the following libraries: 1) Allegro 4.1.17 -3) JGmod 0.99 +2) SDL +3) SDL_mixer 4) Guichan 0.2.0 @@ -48,15 +49,11 @@ After you fetched it simply run and install. All the libs have DevPaks that are very easy drop-ins for Dev-C++, without any complex actions on your side. -Because Guichan can work with SDL as well as Allegro, and because we plan to -switch to SDL anyway, we'll install SDL and SDL_image too, even though TMW -doesn't require them at this time. - Get the following list of DevPaks: - Allegro (http://devpaks.org/show.php?devpak=2) -- JGMOD (http://devpaks.org/show.php?devpak=121) - SDL (http://devpaks.org/show.php?devpak=57) +- SDL_mixer (http://devpaks.org/) - SDL_image (http://devpaks.org/show.php?devpak=25) - Guichan (http://guichan.darkbits.org/downloads/guichan-0.2.0.DevPak) @@ -14,6 +14,7 @@ MODULES = src/sound/sound.cpp \ src/gui/inventory.cpp \ src/gui/login.cpp \ src/gui/npc.cpp \ + src/gui/npc_text.cpp \ src/gui/ok_dialog.cpp \ src/gui/passwordfield.cpp \ src/gui/progressbar.cpp \ diff --git a/src/Makefile.am b/src/Makefile.am index 3821f835..2de7cba9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,7 @@ tmw_SOURCES = sound/sound.cpp \ gui/inventory.cpp \ gui/login.cpp \ gui/npc.cpp \ + gui/npc_text.cpp \ gui/ok_dialog.cpp \ gui/passwordfield.cpp \ gui/progressbar.cpp \ diff --git a/src/game.cpp b/src/game.cpp index eb2a99a5..73439947 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -155,7 +155,6 @@ void do_init() { } player_node->weapon = char_info->weapon; add_node(player_node); - show_npc_dialog = 0; remove("./docs/packet.list"); } @@ -260,17 +259,16 @@ void do_input() { } if (mouse_b & 2) { - //if(show_npc_dialog==0) { - int npc_x = mouse_x/32+camera_x; - int npc_y = mouse_y/32+camera_y; + // Make contact with NPC + int npc_x = mouse_x / 32 + camera_x; + int npc_y = mouse_y / 32 + camera_y; int id = find_npc(npc_x, npc_y); - if(id!=0) { + if (id != 0) { WFIFOW(0) = net_w_value(0x0090); WFIFOL(2) = net_l_value(id); WFIFOB(6) = 0; WFIFOSET(7); } - //} } } @@ -538,19 +536,17 @@ void do_parse() { break; // NPC dialog case 0x00b4: - if(!strstr(npc_text, RFIFOP(8))) { - strcat(npc_text, RFIFOP(8)); - strcat(npc_text, "\n"); - show_npc_dialog = 1; - } - break; - // Get the items - case 0x01ee: - for(int loop=0;loop<(RFIFOW(2)-4)/18;loop++) { - inventoryWindow->addItem(RFIFOW(4 + loop * 18), - RFIFOW(4 + loop * 18 + 2), RFIFOW(4 + loop * 18 + 6)); - } - break; + npcTextDialog->addText(RFIFOP(8)); + npcListDialog->setVisible(false); + npcTextDialog->setVisible(true); + break; + // Get the items + case 0x01ee: + for (int loop = 0; loop < (RFIFOW(2) - 4) / 18; loop++) { + inventoryWindow->addItem(RFIFOW(4 + loop * 18), + RFIFOW(4 + loop * 18 + 2), RFIFOW(4 + loop * 18 + 6)); + } + break; // Can I use the item? case 0x00a8: // index RFIFOW(2) @@ -562,7 +558,7 @@ void do_parse() { case 0x0091: memset(map_path, '\0', 480); append_filename(map_path, "./data/map/", RFIFOP(2), 480); - if(load_map(map_path)) { + if (load_map(map_path)) { empty(); player_node = new NODE(); player_node->job = 0; diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp index bba04d52..be20aeb9 100644 --- a/src/graphic/graphic.cpp +++ b/src/graphic/graphic.cpp @@ -29,12 +29,11 @@ BITMAP *buffer, *chat_background; char itemCurrenyQ[10] = "0"; int map_x, map_y, camera_x, camera_y; -DIALOG_PLAYER *npc_player, *skill_player, *sell_player, *skill_list_player, *npc_list_player; +DIALOG_PLAYER *skill_player, *skill_list_player; char npc_text[1000] = ""; char statsString2[255] = "n/a"; char skill_points[10] = ""; Chat chatlog("./docs/chatlog.txt", 20); -int show_npc_dialog = 0; bool show_skill_dialog = false; bool show_skill_list_dialog = false; char npc_button[10] = "Close"; @@ -47,6 +46,7 @@ SellDialog *sellDialog; BuySellDialog *buySellDialog; InventoryWindow *inventoryWindow; NpcListDialog *npcListDialog; +NpcTextDialog *npcTextDialog; void ChatListener::action(const std::string& eventId) { @@ -81,14 +81,6 @@ void BuySellListener::action(const std::string& eventId) buySellDialog->setVisible(false); } -DIALOG npc_dialog[] = { - /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */ - { tmw_dialog_proc, 300, 200, 260, 150, 0, 0, 0, 0, 0, 0, (char *)"NPC", NULL, NULL }, - { tmw_button_proc, 508, 326, 50, 20, 255, 0, 'c', D_EXIT, 0, 0, (char *)npc_button, NULL, NULL }, - { tmw_textbox_proc, 304, 224, 252, 100, 0, 0, 0, 0, 0, 0, npc_text, NULL, NULL }, - { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } -}; - DIALOG skill_list_dialog[] = { /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */ { tmw_dialog_proc, 300, 200, 260, 200, 0, 0, 0, 0, 0, 0, (char *)"Stats", NULL, NULL }, @@ -121,9 +113,9 @@ int get_x_offset(NODE *node) { int offset = 0; char direction = get_direction(node->coordinates); if (node->action == WALK) { - if (direction!=NORTH && direction!=SOUTH) { + if (direction != NORTH && direction != SOUTH) { offset = node->frame + 1; - if (offset==5)offset = 0; + if (offset == 5)offset = 0; offset *= 8; if (direction == WEST || direction == NW || direction == SW) { offset = -offset; @@ -192,16 +184,17 @@ GraphicEngine::GraphicEngine() { inventoryWindow->setVisible(false); inventoryWindow->setPosition(100, 100); + npcTextDialog = new NpcTextDialog(guiTop); + npcTextDialog->setVisible(false); + npcListDialog = new NpcListDialog(guiTop); npcListDialog->setVisible(false); - npc_player = init_dialog(npc_dialog, -1); - position_dialog(npc_dialog, 300, 200); skill_player = init_dialog(skill_dialog, -1); skill_list_player = init_dialog(skill_list_dialog, -1); buffer = create_bitmap(SCREEN_W, SCREEN_H); - if(!buffer) { + if (!buffer) { error("Not enough memory to create buffer"); } @@ -214,7 +207,6 @@ GraphicEngine::GraphicEngine() { npcset = new Spriteset("./data/graphic/npcset.dat"); playerset = new Spriteset("./data/graphic/playerset.dat"); monsterset = new Spriteset("./data/graphic/monsterset.dat"); - } GraphicEngine::~GraphicEngine() { @@ -222,10 +214,11 @@ GraphicEngine::~GraphicEngine() { delete buyDialog; delete sellDialog; delete buySellDialog; + delete npcListDialog; + delete npcTextDialog; //delete tileset; - shutdown_dialog(npc_player); shutdown_dialog(skill_player); } @@ -455,18 +448,6 @@ void GraphicEngine::refresh() { chatlog.chat_draw(buffer, 8, font); - switch (show_npc_dialog) { - case 1: - dialog_message(npc_dialog, MSG_DRAW, 0, 0); - if (!(show_npc_dialog = gui_update(npc_player))) { - strcpy(npc_text, ""); - WFIFOW(0) = net_w_value(0x00b9); - WFIFOL(2) = net_l_value(current_npc); - WFIFOSET(6); - } - break; - } - if (show_skill_dialog) { update_skill_dialog(); if (gui_update(skill_player) == 0) { diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h index 564a380e..05b92acb 100644 --- a/src/graphic/graphic.h +++ b/src/graphic/graphic.h @@ -27,6 +27,7 @@ #include "../being.h" #include "../gui/buy.h" #include "../gui/npc.h" +#include "../gui/npc_text.h" #include "../gui/sell.h" #include "../gui/buysell.h" #include "../gui/chat.h" @@ -60,6 +61,7 @@ extern SellDialog *sellDialog; extern BuySellDialog *buySellDialog; extern InventoryWindow *inventoryWindow; extern NpcListDialog *npcListDialog; +extern NpcTextDialog *npcTextDialog; // The action listener for the chat field class ChatListener : public gcn::ActionListener { diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp index d206010e..80d55c73 100644 --- a/src/gui/npc.cpp +++ b/src/gui/npc.cpp @@ -54,6 +54,14 @@ NpcListDialog::NpcListDialog(gcn::Container *parent): setLocationRelativeTo(getParent()); } +NpcListDialog::~NpcListDialog() +{ + delete okButton; + delete cancelButton; + delete itemList; + delete scrollArea; +} + int NpcListDialog::getNumberOfElements() { return items.size(); diff --git a/src/gui/npc.h b/src/gui/npc.h index acc91173..d0810201 100644 --- a/src/gui/npc.h +++ b/src/gui/npc.h @@ -21,8 +21,8 @@ * $Id$ */ -#ifndef _NPC_H -#define _NPC_H +#ifndef _TMW_NPC_H +#define _TMW_NPC_H #include <guichan.hpp> #include <vector> @@ -46,6 +46,11 @@ class NpcListDialog : public Window, public gcn::ActionListener, NpcListDialog(gcn::Container *parent); /** + * Destructor. + */ + ~NpcListDialog(); + + /** * Called when receiving actions from the widgets. */ void action(const std::string& eventId); diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp new file mode 100644 index 00000000..38c29688 --- /dev/null +++ b/src/gui/npc_text.cpp @@ -0,0 +1,75 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World 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 The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include "npc_text.h" +#include "scrollarea.h" +#include "button.h" +#include "../game.h" + +NpcTextDialog::NpcTextDialog(gcn::Container *parent): + Window(parent, "NPC") +{ + textBox = new gcn::TextBox(); + textBox->setEditable(false); + scrollArea = new ScrollArea(textBox); + okButton = new Button("OK"); + + setSize(260, 175); + scrollArea->setDimension(gcn::Rectangle(5, 5, 250, 130)); + okButton->setPosition(260 - 10 - okButton->getWidth(), 145); + + okButton->setEventId("ok"); + okButton->addActionListener(this); + + add(scrollArea); + add(okButton); + + setLocationRelativeTo(getParent()); +} + +NpcTextDialog::~NpcTextDialog() +{ + delete okButton; + delete textBox; + delete scrollArea; +} + +void NpcTextDialog::setText(const char *text) +{ + textBox->setText(std::string(text)); +} + +void NpcTextDialog::addText(const char *text) +{ + textBox->setText( + textBox->getText() + std::string(text) + std::string("\n")); +} + +void NpcTextDialog::action(const std::string& eventId) +{ + WFIFOW(0) = net_w_value(0x00b9); + WFIFOL(2) = net_l_value(current_npc); + WFIFOSET(6); + setText(""); + setVisible(false); +} diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h new file mode 100644 index 00000000..6bb7d943 --- /dev/null +++ b/src/gui/npc_text.h @@ -0,0 +1,78 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World 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 The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#ifndef _TMW_NPC_TEXT_H +#define _TMW_NPC_TEXT_H + +#include <guichan.hpp> +#include <vector> +#include <string> +#include "window.h" + +/** + * The npc text dialog. + * + * \ingroup GUI + */ +class NpcTextDialog : public Window, public gcn::ActionListener +{ + public: + /** + * Constructor. + * + * @see Window::Window + */ + NpcTextDialog(gcn::Container *parent); + + /** + * Destructor. + */ + ~NpcTextDialog(); + + /** + * Called when receiving actions from the widgets. + */ + void action(const std::string& eventId); + + /** + * Sets the text shows in the dialog. + * + * @param string The new text. + */ + void setText(const char *string); + + /** + * Adds the text to the text shows in the dialog. Also adds a newline + * to the end. + * + * @param string The text to add. + */ + void addText(const char *string); + + private: + gcn::Button *okButton; + gcn::TextBox *textBox; + gcn::ScrollArea *scrollArea; +}; + +#endif diff --git a/src/gui/passwordfield.cpp b/src/gui/passwordfield.cpp index ee849c45..aa5c3141 100644 --- a/src/gui/passwordfield.cpp +++ b/src/gui/passwordfield.cpp @@ -32,7 +32,7 @@ PasswordField::PasswordField(const std::string& text): void PasswordField::draw(gcn::Graphics *graphics) { - int x, y, w, h, col; + int x, y, w, h; getAbsolutePosition(x, y); w = getWidth(); h = getHeight(); diff --git a/src/gui/slider.cpp b/src/gui/slider.cpp index 612d2e2e..11254f09 100644 --- a/src/gui/slider.cpp +++ b/src/gui/slider.cpp @@ -65,7 +65,6 @@ void Slider::draw(gcn::Graphics *graphics) void Slider::drawMarker(gcn::Graphics *graphics) { - int w = getWidth(); int h = getHeight(); int x, y; getAbsolutePosition(x, y); diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp index 3479355d..4022ca2d 100644 --- a/src/gui/textfield.cpp +++ b/src/gui/textfield.cpp @@ -33,7 +33,7 @@ TextField::TextField(const std::string& text): void TextField::draw(gcn::Graphics *graphics) { - int x, y, w, h, col; + int x, y, w, h; getAbsolutePosition(x, y); w = getWidth(); h = getHeight(); diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 4d386071..632ad303 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -172,9 +172,6 @@ void Window::add(Widget *w, int x, int y) void Window::mousePress(int mx, int my, int button) { - int x = this->getDimension().x; - int y = this->getDimension().y; - mouseDown = true; mousePX = mx; @@ -199,24 +196,16 @@ void Window::mouseMotion(int mx, int my) y = y - (mousePY - my); // Keep guichan window inside window - if (x < 0) - x = 0; - if (y < 0) - y = 0; - if (x + winWidth > 799) - x = 799 - winWidth; - if (y + winHeight > 599) - y = 599 - winHeight; + if (x < 0) x = 0; + if (y < 0) y = 0; + if (x + winWidth > 799) x = 799 - winWidth; + if (y + winHeight > 599) y = 599 - winHeight; // Snap window to edges - if (x < snapSize) - x = 0; - if (y < snapSize) - y = 0; - if (x + winWidth + snapSize > 799) - x = 799 - winWidth; - if (y + winHeight + snapSize > 599) - y = 599 - winHeight; + if (x < snapSize) x = 0; + if (y < snapSize) y = 0; + if (x + winWidth + snapSize > 799) x = 799 - winWidth; + if (y + winHeight + snapSize > 599) y = 599 - winHeight; this->setPosition(x, y); } |