Esempio n. 1
0
bool SceneComponent::keyPressed (const KeyPress &key, Component *originatingComponent)
{
    if (key == KeyPress::downKey || key == KeyPress::rightKey)
    {
        selectSlot(-1);
        return true;
    }
    else if (key == KeyPress::upKey || key == KeyPress::leftKey)
    {
        selectSlot(-2);
        return true;
    }
    else
        return false; //incase the keypress is a shortcut that the parent needs to react to.
}
Esempio n. 2
0
void Inventory::update(const sf::Time& frameTime) {
	if (!m_isVisible) return;

	// check whether an item was selected
	for (auto& it : *(m_typeMap.at(m_currentTab))) {
		it.second.update(frameTime);
		if (it.second.isClicked()) {
			selectSlot(it.second.getItemID(), ItemType::VOID);
			return;
		}
		if (it.second.isRightClicked()) {
			handleLevelRightClick(&it.second);
			handleMapRightClick(&it.second);
			break;
		}
	}

	for (auto& it : m_tabs) {
		it.first.update(frameTime);
		if (it.first.isClicked() && m_currentTab != it.second) {
			selectTab(it.second);
			return;
		}
	}

	// update equipment part
	m_equipment->update(frameTime);
	InventorySlot* eqSlot = m_equipment->getSelectedSlot();
	if (eqSlot != nullptr) {
		selectSlot(eqSlot->getItemID(), eqSlot->getItemType());
	}

	handleDragAndDrop();

	if (m_equipment->requiresReload()) {
		reload();
	}
}
Esempio n. 3
0
void ConnectDialog::setSignalSlot(const QString &signal, const QString &slot)
{
    ListWidgetItems sigItems = m_ui.signalList->findItems(signal, Qt::MatchExactly);

    if (sigItems.empty()) {
        m_ui.showAllCheckBox->setChecked(true);
        sigItems = m_ui.signalList->findItems(signal, Qt::MatchExactly);
    }

    if (!sigItems.empty()) {
        selectSignal(sigItems.front());
        ListWidgetItems slotItems = m_ui.slotList->findItems(slot, Qt::MatchExactly);
        if (slotItems.empty()) {
            m_ui.showAllCheckBox->setChecked(true);
            slotItems = m_ui.slotList->findItems(slot, Qt::MatchExactly);
        }
        if (!slotItems.empty())
            selectSlot(slotItems.front());
    }
}
Esempio n. 4
0
bool TankEngine::storeTSRS ( const TSRSExt&  pTsrs  )
{
	if(testTankCID (  pTsrs )&& testFillOrderAndSection ( pTsrs )&& testRack(pTsrs ) && testSlot(pTsrs))
	{
	  sli.initialize();

	  if( setTankExt(pTsrs ) )
	  {
//		if( setFillOrderAndSection( pTsrs.fillOrder, pTsrs.section ))
		if( setFillOrderAndSection( pTsrs ))
		{
		  if( setRack(pTsrs.rack ))
		  {
			if( setSlot(pTsrs.slot))
			{
			  selectSlot(pTsrs );
			  return true;
			}else
			{
			  sli.initialize();
			  return false;
			}

		  }else
		  {
			sli.initialize();
			return false;
		  }
		}else
		{
		  sli.initialize();
		  return false;
		}
	  }else
	  {
		sli.initialize();
		return false;
	  }
	}
	return false;
}
Esempio n. 5
0
bool SkColorPalette::onClick(SkView::Click* click) {
    SkPoint curr = click->fCurr;
    //SkDebugf("click %f %f \n", curr.fX, curr.fY);
    int selected = selectSlot(curr);
    if (selected >= 0) {
        switch (click->fState) {
            case SkView::Click::kDown_State:
            case SkView::Click::kMoved_State:
            case SkView::Click::kUp_State:
                fSelected = selected;
                fCurrColor = fColors[fSelected];
                break;
            default:
                break;
        }
        return true;
    }
    else{
        //account for padding
        curr.fX -= PalettePadding;
        curr.fY -= 2 * PalettePadding + (fSlotRect.height() + PalettePadding) * PaletteSlots;
        if (curr.fX < 0 || curr.fX > fGradientRect.width() ||
            curr.fY < 0 || curr.fY > fGradientRect.height()) {
            return false;
        }
        else {
            switch (click->fState) {
                case SkView::Click::kDown_State:
                case SkView::Click::kMoved_State:
                case SkView::Click::kUp_State:
                    fColors[fSelected] = selectColorFromGradient(curr);
                    fCurrColor = fColors[fSelected];
                    break;
                default:
                    break;
            }
            return true;
        }
    }
}
Esempio n. 6
0
int AgiEngine::loadGameDialog() {
	int rc, slot = 0;
	int hm, vm, hp, vp;	// box margins
	int w;

	hm = 1;
	vm = 3;
	hp = hm * CHAR_COLS;
	vp = vm * CHAR_LINES;
	w = (40 - 2 * hm) - 1;

	_sprites->eraseBoth();
	_sound->stopSound();

	drawWindow(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
	printText("Select a game which you wish to\nrestore:",
			0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOR);

	slot = selectSlot();

	if (slot < 0) {
		if (slot == -1) // slot = -2 when GMM was launched
			messageBox("Game NOT restored.");

		return errOK;
	}

	Common::String fileName = getSavegameFilename(_firstSlot + slot);

	if ((rc = loadGame(fileName)) == errOK) {
		messageBox("Game restored.");
		_game.exitAllLogics = 1;
		_menu->enableAll();
	} else {
		messageBox("Error restoring game.");
	}

	return rc;
}
Esempio n. 7
0
/**
 * Read Flash manufacturer and device IDs, print then on the screen.
 * If they are not okay, print an error message and return 0.
 * If everything is okay, return 1.
 */
uint8_t checkFlashType(void)
{
    uint8_t* pDriver;
    uint8_t  bDriverFound = 0;

    pDriver = aEAPIDrivers[0];
    while (*pDriver)
    {
        memcpy(EAPI_LOAD_TO, pDriver, EAPI_SIZE);

        nBanks = eapiInit(&nManufacturerId, &nDeviceId);
        if (nBanks > 0)
        {
            bDriverFound = 1;
            break;
        }

        /* if we are here, there is an error */
        switch (nDeviceId)
        {
        case EAPI_ERR_RAM:
            screenPrintSimpleDialog(apStrBadRAM);
            goto failed;

        case EAPI_ERR_ROML_PROTECTED:
            screenPrintSimpleDialog(apStrROMLProtected);
            goto failed;

        case EAPI_ERR_ROMH_PROTECTED:
            screenPrintSimpleDialog(apStrROMHProtected);
            goto failed;
        }
        pDriver += EAPI_SIZE;
    }

    if (bDriverFound)
    {
        pStrFlashDriver = EAPI_DRIVER_NAME;
        nSlots = 1;
        if (nBanks < 64)
        {
            nSlots = nBanks;
            nBanks = 64;
        }
        updateMemSizeText();
        refreshMainScreen();
        if (nSlots > 1)
            selectSlot(nSlots);
        return 1;
    }
    else
    {
        screenPrintSimpleDialog(apStrWrongFlash);
    }

failed:
    pStrFlashDriver = "(failed)";
    refreshMainScreen();
    nManufacturerId = nDeviceId = 0;
    return 0;
}
Esempio n. 8
0
int AgiEngine::saveGameDialog() {
	char *desc;
	const char *buttons[] = { "Do as I say!", "I regret", NULL };
	char dstr[200];
	int rc, slot = 0;
	int hm, vm, hp, vp;
	int w;

	hm = 1;
	vm = 3;
	hp = hm * CHAR_COLS;
	vp = vm * CHAR_LINES;
	w = (40 - 2 * hm) - 1;

	do {
		drawWindow(hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
		printText("Select a slot in which you wish to\nsave the game:",
				0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOR);
		slot = selectSlot();
		if (slot + _firstSlot == 0)
			messageBox("That slot is for Autosave only.");
		else if (slot < 0)
			return errOK;
	} while (slot + _firstSlot == 0);

	drawWindow(hp, vp + 5 * CHAR_LINES, GFX_WIDTH - hp,
			GFX_HEIGHT - vp - 9 * CHAR_LINES);
	printText("Enter a description for this game:",
			0, hm + 1, vm + 6, w, MSG_BOX_TEXT, MSG_BOX_COLOR);
	_gfx->drawRectangle(3 * CHAR_COLS, 11 * CHAR_LINES - 1,
			37 * CHAR_COLS, 12 * CHAR_LINES, MSG_BOX_TEXT);
	_gfx->flushBlock(3 * CHAR_COLS, 11 * CHAR_LINES - 1,
			37 * CHAR_COLS, 12 * CHAR_LINES);

	// The description field of the save/restore dialog holds 32 characters
	// but we use four of them for the slot number. The input field is a
	// bit wider than that, so we don't have to worry about leaving space
	// for the cursor.

	getString(2, 11, 28, MAX_STRINGS);

	// If we're saving over an old slot, show the old description. We can't
	// access that buffer directly, so we have to feed the characters to
	// the input handler one at a time.

	char name[40];
	int numChars;

	getSavegameDescription(_firstSlot + slot, name, false);

	for (numChars = 0; numChars < 28 && name[numChars]; numChars++)
		handleGetstring(name[numChars]);

	_gfx->printCharacter(numChars + 3, 11, _game.cursorChar, MSG_BOX_COLOR, MSG_BOX_TEXT);
	do {
		mainCycle();
	} while (_game.inputMode == INPUT_GETSTRING);
	closeWindow();

	desc = _game.strings[MAX_STRINGS];
	sprintf(dstr, "Are you sure you want to save the game "
			"described as:\n\n%s\n\nin slot %d?\n\n\n", desc, _firstSlot + slot);

	rc = selectionBox(dstr, buttons);

	if (rc != 0) {
		messageBox("Game NOT saved.");
		return errOK;
	}

	Common::String fileName = getSavegameFilename(_firstSlot + slot);
	debugC(8, kDebugLevelMain | kDebugLevelResources, "file is [%s]", fileName.c_str());

	// Make sure all graphics was blitted to screen. This fixes bug
	// #2960567: "AGI: Ego partly erased in Load/Save thumbnails"
	_gfx->doUpdate();

	int result = saveGame(fileName, desc);

	if (result == errOK)
		messageBox("Game saved.");
	else
		messageBox("Error saving game.");

	return result;
}