///////////////////
// Shutdown the internet menu
void Menu_Net_NETShutdown()
{
	if (tLXOptions)  {

		// Save the list
		if( iNetMode == net_internet )  {
			SvrList_Save();

			CListview* l = (CListview *)cInternet.getWidget(mi_ServerList);
			if(l) {
				// Save the column widths
				for (int i=0;i<7;i++)
					tLXOptions->iInternetList[i] = l->GetColumnWidth(i);

				// Save the sorting column
				tLXOptions->iInternetSortColumn = l->GetSortColumn();
			}
		}

		// Save the selected player
		GuiListItem::Pt item = ((CCombobox*)cInternet.getWidget(mi_PlayerSelection)) ? ((CCombobox*)cInternet.getWidget(mi_PlayerSelection))->getSelectedItem() : NULL;
		if (item.get())
			tLXOptions->sLastSelectedPlayer = item->index();
	}

	cInternet.Shutdown();
}
Beispiel #2
0
///////////////////
// Remove the part and put it into the spare parts bin
void Gar_RemovePart(void)
{
    // Add to the players spare parts
	cMainGuy->addPart(tPartChange.cPart);

    // Engine part
    if(tGarage->iState == GAR_ENGINEPART) {
        // If this part is attached to a parent part (block), let the parent part handle it
        if(tPartChange.cPart->getParent())
		    tPartChange.cPart->getParent()->removeAttached(tPartChange.cPart);
        else
		    tPartChange.cCar->removeEnginePart(tPartChange.cPart);
    } else {

        // Running gear part
        if(tGarage->iState == GAR_RUNGPART)
	        cMainGuy->getCurCar()->removeRunningGearPart(tPartChange.cPart);
    }

    if( tPartChange.tItem )
	    tPartChange.tItem->iUsed = false;

    // Go up a level
	if(tGarage->iState == GAR_ENGINEPART) {
		Gar_Part2Engine();
	}
	if(tGarage->iState == GAR_RUNGPART) {
		Gar_Part2RunningG();
	}

    BASS_SamplePlay(sfxParts.smpRemove);

    // Shutdown the dialog box
    cPartDlg.Shutdown();
}
Beispiel #3
0
///////////////////
// Shutdown the diner
void Dnr_Shutdown(void)
{
    cDinerLayout.Shutdown();
    cDinerLayout2.Shutdown();

    if( psDiner ) {

        if( psDiner->pcLocation ) {
            psDiner->pcLocation->Shutdown();
            delete psDiner->pcLocation;
        }

        psDiner->cSky.Shutdown();

        delete psDiner;
    }

    psDiner = NULL;
}
///////////////////
// Join a server
void Menu_Net_NETJoinServer(const std::string& sAddress, const std::string& sName)
{
	// Fill in the game structure
	CCombobox* combo = (CCombobox *) cInternet.getWidget(mi_PlayerSelection);
	const GuiListItem::Pt item = combo->getSelectedItem();
	if(!item.get()) {
		errors << "no player selected" << endl;
		return;
	}
		
	tLXOptions->sLastSelectedPlayer = item->index();

	if(!JoinServer(sAddress, sName, item->index()))
		return;

	// Shutdown
	cInternet.Shutdown();
	
	iNetMode = net_join;
	tMenu->iReturnTo = net_internet;
	
	// Connect to the server
	Menu_Net_JoinConnectionInitialize(sAddress);
}
Beispiel #5
0
///////////////////
// Setup a part change
void Gar_SetupPartChange(void)
{
    // Initialize the dialog box for the part change
    cPartDlg.Initialize();

    if( tPartChange.iNutsGoingon )
        cPartDlg.Add( new CButton("Add All",-1),		    1,  340,255,75, 25  );
    else
        cPartDlg.Add( new CButton("Remove",-1),		        1,  340,255,75, 25  );

    cPartDlg.Add( new CButton("Repair",-1),		            2,  340,300,75, 25  );
	cPartDlg.Add( new CButton("Forget it",btn_forgit),      3,  340,345,120,25  );
    cPartDlg.Add( new CDialog("Part Change",dlgs_small),    4,  35, 25, 300,200 );

    cPartDlg.moveWidgets(240,-170);
}
Beispiel #6
0
///////////////////
// Finish adding the part
void Gar_FinishAddPart(void)
{
    // Go up a level
	if(tGarage->iState == GAR_ENGINEPART) {
		Gar_Part2Engine();
		//cGarTaskb.Remove("engine");
	}
	if(tGarage->iState == GAR_RUNGPART) {
		Gar_Part2RunningG();
	}

	tPartChange.cPart->setDrawNuts(false);

    BASS_SamplePlay(sfxParts.smpRemove);

    // Shutdown the dialog box
    cPartDlg.Shutdown();
}
Beispiel #7
0
///////////////////
// Initialize the news net menu
bool Menu_Net_ChatInitialize()
{
	iNetMode = net_chat;

	// Setup the gui layout
	cChat.Shutdown();
	cChat.Initialize();

	cChat.Add( new CButton(BUT_BACK, tMenu->bmpButtons), nc_Back, 25,440, 50,15);

	cChat.Add( new CChatWidget(), nc_Chat, 25, 140, 585, 280);
	cChat.Add( new CCheckbox(tLXOptions->bEnableChat), nc_EnableChat, 100, 440, 20, 20);
	cChat.Add( new CLabel("Enable", tLX->clNormalLabel), -1, 130, 440, 0, 0);

	cChat.Add( new CCheckbox(tLXOptions->bEnableMiniChat), nc_EnableMiniChat, 350, 440, 20, 20);
	cChat.Add( new CLabel("Mini chat in server list", tLX->clNormalLabel), -1, 380, 440, 0, 0);

	cChatGuiInitialized = true;
	return true;
}
Beispiel #8
0
///////////////////
// Start the diner
bool Dnr_Start(char *szDir)
{
    keyboard_t *kb = System_GetKeyboard();
    GLfloat     one[] = {0.3f,0.3f,0.3f,1};
    GLfloat     blue[] = {0.3f, 0.3f, 1.0f, 1.0f};
    GLfloat     pos1[4] = {1,1,1,1};
    GLfloat     pos2[4] = {1,1,1,1};
    GLfloat     pos3[4] = {25,-100,50,1};
    int         i;

    if( !Dnr_Load(szDir) )
        return false;

    for( i=0; i<3; i++ ) {
        pos1[i] = psDiner->pcLocation->getScene()->getLight(0).Position.GetIndex(i);
        pos2[i] = psDiner->pcLocation->getScene()->getLight(1).Position.GetIndex(i);
    }

    // Setup the diner for an opponent
    psDiner->nOppState = opp_waiting;
    psDiner->fOppTimer = tMainSR3.fCurTime + (float)GetRandomInt(2)+2.0f;

    sRaceInfo.pcOpponent = NULL;

    // HACK: Quickly get the opponent in the diner
    //Dnr_RollinOpponent();


    //psDiner->pcLocation->SetupCamera( CVec(25,11,-1.4f),100);
    //psDiner->pcLocation->setCamPos( CVec(0,0,0) );

    // Setup the fog
    State_Disable(GL_FOG);

    // Setup the lighting
    State_Enable(GL_LIGHTING);
    State_Enable(GL_LIGHT1);
    State_Enable(GL_LIGHT2);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, one);
    glLightfv(GL_LIGHT1, GL_DIFFUSE, one);
    glLightfv(GL_LIGHT2, GL_DIFFUSE, one);
    glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1.00f);
	glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.0f);
    glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 1.00f);
	glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.0f);
    glLightf(GL_LIGHT2, GL_CONSTANT_ATTENUATION, 0.80f);
	glLightf(GL_LIGHT2, GL_LINEAR_ATTENUATION, 0.01f);
    glMaterialf(GL_FRONT, GL_SHININESS, 25.0);
    glMaterialfv(GL_FRONT, GL_SPECULAR, one);


    System_ProcessInput();
	while(psDiner->bProcessDiner) {
		System_ProcessInput();

        //
        // Processing
        //
        psDiner->pcLocation->Process();
        psDiner->cSky.Simulate(tMainSR3.fDeltaTime);

        if( !psDiner->bSpeechBubble ) {
            Dnr_ProcessOpponent();
            Dnr_ProcessGUI();
        }

		cMainGuy->processFrame();



        //
        // 3D Drawing
        //
        glLightfv(GL_LIGHT0, GL_POSITION, pos1);
        glLightfv(GL_LIGHT1, GL_POSITION, pos2);
        glLightfv(GL_LIGHT2, GL_POSITION, pos3);

        SetupFrame();
        // Manually setup the camera
        psDiner->pcLocation->getCamera()->LookAt(psDiner->pcLocation->getCamLook());
        psDiner->pcLocation->getCamera()->Show();

        psDiner->cSky.Render( psDiner->pcLocation->getCamera() );
        State_Enable(GL_LIGHTING);
		psDiner->pcLocation->Draw(true, true, false);

        Dnr_DrawOpponent();



        //
        // 2D Drawing
        //
        Render_Begin2D();

            // Draw the sidedoor bit
            State_Enable(GL_TEXTURE_2D);
            State_Disable(GL_LIGHTING);
            State_Enable(GL_BLEND);
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
            glColor4f(1,1,1,1);
            BlitTexture(psDiner->psSideDoor, 0,0, 0,472, 105,128, 1,1);
            for(i=0; i<10; i++ ) {
                BlitTexture(psDiner->psSideDoor, 105,0, i*95+105,472, 95,128, 1,1);
            }

            if( psDiner->bSpeechBubble )
                Dnr_SpeechProcess();

            psDiner->pcLocation->FinalDraw();

            if(psOptions->nShowFPS) {
                Font_SetAlpha(1);
                Font_SetSize(14);
                int fps = GetFPS();
                Font_Draw(5, 583, CVec(0,0,0), "FPS:  %d", fps);
                Font_Draw(5, 585, CVec(1,1,1), "FPS:  %d", fps);
            }
            if(psOptions->nDeveloper) {
                Font_SetAlpha(1);
                Font_SetSize(14);
                Font_Draw(5, 563, CVec(0,0,0), "Tris: %d", tMainSR3.TriCount);
                Font_Draw(5, 565, CVec(1,1,1), "Tris: %d", tMainSR3.TriCount);
            }

            // Draw the gui
            if(!psDiner->bSpeechBubble && psDiner->bProcessDiner) {
                if( psDiner->bOppClicked )
                    cDinerLayout.Draw();
                cDinerLayout2.Draw();
            }

            gui_DrawMouse();

		Render_End2D();

		SDL_GL_SwapBuffers();
    }

    //
    // Show a loading sign on the screen
    //
    Render_Begin2D();
    Font_SetSize(14);
    Font_SetAlpha(1);
    Font_DrawCentered(400, 300, CVec(1,1,1), "Loading...");
    Render_End2D();
    SDL_GL_SwapBuffers();


    // Are we going to race?
    if(psDiner->bRacing)
        // Off to the track
        Game_SetLocation(LOC_RACE);
    else
        // Back to the garage
        Game_SetLocation(LOC_GARAGE);

    Dnr_Shutdown();

    return true;
}
namespace DeprecatedGUI {

CGuiLayout	cInternet;
std::string szNetCurServer;

// Internet widgets
enum {
	mi_Join=0,
	mi_ServerList,
	mi_Refresh,
	mi_UpdateList,
	mi_AddServer,
	mi_Back,
    mi_PopupMenu,
	mi_PlayerSelection,
};

void Menu_Net_NET_ServerList_Refresher() {
	Menu_SvrList_FillList( (CListview *)cInternet.getWidget( mi_ServerList ), SLFT_CustomSettings, SvrListSettingsFilter::Load(tLXOptions->sSvrListSettingsFilterCfg) );
}
	
	
///////////////////
// Initialize the Internet menu
bool Menu_Net_NETInitialize()
{
	iNetMode = net_internet;
    szNetCurServer = "";

	cInternet.Shutdown();
	cInternet.Initialize();

	cInternet.Add( new CListview(),								mi_ServerList, 40, 180, 560, 242);
	cInternet.Add( new CButton(BUT_BACK, tMenu->bmpButtons),    mi_Back,       25, 440, 50,  15);
	cInternet.Add( new CButton(BUT_ADD, tMenu->bmpButtons),		mi_AddServer,  140,440, 40,  15);
	cInternet.Add( new CButton(BUT_REFRESH, tMenu->bmpButtons), mi_Refresh,	250,440, 83,  15);
	cInternet.Add( new CButton(BUT_UPDATELIST, tMenu->bmpButtons),	mi_UpdateList,  390,440, 125,  15);
	cInternet.Add( new CButton(BUT_JOIN, tMenu->bmpButtons),    mi_Join,		570,440, 43,  15);
	cInternet.Add( new CLabel("Select player:",tLX->clNormalLabel),-1,		125, 152, 180,15);
	cInternet.Add( new CCombobox(),								mi_PlayerSelection,		225,150, 170,  19);
	if( tLXOptions->bEnableChat && tLXOptions->bEnableMiniChat )
		cInternet.Add( new CChatWidget(),						-1,	25, 15, 585, 85 );


	/*
	  Server list columns

      Connection speed
	  Name
	  State
	  Players
	  Ping
	  Address
    */

	// Add players to the list
	profile_t *p = GetProfiles();
	bool validName = false;
	for(;p;p=p->tNext) {
		if(p->iType == PRF_COMPUTER->toInt())
			continue;

		int i = ((CCombobox*) cInternet.getWidget( mi_PlayerSelection ))->addItem(p->sName, p->sName);
		((CCombobox*) cInternet.getWidget( mi_PlayerSelection ))->setImage(p->cSkin.getPreview(), i);
		if( p->sName == tLXOptions->sLastSelectedPlayer )
			validName=true;
	}

	if( ! validName )
		tLXOptions->sLastSelectedPlayer = GetProfiles()->sName;

	((CCombobox*) cInternet.getWidget( mi_PlayerSelection ))->setCurSIndexItem( tLXOptions->sLastSelectedPlayer );

    Menu_redrawBufferRect(0, 0, 640, 480);

	cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "", tLXOptions->iInternetList[0]);
	cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "Server Name", tLXOptions->iInternetList[1]);
	cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "State", tLXOptions->iInternetList[2]);
	cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "Players", tLXOptions->iInternetList[3]);
	cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "Ping", tLXOptions->iInternetList[4]);

	if (tLXOptions->bUseIpToCountry)
	{	// Too lazy to update tLXOptions, so I'll calculate last column width from width of listview
		//int CountryColumnWidth = 21; // TODO: not used

		// HINT: because this column is optional, it is at the end of the array from options
		cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "Country", tLXOptions->iInternetList[5]);
	}

	cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "Address", tLXOptions->iInternetList[6]);

	((CListview*) cInternet.getWidget( mi_ServerList ))->SetSortColumn( tLXOptions->iInternetSortColumn, true ); // Sorting

    // Load the list
	Menu_Net_NET_ServerList_Refresher();
	SvrList_UpdateUDPList();
	
	Timer("Menu_Net_NETInitialize serverlist timeout", null, NULL, SVRLIST_TIMEOUT, true).startHeadless();
	
	return true;
}


///////////////////
// Shutdown the internet menu
void Menu_Net_NETShutdown()
{
	if (tLXOptions)  {

		// Save the list
		if( iNetMode == net_internet )  {
			SvrList_Save();

			CListview* l = (CListview *)cInternet.getWidget(mi_ServerList);
			if(l) {
				// Save the column widths
				for (int i=0;i<7;i++)
					tLXOptions->iInternetList[i] = l->GetColumnWidth(i);

				// Save the sorting column
				tLXOptions->iInternetSortColumn = l->GetSortColumn();
			}
		}

		// Save the selected player
		GuiListItem::Pt item = ((CCombobox*)cInternet.getWidget(mi_PlayerSelection)) ? ((CCombobox*)cInternet.getWidget(mi_PlayerSelection))->getSelectedItem() : NULL;
		if (item.get())
			tLXOptions->sLastSelectedPlayer = item->index();
	}

	cInternet.Shutdown();
}


///////////////////
// Net Internet frame
void Menu_Net_NETFrame(int mouse)
{
	gui_event_t *ev = NULL;
	std::string	addr;


	// Process & Draw the gui
	ev = cInternet.Process();
	cInternet.Draw( VideoPostProcessor::videoSurface() );


	// Process the server list
	static bool wasLoadedBefore = false;
	if( SvrList_Process() || (tIpToCountryDB->Loaded() && !wasLoadedBefore) ) {
		// Add the servers to the listview
		Menu_Net_NET_ServerList_Refresher();
		wasLoadedBefore = tIpToCountryDB->Loaded();
	}



	// Process any events
	if(ev) {

		switch(ev->iControlID) {

			// Add Server
			case mi_AddServer:
				if(ev->iEventMsg == BTN_CLICKED) {
					// Click!
					PlaySoundSample(sfxGeneral.smpClick);

					Menu_Net_NETAddServer();
				}
				break;

			// Back
			case mi_Back:
				if(ev->iEventMsg == BTN_CLICKED) {

					// Shutdown
					Menu_Net_NETShutdown();

					// Click!
					PlaySoundSample(sfxGeneral.smpClick);

					// Back to main menu
					Menu_MainInitialize();
				}
				break;

			// Refresh
			case mi_Refresh:
				if(ev->iEventMsg == BTN_CLICKED) {

					// Click!
					PlaySoundSample(sfxGeneral.smpClick);

					// Refresh the currently visible servers
					SvrList_RefreshList();
					Menu_Net_NET_ServerList_Refresher();
				}
				break;

			// Join
			case mi_Join:
                if(ev->iEventMsg == BTN_CLICKED) {

					addr = "";
					int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0);
					if(result != -1 && addr != "") {

                        // Save the list
                        SvrList_Save();

						// Click!
						PlaySoundSample(sfxGeneral.smpClick);

						lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1);

						// Join
						if (sub)
							Menu_Net_NETJoinServer(addr,sub->sText);
						return;
					}
				}
				break;

			// Serverlist
			case mi_ServerList:

                // Double click
				if(ev->iEventMsg == LV_DOUBLECLK) {

					/*
					  Now.... Should a double click refresh the server (like tribes)?
					  Or should it join the server like other games???
					*/

					// Just join for the moment
					addr = "";
					int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0);
					lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1);
					if(result != -1 && addr != "" && sub) {
                        // Save the list
                        SvrList_Save();

						Menu_Net_NETJoinServer(addr,sub->sText);
						return;
					}
				}

                // Right click
                if( ev->iEventMsg == LV_RIGHTCLK ) {
                    addr = "";
					int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0);
					if(result && addr != "") {
                        // Display a menu
                        szNetCurServer = addr;
                        mouse_t *m = GetMouse();

                        cInternet.Add( new CMenu(m->X, m->Y), mi_PopupMenu, 0,0, 640,480 );
                        cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Delete server",				0 );
                        cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Refresh server",				1 );
                        cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Join server",				2 );
						cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Add to favourites",			3 );
						cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Send \"I want to join message\"",4 );
						cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Copy IP to clipboard",		5 );
                        cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Server details",				6 );
                    }
                }


				// Enter key
				if( ev->iEventMsg == LV_ENTER )  {
					// Join
					addr = "";
					int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0);
					lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1);
					if(result != -1 && addr != "" && sub) {
                        // Save the list
                        SvrList_Save();

						Menu_Net_NETJoinServer(addr,sub->sText);
						return;
					}
				}

				// Delete
				if( ev->iEventMsg == LV_DELETE )  {
					addr = "";
					int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0);
					if(result && addr != "") {
						SvrList_RemoveServer(addr);
						// Re-Fill the server list
						Menu_Net_NET_ServerList_Refresher();
					}
				}
				break;

            // Popup menu
            case mi_PopupMenu:
                switch( ev->iEventMsg ) {
                    // Delete the server
                    case MNU_USER+0:
                        SvrList_RemoveServer(szNetCurServer);
                        break;

                    // Refresh the server
                    case MNU_USER+1:
                        {
							server_t::Ptr sv = SvrList_FindServerStr(szNetCurServer);
                            if(sv)
                                SvrList_RefreshServer(sv);
                        }
                        break;

                    // Join a server
                    case MNU_USER+2:  {
                        // Save the list
                        SvrList_Save();
						lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1);
						if (sub)
							Menu_Net_NETJoinServer(szNetCurServer,sub->sText);
						}
                        return;

                    // Add server to favourites
                    case MNU_USER+3:
						{
							server_t::Ptr sv = SvrList_FindServerStr(szNetCurServer);
							if (sv)
								SvrList_AddFavourite(sv->szName,sv->szAddress);
						}
                        break;

					// Send a "wants to join" message
                    case MNU_USER+4:
						{
							server_t::Ptr sv = SvrList_FindServerStr(szNetCurServer);
							std::string Nick;
							cInternet.SendMessage(mi_PlayerSelection, CBS_GETCURNAME, &Nick, 0);
							if (sv)
								SvrList_WantsJoin(Nick, sv);
						}
                        break;

					// Copy the IP to clipboard
					case MNU_USER+5:
						{
							copy_to_clipboard(szNetCurServer);
						}
						break;

                    // Show server details
                    case MNU_USER+6:
						cInternet.removeWidget(mi_PopupMenu);
                        Menu_Net_NETShowServer(szNetCurServer);
                        break;
                }

                // Re-Fill the server list
				Menu_Net_NET_ServerList_Refresher();

                // Remove the menu widget
                cInternet.SendMessage( mi_PopupMenu, MNM_REDRAWBUFFER, (DWORD)0, 0);
                cInternet.removeWidget(mi_PopupMenu);
                break;

			// Update server list
			case mi_UpdateList:
				if(ev->iEventMsg == BTN_CLICKED) {
					// Click!
					PlaySoundSample(sfxGeneral.smpClick);

					Menu_Net_NETUpdateList();
				}
				break;
		}

	}

	// F5 updates the list
	if (WasKeyboardEventHappening(SDLK_F5))
		Menu_Net_NETUpdateList();

	// Draw the mouse
	DrawCursor(VideoPostProcessor::videoSurface());

}


///////////////////
// Join a server
void Menu_Net_NETJoinServer(const std::string& sAddress, const std::string& sName)
{
	// Fill in the game structure
	CCombobox* combo = (CCombobox *) cInternet.getWidget(mi_PlayerSelection);
	const GuiListItem::Pt item = combo->getSelectedItem();
	if(!item.get()) {
		errors << "no player selected" << endl;
		return;
	}
		
	tLXOptions->sLastSelectedPlayer = item->index();

	if(!JoinServer(sAddress, sName, item->index()))
		return;

	// Shutdown
	cInternet.Shutdown();
	
	iNetMode = net_join;
	tMenu->iReturnTo = net_internet;
	
	// Connect to the server
	Menu_Net_JoinConnectionInitialize(sAddress);
}



// TODO: remove this here!
extern CButton	cNetButtons[6];

///////////////////
// Show an 'add server' box to enter in an address
enum  {
	na_Cancel=0,
	na_Add,
	na_Address
};

void Menu_Net_NETAddServer()
{
	CGuiLayout	cAddSvr;
	gui_event_t *ev = NULL;
	bool		addServerMsg = true;


	// Create the background
	cInternet.Draw( tMenu->bmpBuffer.get() );
	Menu_DrawBox(tMenu->bmpBuffer.get(), 200, 220, 440, 340);
	//DrawImageAdv(tMenu->bmpBuffer, tMenu->bmpMainBack, 202,222, 202,222, 237,117);
    DrawRectFill(tMenu->bmpBuffer.get(), 202,222,439,339,tLX->clDialogBackground);
	for(int i=0;i<6;i++)
		cNetButtons[i].Draw(tMenu->bmpBuffer.get());
	Menu_RedrawMouse(true);


	cAddSvr.Initialize();
	cAddSvr.Add( new CButton(BUT_ADD, tMenu->bmpButtons),	na_Add, 220, 320, 40,15);
	cAddSvr.Add( new CButton(BUT_CANCEL, tMenu->bmpButtons),na_Cancel, 350, 320, 70,15);
	cAddSvr.Add( new CLabel("Add a server", tLX->clNormalLabel),		-1,275, 225, 0, 0);
	cAddSvr.Add( new CLabel("Address", tLX->clNormalLabel),				-1,215, 267, 0, 0);
	cAddSvr.Add( new CTextbox(),							na_Address, 280, 265, 140, tLX->cFont.GetHeight());

	ProcessEvents();
	while(!WasKeyboardEventHappening(SDLK_ESCAPE,false) && addServerMsg && tMenu->bMenuRunning) {
		Menu_RedrawMouse(true);
		DrawImageAdv(VideoPostProcessor::videoSurface(),tMenu->bmpBuffer, 200,220, 200,220, 240, 240);

		ProcessEvents();

		// Process the server list
		if( SvrList_Process() ) {
			// Add the servers to the listview
			Menu_Net_NET_ServerList_Refresher();
		}

		cAddSvr.Draw( VideoPostProcessor::videoSurface() );
		ev = cAddSvr.Process();

		// Process any events
		if(ev) {

			switch(ev->iControlID) {

				// Add
				case na_Add:
					if(ev->iEventMsg == BTN_CLICKED) {

						std::string addr;
						cAddSvr.SendMessage(na_Address, TXS_GETTEXT, &addr, 0);

						SvrList_AddServer(addr, true);
						Menu_Net_NET_ServerList_Refresher();

						// Click!
						PlaySoundSample(sfxGeneral.smpClick);

						addServerMsg = false;
					}
					break;

				// Cancel
				case na_Cancel:
					if(ev->iEventMsg == BTN_CLICKED) {
						// Click!
						PlaySoundSample(sfxGeneral.smpClick);

						addServerMsg = false;
					}
					break;
			}
		}


		DrawCursor(VideoPostProcessor::videoSurface());
		doVideoFrameInMainThread();
		CapFPS();
	}


	cAddSvr.Shutdown();

	// Re-draw the background
	DrawImage(tMenu->bmpBuffer.get(),tMenu->bmpMainBack_common,0,0);
	Menu_DrawSubTitle(tMenu->bmpBuffer.get(),SUB_NETWORK);
	if (tMenu->tFrontendInfo.bPageBoxes)
		Menu_DrawBox(tMenu->bmpBuffer.get(), 15,130, 625, 465);
	Menu_RedrawMouse(true);
}

	
		
///////////////////
// Update the server list
void Menu_Net_NETUpdateList()
{
	SvrList_UpdateList();
}
	
	
enum  {
	nd_Ok=0,
	nd_Refresh,
	nd_Join
};

///////////////////
// Show a server's details
void Menu_Net_NETShowServer(const std::string& szAddress)
{
    CGuiLayout  cDetails;

    // Create the buffer
    DrawImage(tMenu->bmpBuffer.get(),tMenu->bmpMainBack_common,0,0);
    Menu_DrawBox(tMenu->bmpBuffer.get(), 15,130, 625, 465);
	Menu_DrawSubTitle(tMenu->bmpBuffer.get(),SUB_NETWORK);
	cInternet.Draw(tMenu->bmpBuffer.get());

	//for(ushort i=1;i<4;i++)
	//	cNetButtons[i].Draw(tMenu->bmpBuffer.get());

	Menu_RedrawMouse(true);

	int center = VideoPostProcessor::videoSurface()->w/2;
	int y = VideoPostProcessor::videoSurface()->h/2 - INFO_H/2;
	
    cDetails.Initialize();
	cDetails.Add( new CButton(BUT_REFRESH, tMenu->bmpButtons),  nd_Refresh,	center - 105, y+INFO_H-20, 85,15);
    cDetails.Add( new CButton(BUT_JOIN, tMenu->bmpButtons),	    nd_Join,    center, y+INFO_H-20, 40,45);
	cDetails.Add( new CButton(BUT_OK, tMenu->bmpButtons),	    nd_Ok,      center + 60, y+INFO_H-20, 40,15);
	((CButton *)cDetails.getWidget(nd_Refresh))->setRedrawMenu(false);
	((CButton *)cDetails.getWidget(nd_Ok))->setRedrawMenu(false);
	((CButton *)cDetails.getWidget(nd_Join))->setRedrawMenu(false);

	bGotDetails = false;
	bOldLxBug = false;
	nTries = 0;
	fStart = AbsTime();

    while(!WasKeyboardEventHappening(SDLK_ESCAPE,false) && tMenu->bMenuRunning) {
		tLX->currentTime = GetTime();

		Menu_RedrawMouse(true);
		ProcessEvents();
		//DrawImageAdv(VideoPostProcessor::videoSurface(),tMenu->bmpBuffer, 200,220, 200,220, 240, 240);

		Menu_SvrList_DrawInfo(szAddress, INFO_W, INFO_H);

        cDetails.Draw(VideoPostProcessor::videoSurface());
        gui_event_t *ev = NULL;

		ev = cDetails.Process();
        if(ev) {

			// Ok
            if(ev->iControlID == nd_Ok && ev->iEventMsg == BTN_CLICKED) {
                break;
			// Refresh
            } else if (ev->iControlID == nd_Refresh && ev->iEventMsg == BTN_CLICKED)  {
				fStart = AbsTime();
				bGotDetails = false;
				bOldLxBug = false;
				nTries = 0;
			} else if (ev->iControlID == nd_Join && ev->iEventMsg == BTN_CLICKED)  {
                // Save the list
                SvrList_Save();

				lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1);

				// Join
				if (sub)
					Menu_Net_NETJoinServer(szAddress, sub->sText);

				break;
			}
        }

        DrawCursor(VideoPostProcessor::videoSurface());
		doVideoFrameInMainThread();
		CapFPS();
    }

	cDetails.Shutdown();


    // Redraw the background
	DrawImage(tMenu->bmpBuffer.get(),tMenu->bmpMainBack_common,0,0);
	if (tMenu->tFrontendInfo.bPageBoxes)
		Menu_DrawBox(tMenu->bmpBuffer.get(), 15,130, 625, 465);
	Menu_DrawSubTitle(tMenu->bmpBuffer.get(),SUB_NETWORK);
	Menu_RedrawMouse(true);
}

}; // namespace DeprecatedGUI
///////////////////
// Net Internet frame
void Menu_Net_NETFrame(int mouse)
{
	gui_event_t *ev = NULL;
	std::string	addr;


	// Process & Draw the gui
	ev = cInternet.Process();
	cInternet.Draw( VideoPostProcessor::videoSurface() );


	// Process the server list
	static bool wasLoadedBefore = false;
	if( SvrList_Process() || (tIpToCountryDB->Loaded() && !wasLoadedBefore) ) {
		// Add the servers to the listview
		Menu_Net_NET_ServerList_Refresher();
		wasLoadedBefore = tIpToCountryDB->Loaded();
	}



	// Process any events
	if(ev) {

		switch(ev->iControlID) {

			// Add Server
			case mi_AddServer:
				if(ev->iEventMsg == BTN_CLICKED) {
					// Click!
					PlaySoundSample(sfxGeneral.smpClick);

					Menu_Net_NETAddServer();
				}
				break;

			// Back
			case mi_Back:
				if(ev->iEventMsg == BTN_CLICKED) {

					// Shutdown
					Menu_Net_NETShutdown();

					// Click!
					PlaySoundSample(sfxGeneral.smpClick);

					// Back to main menu
					Menu_MainInitialize();
				}
				break;

			// Refresh
			case mi_Refresh:
				if(ev->iEventMsg == BTN_CLICKED) {

					// Click!
					PlaySoundSample(sfxGeneral.smpClick);

					// Refresh the currently visible servers
					SvrList_RefreshList();
					Menu_Net_NET_ServerList_Refresher();
				}
				break;

			// Join
			case mi_Join:
                if(ev->iEventMsg == BTN_CLICKED) {

					addr = "";
					int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0);
					if(result != -1 && addr != "") {

                        // Save the list
                        SvrList_Save();

						// Click!
						PlaySoundSample(sfxGeneral.smpClick);

						lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1);

						// Join
						if (sub)
							Menu_Net_NETJoinServer(addr,sub->sText);
						return;
					}
				}
				break;

			// Serverlist
			case mi_ServerList:

                // Double click
				if(ev->iEventMsg == LV_DOUBLECLK) {

					/*
					  Now.... Should a double click refresh the server (like tribes)?
					  Or should it join the server like other games???
					*/

					// Just join for the moment
					addr = "";
					int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0);
					lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1);
					if(result != -1 && addr != "" && sub) {
                        // Save the list
                        SvrList_Save();

						Menu_Net_NETJoinServer(addr,sub->sText);
						return;
					}
				}

                // Right click
                if( ev->iEventMsg == LV_RIGHTCLK ) {
                    addr = "";
					int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0);
					if(result && addr != "") {
                        // Display a menu
                        szNetCurServer = addr;
                        mouse_t *m = GetMouse();

                        cInternet.Add( new CMenu(m->X, m->Y), mi_PopupMenu, 0,0, 640,480 );
                        cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Delete server",				0 );
                        cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Refresh server",				1 );
                        cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Join server",				2 );
						cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Add to favourites",			3 );
						cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Send \"I want to join message\"",4 );
						cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Copy IP to clipboard",		5 );
                        cInternet.SendMessage( mi_PopupMenu, MNS_ADDITEM, "Server details",				6 );
                    }
                }


				// Enter key
				if( ev->iEventMsg == LV_ENTER )  {
					// Join
					addr = "";
					int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0);
					lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1);
					if(result != -1 && addr != "" && sub) {
                        // Save the list
                        SvrList_Save();

						Menu_Net_NETJoinServer(addr,sub->sText);
						return;
					}
				}

				// Delete
				if( ev->iEventMsg == LV_DELETE )  {
					addr = "";
					int result = cInternet.SendMessage(mi_ServerList, LVS_GETCURSINDEX, &addr, 0);
					if(result && addr != "") {
						SvrList_RemoveServer(addr);
						// Re-Fill the server list
						Menu_Net_NET_ServerList_Refresher();
					}
				}
				break;

            // Popup menu
            case mi_PopupMenu:
                switch( ev->iEventMsg ) {
                    // Delete the server
                    case MNU_USER+0:
                        SvrList_RemoveServer(szNetCurServer);
                        break;

                    // Refresh the server
                    case MNU_USER+1:
                        {
							server_t::Ptr sv = SvrList_FindServerStr(szNetCurServer);
                            if(sv)
                                SvrList_RefreshServer(sv);
                        }
                        break;

                    // Join a server
                    case MNU_USER+2:  {
                        // Save the list
                        SvrList_Save();
						lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1);
						if (sub)
							Menu_Net_NETJoinServer(szNetCurServer,sub->sText);
						}
                        return;

                    // Add server to favourites
                    case MNU_USER+3:
						{
							server_t::Ptr sv = SvrList_FindServerStr(szNetCurServer);
							if (sv)
								SvrList_AddFavourite(sv->szName,sv->szAddress);
						}
                        break;

					// Send a "wants to join" message
                    case MNU_USER+4:
						{
							server_t::Ptr sv = SvrList_FindServerStr(szNetCurServer);
							std::string Nick;
							cInternet.SendMessage(mi_PlayerSelection, CBS_GETCURNAME, &Nick, 0);
							if (sv)
								SvrList_WantsJoin(Nick, sv);
						}
                        break;

					// Copy the IP to clipboard
					case MNU_USER+5:
						{
							copy_to_clipboard(szNetCurServer);
						}
						break;

                    // Show server details
                    case MNU_USER+6:
						cInternet.removeWidget(mi_PopupMenu);
                        Menu_Net_NETShowServer(szNetCurServer);
                        break;
                }

                // Re-Fill the server list
				Menu_Net_NET_ServerList_Refresher();

                // Remove the menu widget
                cInternet.SendMessage( mi_PopupMenu, MNM_REDRAWBUFFER, (DWORD)0, 0);
                cInternet.removeWidget(mi_PopupMenu);
                break;

			// Update server list
			case mi_UpdateList:
				if(ev->iEventMsg == BTN_CLICKED) {
					// Click!
					PlaySoundSample(sfxGeneral.smpClick);

					Menu_Net_NETUpdateList();
				}
				break;
		}

	}

	// F5 updates the list
	if (WasKeyboardEventHappening(SDLK_F5))
		Menu_Net_NETUpdateList();

	// Draw the mouse
	DrawCursor(VideoPostProcessor::videoSurface());

}
Beispiel #11
0
namespace DeprecatedGUI {

CGuiLayout	cChat;
static bool cChatGuiInitialized;

enum {
	nc_Back = 0,
	nc_EnableChat,
	nc_EnableMiniChat,
	nc_Chat
};


///////////////////
// Initialize the news net menu
bool Menu_Net_ChatInitialize()
{
	iNetMode = net_chat;

	// Setup the gui layout
	cChat.Shutdown();
	cChat.Initialize();

	cChat.Add( new CButton(BUT_BACK, tMenu->bmpButtons), nc_Back, 25,440, 50,15);

	cChat.Add( new CChatWidget(), nc_Chat, 25, 140, 585, 280);
	cChat.Add( new CCheckbox(tLXOptions->bEnableChat), nc_EnableChat, 100, 440, 20, 20);
	cChat.Add( new CLabel("Enable", tLX->clNormalLabel), -1, 130, 440, 0, 0);

	cChat.Add( new CCheckbox(tLXOptions->bEnableMiniChat), nc_EnableMiniChat, 350, 440, 20, 20);
	cChat.Add( new CLabel("Mini chat in server list", tLX->clNormalLabel), -1, 380, 440, 0, 0);

	cChatGuiInitialized = true;
	return true;
}

//////////////////
// Shutdown the news menu
void Menu_Net_ChatShutdown()
{
	cChatGuiInitialized = false;
	cChat.Shutdown();
}


///////////////////
// The net news menu frame
void Menu_Net_ChatFrame(int mouse)
{
	gui_event_t *ev = NULL;


	// Process & Draw the gui
	ev = cChat.Process();
	cChat.Draw( VideoPostProcessor::videoSurface() );


	// Process any events
	if(ev) {

		switch(ev->iControlID) {

			// Back
			case nc_Back:
				if(ev->iEventMsg == BTN_CLICKED) {

					// Click!
					PlaySoundSample(sfxGeneral.smpClick);

					// Shutdown
					Menu_Net_ChatShutdown();

					// Back to main menu
					Menu_MainInitialize();
				}
				break;


			case nc_EnableChat:
				if(ev->iEventMsg == CHK_CHANGED) {
					
					PlaySoundSample(sfxGeneral.smpClick);
					tLXOptions->bEnableChat = cChat.SendMessage(nc_EnableChat, CKM_GETCHECK, 1, 1) != 0;
					if (!tLXOptions->bEnableChat)
					{
						((CChatWidget *)cChat.getWidget(nc_Chat))->DisableChat();
						ShutdownIRC();
					}
					else
					{
						InitializeIRC();
						((CChatWidget *)cChat.getWidget(nc_Chat))->EnableChat();
					}
				}
				break;

			case nc_EnableMiniChat:
				if(ev->iEventMsg == CHK_CHANGED) {
					PlaySoundSample(sfxGeneral.smpClick);
					tLXOptions->bEnableMiniChat = cChat.SendMessage(nc_EnableMiniChat, CKM_GETCHECK, 1, 1) != 0;
				}
				break;
		}

	}


	// Draw the mouse
	DrawCursor(VideoPostProcessor::videoSurface());
}

}; // namespace DeprecatedGUI
Beispiel #12
0
///////////////////
// Challenge the opponent
void Dnr_ChallengeOpponent(int nLevel, int nType)
{
    psDiner->bOppClicked = true;
    psDiner->bGoodOffer = false;

    // Setup the racing gui
    cDinerLayout.Initialize();

    // Level 1
    // Top level choice
    if(nLevel == 0) {
        cDinerLayout.Add( new CButton("Drag race",-1),          dng_drag,   335,230,0,  0);
        cDinerLayout.Add( new CButton("Road race",-1),          dng_road,   335,280,0,  0);
        cDinerLayout.Add( new CButton("Forget it",-1),          dng_cancel, 335,330,0,  0);
        cDinerLayout.Add( new CDialog("Race", dlgs_small),      dng_dlg,    0,  0,  230,200);
    }

    // Level 2
    // Location
    if(nLevel == 1) {
        // Drag
        if(nType == 0) {
            for(int i=0; i<psDiner->nNumDragTracks; i++) {
                cDinerLayout.Add(new CButton(psDiner->sDragTracks[i].szName,-1),   dng_dragtrk1+i,   335,230+i*5,0,  0);

                CButton *b = ((CButton *)cDinerLayout.getWidget(dng_dragtrk1+i));
                if(b)
                    b->setSize(10);
            }

            cDinerLayout.Add( new CButton("Forget it",-1),          dng_cancel, 335,330,0,  0);
            cDinerLayout.Add( new CDialog("Race", dlgs_small),      dng_dlg,    0,  0,  230,200);
        }
    }

    // Level 3
    // Bet
    if(nLevel == 2) {
        // Drag
        if(nType == 0) {
            cDinerLayout.Add( new CButton("For kicks",-1),          dng_dragkicks,   335,220,0,  0);
            cDinerLayout.Add( new CButton("$10",-1),                dng_drag10,      335,260,0,  0);
            cDinerLayout.Add( new CButton("$50",-1),                dng_drag50,      335,300,0,  0);

            cDinerLayout.Add( new CButton("Back",-1),               dng_dragback,    335,350,0,  0);
            cDinerLayout.Add( new CDialog("Race", dlgs_small),      dng_dlg,    0,  0,  230,200);
        }

    }

    cDinerLayout.moveWidgets(-270, 180);
}
Beispiel #13
0
///////////////////
// Change a part
void Gar_ChangePart(void)
{
	mouse_t *mouse = System_GetMouse();


    // Process an escape
    /*if( System_GetKeyboard()->KeyUp[SDLK_ESCAPE] ) {
        // Go up a level
		if(tGarage->iState == GAR_ENGINEPART) {
			Gar_Part2Engine();
		}
		if(tGarage->iState == GAR_RUNGPART) {
			tGarage->iState = GAR_RUNNINGG;
			Gar_Part2RunningG();
		}
        return;
    }*/

    // Draw the part information
    cGarLocation->drawPartInfo(tPartChange.cPart, 1);


    // Process the change part dialog box
    cPartDlg.Draw();
    gui_event_t *ev = cPartDlg.Process();
    if( ev ) {
        switch(ev->iControlID) {

            // Add all / Remove all
            case 1:
                if( ev->iEventMsg == BUT_CLICKED ) {

                    if( tPartChange.iNutsGoingon ) {
                        // Put all the nuts on
                        tPartChange.cPart->putNutsOn();
                        Gar_FinishAddPart();
                    } else {

                        // Remove all the nuts
                        Gar_RemovePart();
                    }

                    cPartDlg.Shutdown();
                    return;

                }
                break;

            // Repair
            case 2:
                if( ev->iEventMsg == BUT_CLICKED ) {

                    // Parts with more then 50% damage cannot be repaired
                    if( tPartChange.cPart->getDamage() >= 50 ) {
                        Gar_InitSpeechBubble("The part is too damaged to be repaired");
                        return;
                    }

                    // Can we afford to repair the part?
                    if( !cMainGuy->canBuy( tPartChange.cPart->repairCost() ) ) {
                        Gar_InitSpeechBubble("You ain't got enough cash buddy");
                        return;
                    }

                    // Repair the part
                    int cost = tPartChange.cPart->repair();
                    cMainGuy->makePurchase(cost);
                }
                break;

            // Forget it
            case 3:
                if( ev->iEventMsg == BUT_CLICKED ) {

                    // If this part is coming off but was cancelled; put all the nuts back on
                    if( !tPartChange.iNutsGoingon )
                        tPartChange.cPart->putNutsOn();
                    else {
                        // Remove the part
                        Gar_RemovePart();
                    }


                    // Go up a level
		            if(tGarage->iState == GAR_ENGINEPART) {
			            Gar_Part2Engine();
		            }
		            if(tGarage->iState == GAR_RUNGPART) {
			            tGarage->iState = GAR_RUNNINGG;
			            Gar_Part2RunningG();
		            }

                    cPartDlg.Shutdown();
                    return;
                }
                break;
        }

    }


	CVec dir = tGarage->mousePoint - cGarLocation->getCamPos();
	VectorNormalize(&dir);

	// Check if any of the nuts are highlighted
	int n = tPartChange.cPart->LineIntersectNut(cGarLocation->getCamPos(),dir);

	if(n == -1)
		return;
	CNut *nut = tPartChange.cPart->getNut(n);

	// Left clicking does the work
	if(mouse->Up & SDL_BUTTON(1)) {

        // If the nuts are going on, left clicking on a nut puts the nut in
        if( tPartChange.iNutsGoingon ) {

            // Do ratchet noise
            if( !nut->getIn() )
		        BASS_SamplePlay(sfxParts.smpRatchet);

            nut->setIn(true);

            // If the nuts are all on the part, then we finish adding the part
            if( tPartChange.cPart->AllNutsOn() )
                Gar_FinishAddPart();
        } else {

            // If the nuts are coming off, left clicking on a nut removes it

            // Do ratchet noise
            if( nut->getIn() )
		        BASS_SamplePlay(sfxParts.smpRatchet);

            nut->setIn(false);

            // If all the nuts are gone, remove the part from the car
            // and put it into the player's spare parts
            if( tPartChange.cPart->AllNutsGone() )
                Gar_RemovePart();
        }
    }

    // Highlight the nut
	nut->setHighlight(true);
	cGarLocation->setStatusText((char *)(nut->getIn() ? "Undo nut" : "Put nut"));
}
void Menu_Net_NET_ServerList_Refresher() {
	Menu_SvrList_FillList( (CListview *)cInternet.getWidget( mi_ServerList ), SLFT_CustomSettings, SvrListSettingsFilter::Load(tLXOptions->sSvrListSettingsFilterCfg) );
}
void Menu_Net_NETAddServer()
{
	CGuiLayout	cAddSvr;
	gui_event_t *ev = NULL;
	bool		addServerMsg = true;


	// Create the background
	cInternet.Draw( tMenu->bmpBuffer.get() );
	Menu_DrawBox(tMenu->bmpBuffer.get(), 200, 220, 440, 340);
	//DrawImageAdv(tMenu->bmpBuffer, tMenu->bmpMainBack, 202,222, 202,222, 237,117);
    DrawRectFill(tMenu->bmpBuffer.get(), 202,222,439,339,tLX->clDialogBackground);
	for(int i=0;i<6;i++)
		cNetButtons[i].Draw(tMenu->bmpBuffer.get());
	Menu_RedrawMouse(true);


	cAddSvr.Initialize();
	cAddSvr.Add( new CButton(BUT_ADD, tMenu->bmpButtons),	na_Add, 220, 320, 40,15);
	cAddSvr.Add( new CButton(BUT_CANCEL, tMenu->bmpButtons),na_Cancel, 350, 320, 70,15);
	cAddSvr.Add( new CLabel("Add a server", tLX->clNormalLabel),		-1,275, 225, 0, 0);
	cAddSvr.Add( new CLabel("Address", tLX->clNormalLabel),				-1,215, 267, 0, 0);
	cAddSvr.Add( new CTextbox(),							na_Address, 280, 265, 140, tLX->cFont.GetHeight());

	ProcessEvents();
	while(!WasKeyboardEventHappening(SDLK_ESCAPE,false) && addServerMsg && tMenu->bMenuRunning) {
		Menu_RedrawMouse(true);
		DrawImageAdv(VideoPostProcessor::videoSurface(),tMenu->bmpBuffer, 200,220, 200,220, 240, 240);

		ProcessEvents();

		// Process the server list
		if( SvrList_Process() ) {
			// Add the servers to the listview
			Menu_Net_NET_ServerList_Refresher();
		}

		cAddSvr.Draw( VideoPostProcessor::videoSurface() );
		ev = cAddSvr.Process();

		// Process any events
		if(ev) {

			switch(ev->iControlID) {

				// Add
				case na_Add:
					if(ev->iEventMsg == BTN_CLICKED) {

						std::string addr;
						cAddSvr.SendMessage(na_Address, TXS_GETTEXT, &addr, 0);

						SvrList_AddServer(addr, true);
						Menu_Net_NET_ServerList_Refresher();

						// Click!
						PlaySoundSample(sfxGeneral.smpClick);

						addServerMsg = false;
					}
					break;

				// Cancel
				case na_Cancel:
					if(ev->iEventMsg == BTN_CLICKED) {
						// Click!
						PlaySoundSample(sfxGeneral.smpClick);

						addServerMsg = false;
					}
					break;
			}
		}


		DrawCursor(VideoPostProcessor::videoSurface());
		doVideoFrameInMainThread();
		CapFPS();
	}


	cAddSvr.Shutdown();

	// Re-draw the background
	DrawImage(tMenu->bmpBuffer.get(),tMenu->bmpMainBack_common,0,0);
	Menu_DrawSubTitle(tMenu->bmpBuffer.get(),SUB_NETWORK);
	if (tMenu->tFrontendInfo.bPageBoxes)
		Menu_DrawBox(tMenu->bmpBuffer.get(), 15,130, 625, 465);
	Menu_RedrawMouse(true);
}
Beispiel #16
0
///////////////////
// The net news menu frame
void Menu_Net_ChatFrame(int mouse)
{
	gui_event_t *ev = NULL;


	// Process & Draw the gui
	ev = cChat.Process();
	cChat.Draw( VideoPostProcessor::videoSurface() );


	// Process any events
	if(ev) {

		switch(ev->iControlID) {

			// Back
			case nc_Back:
				if(ev->iEventMsg == BTN_CLICKED) {

					// Click!
					PlaySoundSample(sfxGeneral.smpClick);

					// Shutdown
					Menu_Net_ChatShutdown();

					// Back to main menu
					Menu_MainInitialize();
				}
				break;


			case nc_EnableChat:
				if(ev->iEventMsg == CHK_CHANGED) {
					
					PlaySoundSample(sfxGeneral.smpClick);
					tLXOptions->bEnableChat = cChat.SendMessage(nc_EnableChat, CKM_GETCHECK, 1, 1) != 0;
					if (!tLXOptions->bEnableChat)
					{
						((CChatWidget *)cChat.getWidget(nc_Chat))->DisableChat();
						ShutdownIRC();
					}
					else
					{
						InitializeIRC();
						((CChatWidget *)cChat.getWidget(nc_Chat))->EnableChat();
					}
				}
				break;

			case nc_EnableMiniChat:
				if(ev->iEventMsg == CHK_CHANGED) {
					PlaySoundSample(sfxGeneral.smpClick);
					tLXOptions->bEnableMiniChat = cChat.SendMessage(nc_EnableMiniChat, CKM_GETCHECK, 1, 1) != 0;
				}
				break;
		}

	}


	// Draw the mouse
	DrawCursor(VideoPostProcessor::videoSurface());
}
Beispiel #17
0
//////////////////
// Shutdown the news menu
void Menu_Net_ChatShutdown()
{
	cChatGuiInitialized = false;
	cChat.Shutdown();
}
///////////////////
// Show a server's details
void Menu_Net_NETShowServer(const std::string& szAddress)
{
    CGuiLayout  cDetails;

    // Create the buffer
    DrawImage(tMenu->bmpBuffer.get(),tMenu->bmpMainBack_common,0,0);
    Menu_DrawBox(tMenu->bmpBuffer.get(), 15,130, 625, 465);
	Menu_DrawSubTitle(tMenu->bmpBuffer.get(),SUB_NETWORK);
	cInternet.Draw(tMenu->bmpBuffer.get());

	//for(ushort i=1;i<4;i++)
	//	cNetButtons[i].Draw(tMenu->bmpBuffer.get());

	Menu_RedrawMouse(true);

	int center = VideoPostProcessor::videoSurface()->w/2;
	int y = VideoPostProcessor::videoSurface()->h/2 - INFO_H/2;
	
    cDetails.Initialize();
	cDetails.Add( new CButton(BUT_REFRESH, tMenu->bmpButtons),  nd_Refresh,	center - 105, y+INFO_H-20, 85,15);
    cDetails.Add( new CButton(BUT_JOIN, tMenu->bmpButtons),	    nd_Join,    center, y+INFO_H-20, 40,45);
	cDetails.Add( new CButton(BUT_OK, tMenu->bmpButtons),	    nd_Ok,      center + 60, y+INFO_H-20, 40,15);
	((CButton *)cDetails.getWidget(nd_Refresh))->setRedrawMenu(false);
	((CButton *)cDetails.getWidget(nd_Ok))->setRedrawMenu(false);
	((CButton *)cDetails.getWidget(nd_Join))->setRedrawMenu(false);

	bGotDetails = false;
	bOldLxBug = false;
	nTries = 0;
	fStart = AbsTime();

    while(!WasKeyboardEventHappening(SDLK_ESCAPE,false) && tMenu->bMenuRunning) {
		tLX->currentTime = GetTime();

		Menu_RedrawMouse(true);
		ProcessEvents();
		//DrawImageAdv(VideoPostProcessor::videoSurface(),tMenu->bmpBuffer, 200,220, 200,220, 240, 240);

		Menu_SvrList_DrawInfo(szAddress, INFO_W, INFO_H);

        cDetails.Draw(VideoPostProcessor::videoSurface());
        gui_event_t *ev = NULL;

		ev = cDetails.Process();
        if(ev) {

			// Ok
            if(ev->iControlID == nd_Ok && ev->iEventMsg == BTN_CLICKED) {
                break;
			// Refresh
            } else if (ev->iControlID == nd_Refresh && ev->iEventMsg == BTN_CLICKED)  {
				fStart = AbsTime();
				bGotDetails = false;
				bOldLxBug = false;
				nTries = 0;
			} else if (ev->iControlID == nd_Join && ev->iEventMsg == BTN_CLICKED)  {
                // Save the list
                SvrList_Save();

				lv_subitem_t *sub = ((CListview *)cInternet.getWidget(mi_ServerList))->getCurSubitem(1);

				// Join
				if (sub)
					Menu_Net_NETJoinServer(szAddress, sub->sText);

				break;
			}
        }

        DrawCursor(VideoPostProcessor::videoSurface());
		doVideoFrameInMainThread();
		CapFPS();
    }

	cDetails.Shutdown();


    // Redraw the background
	DrawImage(tMenu->bmpBuffer.get(),tMenu->bmpMainBack_common,0,0);
	if (tMenu->tFrontendInfo.bPageBoxes)
		Menu_DrawBox(tMenu->bmpBuffer.get(), 15,130, 625, 465);
	Menu_DrawSubTitle(tMenu->bmpBuffer.get(),SUB_NETWORK);
	Menu_RedrawMouse(true);
}
Beispiel #19
0
///////////////////
// Load the diner
bool Dnr_Load(char *szDir)
{
    char buf[256];

    // Allocate the structures
    psDiner = new diner_t;
    if( !psDiner )
        return false;

    psDiner->pcLocation = new CLocation;
    if( !psDiner ) {
        delete psDiner;
        psDiner = NULL;
        return false;
    }

    psDiner->bProcessDiner = true;
    psDiner->bSpeechBubble = false;
    psDiner->bGoodOffer = false;
    psDiner->bRacing = false;

    // Load the diner scene
    sprintf(buf,"%s/diner",szDir);
    Tex_AddDir(buf);

	sprintf(buf,"%s/diner/diner",szDir);
    if(!psDiner->pcLocation->Load(buf)) {
        delete psDiner->pcLocation;
        delete psDiner;
        psDiner = NULL;
		return false;
    }

    sprintf(buf,"%s/diner",szDir);
    Tex_RemoveDir(buf);

    psDiner->pcLocation->lockCamera();
    psDiner->pcLocation->SetupCamera(CVec(25,-60,5), 30);
    psDiner->pcLocation->setCamPos(CVec(25,-90,9));

    psDiner->psSideDoor = Cache_LoadTexture("data/textures/sidedoor.png");
    Tex_Upload(psDiner->psSideDoor);

    // Setup the gui layout
    cDinerLayout.Initialize();

    cDinerLayout2.Initialize();
    cDinerLayout2.Add( new CButton("Leave", -1),     0,  650, 530, 0,0);

    // Load the sky
    psDiner->cSky.Initialize();


    // Load the track details
    psDiner->nNumDragTracks = 0;
    psDiner->nNumRoadTracks = 0;

    sprintf(buf,"%s/city.sr3",szDir);
    ReadInteger(buf, "Tracks", "NumDragTracks", &psDiner->nNumDragTracks, 0);
    ReadInteger(buf, "Tracks", "NumRoadTracks", &psDiner->nNumRoadTracks, 0);

    psDiner->nNumDragTracks = MAX(MIN(psDiner->nNumDragTracks,MAX_TRACKS-1), 0);
    psDiner->nNumRoadTracks = MAX(MIN(psDiner->nNumRoadTracks,MAX_TRACKS-1), 0);

    char    trk[32];
    int     i;

    // Drag
    for(i=0; i<psDiner->nNumDragTracks; i++) {
        sprintf(trk, "DragTrack%d", i+1);
        ReadString(buf, trk, "Name", psDiner->sDragTracks[i].szName, "");
        ReadString(buf, trk, "Dir", psDiner->sDragTracks[i].szDir, "");
    }

    // Road
    for(i=0; i<psDiner->nNumRoadTracks; i++) {
        sprintf(trk, "RoadTrack%d", i+1);
        ReadString(buf, trk, "Name", psDiner->sRoadTracks[i].szName, "");
        ReadString(buf, trk, "Dir", psDiner->sRoadTracks[i].szDir, "");
    }

    return true;
}
///////////////////
// Initialize the Internet menu
bool Menu_Net_NETInitialize()
{
	iNetMode = net_internet;
    szNetCurServer = "";

	cInternet.Shutdown();
	cInternet.Initialize();

	cInternet.Add( new CListview(),								mi_ServerList, 40, 180, 560, 242);
	cInternet.Add( new CButton(BUT_BACK, tMenu->bmpButtons),    mi_Back,       25, 440, 50,  15);
	cInternet.Add( new CButton(BUT_ADD, tMenu->bmpButtons),		mi_AddServer,  140,440, 40,  15);
	cInternet.Add( new CButton(BUT_REFRESH, tMenu->bmpButtons), mi_Refresh,	250,440, 83,  15);
	cInternet.Add( new CButton(BUT_UPDATELIST, tMenu->bmpButtons),	mi_UpdateList,  390,440, 125,  15);
	cInternet.Add( new CButton(BUT_JOIN, tMenu->bmpButtons),    mi_Join,		570,440, 43,  15);
	cInternet.Add( new CLabel("Select player:",tLX->clNormalLabel),-1,		125, 152, 180,15);
	cInternet.Add( new CCombobox(),								mi_PlayerSelection,		225,150, 170,  19);
	if( tLXOptions->bEnableChat && tLXOptions->bEnableMiniChat )
		cInternet.Add( new CChatWidget(),						-1,	25, 15, 585, 85 );


	/*
	  Server list columns

      Connection speed
	  Name
	  State
	  Players
	  Ping
	  Address
    */

	// Add players to the list
	profile_t *p = GetProfiles();
	bool validName = false;
	for(;p;p=p->tNext) {
		if(p->iType == PRF_COMPUTER->toInt())
			continue;

		int i = ((CCombobox*) cInternet.getWidget( mi_PlayerSelection ))->addItem(p->sName, p->sName);
		((CCombobox*) cInternet.getWidget( mi_PlayerSelection ))->setImage(p->cSkin.getPreview(), i);
		if( p->sName == tLXOptions->sLastSelectedPlayer )
			validName=true;
	}

	if( ! validName )
		tLXOptions->sLastSelectedPlayer = GetProfiles()->sName;

	((CCombobox*) cInternet.getWidget( mi_PlayerSelection ))->setCurSIndexItem( tLXOptions->sLastSelectedPlayer );

    Menu_redrawBufferRect(0, 0, 640, 480);

	cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "", tLXOptions->iInternetList[0]);
	cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "Server Name", tLXOptions->iInternetList[1]);
	cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "State", tLXOptions->iInternetList[2]);
	cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "Players", tLXOptions->iInternetList[3]);
	cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "Ping", tLXOptions->iInternetList[4]);

	if (tLXOptions->bUseIpToCountry)
	{	// Too lazy to update tLXOptions, so I'll calculate last column width from width of listview
		//int CountryColumnWidth = 21; // TODO: not used

		// HINT: because this column is optional, it is at the end of the array from options
		cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "Country", tLXOptions->iInternetList[5]);
	}

	cInternet.SendMessage( mi_ServerList, LVS_ADDCOLUMN, "Address", tLXOptions->iInternetList[6]);

	((CListview*) cInternet.getWidget( mi_ServerList ))->SetSortColumn( tLXOptions->iInternetSortColumn, true ); // Sorting

    // Load the list
	Menu_Net_NET_ServerList_Refresher();
	SvrList_UpdateUDPList();
	
	Timer("Menu_Net_NETInitialize serverlist timeout", null, NULL, SVRLIST_TIMEOUT, true).startHeadless();
	
	return true;
}
Beispiel #21
0
///////////////////
// Process the gui
void Dnr_ProcessGUI(void)
{
    gui_event_t *ev;

    // Process the bottom gui
    ev = cDinerLayout2.Process();
    if(ev) {
        // Leave button
        if(ev->iControlID == 0 && ev->iEventMsg == BUT_CLICKED) {
            psDiner->bProcessDiner = false;
            psDiner->bRacing = false;
            return;
        }
    }


    // Process the racing gui
    if(psDiner->bOppClicked) {
        ev = cDinerLayout.Process();
        if(!ev)
            return;

        switch(ev->iControlID) {

            // Cancel
            case dng_cancel:
                // Chicken
                if(ev->iEventMsg == BUT_CLICKED) {
                    // Leave
                    psDiner->bOppClicked = false;
                    psDiner->nOppState = opp_rollingout;

                    Dnr_InitSpeechBubble("Chicken");
                }
                break;

            // Drag race
            case dng_drag:
                if(ev->iEventMsg == BUT_CLICKED) {
                    sRaceInfo.nType = rc_drag;

                    // Show tracks
                    Dnr_ChallengeOpponent(1, 0);
                    return;
                }
                break;

            // Drag : track selection
            case dng_dragtrk1:      // Fall through
            case dng_dragtrk2:
            case dng_dragtrk3:
            case dng_dragtrk4:
            case dng_dragtrk5:
            case dng_dragtrk6:
            case dng_dragtrk7:
            case dng_dragtrk8:
            case dng_dragtrk9:
                if(ev->iEventMsg == BUT_CLICKED) {
                    int l = ev->iControlID - dng_dragtrk1;
                    sr_strncpy(sRaceInfo.szTrackDir, psDiner->sDragTracks[l].szDir, 127);

                    // Show bets
                    Dnr_ChallengeOpponent(2, 0);
                    return;
                }
                break;

            // Drag : Back
            case dng_dragback:
                if(ev->iEventMsg == BUT_CLICKED) {
                    // Show tracks
                    Dnr_ChallengeOpponent(1, 0);
                    return;
                }
                break;


            //
            // Drag : Bet
            //
            case dng_dragkicks:
                if(ev->iEventMsg == BUT_CLICKED) {
                    // Make an offer
                    Dnr_MakeOffer(rcb_kicks, 0);
                }
                break;

            case dng_drag10:
                if(ev->iEventMsg == BUT_CLICKED) {
                    // Make an offer
                    Dnr_MakeOffer(rcb_money, 10);
                }
                break;

            case dng_drag50:
                if(ev->iEventMsg == BUT_CLICKED) {
                    // Make an offer
                    Dnr_MakeOffer(rcb_money, 50);
                }
                break;
        }
    }
}