Пример #1
0
void ExtractAndUpdateAmmoGUI()
{
	INT32 i;
	//Update the number of clips
	i = GetNumericStrictValueFromField( 1 );
	if( i == -1 )
		i = 1 + Random( Item[ gpItem->usItem ].ubPerPocket );
	else
		i = max( 1, min( i, Item[ gpItem->usItem ].ubPerPocket ) );
	gpItem->ubNumberOfObjects = (UINT8)i;
	SetInputFieldStringWithNumericStrictValue( 1, i );
	CreateItems( gpItem->usItem, 100, gpItem->ubNumberOfObjects, gpItem );
	//Update the trap level
	i = GetNumericStrictValueFromField( 2 );
	i = ( i == -1 ) ? 0 : min( i, 20 );
	gpItem->bTrap = (INT8)i;
	SetInputFieldStringWithNumericStrictValue( 2, i );
	if( gpEditingItemPool )
	{
		giDefaultExistChance = GetNumericStrictValueFromField( 3 );
		giDefaultExistChance = ( giDefaultExistChance == -1 ) ? 100 : max( 1, min( giDefaultExistChance, 100 ) );
		gWorldItems[ gpEditingItemPool->iItemIndex ].ubNonExistChance = (UINT8)(100 - giDefaultExistChance );
		SetInputFieldStringWithNumericStrictValue( 3, giDefaultExistChance );
	}
}
Пример #2
0
 Container::Ptr OpenAYL(Item::DataProvider::Ptr provider, const QString& filename, Log::ProgressCallback& cb)
 {
   const QFileInfo info(filename);
   if (!info.isFile() || !info.isReadable() ||
       !CheckAYLByName(info.fileName()))
   {
     return Container::Ptr();
   }
   QFile device(filename);
   if (!device.open(QIODevice::ReadOnly | QIODevice::Text))
   {
     assert(!"Failed to open playlist");
     return Container::Ptr();
   }
   QTextStream stream(&device);
   const String header = FromQString(stream.readLine(0).simplified());
   const int vers = CheckAYLBySignature(header);
   if (vers < 0)
   {
     return Container::Ptr();
   }
   Dbg("Processing AYL version %1%", vers);
   const VersionLayer version(vers);
   LinesSource lines(stream, version);
   const AYLContainer aylItems(lines, cb);
   const QString basePath = info.absolutePath();
   const ContainerItems::Ptr items = CreateItems(basePath, version, aylItems);
   const Parameters::Container::Ptr properties = CreateProperties(version, aylItems);
   properties->SetValue(Playlist::ATTRIBUTE_NAME, FromQString(info.baseName()));
   return Playlist::IO::CreateContainer(provider, properties, items);
 }
Пример #3
0
void ecBuildOptionsDialog::OnInitDialog(wxInitDialogEvent& event)
{
    m_treeCtrl->DeleteAllItems();
    //wxTreeItemId rootId = m_treeCtrl->AddRoot(_("Configuration"), 0, -1);
    CreateItems(wxGetApp().GetConfigToolDoc()->GetFirstItem(), wxTreeItemId());

    m_treeCtrl->Expand(m_treeCtrl->GetRootItem());
    ((wxChoice*) FindWindow(ecID_BUILD_OPTIONS_CATEGORY))->SetSelection(0);
}
Пример #4
0
ListBox::ListBox(imli_context_t ctx, std::vector<SylString>& wordlist, QTextCharFormat& f, QWidget* parent)
    : QListWidget(parent),
      ctx_(ctx), 
      data_(wordlist),
      format_(f)
{
    CreateItems();
    setCurrentRow(0);
}
Пример #5
0
GtkWidget *
CreateVBox(datastruct*ds, GtkWidget * w)
{
  GtkWidget * v = gtk_vbox_new (FALSE, FALSE);
  gtk_container_add (GTK_CONTAINER (w), v);
  CreateItems(ds, v);
  gtk_widget_show(v);
				/* this v is the vbox people should add their objects to. */
  return v;
}
Пример #6
0
UPnpCDSExtensionResults *UPnpCDSExtension::ProcessAll ( UPnpCDSRequest          *pRequest,
                                                        UPnpCDSExtensionResults *pResults,
                                                        QStringList             &/*idPath*/ )
{
    pResults->m_nTotalMatches   = 0;
    pResults->m_nUpdateID       = 1;

    // ----------------------------------------------------------------------
    //
    // ----------------------------------------------------------------------

    switch( pRequest->m_eBrowseFlag )
    {
        case CDS_BrowseMetadata:
        {
            // --------------------------------------------------------------
            // Return Container Object Only
            // --------------------------------------------------------------

            UPnpCDSRootInfo *pInfo = GetRootInfo( 0 );

            if (pInfo != NULL)
            {
                pResults->m_nTotalMatches   = 1;
                pResults->m_nUpdateID       = 1;

                CDSObject *pItem = CreateContainer( pRequest->m_sObjectId,
                                                    QObject::tr( pInfo->title ),
                                                    m_sExtensionId );

                pItem->SetChildCount( GetDistinctCount( pInfo ) );

                pResults->Add( pItem );
            }

            break;
        }

        case CDS_BrowseDirectChildren:
        {

            CreateItems( pRequest, pResults, 0, "", false );

            break;
        }

        case CDS_BrowseUnknown:
        default:
            break;

    }


    return pResults;
}
Пример #7
0
void ecBuildOptionsDialog::CreateItems(ecConfigItem *pti, wxTreeItemId hParent)
{
    if (pti->IsPackage() || !hParent.IsOk())
    {
        wxTreeItemId h;

        if (!hParent.IsOk()) // pti->GetItemNameOrMacro() == _("Configuration"))
            h = m_treeCtrl->AddRoot(pti->GetItemNameOrMacro(), 0, -1);
        else
            h = m_treeCtrl->AppendItem(hParent, pti->GetItemNameOrMacro(), 0, -1);

        m_treeCtrl->SetItemData(h, new ecBuildOptionsData(pti));
        // m_Tree.SetItemImage(h,18,18);
        for(ecConfigItem *pChild=pti->FirstChild();pChild;pChild=pChild->NextSibling()){
            CreateItems(pChild,h);
        }
    }
}
Пример #8
0
UPnpCDSExtensionResults *UPnpCDSExtension::Search( UPnpCDSRequest *pRequest )
{
    // -=>TODO: Need to add Filter & Sorting Support.
    // -=>TODO: Need to add Sub-Folder/Category Support!!!!!

    QStringList sEmptyList;
    VERBOSE(VB_UPNP, QString("UPnpCDSExtension::Search : m_sClass = %1 : m_sSearchClass = %2").arg(m_sClass).arg(pRequest->m_sSearchClass));

    if ( !IsSearchRequestForUs( pRequest ))
    {
        VERBOSE( VB_UPNP, QString("UPnpCDSExtension::Search - Not For Us : m_sClass = %1 : m_sSearchClass = %2").arg(m_sClass).arg(pRequest->m_sSearchClass));
        return NULL;
    }

    UPnpCDSExtensionResults *pResults = new UPnpCDSExtensionResults();

    CreateItems( pRequest, pResults, 0, "", false );

    return pResults;
}
Пример #9
0
void ExtractAndUpdateExplosivesGUI()
{
	INT32 i;
	//Update the explosives status
	i = GetNumericStrictValueFromField( 1 );
	if( i == -1 )
		i = 20 + Random( 81 );
	else
		i = min( i, 100 );
	gpItem->bStatus[0] = (INT8)i;
	SetInputFieldStringWithNumericStrictValue( 1, i );
	//Update the quantity
	if( Item[ gpItem->usItem ].ubPerPocket > 1 )
	{
		i = GetNumericStrictValueFromField( 2 );
		if( i == -1 )
			i = 1 + Random( Item[ gpItem->usItem ].ubPerPocket );
		else
			i = max( 1, min( i, Item[ gpItem->usItem ].ubPerPocket ) );
		gpItem->ubNumberOfObjects = (UINT8)i;
		SetInputFieldStringWithNumericStrictValue( 2, i );
		CreateItems( gpItem->usItem, gpItem->bStatus[0], gpItem->ubNumberOfObjects, gpItem );
	}
	//Update the trap level
	i = GetNumericStrictValueFromField( 3 );
	i = ( i == -1 ) ? 0 : min( i, 20 );	
	gpItem->bTrap = (INT8)i;
	SetInputFieldStringWithNumericStrictValue( 3, i );
	if( gpEditingItemPool )
	{
		giDefaultExistChance = GetNumericStrictValueFromField( 4 );
		giDefaultExistChance = ( giDefaultExistChance == -1 ) ? 100 : max( 1, min( giDefaultExistChance, 100 ) );
		gWorldItems[ gpEditingItemPool->iItemIndex ].ubNonExistChance = (UINT8)(100 - giDefaultExistChance );
		SetInputFieldStringWithNumericStrictValue( 4, giDefaultExistChance );
	}
}
Пример #10
0
UPnpCDSExtensionResults *UPnpCDSExtension::ProcessKey( UPnpCDSRequest          *pRequest,
                                                       UPnpCDSExtensionResults *pResults,
                                                       QStringList             &idPath )
{
    pResults->m_nTotalMatches   = 0;
    pResults->m_nUpdateID       = 1;

    // ----------------------------------------------------------------------
    //
    // ----------------------------------------------------------------------

    QString sKey = idPath.last().section( '=', 1, 1 );
    QUrl::decode( sKey );

    if (sKey.length() > 0)
    {
        int nNodeIdx = idPath[ idPath.count() - 2 ].toInt();

        switch( pRequest->m_eBrowseFlag )
        {

            case CDS_BrowseMetadata:
            {
                UPnpCDSRootInfo *pInfo = GetRootInfo( nNodeIdx );

                if (pInfo == NULL)
                    return pResults;

                pRequest->m_sParentId = RemoveToken( "/", pRequest->m_sObjectId, 1 );

                // --------------------------------------------------------------
                // Since Key is not always the title, we need to lookup title.
                // --------------------------------------------------------------

                MSqlQuery query(MSqlQuery::InitCon());

                if (query.isConnected())
                {
                    QString sSQL   = QString( pInfo->sql )
                                        .arg( pInfo->where );

                    // -=>TODO: There is a problem when called for an Item, instead of a container
                    //          sKey = '<KeyName>/item?ChanId' which is incorrect.


                    query.prepare  ( sSQL );
                    query.bindValue( ":KEY", sKey );
                    query.exec();

                    if (query.isActive() && query.size() > 0)
                    {
                        if ( query.next() )
                        {
                            // ----------------------------------------------
                            // Return Container Object Only
                            // ----------------------------------------------

                            pResults->m_nTotalMatches   = 1;
                            pResults->m_nUpdateID       = 1;

                            CDSObject *pItem = CreateContainer( pRequest->m_sObjectId,
                                                                query.value(1).toString(),
                                                                pRequest->m_sParentId );

                            pItem->SetChildCount( GetDistinctCount( pInfo ));

                            pResults->Add( pItem );
                        }
                    }
                }
                break;
            }

            case CDS_BrowseDirectChildren:
            {

                CreateItems( pRequest, pResults, nNodeIdx, sKey, true );

                break;
            }

            case CDS_BrowseUnknown:
                default:
                break;
        }
    }

    return pResults;
}
Пример #11
0
CMessageRecord::CMessageRecord()
{
	m_pItemName = NULL;

	CreateItems();
}
Пример #12
0
LevelMine::LevelMine(unique_ptr<Game> & game, const unique_ptr<PlayerTransfer> & playerTransfer) : Level(game, playerTransfer) {
	mName = LevelName::Mine;

	LoadLocalization("mine.loc");

	mPlayer->mYaw.SetTarget(180.0f);

	LoadSceneFromFile("data/maps/mine.scene");

	mPlayer->SetPosition(GetUniqueObject("PlayerPosition")->GetPosition());

	Vector3 placePos = GetUniqueObject("PlayerPosition")->GetPosition();
	Vector3 playerPos = mPlayer->GetCurrentPosition();

	mPlayer->GetHUD()->SetObjective(mLocalization.GetString("objective1"));

	AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note1")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note1Desc"), mLocalization.GetString("note1")); });
	AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note2")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note2Desc"), mLocalization.GetString("note2")); });
	AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note3")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note3Desc"), mLocalization.GetString("note3")); });
	AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note4")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note4Desc"), mLocalization.GetString("note4")); });
	AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note5")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note5Desc"), mLocalization.GetString("note5")); });
	AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note6")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note6Desc"), mLocalization.GetString("note6")); });
	AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note7")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note7Desc"), mLocalization.GetString("note7")); });
	AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note8")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note8Desc"), mLocalization.GetString("note8")); });

	mStoneFallZone = GetUniqueObject("StoneFallZone");

	mNewLevelZone = GetUniqueObject("NewLevel");

	auto soundSystem = mGame->GetEngine()->GetSoundSystem();

	soundSystem->SetReverbPreset(ReverbPreset::Cave);

	AddSound(mMusic = soundSystem->LoadMusic("data/music/chapter2.ogg"));

	mConcreteWall = GetUniqueObject("ConcreteWall");
	mDeathZone = GetUniqueObject("DeadZone");
	mDetonator = GetUniqueObject("Detonator");

	AddSound(mAlertSound = soundSystem->LoadSound3D("data/sounds/alert.ogg"));
	mAlertSound->Attach(mDetonator);

	AddSound(mExplosionSound = soundSystem->LoadSound3D("data/sounds/blast.ogg"));
	mExplosionSound->SetReferenceDistance(10);

	mDetonatorActivated = 0;

	mExplosionFlashAnimator = 0;

	// Create detonator places
	AddItemPlace(mDetonatorPlace[0] = make_shared<ItemPlace>(GetUniqueObject("DetonatorPlace1"), Item::Type::Explosives));
	AddItemPlace(mDetonatorPlace[1] = make_shared<ItemPlace>(GetUniqueObject("DetonatorPlace2"), Item::Type::Explosives));
	AddItemPlace(mDetonatorPlace[2] = make_shared<ItemPlace>(GetUniqueObject("DetonatorPlace3"), Item::Type::Explosives));
	AddItemPlace(mDetonatorPlace[3] = make_shared<ItemPlace>(GetUniqueObject("DetonatorPlace4"), Item::Type::Explosives));

	mWireModels[0] = GetUniqueObject("WireModel1");
	mWireModels[1] = GetUniqueObject("WireModel2");
	mWireModels[2] = GetUniqueObject("WireModel3");
	mWireModels[3] = GetUniqueObject("WireModel4");

	mDetonatorModels[0] = GetUniqueObject("DetonatorModel1");
	mDetonatorModels[1] = GetUniqueObject("DetonatorModel2");
	mDetonatorModels[2] = GetUniqueObject("DetonatorModel3");
	mDetonatorModels[3] = GetUniqueObject("DetonatorModel4");

	mExplosivesModels[0] = GetUniqueObject("ExplosivesModel1");
	mExplosivesModels[1] = GetUniqueObject("ExplosivesModel2");
	mExplosivesModels[2] = GetUniqueObject("ExplosivesModel3");
	mExplosivesModels[3] = GetUniqueObject("ExplosivesModel4");

	mFindItemsZone = GetUniqueObject("FindItemsZone");

	AddAmbientSound(soundSystem->LoadSound3D("data/sounds/ambient/mine/ambientmine1.ogg"));
	AddAmbientSound(soundSystem->LoadSound3D("data/sounds/ambient/mine/ambientmine2.ogg"));
	AddAmbientSound(soundSystem->LoadSound3D("data/sounds/ambient/mine/ambientmine3.ogg"));
	AddAmbientSound(soundSystem->LoadSound3D("data/sounds/ambient/mine/ambientmine4.ogg"));
	AddAmbientSound(soundSystem->LoadSound3D("data/sounds/ambient/mine/ambientmine5.ogg"));

	mExplosionTimer = ITimer::Create();
	mBeepSoundTimer = ITimer::Create();
	mBeepSoundTiming = 1.0f;

	CreateItems();

	mReadyExplosivesCount = 0;

	MakeLadder("LadderBegin", "LadderEnd", "LadderEnter", "LadderBeginLeavePoint", "LadderEndLeavePoint");
	MakeDoor("Door1", 90);
	MakeDoor("Door3", 90);
	MakeDoor("DoorToAdministration", 90);
	MakeDoor("Door6", 90);
	MakeDoor("DoorToDirectorsOffice", 90);
	MakeDoor("DoorToResearchFacility", 90);

	MakeKeypad("Keypad1", "Keypad1Key0", "Keypad1Key1", "Keypad1Key2", "Keypad1Key3", "Keypad1Key4", "Keypad1Key5", "Keypad1Key6", "Keypad1Key7", "Keypad1Key8", "Keypad1Key9", "Keypad1KeyCancel", MakeDoor("StorageDoor", 90), "7854");
	MakeKeypad("Keypad2", "Keypad2Key0", "Keypad2Key1", "Keypad2Key2", "Keypad2Key3", "Keypad2Key4", "Keypad2Key5", "Keypad2Key6", "Keypad2Key7", "Keypad2Key8", "Keypad2Key9", "Keypad2KeyCancel", MakeDoor("DoorToResearchFacility", 90), "1689");
	MakeKeypad("Keypad3", "Keypad3Key0", "Keypad3Key1", "Keypad3Key2", "Keypad3Key3", "Keypad3Key4", "Keypad3Key5", "Keypad3Key6", "Keypad3Key7", "Keypad3Key8", "Keypad3Key9", "Keypad3KeyCancel", MakeDoor("DoorMedical", 90), "9632");

	mMusic->Play();

	mStages["ConcreteWallExp"] = false;
	mStages["FindObjectObjectiveSet"] = false;
	mStages["FoundObjectsForExplosion"] = false;

	// create paths
	const char * ways[] = {
		"WayA", "WayB", "WayC", "WayD", "WayE", "WayF", "WayG",
		"WayH", "WayI", "WayJ", "WayK"
	};
	Path p;
	for(auto w : ways) {
		p += Path(mScene, w);
	}

	p.Get("WayB1")->AddEdge(p.Get("WayA004"));
	p.Get("WayC1")->AddEdge(p.Get("WayA019"));
	p.Get("WayD1")->AddEdge(p.Get("WayA019"));
	p.Get("WayE1")->AddEdge(p.Get("WayA040"));
	p.Get("WayF1")->AddEdge(p.Get("WayA042"));
	p.Get("WayF009")->AddEdge(p.Get("WayG1"));
	p.Get("WayH1")->AddEdge(p.Get("WayA059"));
	p.Get("WayI1")->AddEdge(p.Get("WayA097"));
	p.Get("WayJ1")->AddEdge(p.Get("WayA073"));
	p.Get("WayK1")->AddEdge(p.Get("WayA027"));

	vector<shared_ptr<GraphVertex>> patrolPoints = {
		p.Get("WayA1"), p.Get("WayC024"), p.Get("WayB012"),
		p.Get("WayB012"), p.Get("WayD003"), p.Get("WayK005"),
		p.Get("WayE006"), p.Get("WayF019"), p.Get("WayG007"),
		p.Get("WayH010"), p.Get("WayA110"), p.Get("WayI009")
	};

	mEnemy = make_unique<Enemy>(mGame, p.mVertexList, patrolPoints);
	mEnemy->SetPosition(GetUniqueObject("EnemyPosition")->GetPosition());

	mExplosivesDummy[0] = GetUniqueObject("ExplosivesModel5");
	mExplosivesDummy[1] = GetUniqueObject("ExplosivesModel6");
	mExplosivesDummy[2] = GetUniqueObject("ExplosivesModel7");
	mExplosivesDummy[3] = GetUniqueObject("ExplosivesModel8");

	mExplodedWall = GetUniqueObject("ConcreteWallExploded");
	mExplodedWall->Hide();

	mExplosionFlashPosition = GetUniqueObject("ExplosionFlash");

	mPlayer->GetInventory()->RemoveItem(Item::Type::Crowbar, 1);

	DoneInitialization();
}
Пример #13
0
//---------------------------------------------------------------------------- 
// Nome: ChangeState(CLevel::GameState NewState)
// Desc: Muda o estado da máquina de estados da CLevel
// Pams: novo estado
//---------------------------------------------------------------------------- 
void CLevel::ChangeState(CLevel::GameState NewState)
{
	//somente muda o estado se o novo for diferente do atual
	if(State != NewState)
	{
		switch(NewState)
		{
			case GS_GAME:
			{
				if(State == GS_MENU)
				{
					if(!Menu.bInGame)
					{
						Menu.bInGame = true; //indica para o menu que o jogo está rodando
						CreateItems();		//cria os itens
						CreateEnemies();	//cria os inimigos
						CreatePlayer();		//cria o jogador						
						if(p_SprSwitch)
						{
							//ajusta animação da alavanca da fase para 0 (levantada)
							p_SprSwitch->SetCurrentAnimation(0);
						}
						//faz aparecer layer de interface (com pontos e vidas)
						p_LayInterface->bVisible = true;
					}					
					//esconde menu
					Menu.Show(false);

					State = NewState; //estado atual recebe novo estado
					break;
				}
				if(State == GS_PAUSE)
				{
					//17.5.3. Esconder mensagem de pausa
					p_MsgPaused->bVisible = false;

					State = NewState; //estado atual recebe novo estado
					break;
				}
				break;
			}
			case GS_PAUSE:
			{
				if(State == GS_GAME)
				{
					//17.5.3. Exibir mensagem de pausa
					if(p_MsgPaused)
					{
						p_MsgPaused->bVisible = true;
					}

					State = NewState; //estado atual recebe novo estado
					break;
				}
				break;
			}
			case GS_MENU:
			{
				if(State == GS_GAME)
				{	
					Menu.bInGame = true; //mostrará botão "Continuar"
					Menu.Show(true); //mostra o menu principal
					State = NewState; //estado atual recebe novo estado
					break;
				}
				if((State == GS_CONGRATULATIONS)||(State == GS_GAMEOVER))
				{
					if(p_MsgCongrats)
					{
						//esconde mensagem de congratulação
						p_MsgCongrats->bVisible = false;
					}
					if(p_MsgGameOver)
					{
						//esconde mensagem de game over
						p_MsgGameOver->bVisible = false;
					}
					ReleaseCharacters();	//desalocando os inimigos
					ReleaseItems();				//desalocando os itens
					Menu.bInGame = false; //mostrará botão "Novo Jogo"
					Menu.Show(true);			//mostra o menu principal
					Scroll(CNGLVector(0,0)); //desloca a as layers para o início da fase
					
					State = NewState; //estado atual recebe novo estado
					break;
				}
				break;
			}
			case GS_GAMEOVER:
			{
				if(State == GS_GAME)
				{
					if(p_MsgGameOver)
					{
						//mostra mensagem de game over
						p_MsgGameOver->bVisible = true;
					}
					State = NewState; //estado atual recebe novo estado
					break;
				}
				break;
			}
			case GS_CONGRATULATIONS:
			{
				if(State == GS_GAME)
				{
					//21.1.4.
					//1. mostrar mensagem de congratulação

					//2. reproduz o som de congratulação

					//3. troca a animação do jogador para a 2


					State = NewState; //estado atual recebe novo estado
					break;
				}
				break;
			}
		}
	}
}