void MyDialog::GetHiscoreName() { MAS::Window win; Dialog clientArea; ClearScreen clr; EditBox edit; Label l1, l2; Button but; clientArea.Add(clr); win.title.SetText("Game Over!"); clientArea.Resize(278, 98); l1.Setup(10, 10, 200, 16, 0, 0, "You have a high score!", 0); l2.Setup(10, 38, 128, 16, 0, 0, "Enter your name:", 0); edit.Setup(150, 26, 100, 28, 0, D_EXIT, "player", 8); but.Setup(50, 60, 130, 24, ALLEGRO_KEY_O, D_EXIT, "&OK"); clientArea.Add(l1); clientArea.Add(l2); clientArea.Add(edit); clientArea.Add(but); win.SetClientArea(&clientArea); win.Centre(); edit.Select(); //TODO //win.Popup(this, win.x(), win.y(), &edit); hsc->Add(edit.GetText(), eScore.GetInt(), eLines.GetInt()); }
void Meal(void* args) { //Disable buttons/settings cButton.SetText("End Meal"); cEditDelay.SetEnabled(0); cComboDate.SetEnabled(0); cComboRecord.SetEnabled(0); cComboSensitivity.SetEnabled(0); mScale.EditItem(ID_SCALE_ZERO, "&Zero", MF_DISABLED); //Get Variables char* tmpWait = new char[255]; cEditDelay.GetText(tmpWait); iMealWait = atoi(tmpWait); if (iMealWait==0) iMealWait = 10; mCompare = cComboRecord.GetSelectedItem(); mSensitivity = ((float)cComboSensitivity.GetSelectedItem()+1.0)/100.0; //Initialize the first weight AddCurrentValue(); //Activate the meal bMealActive = true; while(bMealActive) { //So if the scale is not stable, set the current time to when the scale was last stable if (!scale->IsStable()) uLastStable = time(0); if (time(0) - uLastStable >= iMealWait) { if (scale!=NULL && scale->IsConnected()) { if (fabs(scale->GetWeight() - fLastWeight) >= mSensitivity) { if ((mCompare == 0 || mCompare == 2) && scale->GetWeight() > fLastWeight) AddCurrentValue(); if ((mCompare == 1 || mCompare == 2) && scale->GetWeight() < fLastWeight) AddCurrentValue(); } } } //Sleep for .1 second Sleep(100); } //Check and see if the person saved the file CheckAndSave(); //Enable them cButton.SetText("New Meal"); cEditDelay.SetEnabled(1); cComboDate.SetEnabled(1); cComboRecord.SetEnabled(1); cComboSensitivity.SetEnabled(1); mScale.EditItem(ID_SCALE_ZERO, "&Zero", 0); }