Esempio n. 1
0
/**
 * Show mouseover descriptions of disciplines and powers
 */
TooltipData MenuPowers::checkTooltip(const Point& mouse) {

	TooltipData tip;

	for (size_t i=0; i<power_cell.size(); i++) {

		if (tab_control && (tab_control->getActiveTab() != power_cell[i].tab)) continue;

		int cell_index = getCellByPowerIndex(power_cell[i].id, power_cell_all);
		if (!checkCellVisible(cell_index)) continue;

		if (slots[i] && isWithinRect(slots[i]->pos, mouse)) {
			bool base_unlocked = checkUnlocked(cell_index) || std::find(stats->powers_list.begin(), stats->powers_list.end(), power_cell[i].id) != stats->powers_list.end();

			createTooltip(&tip, static_cast<int>(i), power_cell, !base_unlocked);
			if (!power_cell[i].upgrades.empty()) {
				int next_level = getNextLevelCell(static_cast<int>(i));
				if (next_level != -1) {
					tip.addText("\n" + msg->get("Next Level:"));
					createTooltip(&tip, next_level, power_cell_upgrade, base_unlocked);
				}
			}

			return tip;
		}
	}

	return tip;
}
Esempio n. 2
0
bool Object::createSpeechTooltip(const Common::UString &line) {
	if (!createTooltip(Tooltip::kTypeSpeech))
		return false;

	_tooltip->clearLines();
	_tooltip->addLine(line, 1.0f, 1.0f, 1.0f, 1.0f);

	return true;
}
Esempio n. 3
0
bool Object::createFeedbackTooltip() {
	if (!createTooltip(Tooltip::kTypeFeedback))
		return false;

	_tooltip->clearLines();
	_tooltip->addLine(_name, 0.5f, 0.5f, 1.0f, 1.0f);

	return true;
}
Esempio n. 4
0
void MapRenderer::checkNearestEvent() {
	if (NO_MOUSE) show_tooltip = false;

	std::vector<Event>::iterator it;
	std::vector<Event>::iterator nearest = events.end();
	float best_distance = std::numeric_limits<float>::max();

	// loop in reverse because we may erase elements
	for (it = events.end(); it != events.begin(); ) {
		--it;

		// skip inactive events
		if (!EventManager::isActive(*it)) continue;

		// skip events without hotspots
		if ((*it).hotspot.h == 0) continue;

		// skip events on cooldown
		if ((*it).cooldown_ticks != 0) continue;

		float distance = calcDist(cam, (*it).center);
		if ((((*it).reachable_from.w == 0 && (*it).reachable_from.h == 0) || isWithin((*it).reachable_from, floor(cam)))
				&& distance < INTERACT_RANGE && distance < best_distance) {
			best_distance = distance;
			nearest = it;
		}

	}

	if (nearest != events.end()) {
		if (NO_MOUSE || TOUCHSCREEN) {
			// new tooltip?
			createTooltip((*nearest).getComponent("tooltip"));
			tip_pos = map_to_screen((*nearest).center.x, (*nearest).center.y, shakycam.x, shakycam.y);
			if ((*nearest).getComponent("npc_hotspot")) {
				tip_pos.y -= npc_tooltip_margin;
			}
			else {
				tip_pos.y -= TILE_H;
			}
		}

		if (inpt->pressing[ACCEPT] && !inpt->lock[ACCEPT]) {
			if (inpt->pressing[ACCEPT]) inpt->lock[ACCEPT] = true;

			if(EventManager::executeEvent(*nearest))
				events.erase(nearest);
		}
	}
}
void GraphicalTimetableLine::init()
{
    if ( !m_svg.hasElement("background") ) {
        setFailedToLaunch( true, i18n("No 'background' element found in the SVG") );
    }

    m_zoomInButton = new Plasma::ToolButton( this );
    m_zoomOutButton = new Plasma::ToolButton( this );
    m_zoomInButton->setIcon( KIcon("zoom-in") );
    m_zoomOutButton->setIcon( KIcon("zoom-out") );
    m_zoomInButton->setZValue( 999999 );
    m_zoomOutButton->setZValue( 999999 );
    connect( m_zoomInButton, SIGNAL(clicked()), this, SLOT(zoomIn()) );
    connect( m_zoomOutButton, SIGNAL(clicked()), this, SLOT(zoomOut()) );

    m_title = new Plasma::Label( this );
    QFont font = Plasma::Theme::defaultTheme()->font( Plasma::Theme::DefaultFont );
    font.setPixelSize( 14 );
    font.setBold( true );
    m_title->setFont( font );
    m_title->setWordWrap( false );
    m_title->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    m_title->setZValue( 999999 );

    m_courtesy = new Plasma::Label;
    m_courtesy->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
    connect( m_courtesy, SIGNAL(linkActivated(QString)),
                KToolInvocation::self(), SLOT(invokeBrowser(QString)) );
    QLabel *labelInfo = m_courtesy->nativeWidget();
    labelInfo->setOpenExternalLinks( true );
    labelInfo->setWordWrap( true );
    m_courtesy->setText( courtesyText() );
    m_courtesy->setZValue( 999999 );

    m_departureView = new QGraphicsWidget( this );
    m_departureView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    m_departureView->translate( 0, -m_title->size().height() - 25 );

    QGraphicsGridLayout *l = new QGraphicsGridLayout( this );
    l->addItem( m_zoomInButton, 0, 0 );
    l->addItem( m_zoomOutButton, 0, 1 );
    l->addItem( m_title, 0, 2 );
    l->addItem( m_departureView, 1, 0, 1, 3 );
    l->addItem( m_courtesy, 2, 0, 1, 3 );

    m_stopSettings.set( ServiceProviderSetting,
                        config().readEntry(QLatin1String("serviceProvider"), QString()) );
    m_stopSettings.set( StopNameSetting,
                        config().readEntry(QLatin1String("stopName"), QString()) );

    m_timelineLength = config().readEntry( QLatin1String("timelineLength"), 10 );
    m_showTimetable = config().readEntry( QLatin1String("showTimetable"), true );
    m_drawTransportLine = config().readEntry( QLatin1String("drawTransportLine"), true );

    QVariantList vehicleTypes = config().readEntry( QLatin1String("vehicleTypes"), QVariantList() );
    if ( vehicleTypes.isEmpty() ) {
        m_vehicleTypes << UnknownVehicleType << Tram << Bus << TrolleyBus << InterurbanTrain
                << Subway << Metro << RegionalTrain << RegionalExpressTrain << InterregionalTrain
                << IntercityTrain << HighSpeedTrain << Ship << Plane << Feet;
    } else {
        foreach ( const QVariant &vehicleType, vehicleTypes ) {
            m_vehicleTypes << static_cast<VehicleType>( vehicleType.toInt() );
        }
    }

    if ( m_stopSettings.stopList().isEmpty() ) {
        setConfigurationRequired( true, i18n("Please select a stop name") );
    } else if ( m_stopSettings.get<QString>(ServiceProviderSetting).isEmpty() ) {
        setConfigurationRequired( true, i18n("Please select a service provider") );
    } else {
        setConfigurationRequired( false );
    }

    if ( !configurationRequired() ) {
        m_sourceName = QString("Departures %1|stop=%2|timeoffset=0")
                    .arg(m_stopSettings.get<QString>(ServiceProviderSetting))
                    .arg(m_stopSettings.stop(0).nameOrId());
        dataEngine("publictransport")->connectSource( m_sourceName,
                this, 60000, Plasma::AlignToMinute );
    }

    createTooltip();
}
Esempio n. 6
0
/**
 * Some events have a hotspot (rectangle screen area) where the user can click
 * to trigger the event.
 *
 * The hero must be within range (INTERACT_RANGE) to activate an event.
 *
 * This function checks valid mouse clicks against all clickable events, and
 * executes
 */
void MapRenderer::checkHotspots() {
	if (NO_MOUSE) return;

	show_tooltip = false;

	std::vector<Event>::iterator it;

	// work backwards through events because events can be erased in the loop.
	// this prevents the iterator from becoming invalid.
	for (it = events.end(); it != events.begin(); ) {
		--it;

		for (int x=it->hotspot.x; x < it->hotspot.x + it->hotspot.w; ++x) {
			for (int y=it->hotspot.y; y < it->hotspot.y + it->hotspot.h; ++y) {
				bool matched = false;
				bool is_npc = false;

				Event_Component* npc = (*it).getComponent("npc_hotspot");
				if (npc) {
					is_npc = true;

					Point p = map_to_screen(float(npc->x), float(npc->y), shakycam.x, shakycam.y);
					p = center_tile(p);

					Rect dest;
					dest.x = p.x - npc->z;
					dest.y = p.y - npc->a;
					dest.w = npc->b;
					dest.h = npc->c;

					if (isWithin(dest, inpt->mouse)) {
						matched = true;
						tip_pos.x = dest.x + dest.w/2;
						tip_pos.y = p.y - npc_tooltip_margin;
					}
				}
				else {
					for (unsigned index = 0; index <= index_objectlayer; ++index) {
						maprow *current_layer = layers[index];
						Point p = map_to_screen(float(x), float(y), shakycam.x, shakycam.y);
						p = center_tile(p);

						if (const short current_tile = current_layer[x][y]) {
							// first check if mouse pointer is in rectangle of that tile:
							Rect dest;
							dest.x = p.x - tset.tiles[current_tile].offset.x;
							dest.y = p.y - tset.tiles[current_tile].offset.y;
							dest.w = tset.tiles[current_tile].tile->getClip().w;
							dest.h = tset.tiles[current_tile].tile->getClip().h;

							if (isWithin(dest, inpt->mouse)) {
								matched = true;
								tip_pos = map_to_screen(it->center.x, it->center.y, shakycam.x, shakycam.y);
								tip_pos.y -= TILE_H;
							}
						}
					}
				}

				if (matched) {
					// skip inactive events
					if (!EventManager::isActive(*it)) continue;

					// skip events without hotspots
					if ((*it).hotspot.h == 0) continue;

					// skip events on cooldown
					if ((*it).cooldown_ticks != 0) continue;

					// new tooltip?
					createTooltip((*it).getComponent("tooltip"));

					if ((((*it).reachable_from.w == 0 && (*it).reachable_from.h == 0) || isWithin((*it).reachable_from, floor(cam)))
							&& calcDist(cam, (*it).center) < INTERACT_RANGE) {

						// only check events if the player is clicking
						// and allowed to click
						if (is_npc) {
							curs->setCursor(CURSOR_TALK);
						}
						else {
							curs->setCursor(CURSOR_INTERACT);
						}
						if (!inpt->pressing[MAIN1]) return;
						else if (inpt->lock[MAIN1]) return;

						inpt->lock[MAIN1] = true;
						if (EventManager::executeEvent(*it))
							it = events.erase(it);
					}
					return;
				}
				else show_tooltip = false;
			}
		}
	}
}
Esempio n. 7
0
void NWNWidget::setTooltipPosition(float x, float y, float z) {
	createTooltip();

	_tooltip->setPosition(x, y, z);
}
Esempio n. 8
0
void NWNWidget::setTooltip(const Common::UString &text) {
	createTooltip();

	_tooltip->clearLines();
	_tooltip->addLine(text, 1.0, 1.0, 1.0, 1.0);
}
Esempio n. 9
0
void Placeable::showTooltip() {
	createTooltip();
	_tooltip->show();
}