From: <la...@us...> - 2011-07-12 05:29:08
|
Revision: 7513 http://planeshift.svn.sourceforge.net/planeshift/?rev=7513&view=rev Author: landson Date: 2011-07-12 05:29:02 +0000 (Tue, 12 Jul 2011) Log Message: ----------- just realized attacklist.cpp and attacklist.h weren't adding to the svn so here they are Added Paths: ----------- soc/2011/combat/src/client/gui/attacklist.cpp soc/2011/combat/src/client/gui/attacklist.h Added: soc/2011/combat/src/client/gui/attacklist.cpp =================================================================== --- soc/2011/combat/src/client/gui/attacklist.cpp (rev 0) +++ soc/2011/combat/src/client/gui/attacklist.cpp 2011-07-12 05:29:02 UTC (rev 7513) @@ -0,0 +1,162 @@ +/* + * attacklist.cpp creator: har...@gm... + * + * Copyright (C) 2001-2011 Atomic Blue (in...@pl..., http://www.atomicblue.org) + * + * + * This program 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 (version 2 of the License) + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include <psconfig.h> + +// COMMON INCLUDES +#include "net/messages.h" +#include "net/clientmsghandler.h" +#include "util/strutil.h" +#include "net/connection.h" +#include "net/cmdhandler.h" + +// CLIENT INCLUDES +#include "../globals.h" + +// PAWS INCLUDES +#include "gui/attacklist.h" +#include "paws/pawstextbox.h" +#include "paws/pawslistbox.h" +#include "paws/pawsmanager.h" +#include "gui/pawsslot.h" +#include "gui/pawscontrolwindow.h" + + +pawsAttackBookWindow::pawsAttackBookWindow() +{ + selectedAttack.Clear(); +} + +pawsAttackBookWindow::~pawsAttackBookWindow() +{ + +} + +bool pawsAttackBookWindow::PostSetup() +{ + psengine->GetMsgHandler()->Subscribe(this, MSGTYPE_ATTACK_BOOK); + + attackList = (pawsListBox*)FindWidget("AttackList"); + attackDescription = (pawsMessageTextBox*)FindWidget("Description"); + attackImage = (pawsSlot*)FindWidget("AttackImage"); + + attackList->SetSortingFunc(0, textBoxSortFunc); + attackList->SetSortingFunc(5, textBoxSortFunc); + attackList->SetSortingFunc(6, textBoxSortFunc); + + return true; +} + +void pawsAttackBookWindow::HandleMessage( MsgEntry* me ) +{ + switch ( me->GetType() ) + { + case MSGTYPE_ATTACK_BOOK: + { + HandleAttacks( me ); + attackList->SortRows(); ///after getting attacks sort the column specified in xml + break; + } + } +} + +bool pawsAttackBookWindow::OnButtonPressed(int /*mouseButton*/, int /*keyModifier*/, pawsWidget* widget) +{ + if (!strcmp(widget->GetName(),"Queue")) + { + Queue(); //queue the selected attack + return true; + } +} + +void pawsAttackBookWindow::HandleAttacks( MsgEntry* me ) +{ + //lists all available attacks + attackList->Clear(); + descriptions_Hash.Empty(); + images_Hash.Empty(); + + + psAttackBookMessage mesg(me, ((psNetManager*)psengine->GetNetManager())->GetConnection()->GetAccessPointers()); + + for ( size_t x = 0; x < mesg.attacks.GetSize(); x++ ) + { + pawsListBoxRow* row = attackList->NewRow(); + pawsTextBox* name = (pawsTextBox*)row->GetColumn(0); + name->SetText( mesg.attacks[x].name ); + + pawsTextBox* type = (pawsTextBox*)row->GetColumn(2); + type->SetText( mesg.attacks[x].type ); + + + descriptions_Hash.Put(mesg.attacks[x].name, mesg.attacks[x].description); + images_Hash.Put(mesg.attacks[x].name, mesg.attacks[x].image); + if (selectedAttack == mesg.attacks[x].name) + { + attackList->Select(row); + } + } +} + + + +void pawsAttackBookWindow::Queue() +{ + if ( selectedAttack.Length() > 0 ) + { + csString Command; + Command.Append("/queue "); + Command.Append(selectedAttack); + psengine->GetCmdHandler()->Execute(Command); + } +} + + +void pawsAttackBookWindow::Show() +{ + pawsControlledWindow::Show(); + psAttackBookMessage msg; + msg.SendMessage(); +} + + +void pawsAttackBookWindow::Close() +{ + Hide(); + attackList->Clear(); +} + +void pawsAttackBookWindow::OnListAction( pawsListBox* widget, int status ) +{ + if (status==LISTBOX_HIGHLIGHTED) + { + attackDescription->Clear(); + pawsListBoxRow* row = widget->GetSelectedRow(); + + pawsTextBox* attackName = (pawsTextBox*)(row->GetColumn(0)); + + selectedAttack.Replace( attackName->GetText() ); + attackDescription->AddMessage(descriptions_Hash.Get(attackName->GetText(), "Unknown")); + attackDescription->ResetScroll(); + attackImage->PlaceItem(images_Hash.Get(attackName->GetText(),""), "", "", 1); + csString action = "/queue " + csString(attackName->GetText()); + attackImage->SetBartenderAction(action); + attackImage->SetToolTip(attackName->GetText()); + } +} Property changes on: soc/2011/combat/src/client/gui/attacklist.cpp ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: soc/2011/combat/src/client/gui/attacklist.h =================================================================== --- soc/2011/combat/src/client/gui/attacklist.h (rev 0) +++ soc/2011/combat/src/client/gui/attacklist.h 2011-07-12 05:29:02 UTC (rev 7513) @@ -0,0 +1,72 @@ +/* + * attacklist.cpp creator: har...@gm... + * + * Copyright (C) 2001-2011 Atomic Blue (in...@pl..., http://www.atomicblue.org) + * + * + * This program 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 (version 2 of the License) + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ +#ifndef PAWS_ATTACK_WINDOW_HEADER +#define PAWS_ATTACK_WINDOW_HEADER + +#include "paws/pawswidget.h" +class pawsTextBox; +class pawsListBox; +class pawsMessageTextBox; +class pawsSlot; + +#include "net/cmdbase.h" +#include "gui/pawscontrolwindow.h" + + +/** This handles all the details about how the spell book works. + */ +class pawsAttackBookWindow : public pawsControlledWindow, public psClientNetSubscriber +{ +public: + + pawsAttackBookWindow(); + virtual ~pawsAttackBookWindow(); + + bool PostSetup(); + + virtual void HandleMessage(MsgEntry *msg); + + bool OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget ); + void OnListAction( pawsListBox* listbox, int status ); + void Show(); +private: + + void Queue(); + + void Close(); + + void HandleAttacks( MsgEntry* me ); + + pawsListBox* attackList; + pawsMessageTextBox* attackDescription; + pawsSlot* attackImage; + + csString selectedAttack; + + csHash<csString, csString> descriptions_Hash; + csHash<csString, csString> images_Hash; +}; + +CREATE_PAWS_FACTORY( pawsAttackBookWindow ); + + +#endif + + + Property changes on: soc/2011/combat/src/client/gui/attacklist.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |