Esempio n. 1
0
Launcher::LauncherWindow::LauncherWindow()
    : QWidget(0) {

    setWindowTitle("SilkyStrings - launcher");
    setGeometry(100, 100, 370, 300);

    /* settingsGroup */
    QGroupBox *settingsGroup = new QGroupBox("Settings");
    QGridLayout *settingsLayout = new QGridLayout;
    settingsGroup->setLayout(settingsLayout);


    /* resolution */
    resolution = new QComboBox();
    resolution->addItem("800x600");
    resolution->addItem("1024x768");
    resolution->addItem("1600x1200");
    settingsLayout->addWidget(new QLabel("Resolution: "), 0, 0, Qt::AlignRight);
    settingsLayout->addWidget(resolution, 0, 1);

    /* fullscreen */
    fullscreen = new QCheckBox();
    fullscreen->setCheckState(Qt::Checked);
    settingsLayout->addWidget(new QLabel("Fullscreen: "), 1, 0, Qt::AlignRight);
    settingsLayout->addWidget(fullscreen, 1, 1);
    settingsLayout->setRowMinimumHeight(2, 10);

    /* difficulty */
    difficulty = new QComboBox();
    difficulty->addItem("Supaeasy");
    difficulty->addItem("Easy");
    difficulty->addItem("Medium");
    difficulty->addItem("Amazing");
    settingsLayout->addWidget(new QLabel("Difficulty: "), 3, 0, Qt::AlignRight);
    settingsLayout->addWidget(difficulty, 3, 1);
    settingsLayout->setRowMinimumHeight(4, 10);

    /* gameButtons */
    const char *button_strings[7] =
    {
        "Fret 1: ",
        "Fret 2: ",
        "Fret 3: ",
        "Fret 4: ",
        "Fret 5: ",
        "Pick: ",
        "Quit: ",
    };
    const int defaultKeys[7] =
    {
        SilkyStrings::KEY_F1,
        SilkyStrings::KEY_F2,
        SilkyStrings::KEY_F3,
        SilkyStrings::KEY_F4,
        SilkyStrings::KEY_F5,
        SilkyStrings::KEY_ENTER,
        SilkyStrings::KEY_ESC,
    };
    for(int i=0; i<7; i++) {
        gameButtons[i] = new QComboBox();

        for(int j=0; j<SilkyStrings::KEY_NUMBER_OF; j++) {
            gameButtons[i]->addItem(SilkyStrings::key_strings[j]);
        }

        gameButtons[i]->setCurrentIndex(defaultKeys[i]);

        settingsLayout->addWidget(new QLabel(button_strings[i]), i+5, 0, Qt::AlignRight);
        settingsLayout->addWidget(gameButtons[i], i+5,1);
    }



    /* songGroup */
    QGroupBox *songGroup = new QGroupBox("Song selection");
    QGridLayout *songLayout = new QGridLayout();
    songGroup->setLayout(songLayout);

    songList = new QListWidget;

    loadSongs();

    songLayout->addWidget(songList);


    /* buttonLayout */
    QHBoxLayout *buttonLayout = new QHBoxLayout;

    QPushButton *exitButton = new QPushButton("Exit");
    QPushButton *refreshButton = new QPushButton("Refresh");
    QPushButton *playButton = new QPushButton("Play");

    connect(exitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
    connect(refreshButton, SIGNAL(clicked()), this, SLOT(loadSongs()));
    connect(playButton, SIGNAL(clicked()), this, SLOT(play()));

    buttonLayout->addWidget(refreshButton);
    buttonLayout->addWidget(exitButton);
    buttonLayout->addWidget(playButton);


    /* mainLayout */
    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(songGroup, 0,1);
    mainLayout->addLayout(buttonLayout, 1,0,1,2);
    mainLayout->addWidget(settingsGroup, 0,0);


    setLayout(mainLayout);
}
Esempio n. 2
0
/*************************************************************
 * Function: main ()
 * Created: January 27th, 2012
 * Last Revised: February 2nd, 2012
 * Description: This function controls the program
 * Input parameters: None
 * Returns: None
 * Preconditions: the program needs to be run
 * Postconditions: the program has been run
 *************************************************************/
int main (void)
{
	// variables
	char programTitle[] = "Digital Music Manager";
	Node *pSongs = NULL;
	int prog_state = 0, sub_state = 0, option = 0;
	Bool success = false;
	FILE *ioFile = NULL;

	while (prog_state >= 0)
	{
		//// LOADING ////
		if (prog_state == 0)
		{
			// open the music file
			ioFile = fopen ("music.dmm", "r+");
			prog_state = 1;
		}

		//// MAIN MENU ////
		else if (prog_state == 1)
		{
			// display menu and get selected option
			option = display_menu (2, 2, ':', 1, 9, ";", programTitle, "Main Menu",
				"Display Songs;Rate Songs;Sort Songs;Add Song;Edit Song;Delete Song;Load Songs;Store Songs;Exit Digital Music Manager");
			// Display Songs
			if (option == 1)
			{
				displaySongs (pSongs);
			}
			// Rate Songs
			else if (option == 2)
			{
				editSong (1, &pSongs);
			}
			// Sort Songs
			else if (option == 3)
			{
				sortSongs (&pSongs, display_menu (2, 2, ':', 1, 3, ";", programTitle, "Choose an Insert Order...",
					"Insert by Song Title;Insert by Genre;Insert by Rating"));
			}
			// Add Song
			else if (option == 4)
			{
				success = addSong (&pSongs);
				if (!success)
				{
					printf ("Failed to create song!\n");
				}
				else
				{
					sortSongs (&pSongs, display_menu (2, 2, ':', 1, 3, ";", programTitle, "Choose an Insert Order...",
						"Insert by Song Title;Insert by Genre;Insert by Rating"));
				}
			}
			// Edit Song
			else if (option == 5)
			{
				editSong (0, &pSongs);
			}
			// Delete Song
			else if (option == 6)
			{
				deleteSong (&pSongs);
			}
			// Load Songs
			else if (option == 7)
			{
				loadSongs (&pSongs, ioFile);
			}
			// Store Songs
			else if (option == 8)
			{
				storeSongs (pSongs, ioFile);
			}
			// Exit program
			else if (option == 9)
			{
				fclose (ioFile);
				prog_state = -1;
			}
		}
	}
	return 0;
}