Example #1
0
// reset
//---------------------------------------------------------------------------
// Purpose: Reset all the settings for this window.
//---------------------------------------------------------------------------
void View::reset()
{
    min.zero();
    max.zero();
    status                =  0;
    searchName            = 0;
    title                 = 0;
    subTitle              = 0;
    statusText            = 0;
    focusComponent        = 0;

    setSearchName("donut");
    setTitle("donut");
    setSubTitle("donut");

    removeComponents();

    moveAreaHeight  = DEFAULT_MOVE_AREA_HEIGHT;
    borderSize      = DEFAULT_BORDER_SIZE;
    snapToTolerance = DEFAULT_SNAP_TOLERANCE;

    setAllowResize(true);
    setAllowMove(true);
    setBordered(true);
    setVisible(false);
    setDisplayStatusBar(false);
    setAlwaysOnBottom(false);

    //setScrollBar(false);
} // end reset
EndRoundView::EndRoundView() : SpecialButtonView()
{
    setSearchName("EndRoundView");
    setTitle("Round stats");
    setSubTitle("");

    setAllowResize(false);
    setAllowMove(false);
    setVisible(false);
    setBordered(false);

    int x = (screen->getWidth() / 2) - 250;
    int y = (screen->getHeight() / 2) - 250;
    moveTo(iXY(x, y));
    resize(iXY(500, 500));
    checkArea(iXY(screen->getWidth(),screen->getHeight()));

    allyImage.loadBMP("pics/default/ally.bmp");
    allyRequestImage.loadBMP("pics/default/allyRequest.bmp");
    allyOtherImage.loadBMP("pics/default/allyOther.bmp");
    noAllyImage.loadBMP("pics/default/noAlly.bmp");
    colorImage.loadBMP("pics/default/playerColor.bmp");

    selected_line = -1;
    RectWinner = getClientRect();
    RectWinner.min.x = RectWinner.min.y = 0;
    RectStates = RectWinner;
    RectWinner.max.y = HEADER_HEIGHT-10;
    RectStates.min.y = HEADER_HEIGHT;

} // end EndRoundView::EndRoundView
// ImageSelectorView
//---------------------------------------------------------------------------
ImageSelectorView::ImageSelectorView() : cView()
{
    setTitle("Image Selector View");
    setAllowResize(false);
    setDisplayStatusBar(false);
    setVisible(false);
    setAllowMove(false);
    setBordered(false);

    reset();

} // end ImageSelectorView::ImageSelectorView
GFlagSelectionView::GFlagSelectionView() : View()
{
    setSearchName("GFlagSelectionView");
    setTitle("GFlag Selection");
    setSubTitle("");

    setAllowResize(false);
    setAllowMove(false);
    setVisible(false);
    setBordered(false);

    loaded = false;
}
void
DisconectedView::init()
{
    setBordered(true);

    resize(screen->getWidth(),screen->getHeight());
    moveTo(0,0);

    int bsize = Surface::getTextLength(" ") * 8;
    add( Button::createTextButton( "btok", "Ok", iXY((getClientRect().getSizeX()/2)-(bsize/2),
                (getClientRect().getSizeY()/2)+(Surface::getFontHeight() * 2)),
                bsize, BTN_OK) );
}
// init
//---------------------------------------------------------------------------
void AreYouSureResignView::init()
{
    setBordered(false);
    setAllowResize(false);
    setDisplayStatusBar(false);

    moveTo(iXY(0, 0));
    resize(iXY(800, 600));

    int x = (getClientRect().getSize().x - (141 * 2 + 20)) / 2;
    int y = getClientRect().getSize().y/2 + 30;
    add( Button::createTextButton( _("YES"), iXY(x, y), 137, ActionManager::getAction("disconnect")));
    x += 141 + 10;
    add( Button::createTextButton( _("NO"), iXY(x, y), 137, ActionManager::getAction("hide_confirmdisconnect")));
    loaded = true;
} // end AreYouSureResignView::init
void
DisconectedView::init()
{
    removeAllButtons();

    setBordered(true);
    setAllowResize(false);

    resize(screen->getWidth(),screen->getHeight());
    moveTo(0,0);

    int bsize = Surface::getTextLength(" ") * 8;
    addButtonCenterText(iXY((getClientRect().getSizeX()/2)-(bsize/2),
                (getClientRect().getSizeY()/2)+(Surface::getFontHeight() * 2)),
                bsize, "Ok", "", buttonOk);
}
// init
//---------------------------------------------------------------------------
void GameView::init()
{
    setSearchName("GameView");
    setTitle("Game");
    setSubTitle("");

    setBordered(false);
    setAlwaysOnBottom(true);
    setAllowResize(false);
    setDisplayStatusBar(false);
    setVisible(false);

    moveTo(iXY(0, 0));
    resize(iXY(SCREEN_XPIX, SCREEN_YPIX));

} // end GameView::init
// init
//---------------------------------------------------------------------------
void GameView::init()
{
    setSearchName("GameView");
    setTitle("Game");
    setSubTitle("");

    setBordered(false);
    setAlwaysOnBottom(true);
    setAllowResize(false);
    setDisplayStatusBar(false);
    setVisible(false);

    moveTo(iXY(0, 0));
    resize(iXY(screen->getPixX(), screen->getPixY()));

} // end GameView::init
// MiniMapView
//---------------------------------------------------------------------------
MiniMapView::MiniMapView() : GameTemplateView()
{
    assert(this != 0);

    setSearchName("MiniMapView");
    setTitle("MiniMapView");
    setSubTitle("");
    setAllowResize(false);
    setDisplayStatusBar(false);
    setVisible(false);
    setAllowMove(true);

    setBordered(false);
    
    resize(160, 160);
    add(new MiniMap(1,1,158,158));
} // end MiniMapView::MiniMapView
// MiniMapView
//---------------------------------------------------------------------------
MiniMapView::MiniMapView() : GameTemplateView()
{
    assert(this != 0);

    setSearchName("MiniMapView");
    setTitle("MiniMapView");
    setSubTitle("");
    setAllowResize(false);
    setDisplayStatusBar(false);
    setVisible(false);

    setBordered(false);

    add(CLOSE_VIEW_BUTTON);
    add(MINMAX_VIEW_BUTTON);

} // end MiniMapView::MiniMapView
// init
//---------------------------------------------------------------------------
void AreYouSureResignView::init()
{
    setBordered(false);
    setDisplayStatusBar(false);

    resize(screen->getWidth(), screen->getHeight());
    moveTo(0,0);

    int x = (getClientRect().getSize().x - (141 * 2 + 20)) / 2;
    int y = getClientRect().getSize().y/2 + 30;

    iXY pos(x,y);
    add( Button::createSpecialButton("yes","Yes", pos, BTN_YES));

    pos.x += 141 + 10;
    add( Button::createSpecialButton("no","No", pos, BTN_NO));

} // end AreYouSureResignView::init
void
LoadingView::init()
{
    setSearchName("LoadingView");
    setTitle("Loading Progress");
    setSubTitle("");
    
    setAllowResize(false);
    setAllowMove(false);
    setDisplayStatusBar(false);
    setVisible(false);
    setBordered(false);

    resize(640, 480);
    
    addButtonCenterText(iXY(628 - 60, 302 - 15), 60, "Abort", "Cancel the joining of this game.", bAbort);
    
}
// GameView
//---------------------------------------------------------------------------
GameView::GameView() : View()
{
    setSearchName("GameView");
    setTitle("Game");
    setSubTitle("");

    setBordered(false);
    setAlwaysOnBottom(true);
    setAllowResize(false);
    setDisplayStatusBar(false);
    setVisible(false);

    resize(640,480);
    moveTo(iXY(0, 0));

    add(new InfoBar(0,0));
    // will add after input handling is done
    //add(new MiniMap(100,100));

} // end GameView::GameView
// GameInfoView
//--------------------------------------------------------------------------
GameInfoView::GameInfoView() : GameTemplateView()
{
    setSearchName("GameInfoView");
    setTitle("Information");
    setSubTitle("");

    setAllowResize(false);
    setAllowMove(false);
    setDisplayStatusBar(false);
    setVisible(false);
    setBordered(true);

    moveTo(iXY(0, 0));
    //resizeClientArea(iXY(100, 2 * 2 + 12 * 3 + 8));
    resizeClientArea(iXY(140, 2 * 2 + 12 * 5 + 8));

    // Start it in the top-left corner.
    moveTo(iXY(10000, 0));

} // end GameInfoView::GameInfoView
// MenuTemplateView
//---------------------------------------------------------------------------
MenuTemplateView::MenuTemplateView() : SpecialButtonView()
{
    setSearchName("MenuTemplateView");
    setTitle("MenuTemplate");
    setSubTitle("");

    setAllowResize(false);
    setVisible(false);
    setAllowMove(false);
    setDisplayStatusBar(false);
    setBordered(false);
    setAlwaysOnBottom(true);

    moveTo(iXY(0, 0));
    resize(iXY(640, 480));

    initButtons();

    curTitleFlashTime  = 0.0f;
    titleFlashTimeHalf = 0.5;
} // end MenuTemplateView constructor
// init
//---------------------------------------------------------------------------
void ProgressView::init()
{
	setSearchName("ProgressView");
	setTitle("Progress Update");
	setSubTitle("");

	setAllowResize(false);
    setAllowMove(false);
	setDisplayStatusBar(false);
	setVisible(false);
	setBordered(false);

	background.create(628 - 179, 302 - 153, 628 - 179, 1);
	background.fill(0);

	moveTo(0, 0);
	resize(640, 480);

	iXY size(getClientRect().getSize());

} // end ProgressView::init
// init
//---------------------------------------------------------------------------
void LobbyView::init()
{
    setSearchName("LobbyView");
    setTitle("Join Lobby");
    setSubTitle("");

    setAllowResize(false);
    setAllowMove(false);
    setDisplayStatusBar(false);
    setVisible(false);
    setBordered(false);

    background.create(628 - 179, 302 - 153, 1);
    background.fill(0);

    moveTo(0, 0);
    resize(640, 480);

    addButtonCenterText(iXY(628 - 60, 302 - 15), 60, "Abort", "Cancel the joining of this game.", bAbort);

    currentline = 0;
} // end LobbyView::init
// init
//---------------------------------------------------------------------------
void AreYouSureResignView::init()
{
    removeAllButtons();

    setBordered(false);
    setAllowResize(false);
    setDisplayStatusBar(false);

    resize(screen->getPix());
    moveTo(0,0);

    int x = (getClientRect().getSize().x - (141 * 2 + 20)) / 2;
    int y = getClientRect().getSize().y/2 + 30;
    addSpecialButton(	iXY(x, y),
                      "YES",
                      bYES);

    x += 141 + 10;
    addSpecialButton(	iXY(x, y),
                      "NO",
                      bNO);

} // end AreYouSureResignView::init
// init
//---------------------------------------------------------------------------
void AreYouSureExitView::init()
{
    removeAllButtons();

    setBordered(false);
    setAllowResize(false);
    setDisplayStatusBar(false);

    moveTo(0, 0);
    resize(SCREEN_PIX);

    int x = (getClientRect().getSize().x - (141 * 2 + 20)) / 2;
    int y = SCREEN_YCENTER + 30;
    addSpecialButton(	iXY(x, y),
                      "YES",
                      bYES);

    x += 141 + 10;
    addSpecialButton(	iXY(x, y),
                      "NO",
                      bNO);

} // end AreYouSureExitView::init
void
LoadingView::init()
{
    setSearchName("LoadingView");
    setTitle("Loading Progress");
    setSubTitle("");

    setAllowResize(false);
    setAllowMove(false);
    setDisplayStatusBar(false);
    setVisible(false);
    setBordered(false);
    need_password = false;
    password_str.init("", 31,31);

    resize(800, 600);

    addButtonCenterText(iXY(340, 15), 100, "Abort", "Cancel the joining of this game.", bAbort);


    okButton = Button::createTextButton("OK", "Enter", iXY(340,100), 100);
    passwordLabel = new Label(340, 68, "Game Password", Color::white);

}
// VehicleSelectionView
//---------------------------------------------------------------------------
VehicleSelectionView::VehicleSelectionView() : GameTemplateView()
{
    setSearchName("VehicleSelectionView");
    setTitle("Unit Production");
    setSubTitle("");

    setAllowResize(false);
    setVisible(false);
    setBordered(true);
    setDisplayStatusBar(true);

    moveTo(iXY(0, 0));

    char      strBuf[256];
    int       unit_regen_time;
    const int yOffset  = 15;
    const int gapSpace =  1;

    resizeClientArea(48 * 5 + gapSpace * 4, 198 + 84);

    // Power status.
    iXY pos(0 ,0);

    pos.x = 0;
    addLabel(pos + iXY(2,2), "Static Display:", Color::white);

    pos.x = getClientRect().getSizeX() - 100;
    buttonStaticDisplay.setLabel("On");
    buttonStaticDisplay.setBounds(iRect(pos, pos + iXY(100, 15)));
    add(&buttonStaticDisplay);
    pos.y += yOffset;

    pos.x = 0;
    addLabel(pos + iXY(2,2) , "Power:", Color::white);

    pos.x = getClientRect().getSizeX() - 100;
    buttonPower.setLabel("Off");
    buttonPower.setBounds(iRect(pos, pos + iXY(100, 15)));
    add(&buttonPower);
    pos.y += yOffset;

    // XXX hardcoded for now
    int CHAR_XPIX = 8;
    
    pos.x = 0;
    addLabel(pos + iXY(2,2), "Production:", Color::white);
    productionUnitPos.x = (strlen("Current Unit:") + 1) * CHAR_XPIX + 2;
    productionUnitPos.y = pos.y + 2;
    pos.y += yOffset;

    pos.x = 0;
    addLabel(pos + iXY(2,2), "Time:        ", Color::white);
    timeRequiredPos.x = (strlen("Time:        ") + 1) * CHAR_XPIX + 2;
    timeRequiredPos.y = pos.y + 2;
    pos.y += yOffset;

    pos.x = 0;
    addLabel(pos + iXY(2,2), "Unit Built:   ", Color::white);
    unitsBuiltPos.x = (strlen("Time:        ") + 1) * CHAR_XPIX + 2;
    unitsBuiltPos.y = pos.y + 2;
    pos.y += yOffset;

    pos.x = 0;

    // Unit images.
    unit_regen_time = getUnitRegenTime(_unit_type_humvee);
    sprintf(strBuf, "SpahPanzer - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60);
    addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/scout.bmp", strBuf, bSelectScout);
    abstractButtonHumvee.setBounds(iRect(pos, pos + iXY(48,48)));
    add(&abstractButtonHumvee);

    pos.x += 48 + gapSpace;
    unit_regen_time = getUnitRegenTime(_unit_type_valentine);
    sprintf(strBuf, "Manta - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60);
    addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/manta.bmp", strBuf, bSelectManta);
    abstractButtonValentine.setBounds(iRect(pos, pos + iXY(48,48)));
    add(&abstractButtonValentine);

    pos.x += 48 + gapSpace;
    unit_regen_time = getUnitRegenTime(_unit_type_leopard);
    sprintf(strBuf, "Panther1 - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60);
    addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/panther1.bmp", strBuf, bSelectPanther1);
    abstractButtonLeopard.setBounds(iRect(pos, pos + iXY(48,48)));
    add(&abstractButtonLeopard);

    pos.x += 48 + gapSpace;
    unit_regen_time = getUnitRegenTime(_unit_type_abrams);
    sprintf(strBuf, "Titan - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60);
    addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/titan.bmp", strBuf, bSelectTitan);
    abstractButtonAbrams.setBounds(iRect(pos, pos + iXY(48,48)));
    add(&abstractButtonAbrams);

    pos.x += 48 + gapSpace;
    unit_regen_time = getUnitRegenTime(_unit_type_hammerhead);
    sprintf(strBuf, "Stinger - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60);
    addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/stinger.bmp", strBuf, bSelectStinger);
    abstractButtonHammerhead.setBounds(iRect(pos, pos + iXY(48,48)));
    add(&abstractButtonHammerhead);

    pos.x = 0;
    pos.y += 48 + gapSpace;
    unit_regen_time = getUnitRegenTime(_unit_type_lynx);
    sprintf(strBuf, "Bobcat - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60);
    addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/bobcat.bmp", strBuf, bSelectBobcat);
    abstractButtonLynx.setBounds(iRect(pos, pos + iXY(48,48)));
    add(&abstractButtonLynx);

    pos.x += 48 + gapSpace;
    unit_regen_time = getUnitRegenTime(_unit_type_scorpion);
    sprintf(strBuf, "Wolf - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60);
    addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/wolf.bmp", strBuf, bSelectWolf);
    abstractButtonScorpion.setBounds(iRect(pos, pos + iXY(48, 48)));
    add(&abstractButtonScorpion);

    pos.x += 48 + gapSpace;
    unit_regen_time = getUnitRegenTime(_unit_type_spahpanzer);
    sprintf(strBuf, "Bear - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60);
    addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/bear.bmp", strBuf, bSelectBear);
    abstractButtonSpahpanzer.setBounds(iRect(pos, pos + iXY(48, 48)));
    add(&abstractButtonSpahpanzer);

    pos.x += 48 + gapSpace;
    unit_regen_time = getUnitRegenTime(_unit_type_m109);
    sprintf(strBuf, "Drake - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60);
    addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/drake.bmp", strBuf, bSelectDrake);
    abstractButtonM109.setBounds(iRect(pos, pos + iXY(48, 48)));
    add(&abstractButtonM109);

    pos.x += 48 + gapSpace;
    unit_regen_time = getUnitRegenTime(_unit_type_archer);
    sprintf(strBuf, "Archer - Build Time: %01d:%02d", unit_regen_time / 60, unit_regen_time % 60);
    addButtonBMPBordered(pos, "pics/menus/vehicleSelectionView/archer.bmp", strBuf, bSelectArcher);
    abstractButtonArcher.setBounds(iRect(pos, pos + iXY(48, 48)));
    add(&abstractButtonArcher);

    pos.y += 48 + gapSpace * 4;
    pos.x = 0;

    unitProfileDataY = pos.y;
    pos.y += 74;

    //addLabel(pos + 2, "Time Remaining:", Color::white);
    //timeRemainingPos.x = (strlen("Time Remaining: ") + 1) * CHAR_XPIX + 2;
    //timeRemainingPos.y = pos.y + 2;
    //pos.y += yOffset;

    pos.x = (getClientRect().getSizeX() - 100) / 2;
    buttonOk.setLabel("Ok");
    buttonOk.setBounds(iRect(pos, pos + iXY(100, 15)));
    add(&buttonOk);

    unitImages.create(48, 48, _MAX_UNIT_TYPES);

    Surface tempSurface;
    int i = 0;

    tempSurface.loadBMP("pics/menus/vehicleSelectionView/manta.bmp");
    unitImages.setFrame(i++);
    tempSurface.blt(unitImages, 0, 0);
    tempSurface.loadBMP("pics/menus/vehicleSelectionView/panther1.bmp");
    unitImages.setFrame(i++);
    tempSurface.blt(unitImages, 0, 0);
    tempSurface.loadBMP("pics/menus/vehicleSelectionView/titan.bmp");
    unitImages.setFrame(i++);
    tempSurface.blt(unitImages, 0, 0);
    tempSurface.loadBMP("pics/menus/vehicleSelectionView/stinger.bmp");
    unitImages.setFrame(i++);
    tempSurface.blt(unitImages, 0, 0);
    tempSurface.loadBMP("pics/menus/vehicleSelectionView/bobcat.bmp");
    unitImages.setFrame(i++);
    tempSurface.blt(unitImages, 0, 0);
    tempSurface.loadBMP("pics/menus/vehicleSelectionView/bear.bmp");
    unitImages.setFrame(i++);
    tempSurface.blt(unitImages, 0, 0);
    tempSurface.loadBMP("pics/menus/vehicleSelectionView/archer.bmp");
    unitImages.setFrame(i++);
    tempSurface.blt(unitImages, 0, 0);
    tempSurface.loadBMP("pics/menus/vehicleSelectionView/wolf.bmp");
    unitImages.setFrame(i++);
    tempSurface.blt(unitImages, 0, 0);
    tempSurface.loadBMP("pics/menus/vehicleSelectionView/drake.bmp");
    unitImages.setFrame(i++);
    tempSurface.blt(unitImages, 0, 0);
    tempSurface.loadBMP("pics/menus/vehicleSelectionView/scout.bmp");
    unitImages.setFrame(i++);
    tempSurface.blt(unitImages, 0, 0);
    unitImages.setFrame(i++);
    unitImages.fill(Color::red);
    unitImages.setFrame(i++);
    unitImages.fill(Color::green);
    unitImages.setFrame(i++);
    unitImages.fill(Color::blue);

    maxHitPoints = 1;
    maxAttackFactor = 1;
    maxAttackRange = 1;
    maxDefendRange = 1;
    maxTotalSpeed = 1;
    maxReloadTime = 1;
    maxRegenTime = 1;
    getProfileData();

    highlightedUnitType = 0;

} // end VehicleSelectionView::VehicleSelectionView