Example #1
0
void HandleMenu(HWND hWnd, DWORD opt) {
    switch(opt) {
        case ID_SCALE_CONNECT:
            cEditBox.SetText("Trying to communicate with the scale...");
            mScale.EditItem(ID_SCALE_CONNECT, "&Connecting...", MF_DISABLED);
            _beginthread(ScaleConnect, 0, (void*) hWnd);
        break;

        case ID_FILE_NEW:
            if (!bSaved && vMealItems.size() > 0) {
                switch(MessageBox(hWnd, "You haven't saved the current meal, would you like to?","Hold Up!", MB_YESNOCANCEL | MB_ICONINFORMATION)) {
                    case IDYES:
                        if (CheckAndSave()==-1) break;
                    case IDNO:
                        cListBox.Clear();
                        vMealItems.clear();
                        strcpy(cSaveName, "");
                        cWindow.SetTitle("MealTrack - Untitled");
                        cButton.SetText("Start Meal");
                    break;

                    case IDCANCEL:
                    default:
                    break;
                }
            } else {
                cListBox.Clear();
                vMealItems.clear();
                strcpy(cSaveName, "");
                cWindow.SetTitle("MealTrack - Untitled");
                cButton.SetText("Start Meal");
            }
        break;

        case ID_FILE_SAVE:
            GetSaveFile(hWnd);
            if (vMealItems.size() >= 1) CheckAndSave();

            char tmp[313];
            sprintf(tmp, "MealTrack - %s", strrchr(cSaveName,'\\') + 1);
            cWindow.SetTitle(tmp);
        break;

        case ID_FILE_EXIT:
            PostMessage(hWnd, WM_CLOSE, 0, 0);
        break;

        case ID_SCALE_ZERO:
            if (scale != NULL) scale->Zero();
        break;
    }
}
void UfopaediaCategory::Begin()
{
	Label* infolabel = ((Label*)menuform->FindControl("TEXT_INFO"));
	ListBox* entrylist = ((ListBox*)menuform->FindControl("LISTBOX_SHORTCUTS"));
	entrylist->Clear();
	entrylist->ItemHeight = infolabel->GetFont()->GetFontHeight() + 2;
	int idx = 1;
	for( auto entry = Entries.begin(); entry != Entries.end(); entry++ )
	{
		std::shared_ptr<UfopaediaEntry> e = (std::shared_ptr<UfopaediaEntry>)*entry;
		TextButton* tb = new TextButton( fw, nullptr, fw.gamecore->GetString(e->Title), infolabel->GetFont() );
		tb->Name = "Index" + Strings::FromInteger( idx );
		tb->RenderStyle = TextButton::TextButtonRenderStyles::SolidButtonStyle;
		tb->TextHAlign = HorizontalAlignment::Left;
		tb->TextVAlign = VerticalAlignment::Centre;
		tb->BackgroundColour.a = 0;
		entrylist->AddItem( tb );
		idx++;
	}

	SetupForm();
	SetTopic( 0 );
}