Previous/Next button implemented

actorid
gugus 13 years ago
parent 9031f62962
commit eb4dea3d87

@ -83,6 +83,10 @@ MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager)
getWidget(mLeftTextWidget, "LeftText");
getWidget(mRightTextWidget, "RightText");
getWidget(mPrevBtn, "PrevPageBTN");
mPrevBtn->eventMouseButtonClick = MyGUI::newDelegate(this,&MWGui::JournalWindow::notifyPrevPage);
getWidget(mNextBtn, "NextPageBTN");
mNextBtn->eventMouseButtonClick = MyGUI::newDelegate(this,&MWGui::JournalWindow::notifyNextPage);
//MyGUI::ItemBox* list = new MyGUI::ItemBox();
//list->addItem("qaq","aqzazaz");
//mScrollerWidget->addChildItem(list);
@ -107,11 +111,9 @@ MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager)
void MWGui::JournalWindow::open()
{
mPageNumber = 0;
if(mWindowManager.getEnvironment().mJournal->begin()!=mWindowManager.getEnvironment().mJournal->end())
{
std::vector<std::string> leftPages;
std::vector<std::string> rightPages;
book journal;
journal.endLine = 0;
@ -119,7 +121,7 @@ void MWGui::JournalWindow::open()
{
std::string a = it->getText(mWindowManager.getEnvironment().mWorld->getStore());
std::cout << a;
journal = formatText(a,journal,10,20);
journal = formatText(a,journal,10,17);
journal.endLine = journal.endLine +1;
journal.pages.back() = journal.pages.back() + std::string("\n");
}
@ -140,8 +142,9 @@ void MWGui::JournalWindow::open()
}
if(!left) rightPages.push_back("");
displayLeftText(leftPages.back());
displayRightText(rightPages.back());
mPageNumber = leftPages.size()-1;
displayLeftText(leftPages[mPageNumber]);
displayRightText(rightPages[mPageNumber]);
}
else
@ -165,4 +168,27 @@ void MWGui::JournalWindow::displayRightText(std::string text)
{
mRightTextWidget->eraseText(0,mRightTextWidget->getTextLength());
mRightTextWidget->addText(text);
}
void MWGui::JournalWindow::notifyNextPage(MyGUI::WidgetPtr _sender)
{
std::cout << mPageNumber;
if(mPageNumber < int(leftPages.size())-1)
{
mPageNumber = mPageNumber + 1;
displayLeftText(leftPages[mPageNumber]);
displayRightText(rightPages[mPageNumber]);
}
}
void MWGui::JournalWindow::notifyPrevPage(MyGUI::WidgetPtr _sender)
{
std::cout << mPageNumber;
if(mPageNumber > 0)
{
mPageNumber = mPageNumber - 1;
displayLeftText(leftPages[mPageNumber]);
displayRightText(rightPages[mPageNumber]);
}
}

@ -31,6 +31,13 @@ namespace MWGui
void displayLeftText(std::string text);
void displayRightText(std::string text);
/**
*Called when next/prev button is used.
*/
void notifyNextPage(MyGUI::WidgetPtr _sender);
void notifyPrevPage(MyGUI::WidgetPtr _sender);
static const int lineHeight;
MyGUI::WidgetPtr skillAreaWidget, skillClientWidget;
@ -38,6 +45,11 @@ namespace MWGui
int lastPos, clientHeight;
MyGUI::EditPtr mLeftTextWidget;
MyGUI::EditPtr mRightTextWidget;
MyGUI::ButtonPtr mPrevBtn;
MyGUI::ButtonPtr mNextBtn;
std::vector<std::string> leftPages;
std::vector<std::string> rightPages;
int mPageNumber; //store the number of the current left page
};
}

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Window" skin="" layer="Windows" align="Left|Top" position="00 200 512 256" name="_Main">
@ -9,8 +8,14 @@
<Property key="Image_Texture" value="textures\tx_menubook.dds"/>
<!--Property key="Image_Texture" value="mwgui.png"/-->
<Widget type="Edit" skin="MW_ConsoleLog" position_real="0.22 0.186667 0.31 0.613333" name = "LeftText"/>
<Widget type="Edit" skin="MW_ConsoleLog" position_real="0.58 0.2 0.3 0.6" name = "RightText"/>
<Widget type="Button" skin="Next_btn" position="370 220 64 32" name="NextPageBTN">
</Widget>
<Widget type="Button" skin="Prev_btn" position="80 220 128 32" name="PrevPageBTN">
</Widget>
<Widget type="Edit" skin="MW_BookPage" position_real="0.15 0.1 0.3 0.8" name = "LeftText"/>
<Widget type="Edit" skin="MW_BookPage" position_real="0.55 0.1 0.3 0.8" name = "RightText"/>
</Widget>
</Widget>

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Skin">
<Skin name="Next_btn" size="64 32" texture="textures\tx_menubook_next_idle.dds">
<BasisSkin type="MainSkin" offset="0 0 64 32" align="ALIGN_VSTRETCH">
<State name="normal" offset="0 0 64 32"/>
</BasisSkin>
</Skin>
<Skin name="Prev_btn" size="128 32" texture="textures\tx_menubook_prev_idle.dds">
<BasisSkin type="MainSkin" offset="0 0 128 32" align="ALIGN_VSTRETCH">
<State name="normal" offset="0 0 128 32"/>
</BasisSkin>
</Skin>
<Skin name = "MW_BookClient" size = "10 10">
<Property key="FontName" value = "MonoFont" />
<Property key="AlignText" value = "Left Top" />
<Property key="Colour" value = "0000FF" />
<!--Property key="Pointer" value = "beam" /-->
<BasisSkin type="EditText" offset = "0 0 10 10" align = "Stretch"/>
</Skin>
<Skin name="MW_BookPage" size="0 0 50 50">
<Property key="WordWrap" value = "true" />
<Child type="Widget" skin="MW_BookClient" offset="0 0 35 10" align = "ALIGN_STRETCH" name = "Client"/>
<!--Child type="VScroll" skin="VScroll" offset = "35 0 15 50" align = "Right VStretch" name = "VScroll"/-->
</Skin>
</MyGUI>
Loading…
Cancel
Save