Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

/home/groups/n/no/noxwizard/cvs/src/menu.h

Go to the documentation of this file.
00001   /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
00002     || NoX-Wizard UO Server Emulator (NXW) [http://noxwizard.sourceforge.net]  ||
00003     ||                                                                         ||
00004     || This software is free software released under GPL2 license.             ||
00005     || You can find detailed license information in nox-wizard.cpp file.       ||
00006     ||                                                                         ||
00007     || For any question post to NoX-Wizard forums.                             ||
00008     -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
00009 
00016 #ifndef _MENU_H_
00017 #define _MENU_H_
00018 
00019 
00020 #include "nxwcommn.h"
00021 #include "packets.h"
00022 
00023 
00024 #define MENUSTYLE_LARGE 128
00025 
00026 //rename after from M_ to MENUTYPE_
00027 enum MENU_TYPE {
00028         MENUTYPE_INVALID = INVALID,
00029         MENUTYPE_STONE = 0,
00030         MENUTYPE_SCROLL,
00031         MENUTYPE_PAPER,
00032         MENUTYPE_BLACKBOARD,
00033         MENUTYPE_TRASPARENCY,
00034         MENUTYPE_CUSTOM,
00035         MENUTYPE_ICONLIST = 16,
00036         MENUTYPE_ADDMENU
00037 };
00038 
00039 #define MENU_CLOSE 0
00040 
00041 typedef void ( *menu_callback ) ( P_MENU, NXWCLIENT, SI32 );
00042 
00047 class cBasicMenu {
00048 
00049         friend class cOldMenu;
00050         friend class cNewAddMenu;
00051         friend class cMenus;
00052 
00053         private:
00054 
00055                 std::set<SERIAL> whoSeeThis; 
00056 
00057         protected:
00058 
00059                 AmxFunction* callback; 
00060 
00061                 virtual cServerPacket* createPacket();
00062                 virtual cServerPacket* build();
00063 
00064         public:
00065 
00066                 MENU_TYPE id; 
00067                 menu_callback hard; 
00068 
00069                 cBasicMenu( MENU_TYPE id );
00070                 virtual ~cBasicMenu();
00071 
00072                 SERIAL  serial; 
00073 
00074                 void setCallBack( std::string arg );
00075                 void setCallBack( FUNCIDX fn );
00076 
00077                 virtual void handleButton( NXWCLIENT ps, cClientPacket* pkg  );
00078                 virtual void show( P_CHAR pc );
00079 
00080 
00081 };
00082 
00083 
00084 #define ISVALIDPM( M )  ( M!=NULL ) 
00085 #define VALIDATEPM( M ) if( !ISVALIDPM(M) )     return;
00086 #define VALIDATEPMR( M, R )     if( !ISVALIDPM(M) )     return R;
00087 
00088 #define MENU_BUFF_COUNT 5
00089 #define ISVALIDMENUBUFFER( I ) ( (I>INVALID) && (I<MENU_BUFF_COUNT) )
00090 
00095 class cMenu : public cBasicMenu
00096 {
00097 
00098         private:
00099 
00100                 bool closeable;
00101                 bool moveable;
00102                 bool disposeable;
00103                 
00104                 SERIAL rc_serialCurrent;        
00105                 std::map< SERIAL, SI32 > rc_button;     
00106                 std::map< SERIAL, SI32 > rc_radio;      
00107                 std::map< SERIAL, SI32 > rc_checkbox;   
00108                 std::map< SERIAL, SI32 > rc_edit;       
00109 
00110                 std::map< SERIAL, FUNCIDX > buttonCallbacks;    
00111                 std::map< SERIAL, SI32 > editProps;     
00112 
00113                 std::vector< SERIAL >* switchs; 
00114                 std::map< SERIAL, std::wstring >* textResp; 
00115 
00116                 UI32 addString( wstring s );
00117 
00118                 void removeCommand( std::string command );
00119                 void removeCommand( char* s, ... );
00120 
00121                 void setPropertyField( SERIAL type, SERIAL obj, int prop, int subProp, int subProp2, bool data );
00122                 void setPropertyField( SERIAL type, SERIAL obj, int prop, int subProp, int subProp2, std::wstring data );
00123                 
00124                 bool getPropertyFieldBool( SERIAL type, SERIAL obj, int prop, int subProp, int subProp2 );
00125                 std::wstring getPropertyField( SERIAL type, SERIAL obj, int prop, int subProp, int subProp2 );
00126 
00127                 SI32 getIntFromProps( int prop, int prop2, int prop3 );
00128                 void getPropsFromInt( SI32 returnCode, int& prop, int& prop2, int& prop3 );
00129 
00130         protected:
00131                 std::vector< std::string >      commands; 
00132                 std::vector< wstring >  texts; 
00133         
00134                 virtual cServerPacket* createPacket();
00135 
00136         public:
00137                                 
00138                 UI32 x; 
00139                 UI32 y; 
00140                 UI32 pageCount; 
00141                 UI32 pageCurrent;       
00142                 UI32 groupCount;        
00143                 UI32 groupCurrent;      
00144                 SERIAL buffer[MENU_BUFF_COUNT];
00145                 std::string buffer_str[MENU_BUFF_COUNT];
00146 
00147                 cMenu( MENU_TYPE id, UI32 x, UI32 y, bool canMove, bool canClose, bool canDispose );
00148                 ~cMenu();
00149 
00150                 void setCloseable( bool canClose );
00151                 bool getCloseable();
00152                 void setDisposeable( bool canDispose );
00153                 bool getDisposeable();
00154                 void setMoveable( bool canMove );
00155                 bool getMoveable();
00156 
00157                 virtual void handleButton( NXWCLIENT ps,  cClientPacket* pkg  );
00158 
00159                 void addCommand( std::string command );
00160                 void addCommand( char* s, ... );
00161 
00162                 void addBackground( UI32 gumpId, UI32 width, UI32 height );
00163                 void addButton( UI32 x, UI32 y, UI32 up, UI32 down, SI32 returnCode, bool pressable );
00164                 void addButtonFn( UI32 x, UI32 y, UI32 up, UI32 down, SI32 returnCode, bool pressable, FUNCIDX fn );
00165                 void addCheckbox( UI32 x, UI32 y, UI32 off, UI32 on, UI32 checked, SI32 result );
00166                 void addCheckertrans( UI32 x, UI32 y, UI32 width, UI32 height );
00167                 void addCroppedText( UI32 x, UI32 y, UI32 width, UI32 height, wstring text, UI32 hue );
00168                 void addGump( UI32 x, UI32 y, UI32 gump, UI32 hue );
00169                 void addHtmlGump( UI32 x, UI32 y, UI32 width, UI32 height, wstring html, UI32 hasBack, UI32 canScroll );
00170                 void addInputField( UI32 x, UI32 y, UI32 width, UI32 height, UI16 textId, wstring data, UI32 hue = 0 );
00171                 void addPropertyField( UI32 x, UI32 y, UI32 width, UI32 height, UI32 property, UI32 subProperty, UI32 hue = 0, UI32 subProperty2 = 0 );
00172                 void addRadioButton( UI32 x, UI32 y, UI32 off, UI32 on, UI32 checked, SI32 result  );
00173                 void addResizeGump( UI32 x, UI32 y, UI32 gumpId, UI32 width, UI32 height );
00174                 void addText( UI32 x, UI32 y, wstring data, UI32 hue = 0 );
00175                 void addTilePic( UI32 x, UI32 y, UI32 tile, UI32 hue = 0 );
00176                 void addTiledGump( UI32 x, UI32 y, UI32 width, UI32 height, UI32 gump, UI32 hue );
00177                 void addXmfHtmlGump( UI32 x, UI32 y, UI32 width, UI32 height, wstring clilocid, UI32 hasBack , UI32 canScroll );
00178                 void addGroup( UI32 group = 0 );
00179                 void addPage( UI32 page );
00180                 void addPageButton( UI32 x, UI32 y, UI32 up, UI32 down, UI32 page );
00181 
00182                 bool getCheckBox( SERIAL checkbox, bool raw=false );
00183                 bool getRadio( SERIAL radio, bool raw=false );
00184                 std::wstring* getText( SERIAL text, bool raw=false );
00185                 SI32 getButton( SI32 rawButton );
00186 };
00187 
00188 
00189 class cIconListMenu : public cBasicMenu
00190 {
00191 
00192         protected:
00193 
00194                 virtual cServerPacket* createPacket();
00195                 std::vector< pkg_icon_list_menu_st > icons;
00196                 std::map< SERIAL, SI32 > iconData;
00197 
00198         public:
00199 
00200                 std::string question;
00201 
00202                 cIconListMenu();
00203                 ~cIconListMenu();
00204 
00205                 virtual void handleButton( NXWCLIENT ps,  cClientPacket* pkg  );
00206                 void addIcon( UI16 model, COLOR color, std::string response );
00207                 void addIcon( UI16 model, COLOR color, SI32 data, std::string response );
00208 
00209 };
00210 
00211 
00212 bool isIconList( NXWSOCKET s );
00213 bool isIconList( UI08 cmd );
00214 
00215 typedef std::map< UI32, P_MENU > MENU_MAP;
00216 
00220 class cMenus
00221 {
00222         
00223         friend class cBasicMenu;
00224 
00225         private:
00226                 SERIAL current_serial; 
00227                 MENU_MAP menuMap; 
00228 
00229                 std::map< SERIAL, std::set<SERIAL> > whoSeeWhat; 
00230 
00231                 bool removeFromView( P_MENU menu, SERIAL chr );
00232 
00233         public:
00234 
00235                 cMenus();
00236                 ~cMenus();
00237 
00238                 P_MENU insertMenu( P_MENU menu );
00239                 SERIAL removeMenu( SERIAL menu, P_CHAR pc = NULL );
00240                 bool handleMenu( NXWCLIENT ps );
00241                 P_MENU getMenu( SERIAL menu );
00242                 bool showMenu( SERIAL menu, P_CHAR pc );
00243 
00244 };
00245 
00246 extern cMenus Menus;
00247 
00248 #endif
SourceForge.net Logo