ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

item.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef STARK_RESOURCES_ITEM_H
00024 #define STARK_RESOURCES_ITEM_H
00025 
00026 #include "engines/stark/resources/object.h"
00027 #include "engines/stark/resourcereference.h"
00028 
00029 #include "common/rect.h"
00030 #include "common/str.h"
00031 
00032 #include "math/vector3d.h"
00033 
00034 namespace Stark {
00035 
00036 class AnimHandler;
00037 class Movement;
00038 class Visual;
00039 
00040 namespace Gfx {
00041 class RenderEntry;
00042 }
00043 
00044 namespace Formats {
00045 class XRCReadStream;
00046 }
00047 
00048 namespace Resources {
00049 
00050 class Anim;
00051 class AnimHierarchy;
00052 class BonesMesh;
00053 class Bookmark;
00054 class ItemVisual;
00055 class Script;
00056 class TextureSet;
00057 
00063 class Item : public Object {
00064 public:
00065     static const Type::ResourceType TYPE = Type::kItem;
00066 
00067     enum SubType {
00068         kItemGlobalTemplate = 1,
00069         kItemInventory = 2,
00070         kItemLevelTemplate = 3,
00071         kItemStaticProp = 5,
00072         kItemAnimatedProp = 6,
00073         kItemBackgroundElement = 7,
00074         kItemBackground = 8,
00075         kItemModel = 10
00076     };
00077 
00079     static Object *construct(Object *parent, byte subType, uint16 index, const Common::String &name);
00080 
00081     Item(Object *parent, byte subType, uint16 index, const Common::String &name);
00082     virtual ~Item();
00083 
00084     // Resource API
00085     virtual void readData(Formats::XRCReadStream *stream) override;
00086     virtual void onGameLoop() override;
00087     virtual void saveLoad(ResourceSerializer *serializer) override;
00088     virtual void saveLoadCurrent(ResourceSerializer *serializer) override;
00089 
00091     bool isEnabled() const;
00092 
00094     virtual void setEnabled(bool enabled);
00095 
00097     int32 getCharacterIndex() const;
00098 
00100     virtual Gfx::RenderEntry *getRenderEntry(const Common::Point &positionOffset);
00101 
00103     virtual ItemVisual *getSceneInstance() = 0;
00104 
00106     void setMovement(Movement *movement);
00107 
00109     Movement *getMovement() const;
00110 
00117     void setMovementSuspendedScript(Script *script);
00118 
00120     virtual void setAnimHierarchy(AnimHierarchy *animHierarchy) = 0;
00121 
00123     virtual Common::Array<Common::Point> listExitPositions();
00124 
00125 protected:
00126     void printData() override;
00127 
00128     bool _enabled;
00129     int32 _characterIndex;
00130 
00131     Movement *_movement;
00132     Script *_movementSuspendedScript;
00133 };
00134 
00140 class ItemVisual : public Item {
00141 public:
00142     ItemVisual(Object *parent, byte subType, uint16 index, const Common::String &name);
00143     virtual ~ItemVisual();
00144 
00145     // Resource API
00146     virtual void readData(Formats::XRCReadStream *stream) override;
00147     virtual void onAllLoaded() override;
00148     virtual void saveLoad(ResourceSerializer *serializer) override;
00149     virtual void saveLoadCurrent(ResourceSerializer *serializer) override;
00150 
00151     // Item API
00152     void setEnabled(bool enabled) override;
00153     ItemVisual *getSceneInstance() override;
00154     void setAnimHierarchy(AnimHierarchy *animHierarchy) override;
00155 
00161     virtual void setPosition2D(const Common::Point &position);
00162 
00164     int getHotspotIndexForPoint(const Common::Point &point);
00165 
00167     Common::String getHotspotTitle(uint32 hotspotIndex);
00168 
00170     bool canPerformAction(uint32 action, uint32 hotspotIndex);
00171 
00173     bool doAction(uint32 action, uint32 hotspotIndex);
00174 
00176     void setAnimActivity(int32 activity);
00177 
00179     int32 getAnimActivity() const;
00180 
00182     Anim *getAnim() const;
00183 
00185     Anim *getActionAnim() const;
00186 
00188     void playActionAnim(Anim *anim);
00189 
00191     void resetActionAnim();
00192 
00193 protected:
00194     // Resource API
00195     void printData() override;
00196 
00198     Common::Array<Common::Point> listExitPositionsImpl();
00199 
00200     Visual *getVisual();
00201 
00202     Gfx::RenderEntry *_renderEntry;
00203 
00204     Anim *_actionAnim;
00205     AnimHierarchy *_animHierarchy;
00206     int32 _currentAnimActivity;
00207     bool _clickable;
00208 };
00209 
00215 class ItemTemplate : public Item {
00216 public:
00217     ItemTemplate(Object *parent, byte subType, uint16 index, const Common::String &name);
00218     virtual ~ItemTemplate();
00219 
00220     // Resource API
00221     void onAllLoaded() override;
00222     void onEnterLocation() override;
00223     void saveLoadCurrent(ResourceSerializer *serializer) override;
00224 
00225     // Item API
00226     ItemVisual *getSceneInstance() override;
00227     void setAnimHierarchy(AnimHierarchy *animHierarchy) override;
00228 
00230     virtual BonesMesh *findBonesMesh() = 0;
00231 
00233     virtual TextureSet *findTextureSet(uint32 textureType) = 0;
00234 
00236     virtual AnimHierarchy *findStockAnimHierarchy() = 0;
00237 
00239     void setStockAnimHierachy(AnimHierarchy *animHierarchy);
00240 
00242     void setBonesMesh(int32 index);
00243 
00245     void setTexture(int32 index, uint32 textureType);
00246 
00248     void setInstanciatedItem(Item *instance);
00249 
00250 protected:
00251     int32 _meshIndex;
00252     int32 _textureNormalIndex;
00253     int32 _textureFaceIndex;
00254     int32 _animHierarchyIndex;
00255 
00256     Item *_instanciatedItem;
00257     ItemTemplate *_referencedItem;
00258 };
00259 
00265 class GlobalItemTemplate : public ItemTemplate {
00266 public:
00267     GlobalItemTemplate(Object *parent, byte subType, uint16 index, const Common::String &name);
00268     virtual ~GlobalItemTemplate();
00269 
00270     // ItemTemplate API
00271     BonesMesh *findBonesMesh() override;
00272     TextureSet *findTextureSet(uint32 textureType) override;
00273     AnimHierarchy *findStockAnimHierarchy() override;
00274 
00275 protected:
00276 };
00277 
00281 class InventoryItem : public ItemVisual {
00282 public:
00283     InventoryItem(Object *parent, byte subType, uint16 index, const Common::String &name);
00284     virtual ~InventoryItem();
00285 
00286     // Item API
00287     Gfx::RenderEntry *getRenderEntry(const Common::Point &positionOffset) override;
00288     void setEnabled(bool enabled) override;
00289 
00291     Visual *getActionVisual(bool active) const;
00292 
00294     Visual *getCursorVisual() const;
00295 
00296 protected:
00297 };
00298 
00305 class LevelItemTemplate : public ItemTemplate {
00306 public:
00307     LevelItemTemplate(Object *parent, byte subType, uint16 index, const Common::String &name);
00308     virtual ~LevelItemTemplate();
00309 
00310     // Resource API
00311     void readData(Formats::XRCReadStream *stream) override;
00312     void onAllLoaded() override;
00313 
00314     // ItemTemplate API
00315     BonesMesh *findBonesMesh() override;
00316     TextureSet *findTextureSet(uint32 textureType) override;
00317     AnimHierarchy *findStockAnimHierarchy() override;
00318 
00320     ItemTemplate *getItemTemplate() const;
00321 
00322 protected:
00323     void printData() override;
00324 
00325     ResourceReference _reference;
00326 };
00327 
00334 class FloorPositionedItem : public ItemVisual {
00335 public:
00336     FloorPositionedItem(Object *parent, byte subType, uint16 index, const Common::String &name);
00337     virtual ~FloorPositionedItem();
00338 
00339     // Object API
00340     void saveLoad(ResourceSerializer *serializer) override;
00341 
00343     void placeOnBookmark(Bookmark *target);
00344 
00346     void placeDefaultPosition();
00347 
00349     Math::Vector3d getPosition3D() const;
00351     void setPosition3D(const Math::Vector3d &position);
00352 
00354     int32 getFloorFaceIndex() const;
00356     void setFloorFaceIndex(int32 faceIndex);
00357 
00359     Math::Vector3d getDirectionVector() const;
00360 
00362     void setDirection(const Math::Angle &direction);
00363 
00365     float getSortKey() const;
00366 
00372     void overrideSortKey(float sortKey);
00373 
00374 protected:
00375     int32 _floorFaceIndex;
00376     Math::Vector3d _position3D;
00377     float _direction3D;
00378 
00379     bool _sortKeyOverride;
00380     float _sortKeyOverridenValue;
00381 };
00382 
00388 class FloorPositionedImageItem : public FloorPositionedItem {
00389 public:
00390     FloorPositionedImageItem(Object *parent, byte subType, uint16 index, const Common::String &name);
00391     virtual ~FloorPositionedImageItem();
00392 
00393     // Resource API
00394     virtual void readData(Formats::XRCReadStream *stream) override;
00395 
00396     // Item API
00397     Gfx::RenderEntry *getRenderEntry(const Common::Point &positionOffset) override;
00398     Common::Array<Common::Point> listExitPositions() override;
00399 
00400     // ItemVisual API
00401     void setPosition2D(const Common::Point &position) override;
00402 
00403 protected:
00404     void printData() override;
00405 
00406     Common::Point _position;
00407 };
00408 
00414 class ModelItem : public FloorPositionedItem {
00415 public:
00416     ModelItem(Object *parent, byte subType, uint16 index, const Common::String &name);
00417     virtual ~ModelItem();
00418 
00419     // Resource API
00420     void readData(Formats::XRCReadStream *stream) override;
00421     void onAllLoaded() override;
00422     void onEnterLocation() override;
00423     void onExitLocation() override;
00424     void saveLoadCurrent(ResourceSerializer *serializer) override;
00425 
00426     // Item API
00427     Gfx::RenderEntry *getRenderEntry(const Common::Point &positionOffset) override;
00428 
00430     void setTexture(int32 index, uint32 textureType);
00431 
00433     void setBonesMesh(int32 index);
00434 
00436     BonesMesh *findBonesMesh();
00437 
00439     TextureSet *findTextureSet(uint32 textureType);
00440 
00442     ItemTemplate *getItemTemplate() const;
00443 
00445     void updateAnim();
00446 
00448     void resetAnimationBlending();
00449 
00451     Anim *getIdleActionAnim() const;
00452 
00453     AnimHandler *getAnimHandler() const;
00454 
00455 protected:
00456     void printData() override;
00457 
00458     int32 _meshIndex;
00459     int32 _textureNormalIndex;
00460     int32 _textureFaceIndex;
00461 
00462     ResourceReference _reference;
00463     ItemTemplate *_referencedItem;
00464 
00465     AnimHandler *_animHandler;
00466 };
00467 
00473 class ImageItem : public ItemVisual {
00474 public:
00475     ImageItem(Object *parent, byte subType, uint16 index, const Common::String &name);
00476     virtual ~ImageItem();
00477 
00478     // Resource API
00479     virtual void readData(Formats::XRCReadStream *stream) override;
00480 
00481     // Item API
00482     Gfx::RenderEntry *getRenderEntry(const Common::Point &positionOffset) override;
00483     Common::Array<Common::Point> listExitPositions() override;
00484 
00485     // ItemVisual API
00486     void setPosition2D(const Common::Point &position) override;
00487 
00488 protected:
00489     void printData() override;
00490 
00491     ResourceReference _reference;
00492     Common::Point _position;
00493 };
00494 
00495 } // End of namespace Resources
00496 } // End of namespace Stark
00497 
00498 #endif // STARK_RESOURCES_ITEM_H


Generated on Sat Nov 9 2019 05:00:31 for ResidualVM by doxygen 1.7.1
curved edge   curved edge