AeN64DriverMenu.c++ 2.29 KB
#include <assert.h>
#include <Vk/VkWindow.h>
#include <Vk/VkSubMenu.h>
#include <Vk/VkFileSelectionDialog.h>

#include "AeN64Driver.h"
#include "AeConfig.h"
#include "AeAssetWindow.h"

void
AeN64Driver::BuildMenu (AeAssetWindow * window)
{
    fPlayerMenu = window->addMenuPane("N64");

    fClearProfileButton = fPlayerMenu->addAction ("Clear Profile Values",
						  &AeN64Driver::clearProfileCallback,
						  this);
    fPlayerMenu->addSeparator ();

    fConfigureButton = fPlayerMenu->addAction ("Configure Hardware",
					       &AeN64Driver::configureCallback,
					       this);

    fSaveConfigButton = fPlayerMenu->addAction ("Save Configuration...",
						&AeN64Driver::saveConfigCallback,
						this);
    fLoadConfigButton = fPlayerMenu->addAction ("Load Configuration...",
						&AeN64Driver::loadConfigCallback,
						this);
    fPlayerMenu->addSeparator ();

    fResetSystemButton = fPlayerMenu->addAction ("Reset Hardware",
						 &AeN64Driver::resetSystemCallback,
						 this);
}



void
AeN64Driver::configureCallback (Widget w, XtPointer clientData, XtPointer callData) 
{ 
    AeN64Driver * driver = (AeN64Driver *) clientData;
    driver->PoseConfigure();
}


void
AeN64Driver::saveConfigCallback (Widget w, XtPointer clientData, XtPointer callData) 
{ 
    AeN64Driver * driver = (AeN64Driver *) clientData;
    AeN64Config * config = driver->GetConfig ();

    assert (config);

    if (theFileSelectionDialog->postAndWait("Save configuration:") == VkDialogManager::OK)
	config->WriteToFile (theFileSelectionDialog->fileName ());
}


void
AeN64Driver::loadConfigCallback (Widget w, XtPointer clientData, XtPointer callData) 
{ 
    AeN64Driver * driver = (AeN64Driver *) clientData;
    AeN64Config * config = driver->GetConfig ();

    assert (config);

    if (theFileSelectionDialog->postAndWait("Load configuration:") == VkDialogManager::OK)
    {
	config->ReadFromFile (theFileSelectionDialog->fileName ());
	driver->ReconfigureAudio ();
    }
}


void
AeN64Driver::clearProfileCallback (Widget w, XtPointer clientData, XtPointer callData) 
{ 
    AeN64Driver * driver = (AeN64Driver *) clientData;
    driver->ResetMidi ();
}


void
AeN64Driver::resetSystemCallback (Widget w, XtPointer clientData, XtPointer callData) 
{ 
    AeN64Driver * driver = (AeN64Driver *) clientData;
    driver->ResetDevice ();
}