178{
179 ImGuiWrapper& imgui = *wxGetApp().imgui();
180
182
183
184 std::string title_line;
185 std::string content_lines;
186 size_t end_pos =
m_data.main_text.find_first_of(
'\n');
187 if (end_pos != std::string::npos) {
188 title_line =
m_data.main_text.substr(0, end_pos);
189 title_line = ImGui::ColorMarkerStart + title_line + ImGui::ColorMarkerEnd;
190 content_lines =
m_data.main_text.substr(end_pos + 1);
191 }
192
193 ImGui::SetCursorPos(start_pos);
194 imgui.text(title_line);
195
196 bool is_zh =
has_cjk(content_lines);
197 if (!is_zh) {
198
199 ImGui::SetCursorPosX(start_pos.x);
200 imgui.text_wrapped(content_lines, size.x);
201 }
202 else {
203 Label* wrapped_text = new Label(wxGetApp().GetTopWindow());
204 wrapped_text->Hide();
205 wrapped_text->SetLabelText(wxString::FromUTF8(content_lines));
206 float wrap_width = size.x + ImGui::CalcTextSize("A").x * 5.0f;
207#ifdef __APPLE__
208 wrap_width /= 2.0f;
209#endif
210 wrapped_text->
Wrap(wrap_width);
211 std::string wrapped_content_lines = wrapped_text->GetLabel().ToUTF8().data();
212 wrapped_text->Destroy();
213 ImGui::SetCursorPosX(start_pos.x);
214 imgui.text(wrapped_content_lines);
215 }
216
217
218 if (!
m_data.wiki_url.empty()) {
219 std::string tips_line =
_u8L(
"For more information, please check out our Wiki");
220 std::string wiki_part_text =
_u8L(
"Wiki");
221 std::string first_part_text = tips_line.substr(0, tips_line.find(wiki_part_text));
222 ImVec2 wiki_part_size = ImGui::CalcTextSize(wiki_part_text.c_str());
223 ImVec2 first_part_size = ImGui::CalcTextSize(first_part_text.c_str());
224
225
226 ImGui::SetCursorPosX(start_pos.x);
227 ImVec2 link_start_pos = ImGui::GetCursorScreenPos();
228 imgui.text(first_part_text);
229
230 ImColor HyperColor = ImColor(0, 150, 136, (
int)(255 *
m_fade_opacity)).Value;
231 ImVec2 wiki_part_rect_min = ImVec2(link_start_pos.x + first_part_size.x, link_start_pos.y);
232 ImVec2 wiki_part_rect_max = wiki_part_rect_min + wiki_part_size;
233 ImGui::PushStyleColor(ImGuiCol_Text, HyperColor.Value);
234 ImGui::SetCursorScreenPos(wiki_part_rect_min);
235 imgui.text(wiki_part_text.c_str());
236 ImGui::PopStyleColor();
237
238
239 if (ImGui::IsMouseHoveringRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), true))
240 {
241
242 ImVec2 lineEnd = ImGui::GetItemRectMax();
243 lineEnd.y -= 2.0f;
244 ImVec2 lineStart = lineEnd;
245 lineStart.x = ImGui::GetItemRectMin().x;
246 ImGui::GetWindowDrawList()->AddLine(lineStart, lineEnd, HyperColor);
247
248 if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
250 }
251 }
252 ImGui::PopStyleColor();
253}
void Wrap(int width)
Definition Label.cpp:366
void open_wiki() const
Definition DailyTips.cpp:96
bool has_cjk(const std::string &text)
Definition DailyTips.cpp:162
#define _u8L(s)
Definition I18N.hpp:11