void gsGame::extractClickables(json clickables) {
	for (auto clickable : clickables) {
		json area = clickable["area"];
		Clickable clickArea;

		if (area.is_array()) {
			clickArea.setBounds(area[0], area[1], area[2], area[3]);
		} else if (area.is_string()) {
			SDL_Rect bounds = directionRects[area.get<std::string>()];
			clickArea.setBounds(bounds.x, bounds.y, bounds.w, bounds.h);
			directions[area.get<std::string>()] = "turnmeon";
		} else {
			NNB_ERROR << "\"" << area << "\" is not a string nor an array!";
		}

		if (clickable.find("condition") != clickable.end()) {
			clickArea.condition = clickable["condition"].get<std::string>();
		}

		if (clickable.find("actions") != clickable.end()) {
			clickArea.actions = clickable["actions"].get<std::vector<std::string>>();
		}

		if (clickable.find("elseActions") != clickable.end()) {
			clickArea.elseActions = clickable["elseActions"].get<std::vector<std::string>>();
		}

		clickAreas.push_back(clickArea);
	}
}
void StyledLabel::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton) {
        Clickable click = _clickables.atCursorPos(posToCursor(event->posF()));
        if (click.isValid())
            emit clickableActivated(click);
    }
}
void StyledLabel::mouseMoveEvent(QMouseEvent *event)
{
    if (event->buttons() == Qt::NoButton) {
        Clickable click = _clickables.atCursorPos(posToCursor(event->posF()));
        if (click.isValid())
            setHoverMode(click.start(), click.length());
        else
            endHoverMode();
    }
}
Beispiel #4
0
void TopicWidget::clickableActivated(const Clickable &click)
{
    NetworkId networkId = selectionModel()->currentIndex().data(NetworkModel::NetworkIdRole).value<NetworkId>();
    UiStyle::StyledString sstr = GraphicalUi::uiStyle()->styleString(GraphicalUi::uiStyle()->mircToInternal(_topic), UiStyle::PlainMsg);
    click.activate(networkId, sstr.plainText);
}
void TopicWidget::clickableActivated(const Clickable &click) {
  NetworkId networkId = selectionModel()->currentIndex().data(NetworkModel::NetworkIdRole).value<NetworkId>();
  click.activate(networkId, _topic);
}
Beispiel #6
0
void DrawClickable( Clickable& clickable, NimblePixMap& map, int x, int y ) {
	Assert( ClickableSetEnd<&ClickableSet[ClickableSetMaxSize]);
    *ClickableSetEnd++ = &clickable;
	clickable.drawOn(map,x,y);
}