当前位置: 首页>>代码示例>>C++>>正文


C++ Dialog::AddPausePosition方法代码示例

本文整理汇总了C++中Dialog::AddPausePosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Dialog::AddPausePosition方法的具体用法?C++ Dialog::AddPausePosition怎么用?C++ Dialog::AddPausePosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dialog的用法示例。


在下文中一共展示了Dialog::AddPausePosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Dialog

Dialog * Dialog::CreateForString(const string &dialogText, const string &filePath, int timeBeforeDialogInitial, int delayBeforeContinuing, bool isInterrogation, bool isPassive, bool isConfrontation, bool canNavigateBack, bool canNavigateForward, bool presentEvidenceAutomatically, bool canStopPresentingEvidence)
{
    Dialog *pDialog = new Dialog(filePath, timeBeforeDialogInitial, delayBeforeContinuing, isInterrogation, isPassive, isConfrontation, canNavigateBack, canNavigateForward, presentEvidenceAutomatically, canStopPresentingEvidence);

    double allowedWidth = textAreaRect.GetWidth() - desiredPadding * 2;
    string fullString = "";
    deque<string> wordList = split(dialogText, ' ');

    while (!wordList.empty())
    {
        string curstring = "";
        double curTextWidth = 0;
        bool lineDone = false;
        bool addSpace = false;

        if (fullString.length() > 0)
        {
            fullString += "\n";
        }

        while (!lineDone)
        {
            string stringToTest = (addSpace ? " " : "") + wordList.front();
            double curStringWidth = pDialogFont->GetWidth(pDialog->StripEvents(stringToTest));

            // If we've got a single word that takes up more than the entire length of the screen,
            // then we need to split it up.
            if (curTextWidth == 0 && curStringWidth > allowedWidth)
            {
                string testString = "";
                string lastTestString = "";
                curStringWidth = 0;

                while (curStringWidth <= allowedWidth)
                {
                    if (stringToTest[0] == '{')
                    {
                        testString += stringToTest[0];
                        stringToTest = stringToTest.substr(1);

                        while (stringToTest[0] != '}')
                        {
                            testString += stringToTest[0];
                            stringToTest = stringToTest.substr(1);
                        }

                        testString += stringToTest[0];
                        stringToTest = stringToTest.substr(1);
                    }

                    lastTestString = testString;
                    testString += stringToTest[0];
                    double testCurStringWidth = pDialogFont->GetWidth(pDialog->StripEvents(testString));

                    if (testCurStringWidth > allowedWidth)
                    {
                        break;
                    }

                    curStringWidth = testCurStringWidth;
                    stringToTest = stringToTest.substr(1);
                }

                wordList.insert(wordList.begin() + 1, stringToTest);
                stringToTest = lastTestString;
            }

            if (curTextWidth + curStringWidth <= allowedWidth)
            {
                string stringToPrependOnNext;
                stringToTest = pDialog->ParseEvents(fullString.length() + curstring.length(), stringToTest, &stringToPrependOnNext);
                curstring += stringToTest;
                curTextWidth += curStringWidth;
                wordList.pop_front();
                addSpace = true;

                if (wordList.empty())
                {
                    lineDone = true;
                }
                else
                {
                    wordList[0] = stringToPrependOnNext + wordList.front();
                }
            }
            else
            {
                lineDone = true;
            }
        }

        fullString += curstring;
    }

    pDialog->SetText(fullString);

    if (delayBeforeContinuing >= 0)
    {
        pDialog->AddPausePosition(fullString.length(), delayBeforeContinuing);
    }
//.........这里部分代码省略.........
开发者ID:Abion47,项目名称:my-little-investigations,代码行数:101,代码来源:Dialog.cpp


注:本文中的Dialog::AddPausePosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。