예제 #1
0
void
awl::backends::windows::message_box(
	awl::backends::windows::window::const_optional_object_ref const &_opt_window,
	fcppt::string const &_text,
	fcppt::string const &_title,
	UINT const _type
)
{
	if(
		::MessageBox(
			fcppt::optional::maybe(
				_opt_window,
				fcppt::const_<
					HWND
				>(
					nullptr
				),
				[](
					fcppt::reference<
						awl::backends::windows::window::object const
					> const _window
				)
				{
					return
						_window.get().hwnd();
				}
			),
			_text.c_str(),
			_title.c_str(),
			_type
		)
		== 0
	)
		throw
			awl::exception(
				FCPPT_TEXT("MessageBox failed: ")
				+
				_text
			);
}
예제 #2
0
void
fruitlib::message_box(
	fcppt::string const &s)
{
#ifdef FCPPT_CONFIG_WINDOWS_PLATFORM
	if(
		::MessageBox(
			NULL,
			s.c_str(),
			FCPPT_TEXT("Error"),
			MB_OK | MB_ICONERROR) == 0)
		fcppt::io::cerr() << FCPPT_TEXT("MessageBox failed!\n");
#else
	fcppt::io::cerr() << FCPPT_TEXT("Error: ") << s << FCPPT_TEXT("\n");
#endif
}
예제 #3
0
sanguis::tiles::impl::optional_orientation
sanguis::tiles::impl::decode_name(
	fcppt::string const &_name
)
{
	return
		_name.size()
		!=
		fcppt::enum_size<
			sanguis::tiles::direction
		>::value
		?
			sanguis::tiles::impl::optional_orientation()
		:
			fcppt::algorithm::fold(
				fcppt::make_enum_range<
					sanguis::tiles::direction
				>(),
				sanguis::tiles::impl::optional_orientation(
					sanguis::tiles::orientation::null()
				),
				[
					&_name
				](
					sanguis::tiles::direction const _dir,
					sanguis::tiles::impl::optional_orientation const _state
				)
				{
					return
						fcppt::optional::bind(
							_state,
							[
								_dir,
								&_name
							](
								sanguis::tiles::orientation const _orientation
							)
							{
								typedef
								fcppt::optional::object<
									bool
								>
								optional_bool;

								auto const char_to_bool(
									[](
										fcppt::char_type const _value
									)
									-> optional_bool
									{
										switch(
											_value
										)
										{
										case FCPPT_TEXT('0'):
											return
												optional_bool(
													true
												);
										case FCPPT_TEXT('1'):
											return
												optional_bool(
													false
												);
										}

										return
											optional_bool();
									}
								);

								return
									fcppt::optional::map(
										char_to_bool(
											_name[
												fcppt::cast::enum_to_int<
													fcppt::string::size_type
												>(
													_dir
												)
											]
										),
										[
											_orientation,
											_dir
										](
											bool const _value
										)
										-> sanguis::tiles::orientation
										{
											return
												_value
												?
													_orientation
													|
													_dir
												:
													_orientation
												;
										}
									);
							}
						);
				}
			);
}