00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "pent_include.h"
00020 #include "BookGump.h"
00021 #include "TextWidget.h"
00022 #include "GameData.h"
00023 #include "Shape.h"
00024 #include "GumpShapeArchive.h"
00025 #include "ShapeFrame.h"
00026 #include "UCMachine.h"
00027 #include "GumpNotifyProcess.h"
00028 #include "Item.h"
00029 #include "getObject.h"
00030
00031
00032 #include "IDataSource.h"
00033 #include "ODataSource.h"
00034
00035 DEFINE_RUNTIME_CLASSTYPE_CODE(BookGump,ModalGump);
00036
00037
00038
00039 BookGump::BookGump()
00040 : ModalGump()
00041 {
00042
00043 }
00044
00045 BookGump::BookGump(ObjId owner, std::string msg) :
00046 ModalGump(0, 0, 100, 100, owner), text(msg)
00047 {
00048 }
00049
00050 BookGump::~BookGump(void)
00051 {
00052 }
00053
00054 void BookGump::InitGump(Gump* newparent, bool take_focus)
00055 {
00056 ModalGump::InitGump(newparent, take_focus);
00057
00058
00059 TextWidget *widget = new TextWidget(9,5,text,true,9,123,129);
00060 widget->InitGump(this);
00061 textwidgetL = widget->getObjId();
00062
00063 widget = new TextWidget(150,5,text,true,9,123,129);
00064 widget->InitGump(this);
00065 textwidgetR = widget->getObjId();
00066 widget->setupNextText();
00067
00068 text.clear();
00069
00071 Shape* shape = GameData::get_instance()->getGumps()->getShape(6);
00072
00073 SetShape(shape, 0);
00074
00075 ShapeFrame* sf = shape->getFrame(0);
00076 assert(sf);
00077
00078 dims.w = sf->width;
00079 dims.h = sf->height;
00080 }
00081
00082 void BookGump::NextText()
00083 {
00084 TextWidget *widgetL = p_dynamic_cast<TextWidget*>(getGump(textwidgetL));
00085 TextWidget *widgetR = p_dynamic_cast<TextWidget*>(getGump(textwidgetR));
00086 assert(widgetL);
00087 assert(widgetR);
00088 if (!widgetR->setupNextText()) {
00089 Close();
00090 }
00091 widgetL->setupNextText();
00092 widgetL->setupNextText();
00093 widgetR->setupNextText();
00094 }
00095
00096 bool BookGump::Run(const uint32 framenum)
00097 {
00098 ModalGump::Run(framenum);
00099
00100 return true;
00101 }
00102
00103 void BookGump::OnMouseClick(int button, int mx, int my)
00104 {
00105
00106 NextText();
00107 }
00108
00109 void BookGump::OnMouseDouble(int button, int mx, int my)
00110 {
00111 Close();
00112 }
00113
00114 uint32 BookGump::I_readBook(const uint8* args, unsigned int )
00115 {
00116 ARG_ITEM_FROM_PTR(item);
00117 ARG_STRING(str);
00118 assert(item);
00119
00120 Gump *gump = new BookGump(item->getObjId(), str);
00121 gump->InitGump(0);
00122 gump->setRelativePosition(CENTER);
00123
00124 return gump->GetNotifyProcess()->getPid();
00125 }
00126
00127 void BookGump::saveData(ODataSource* ods)
00128 {
00129 CANT_HAPPEN_MSG("Trying to save ModalGump");
00130 }
00131
00132 bool BookGump::loadData(IDataSource* ids, uint32 version)
00133 {
00134 CANT_HAPPEN_MSG("Trying to load ModalGump");
00135
00136 return false;
00137 }