mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-15 00:27:31 +00:00
TWP: Add hotspot marker
This commit is contained in:
parent
16ef14aaeb
commit
4f88b8e026
@ -40,7 +40,8 @@ enum TwpAction {
|
||||
kSelectChoice6,
|
||||
kSelectPreviousActor,
|
||||
kSelectNextActor,
|
||||
kSkipText
|
||||
kSkipText,
|
||||
kShowHotspots
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -187,6 +187,7 @@ Common::Array<Common::Keymap *> TwpMetaEngine::initKeymaps(const char *target) c
|
||||
{"SELECTNEXTACTOR", _("Select Next Actor"), Twp::kSelectNextActor, "0"},
|
||||
{"SELECTPREVACTOR", _("Select Previous Actor"), Twp::kSelectPreviousActor, "9"},
|
||||
{"SKIPTEXT", _("Skip Text"), Twp::kSkipText, "."},
|
||||
{"SHOWHOTSPOTS", _("Show hotspots"), Twp::kShowHotspots, "TAB"},
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(actions); i++) {
|
||||
|
@ -718,4 +718,36 @@ bool NoOverrideNode::update(float elapsed) {
|
||||
return true;
|
||||
}
|
||||
|
||||
HotspotMarkerNode::HotspotMarkerNode() : Node("HotspotMarker") {
|
||||
_zOrder = -1000;
|
||||
_visible = false;
|
||||
}
|
||||
|
||||
HotspotMarkerNode::~HotspotMarkerNode() {}
|
||||
|
||||
void HotspotMarkerNode::drawSprite(const SpriteSheetFrame &sf, Texture *texture, Color color, Math::Matrix4 trsf) {
|
||||
Math::Vector3d pos(sf.spriteSourceSize.left - sf.sourceSize.getX() / 2.f, -sf.spriteSourceSize.height() - sf.spriteSourceSize.top + sf.sourceSize.getY() / 2.f, 0.f);
|
||||
trsf.translate(pos);
|
||||
g_engine->getGfx().drawSprite(sf.frame, *texture, color, trsf);
|
||||
}
|
||||
|
||||
void HotspotMarkerNode::drawCore(Math::Matrix4 trsf) {
|
||||
SpriteSheet *gameSheet = g_engine->_resManager.spriteSheet("GameSheet");
|
||||
Texture *texture = g_engine->_resManager.texture(gameSheet->meta.image);
|
||||
SpriteSheetFrame *frame = &gameSheet->frameTable["hotspot_marker"];
|
||||
Color color = Color::create(255, 165, 0);
|
||||
for (int i = 0; i < g_engine->_room->_layers.size(); i++) {
|
||||
Layer *layer = g_engine->_room->_layers[i];
|
||||
for (int j = 0; j < layer->_objects.size(); j++) {
|
||||
Object *obj = layer->_objects[j];
|
||||
if (isObject(obj->getId()) && (obj->_objType == otNone) && obj->isTouchable()) {
|
||||
Math::Vector2d pos = g_engine->roomToScreen(obj->_node->getAbsPos());
|
||||
Math::Matrix4 t;
|
||||
t.translate(Math::Vector3d(pos.getX(), pos.getY(), 0.f));
|
||||
drawSprite(*frame, texture, color, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Twp
|
||||
|
@ -353,6 +353,16 @@ private:
|
||||
float _elapsed = 0.f;
|
||||
};
|
||||
|
||||
class HotspotMarkerNode: public Node {
|
||||
public:
|
||||
HotspotMarkerNode();
|
||||
virtual ~HotspotMarkerNode();
|
||||
|
||||
private:
|
||||
void drawSprite(const SpriteSheetFrame& sf, Texture* texture, Color color, Math::Matrix4 trsf);
|
||||
void drawCore(Math::Matrix4 trsf) override final;
|
||||
};
|
||||
|
||||
} // End of namespace Twp
|
||||
|
||||
#endif
|
||||
|
@ -63,6 +63,7 @@ TwpEngine::TwpEngine(OSystem *syst, const ADGameDescription *gameDesc)
|
||||
_screenScene.setName("Screen");
|
||||
// _scene.addChild(&_walkboxNode);
|
||||
// _screenScene.addChild(&_pathNode);
|
||||
_screenScene.addChild(&_hotspotMarker);
|
||||
_screenScene.addChild(&_inputState);
|
||||
_screenScene.addChild(&_sentence);
|
||||
_screenScene.addChild(&_dialog);
|
||||
@ -735,9 +736,12 @@ Common::Error TwpEngine::run() {
|
||||
case TwpAction::kSelectChoice6:
|
||||
if (_dialog.getState() == DialogState::None) {
|
||||
int index = (TwpAction)e.customType - kSelectChoice1;
|
||||
g_engine->_dialog.choose(index);
|
||||
_dialog.choose(index);
|
||||
}
|
||||
break;
|
||||
case TwpAction::kShowHotspots:
|
||||
_hotspotMarker.setVisible(!_hotspotMarker.isVisible());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
|
@ -215,6 +215,7 @@ public:
|
||||
AudioSystem _audio;
|
||||
SaveGameManager _saveGameManager;
|
||||
ShaderParams _shaderParams;
|
||||
HotspotMarkerNode _hotspotMarker;
|
||||
|
||||
private:
|
||||
Gfx _gfx;
|
||||
|
Loading…
x
Reference in New Issue
Block a user