[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs info_box.cxx,1.11,1.12 info
From: |
torangan |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/worldobjs info_box.cxx,1.11,1.12 info_box.hxx,1.9,1.10 |
Date: |
14 Sep 2002 13:35:40 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/worldobjs
In directory dark:/tmp/cvs-serv823/worldobjs
Modified Files:
info_box.cxx info_box.hxx
Log Message:
splitted InfoBox
Index: info_box.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjs/info_box.cxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- info_box.cxx 10 Sep 2002 21:03:33 -0000 1.11
+++ info_box.cxx 14 Sep 2002 13:35:38 -0000 1.12
@@ -24,195 +24,69 @@
#include "../pingu_holder.hxx"
#include "../world.hxx"
#include "../pingus_resource.hxx"
-#include "../xml_helper.hxx"
-#include "info_box.hxx"
#include "../pingu.hxx"
-
-namespace WorldObjsData {
-
-InfoBoxData::InfoBoxData ()
-{
-}
-
-InfoBoxData::~InfoBoxData ()
-{
-}
-
-WorldObj*
-InfoBoxData::create_WorldObj()
-{
- return new WorldObjs::InfoBox (*this);
-}
-
-EditorObjLst
-InfoBoxData::create_EditorObj()
-{
- EditorObjLst lst;
- lst.push_back (new EditorObjs::EditorInfoBox (*this));
- return lst;
-}
-
-InfoBoxData::InfoBoxData (xmlDocPtr doc, xmlNodePtr cur)
-{
- cur = cur->children;
-
- while (cur)
- {
- if (xmlIsBlankNode(cur))
- {
- cur = cur->next;
- continue;
- }
- else if (XMLhelper::equal_str(cur->name, "position"))
- {
- pos = XMLhelper::parse_vector (doc, cur);
- }
- else if (XMLhelper::equal_str(cur->name, "info-text"))
- {
- info_text = XMLhelper::parse_string (doc, cur);
- }
- else
- std::cout << "InfoBox::creata (): Unhandled " << cur->name << std::endl;
- cur = cur->next;
- }
-}
-
-InfoBoxData::InfoBoxData (const InfoBoxData& old) : WorldObjData(old),
- info_text(old.info_text),
- pos(old.pos),
- text_pos(old.text_pos)
-{
-}
-
-InfoBoxData
-InfoBoxData::operator= (const InfoBoxData& old)
-{
- if (this == &old)
- return *this;
-
- WorldObjData::operator=(old);
-
- info_text = old.info_text;
- pos = old.pos;
- text_pos = old.text_pos;
-
- return *this;
-}
-
-void
-InfoBoxData::write_xml(std::ostream& xml)
-{
- xml << " <worldobj type=\"infobox\">\n";
- XMLhelper::write_vector_xml (xml, pos);
- xml << " <info-text>" << info_text << "</info-text>\n"
- << " </worldobj>\n" << std::endl;
-}
-
-} // namespace WorldObjsData
+#include "../worldobjsdata/info_box_data.hxx"
+#include "info_box.hxx"
namespace WorldObjs {
-InfoBox::InfoBox (const WorldObjsData::InfoBoxData& data)
- : InfoBoxData (data),
- sprite ("infobox", "worldobjs"),
- is_open (false)
+InfoBox::InfoBox (WorldObjsData::InfoBoxData* data_)
+ : is_open (false),
+ data(new WorldObjsData::InfoBoxData(*data_))
{
- sprite.set_align_center_bottom ();
- font = PingusResource::load_font("Fonts/pingus_small", "fonts");
}
void
InfoBox::draw (GraphicContext& gc)
{
- int x = int(gc.get_x_offset () + (gc.get_width ()/2));
- int y = int(gc.get_y_offset () + (gc.get_height ()/2));
+ int x = static_cast<int>(gc.get_x_offset() + (gc.get_width ()/2));
+ int y = static_cast<int>(gc.get_y_offset() + (gc.get_height()/2));
- int x_pos = int(pos.x) + x;
- int y_pos = int(pos.y) + y - 100;
+ int x_pos = static_cast<int>(data->pos.x) + x;
+ int y_pos = static_cast<int>(data->pos.y) + y - 100;
if (is_open)
{
- int width = font->get_text_width (info_text.c_str ());
+ int width = data->font->get_text_width(data->info_text.c_str());
int border = 6;
- gc.draw_line (pos, pos + CL_Vector(0, 0 - 100), 0.0f, 1.0f, 0.0f, 1.0f);
- gc.draw(sprite, pos);
- CL_Display::fill_rect (x_pos - width/2 - border, y_pos - border,
- x_pos + width/2 + border, y_pos + font->get_height
() + border,
- 0.0, 0.0, 0.0, 1.0);
- font->print_center (x_pos, y_pos, info_text.c_str ());
+ gc.draw_line(data->pos, data->pos + CL_Vector(0, 0 - 100), 0.0f, 1.0f,
0.0f, 1.0f);
+ gc.draw(data->sprite, data->pos);
+ CL_Display::fill_rect(x_pos - width/2 - border,
+ y_pos - border,
+ x_pos + width/2 + border,
+ y_pos + data->font->get_height() + border,
+ 0.0, 0.0, 0.0, 1.0);
+ data->font->print_center(x_pos, y_pos, data->info_text.c_str());
}
else
{
- gc.draw (sprite, pos);
+ gc.draw(data->sprite, data->pos);
}
}
void
InfoBox::update (float delta)
{
- sprite.update (delta);
+ data->sprite.update(delta);
PinguHolder* holder = world->get_pingu_p();
for (PinguIter pingu = holder->begin (); pingu != holder->end (); ++pingu)
{
- if ((*pingu)->is_inside (int(pos.x - 16), int(pos.y - 32),
- int(pos.x + 16), int(pos.y)))
+ if ((*pingu)->is_inside (static_cast<int>(data->pos.x - 16),
+ static_cast<int>(data->pos.y - 32),
+ static_cast<int>(data->pos.x + 16),
+ static_cast<int>(data->pos.y)))
{
is_open = true;
}
}
}
-} // namespace WorldObjs
-
-namespace EditorObjs {
-
-EditorInfoBox::EditorInfoBox(const InfoBoxData& data)
- : InfoBoxData (data),
- SpriteEditorObj ("infobox", "worldobjs", &pos)
-{
- sprite.set_align_center_bottom ();
-}
-
-EditorInfoBox::EditorInfoBox (const EditorInfoBox& old) : InfoBoxData(old),
- SpriteEditorObj(old)
-{
-}
-
-EditorInfoBox
-EditorInfoBox::operator= (const EditorInfoBox& old)
-{
- if (this == &old)
- return *this;
-
- InfoBoxData::operator=(old);
- SpriteEditorObj::operator=(old);
-
- return *this;
-}
-
-EditorObjLst
-EditorInfoBox::create (const CL_Vector& pos)
-{
- EditorObjLst lst;
- InfoBoxData data;
- data.pos = pos;
- lst.push_back (new EditorInfoBox (data));
- return lst;
-}
-
-EditorObj*
-EditorInfoBox::duplicate()
-{
- return new EditorInfoBox (*this);
-}
-
-std::string
-EditorInfoBox::status_line ()
-{
- return "InfoBox";
+float
+InfoBox::get_z_pos () const {
+ return data->pos.z;
}
-} // namespace EditorObjs
+} // namespace WorldObjs
/* EOF */
Index: info_box.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldobjs/info_box.hxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- info_box.hxx 10 Sep 2002 19:24:19 -0000 1.9
+++ info_box.hxx 14 Sep 2002 13:35:38 -0000 1.10
@@ -21,56 +21,26 @@
#define HEADER_PINGUS_WORLDOBJS_INFO_BOX_HXX
#include "../worldobj.hxx"
-#include "../worldobj_data.hxx"
#include "../editor/sprite_editorobj.hxx"
-class CL_Font;
-class CL_Vector;
-
-#include "../libxmlfwd.hxx"
-
namespace WorldObjsData {
-
-class InfoBoxData : public WorldObjData
-{
-public:
- std::string info_text;
- CL_Vector pos;
- CL_Vector text_pos;
-
-public:
- InfoBoxData ();
- InfoBoxData (xmlDocPtr doc, xmlNodePtr cur);
-
- InfoBoxData (const InfoBoxData& old);
- InfoBoxData operator= (const InfoBoxData& old);
-
- ~InfoBoxData ();
-
- void write_xml(std::ostream& xml);
- WorldObj* create_WorldObj();
- EditorObjLst create_EditorObj();
-};
-
-} // namespace WorldObjsData
+class InfoBoxData;
+}
namespace WorldObjs {
-// FIXME: Split data into member var
-class InfoBox : public WorldObjsData::InfoBoxData,
- public WorldObj
+class InfoBox : public WorldObj
{
private:
- Sprite sprite;
- CL_Font* font;
bool is_open;
+ WorldObjsData::InfoBoxData* const data;
public:
- InfoBox (const InfoBoxData& data);
+ InfoBox (WorldObjsData::InfoBoxData* data_);
void draw (GraphicContext& gc);
void update (float delta);
- float get_z_pos() const { return pos.z; }
+ float get_z_pos () const;
private:
InfoBox (const InfoBox&);
@@ -79,26 +49,6 @@
} // namespace WorldObjs
-namespace EditorObjs {
-
-class EditorInfoBox : public WorldObjsData::InfoBoxData,
- public SpriteEditorObj
-{
-public:
- EditorInfoBox (const InfoBoxData& data);
-
- static EditorObjLst create (const CL_Vector& pos);
-
- void write_xml(std::ostream& xml) { InfoBoxData::write_xml (xml); }
- EditorObj* duplicate();
- std::string status_line ();
-
-private:
- EditorInfoBox (const EditorInfoBox& old);
- EditorInfoBox operator= (const EditorInfoBox& old);
-};
-
-} // namespace EditorObjs
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/worldobjs info_box.cxx,1.11,1.12 info_box.hxx,1.9,1.10,
torangan <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/editorobjs info_box_obj.cxx,NONE,1.1 info_box_obj.hxx,NONE,1.1 Makefile.am,1.3,1.4
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata info_box_data.cxx,NONE,1.1 info_box_data.hxx,NONE,1.1 Makefile.am,1.3,1.4
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/editorobjs info_box_obj.cxx,NONE,1.1 info_box_obj.hxx,NONE,1.1 Makefile.am,1.3,1.4
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/worldobjsdata info_box_data.cxx,NONE,1.1 info_box_data.hxx,NONE,1.1 Makefile.am,1.3,1.4
- Index(es):