Example #1
0
//
// Updates the queue depth if necessary.
//
void CPageDisk::OnKillfocusEQueueDepth()
{
	Manager *manager;
	Worker *worker;

	// If the disk queue was left blank, use the previous value
	if (!m_EQueueDepth.LineLength()) {
		ShowSettings();
	}
	// Verify that the queue depth is > 0.
	else if (GetDlgItemInt(EQueueDepth) <= 0) {
		ErrorMessage("# of Outstanding I/Os cannot be 0.");
		ShowSettings();
		return;
	} else {
		// Seeing what kind of item is selected.
		switch (theApp.pView->m_pWorkerView->GetSelectedType()) {
		case WORKER:
			worker = theApp.pView->m_pWorkerView->GetSelectedWorker();
			worker->SetQueueDepth(GetDlgItemInt(EQueueDepth));
			break;
		case MANAGER:
			manager = theApp.pView->m_pWorkerView->GetSelectedManager();
			manager->SetQueueDepth(GetDlgItemInt(EQueueDepth), GenericDiskType);
			break;
		case ALL_MANAGERS:
			theApp.manager_list.SetQueueDepth(GetDlgItemInt(EQueueDepth), GenericDiskType);
			break;
		}
	}

	EnableWindow();
}
//
// Updates the maximum number of sends if necessary that can be outstanding.
// Currently this only applies to VI network servers.
//
void CPageNetwork::OnKillfocusEMaxSends()
{
	Manager *manager;
	Worker *worker;

	// If max sends was left blank, use the previous value
	if (!m_EMaxSends.LineLength()) {
		ShowSettings();
	}
	// Verify that the max sends is > 0.
	else if (GetDlgItemInt(EMaxSends) <= 0) {
		ErrorMessage("Maximum # of Outstanding Sends cannot be 0.");
		ShowSettings();
		return;
	} else {
		// Seeing what kind of item is selected.
		switch (theApp.pView->m_pWorkerView->GetSelectedType()) {
		case WORKER:
			worker = theApp.pView->m_pWorkerView->GetSelectedWorker();
			worker->SetMaxSends(GetDlgItemInt(EMaxSends));
			break;
		case MANAGER:
			manager = theApp.pView->m_pWorkerView->GetSelectedManager();
			manager->SetMaxSends(GetDlgItemInt(EMaxSends));
			break;
		case ALL_MANAGERS:
			theApp.manager_list.SetMaxSends(GetDlgItemInt(EMaxSends));
			break;
		}
	}

	EnableWindow();
}
//
// Displays the values from memory in the GUI.
//
void CPageDisk::ShowData()
{
	Manager	*manager;
	Worker	*worker;

	// Only enable the display if a disk worker or a manager with disk 
	// interfaces is selected.
	manager = theApp.pView->m_pWorkerView->GetSelectedManager();
	worker = theApp.pView->m_pWorkerView->GetSelectedWorker();
	if (( theApp.pView->m_pWorkerView->GetSelectedType() == ALL_MANAGERS) ||
		( manager && !manager->InterfaceCount( GenericDiskType ) ) ||
		( worker && !IsType( worker->Type(), GenericDiskType ) ) )
	{
		Reset();
		return;
	}

	// This is a new view of the target assignment.  
	// It has not been modified.
	selected = NULL;
	highlighted = NULL;
	// Show the target list.
	ShowTargets();
	// Set the target selection check boxes.
	ShowTargetSelection();
	// Bold the last selected item.
	ShowFocus();
	// Show the connection rate settings.
	ShowConnectionRate();
	// Show the disk specific settings.
	ShowSettings();
	// Enable the apropriate windows and redraw the page.
	EnableWindow();
}
Example #4
0
//
// Updates the disk size to access if necessary.
//
void CPageDisk::OnKillfocusEDiskSize()
{
	Manager *manager;
	Worker *worker;

	// If the disk size was left blank, use the previous value.
	if (!m_EDiskSize.LineLength())
		ShowSettings();
	else {
		// Seeing what kind of item is selected.
		switch (theApp.pView->m_pWorkerView->GetSelectedType()) {
		case WORKER:
			// Recording disk attributes.
			worker = theApp.pView->m_pWorkerView->GetSelectedWorker();
			worker->SetDiskSize(GetDlgItemInt64(EDiskSize));
			break;
		case MANAGER:
			manager = theApp.pView->m_pWorkerView->GetSelectedManager();
			manager->SetDiskSize(GetDlgItemInt64(EDiskSize));
			break;
		case ALL_MANAGERS:
			theApp.manager_list.SetDiskSize(GetDlgItemInt64(EDiskSize));
			break;
		}
	}

	EnableWindow();
}
Example #5
0
/**
 * Generic message handler
 *
 * When user clicks the save button, the terminal window settings are updated
 * and a message is send to the terminal to reflect changes. Changes are also
 * saved to disk.
 *
 * When user clicks the apply button, the terminal window settings are updated
 * and a message is send to the terminal to reflect changes.
 *
 * When user clicks the revert button, no change is made to terminal window
 * until user click save button.
 * 
 * Cancel button closes this window, discarding any changes.
 */
void SettingsWindow::HandleMessage( Message * pcMsg )
{
    switch ( pcMsg->GetCode() ) {
    case M_APPLY:
        ApplySettings();
        Application::GetInstance()->
            HandleMessage( new Message( M_REFRESH ) );
        Quit();
        break;
    case M_SAVE:
        ApplySettings();
        m_pcDestSettings->Save( false );
        Application::GetInstance()->
            HandleMessage( new Message( M_REFRESH ) );
        Quit();
        break;
    case M_CANCEL:
        Quit();
        break;
    case M_REVERT:
        m_cTempSettings.RevertToDefaults();
        ShowSettings();
        break;
    default:
        Window::HandleMessage( pcMsg );
    }
}
//
// Updates the starting sector if necessary.
//
void CPageDisk::OnKillfocusEDiskStart() 
{
	Manager *manager;
	Worker	*worker;
	// If the disk starting sector was left blank, use the previous value.
	if ( !m_EDiskStart.LineLength() )
		ShowSettings();
	else
	// Seeing what kind of item is selected.
	switch ( theApp.pView->m_pWorkerView->GetSelectedType() )
	{
	case WORKER:
		worker = theApp.pView->m_pWorkerView->GetSelectedWorker();
		worker->SetDiskStart( GetDlgItemInt( EDiskStart ) );
		break;
	case MANAGER:
		manager = theApp.pView->m_pWorkerView->GetSelectedManager();
		manager->SetDiskStart( GetDlgItemInt( EDiskStart ) );
		break;
	case ALL_MANAGERS:
		theApp.manager_list.SetDiskStart( GetDlgItemInt( EDiskStart ) );
		break;
	}

	EnableWindow();
}
Example #7
0
void QtMainWindow::SetupActions()
{
	QtMainWindowHandler *actionHandler = QtMainWindowHandler::Instance();

	//File
	connect(ui->menuFile, SIGNAL(triggered(QAction *)), actionHandler, SLOT(FileMenuTriggered(QAction *)));
	connect(ui->actionNewScene, SIGNAL(triggered()), actionHandler, SLOT(NewScene()));
	connect(ui->actionOpenScene, SIGNAL(triggered()), actionHandler, SLOT(OpenScene()));
	connect(ui->actionOpenProject, SIGNAL(triggered()), actionHandler, SLOT(OpenProject()));
	connect(ui->actionSaveScene, SIGNAL(triggered()), actionHandler, SLOT(SaveScene()));
	connect(ui->actionSaveToFolder, SIGNAL(triggered()), actionHandler, SLOT(SaveToFolderWithChilds()));
    
    ui->actionExportPVRIOS->setData(GPU_POWERVR_IOS);
    ui->actionExportPVRAndroid->setData(GPU_POWERVR_ANDROID);
    ui->actionExportTegra->setData(GPU_TEGRA);
    ui->actionExportMali->setData(GPU_MALI);
    ui->actionExportAdreno->setData(GPU_ADRENO);
    ui->actionExportPNG->setData(GPU_UNKNOWN);
	connect(ui->menuExport, SIGNAL(triggered(QAction *)), actionHandler, SLOT(ExportMenuTriggered(QAction *)));
    
    
	connect(ui->actionReloadAll, SIGNAL(triggered()), actionHandler, SLOT(RepackAndReloadTextures()));

	//View
	connect(ui->actionRestoreViews, SIGNAL(triggered()), actionHandler, SLOT(RestoreViews()));

	//Tools
	connect(ui->actionMaterialEditor, SIGNAL(triggered()), actionHandler, SLOT(Materials()));
	connect(ui->actionTextureConverter, SIGNAL(triggered()), actionHandler, SLOT(ConvertTextures()));
	connect(ui->actionHeightMapEditor, SIGNAL(triggered()), actionHandler, SLOT(HeightmapEditor()));
	connect(ui->actionTileMapEditor, SIGNAL(triggered()), actionHandler, SLOT(TilemapEditor()));
	connect(ui->actionRulerTool, SIGNAL(triggered()), actionHandler, SLOT(RulerTool()));
	connect(ui->actionShowSettings, SIGNAL(triggered()), actionHandler, SLOT(ShowSettings()));
    connect(ui->actionSquareTextures, SIGNAL(triggered()), actionHandler, SLOT(SquareTextures()));
    connect(ui->actionShowMipmapLevel, SIGNAL(triggered()), actionHandler, SLOT(ReplaceZeroMipmaps()));
    
#if defined (__DAVAENGINE_MACOS__)
    ui->menuTools->removeAction(ui->actionBeast);
#else //#if defined (__DAVAENGINE_MACOS__)
	connect(ui->actionBeast, SIGNAL(triggered()), actionHandler, SLOT(Beast()));
#endif //#if defined (__DAVAENGINE_MACOS__)
    
	//Edit
	connect(ui->actionConvertToShadow, SIGNAL(triggered()), actionHandler, SLOT(ConvertToShadow()));
    
	//Temporary hided for development-qa branch
	ui->actionEnableCameraLight->setVisible(false);
    ui->actionEnableCameraLight->setChecked(EditorSettings::Instance()->GetShowEditorCamerLight());
	connect(ui->actionEnableCameraLight, SIGNAL(triggered()), actionHandler, SLOT(CameraLightTrigerred()));

    //Help
    connect(ui->actionHelp, SIGNAL(triggered()), actionHandler, SLOT(OpenHelp()));
}
Example #8
0
/****************************************************************************
REMARKS:
Main program entry point
****************************************************************************/
int main(
    int argc,
    char *argv[])
{
    /* Now handle the query */
    if (argc >= 2 && stricmp(argv[1],"show") == 0)
        ShowSettings(0);
    else if (argc >= 3) {
        LoadDriver(0);
        opt.LCDPanelWidth = atoi(argv[1]);
        opt.LCDPanelHeight = atoi(argv[2]);
        init.SetOptions(&opt);
        GA_saveOptions(dc,&opt);
        ShowSettings(0);
        }
    else
        help();
    if (dc)
        GA_unloadDriver(dc);
    return 0;
}
//
// Resetting contents of display.
//
void CPageDisk::Reset()
{
	// Clear the target list.
	m_TTargets.DeleteAllItems();
	
	// Display the conneciton rate and disk settings.
	ShowConnectionRate();
	ShowSettings();

	selected = NULL;
	highlighted = NULL;

	EnableWindow();
}
Example #10
0
	void Viewer::ViewportMode(ScreenMode newMode)
	{
		if (m_screenMode == newMode)
		{
			return;
		}

		m_screenMode = newMode;

		if (newMode == Viewer::SM_Fullscreen)
		{
			m_userInitiatedMove = false;
			wxDisplay mon(DisplayFromPointFallback(PositionScreen()));

			m_statusBar->Show(false);
			m_previousWindowStyle = GetWindowStyle();
			SetWindowStyleFlag(wxBORDER_NONE);
			m_previousWindowRegion = wxToRect(GetRect());
			auto monRegion = wxToRect(mon.GetClientArea());

			SetSize(monRegion.Left(), monRegion.Top(), monRegion.Width(), monRegion.Height());
			m_viewPort.ActiveCursorMode(ViewPort::CursorHideAutomatic);
			Raise();
			m_userInitiatedMove = true;
		}
		else
		{
			m_userInitiatedMove = false;
			SetWindowStyleFlag(m_previousWindowStyle);
			m_statusBar->Show(m_cfg.View.ShowStatusBar);
			SetSize(m_previousWindowRegion.Left(), m_previousWindowRegion.Top(), m_previousWindowRegion.Width(), m_previousWindowRegion.Height());
			m_viewPort.ActiveCursorMode(ViewPort::CursorShow);
			m_userInitiatedMove = true;
		}

		// Make sure that the settings and adjust dialogs are on top (if running)
		InitDialogs();
		if (m_settings->IsVisible())
		{
			ShowSettings();
		}

		if (m_adjust->IsVisible())
		{
			ShowAdjust();
		}

		ImageChanged();
		UpdateImageInformation();
	}
Example #11
0
//
// Resetting contents of display.
//
void CPageDisk::Reset()
{
	// Clear the target list.
	m_TTargets.DeleteAllItems();

	// Display the conneciton rate, disk settings, and random data check.
	ShowConnectionRate();
	ShowSettings();
	ShowDataPattern();
	ShowFixedSeedValue();

	selected = NULL;
	highlighted = NULL;

	EnableWindow();
}
//
// Grays out the check boxes in the target list, clears the interface
// selection, sets the conneciton rate check box to it's 3rd state,
// and hides the content of the connection rate edit box.
//
void CPageNetwork::Reset()
{
	// Clear the target list.
	m_TTargets.DeleteAllItems();

	// Clear the interface selection.
	ShowInterface();

	// Set the connection rate check box to it's ambiguous state.
	ShowConnectionRate();
	ShowSettings();

	selected = NULL;
	highlighted = NULL;

	EnableWindow();
}
Example #13
0
void GameSetup::onOkClicked()
{
    //
    settings->shape = static_cast<Shape>(ui->boxShapes->currentIndex());

    QList<unsigned int> list1;

    if(ui->box0A->isChecked()) list1.append(0);
    if(ui->box1A->isChecked()) list1.append(1);
    if(ui->box2A->isChecked()) list1.append(2);
    if(ui->box3A->isChecked()) list1.append(3);
    if(ui->box4A->isChecked()) list1.append(4);
    if(ui->box5A->isChecked()) list1.append(5);
    if(ui->box6A->isChecked()) list1.append(6);
    if(ui->box7A->isChecked()) list1.append(7);
    if(ui->box8A->isChecked()) list1.append(8);
    if(ui->box9A->isChecked()) list1.append(9);


    settings->nToStayAlive = list1;

    list1.clear();

    if(ui->box0R->isChecked()) list1.append(0);
    if(ui->box1R->isChecked()) list1.append(1);
    if(ui->box2R->isChecked()) list1.append(2);
    if(ui->box3R->isChecked()) list1.append(3);
    if(ui->box4R->isChecked()) list1.append(4);
    if(ui->box5R->isChecked()) list1.append(5);
    if(ui->box6R->isChecked()) list1.append(6);
    if(ui->box7R->isChecked()) list1.append(7);
    if(ui->box8R->isChecked()) list1.append(8);
    if(ui->box9R->isChecked()) list1.append(9);

    settings->nToRevive = list1;

    settings->gameAreaSize = QSize(ui->lineX->text().toInt(), ui->lineY->text().toInt());
    settings->cellColor = QColor(ui->sliderR->value(),ui->sliderG->value(), ui->sliderB->value());
    settings->bkgColor = QColor(ui->sliderR_2->value(),ui->sliderG_2->value(), ui->sliderB_2->value());
    settings->Save();

    ShowSettings();

    accept();
}
void CPageNetwork::OnSelchangeDInterface()
{
	Manager *manager;
	Worker *worker;

	switch (theApp.pView->m_pWorkerView->GetSelectedType()) {
	case WORKER:
		worker = theApp.pView->m_pWorkerView->GetSelectedWorker();
		worker->SetLocalNetworkInterface(m_DInterface.GetCurSel());
		break;
	case MANAGER:
		manager = theApp.pView->m_pWorkerView->GetSelectedManager();
		manager->SetLocalNetworkInterface(m_DInterface.GetCurSel());
		break;
	}

	ShowTargets();
	ShowTargetSelection();
	ShowSettings();
	EnableWindow();
}
Example #15
0
GameSetup::GameSetup(QWidget *parent) :
    ui(new Ui::GameSetup)
{

    settings = new GameSettings();
    setCaption(i18n("Setup GameOfLife"));
    setButtons(Ok|Cancel|Help|Default);
    setDefaultButton(Ok);
    setModal(true);
    showButtonSeparator(true);
    setButtonText(Help, i18n("A&bout"));

    QWidget *main = new QWidget(this);
    setMainWidget(main);

    ui->setupUi(main);

    ui->boxShapes->addItem("Rectangle");
    ui->boxShapes->addItem("Rounded rectangle");
    ui->boxShapes->addItem("Ellipse");

    cell = QPixmap(71, 21);
    bkg = QPixmap(71, 21);


    connect(ui->sliderR, SIGNAL(valueChanged(int)), this, SLOT(onSliderRValueChanged(int)));
    connect(ui->sliderG, SIGNAL(valueChanged(int)), this, SLOT(onSliderGValueChanged(int)));
    connect(ui->sliderB, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int)));

    connect(ui->sliderR_2, SIGNAL(valueChanged(int)), this, SLOT(onSliderR_2ValueChanged(int)));
    connect(ui->sliderG_2, SIGNAL(valueChanged(int)), this, SLOT(onSliderG_2ValueChanged(int)));
    connect(ui->sliderB_2, SIGNAL(valueChanged(int)), this, SLOT(onSliderB_2ValueChanged(int)));


    connect(this, SIGNAL(okClicked()), SLOT(onOkClicked()));
    connect(this, SIGNAL(helpClicked()), SLOT(onHelpClicked()));
    connect(this, SIGNAL(defaultClicked()), SLOT(onDefaultClicked()));

    ShowSettings();
}
Example #16
0
/****************************************************************************
REMARKS:
Main program entry point
****************************************************************************/
int main(
    int argc,
    char *argv[])
{
    GA_devCtx *dc = NULL;

    /* Now handle the query */
    if (argc >= 2 && stricmp(argv[1],"show") == 0) {
        dc = LoadDriver((argc > 2) ? atoi(argv[2]) : 0);
        ShowSettings(dc);
        }
    else if (argc >= 2 && stricmp(argv[1],"showvbe") == 0) {
        dc = LoadDriver((argc > 2) ? atoi(argv[2]) : 0);
        ShowVBESettings(dc);
        }
    else if (argc >= 5 && stricmp(argv[1],"add") == 0) {
        dc = LoadDriver((argc > 5) ? atoi(argv[5]) : 0);
        AddMode(dc,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
        }
    else if (argc >= 5 && stricmp(argv[1],"addref") == 0) {
        dc = LoadDriver((argc > 5) ? atoi(argv[5]) : 0);
        AddRefresh(dc,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
        }
    else if (argc >= 5 && stricmp(argv[1],"del") == 0) {
        dc = LoadDriver((argc > 5) ? atoi(argv[5]) : 0);
        DelMode(dc,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
        }
    else if (argc >= 6 && stricmp(argv[1],"set") == 0) {
        dc = LoadDriver((argc > 6) ? atoi(argv[6]) : 0);
        SetMode(dc,atoi(argv[2]),atoi(argv[3]),atoi(argv[4]),atoi(argv[5]),
            (argc > 7) ? atoi(argv[7]) : 0);
        }
    else
        help();
    if (dc)
        GA_unloadDriver(dc);
    return 0;
}
Example #17
0
int main()
{
	
	int turn = 0;
	previousPWMSignal = readPWMSignal();
	LCD_Init();
	BTN_Init();
	Settings_Init(all_settings);
	Relay_Init();
	resetPWMParts(all_settings);

	ledON;
	/*LCD_Clear_Display();
	LCD_2buffer_begin();
	LCD_2buffer_printStr("HELLO");
	LCD_2buffer_end();
	while (1)
	{
		ledOFF;
		_delay_ms(1000);
		ledON;
		_delay_ms(1000);		
	}*/
	
	while (1)
	{
		uint8_t q = readPWMSignal();
		if (q!=previousPWMSignal)
		{
			onPWMSignalChange();			
		}
		previousPWMSignal = q;
		
		
		BTN_Process();
		_delay_ms(1);
		//LCD_Clear_Display();
		switch(current_status)
		{
			case STATUS_DEFAULT:
				DoWork();			
			break;
			case STATUS_TERM:
				ShowTerm();
			break; 
			case STATUS_SETTINGS:
				ShowSettings();
			break; 
			case STATUS_RELAY:
				ShowRelayMenu();
			break; 
			case STATUS_RESET:
				ShowReset();
			break;
		}
		

		


	}
	return 0;
}
Example #18
0
void GribSettingsDialog::ShowFittingSettings( int settings )
{
    //Hide all Parameters
    ShowSettings( B_ARROWS, false );
    ShowSettings( ISO_LINE, false );
    if(m_fIsoBarSpacing->GetItem(m_sIsoBarSpacing) != NULL)  m_fIsoBarSpacing->Detach(m_sIsoBarSpacing);
    if(m_fIsoBarVisibility->GetItem(m_sIsoBarSpacing) != NULL)  m_fIsoBarVisibility->Detach(m_sIsoBarSpacing);
    if(m_fIsoBarVisibility->GetItem(m_sIsoBarVisibility) != NULL)  m_fIsoBarVisibility->Detach(m_sIsoBarVisibility);
    ShowSettings( ISO_ABBR, false );
    ShowSettings( D_ARROWS, false  );
    ShowSettings( OVERLAY, false  );
    ShowSettings( NUMBERS, false );
    ShowSettings( PARTICLES, false );
    this->Fit();
    //Show only fitting parameters
    switch(settings){
    case GribOverlaySettings::WIND:
        ShowSettings( ISO_LINE_SHORT );
        ShowSettings( ISO_LINE );
        m_cbIsoBars->SetLabel(_("Display Isotachs"));
        ShowSettings( B_ARROWS );
        ShowSettings( OVERLAY );
        ShowSettings( NUMBERS );
        ShowSettings( PARTICLES );
        break;
    case GribOverlaySettings::WIND_GUST:
        ShowSettings( ISO_LINE_SHORT );
        ShowSettings( ISO_LINE );
        m_cbIsoBars->SetLabel(_("Display Isotachs"));
        ShowSettings( OVERLAY );
        ShowSettings( NUMBERS );
        break;
    case GribOverlaySettings::PRESSURE:
        ShowSettings( ISO_LINE_VISI );
        ShowSettings( ISO_LINE );
        m_cbIsoBars->SetLabel(_("Display Isobars"));
        ShowSettings( ISO_ABBR );
        ShowSettings( NUMBERS );
        break;
    case GribOverlaySettings::CURRENT:
        ShowSettings( PARTICLES ); // should we allow particles for waves?
    case GribOverlaySettings::WAVE:
        ShowSettings( D_ARROWS );
        ShowSettings( OVERLAY );
        ShowSettings( NUMBERS );
        break;
    case GribOverlaySettings::PRECIPITATION:
    case GribOverlaySettings::CLOUD:
        ShowSettings( OVERLAY );
        ShowSettings( NUMBERS );
        break;
    case GribOverlaySettings::AIR_TEMPERATURE:
    case GribOverlaySettings::SEA_TEMPERATURE:
        ShowSettings( ISO_LINE_SHORT );
        ShowSettings( ISO_LINE );
        m_cbIsoBars->SetLabel(_("Display Isotherms"));
        ShowSettings( OVERLAY );
        ShowSettings( NUMBERS );
        break;
    case GribOverlaySettings::CAPE:
        ShowSettings( ISO_LINE_SHORT );
        ShowSettings( ISO_LINE );
        m_cbIsoBars->SetLabel(_("Display Iso CAPE"));
        ShowSettings( OVERLAY );
        ShowSettings( NUMBERS );
        break;
    case GribOverlaySettings::COMP_REFL:
        ShowSettings( ISO_LINE_SHORT );
        ShowSettings( ISO_LINE );
        m_cbIsoBars->SetLabel(_("Display Comp. Reflectivity"));
        ShowSettings( OVERLAY );
        ShowSettings( NUMBERS );
        break;
    }

	wxString l = (m_lastdatatype == GribOverlaySettings::PRESSURE && m_cDataUnits->GetSelection() == GribOverlaySettings::INHG) ? _T("(0.03 " ) : _T("(");
	m_tIsoBarSpacing->SetLabel( wxString(_("Spacing")).Append(l).Append(m_Settings.GetUnitSymbol( m_lastdatatype ) ).Append( _T(")") ) );
}
Example #19
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	static uint32_t lanLastPing = 0;
	static HFONT _hFont = 0;
	switch (message)
	{
	case WM_CREATE:
	{
		HFONT hFont = 0;

		NONCLIENTMETRICS ncm = { sizeof(ncm) };
		if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0))
		{
			hFont = CreateFontIndirect(&ncm.lfMessageFont);
			_hFont = hFont;
		}
		if (!hFont)
			hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);

		RECT rcClient;
		GetClientRect(hWnd, &rcClient);

		g_hWndListViewServers = CreateWindow(WC_LISTVIEW, nullptr, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | LVS_REPORT | LVS_SHOWSELALWAYS | LVS_AUTOARRANGE | LVS_OWNERDATA, 1, 21, rcClient.right - UI_PLAYERLIST_WIDTH - 4, rcClient.bottom - UI_SERVERINFO_HEIGHT - 21 - 2, hWnd, nullptr, g_hInst, nullptr);
		if (g_hWndListViewServers)
		{
			SetWindowTheme(g_hWndListViewServers, L"Explorer", nullptr);
			ListView_SetExtendedListViewStyle(g_hWndListViewServers, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);

			LVCOLUMN lvc;
			lvc.mask = LVCF_WIDTH;
			lvc.cx = 30;
			ListView_InsertColumn(g_hWndListViewServers, 0, &lvc);

			lvc.mask = LVCF_WIDTH | LVCF_TEXT;
			lvc.cx = 240;
			lvc.pszText = LoadStr(L"Server Name", IDS_SERVERNAME);
			ListView_InsertColumn(g_hWndListViewServers, 1, &lvc);

			lvc.cx = 60;
			lvc.pszText = LoadStr(L"Ping", IDS_PING);
			ListView_InsertColumn(g_hWndListViewServers, 2, &lvc);

			lvc.cx = 80;
			lvc.pszText = LoadStr(L"Players", IDS_PLAYERS);
			ListView_InsertColumn(g_hWndListViewServers, 3, &lvc);

			lvc.cx = 70;
			lvc.pszText = LoadStr(L"Version", IDS_VERSION);
			ListView_InsertColumn(g_hWndListViewServers, 4, &lvc);

			lvc.cx = 120;
			lvc.pszText = LoadStr(L"Gamemode", IDS_GAMEMODE);
			ListView_InsertColumn(g_hWndListViewServers, 5, &lvc);

			lvc.cx = 100;
			lvc.pszText = LoadStr(L"Map Name", IDS_MAPNAME);
			ListView_InsertColumn(g_hWndListViewServers, 6, &lvc);
		}

		g_hWndListViewHistory = CreateWindow(WC_LISTVIEW, nullptr, WS_CHILD | WS_CLIPSIBLINGS | LVS_REPORT | LVS_SHOWSELALWAYS | LVS_AUTOARRANGE | LVS_OWNERDATA, 1, 21, rcClient.right - UI_PLAYERLIST_WIDTH - 4, rcClient.bottom - UI_SERVERINFO_HEIGHT - 21 - 2, hWnd, nullptr, g_hInst, nullptr);
		if (g_hWndListViewHistory)
		{
			SetWindowTheme(g_hWndListViewHistory, L"Explorer", nullptr);
			ListView_SetExtendedListViewStyle(g_hWndListViewHistory, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);

			LVCOLUMN lvc;
			lvc.mask = LVCF_WIDTH;
			lvc.cx = 30;
			ListView_InsertColumn(g_hWndListViewHistory, 0, &lvc);

			lvc.mask = LVCF_WIDTH | LVCF_TEXT;
			lvc.cx = 220;
			lvc.pszText = LoadStr(L"Server Name", IDS_SERVERNAME);
			ListView_InsertColumn(g_hWndListViewHistory, 1, &lvc);

			lvc.cx = 60;
			lvc.pszText = LoadStr(L"Ping", IDS_PING);
			ListView_InsertColumn(g_hWndListViewHistory, 2, &lvc);

			lvc.cx = 80;
			lvc.pszText = LoadStr(L"Players", IDS_PLAYERS);
			ListView_InsertColumn(g_hWndListViewHistory, 3, &lvc);

			lvc.cx = 70;
			lvc.pszText = LoadStr(L"Version", IDS_VERSION);
			ListView_InsertColumn(g_hWndListViewHistory, 4, &lvc);

			lvc.cx = 100;
			lvc.pszText = LoadStr(L"Gamemode", IDS_GAMEMODE);
			ListView_InsertColumn(g_hWndListViewHistory, 5, &lvc);

			lvc.cx = 160;
			lvc.pszText = LoadStr(L"Last Played", IDS_LASTPLAYED);
			ListView_InsertColumn(g_hWndListViewHistory, 6, &lvc);
		}

		g_hWndTab = CreateWindow(WC_TABCONTROL, nullptr, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, 0, 0, rcClient.right - UI_PLAYERLIST_WIDTH, rcClient.bottom - UI_SERVERINFO_HEIGHT, hWnd, nullptr, g_hInst, nullptr);
		if (g_hWndTab)
		{
			SetWindowFont(g_hWndTab, hFont, FALSE);

			HIMAGELIST hTabIml = ImageList_Create(16, 16, ILC_COLOR32, 0, 0);
			if (hTabIml)
			{
				for (int i = IDI_FAVORITE; i <= IDI_HISTORY; ++i)
					ImageList_AddIcon(hTabIml, LoadIcon(g_hInst, MAKEINTRESOURCE(i)));
				TabCtrl_SetImageList(g_hWndTab, hTabIml);
			}

			TCITEM tie;
			tie.mask = TCIF_TEXT | TCIF_IMAGE;
			tie.iImage = 0;
			tie.pszText = LoadStr(L"Favorites", IDS_FAVORITES);
			TabCtrl_InsertItem(g_hWndTab, 0, &tie);

			tie.iImage = 1;
			tie.pszText = LoadStr(L"Internet", IDS_INTERNET);
			TabCtrl_InsertItem(g_hWndTab, 1, &tie);

			tie.iImage = 1;
			tie.pszText = LoadStr(L"Official", IDS_OFFICIAL);
			TabCtrl_InsertItem(g_hWndTab, 2, &tie);

			tie.iImage = 2;
			tie.pszText = LoadStr(L"Lan", IDS_LAN);
			TabCtrl_InsertItem(g_hWndTab, 3, &tie);

			tie.iImage = 3;
			tie.pszText = LoadStr(L"History", IDS_HISTORY);
			TabCtrl_InsertItem(g_hWndTab, 4, &tie);
		}

		g_hWndListViewPlayers = CreateWindowEx(0, WC_LISTVIEW, nullptr, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_SINGLESEL | LVS_OWNERDATA, rcClient.right - UI_PLAYERLIST_WIDTH + 1, 18, UI_PLAYERLIST_WIDTH - 2, rcClient.bottom - UI_SERVERINFO_HEIGHT - 18 - 2, hWnd, nullptr, g_hInst, nullptr);
		if (g_hWndListViewPlayers)
		{
			SetWindowTheme(g_hWndListViewPlayers, L"Explorer", nullptr);
			ListView_SetExtendedListViewStyle(g_hWndListViewPlayers, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);

			LVCOLUMN lvc;
			lvc.mask = LVCF_WIDTH;
			lvc.cx = UI_PLAYERLIST_WIDTH - 2;
			ListView_InsertColumn(g_hWndListViewPlayers, 0, &lvc);
		}

		g_hWndGroupBox1 = CreateWindow(WC_BUTTON, LoadStr(L"Players", IDS_PLAYERSLIST), WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_GROUPBOX, rcClient.right - UI_PLAYERLIST_WIDTH, 0, UI_PLAYERLIST_WIDTH, rcClient.bottom - UI_SERVERINFO_HEIGHT, hWnd, nullptr, g_hInst, nullptr);
		if (g_hWndGroupBox1)
		{
			SetWindowFont(g_hWndGroupBox1, hFont, FALSE);
		}

		g_hWndGroupBox2 = CreateWindow(WC_BUTTON, LoadStr(L"Server Info", IDS_SERVERINFO), WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | BS_GROUPBOX, 0, rcClient.bottom - UI_SERVERINFO_HEIGHT, rcClient.right, 118, hWnd, nullptr, g_hInst, nullptr);
		if (g_hWndGroupBox2)
		{
			SetWindowFont(g_hWndGroupBox2, hFont, FALSE);

			int y = 18;
#define LINE_GAP 20

			HWND hStatic = CreateWindow(WC_STATIC, LoadStr(L"Server Name:", IDS_SERVERNAME_), WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, 10, y, 100, 16, g_hWndGroupBox2, nullptr, g_hInst, nullptr);
			if (hStatic) SetWindowFont(hStatic, hFont, FALSE);

			HWND hEdit = CreateWindow(WC_EDIT, nullptr, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | ES_READONLY, 112, y, 300, 16, g_hWndGroupBox2, (HMENU)1001, g_hInst, nullptr);
			if (hEdit) SetWindowFont(hEdit, hFont, FALSE);
			y += LINE_GAP;

			hStatic = CreateWindow(WC_STATIC, LoadStr(L"Server IP:", IDS_SERVERIP), WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, 10, y, 100, 16, g_hWndGroupBox2, nullptr, g_hInst, nullptr);
			if (hStatic) SetWindowFont(hStatic, hFont, FALSE);

			hEdit = CreateWindow(WC_EDIT, nullptr, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | ES_READONLY, 112, y, 300, 16, g_hWndGroupBox2, (HMENU)1002, g_hInst, nullptr);
			if (hEdit) SetWindowFont(hEdit, hFont, FALSE);
			y += LINE_GAP;

			hStatic = CreateWindow(WC_STATIC, LoadStr(L"Server Players:", IDS_SERVERPLAYERS), WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, 10, y, 100, 16, g_hWndGroupBox2, nullptr, g_hInst, nullptr);
			if (hStatic) SetWindowFont(hStatic, hFont, FALSE);

			hEdit = CreateWindow(WC_EDIT, nullptr, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | ES_READONLY, 112, y, 300, 16, g_hWndGroupBox2, (HMENU)1003, g_hInst, nullptr);
			if (hEdit) SetWindowFont(hEdit, hFont, FALSE);
			y += LINE_GAP;

			hStatic = CreateWindow(WC_STATIC, LoadStr(L"Server Ping:", IDS_SERVERPING), WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, 10, y, 100, 16, g_hWndGroupBox2, nullptr, g_hInst, nullptr);
			if (hStatic) SetWindowFont(hStatic, hFont, FALSE);

			hEdit = CreateWindow(WC_EDIT, nullptr, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | ES_READONLY, 112, y, 300, 16, g_hWndGroupBox2, (HMENU)1004, g_hInst, nullptr);
			if (hEdit) SetWindowFont(hEdit, hFont, FALSE);
			y += LINE_GAP;

			hStatic = CreateWindow(WC_STATIC, LoadStr(L"Server Gamemode:", IDS_SERVERGAMEMODE), WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, 10, y, 100, 16, g_hWndGroupBox2, nullptr, g_hInst, nullptr);
			if (hStatic) SetWindowFont(hStatic, hFont, FALSE);

			hEdit = CreateWindow(WC_EDIT, nullptr, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | ES_READONLY, 112, y, 300, 16, g_hWndGroupBox2, (HMENU)1005, g_hInst, nullptr);
			if (hEdit) SetWindowFont(hEdit, hFont, FALSE);
		}

		g_hWndStatusBar = CreateWindow(STATUSCLASSNAME, nullptr, WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hWnd, nullptr, g_hInst, nullptr);

		do {
			g_UDPSocket = socket(AF_INET, SOCK_DGRAM, 0);
			if (g_UDPSocket == INVALID_SOCKET)
				break;

			uint32_t timeout = 2000;
			setsockopt(g_UDPSocket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout));

			struct sockaddr_in bindaddr = { AF_INET };
			if (bind(g_UDPSocket, (sockaddr *)&bindaddr, 16) != NO_ERROR)
			{
				closesocket(g_UDPSocket);
				break;
			}

			if (WSAAsyncSelect(g_UDPSocket, hWnd, WM_SOCKET, FD_READ) == SOCKET_ERROR)
			{
				closesocket(g_UDPSocket);
				break;
			}

			return 0;
		} while (0);
	}
	break;
	case WM_COMMAND:
	{
		int wmId = LOWORD(wParam);
		switch (wmId)
		{
		case IDM_TOOLS_SETTINGS:
			ShowSettings();
			break;
		case IDM_ABOUT:
			DialogBox(g_hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
	}
	break;
	case WM_NOTIFY:
	{
		switch (((LPNMHDR)lParam)->code)
		{
		case TCN_SELCHANGE:
		{
			g_currentTab = TabCtrl_GetCurSel(((LPNMHDR)lParam)->hwndFrom);
			switch (g_currentTab)
			{
			case 0: // Favorites
			case 1: // Internet
			case 2: // Official
			case 3: // Lan
				ListView_DeleteAllItems(g_hWndListViewServers);
				ListView_DeleteAllItems(g_hWndListViewPlayers);
				g_serversList.clear();
				ShowWindow(g_hWndListViewServers, SW_SHOW);
				ShowWindow(g_hWndListViewHistory, SW_HIDE);
				UpdateWindow(g_hWndListViewServers);
				if (g_currentTab == 1 || g_currentTab == 2)
				{
					HWND hDialog = CreateDialog(g_hInst, MAKEINTRESOURCEW(IDD_LOADING), hWnd, nullptr);
					SetWindowPos(hDialog, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
					UpdateWindow(hDialog);

					if (g_serversMasterList)
					{
						delete g_serversMasterList;
						g_serversMasterList = nullptr;
					}

					std::string data;
					data.reserve(2048);

					const char *url;
					if (g_currentTab == 1)
						url = (g_browserSettings.masterlistURL + "/servers").c_str();
					else
						url = (g_browserSettings.masterlistURL + "/official").c_str();
					CURLcode curlRet = CurlRequset(url, data, "VCMP/0.4");
					if (curlRet == CURLE_OK)
					{
						serverMasterList serversList;
						if (ParseJson(data.data(), serversList))
						{
							for (auto it = serversList.begin(); it != serversList.end(); ++it)
							{
								SendQuery(it->address, 'i');
								it->lastPing = GetTickCount();
							}
							g_serversMasterList = new serverMasterList(serversList);
						}
						else
						{
							MessageBox(hWnd, LoadStr(L"Can't parse master list data.", IDS_MASTERLISTDATA), LoadStr(L"Error", IDS_ERROR), MB_ICONWARNING);
						}
					}
					else
					{
						wchar_t message[512];
						swprintf_s(message, LoadStr(L"Can't get information from master list.\n%hs", IDS_MASTERLISTFAILED), curl_easy_strerror(curlRet));
						MessageBox(hWnd, message, LoadStr(L"Error", IDS_ERROR), MB_ICONWARNING);
					}

					DestroyWindow(hDialog);
				}
				else if (g_currentTab == 3)
				{
					BOOL broadcast = TRUE;
					setsockopt(g_UDPSocket, SOL_SOCKET, SO_BROADCAST, (char *)&broadcast, sizeof(broadcast));

					for (uint16_t port = 8000; port <= 8200; ++port)
					{
						serverAddress address = { INADDR_BROADCAST, port };
						SendQuery(address, 'i');
					}

					broadcast = FALSE;
					setsockopt(g_UDPSocket, SOL_SOCKET, SO_BROADCAST, (char *)&broadcast, sizeof(broadcast));

					lanLastPing = GetTickCount();
				}
				break;
			case 4: // History
				ShowWindow(g_hWndListViewHistory, SW_SHOW);
				ShowWindow(g_hWndListViewServers, SW_HIDE);
				break;
			}
		}
		break;
		case LVN_GETDISPINFO:
		{
			LPNMLVDISPINFOW di = (LPNMLVDISPINFOW)lParam;
			if (di->hdr.hwndFrom == g_hWndListViewServers)
			{
				size_t i = di->item.iItem;
				if (g_serversList.size() > i)
				{
					if (di->item.iSubItem == 0 && di->item.mask & LVIF_IMAGE)
						di->item.iImage = 0;

					if (di->item.mask & LVIF_TEXT)
					{
						switch (di->item.iSubItem)
						{
						case 0: // Icon
							break;
						case 1: // Server Name
							if (di->item.cchTextMax > 0 && di->item.pszText)
							{
								MultiByteToWideChar(CP_ACP, 0, g_serversList[i].info.serverName.c_str(), -1, di->item.pszText, di->item.cchTextMax);
							}
							break;
						case 2: // Ping
						{
							uint32_t ping = g_serversList[i].lastRecv - g_serversList[i].lastPing[1];
							_itow_s(ping, di->item.pszText, di->item.cchTextMax, 10);
						}
						break;
						case 3: // Players
							swprintf_s(di->item.pszText, di->item.cchTextMax, L"%hu/%hu", g_serversList[i].info.players, g_serversList[i].info.maxPlayers);
							break;
						case 4: // Version
						{
							MultiByteToWideChar(CP_ACP, 0, g_serversList[i].info.versionName, -1, di->item.pszText, di->item.cchTextMax);
						}
						break;
						case 5: // Gamemode
						{
							MultiByteToWideChar(CP_ACP, 0, g_serversList[i].info.gameMode.c_str(), -1, di->item.pszText, di->item.cchTextMax);
						}
						break;
						case 6: // Map name
						{
							MultiByteToWideChar(CP_ACP, 0, g_serversList[i].info.mapName.c_str(), -1, di->item.pszText, di->item.cchTextMax);
						}
						break;
						}
					}
				}
			}
			else if (di->hdr.hwndFrom == g_hWndListViewHistory) // FIXME
			{

			}
			else if (di->hdr.hwndFrom == g_hWndListViewPlayers)
			{
				size_t i = ListView_GetSelectionMark(g_hWndListViewServers);
				if (g_serversList.size() > i)
				{
					serverPlayers &players = g_serversList[i].players;

					size_t j = di->item.iItem;
					if (players.size() > j)
					{
						if (di->item.mask & LVIF_TEXT)
						{
							MultiByteToWideChar(CP_ACP, 0, players[j].name, -1, di->item.pszText, di->item.cchTextMax);
						}
					}
				}
			}
		}
		break;
		case NM_CUSTOMDRAW:
		{
			LPNMLVCUSTOMDRAW nmcd = (LPNMLVCUSTOMDRAW)lParam;
			if (nmcd->nmcd.hdr.hwndFrom == g_hWndListViewServers)
			{
				switch (nmcd->nmcd.dwDrawStage)
				{
				case CDDS_PREPAINT:
					return CDRF_NOTIFYITEMDRAW;
				case CDDS_ITEMPREPAINT:
				{
					COLORREF crText;
					size_t i = nmcd->nmcd.dwItemSpec;
					if (g_serversList.size() > i && g_serversList[i].isOfficial)
						crText = g_browserSettings.officialColor;
					else
						crText = 0;

					nmcd->clrText = crText;
					return CDRF_DODEFAULT;
				}
				}
			}
		}
		break;
		case LVN_ITEMCHANGED:
		{
			LPNMITEMACTIVATE nmitem = (LPNMITEMACTIVATE)lParam;
			if (nmitem->hdr.hwndFrom == g_hWndListViewServers)
			{
				size_t i = nmitem->iItem;
				if (i != -1 && g_serversList.size() > i)
				{
					if (g_serversList[i].info.players == 0)
						ListView_DeleteAllItems(g_hWndListViewPlayers);

					std::wstring wstr;

					ConvertCharset(g_serversList[i].info.serverName.c_str(), wstr);
					SetDlgItemText(g_hWndGroupBox2, 1001, wstr.c_str()); // Server Name

					wchar_t ipstr[22];
					char *ip = (char *)&(g_serversList[i].address.ip);
					swprintf_s(ipstr, L"%hhu.%hhu.%hhu.%hhu:%hu", ip[0], ip[1], ip[2], ip[3], g_serversList[i].address.port);
					SetDlgItemText(g_hWndGroupBox2, 1002, ipstr); // Server IP

					wchar_t playersstr[12];
					swprintf_s(playersstr, L"%hu/%hu", g_serversList[i].info.players, g_serversList[i].info.maxPlayers);
					SetDlgItemText(g_hWndGroupBox2, 1003, playersstr); // Server Players

					wchar_t pingsstr[12];
					uint32_t ping = g_serversList[i].lastRecv - g_serversList[i].lastPing[1];
					_itow_s(ping, pingsstr, 10);
					SetDlgItemText(g_hWndGroupBox2, 1004, pingsstr); // Server Ping

					ConvertCharset(g_serversList[i].info.gameMode.c_str(), wstr);
					SetDlgItemText(g_hWndGroupBox2, 1005, wstr.c_str()); // Server Gamemode

					SendQuery(g_serversList[i].address, 'i');
					SendQuery(g_serversList[i].address, 'c');
					g_serversList[i].lastPing[0] = GetTickCount();
				}
				else
				{
					ListView_DeleteAllItems(g_hWndListViewPlayers);
					for (int i = 1001; i <= 1005; ++i)
						SetDlgItemText(g_hWndGroupBox2, i, nullptr);
				}
			}
		}
		break;
		case LVN_ITEMACTIVATE:
		{
			LPNMITEMACTIVATE nmia = (LPNMITEMACTIVATE)lParam;
			if (nmia->hdr.hwndFrom == g_hWndListViewServers)
			{
				size_t i = nmia->iItem;
				if (i != -1 && g_serversList.size() > i)
				{
					char ipstr[16];
					char *ip = (char *)&(g_serversList[i].address.ip);
					snprintf(ipstr, sizeof(ipstr), "%hhu.%hhu.%hhu.%hhu", ip[0], ip[1], ip[2], ip[3]);
					char vcmpDll[MAX_PATH];
					snprintf(vcmpDll, sizeof(vcmpDll), "%ls%s\\vcmp-game.dll", g_exePath, g_serversList[i].info.versionName);
					LaunchVCMP(ipstr, g_serversList[i].address.port, g_browserSettings.playerName, nullptr, g_browserSettings.gamePath, vcmpDll);
				}
			}
		}
		break;
		}
	}
	break;
	case WM_SIZE:
	{
		int clientWidth = GET_X_LPARAM(lParam), clientHeight = GET_Y_LPARAM(lParam);
		SetWindowPos(g_hWndTab, 0, 0, 0, clientWidth - UI_PLAYERLIST_WIDTH, clientHeight - UI_SERVERINFO_HEIGHT, SWP_NOZORDER);
		SetWindowPos(g_hWndListViewServers, 0, 1, 21, clientWidth - UI_PLAYERLIST_WIDTH - 4, clientHeight - UI_SERVERINFO_HEIGHT - 21 - 2, SWP_NOZORDER);
		SetWindowPos(g_hWndListViewHistory, 0, 1, 21, clientWidth - UI_PLAYERLIST_WIDTH - 4, clientHeight - UI_SERVERINFO_HEIGHT - 21 - 2, SWP_NOZORDER);
		SetWindowPos(g_hWndGroupBox1, 0, clientWidth - UI_PLAYERLIST_WIDTH, 0, UI_PLAYERLIST_WIDTH, clientHeight - UI_SERVERINFO_HEIGHT, SWP_NOZORDER);
		SetWindowPos(g_hWndListViewPlayers, 0, clientWidth - UI_PLAYERLIST_WIDTH + 1, 18, UI_PLAYERLIST_WIDTH - 2, clientHeight - UI_SERVERINFO_HEIGHT - 18 - 2, SWP_NOZORDER);
		SetWindowPos(g_hWndGroupBox2, 0, 0, clientHeight - UI_SERVERINFO_HEIGHT, clientWidth, 118, SWP_NOZORDER);
		SendMessage(g_hWndStatusBar, WM_SIZE, 0, 0);
	}
	break;
	case WM_GETMINMAXINFO:
		((LPMINMAXINFO)lParam)->ptMinTrackSize = { 750, 500 };
		break;
	case WM_DESTROY:
		if (_hFont)
			DeleteObject(_hFont);
		PostQuitMessage(0);
		break;
	case WM_SOCKET:
	{
		if (WSAGETSELECTEVENT(lParam) == FD_READ)
		{
			char *recvBuf = (char *)calloc(1024, sizeof(char));
			if (recvBuf)
			{
				struct sockaddr_in recvAddr;
				int addrLen = sizeof(recvAddr);
				int recvLen = recvfrom(g_UDPSocket, recvBuf, 1024, 0, (sockaddr *)&recvAddr, &addrLen);
				if (recvLen != -1 && recvLen >= 11)
				{
					if (recvLen > 1024)
						recvLen = 1024;

					if (*(int *)recvBuf == 0x3430504D) // MP04
					{
						char opcode = recvBuf[10];
						if (opcode == 'i' || opcode == 'c')
						{
							uint32_t ip = recvAddr.sin_addr.s_addr;
							uint16_t port = ntohs(recvAddr.sin_port);

							bool found = false;
							serverMasterListInfo masterInfo;
							if (g_currentTab == 1 || g_currentTab == 2)
							{
								for (auto it = g_serversMasterList->begin(); it != g_serversMasterList->end(); ++it)
								{
									if (it->address.ip == ip && it->address.port == port)
									{
										found = true;
										masterInfo = *it;
										break;
									}
								}
							}
							else if (g_currentTab == 3) // Lan
							{
								found = true;
								masterInfo.address = { ip, port };
								masterInfo.isOfficial = false;
								masterInfo.lastPing = lanLastPing;
							}

							if (found)
							{
								switch (opcode)
								{
								case 'i':
								{
									serverInfo info;
									if (GetServerInfo(recvBuf, recvLen, info))
									{
										bool inList = false;
										for (auto it = g_serversList.begin(); it != g_serversList.end(); ++it)
										{
											if (it->address.ip == ip && it->address.port == port)
											{
												inList = true;
												it->lastRecv = GetTickCount();
												it->lastPing[1] = it->lastPing[0];
												it->info = info;
												auto i = it - g_serversList.begin();
												ListView_Update(g_hWndListViewServers, i);
												break;
											}
										}
										if (!inList)
										{
											serverAllInfo allInfo;
											allInfo.address = masterInfo.address;
											allInfo.info = info;
											allInfo.isOfficial = masterInfo.isOfficial;
											allInfo.lastPing[0] = masterInfo.lastPing;
											allInfo.lastPing[1] = masterInfo.lastPing;
											allInfo.lastRecv = GetTickCount();
											g_serversList.push_back(allInfo);

											LVITEM lvi = { 0 };
											ListView_InsertItem(g_hWndListViewServers, &lvi);
										}
									}
								}
								break;
								case 'c':
								{
									serverPlayers players;
									if (GetServerPlayers(recvBuf, recvLen, players))
									{
										for (auto it = g_serversList.begin(); it != g_serversList.end(); ++it)
										{
											if (it->address.ip == ip && it->address.port == port)
											{
												it->lastRecv = GetTickCount();
												it->lastPing[1] = it->lastPing[0];
												it->players = players;
												auto i = it - g_serversList.begin();
												ListView_SetItemCount(g_hWndListViewPlayers, players.size());
												break;
											}
										}
									}
								}
								break;
								}
							}
						}
					}
				}
				free(recvBuf);
			}
		}
	}
	break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
//
// Single selection keyboard handler for the tree control.
//
void CPageNetwork::KeySingleSel(WORD wVKey)
{
	BOOL shift = GetKeyState(VK_SHIFT) & 0x8000;
	BOOL control = GetKeyState(VK_CONTROL) & 0x8000;

	// Make sure there are interfaces.
	if (!highlighted)
		return;

	switch (wVKey) {
	case VK_UP:
		SetFocusUp();
		// Only select items if the shift key is pressed.
		if (shift) {
			SelectRange(highlighted, highlighted, TRUE, TargetChecked);
			StoreTargetSelection();
		}
		break;
	case VK_DOWN:
		SetFocusDown();
		// Only select items if the shift key is pressed.
		if (shift) {
			SelectRange(highlighted, highlighted, TRUE, TargetChecked);
			StoreTargetSelection();
		}
		break;
	case VK_HOME:
		SetFocusHome();
		// Only select items if the shift key is pressed.
		if (shift) {
			SelectRange(highlighted, highlighted, TRUE, TargetChecked);
			StoreTargetSelection();
		}
		break;
	case VK_END:
		SetFocusEnd();
		// Only select items if the shift key is pressed.
		if (shift) {
			SelectRange(highlighted, highlighted, TRUE, TargetChecked);
			StoreTargetSelection();
		}
		break;
	case VK_SPACE:
		if (control)	// toggle.
		{
			// Toggle the selection, but do not clear any other items.
			if (GetSelectionCheck(highlighted) == TargetChecked) {
				SelectRange(highlighted, highlighted, FALSE, TargetUnChecked);
			} else {
				SelectRange(highlighted, highlighted, FALSE, TargetChecked);
			}
		} else		// normal selection.
		{
			// Extend the selection and clear any other items.
			SelectRange(highlighted, highlighted, TRUE, TargetChecked);
		}

		ShowFocus();
		StoreTargetSelection();
		break;
	}
	ShowSettings();
	EnableWindow();
}
Example #21
0
void ViewManager::ShowSettings (const QUrl& url)
{
    auto manager = Quark2Manager_ [url];
    manager->ShowSettings ();
}
Example #22
0
/**
 * Show settings window
 *
 * The window will show the provided \a cSettings values.
 * If user choose to save changes, \a cSettings will be updated to reflect changes.
 *
 */
SettingsWindow::SettingsWindow( const Rect & cFrame,
    TermSettings * pcSettings, const String &cName, const String &cTitle,
    uint32 nFlags )
:Window( cFrame, cName, cTitle, nFlags )
{
    m_pcDestSettings = pcSettings;
    /* Make a local copy of setings */
    m_cTempSettings = *pcSettings;

    /*
     * a first table : 1 col, 3 rows :
     *    - first row contains colors table
     *    - second row contains ibeam check box
     *    - third row contains buttons
     */
    m_pcLayoutTable =
        new TableView( Rect( 0, 0, 1, 1 ), "LayoutTable", "", 1, 4,
        CF_FOLLOW_LEFT | CF_FOLLOW_TOP );

    /*
     * The colors table
     */
    m_pcColorsTable =
        new TableView( Rect( 0, 0, 1, 1 ), "ColorsTable", "", 3, 3,
        CF_FOLLOW_LEFT | CF_FOLLOW_TOP );

    m_pcNormalLabel =
        new StringView( Rect( 0, 0, 1, 1 ), "NormalLabel", "Normal text" );
    m_pcSelectedLabel =
        new StringView( Rect( 0, 0, 1, 1 ), "SelectedLabel",
        "Selected text" );
    m_pcTextLabel = new StringView( Rect( 0, 0, 1, 1 ), "TextLabel", "Text" );
    m_pcBackgroundLabel =
        new StringView( Rect( 0, 0, 1, 1 ), "BackgroundLabel", "Background" );
    m_pcNormalLabel->ResizeTo( m_pcNormalLabel->GetPreferredSize( false ) );
    m_pcSelectedLabel->ResizeTo( m_pcSelectedLabel->
        GetPreferredSize( false ) );
    m_pcTextLabel->ResizeTo( m_pcTextLabel->GetPreferredSize( false ) );
    m_pcBackgroundLabel->ResizeTo( m_pcBackgroundLabel->
        GetPreferredSize( false ) );

    m_pcNormalTextList =
        new DropdownMenu( Rect( 0, 0, 1, 1 ), "NormalTextList",
        CF_FOLLOW_LEFT | CF_FOLLOW_TOP );
    m_pcNormalBackgroundList =
        new DropdownMenu( Rect( 0, 0, 1, 1 ), "NormalBackgroundList",
        CF_FOLLOW_LEFT | CF_FOLLOW_TOP );
    m_pcSelectedTextList =
        new DropdownMenu( Rect( 0, 0, 1, 1 ), "SelectedTextList",
        CF_FOLLOW_LEFT | CF_FOLLOW_TOP );
    m_pcSelectedBackgroundList =
        new DropdownMenu( Rect( 0, 0, 1, 1 ), "SelectedBackgroundList",
        CF_FOLLOW_LEFT | CF_FOLLOW_TOP );

    m_pcNormalTextList->SetReadOnly( true );
    m_pcNormalBackgroundList->SetReadOnly( true );
    m_pcSelectedTextList->SetReadOnly( true );
    m_pcSelectedBackgroundList->SetReadOnly( true );

    for( int i = 0; i < 16; i++ ) {
        m_pcNormalTextList->AppendItem( Colors[i].name );
        m_pcNormalBackgroundList->AppendItem( Colors[i].name );
        m_pcSelectedTextList->AppendItem( Colors[i].name );
        m_pcSelectedBackgroundList->AppendItem( Colors[i].name );
    }

    m_pcNormalTextList->ResizeTo( m_pcNormalTextList->
        GetPreferredSize( false ) );
    m_pcNormalBackgroundList->ResizeTo( m_pcNormalBackgroundList->
        GetPreferredSize( false ) );
    m_pcSelectedTextList->ResizeTo( m_pcSelectedTextList->
        GetPreferredSize( false ) );
    m_pcSelectedBackgroundList->ResizeTo( m_pcSelectedBackgroundList->
        GetPreferredSize( false ) );

    m_pcColorsTable->SetChild( m_pcNormalLabel, 0, 1 );
    m_pcColorsTable->SetChild( m_pcSelectedLabel, 0, 2 );
    m_pcColorsTable->SetChild( m_pcTextLabel, 1, 0 );
    m_pcColorsTable->SetChild( m_pcBackgroundLabel, 2, 0 );
    m_pcColorsTable->SetChild( m_pcNormalTextList, 1, 1 );
    m_pcColorsTable->SetChild( m_pcNormalBackgroundList, 2, 1 );
    m_pcColorsTable->SetChild( m_pcSelectedTextList, 1, 2 );
    m_pcColorsTable->SetChild( m_pcSelectedBackgroundList, 2, 2 );

    //m_pcColorsTable->ResizeTo( m_pcColorsTable->GetPreferredSize( false ) );

    /*
     * The ibeam checkbox
     */
    m_pcIBeamCheck =
        new CheckBox( Rect( 0, 0, 1, 1 ), "IBeamCheck",
        "White halo around the I-beam cursor", NULL,
        CF_FOLLOW_LEFT | CF_FOLLOW_TOP );
    m_pcIBeamCheck->ResizeTo( m_pcIBeamCheck->GetPreferredSize( false ) );

    /*
     * The buttons
     */
    m_pcButtonsTable =
        new TableView( Rect( 0, 0, 1, 1 ), "ButtonsTable", "", 3, 2,
        CF_FOLLOW_LEFT | CF_FOLLOW_TOP );
    m_pcApplyButton =
        new Button( Rect( 0, 0, 1, 1 ), "ApplyButton", "Apply and close",
        new Message( M_APPLY ), CF_FOLLOW_LEFT | CF_FOLLOW_TOP );
    m_pcSaveButton =
        new Button( Rect( 0, 0, 1, 1 ), "SaveButton",
        "Apply, Save as defaults and close", new Message( M_SAVE ),
        CF_FOLLOW_LEFT | CF_FOLLOW_TOP );
    m_pcCancelButton =
        new Button( Rect( 0, 0, 1, 1 ), "CancelButton", "Cancel",
        new Message( M_CANCEL ), CF_FOLLOW_LEFT | CF_FOLLOW_TOP );
    m_pcRevertButton =
        new Button( Rect( 0, 0, 1, 1 ), "RevertButton",
        "Revert to factory settings", new Message( M_REVERT ),
        CF_FOLLOW_LEFT | CF_FOLLOW_TOP );

    m_pcApplyButton->ResizeTo( m_pcApplyButton->GetPreferredSize( false ) );
    m_pcSaveButton->ResizeTo( m_pcSaveButton->GetPreferredSize( false ) );
    m_pcCancelButton->ResizeTo( m_pcCancelButton->GetPreferredSize( false ) );
    m_pcRevertButton->ResizeTo( m_pcRevertButton->GetPreferredSize( false ) );

    m_pcButtonsTable->SetChild( m_pcSaveButton, 2, 1 );
    m_pcButtonsTable->SetChild( m_pcApplyButton, 2, 0 );
    m_pcButtonsTable->SetChild( m_pcCancelButton, 1, 0 );
    m_pcButtonsTable->SetChild( m_pcRevertButton, 0, 0 );

    m_pcButtonsTable->ResizeTo( m_pcButtonsTable->GetPreferredSize( false ) );

    /*
     * The notice
     */
    m_pcNoticeLabel =
        new StringView( Rect( 0, 0, 1, 1 ), "NoticeLabel", "Note: "
        "clicking \"Save as defaults\" will also save current terminal size"
        " and position." );

    /*
     * Final layout
     */
    m_pcLayoutTable->SetChild( m_pcColorsTable, 0, 0 );
    m_pcLayoutTable->SetCellAlignment( 0, 0, ALIGN_CENTER, ALIGN_CENTER );
    m_pcLayoutTable->SetCellAlignment( 0, 1, ALIGN_CENTER, ALIGN_CENTER );
    m_pcLayoutTable->SetChild( m_pcIBeamCheck, 0, 1 );
    m_pcLayoutTable->SetChild( m_pcButtonsTable, 0, 2 );
    m_pcLayoutTable->SetChild( m_pcNoticeLabel, 0, 3 );
    m_pcLayoutTable->ResizeTo( m_pcLayoutTable->GetPreferredSize( false ) );

    AddChild( m_pcLayoutTable );
    SetFrame( m_pcLayoutTable->GetFrame() );

    ShowSettings();
}
//
// Process mouse click in the target list.  For a worker, assign the selected
// target.  For a manager, distribute the assigned targets among its net servers.
//
void CPageNetwork::OnClickTTargets(NMHDR * pNMHDR, LRESULT * pResult)
{
	CPoint point;
	TV_HITTESTINFO test_info;
	TargetSelType state;

	// Get the cursor position.
	GetCursorPos(&point);
	test_info.pt = point;
	m_TTargets.ScreenToClient(&(test_info.pt));

	// Check to see whether the cursor is on an item.
	m_TTargets.HitTest(&test_info);

	// Check that we have an interface item.
	if (!test_info.hItem || !m_TTargets.GetParentItem(test_info.hItem))
		return;

	// A new target assignment is being made.  Clear the results since they are
	// for a configuration we no longer have.
	theApp.pView->ResetDisplayforNewTest();

	// Toggle the selection if the control key is pressed.
	if (GetKeyState(VK_CONTROL) & 0x8000 && GetSelectionCheck(test_info.hItem) == TargetChecked) {
		state = TargetUnChecked;
	} else {
		state = TargetChecked;
	}

	switch (theApp.pView->m_pWorkerView->GetSelectedType()) {
	case WORKER:
		// All clicks work the same for the worker.
		SelectRange(test_info.hItem, test_info.hItem, TRUE, state);
		break;
	case MANAGER:
		// A shift click extends the selection from the last selected item
		// to the currently focused item.  When the control key is also
		// pressed, any previous selection is not cleared.
		if ((GetKeyState(VK_SHIFT) & 0x8000) && selected) {
			// We have a previous item (not the first click) and the shift
			// key is down.
			SelectRange(selected, test_info.hItem, !(GetKeyState(VK_CONTROL) & 0x8000));
		} else if (GetKeyState(VK_CONTROL) & 0x8000) {
			// The control key is down.
			SelectRange(test_info.hItem, test_info.hItem, FALSE, state);
		} else {
			SelectRange(test_info.hItem, test_info.hItem, TRUE, state);
		}
		break;
	default:
		ErrorMessage("Unexpected selection type in CPageNetwork::" "OnClickTTargets().");
		return;
	}

	// immediately refresh the display (create/delete NetClients as needed)
	StoreTargetSelection();
	ShowSettings();
	EnableWindow();

	*pResult = 0;
}
Example #24
0
void GameSetup::onDefaultClicked()
{
    settings->RestoreDefault();
    ShowSettings();
}
void PDocument::MessageReceived(BMessage* message)
{
	TRACE();
	switch(message->what)
	{
		case MENU_FILE_SAVE:
		{
			if (entryRef == NULL)
				SavePanel();
			else
				Save();
			break;
		}
		case MENU_FILE_SAVEAS:
		{
			SavePanel();
			break;
		}
		case MENU_FILE_PRINT:
		{
			Print();
			break;
		}
		case MENU_APP_SETTINGS:
				ShowSettings();
			break;
		case MENU_MACRO_START_RECORDING:
		{
			commandManager->StartMacro();
			break;
		}
		case MENU_MACRO_STOP_RECORDING:
		{
			commandManager->StopMacro();
			break;
		}
		case P_C_MACRO_TYPE:
		{
			commandManager->PlayMacro(message);
			break;
		}
		case  B_SAVE_REQUESTED:
		{
				message->PrintToStream();
				BMessage	*saveSettings	= new BMessage();
				message->FindMessage("saveSettings",saveSettings);
				entry_ref *ref	= new entry_ref;
				const char* name;
				message->FindRef("directory",ref);
				message->FindString("name", &name);
				SetEntry(ref,name);
				if (documentSetting->ReplaceMessage("saveSettings",saveSettings) != B_OK)
					documentSetting->AddMessage("saveSettings",saveSettings);
				Save();
			break;
		}
		case B_COPY:
		{
			BMessage	*copyMessage	= new BMessage(P_C_EXECUTE_COMMAND);
			copyMessage->AddString("Command::Name","Copy");
			copyMessage->AddBool("shadow",true);
			commandManager->Execute(copyMessage);
			break;
		}
		case B_PASTE:
		{
			BMessage	*pasteMessage	= new BMessage(P_C_EXECUTE_COMMAND);
			pasteMessage->AddString("Command::Name","Paste");
			pasteMessage->AddBool("shadow",true);
			commandManager->Execute(pasteMessage);
			break;
		}

		case B_UNDO:
		{
			commandManager->Undo(NULL);
			break;
		}
		case B_REDO:
		{
			commandManager->Redo(NULL);
			break;
		}
		case P_C_EXECUTE_COMMAND:
		{
			commandManager->Execute(message);
			break;
		}
		case P_C_AUTO_SAVE:
		{
			AutoSave();
			break;
		}
		case P_C_RESTORE_SAVE:
		{
			//for the Moment we use autosave ;-)
			AutoSave();
			break;
		}

		default:
			BLooper::MessageReceived(message);
			break;
	}

}
//
// Multi selection keyboard handler for the tree control.
//
void CPageNetwork::KeyMultiSel(WORD wVKey)
{
	BOOL shift = GetKeyState(VK_SHIFT) & 0x8000;
	BOOL control = GetKeyState(VK_CONTROL) & 0x8000;

	// Make sure there are interfaces.
	if (!highlighted)
		return;

	switch (wVKey) {
	case VK_UP:
		if (!selected && shift)
			selected = highlighted;
		SetFocusUp();
		// Only select items if the shift key is pressed.
		if (shift) {
			SelectRange(selected, highlighted, !control, TargetChecked);
			StoreTargetSelection();
		}
		break;
	case VK_DOWN:
		if (!selected && shift)
			selected = highlighted;

		SetFocusDown();
		// Only select items if the shift key is pressed.
		if (shift) {
			SelectRange(selected, highlighted, !control, TargetChecked);
			StoreTargetSelection();
		}
		break;
	case VK_HOME:
		if (!selected && shift)
			selected = highlighted;

		SetFocusHome();
		// Only select items if the shift key is pressed.
		if (shift) {
			SelectRange(selected, highlighted, !control, TargetChecked);
			StoreTargetSelection();
		}
		break;
	case VK_END:
		if (!selected && shift)
			selected = highlighted;

		SetFocusEnd();
		// Only select items if the shift key is pressed.
		if (shift) {
			SelectRange(selected, highlighted, !control, TargetChecked);
			StoreTargetSelection();
		}
		break;
	case VK_SPACE:
		if (shift) {
			// Extend the selection. Clear any other items if the control
			// key is not pressed.
			SelectRange(selected, highlighted, !control, TargetChecked);
		} else if (control) {	// toggle.
			// Toggle the selection, but do not clear any other items.
			if (GetSelectionCheck(highlighted) == TargetChecked) {
				SelectRange(highlighted, highlighted, FALSE, TargetUnChecked);
			} else {
				SelectRange(highlighted, highlighted, FALSE, TargetChecked);
			}
		} else {	// normal
			// Uniquely select the item with the focus.
			SelectRange(highlighted, highlighted, TRUE, TargetChecked);
		}

		ShowFocus();
		StoreTargetSelection();
		break;
	case 'A':
		if (control) {
			SetAllCheck(TargetChecked);
			StoreTargetSelection();
		}
	}
	ShowSettings();
	EnableWindow();
}
Example #27
0
void GribSettingsDialog::ShowFittingSettings( int settings )
{
    //Hide all Parameters
    m_cbBarbedArrows->Show(false);
    m_tBarbedRange->Show(false);
    m_sBarbedRange->Show(false);
    m_cbIsoBars->Show(false);
    m_tIsoBarSpacing->Show(false);
    m_sIsoBarSpacing->Show(false);
    m_cbDirectionArrows->Show(false);
    m_tDirectionArrowSize->Show(false);
    m_sDirectionArrowSize->Show(false);
    m_cbOverlayMap->Show(false);
    m_tOverlayColors->Show(false);
    m_cOverlayColors->Show(false);
    this->Fit();
    //Show only fitting parameters
    switch(settings){
    case 0:
        ShowSettings( ISO_LINES );
        m_cbIsoBars->SetLabel(_("Display Isotachs"));
        ShowSettings( B_ARROWS );
        ShowSettings( OVERLAY );
        break;
    case 1:
        ShowSettings( ISO_LINES );
        m_cbIsoBars->SetLabel(_("Display Isotachs"));
        ShowSettings( OVERLAY );
        break;
    case 2:
        ShowSettings( ISO_LINES );
        m_cbIsoBars->SetLabel(_("Display Isobars"));
        break;
    case 3:
    case 4:
        ShowSettings( D_ARROWS );
        ShowSettings( OVERLAY );
        break;
    case 5:
    case 6:
        ShowSettings( OVERLAY );
        break;
    case 7:
    case 8:
        ShowSettings( ISO_LINES );
        m_cbIsoBars->SetLabel(_("Display Isotherms"));
        ShowSettings( OVERLAY );
        break;
    case 9:
        ShowSettings( ISO_LINES );
        m_cbIsoBars->SetLabel(_("Display Iso CAPE"));
        ShowSettings( OVERLAY );

    }
}
Example #28
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	MSG Msg;
	HWND hwndTetris = NULL, hwndIduca = NULL, hwndBodlevel = NULL;
	RECT window;
	wchar_t bgimgpath_d[MAX_PATH], *bgimgpath=NULL;
	wchar_t figureimgpath_d[MAX_PATH], *figureimgpath=NULL;
	wchar_t pauseimgpath_d[MAX_PATH], *pauseimgpath=NULL;

	InitCommonControls();

	LoadSettings();
	if (!ShowSettings()) {
		return 0;
	}

	hwndTetris = tetris_window(hInstance, CW_USEDEFAULT, CW_USEDEFAULT, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, 0, NULL);
	GetWindowRect(hwndTetris, &window);
	if (int_settings[is_shownext].value) {
		hwndIduca = iduca_window(hInstance, window.right, window.top, WS_CHILD | WS_POPUP | WS_CAPTION, 0, hwndTetris); 
		GetWindowRect(hwndIduca, &window);
	} else {
		window.left = window.right;
		window.bottom = window.top;
	}
	if (int_settings[is_showdata].value) {
		hwndBodlevel = bodlevel_window(hInstance, window.left, window.bottom, WS_CHILD | WS_POPUP | WS_CAPTION, 0, hwndTetris);
	}

	if (GetSkinBackground(str_settings[ss_skin].value, bgimgpath_d, MAX_PATH) >= 0) bgimgpath=bgimgpath_d;
	if (GetSkinFigureImg(str_settings[ss_skin].value, figureimgpath_d, MAX_PATH) >= 0) figureimgpath=figureimgpath_d;
	if (GetSkinPauseImg(str_settings[ss_skin].value, pauseimgpath_d, MAX_PATH) >=0) pauseimgpath=pauseimgpath_d;

	SetActiveWindow(hwndTetris);
	SetForegroundWindow(hwndTetris);

	SendMessage(hwndBodlevel, LEVEL_PROLAZ, (WPARAM)level_advance, 0);

	SendMessage(hwndTetris, TET_SLIKA_POZADINA, (WPARAM)bgimgpath, 0);
	SendMessage(hwndTetris, TET_SLIKA_FIGURE, (WPARAM)figureimgpath, 0);
	SendMessage(hwndTetris, TET_SLIKA_PAUZE, (WPARAM)pauseimgpath, 0);
	SendMessage(hwndTetris, TET_IDUCA_PROZOR, (WPARAM)hwndIduca, 0);
	SendMessage(hwndTetris, TET_BODLEVEL_PROZOR, (WPARAM)hwndBodlevel, 0);
	SendMessage(hwndTetris, TET_PADA_SA_SREDINE, int_settings[is_midfall].value, 0);
	SendMessage(hwndTetris, TET_BODOVI_RETKA, 10, 0);
	SendMessage(hwndTetris, TET_ROTACIJA, int_settings[is_rotcw].value?ROTACIJA_CW:ROTACIJA_CCW, 0);
	SendMessage(hwndTetris, TET_POCETNI_REDOVI, int_settings[is_lines].value, 0);
	SendMessage(hwndTetris, TET_ODABERI_NIVO, int_settings[is_level].value, 0);
	SendMessage(hwndTetris, TET_GAMEOVE_HANDLER, (WPARAM)goverhandler, 0);
	SendMessage(hwndTetris, TET_START, 0, 0);

	while(GetMessage(&Msg, NULL, 0, 0) > 0)
	{
		TranslateMessage(&Msg);
		DispatchMessage(&Msg);
	}

	if (!SaveSettings()) {
		MessageBox(NULL, L"Ne mogu spremiti postavke!", NULL, MB_OK | MB_ICONWARNING);
	}

	return (int)Msg.wParam;
}