summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-28 00:38:57 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-28 00:38:57 +0000
commit4542a711526bfcd09184436eda440b10bb92fbed (patch)
tree623aa067833af01cb530140ebc151a41659929e6
parente5ba1c69c54cb7e7abbe2bab67aff46255575d0e (diff)
downloadmana-client-4542a711526bfcd09184436eda440b10bb92fbed.tar.gz
mana-client-4542a711526bfcd09184436eda440b10bb92fbed.tar.bz2
mana-client-4542a711526bfcd09184436eda440b10bb92fbed.tar.xz
mana-client-4542a711526bfcd09184436eda440b10bb92fbed.zip
Ported buy/sell dialog, made sure mouse is only drawn once and updated build
files.
-rw-r--r--The Mana World.dev42
-rw-r--r--file.list2
-rw-r--r--src/Makefile.am11
-rw-r--r--src/game.cpp2
-rw-r--r--src/graphic/graphic.cpp99
-rw-r--r--src/graphic/graphic.h8
-rw-r--r--src/gui/buysell.cpp69
-rw-r--r--src/gui/buysell.h61
8 files changed, 225 insertions, 69 deletions
diff --git a/The Mana World.dev b/The Mana World.dev
index c1f13363..38354190 100644
--- a/The Mana World.dev
+++ b/The Mana World.dev
@@ -1,7 +1,7 @@
[Project]
FileName=The Mana World.dev
Name=tmw
-UnitCount=70
+UnitCount=74
Type=0
Ver=1
ObjFiles=
@@ -752,3 +752,43 @@ Priority=1000
OverrideBuildCmd=0
BuildCmd=
+[Unit71]
+FileName=src\gui\radiobutton.cpp
+CompileCpp=1
+Folder=gui
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit72]
+FileName=src\gui\radiobutton.h
+CompileCpp=1
+Folder=gui
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit73]
+FileName=src\gui\buysell.cpp
+CompileCpp=1
+Folder=gui
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit74]
+FileName=src\gui\buysell.h
+CompileCpp=1
+Folder=gui
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
diff --git a/file.list b/file.list
index 9ecb3a7a..f55f76af 100644
--- a/file.list
+++ b/file.list
@@ -4,6 +4,7 @@ MODULES = src/sound/sound.cpp \
src/graphic/image.cpp \
src/gui/button.cpp \
src/gui/buy.cpp \
+ src/gui/buysell.cpp \
src/gui/char_server.cpp \
src/gui/char_select.cpp \
src/gui/chat.cpp \
@@ -15,6 +16,7 @@ MODULES = src/sound/sound.cpp \
src/gui/ok_dialog.cpp \
src/gui/passwordfield.cpp \
src/gui/progressbar.cpp \
+ src/gui/radiobutton.cpp \
src/gui/scrollarea.cpp \
src/gui/setup.cpp \
src/gui/shop.cpp \
diff --git a/src/Makefile.am b/src/Makefile.am
index 4d4f514f..ef31f4c4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,11 +5,11 @@ tmw_SOURCES = sound/sound.cpp \
graphic/image.cpp \
gui/button.cpp \
gui/buy.cpp \
+ gui/buysell.cpp \
gui/char_server.cpp \
gui/char_select.cpp \
gui/chat.cpp \
gui/checkbox.cpp \
- gui/radiobutton.cpp \
gui/gui.cpp \
gui/inventory.cpp \
gui/login.cpp \
@@ -17,6 +17,7 @@ tmw_SOURCES = sound/sound.cpp \
gui/ok_dialog.cpp \
gui/passwordfield.cpp \
gui/progressbar.cpp \
+ gui/radiobutton.cpp \
gui/scrollarea.cpp \
gui/setup.cpp \
gui/shop.cpp \
@@ -27,13 +28,13 @@ tmw_SOURCES = sound/sound.cpp \
gui/window.cpp \
net/network.cpp \
net/protocol.cpp \
- configuration.cpp \
+ astar.cpp \
being.cpp \
+ configuration.cpp \
game.cpp \
- main.cpp \
- map.cpp \
log.cpp \
- astar.cpp
+ main.cpp \
+ map.cpp
# set the include path found by configure
INCLUDES= $(all_includes)
diff --git a/src/game.cpp b/src/game.cpp
index 18ade5a7..b37d77bc 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -747,7 +747,7 @@ void do_parse() {
// Buy/Sell dialog
case 0x00c4:
buyDialog->setVisible(false);
- show_npc_dialog = 2;
+ buySellDialog->setVisible(true);
current_npc = RFIFOL(2);
break;
// Buy dialog
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index 95c69485..d37cafac 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -41,7 +41,7 @@ DATAFILE *tileset;
char itemCurrenyQ[10] = "0";
int map_x, map_y, camera_x, camera_y;
-DIALOG_PLAYER *npc_player, *skill_player, *buy_sell_player, *sell_player, *skill_list_player, *npc_list_player;
+DIALOG_PLAYER *npc_player, *skill_player, *sell_player, *skill_list_player, *npc_list_player;
char npc_text[1000] = "";
char statsString2[255] = "n/a";
char skill_points[10] = "";
@@ -55,6 +55,7 @@ gcn::TextField *chatInput;
StatsDialog *statsDialog;
BuyDialog *buyDialog;
+BuySellDialog *buySellDialog;
InventoryDialog *inventoryDialog;
void ChatListener::action(const std::string& eventId)
@@ -69,6 +70,27 @@ void ChatListener::action(const std::string& eventId)
}
}
+void BuySellListener::action(const std::string& eventId)
+{
+ int actionId = -1;
+
+ if (eventId == "buy") {
+ actionId = 0;
+ }
+ else if (eventId == "sell") {
+ actionId = 1;
+ }
+
+ if (actionId > -1) {
+ WFIFOW(0) = net_w_value(0x00c5);
+ WFIFOL(2) = net_l_value(current_npc);
+ WFIFOB(6) = net_b_value(actionId);
+ WFIFOSET(7);
+ }
+
+ buySellDialog->setVisible(false);
+}
+
Spriteset *new_tileset, *new_playerset, *new_npcset, *new_emotionset;
Spriteset *new_monsterset;
@@ -82,15 +104,6 @@ DIALOG npc_dialog[] = {
};
-DIALOG buy_sell_dialog[] = {
- /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
- { tmw_dialog_proc, 350, 200, 100, 105, 0, 0, 0, 0, 0, 0, (char *)"Shop", NULL, NULL },
- { tmw_button_proc, 360, 225, 80, 20, 255, 0, 0, D_EXIT, 0, 0, (char *)"&Buy", NULL, NULL },
- { tmw_button_proc, 360, 250, 80, 20, 255, 0, 0, D_EXIT, 0, 0, (char *)"&Sell", NULL, NULL },
- { tmw_button_proc, 360, 275, 80, 20, 255, 0, 0, D_EXIT, 0, 0, (char *)"&Cancel",NULL, NULL },
- { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
-};
-
DIALOG sell_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 *)"Sell", NULL, NULL },
@@ -198,21 +211,24 @@ void init_graphic() {
chatInput->requestFocus();
- // Create stats dialog
+ // Create dialogs
+
statsDialog = new StatsDialog(guiTop);
statsDialog->setPosition(SCREEN_W - statsDialog->getWidth() - 10, 10);
- // Create buy and inventory dialog
buyDialog = new BuyDialog(guiTop);
- inventoryDialog = new InventoryDialog(guiTop);
buyDialog->setVisible(false);
+
+ buySellDialog = new BuySellDialog(guiTop, new BuySellListener());
+ buySellDialog->setVisible(false);
+
+ inventoryDialog = new InventoryDialog(guiTop);
inventoryDialog->setVisible(false);
inventoryDialog->setPosition(100, 100);
npc_player = init_dialog(npc_dialog, -1);
position_dialog(npc_dialog, 300, 200);
skill_player = init_dialog(skill_dialog, -1);
- buy_sell_player = init_dialog(buy_sell_dialog, -1);
sell_player = init_dialog(sell_dialog, -1);
skill_list_player = init_dialog(skill_list_dialog, -1);
npc_list_player = init_dialog(npc_list_dialog, -1);
@@ -506,13 +522,6 @@ void do_graphic(void) {
node = node->next;
}
- // Update character status display
- statsDialog->update();
-
- // Update GUI
- guiGraphics->setTarget(vpage[page_num]);
- gui_update(NULL);
-
set_trans_blender(0, 0, 0, 110);
draw_trans_sprite(vpage[page_num], chat_background, 0, SCREEN_H - 125);
@@ -530,46 +539,6 @@ void do_graphic(void) {
WFIFOSET(6);
}
break;
- case 2:
- dialog_message(buy_sell_dialog, MSG_DRAW, 0, 0);
- if (!gui_update(buy_sell_player)) {
- show_npc_dialog = shutdown_dialog(buy_sell_player);
- if (show_npc_dialog == 1 || show_npc_dialog == 2) {
- WFIFOW(0) = net_w_value(0x00c5);
- WFIFOL(2) = net_l_value(current_npc);
- WFIFOB(6) = net_b_value(show_npc_dialog-1);
- WFIFOSET(7);
- }
- show_npc_dialog = 0;
- buy_sell_player = init_dialog(buy_sell_dialog, -1);
- }
- break;
- case 3:
- /*
- char money[20];
- sprintf(money, "%i gp", char_info->gp);
- buy_dialog[4].dp = &money;
- buy_dialog[5].d1 =
- (int)(char_info->gp / get_item_price(buy_dialog[3].d1));
-
- if (buy_dialog[5].d2 > buy_dialog[5].d1)
- dialog_message(buy_dialog, MSG_DRAW, 0, 0);
- if (!gui_update(buy_player)) {
- show_npc_dialog = shutdown_dialog(buy_player);
- buy_dialog[5].d1 = 0;
- if (show_npc_dialog == 1) {
- WFIFOW(0) = net_w_value(0x00c8);
- WFIFOW(2) = net_w_value(8);
- WFIFOW(4) = net_w_value(buy_dialog[5].d2);
- WFIFOW(6) = net_w_value(get_item_id(buy_dialog[3].d1));
- WFIFOSET(8);
- }
- show_npc_dialog = 0;
- buy_player = init_dialog(buy_dialog, -1);
- close_shop();
- }
- */
- break;
case 4:
//alert("","","","","",0,0);
//char ds[20];
@@ -637,7 +606,13 @@ void do_graphic(void) {
}
}
- draw_sprite(vpage[page_num], mouse_sprite, mouse_x, mouse_y);
+ // Update character status display
+ statsDialog->update();
+
+ // Update GUI
+ guiGraphics->setTarget(vpage[page_num]);
+ gui_update(NULL);
+
release_bitmap(vpage[page_num]);
if (page_flipping) {
diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h
index d71c5ead..6ad42676 100644
--- a/src/graphic/graphic.h
+++ b/src/graphic/graphic.h
@@ -26,6 +26,7 @@
#include "../map.h"
#include "../being.h"
#include "../gui/buy.h"
+#include "../gui/buysell.h"
#include "../gui/chat.h"
#include "../gui/inventory.h"
#include "../gui/shop.h"
@@ -51,6 +52,7 @@ extern char npc_button[10];
extern StatsDialog *statsDialog;
extern BuyDialog *buyDialog;
+extern BuySellDialog *buySellDialog;
extern InventoryDialog *inventoryDialog;
// The action listener for the chat field
@@ -59,6 +61,12 @@ class ChatListener : public gcn::ActionListener {
void action(const std::string& eventId);
};
+// The action listener for the buy or sell dialog
+class BuySellListener : public gcn::ActionListener {
+ public:
+ void action(const std::string& eventId);
+};
+
void do_graphic(void);
void init_graphic(void);
void exit_graphic(void);
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp
new file mode 100644
index 00000000..730689e0
--- /dev/null
+++ b/src/gui/buysell.cpp
@@ -0,0 +1,69 @@
+/*
+ * 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 "buysell.h"
+#include "button.h"
+
+BuySellDialog::BuySellDialog(gcn::Container *parent, gcn::ActionListener *al):
+ Window(parent, "Shop")
+{
+ buyButton = new Button("Buy");
+ sellButton = new Button("Sell");
+ cancelButton = new Button("Cancel");
+
+ buyButton->setPosition(10, 10);
+ sellButton->setPosition(
+ buyButton->getX() + buyButton->getWidth() + 10, 10);
+ cancelButton->setPosition(
+ sellButton->getX() + sellButton->getWidth() + 10, 10);
+ setSize(cancelButton->getX() + cancelButton->getWidth() + 10,
+ cancelButton->getY() + cancelButton->getHeight() + 10);
+
+ buyButton->setEventId("buy");
+ sellButton->setEventId("sell");
+ cancelButton->setEventId("cancel");
+
+ buyButton->addActionListener(al);
+ sellButton->addActionListener(al);
+ cancelButton->addActionListener(al);
+
+ add(buyButton);
+ add(sellButton);
+ add(cancelButton);
+
+ setLocationRelativeTo(getParent());
+ buyButton->requestFocus();
+}
+
+BuySellDialog::~BuySellDialog()
+{
+ delete buyButton;
+ delete sellButton;
+ delete cancelButton;
+}
+
+void BuySellDialog::action(const std::string& eventId)
+{
+ if (eventId == "cancel") {
+ }
+}
diff --git a/src/gui/buysell.h b/src/gui/buysell.h
new file mode 100644
index 00000000..fb03cc9e
--- /dev/null
+++ b/src/gui/buysell.h
@@ -0,0 +1,61 @@
+/*
+ * 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_BUYSELL_H
+#define _TMW_BUYSELL_H
+
+#include "gui.h"
+#include "window.h"
+
+/**
+ * A dialog to choose between buying or selling at a shop.
+ *
+ * \ingroup GUI
+ */
+class BuySellDialog : public Window, public gcn::ActionListener {
+ public:
+ /**
+ * Constructor. The action listener passed will receive "sell", "buy"
+ * or "cancel" events when the respective buttons are pressed.
+ *
+ * @see Window::Window
+ */
+ BuySellDialog(gcn::Container *parent, gcn::ActionListener *al);
+
+ /**
+ * Destructor.
+ */
+ ~BuySellDialog();
+
+ /**
+ * Called when receiving actions from the widgets.
+ */
+ void action(const std::string& eventId);
+
+ private:
+ gcn::Button *buyButton;
+ gcn::Button *sellButton;
+ gcn::Button *cancelButton;
+};
+
+#endif