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 "ReadableGump.h"
00021
00022 #include "TextWidget.h"
00023 #include "GameData.h"
00024 #include "Shape.h"
00025 #include "GumpShapeArchive.h"
00026 #include "ShapeFrame.h"
00027 #include "UCMachine.h"
00028 #include "GumpNotifyProcess.h"
00029 #include "Item.h"
00030 #include "getObject.h"
00031 #include "CoreApp.h"
00032 #include "GameInfo.h"
00033 #include "util.h"
00034
00035 #include "IDataSource.h"
00036 #include "ODataSource.h"
00037
00038 DEFINE_RUNTIME_CLASSTYPE_CODE(ReadableGump,ModalGump);
00039
00040 const int jpsub_font = 6;
00041
00042 ReadableGump::ReadableGump()
00043 : ModalGump()
00044 {
00045
00046 }
00047
00048 ReadableGump::ReadableGump(ObjId owner, uint16 shape, int font, std::string msg) :
00049 ModalGump(0, 0, 100, 100, owner), shapenum(shape), fontnum(font), text(msg)
00050 {
00051 }
00052
00053 ReadableGump::~ReadableGump(void)
00054 {
00055 }
00056
00057 void ReadableGump::InitGump(Gump* newparent, bool take_focus)
00058 {
00059 ModalGump::InitGump(newparent, take_focus);
00060
00061 Shape* shape = GameData::get_instance()->getGumps()->getShape(shapenum);
00062
00063 SetShape(shape, 0);
00064
00065 ShapeFrame* sf = shape->getFrame(0);
00066 assert(sf);
00067
00068 dims.w = sf->width;
00069 dims.h = sf->height;
00070
00071 if (CoreApp::get_instance()->getGameInfo()->language ==
00072 GameInfo::GAMELANG_JAPANESE)
00073 {
00074
00075 std::string::size_type pos;
00076 pos = text.find('%');
00077 if (pos != std::string::npos) {
00078 std::string jpsub = text.substr(pos + 1);
00079 text = text.substr(0, pos);
00080
00081 Gump* subwidget = new TextWidget(0, 0, jpsub, true, jpsub_font, 0, 0, Pentagram::Font::TEXT_CENTER);
00082 subwidget->InitGump(this);
00083 subwidget->setRelativePosition(BOTTOM_CENTER, 0, -8);
00084 }
00085 }
00086
00087 Gump *widget = new TextWidget(0, 0, text, true, fontnum, dims.w - 16, 0, Pentagram::Font::TEXT_CENTER);
00088 widget->InitGump(this);
00089 widget->setRelativePosition(CENTER);
00090 }
00091
00092 Gump *ReadableGump::OnMouseDown(int button, int mx, int my)
00093 {
00094 Close();
00095 return this;
00096 }
00097
00098 uint32 ReadableGump::I_readGrave(const uint8* args, unsigned int )
00099 {
00100 ARG_ITEM_FROM_PTR(item);
00101 ARG_UINT16(shape);
00102 ARG_STRING(str);
00103 assert(item);
00104
00105 Gump *gump = new ReadableGump(item->getObjId(), shape, 11, str);
00106 gump->InitGump(0);
00107 gump->setRelativePosition(CENTER);
00108
00109 return gump->GetNotifyProcess()->getPid();
00110 }
00111
00112 uint32 ReadableGump::I_readPlaque(const uint8* args, unsigned int )
00113 {
00114 ARG_ITEM_FROM_PTR(item);
00115 ARG_UINT16(shape);
00116 ARG_STRING(str);
00117 assert(item);
00118
00119 Gump *gump = new ReadableGump(item->getObjId(), shape, 10, str);
00120 gump->InitGump(0);
00121 gump->setRelativePosition(CENTER);
00122
00123 return gump->GetNotifyProcess()->getPid();
00124 }
00125
00126 void ReadableGump::saveData(ODataSource* ods)
00127 {
00128 CANT_HAPPEN_MSG("Trying to load ModalGump");
00129 }
00130
00131 bool ReadableGump::loadData(IDataSource* ids, uint32 version)
00132 {
00133 CANT_HAPPEN_MSG("Trying to load ModalGump");
00134
00135 return false;
00136 }
00137