Exemple #1
0
void UpdateStatusLines()
{
    std::string rule = currlayer->algo->getrule();

    status1 = "Pattern=";
    if (currlayer->dirty) {
        // display asterisk to indicate pattern has been modified
        status1 += "*";
    }
    status1 += currlayer->currname;
    status1 += widescreen ? large_algo_prefix : small_algo_prefix;
    status1 += GetAlgoName(currlayer->algtype);
    status1 += widescreen ? large_rule_prefix : small_rule_prefix;
    status1 += rule;

    // show rule name if one exists and is not same as rule
    // (best NOT to remove any suffix like ":T100,200" in case we allow
    // users to name "B3/S23:T100,200" as "Life on torus")
    std::string rulename = GetRuleName(rule);
    if (!rulename.empty() && rulename != rule) {
        status1 += " [";
        status1 += rulename;
        status1 += "]";
    }

    char scalestr[32];
    int mag = currlayer->view->getmag();
    if (mag < 0) {
        sprintf(scalestr, "2^%d:1", -mag);
    } else {
        sprintf(scalestr, "1:%d", 1 << mag);
    }

    char stepstr[32];
    if (currlayer->currexpo < 0) {
        // show delay in secs
        sprintf(stepstr, "Delay=%gs", (double)GetCurrentDelay() / 1000.0);
    } else {
        sprintf(stepstr, "Step=%d^%d", currlayer->currbase, currlayer->currexpo);
    }

    status2 = widescreen ? large_gen_prefix : small_gen_prefix;
    if (nopattupdate) {
        status2 += "0";
    } else {
        status2 += Stringify(currlayer->algo->getGeneration());
    }
    status2 += widescreen ? large_pop_prefix : small_pop_prefix;
    if (nopattupdate) {
        status2 += "0";
    } else {
        bigint popcount = currlayer->algo->getPopulation();
        if (popcount.sign() < 0) {
            // getPopulation returns -1 if it can't be calculated
            status2 += "?";
        } else {
            status2 += Stringify(popcount);
        }
    }
    status2 += widescreen ? large_scale_prefix : small_scale_prefix;
    status2 += scalestr;
    status2 += widescreen ? large_step_prefix : small_step_prefix;
    status2 += stepstr;
    status2 += widescreen ? large_xy_prefix : small_xy_prefix;
    #ifdef WEB_GUI
        // in web app we show the cursor's current cell location,
        // or nothing if the cursor is outside the viewport (ie. showxy is false)
        if (showxy) {
            bigint xo, yo;
            bigint xpos = currx;   xpos -= currlayer->originx;
            bigint ypos = curry;   ypos -= currlayer->originy;
            if (mathcoords) {
                // Y values increase upwards
                bigint temp = 0;
                temp -= ypos;
                ypos = temp;
            }
            status2 += Stringify(xpos);
            status2 += " ";
            status2 += Stringify(ypos);
        }
    #else
        // in iOS and Android apps we show location of the cell in middle of viewport
        status2 += Stringify(currlayer->view->x);
        status2 += " ";
        status2 += Stringify(currlayer->view->y);
    #endif
}
Stroka CPrimitiveGroup::DebugString() const {
    TStringStream str;
    str << "CPrimitiveGroup \"" << NStr::DebugEncode(UTF8ToWide(GetRuleName())) << "\": homonyms [" << m_ActiveHomonyms << "]";
    return str.Str();
}