コード例 #1
0
/**
 * Initialize the Window. Called by the system only in
 * Lua initialization.
 *
 * When you create your own custom window, this is where you put
 * your own custom initialization that needs to happen before
 * children are created. Fundamental window initialization is
 * handled in every class by this function, so <b>when you
 * override this function you almost always want to call your
 * base class to handle base class initialization.</b>
 */
void TGameWindow::Init(TWindowStyle &style)
{
	TScript * s = TWindowManager::GetInstance()->GetScript();
	ScriptRegisterMemberDirect(s,"SendGameMessage",this,TGameWindow::SendGameMessage);

    // Start the window animation
    StartWindowAnimation( 16 );

	mRows = style.GetInt("rows");
	mColumns= style.GetInt("columns");

	// Send keyboard events our way if no one else uses them
	FindParentModal()->SetDefaultFocus(this);
}
コード例 #2
0
ファイル: credits.cpp プロジェクト: frank-borkin/gornak
void TCredits::Init(TWindowStyle& style)
{
    TWindow::Init(style);

    mCreditsTime = style.GetInt("time");
    mCreditsIntroPause = style.GetInt("intropause");
    mColumnGap = style.GetInt("columngap");
    mColumnWidth = style.GetInt("columnwidth");

    ASSERT(mColumnWidth);
    ASSERT(mColumnGap);
    ASSERT(mCreditsTime);

    mFont = style.GetString( "font","");
    mFontSize = (int)style.GetNumber( "fontsize", 16 );
    mFontColor = style.GetColor( "fontcolor", white);
    TColor headerColor = style.GetColor( "headercolor", white);
    mHeaderColorHex.format("%02x%02x%02x%02x", (int)(headerColor.r * 255), (int)(headerColor.g * 255), (int)(headerColor.b * 255), (int)(headerColor.a * 255));
    mCreditsFile = style.GetString("file","");

    TFile* fp = pf_open(mCreditsFile.c_str(), kReadText);

    str col1="\n";
    str col2="\n";
    str col3="\n";
    const int kSize= 1024;
    char buffer[kSize];
    while (pf_gets(fp, buffer, kSize)) 
    {
        buffer[strlen(buffer)-1]=0;
        char* sep = strchr(buffer, '|');
        if (sep) 
		{
            *sep= 0;
            sep++;
            col1 += CreditLine(buffer, mHeaderColorHex);
            col2 += CreditLine(sep, mHeaderColorHex);
            col3 += str("\n");
        } 
		else 
		{
            col1 += str("\n");
            col2 += str("\n");
            col3 += CreditLine(buffer, mHeaderColorHex);
        }
    }

    pf_close(fp);

    int space = GetWindowHeight();

    for (uint32_t i=0; i<space / mFontSize; i++) 
    {
        col1 += "\n";
        col2 += "\n";
        col3 += "\n";
    }

    mText1 = TTextGraphic::Create(col1+col1, mColumnWidth, space, TText::kHAlignCenter, mFont.c_str(), mFontSize, mFontColor);
    mText2 = TTextGraphic::Create(col2+col2, mColumnWidth, space, TText::kHAlignCenter, mFont.c_str(), mFontSize, mFontColor);
    mText3 = TTextGraphic::Create(col3+col3, mColumnWidth*2+mColumnGap, space, TText::kHAlignCenter, mFont.c_str(), mFontSize, mFontColor);

    TRect bounds;
    mText1->GetTextBounds(&bounds);
    mHeight = bounds.mY2/2;
    mStart = 0;

    StartWindowAnimation(16);
}