void Dlg_AchievementsReporter::SetupColumns()
{
	//	Remove all columns,
	while (ListView_DeleteColumn(m_hList, 0)) {}

	//	Remove all data.
	ListView_DeleteAllItems(m_hList);
	auto limit{ static_cast<int>(col_num) };
	for (auto i = 0; i < limit; i++)
	{

		auto sStr{ std::string{col_names.at(to_unsigned(i))} }; // you can't do it directly

		// would be easier with delegates...
		// Probably should be made in to a class from repetition
		LV_COLUMN col
		{
			LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_FMT,
			LVCFMT_LEFT | LVCFMT_FIXED_WIDTH,
			col_sizes.at(to_unsigned(i)),
			sStr.data(),
			255,
			i
		};

		if (i == limit - 1)	//If the last element: fill to the end
			col.fmt |= LVCFMT_FILL;

		ListView_InsertColumn(m_hList, i, &col);
	}
}
int Dlg_AchievementsReporter::AddAchievementToListBox(const Achievement* pAch)
{
	for (auto& i : repcol_arr)
	{
		// I'd suggest initilizing the achievement strings to a fixed capacity using reserve() instead
		auto col{ etoi(i) };
		auto urows{ to_unsigned(ms_nNumOccupiedRows) };
		switch (i)
		{
		case ReporterColumns::NumReporterColumns:
			_FALLTHROUGH;
		case ReporterColumns::Checked:
			ms_lbxData.at(urows).at(col) = "";
			break;
		case ReporterColumns::Title:
			ms_lbxData.at(urows).at(col) = pAch->Title();
			break;
		case ReporterColumns::Desc:
			ms_lbxData.at(urows).at(col) = pAch->Description();
			break;
		case ReporterColumns::Author:
			ms_lbxData.at(urows).at(col) = pAch->Author();
			break;
		case ReporterColumns::Achieved:
			ms_lbxData.at(urows).at(col) = !pAch->Active() ? "Yes" : "No";
			break;
		default:
			throw std::out_of_range{ "Unknown col!" };
		}
	}




	LV_ITEM item{ LVIF_TEXT, ms_nNumOccupiedRows, 0, 0_z, 0_z, nullptr, 256 };


	for (size_t i = 0; i < num_rep_cols; ++i)
	{
		item.iSubItem = to_signed(i);
		// how did i miss this?
		tstring sStr = ms_lbxData.at(to_unsigned(ms_nNumOccupiedRows)).at(i);	//Scoped cache
		item.pszText = sStr.data();

		if (i == 0)
			item.iItem = ListView_InsertItem(m_hList, &item);
		else
			ListView_SetItem(m_hList, &item);
	}

	ASSERT(item.iItem == ms_nNumOccupiedRows);

	ms_nNumOccupiedRows++;	//	Last thing to do!
	return item.iItem;
}
示例#3
0
文件: strings.c 项目: chriso/intern
uint32_t strings_intern(struct strings *strings, const char *string) {
#ifdef INLINE_UNSIGNED
    if (is_small_unsigned(string)) {
        uint32_t number = to_unsigned(string);
        if (number < unsigned_tag) {
            return number | unsigned_tag;
        }
    }
#endif

    uint32_t hash = strings_hash(strings, string);
    tree_node_t *node = find_node(strings, hash);
    if (node) {
        if (strcmp(node->string, string)) {
            return strings_intern_collision(strings, node, string, hash);
        }
    } else {
        if (!(node = create_node(strings, hash, string))) {
            return 0;
        }
        tree_insert(&strings->hash_map, node);
    }

    return node->id;
}
示例#4
0
文件: strings.c 项目: chriso/intern
uint32_t strings_lookup(const struct strings *strings, const char *string) {
#ifdef INLINE_UNSIGNED
    if (is_small_unsigned(string)) {
        uint32_t number = to_unsigned(string);
        if (number < unsigned_tag) {
            return number | unsigned_tag;
        }
    }
#endif

    uint32_t hash = strings_hash(strings, string);
    tree_node_t *node = find_node(strings, hash);
    if (node) {
        do {
            if (!strcmp(node->string, string)) {
                return node->id;
            }
        } while ((node = node->next));
    }

    return 0;
}
示例#5
0
vm_obj format_nest(vm_obj const & i, vm_obj const & fmt) {
    return to_obj(nest(to_unsigned(i), to_format(fmt)));
}
/// @short двойной факториал
real_t dfact(real_t value) {
	return boost::math::double_factorial<real_t>(to_unsigned(value));
}
/// @short Факториал
real_t fact(real_t value) {
	return boost::math::factorial<real_t>(to_unsigned(value));
}
void Dlg_AchievementsReporter::OnOK(HWND hwnd)
{

	m_hProblem2 = GetDlgItem(hwnd, IDC_RA_PROBLEMTYPE2);





	const auto bProblem1Sel{ Button_GetCheck(m_hProblem1) };
	const auto bProblem2Sel{ Button_GetCheck(m_hProblem2) };

	if ((bProblem1Sel == false) && (bProblem2Sel == false))
	{
		MessageBox(nullptr, TEXT("Please select a problem type."),
			TEXT("Warning"), MB_ICONWARNING);
		return;
	}
	// 0==?
	auto nProblemType{ bProblem1Sel ? 1 : bProblem2Sel ? 2 : 0 };
	auto sProblemTypeNice{ PROBLEM_STR.at(to_unsigned(nProblemType)) };

	std::string sBuggedIDs;
	sBuggedIDs.reserve(1024);

	int nReportCount = 0;

	const size_t nListSize = to_unsigned(ListView_GetItemCount(m_hList));
	for (size_t i = 0; i < nListSize; ++i)
	{
		if (ListView_GetCheckState(m_hList, i) != 0)
		{
			//	NASTY big assumption here...
			auto buffer{
				tfm::format("%d,",
				g_pActiveAchievements->GetAchievement(i).ID())
			};
			sBuggedIDs+=buffer;

			//ListView_GetItem( hList );	
			nReportCount++;
		}
	}

	// Needs another check
	if (sBuggedIDs == "")
	{
		// even with this it might be strange, there has to be a better way to do this...
		// The close button will still close it even though this warning will show up
		MessageBox(GetActiveWindow(),
			_T("You need to to select at least one achievement"),
			_T("Warning"), MB_OK);
		return;
	}

	if (nReportCount > 5)
	{
		if (MessageBox(nullptr,
			TEXT("You have over 5 achievements selected. Is this OK?"),
			TEXT("Warning"), MB_YESNO) == IDNO)
			return;
	}


	m_hComment = GetDlgItem(hwnd, IDC_RA_BROKENACHIEVEMENTREPORTCOMMENT);

	// Now I remember
	auto len{ GetTextLength(m_hComment)};
	std::string sBugReportComment;

	// This ones is extremly important or the capacity will change
	sBugReportComment.reserve(static_cast<std::size_t>(len));
	GetText(m_hComment, len, sBugReportComment.data());


	//	Intentionally MBCS
	auto sBugReportInFull{ tfm::format(
		"--New Bug Report--\n"
		"\n"
		"Game: %s\n"
		"Achievement IDs: %s\n"
		"Problem: %s\n"
		"Reporter: %s\n"
		"ROM Checksum: %s\n"
		"\n"
		"Comment: %s\n"
		"\n"
		"Is this OK?",
		g_pCurrentGameData->GameTitle(),
		sBuggedIDs,
		sProblemTypeNice,
		username(),
		g_sCurrentROMMD5,
		sBugReportComment.c_str()) // strange, it won't show itself as a regular string
	};

	if (MessageBox(nullptr, NativeStr(sBugReportInFull).c_str(),
		TEXT("Summary"), MB_YESNO) == IDNO)
		return;

	PostArgs args
	{
		{ 'u', cusername() },
		{ 't', user_token()},
		{ 'i', sBuggedIDs.c_str() },
		{ 'p', std::to_string(nProblemType) },
		{ 'n', sBugReportComment.c_str() },
		{ 'm', g_sCurrentROMMD5.c_str() }
	};

	Document doc;
	// Something is wrong with this function...
	if (RAWeb::DoBlockingRequest(RequestSubmitTicket, args, doc))
	{

		// really weird, success is in there but it's not
		// really bizzare need to check the contents of JSON and do a new approach

		//for (auto& i : doc.GetObjectA())
		//{
		//	RA_LOG("Type of member %s is %s\n", i.name.GetString(),
		//		i.value.GetType());
		//}




		if (doc["Success"].GetBool())
		{
			auto msg{
				"Submitted OK!\n"
				"\n"
				"Thank you for reporting that bug(s), and sorry it hasn't worked correctly.\n"
				"\n"
				"The development team will investigate this bug as soon as possible\n"
				"and we will send you a message on RetroAchievements.org\n"
				"as soon as we have a solution.\n"
				"\n"
				"Thanks again!"
			};

			MessageBox(hwnd, NativeStr(msg).c_str(), TEXT("Success!"), MB_OK);
			// this is so strange, the achievements get sent over but says it's failing
			IRA_Dialog::OnOK(hwnd);
			return;
		}
		else
		{
			auto buffer{ tfm::format(
				"Failed!\n"
				"\n"
				"Response From Server:\n"
				"\n"
				"Error code: %d", doc.GetParseError())
			};
			MessageBox(hwnd, NativeStr(buffer).c_str(), TEXT("Error from server!"), MB_OK);
			return;
		}
	}
	else
	{
		MessageBox(hwnd,
			TEXT("Failed!\n")
			TEXT("\n")
			TEXT("Cannot reach server... are you online?\n")
			TEXT("\n"),
			TEXT("Error!"), MB_OK);
		return;
	}
}
示例#9
0
vm_obj options_get_nat(vm_obj const & o, vm_obj const & n, vm_obj const & v) {
    return mk_vm_nat(to_options(o).get_unsigned(to_name(n), to_unsigned(v)));
}
示例#10
0
vm_obj options_set_nat(vm_obj const & o, vm_obj const & n, vm_obj const & v) {
    return to_obj(to_options(o).update(to_name(n), to_unsigned(v)));
}