private MenuPhase phase; //the current phase of the window /// <summary> /// Constructor for LibrarianMenu. /// Initializes fields and preps the window for user interaction. /// </summary> /// <param name="controller">controller for library blient</param> /// <param name="mainWindow">reference to the MainWindow that opened this menu</param> public LibrarianMenu(LibraryClientController controller, MainWindow mainWindow) { InitializeComponent(); //initialize fields this.controller = controller; this.mainWindow = mainWindow; phase = MenuPhase.Start; reportsButtonArray = new Button[] { LibrariansReportButton, CardholdersReportButton, AuthorsReportButton, OverdueBooksReportButton }; mainButtonArray = new Button[] { SearchButton, CheckOutInButton, ReportsButton, AddBook }; checkOutInButtonArray = new Button[] { CheckOutButton, CheckInButon }; //prep buttons for user interaction InitializeReportsButtons(); InitializeCheckOutInButtons(); }
/// <summary> /// Event Handler for CheckOutInButton click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CheckOutInButton_Click(object sender, RoutedEventArgs e) { //Move and show appropriate buttons and set to appropriate phase switch (phase) { case MenuPhase.CheckOut: //already in checkout phase, change to start ResetWindow(); phase = MenuPhase.Start; break; case MenuPhase.Start: //at start, show checkout buttons ShowCheckOutInButtons(); phase = MenuPhase.CheckOut; break; default: //in other phase, reset and then show checkout/in buttons ResetWindow(); ShowCheckOutInButtons(); phase = MenuPhase.CheckOut; break; } }
/// <summary> /// Event handler for ReportsButton click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ReportsButton_Click(object sender, RoutedEventArgs e) { //Move and show the appropriate buttons and set to appropriate phase switch (phase) { case MenuPhase.Start: //at start ShowReportsButtons(); phase = MenuPhase.Reports; break; case MenuPhase.Reports: //reports buttons already showing, change to start ResetWindow(); phase = MenuPhase.Start; break; default: //reset window then show reports ResetWindow(); ShowReportsButtons(); phase = MenuPhase.Reports; break; } }
void Update() { if (phase == MenuPhase.MENU && Input.GetButtonDown("Vertical")) { if (Input.GetAxis("Vertical") < 0 && menuBtn == MenuBtn.PLAY) { selector.DOAnchorPosY(creditsBtn_y, 1f); menuBtn = MenuBtn.CREDITS; SfxManager.I.Play("sfx_over"); } else if (Input.GetAxis("Vertical") < 1 && menuBtn == MenuBtn.CREDITS) { selector.DOAnchorPosY(playBtn_y, 1f); menuBtn = MenuBtn.PLAY; SfxManager.I.Play("sfx_over"); } } if (Input.GetButtonDown("Jump")) { if (phase == MenuPhase.MENU && menuBtn == MenuBtn.PLAY) { StartCoroutine(PlayCO()); } else if (phase == MenuPhase.MENU && menuBtn == MenuBtn.CREDITS) { Credits.SetActive(true); phase = MenuPhase.CREDITS; } else if (phase == MenuPhase.CREDITS) { Credits.SetActive(false); phase = MenuPhase.MENU; } } }