Esempio n. 1
0
void MainWindow::userLogged(HUser* usr,QSqlDatabase pdb)
{
    user=usr;
    db=pdb;

    if(usr)
    {


        bool b=db.isOpen();
        qDebug()<<"userLogged Main"<<QString::number(b);
        enableButtonsForRole();
        checkNotifications();
    }
}
Esempio n. 2
0
/**
 * Process all actions for a single frame
 * This includes some message passing between child object
 */
void GameStatePlay::logic() {
	if (inpt->window_resized)
		refreshWidgets();

	checkCutscene();

	// check menus first (top layer gets mouse click priority)
	menu->logic();

	if (!isPaused()) {

		// these actions only occur when the game isn't paused
		if (pc->stats.alive) checkLoot();
		checkEnemyFocus();
		if (pc->stats.alive) {
			mapr->checkHotspots();
			mapr->checkNearestEvent();
			checkNPCInteraction();
		}
		checkTitle();

		menu->act->checkAction(action_queue);
		pc->logic(action_queue, restrictPowerUse(), npc_id != -1);

		// Transform powers change the actionbar layout,
		// so we need to prevent accidental clicks if a new power is placed under the slot we clicked on.
		// It's a bit hacky, but it works
		if (pc->isTransforming()) {
			menu->act->resetSlots();
		}

		// transfer hero data to enemies, for AI use
		if (pc->stats.get(STAT_STEALTH) > 100) enemies->hero_stealth = 100;
		else enemies->hero_stealth = pc->stats.get(STAT_STEALTH);

		enemies->logic();
		hazards->logic();
		loot->logic();
		enemies->checkEnemiesforXP();
		npcs->logic();

		snd->logic(pc->stats.pos);

		comb->logic(mapr->cam);
	}

	// close menus when the player dies, but still allow them to be reopened
	if (pc->close_menus) {
		pc->close_menus = false;
		menu->closeAll();
	}

	// these actions occur whether the game is paused or not.
	checkTeleport();
	checkLootDrop();
	checkLog();
	checkBook();
	checkEquipmentChange();
	checkUsedItems();
	checkStash();
	checkSaveEvent();
	checkNotifications();
	checkCancel();

	mapr->logic();
	mapr->enemies_cleared = enemies->isCleared();
	quests->logic();

	pc->checkTransform();

	// change hero powers on transformation
	if (pc->setPowers) {
		pc->setPowers = false;
		if (!pc->stats.humanoid && menu->pow->visible) menu->closeRight();
		// save ActionBar state and lock slots from removing/replacing power
		for (int i=0; i<ACTIONBAR_MAX ; i++) {
			menu->act->hotkeys_temp[i] = menu->act->hotkeys[i];
			menu->act->hotkeys[i] = 0;
		}
		int count = ACTIONBAR_MAIN;
		// put creature powers on action bar
		// TODO What if creature has more powers than the size of the action bar?
		for (size_t i=0; i<pc->charmed_stats->powers_ai.size(); i++) {
			if (pc->charmed_stats->powers_ai[i].id != 0 && powers->powers[pc->charmed_stats->powers_ai[i].id].beacon != true) {
				menu->act->hotkeys[count] = pc->charmed_stats->powers_ai[i].id;
				menu->act->locked[count] = true;
				count++;
			}
			if (count == ACTIONBAR_MAX) count = 0;
		}
		if (pc->stats.manual_untransform && pc->untransform_power > 0) {
			menu->act->hotkeys[count] = pc->untransform_power;
			menu->act->locked[count] = true;
		}
		else if (pc->stats.manual_untransform && pc->untransform_power == 0)
			logError("GameStatePlay: Untransform power not found, you can't untransform manually");

		menu->act->updated = true;

		// reapply equipment if the transformation allows it
		if (pc->stats.transform_with_equipment)
			menu->inv->applyEquipment(menu->inv->inventory[EQUIPMENT].storage);
	}
	// revert hero powers
	if (pc->revertPowers) {
		pc->revertPowers = false;

		// restore ActionBar state
		for (int i=0; i<ACTIONBAR_MAX; i++) {
			menu->act->hotkeys[i] = menu->act->hotkeys_temp[i];
			menu->act->locked[i] = false;
		}

		menu->act->updated = true;

		// also reapply equipment here, to account items that give bonuses to base stats
		menu->inv->applyEquipment(menu->inv->inventory[EQUIPMENT].storage);
	}

	// when the hero (re)spawns, reapply equipment & passive effects
	if (pc->respawn) {
		pc->stats.alive = true;
		pc->stats.corpse = false;
		pc->stats.cur_state = AVATAR_STANCE;
		menu->inv->applyEquipment(menu->inv->inventory[EQUIPMENT].storage);
		menu->inv->changed_equipment = true;
		checkEquipmentChange();
		powers->activatePassives(&pc->stats);
		pc->stats.logic();
		pc->stats.recalc();
		pc->respawn = false;
	}

	// use a normal mouse cursor is menus are open
	if (menu->menus_open) {
		curs->setCursor(CURSOR_NORMAL);
	}

	// update the action bar as it may have been changed by items
	if (menu->act->updated) {
		menu->act->updated = false;

		// set all hotkeys to their base powers
		for (unsigned i = 0; i < menu->act->slots_count; i++) {
			menu->act->hotkeys_mod[i] = menu->act->hotkeys[i];
		}

		updateActionBar();
	}

	// reload music if changed in the pause menu
	if (menu->exit->reload_music) {
		mapr->loadMusic();
		menu->exit->reload_music = false;
	}
}
Esempio n. 3
0
void Box::update(Events gameEvents)
{
    // ------------------------------- ACTIVE -------------------------------
    if(body->IsActive())
    {
        // Update UserData
        body->SetUserData(this);

        // ------------------------------- Dynamic only -------------------------------
        if(body->GetType() == b2_dynamicBody)
        {
            sprite.setPosition(body->GetPosition().x * SCALE, body->GetPosition().y * SCALE);
            sprite.setRotation(180/b2_pi * body->GetAngle());
            overlaySprite.setPosition(body->GetPosition().x * SCALE, body->GetPosition().y * SCALE);
            overlaySprite.setRotation(180/b2_pi * body->GetAngle());

            lastMouse.x = gameEvents.lastMouse.x;
            lastMouse.y = gameEvents.lastMouse.y;

            // Movement
            moveToTargetArea();

            // AI
            ai();

            // Atack
            attack();
        }
        else // ------------------------------- Static only -------------------------------
        {
            ai();
            attack();
            checkNotifications();
            checkForConversion();
        }
        // ------------------------------- Both -------------------------------
        processImpulse();

        // Deletes boxes that have fallen out of the world
        checkHeight();

        // MouseOver
        if(isSelected(gameEvents.lastMouse.x, gameEvents.lastMouse.y))
        {
            isInfo = true;
            sprite.setColor(sf::Color(120, 120, 120, 255));
        }
        else
        {
            isInfo = false;
            sprite.setColor(sf::Color(255, 255, 255, 255));
        }
    }
    else // ------------------------------- INACTIVE -------------------------------
    {
        if(body->GetType() == b2_staticBody)
        {
            checkNotifications();

            if(isSelected(gameEvents.lastMouse.x, gameEvents.lastMouse.y))
            {
                sprite.setColor(sf::Color(120, 120, 120, 255));
            }
            else
            {
                sprite.setColor(sf::Color(200, 200, 200, 255));
            }
        }
    }

    // ------------------------------- Independant of active status -------------------------------
    // Check for minimap
//    float percX = gameEvents.lastMouseWindow.x / window_width;
//    float percY = gameEvents.lastMouseWindow.y / window_height;
//
//    if(percX >= 0.0f && percX <= minimapSize && percY >= 1.0f - minimapSize && percY <= 1.0f)
//    {
//        sprite.setColor(sf::Color(255, 255, 255, 255));
//    }

    // Flicker as long as the timer is active
    if(!hitTimer.timeReached())
    {
        sprite.setColor(sf::Color::Red);
    }

    // Update timer
    hitTimer.update();
    hitNumberTimer.update();
}
Esempio n. 4
0
void MainWindow::on_pbCkeckNotifications_clicked()
{
     checkNotifications();
}