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 "ScrollGump.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(ScrollGump,ModalGump);
00036
00037
00038
00039 ScrollGump::ScrollGump()
00040 : ModalGump()
00041 {
00042
00043 }
00044
00045 ScrollGump::ScrollGump(ObjId owner, std::string msg) :
00046 ModalGump(0, 0, 100, 100, owner), text(msg)
00047 {
00048 }
00049
00050 ScrollGump::~ScrollGump(void)
00051 {
00052 }
00053
00054 void ScrollGump::InitGump(Gump* newparent, bool take_focus)
00055 {
00056 ModalGump::InitGump(newparent, take_focus);
00057
00058
00059 Gump *widget = new TextWidget(22,29,text,true,9,204,115);
00060 widget->InitGump(this);
00061 textwidget = widget->getObjId();
00062
00063 text.clear();
00064
00065 Shape* shape = GameData::get_instance()->getGumps()->getShape(19);
00066
00067 SetShape(shape, 0);
00068
00069 ShapeFrame* sf = shape->getFrame(0);
00070 assert(sf);
00071
00072 dims.w = sf->width;
00073 dims.h = sf->height;
00074 }
00075
00076 void ScrollGump::NextText()
00077 {
00078 TextWidget *widget = p_dynamic_cast<TextWidget*>(getGump(textwidget));
00079 assert(widget);
00080 if (!widget->setupNextText()) {
00081 Close();
00082 }
00083 }
00084
00085 bool ScrollGump::Run(const uint32 framenum)
00086 {
00087 ModalGump::Run(framenum);
00088
00089 return true;
00090 }
00091
00092 void ScrollGump::OnMouseClick(int button, int mx, int my)
00093 {
00094
00095 NextText();
00096 }
00097
00098 void ScrollGump::OnMouseDouble(int button, int mx, int my)
00099 {
00100 Close();
00101 }
00102
00103 uint32 ScrollGump::I_readScroll(const uint8* args, unsigned int )
00104 {
00105 ARG_ITEM_FROM_PTR(item);
00106 ARG_STRING(str);
00107 assert(item);
00108
00109 Gump *gump = new ScrollGump(item->getObjId(), str);
00110 gump->InitGump(0);
00111 gump->setRelativePosition(CENTER);
00112
00113 return gump->GetNotifyProcess()->getPid();
00114 }
00115
00116 void ScrollGump::saveData(ODataSource* ods)
00117 {
00118 CANT_HAPPEN_MSG("Trying to save ModalGump");
00119 }
00120
00121 bool ScrollGump::loadData(IDataSource* ids, uint32 version)
00122 {
00123 CANT_HAPPEN_MSG("Trying to load ModalGump");
00124
00125 return false;
00126 }
00127