diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-22 00:44:09 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-22 00:44:09 +0000 |
commit | a64c5b01e683e76def759e6e871ceee330c9ae09 (patch) | |
tree | cc65bb71e89df3ce933aaa3ef52884e350f35efa | |
parent | 423bd85aa1ca8051129df388aa2211dfbbe8ec1e (diff) | |
download | mana-a64c5b01e683e76def759e6e871ceee330c9ae09.tar.gz mana-a64c5b01e683e76def759e6e871ceee330c9ae09.tar.bz2 mana-a64c5b01e683e76def759e6e871ceee330c9ae09.tar.xz mana-a64c5b01e683e76def759e6e871ceee330c9ae09.zip |
Picking up now possible with Z, and fixed width of a few scroll area contents.
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | src/game.cpp | 84 | ||||
-rw-r--r-- | src/gui/buy.cpp | 1 | ||||
-rw-r--r-- | src/gui/char_server.cpp | 1 | ||||
-rw-r--r-- | src/gui/npc.cpp | 1 | ||||
-rw-r--r-- | src/gui/scrollarea.cpp | 21 | ||||
-rw-r--r-- | src/gui/scrollarea.h | 6 | ||||
-rw-r--r-- | src/gui/sell.cpp | 1 |
8 files changed, 73 insertions, 44 deletions
@@ -41,7 +41,7 @@ over NPC's feet to talk to them or over a monster to attack it. Other keys: - F5 sit down / stand up - F6 toggle debug pathfinding feature - F7 play test sound -- G pick up item +- G or Z pick up item - Enter focus chat window / send message - Alt + K show skills - Alt + S show stats diff --git a/src/game.cpp b/src/game.cpp index bc56578a..6aad95fd 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -321,53 +321,51 @@ void do_input() } } - if (keysym.sym == SDLK_g && !chatWindow->isFocused()) + if ((keysym.sym == SDLK_g || keysym.sym == SDLK_z) && + !chatWindow->isFocused()) { // Get the item code - if (!chatWindow->isFocused()) + used = true; + int id = 0; + id = find_floor_item_by_cor(player_node->x, player_node->y); + if (id != 0) { - used = true; - int id = 0; - id = find_floor_item_by_cor(player_node->x, player_node->y); - if (id != 0) - { - WFIFOW(0) = net_w_value(0x009f); - WFIFOL(2) = net_l_value(id); - WFIFOSET(6); - } - else { - switch (player_node->direction) { - case NORTH: - id = find_floor_item_by_cor(player_node->x, player_node->y-1); - break; - case SOUTH: - id = find_floor_item_by_cor(player_node->x, player_node->y+1); - break; - case WEST: - id = find_floor_item_by_cor(player_node->x-1, player_node->y); - break; - case EAST: - id = find_floor_item_by_cor(player_node->x+1, player_node->y); - break; - case NW: - id = find_floor_item_by_cor(player_node->x-1, player_node->y-1); - break; - case NE: - id = find_floor_item_by_cor(player_node->x+1, player_node->y-1); - break; - case SW: - id = find_floor_item_by_cor(player_node->x-1, player_node->y+1); - break; - case SE: - id = find_floor_item_by_cor(player_node->x+1, player_node->y+1); - break; - default: - break; - } - WFIFOW(0) = net_w_value(0x009f); - WFIFOL(2) = net_l_value(id); - WFIFOSET(6); + WFIFOW(0) = net_w_value(0x009f); + WFIFOL(2) = net_l_value(id); + WFIFOSET(6); + } + else { + switch (player_node->direction) { + case NORTH: + id = find_floor_item_by_cor(player_node->x, player_node->y-1); + break; + case SOUTH: + id = find_floor_item_by_cor(player_node->x, player_node->y+1); + break; + case WEST: + id = find_floor_item_by_cor(player_node->x-1, player_node->y); + break; + case EAST: + id = find_floor_item_by_cor(player_node->x+1, player_node->y); + break; + case NW: + id = find_floor_item_by_cor(player_node->x-1, player_node->y-1); + break; + case NE: + id = find_floor_item_by_cor(player_node->x+1, player_node->y-1); + break; + case SW: + id = find_floor_item_by_cor(player_node->x-1, player_node->y+1); + break; + case SE: + id = find_floor_item_by_cor(player_node->x+1, player_node->y+1); + break; + default: + break; } + WFIFOW(0) = net_w_value(0x009f); + WFIFOL(2) = net_l_value(id); + WFIFOSET(6); } } } // End key down diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 79f21227..d291650d 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -47,6 +47,7 @@ BuyDialog::BuyDialog(): itemDescLabel = new gcn::Label("Description:"); setContentSize(260, 198); + scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); scrollArea->setDimension(gcn::Rectangle(5, 5, 250, 110)); itemList->setDimension(gcn::Rectangle(5, 5, 238, 110)); slider->setDimension(gcn::Rectangle(5, 120, 200, 10)); diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp index a2bd352f..8674b6d4 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -50,6 +50,7 @@ ServerSelectDialog::ServerSelectDialog(): okButton->setPosition( cancelButton->getX() - okButton->getWidth() - 5, 100 - okButton->getHeight() - 5); + scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); scrollArea->setDimension(gcn::Rectangle( 5, 5, 200 - 2 * 5, 100 - 3 * 5 - cancelButton->getHeight() - diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp index 42d1151c..084f2f6a 100644 --- a/src/gui/npc.cpp +++ b/src/gui/npc.cpp @@ -37,6 +37,7 @@ NpcListDialog::NpcListDialog(): cancelButton = new Button("Cancel"); setContentSize(260, 175); + scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); scrollArea->setDimension(gcn::Rectangle( 5, 5, 250, 160 - okButton->getHeight())); cancelButton->setPosition( diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index ad31ada8..319025a0 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -137,6 +137,27 @@ void ScrollArea::init() instances++; } +void ScrollArea::logic() +{ + gcn::ScrollArea::logic(); + + // When no scrollbar in a certain direction, adapt content size to match + // the content dimension exactly. + if (mContent != NULL) + { + if (getHorizontalScrollPolicy() == gcn::ScrollArea::SHOW_NEVER) + { + mContent->setWidth(getContentDimension().width - + 2 * mContent->getBorderSize()); + } + if (getVerticalScrollPolicy() == gcn::ScrollArea::SHOW_NEVER) + { + mContent->setHeight(getContentDimension().height - + 2 * mContent->getBorderSize()); + } + } +} + void ScrollArea::draw(gcn::Graphics *graphics) { checkPolicies(); diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h index e3e57ae2..66ec1542 100644 --- a/src/gui/scrollarea.h +++ b/src/gui/scrollarea.h @@ -51,6 +51,12 @@ class ScrollArea : public gcn::ScrollArea { ~ScrollArea(); /** + * Logic function optionally adapts width or height of contents. This + * depends on the scrollbar settings. + */ + void logic(); + + /** * Draws the scroll area. */ void draw(gcn::Graphics *graphics); diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index f2e1677f..95c4a2dc 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -45,6 +45,7 @@ SellDialog::SellDialog(): okButton->setEnabled(false); setContentSize(260, 175); + scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); scrollArea->setDimension(gcn::Rectangle(5, 5, 250, 110)); itemList->setDimension(gcn::Rectangle(5, 5, 238, 110)); slider->setDimension(gcn::Rectangle(5, 120, 200, 10)); |