mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 15:45:42 +08:00
Fix build with Clang on Windows
This commit is contained in:
@@ -78,7 +78,8 @@ namespace XSwiftBus
|
||||
{
|
||||
const int y = boxTop - (lineHeight + lineSpace) * (i + 1);
|
||||
const size_t ii = static_cast<size_t>(i);
|
||||
XPLMDrawString(m_messages[ii].m_rgb.data(), x + arrowWidth + arrowWidth / 2, y, const_cast<char *>(m_messages[ii].m_text.c_str()), nullptr, xplmFont_Basic);
|
||||
XPLMDrawString(m_messages[ii].m_rgb.data(), x + arrowWidth + arrowWidth / 2, y,
|
||||
const_cast<char *>(reinterpret_cast<const char *>(m_messages[ii].m_text.c_str())), nullptr, xplmFont_Basic);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,13 +110,12 @@ namespace XSwiftBus
|
||||
CMessageBoxControl::CMessageBoxControl(int left, int right, int top) :
|
||||
m_messageBox(left, right, top),
|
||||
m_showCommand("org/swift-project/xswiftbus/show_messages", "Show XSwiftBus text messages", [this] { show(); }),
|
||||
m_hideCommand("org/swift-project/xswiftbus/hide_messages", "Hide XSwiftBus text messages", [this] { hide(); }),
|
||||
m_toggleCommand("org/swift-project/xswiftbus/toggle_messages", "Toggle XSwiftBus text messages", [this] { toggle(); }),
|
||||
m_scrollUpCommand("org/swift-project/xswiftbus/scroll_up", "Scroll up XSwiftBus text messages", [this] { scrollUp(); }),
|
||||
m_scrollDownCommand("org/swift-project/xswiftbus/scroll_down", "Scroll down XSwiftBus text messages", [this] { scrollDown(); }),
|
||||
m_scrollToTopCommand("org/swift-project/xswiftbus/scroll_top", "Scroll to top of XSwiftBus text messages", [this] { scrollToTop(); }),
|
||||
m_scrollToBottomCommand("org/swift-project/xswiftbus/scroll_bottom", "Scroll to bottom of XSwiftBus text messages", [this] { scrollToBottom(); }),
|
||||
m_debugCommand("org/swift-project/xswiftbus/debug", "", [this] { static int c = 0; this->addMessage({ "hello " + std::to_string(c++), 0, .75, 0 }); })
|
||||
m_hideCommand("org/swift-project/xswiftbus/hide_messages", "Hide XSwiftBus text messages", [this] { hide(); }),
|
||||
m_toggleCommand("org/swift-project/xswiftbus/toggle_messages", "Toggle XSwiftBus text messages", [this] { toggle(); }),
|
||||
m_scrollUpCommand("org/swift-project/xswiftbus/scroll_up", "Scroll up XSwiftBus text messages", [this] { scrollUp(); }),
|
||||
m_scrollDownCommand("org/swift-project/xswiftbus/scroll_down", "Scroll down XSwiftBus text messages", [this] { scrollDown(); }),
|
||||
m_scrollToTopCommand("org/swift-project/xswiftbus/scroll_top", "Scroll to top of XSwiftBus text messages", [this] { scrollToTop(); }),
|
||||
m_scrollToBottomCommand("org/swift-project/xswiftbus/scroll_bottom", "Scroll to bottom of XSwiftBus text messages", [this] { scrollToBottom(); })
|
||||
{
|
||||
show();
|
||||
}
|
||||
|
||||
@@ -22,16 +22,30 @@
|
||||
|
||||
namespace XSwiftBus
|
||||
{
|
||||
//! \cond
|
||||
namespace Private
|
||||
{
|
||||
inline auto empty_u8string()
|
||||
{
|
||||
using namespace std::literals;
|
||||
return u8""s;
|
||||
}
|
||||
}
|
||||
//! \endcond
|
||||
|
||||
/*!
|
||||
* Class representing a single line of text to be drawn in a message box.
|
||||
*/
|
||||
struct CMessage
|
||||
{
|
||||
//! String type.
|
||||
using string = decltype(Private::empty_u8string());
|
||||
|
||||
//! Constructor.
|
||||
CMessage(const std::string &text, float r = 1, float g = 1, float b = 1) : m_text(text), m_rgb{{ r, g, b }} {}
|
||||
CMessage(const string &text, float r = 1, float g = 1, float b = 1) : m_text(text), m_rgb{{ r, g, b }} {}
|
||||
|
||||
//! Text.
|
||||
std::string m_text;
|
||||
string m_text;
|
||||
|
||||
//! Color.
|
||||
std::array<float, 3> m_rgb;
|
||||
@@ -148,7 +162,6 @@ namespace XSwiftBus
|
||||
CCommand m_scrollDownCommand;
|
||||
CCommand m_scrollToTopCommand;
|
||||
CCommand m_scrollToBottomCommand;
|
||||
CCommand m_debugCommand;
|
||||
};
|
||||
} //ns
|
||||
|
||||
|
||||
@@ -145,12 +145,13 @@ namespace XSwiftBus
|
||||
void CService::addTextMessage(const std::string &text, double red, double green, double blue)
|
||||
{
|
||||
if (text.empty()) { return; }
|
||||
static const std::string ellipsis = u8"\u2026";
|
||||
static const CMessage::string ellipsis = u8"\u2026";
|
||||
const int lineLength = m_messages.maxLineLength() - static_cast<int>(ellipsis.size());
|
||||
std::vector<std::string> wrappedLines;
|
||||
std::vector<CMessage::string> wrappedLines;
|
||||
for (size_t i = 0; i < text.size(); i += static_cast<size_t>(lineLength))
|
||||
{
|
||||
wrappedLines.push_back(text.substr(i, static_cast<size_t>(lineLength)) + ellipsis);
|
||||
wrappedLines.emplace_back(text.begin() + i, text.begin() + i + static_cast<size_t>(lineLength));
|
||||
wrappedLines.back() += ellipsis;
|
||||
}
|
||||
wrappedLines.back().erase(wrappedLines.back().size() - ellipsis.size());
|
||||
if (wrappedLines.back().empty()) { wrappedLines.pop_back(); }
|
||||
|
||||
Reference in New Issue
Block a user