// UnitColorView
//---------------------------------------------------------------------------
UnitColorView::UnitColorView() : View()
{
    setSearchName("UnitColorView");
    setTitle("Selects Your Unit Color");
    setSubTitle("");

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

    Surface unitSurface;

    moveTo(400, 200);

    packedBody.load("units/pics/pak/TitaHNSD.pak");
    packedBody.setFPS(12);

    packedTurret.load("units/pics/pak/TitaTNSD.pak");
    packedTurret.setFPS(8);

    grassSurface.loadBMP("pics/grass.bmp");

    fuckingSurface.create(packedTurret.getWidth(), packedTurret.getHeight(), 1);
    fuckingSurface.fill(0);

    resizeClientArea(packedTurret.getWidth(), packedTurret.getHeight());

    int size = packedTurret.getWidth() / 2;
    addButtonCenterText(iXY(0, 0), size, "Up", "", bIncreaseBrightness);
    addButtonCenterText(iXY(size, 0), size, "Down", "", bDecreaseBrightness);

    setGrayColorTable();
    rebuildGrayColorTable();

} // end UnitColorView::UnitColorView
IRCLobbyView::IRCLobbyView() 
    : View()
{
    lobby_connection=0;
    change_name=0;
    skipChatLines=0;
    lobby_view_height=184;
    total_displayed_servers=0;
    setSearchName("IRCLobbyView");
    setTitle("Lobby");
    setSubTitle("");

    setAllowResize(false);
    setAllowMove(false);
    setVisible(false);
    topViewableItem=0;

    moveTo(iXY(bodyTextRect.max.x-440, bodyTextRect.min.y + 170));

    iXY  area_size = iXY(440, lobby_view_height);
    resizeClientArea(area_size);

    int chat_y=lobby_view_height-(Surface::getFontHeight()*2);
    addButtonCenterText(iXY(getClientRect().getSizeX()-80, chat_y), 80,  "Refresh", "", buttonRefresh);
    szChat.init("  ", 255,39);
    cInputField* input = addInputField(iXY(4, chat_y), &szChat, "", true);
    input->setReturnAction(chatReturnPressed);

    server_list_end_y=(Surface::getFontHeight()*6);
    chat_list_end_y=getClientRect().getSizeY()-(Surface::getFontHeight()*2);
    server_list_end_x=(getClientRect().getSizeX()-12);

    iXY size(12, 12);
    iXY pos(getClientRect().getSizeX() - size.x, 0);
    serverUpButton.setLabel("-");
    serverUpButton.setBounds(iRect(pos, pos + size));
    add(&serverUpButton);

    pos.y= server_list_end_y-size.y;
    serverDownButton.setLabel("+");
    serverDownButton.setBounds(iRect(pos, pos + size));
    add(&serverDownButton);

    pos.y+=size.y;
    chatUpButton.setLabel("-");
    chatUpButton.setBounds(iRect(pos, pos + size));
    add(&chatUpButton);

    pos.y = chat_list_end_y-size.y;
    chatDownButton.setLabel("+");
    chatDownButton.setBounds(iRect(pos, pos + size));
    add(&chatDownButton);

    // XXX ugly ugly ugly
    if(!lobby_view)
        lobby_view = this;
} 
ParticleTweakView::ParticleTweakView() : View()
{
    setTitle("ParticleTweakView");
    setAllowResize(false);
    setAllowMove(true);
    setDisplayStatusBar(true);
    setVisible(false);

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

} // end ParticleTweakView::ParticleTweakView
CodeStatsView::CodeStatsView() : GameTemplateView()
{
    setSearchName("CodeStatsView");
    setTitle("CodeStatsView");
    setSubTitle(" - F4");

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

    moveTo(iXY(0, 0));

    iXY  area_size = iXY(280, 280) ;
    long bXOffset;
    INFO_AREA_Y_OFFSET = 2;

    resizeClientArea(area_size);

    bXOffset = area_size.x / 3;
    addButtonCenterText(iXY(0, INFO_AREA_Y_OFFSET), bXOffset,  "Net", "", buttonNetwork);
    addButtonCenterText(iXY(bXOffset, INFO_AREA_Y_OFFSET), bXOffset, "Sprite", "", buttonSorter);
    addButtonCenterText(iXY(bXOffset*2, INFO_AREA_Y_OFFSET), bXOffset, "Unit", "", buttonUnit);

    INFO_AREA_Y_OFFSET += 18;
    addButtonCenterText(iXY(0, INFO_AREA_Y_OFFSET), area_size.x, "Path", "", buttonPathing);

    INFO_AREA_Y_OFFSET += 18;
    bXOffset = area_size.x / 3;
    addButtonCenterText(iXY(0, INFO_AREA_Y_OFFSET), bXOffset,  "Debug", "", buttonDebug);
    addButtonCenterText(iXY(bXOffset, INFO_AREA_Y_OFFSET), bXOffset, "Sample", "", buttonSample);
    addButtonCenterText(iXY(bXOffset*2, INFO_AREA_Y_OFFSET), bXOffset, "NetLog", "", bNetLog );

    INFO_AREA_Y_OFFSET += 18;
    /*
       addButtonCenterText(iXY(0, INFO_AREA_Y_OFFSET), 20, "+", "", bPlusPacketSize );
    addButtonCenterText(iXY(25, INFO_AREA_Y_OFFSET), 20, "-", "", bMinusPacketSize );
    addButtonCenterText(iXY(50, INFO_AREA_Y_OFFSET), 20, "0", "", bMinusPacketSize );
    addButtonCenterText(iXY(65, INFO_AREA_Y_OFFSET), 20, "1", "", bMinusPacketSize );

    addButtonCenterText(iXY(45, INFO_AREA_Y_OFFSET), 40, "Send", "", bSend );

       INFO_AREA_Y_OFFSET += 18;
       INFO_AREA_Y_OFFSET += 18;
       */

    display_mode = _display_mode_network_stats;

} // end CodeStatsView::CodeStatsView
Пример #5
0
// HostOptionsView
//---------------------------------------------------------------------------
HostOptionsView::HostOptionsView() : RMouseHackView()
{
    setSearchName("HostOptionsView");
    setTitle("Host Options");
    setSubTitle("");

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

    moveTo(bodyTextRect.min.x, bodyTextRect.min.y + 205);
    resizeClientArea(bodyTextRect.getSizeX()-5, 168);

    addMeterButtons(iXY(BORDER_SPACE, BORDER_SPACE));

} // end HostOptionsView::HostOptionsView
// GetSessionHostView
//---------------------------------------------------------------------------
GetSessionHostView::GetSessionHostView() : View()
{
	setSearchName("GetSessionHostView");
	setTitle("Select Session Host");
	setSubTitle("");

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

	moveTo(bodyTextRect.min.x, bodyTextRect.min.y + 190);
	resizeClientArea(bodyTextRect.getSizeX(), 158);
	//moveTo(68, 204);
	//resize(610 - 68, 161);

	//setScrollBar(true);

	viewableItemCount =  0;
	highlightedItem   = -1;
	selectedItem      = -1;

	maxYOffset = 0;

	// Define the scrollBar fot this view.
	//scrollBar = new ScrollBar(VERTICAL, 0, 1, 0, 100);

	//add(scrollBar);

	maxViewableItems = getClientRect().getSizeY() / (TEXT_GAP_SPACE + CHAR_YPIX) - 1;
	topViewableItem  = 0;

	iXY size(20, 20);
	iXY pos(getClientRect().getSizeX() - size.x, 0);

	//upButton.setLabel("+");
	//upButton.setBounds(iRect(pos, pos + size));
	//add(&upButton);
	//
	//pos = iXY(getClientRect().getSizeX() - size.x, getClientRect().getSizeY() - size.y);
	//downButton.setLabel("-");
	//downButton.setBounds(iRect(pos, pos + size));
	//add(&downButton);

} // end GetSessionHostView constructor
// PlayerNameView
//---------------------------------------------------------------------------
PlayerNameView::PlayerNameView() : View()
{
    setSearchName("PlayerNameView");
    setTitle("Player Name");
    setSubTitle("");

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

    moveTo(bodyTextRect.min);

    // The plus 8 for x and 4 for y are what I put in input field.  Add function to find out,
    // inpit field dimension.
    resizeClientArea(INPUT_FIELD_CHARACTERS * CHAR_XPIX + 8 + BORDER_SPACE * 2, CHAR_YPIX + 4 + BORDER_SPACE * 2);

    init();

} // end PlayerNameView::PlayerNameView
Пример #8
0
// MapSelectionView
//---------------------------------------------------------------------------
MapSelectionView::MapSelectionView() : RMouseHackView()
{
    setSearchName("MapSelectionView");
    setTitle(_("Map Selection"));
    setSubTitle("");

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

    moveTo(bodyTextRect.min.x, bodyTextRect.min.y + 50);

    resizeClientArea(bodyTextRect.getSizeX() / 2 - 10 + 30, MAP_SIZE + BORDER_SPACE * 2);

    curMap = -1;
    
    init();

} // end MapSelectionView::MapSelectionView
Пример #9
0
// PlayerNameView
//---------------------------------------------------------------------------
PlayerNameView::PlayerNameView() : View()
{
    setSearchName("PlayerNameView");
    setTitle("Player Name");
    setSubTitle("");

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

    moveTo(bodyTextRect.min);

    // The plus 8 for x and 4 for y are what I put in input field.  Add function to find out,
    // inpit field dimension.
    int CHAR_XPIX = 8; // XXX hardcoded :-/
    resizeClientArea((INPUT_FIELD_CHARACTERS+1) * CHAR_XPIX + 8 + BORDER_SPACE * 2, Surface::getFontHeight() + 4 + BORDER_SPACE * 2);

    init();
} // end PlayerNameView::PlayerNameView
// IPAddressView
//---------------------------------------------------------------------------
IPAddressView::IPAddressView() : View()
{
    setSearchName("IPAddressView");
    setTitle("Server IP Address");
    setSubTitle("");

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

    moveTo(iXY(bodyTextRect.min.x, bodyTextRect.min.y + 50));

    iXY  area_size = iXY(
            30 * 8 + 16,
            Surface::getFontHeight() + 4 + 8);
    resizeClientArea(area_size);

    Init();
} // end IPAddressView constructor
// 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
Пример #12
0
CodeStatsView::CodeStatsView() : GameTemplateView()
{
    setSearchName("CodeStatsView");
    setTitle("CodeStatsView");
    setSubTitle(" - F4");

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

    moveTo(iXY(0, 0));

    iXY  area_size = iXY(280, 280) ;
    long bXOffset;
    INFO_AREA_Y_OFFSET = 2;

    resizeClientArea(area_size);

    bXOffset = area_size.x / 3;
    add( Button::createTextButton("Net",    iXY(0, INFO_AREA_Y_OFFSET),              bXOffset-3,    new SetDisplayModeAction(_display_mode_network_stats)));
    add( Button::createTextButton("Sprite", iXY(bXOffset+1, INFO_AREA_Y_OFFSET),     bXOffset-4,    new SetDisplayModeAction(_display_mode_sorter_stats)));
    add( Button::createTextButton("Unit",   iXY((bXOffset*2)+1, INFO_AREA_Y_OFFSET), bXOffset-2,    new SetDisplayModeAction(_display_mode_unit_stats)));

    INFO_AREA_Y_OFFSET += 18;
    add( Button::createTextButton("Path",   iXY(0, INFO_AREA_Y_OFFSET),              area_size.x-2, new SetDisplayModeAction(_display_mode_pathing_stats)));

    INFO_AREA_Y_OFFSET += 18;
    bXOffset = area_size.x / 3;
    add( Button::createTextButton("NetLog", iXY((bXOffset*2)+1, INFO_AREA_Y_OFFSET), bXOffset-2,    new UpdateNetworkStatsAction()));

    INFO_AREA_Y_OFFSET += 18;

    display_mode = _display_mode_network_stats;

} // end CodeStatsView::CodeStatsView
Пример #13
0
bool Window::initialize()
{
	if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_EVENTS) != 0)
	{
		Log::instance()->logError("Unable to initialize SDL\n%s", SDL_GetError());

		return	false;
	}

	m_pDisplay	= XOpenDisplay(NULL);

	if (NULL == m_pDisplay)
	{
		Log::instance()->logError("Unable to open X display");

		return	false;
	}

	int	iMajor;
	int	iMinor;
	
	if (false == glXQueryVersion(m_pDisplay, &iMajor, &iMinor))
	{
		Log::instance()->logError("Unable to query versopm");

		return	false;
	}
	
	if (iMajor < 1 || (1 == iMajor && iMinor < 3))
	{
		return	false;
	}

	int	iTemp;
	
	if (false == glXQueryExtension(m_pDisplay, &iTemp, &iTemp))
	{
		Log::instance()->logError("Unable to query extension");

		return	false;
	}

	int	iVisualAttribs[]  =
	{
		GLX_X_RENDERABLE, True,
		GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
		GLX_RENDER_TYPE, GLX_RGBA_BIT,
		GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
		GLX_RED_SIZE, 8,
		GLX_GREEN_SIZE, 8,
		GLX_BLUE_SIZE, 8,
		GLX_ALPHA_SIZE, 8,
		GLX_DOUBLEBUFFER, True,
		None
	};

	int	iCount	= 0;
	
	// Choose framebuffer config
	m_pFBConfig	= glXChooseFBConfig(m_pDisplay, DefaultScreen(m_pDisplay), iVisualAttribs, &iCount);
	
	if (NULL == m_pFBConfig)
	{
		Log::instance()->logError("Unable to get famebuffer config.");

		return	false;
	}

	// Get visual info
	XVisualInfo*	pVisualInfo	= glXGetVisualFromFBConfig(m_pDisplay, m_pFBConfig[0]);
	
	if (NULL == pVisualInfo)
	{
		Log::instance()->logError("Unable to get visual from framebuffer config.");

		return	false;
	}
	
	XSetWindowAttributes	windowAttributes;
	
	// Create colormap
	m_colormap = XCreateColormap(m_pDisplay, RootWindow(m_pDisplay, pVisualInfo->screen), 
		pVisualInfo->visual, AllocNone);
		
	windowAttributes.colormap			= m_colormap;
	windowAttributes.background_pixmap	= None;
	windowAttributes.border_pixel		= 0;
	windowAttributes.event_mask			= StructureNotifyMask;
	
	const GameHeader&	gameHeader	= System::getGameHeader();
	
	bool	bFullscreen	= gameHeader.bFullScreen;

	if (false == bFullscreen)
	{
		// Create window
		m_window	= XCreateWindow(m_pDisplay, RootWindow(m_pDisplay, pVisualInfo->screen), 0, 0, 
			gameHeader.iWindowedWidth, gameHeader.iWindowedHeight, 0, pVisualInfo->depth, InputOutput,
			pVisualInfo->visual, CWBorderPixel | CWColormap | CWEventMask, &windowAttributes);
		
		resizeClientArea();
	}
	
	else
	{
	}

	XFree(pVisualInfo);
	
	if (0 == m_window)
	{
		Log::instance()->logError("Unable to create window.");
		
		return	false;
	}
	
	// Set window name
	XStoreName(m_pDisplay, m_window, gameHeader.strAppName.c_str());
	
	// Show window
	XMapWindow(m_pDisplay, m_window);
	
	return	true;
}
// GameToolbarView
//--------------------------------------------------------------------------
GameToolbarView::GameToolbarView() : GameTemplateView()
{
	setSearchName("GameToolbarView");
	setTitle("Toolbar - TAB");
	setSubTitle("");

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

	moveTo(iXY(0, 0));
	resizeClientArea(117, 100);

	iXY       pos(0, 0);
	const int yOffset     = 15;
	int       buttonSizeX = getClientRect().getSizeX();

	addButtonCenterText(pos, buttonSizeX - (15 + 1) * 2 - 1, "Mini Map", "Toggle the visibility of the mini map", bToggleMiniMap);
	pos.x = buttonSizeX - (15 + 1) * 2;
	addButton(pos, "-", "", bDecreaseMiniMapSize);
	pos.x += 15 + 1;
	addButton(pos, "+", "", bIncreaseMiniMapSize);
	pos.x += 15 + 1;

	pos.x = 0;
	pos.y += yOffset;
	buttonSizeX = getClientRect().getSizeX() / 2;
	addButtonCenterText(pos, buttonSizeX, "Info", "Toggle the visibility of the mini map", bToggleInfo);
	pos.x += buttonSizeX + 1;
	addButtonCenterText(pos, buttonSizeX, "Rank", "Toggle the visibility of the rank view", bToggleRankView);
	pos.y += yOffset;
	pos.x = 0;
	buttonSizeX = getClientRect().getSizeX();
	addButtonCenterText(pos, buttonSizeX, "MSG All", "", bSendMessageAll);
	pos.y += yOffset;
	addButtonCenterText(pos, buttonSizeX, "MSG Allies", "", bSendMessageAllies);
	pos.y += yOffset;
	addButtonCenterText(pos, buttonSizeX, "MSG Enemies", "", bSendMessageEnemies);
	pos.y += yOffset;

	pos.x = 0;
	addLabel(iXY(pos.x + 2, pos.y + 3), "Group", Color::white);
	pos.x += 48 + 1 + 4;

	addButton(pos, "1", "", bSetGroup1);
	pos.x += 15 + 1;
	addButton(pos, "2", "", bSetGroup2);
	pos.x += 15 + 1;
	addButton(pos, "3", "", bSetGroup3);
	pos.x += 15 + 1;
	addButton(pos, "4", "", bSetGroup4);
	pos.x += 15 + 1;

	pos.x = 0;
	pos.y += yOffset;
	addLabel(iXY(pos.x + 2, pos.y + 3), "Recall", Color::white);
	pos.x += 48 + 1 + 4;

	addButton(pos, "1", "", bRecallGroup1);
	pos.x += 15 + 1;
	addButton(pos, "2", "", bRecallGroup2);
	pos.x += 15 + 1;
	addButton(pos, "3", "", bRecallGroup3);
	pos.x += 15 + 1;
	addButton(pos, "4", "", bRecallGroup4);
	pos.x += 15 + 1;
	pos.y += yOffset;

	buttonSizeX = getClientRect().getSizeX() / 2;

	pos.x = 0;
	addButtonCenterText(pos, buttonSizeX, "Damage", "", bToggleDrawUnitDamage);
	pos.x += buttonSizeX + 1;
	addButtonCenterText(pos, buttonSizeX, "Flags", "", bToggleDrawUnitFlags);
	//pos.x += buttonSizeX + 1;
	//addButtonCenterText(pos, buttonSizeX, "RL", "", bToggleDrawUnitReload);

	pos.y += yOffset;

	resizeClientArea(iXY(117, pos.y));
	
	// Start it in the bottom-left corner.
	moveTo(iXY(10000, 10000));

} // end GameToolbarView::GameToolbarView
// VehicleSelectionView
//---------------------------------------------------------------------------
VehicleSelectionView::VehicleSelectionView() : GameTemplateView()
{
    setSearchName("VehicleSelectionView");
//    setTitle(_("Unit Production"));

    moveTo(iXY(0, 0));

    const int yOffset  = 16;
    const int gapSpace =  1;

    resizeClientArea(48 * 5 + gapSpace+1 * 4, 198 + 100 + 16);

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

    pos.x = 0;
    add( new Label( pos.x+2, pos.y+2, _("Static Display"), Color::white) );

    pos.x = getClientRect().getWidth() - 102;
    if ( !buttonStaticDisplay )
        buttonStaticDisplay = new Button();
    buttonStaticDisplay->setLabel(_("On"));
    buttonStaticDisplay->setLocation(pos.x, pos.y);
    buttonStaticDisplay->setSize( 100, 14);
    buttonStaticDisplay->setNormalBorder();
    add(buttonStaticDisplay);
    pos.y += yOffset+2;

    pos.x = 0;
    add( new Label( pos.x+2, pos.y+2, _("Power"), Color::white) );

    pos.x = getClientRect().getWidth() - 102;
    if ( !buttonPower )
        buttonPower = new Button();
    
    buttonPower->setLabel(_("Off"));
    buttonPower->setLocation(pos.x,pos.y);
    buttonPower->setSize( 100, 14);
    buttonPower->setNormalBorder();
    add(buttonPower);
    pos.y += yOffset+5;

    // XXX hardcoded for now
   
    pos.x = 0;
    add( new Label( pos.x+2, pos.y+2, _("Production"), Color::white) );
    productionUnitPos.x = 130;
    productionUnitPos.y = pos.y + 2;
    pos.y += yOffset;

    pos.x = 0;
    add( new Label( pos.x+2, pos.y+2, _("Time"), Color::white) );
    timeRequiredPos.x = productionUnitPos.x;
    timeRequiredPos.y = pos.y + 2;
    pos.y += yOffset;

    pos.x = 0;
    add( new Label( pos.x+2, pos.y+2, _("Unit Built"), Color::white) );
    unitsBuiltPos.x = productionUnitPos.x;
    unitsBuiltPos.y = pos.y + 2;
    pos.y += yOffset;

    pos.x = 0;

    Surface tempSurface;

    UnitProfile *uprofile;
    UnitSelectionButton *usb;

    if ( ! unitImages.empty() )
    {
        unitImages.deleteAll();
        unitImages.clear();
    }

    for ( unsigned ut=0; ut < UnitProfileInterface::getNumUnitTypes(); ut++)
    {
        uprofile = UnitProfileInterface::getUnitProfile(ut);

        Surface * s = new Surface();
        s->loadPNG(uprofile->imagefile.c_str());
        unitImages.push_back(s);

        usb = new UnitSelectionButton(this, ut, pos.x, pos.y, *s);

        add(usb);

        pos.x += 48 + gapSpace;
        if ( pos.x+48 > getEndX() )
        {
            pos.x = 0;
            pos.y += 48 + gapSpace;
        }
    }

    if ( pos.x == 0 )
    {
        pos.y += gapSpace * 3; // and the one just added before = 4
    }
    else
    {
        pos.y += 48 + gapSpace * 4;
        pos.x = 0;
    }
    
    unitProfileDataY = pos.y;
    pos.y += 73;

    //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().getWidth() - 100) / 2;
    if ( !buttonOk )
        buttonOk = new Button();
    
    buttonOk->setLabel(_("Close"));
    buttonOk->setLocation(pos.x,pos.y);
    buttonOk->setSize(100, 14);
    buttonOk->setNormalBorder();
    add(buttonOk);

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

    highlightedUnitType = -1;
    
    iRect r = getClientRect();
    
//    statusBar = new BoxedLabel(r.getLocationX()+4, r.getEndY() - 32, r.getWidth() - 8, "XXX", Color::black, Color::gray192);
//    add(statusBar);

} // end VehicleSelectionView::VehicleSelectionView
// 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
Пример #17
0
/*
 * ImgEdFrameProc - handle messages for the image editor application
 */
WPI_MRESULT CALLBACK ImgEdFrameProc( HWND hwnd, WPI_MSG msg,
                                 WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    static BOOL         window_destroyed = FALSE;
    static HMENU        hmenu;
    ctl_id              cmdid;
    img_node            *node;
    WPI_RECT            rcmain;
#ifndef __OS2_PM__
    about_info          ai;
#endif
    WPI_RECTDIM         left, top;

    if( !window_destroyed ) {
        enableMainItems( hmenu );
    }

    switch( msg ) {
    case UM_EXIT:
        _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L );
        /* fall through */

    case UM_EXIT_NO_SAVE:
        if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) {
            break;
        }
#ifndef __OS2_PM__
        _wpi_destroywindow( _wpi_getframe( hwnd ) );
#else
        _wpi_sendmessage( hwnd, WM_CLOSE, 0, 0 );
#endif

        break;

    case UM_SAVE_ALL:
        SaveAllImages();
        break;

    case WM_CREATE:
        hmenu = _wpi_getmenu( _wpi_getframe( hwnd ) );
#ifndef __OS2_PM__
        createClientWindow( hwnd );
#endif
        if( !InitStatusLine( hwnd ) ) {
            return( -1 );
        }

        InitFunctionBar( hwnd );
        InitIconInfo();
        InitializeCursors();

        /*
         * Set values from profile information ...
         */
        if( ImgedConfigInfo.brush_size <= 5 && ImgedConfigInfo.brush_size >= 2 ) {
            checkBrushItem( hmenu, IMGED_2x2 - 2 + ImgedConfigInfo.brush_size );
        }
        if( ImgedConfigInfo.grid_on ) {
            CheckGridItem( hmenu );
        }
        if( ImgedConfigInfo.square_grid ) {
            CheckSquareGrid( hmenu );
        }
        if( ImgedConfigInfo.show_state & SET_SHOW_VIEW ) {
            CheckViewItem( hmenu );
        }

        _wpi_enablemenuitem( hmenu, IMGED_CRESET, FALSE, FALSE );
        _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, FALSE, FALSE );
#ifndef __OS2_PM__
        // not necessary for PM
        InitMenus( hmenu );
#endif
        SetHintText( IEAppTitle );
        return( 0 );
#ifdef __NT__
    case WM_DROPFILES:
        OpenImage( (HANDLE)wparam );
        break;
#endif
    case WM_MOVE:
        _wpi_getwindowrect( hwnd, &rcmain );
        if( !ImgedConfigInfo.ismaximized ) {
            ImgedConfigInfo.last_xpos = ImgedConfigInfo.x_pos;
            ImgedConfigInfo.last_ypos = ImgedConfigInfo.y_pos;
            _wpi_getrectvalues( rcmain, &left, &top, NULL, NULL );
            ImgedConfigInfo.x_pos = (short)left;
            ImgedConfigInfo.y_pos = (short)top;
        }
        return( 0 );

    case WM_SIZE:
        ResizeFunctionBar( lparam );
        ResizeStatusBar( lparam );
#ifndef __OS2_PM__
        if( ClientWindow != NULL ) {
            setClientSize( hwnd );
        }
#else
        resizeClientArea( lparam );
#endif

        if( !_imgwpi_issizeminimized( wparam ) && !_imgwpi_issizemaximized( wparam ) ) {
            _wpi_getwindowrect( hwnd, &rcmain );
            ImgedConfigInfo.width = (short)_wpi_getwidthrect( rcmain );
            ImgedConfigInfo.height = (short)_wpi_getheightrect( rcmain );
            ImgedConfigInfo.ismaximized = FALSE;
        } else {
            ImgedConfigInfo.x_pos = ImgedConfigInfo.last_xpos;
            ImgedConfigInfo.y_pos = ImgedConfigInfo.last_ypos;
            ImgedConfigInfo.ismaximized = _imgwpi_issizemaximized( wparam );
        }
        return( FALSE );

    case WM_MENUSELECT:
#ifndef __OS2_PM__
        if( GET_WM_MENUSELECT_FLAGS( wparam, lparam ) & MF_SEPARATOR ) {
            break;
        }
        if( GET_WM_MENUSELECT_FLAGS( wparam, lparam ) & MF_SYSMENU ) {
            PrintHintTextByID( WIE_SYSMENUOPERATIONS, NULL );
            break;
        }
#endif
        ShowHintText( LOWORD( wparam ) );
        break;

    case WM_COMMAND:
        cmdid = LOWORD( wparam );
        if( !IEIsMenuIDValid( hmenu, cmdid ) ) {
            break;
        }
        switch( cmdid ) {
        case IMGED_NEW:
            if( !ImgedIsDDE ) {
                if( !NewImage( UNDEF_IMG, NULL ) ) {
                    PrintHintTextByID( WIE_NEIMAGENOTCREATED, NULL );
                }
            }
            break;

        case IMGED_CLOSE:
            node = GetCurrentNode();
            if( node != NULL ) {
                _wpi_sendmessage( node->hwnd, WM_CLOSE, 0, 0L );
            }
            break;

        case IMGED_CLOSEALL:
            CloseAllImages();
            break;

        case IMGED_HELP:
            IEHelpRoutine();
            break;

        case IMGED_HELP_SEARCH:
            IEHelpSearchRoutine();
            break;

        case IMGED_HELP_ON_HELP:
            IEHelpOnHelpRoutine();
            break;

        case IMGED_ABOUT:
#ifndef __OS2_PM__
            ai.owner = hwnd;
            ai.inst = Instance;
            ai.name = IEAllocRCString( WIE_ABOUTTEXT );
            ai.version = IEAllocRCString( WIE_ABOUTVERSION );
            ai.title = IEAllocRCString( WIE_ABOUTTITLE );
            DoAbout( &ai );
            if( ai.name != NULL ) {
                IEFreeRCString( ai.name );
            }
            if( ai.version != NULL ) {
                IEFreeRCString( ai.version );
            }
            if( ai.title != NULL ) {
                IEFreeRCString( ai.title );
            }
#endif
            break;

#ifndef __OS2_PM__
        case IMGED_DDE_UPDATE_PRJ:
            IEUpdateDDEEditSession();
            break;
#endif

        case IMGED_SAVE_AS:
            SaveFile( SB_SAVE_AS );
            break;

        case IMGED_SAVE:
            SaveFile( SB_SAVE );
            break;

        case IMGED_OPEN:
            if( !ImgedIsDDE ) {
                OpenImage( NULL );
            }
            break;

        case IMGED_CLEAR:
            ClearImage();
            break;

        case IMGED_NEWIMG:
            AddNewIcon();
            break;

        case IMGED_SELIMG:
            SelectIconImg();
            break;

        case IMGED_DELIMG:
            DeleteIconImg();
            break;

        case IMGED_UNDO:
            UndoOp();
            break;

        case IMGED_REDO:
            RedoOp();
            break;

        case IMGED_REST:
            RestoreImage();
            break;

        case IMGED_SNAP:
#ifndef __OS2_PM__
            SnapPicture();
#endif
            break;

        case IMGED_RIGHT:
        case IMGED_LEFT:
        case IMGED_UP:
        case IMGED_DOWN:
            ShiftImage( cmdid );
            break;

        case IMGED_FLIPHORZ:
        case IMGED_FLIPVERT:
            FlipImage( cmdid );
            break;

        case IMGED_ROTATECC:
        case IMGED_ROTATECL:
            RotateImage( cmdid );
            break;

        case IMGED_PASTE:
            PlaceAndPaste();
            break;

        case IMGED_COPY:
            IECopyImage();
            break;

        case IMGED_CUT:
            CutImage();
            break;

        case IMGED_COLOR:
            CheckPaletteItem( hmenu );
            break;

        case IMGED_VIEW:
            CheckViewItem( hmenu );
            break;

        case IMGED_TOOLBAR:
            CheckToolbarItem( hmenu );
            break;

        case IMGED_SQUARE:
            CheckSquareGrid( hmenu );
            break;

        case IMGED_SIZE:
            ChangeImageSize();
            break;

        case IMGED_GRID:
            CheckGridItem( hmenu );
            break;

        case IMGED_MAXIMIZE:
            MaximizeCurrentChild();
            break;

        case IMGED_SETTINGS:
            SelectOptions();
            break;

        case IMGED_2x2:
        case IMGED_3x3:
        case IMGED_4x4:
        case IMGED_5x5:
            checkBrushItem( hmenu, cmdid );
            break;

        case IMGED_CEDIT:
#ifndef __OS2_PM__
            EditColors();
#endif
            break;

        case IMGED_CRESET:
#ifndef __OS2_PM__
            RestoreColors();
#endif
            break;

        case IMGED_CSCREEN:
            ChooseBkColor();
            break;

        case IMGED_SCOLOR:
#ifndef __OS2_PM__
            SaveColorPalette();
#endif
            break;

        case IMGED_LCOLOR:
#ifndef __OS2_PM__
            if( LoadColorPalette() ) {
                _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, TRUE, FALSE );
            }
#endif
            break;

        case IMGED_RCOLOR:
            RestoreColorPalette();
            break;

        case IMGED_FREEHAND:
        case IMGED_LINE:
        case IMGED_RECTO:
        case IMGED_RECTF:
        case IMGED_CIRCLEO:
        case IMGED_CIRCLEF:
        case IMGED_FILL:
        case IMGED_BRUSH:
        case IMGED_CLIP:
        case IMGED_HOTSPOT:
            SetToolType( cmdid );
            PushToolButton( cmdid );
            break;

        case IMGED_ARRANGE:
#ifndef __OS2_PM__
            SendMessage( ClientWindow, WM_MDIICONARRANGE, 0, 0L );
#endif
            break;

        case IMGED_TILE:
#ifndef __OS2_PM__
            SendMessage( ClientWindow, WM_MDITILE, MDITILE_VERTICAL, 0L );
#endif
            break;

        case IMGED_CASCADE:
#ifndef __OS2_PM__
            SendMessage( ClientWindow, WM_MDICASCADE, MDITILE_SKIPDISABLED, 0L );
#endif
            break;

        case IMGED_EXIT:
            _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L );

            if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) {
                break;
            }
#ifndef __OS2_PM__
            _wpi_destroywindow( _wpi_getframe( hwnd ) );
#else
            _wpi_sendmessage( hwnd, WM_CLOSE, 0, 0 );
#endif
            break;

        default:
#if 1
            return( _imgwpi_defframeproc( hwnd, ClientWindow, msg, wparam, lparam ) );
#else
            return( 0 );
#endif
        }
        return( 0 );

#ifndef __OS2_PM__
    case WM_COMPACTING:
        RelieveUndos();
        return 0;
#endif

    case WM_QUERYENDSESSION:
        if( _wpi_isiconic( _wpi_getframe( hwnd ) ) ) {
            if( ImgedConfigInfo.ismaximized ) {
                _wpi_maximizewindow( _wpi_getframe( hwnd ) );
            } else {
                _wpi_showwindow( _wpi_getframe( hwnd ), SW_SHOWNORMAL );
            }
        }
        _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L );

        if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) {
            return( 0 );
        }
        return( (WPI_MRESULT)1 );

    case WM_CLOSE:
        // wParam is non-zero if the DDE connection died
        if( !wparam && !ImgEdEnableMenuInput ) {
            // this prevents the user from closing the editor during
            // DDE initialization
            return( 0 );
        }
        _wpi_sendmessage( hwnd, WM_COMMAND, IMGED_CLOSEALL, 0L );
#ifdef __OS2_PM__
        return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
#else

        if( _wpi_getfirstchild( _wpi_getclient( ClientWindow ) ) != NULL ) {
            return( 0 );
        }
        window_destroyed = TRUE;
        _wpi_destroywindow( _wpi_getframe( hwnd ) );
        return( 0 );
#endif

    case WM_DESTROY:
#ifndef __OS2_PM__
        WWinHelp( HMainWindow, "resimg.hlp", HELP_QUIT, 0 );
#endif
        FiniStatusLine();
        CleanupClipboard();
        CleanupCursors();
        CloseToolBar();
        CloseFunctionBar();
        _wpi_deletefont( SmallFont );
        _wpi_postquitmessage( 0 );
        return( 0 );
    default:
        break;
    }
    return( _imgwpi_defframeproc( hwnd, ClientWindow, msg, wparam, lparam ) );

} /* ImgEdFrameProc */
Пример #18
0
 inline void resizeClientArea(const int &x, const int &y)
 {
     resizeClientArea(iXY(x, y));
 }