6 protected HtmlWidget m_content;
7 protected float m_page_height;
8 protected float m_content_total_height;
9 protected float m_content_pos;
13 layoutRoot =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/day_z_book.layout");
14 Class.CastTo(m_content, layoutRoot.FindAnyWidget(
"HtmlWidget"));
15 Class.CastTo(m_author, layoutRoot.FindAnyWidget(
"Author"));
16 Class.CastTo(m_title, layoutRoot.FindAnyWidget(
"Title"));
17 Class.CastTo(m_page, layoutRoot.FindAnyWidget(
"Page"));
20 m_content.GetScreenSize(width, m_page_height);
26 m_content.LoadFile( book.ConfigGetString(
"file") );
27 m_author.SetText( book.ConfigGetString(
"author") );
28 m_title.SetText( book.ConfigGetString(
"title") );
29 m_content_total_height = m_content.GetContentHeight();
36 super.OnClick(w,
x,
y, button);
38 switch (w.GetUserID())
54 void NextPrevPage(
bool next)
58 m_content_pos = m_content_pos + m_page_height;
62 m_content_pos = m_content_pos - m_page_height;
66 if (m_content_total_height > m_page_height)
68 maxOffset = m_content_total_height - m_page_height;
71 if (m_content_pos < 0)
76 if (m_content_pos > maxOffset)
78 m_content_pos = maxOffset;
81 m_content.SetContentOffset(m_content_pos,
true);
83 float pagesTotal =
Math.Ceil(m_content_total_height / m_page_height);
84 float currPage =
Math.Round(m_content_pos / m_page_height) + 1;
86 m_page.SetText( currPage.ToString() +
" / " + pagesTotal.ToString() );