コード例 #1
0
ファイル: SamplesGame.cpp プロジェクト: Divoo/GamePlay
void SamplesGame::initialize()
{
    _font = Font::create("res/ui/arial.gpb");

    for (size_t i = 0; i < _categories->size(); ++i)
    {
        std::sort((*_samples)[i].begin(), (*_samples)[i].end());
    }

    // Load camera script
    getScriptController()->loadScript("res/common/camera.lua");

    // Create the selection form
    _sampleSelectForm = Form::create("sampleSelect", NULL, Layout::LAYOUT_VERTICAL);
    _sampleSelectForm->setWidth(200);
    _sampleSelectForm->setAutoHeight(Control::AUTO_SIZE_STRETCH);
    _sampleSelectForm->setScroll(Container::SCROLL_VERTICAL);
    const size_t size = _samples->size();
    for (size_t i = 0; i < size; ++i)
    {
		Label* categoryLabel = Label::create((*_categories)[i].c_str());
        categoryLabel->setAutoWidth(Control::AUTO_SIZE_FIT);
        categoryLabel->setAutoHeight(Control::AUTO_SIZE_FIT);
        categoryLabel->setFontSize(22);
        categoryLabel->setText((*_categories)[i].c_str());
        _sampleSelectForm->addControl(categoryLabel);
        categoryLabel->release();

        SampleRecordList list = (*_samples)[i];
        const size_t listSize = list.size();
        for (size_t j = 0; j < listSize; ++j)
        {
            SampleRecord sampleRecord = list[j];
			Button* sampleButton = Button::create(sampleRecord.title.c_str());
            sampleButton->setText(sampleRecord.title.c_str());
            sampleButton->setAutoWidth(Control::AUTO_SIZE_STRETCH);
            sampleButton->setHeight(50);
            sampleButton->addListener(this, Control::Listener::CLICK);
            _sampleSelectForm->addControl(sampleButton);
            sampleButton->release();
        }
    }
    _sampleSelectForm->setFocus();

    // Disable virtual gamepads.
    unsigned int gamepadCount = getGamepadCount();

    for (unsigned int i = 0; i < gamepadCount; i++)
    {
        Gamepad* gamepad = getGamepad(i, false);
        if (gamepad->isVirtual())
        {
            gamepad->getForm()->setEnabled(false);
        }
    }
}
コード例 #2
0
void SamplesGame::controlEvent(Control* control, EventType evt)
{
    const size_t size = _samples->size();
    for (size_t i = 0; i < size; ++i)
    {
        SampleRecordList list = (*_samples)[i];
        const size_t listSize = list.size();
        for (size_t j = 0; j < listSize; ++j)
        {
            SampleRecord sampleRecord = list[j];
            if (sampleRecord.title.compare(control->getId()) == 0)
            {
                _sampleSelectForm->setEnabled(false);
                runSample(sampleRecord.funcPtr);
                return;
            }
        }
    }
}
コード例 #3
0
void SamplesGame::initialize()
{
	LOGI(">SamplesGame::initialize ()");
	LOGI(">SamplesGame::initialize FileSystem::getAssetPath() = '%s'", FileSystem::getAssetPath());
	LOGI(">SamplesGame::initialize FileSystem::getResourcePath() = '%s'", FileSystem::getResourcePath());

	Bundle* bundle = Bundle::create("res/ui/arial.gpb");
	LOGI(">SamplesGame::initialize bundle=%p", bundle);

	_font = bundle->loadFont(bundle->getObjectId(0));
	LOGI(">SamplesGame::initialize _font=%p", _font);

    _font = Font::create("res/ui/arial.gpb");
    LOGI(">SamplesGame::initialize _font=%p", _font);

    for (size_t i = 0; i < _categories->size(); ++i)
    {
        std::sort((*_samples)[i].begin(), (*_samples)[i].end());
    }

    // Load camera script
    getScriptController()->loadScript("res/common/camera.lua");

    // Create the selection form
    _sampleSelectForm = Form::create("sampleSelect", NULL, Layout::LAYOUT_VERTICAL);
    _sampleSelectForm->setWidth(220);
    _sampleSelectForm->setHeight(1, true);
    _sampleSelectForm->setScroll(Container::SCROLL_VERTICAL);
    const size_t size = _samples->size();
    LOGI(">SamplesGame::initialize _samples->size()=%d", size);

    for (size_t i = 0; i < size; ++i)
    {
		Label* categoryLabel = Label::create((*_categories)[i].c_str());
        categoryLabel->setFontSize(22);
        categoryLabel->setText((*_categories)[i].c_str());
        _sampleSelectForm->addControl(categoryLabel);
        categoryLabel->release();

        SampleRecordList list = (*_samples)[i];
        const size_t listSize = list.size();
        for (size_t j = 0; j < listSize; ++j)
        {
            SampleRecord sampleRecord = list[j];
			Button* sampleButton = Button::create(sampleRecord.title.c_str());
            sampleButton->setText(sampleRecord.title.c_str());
            sampleButton->setWidth(1, true);
            sampleButton->setHeight(50);
            sampleButton->addListener(this, Control::Listener::CLICK);
            _sampleSelectForm->addControl(sampleButton);
            sampleButton->release();
        }
    }
    _sampleSelectForm->setFocus();

    // Disable virtual gamepads.
    unsigned int gamepadCount = getGamepadCount();

    for (unsigned int i = 0; i < gamepadCount; i++)
    {
        Gamepad* gamepad = getGamepad(i, false);
        if (gamepad->isVirtual())
        {
            gamepad->getForm()->setEnabled(false);
        }
    }

    /*
    for (size_t i = 0; i < size; ++i)
    {
        SampleRecordList list = (*_samples)[i];
        const size_t listSize = list.size();
        for (size_t j = 0; j < listSize; ++j)
        {
            SampleRecord sampleRecord = list[j];
            // TODO if (sampleRecord.title.compare(control->getId()) == 0)
            {
                _sampleSelectForm->setEnabled(false);
                runSample(sampleRecord.funcPtr);
                LOGI("<SamplesGame::initialize _activeSample=%lx", (long )_activeSample);
                return;
            }
        }
    }
    */
    LOGI("<SamplesGame::initialize _activeSample=%lx", (long )_activeSample);
}