ScrollGump.cpp

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2004-2006  The Pentagram Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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 // TODO: Remove all the hacks
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         // Create the TextWidget
00059         Gump *widget = new TextWidget(22,29,text,true,9,204,115); 
00060         widget->InitGump(this);
00061         textwidget = widget->getObjId();
00062 
00063         text.clear(); // no longer need this
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;    // Always repaint, even though we really could just try to detect it
00090 }
00091 
00092 void ScrollGump::OnMouseClick(int button, int mx, int my)
00093 {
00094         // Scroll to next text, if possible
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 /*argsize*/)
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 

Generated on Fri Jul 27 22:27:34 2007 for pentagram by  doxygen 1.4.7