// 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, 628 - 179, 1); background.fill(0); moveTo(0, 0); resize(640, 480); iXY size(getClientRect().getSize()); addButtonCenterText(iXY(628 - 60, 302 - 15), 60, "Abort", "Cancel the joining of this game.", bAbort); currentline = 0; } // end LobbyView::init
Objective::Objective(ObjectiveID id, iXY location, BoundBox area) { this->id = id; this->location = location; capture_area = area; occupying_player = 0; MapInterface::pointXYtoMapXY( location, &outpost_map_loc ); selection_box.max = location + iXY( 64, 32 ); selection_box.min = location + iXY( -224, -128 ); this->area.min = iXY( -400, -144 ); this->area.max = iXY( 400, 240 ); outpost_type = 0; unit_generation_type = 0; occupation_status_timer.changePeriod( 3 ); unit_generation_timer.changePeriod( 1 ); unit_collection_loc = outpost_map_loc + iXY( 13, 13 ); unit_generation_loc = iXY( 1, 3 ); occupation_pad_offset = iXY( 224, 48 ); unit_generation_on_flag = false; }
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
void VehicleSelectionView::drawUnitProfileInfo(Surface &dest, const iXY &pos, short int unitType) { if (unitType == -1) { return; } const UnitProfile *profile = UnitProfileInterface::getUnitProfile(unitType); iXY loc = pos; const int gapSpace = 10; const int barOffset = 105; int barLength = getClientRect().getWidth() - barOffset; dest.bltStringShadowed(loc.x, loc.y, _("Hit Points"), Color::white, Color::black); drawBar(dest, iXY(loc.x + barOffset, loc.y), barLength, float(profile->hit_points) / float(maxHitPoints)); loc.y += gapSpace; dest.bltStringShadowed(loc.x, loc.y, _("Attack Power"), Color::white, Color::black); drawBar(dest, iXY(loc.x + barOffset, loc.y), barLength, float(profile->attack_factor) / float(maxAttackFactor)); loc.y += gapSpace; dest.bltStringShadowed(loc.x, loc.y, _("Attack Range"), Color::white, Color::black); drawBar(dest, iXY(loc.x + barOffset, loc.y), barLength, float(sqrt(profile->attack_range)) / float(maxAttackRange)); loc.y += gapSpace; dest.bltStringShadowed(loc.x, loc.y, _("Defend Range"), Color::white, Color::black); drawBar(dest, iXY(loc.x + barOffset, loc.y), barLength, float(sqrt(profile->defend_range)) / float(maxDefendRange)); loc.y += gapSpace; dest.bltStringShadowed(loc.x, loc.y, _("Speed"), Color::white, Color::black); drawBar(dest, iXY(loc.x + barOffset, loc.y), barLength, float(profile->speed_factor + profile->speed_rate) / float(maxTotalSpeed)); loc.y += gapSpace; dest.bltStringShadowed(loc.x, loc.y, _("Reload Time"), Color::white, Color::black); drawBar(dest, iXY(loc.x + barOffset, loc.y), barLength, float(profile->reload_time) / float(maxReloadTime)); loc.y += gapSpace; }
iXY getTarget() const { return iXY(ltoh16(x), ltoh16(y)); }
//-------------------------------------------------------------------------- void LibView::drawParticleInfo(Surface &dest, iXY pos) { int yOffset = 15; int xOffset = 15; char strBuf[256]; dest.bltString(iXY(pos.x, pos.y), "-- Particle Info --", Color::green); pos.y += yOffset; dest.bltString(iXY(pos.x, pos.y), "This frame count", Color::yellow); pos.y += yOffset; sprintf(strBuf, "Particle Systems: %d", ParticleSystem2D::getParticleSystemCount()); dest.bltString(iXY(pos.x + xOffset, pos.y), strBuf, Color::white); pos.y += yOffset; sprintf(strBuf, "Particles: %d", Particle2D::getFrameCount()); dest.bltString(iXY(pos.x + xOffset, pos.y), strBuf, Color::white); pos.y += yOffset; dest.bltString(iXY(pos.x, pos.y), "Peak count", Color::yellow); pos.y += yOffset; sprintf(strBuf, "Particle Systems: %d", ParticleSystem2D::getPeakParticleSystemCount()); dest.bltString(iXY(pos.x + xOffset, pos.y), strBuf, Color::white); pos.y += yOffset; sprintf(strBuf, "Particles: %d", Particle2D::getPeakCount()); dest.bltString(iXY(pos.x + xOffset, pos.y), strBuf, Color::white); pos.y += yOffset; dest.bltString(iXY(pos.x, pos.y), "Crater info", Color::yellow); pos.y += yOffset; float hitCount; float missCount; missCount = CraterParticle2D::getCacheMissCount(); hitCount = CraterParticle2D::getCacheHitCount(); sprintf(strBuf, "Cache Miss: %d (%%%2.2f)", int(missCount), 100.0f * (missCount / (hitCount + missCount))); dest.bltString(iXY(pos.x + xOffset, pos.y), strBuf, Color::white); pos.y += yOffset; sprintf(strBuf, "Cache Hit: %d (%%%2.2f)", int(hitCount), 100.0f * (hitCount / (hitCount + missCount))); dest.bltString(iXY(pos.x + xOffset, pos.y), strBuf, Color::white); pos.y += yOffset; missCount = ParticleInterface::getExplosionFlameFlashCullMissCount(); hitCount = ParticleInterface::getExplosionFlameFlashCullHitCount(); dest.bltString(iXY(pos.x, pos.y), "Cull info", Color::yellow); pos.y += yOffset; sprintf(strBuf, "Explosion Flame Flash Miss:%d (%%%2.2f)", int(missCount), 100.0f * (missCount / (hitCount + missCount))); dest.bltString(iXY(pos.x + xOffset, pos.y), strBuf, Color::white); pos.y += yOffset; sprintf(strBuf, "Explosion Flame Flash Hit: %d (%%%2.2f)", int(hitCount), 100.0f * (hitCount / (hitCount + missCount))); dest.bltString(iXY(pos.x + xOffset, pos.y), strBuf, Color::white); pos.y += yOffset; missCount = ParticleInterface::getMuzzleSystemCullMissCount(); hitCount = ParticleInterface::getMuzzleSystemCullHitCount(); sprintf(strBuf, "Muzzle System Miss: %d (%%%2.2f)", int(missCount), 100.0f * (missCount / (hitCount + missCount))); dest.bltString(iXY(pos.x + xOffset, pos.y), strBuf, Color::white); pos.y += yOffset; sprintf(strBuf, "Muzzle System Hit: %d (%%%2.2f)", int(hitCount), 100.0f * (hitCount / (hitCount + missCount))); dest.bltString(iXY(pos.x + xOffset, pos.y), strBuf, Color::white); pos.y += yOffset; }
iXY getTarget() const { return iXY(ltoh16(target_x), ltoh16(target_y)); }
// rMouseDrag //--------------------------------------------------------------------------- void LibView::rMouseDrag(const iXY&, const iXY &prevPos, const iXY &newPos) { moveTo(min + newPos - prevPos); checkArea(iXY(screen->getWidth(),screen->getHeight())); }
// HelpScrollView //--------------------------------------------------------------------------- HelpScrollView::HelpScrollView() : SpecialButtonView() { setSearchName("HelpScrollView"); setTitle("Help Information"); setSubTitle(""); setAllowResize(false); setAllowMove(false); moveTo(bodyTextRect.min); resize(bodyTextRect.getSize()); insert("Key"); insert(""); insert(" LMC = Left Mouse Click"); insert(" RMC = Right Mouse Click"); insert(" RMH = Right Mouse Hold"); insert(""); insert(""); insert("Unit Related"); insert(""); insert(" LMC Selects a unit"); insert(" LMH Makes a bouding box for unit selection"); insert(" RMC De-selects all selected units"); insert(" LMC + Ctrl Directs (force/manual) fire of a unit"); insert(" LMC + Shift, LMC + Ctrl Add unit to selected set"); //insert(" Ctrl + [0..9], Shift + [0..9] Define a group of units"); insert(" Shift + [0..9] Define a group of units"); insert(" Alt + [1..0] Recall a group of units"); insert(" [1..0] Cycles through the corresponding group of units"); //insert(" 'E' Select all units on screen"); //insert(" LMC + 'T'............................Track the selected unit"); //insert(" LMC + 'W'............................Set the selected objective's way point"); //insert(" RMH..................................Fast map scroll"); //insert(" X....................................Scatter units"); //insert(" S....................................Stop units"); //insert(" LMC + Ctrl + Alt.....................Escort unit"); insert(""); insert(""); insert("Game Related"); insert(""); insert(" LMC + 'A' Allies with the clicked unit's team"); //insert(" Ctrl + [F1..F5] Bookmark world locations"); //insert(" Alt + [F1..F5] Recall bookmarked world locations"); insert(" F2 In game menus"); insert(""); insert(""); insert("Outpost Related"); insert(""); insert(" 'O' Cycle through your outposts"); insert(" Ctrl + RMC on captured outpost Displays the outpost view"); insert(" Double RMC on captured outpost Displays the outpost view"); //insert(" Alt + RMC on captured outpost........Sets selected outpost's delivery location"); insert(""); insert(""); insert("Chat Related"); insert(""); insert(" Enter Send message to all"); insert(" Ctrl + 'A' Send message to allies"); insert(" Ctrl + 'E' Send message to enemies"); insert(""); insert(""); insert("View Related"); insert(""); insert(" F1 Help View"); insert(" F6 Rank View"); insert(" F7 Chat View"); insert(" F8 Mini Map View"); insert(" TAB Toolbar"); insert(" RMH + mouse movement Moves any view on the screen"); insert(" RMH + [1 - 5] Sets the background drawing mode"); insert(" "); insert(" "); insert("Mini Map View Related"); insert(""); insert(" RMH + [1 - 7] Sets the blending level of the minimap"); insert(" RMH + [+ or -] Scales the size of the minimap"); //insert(" RMH + 'O' Toggles outposts"); insert(" "); insert(" "); insert("System Related"); insert(""); insert(" F9 BMP screen shot"); insert(" Alt + '-' Decrease brightness"); insert(" Alt + '=' Increase brightness"); insert(" Alt + Keypad plus Increase game resolution"); insert(" Alt + Keypad minus Decrease game resolution"); // Define the scrollBar fot this view. //scrollBar = new ScrollBar(VERTICAL, 0, 1, 0, text.getCount()); //if (scrollBar == 0) //{ // throw Exception("ERROR: Unable to allocate the scrollBar."); //} // //iRect clientRect(getClientRect()); //scrollBar->setViewableAmount(clientRect.getSizeY() / (TEXT_GAP_SPACE + CHAR_YPIX) - 1); //scrollBar->setBlockIncrement(1); //add(scrollBar); maxViewableItems = (getClientRect().getSizeY() - (TEXT_GAP_SPACE + CHAR_YPIX)) / (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 HelpScrollView::HelpScrollView
// drawMiniProductionStatus //--------------------------------------------------------------------------- void VehicleSelectionView::drawMiniProductionStatus(Surface &dest) { char strBuf[256]; char outpostNameBuf[256]; char outpostUserNameBuf[256]; char productionUnitBuf[256]; char timeLeftBuf[256]; iRect gameViewRect; WorldViewInterface::getViewWindow(&gameViewRect); ObjectiveID objective_id; Objective* obj; ObjectiveID max_objective = ObjectiveInterface::getObjectiveCount(); for ( objective_id = 0; objective_id < max_objective; ++objective_id) { obj = ObjectiveInterface::getObjective( objective_id ); bool owned = obj->occupying_player && obj->occupying_player == PlayerInterface::getLocalPlayer(); if ( ! displayOutpostNames && ( ! owned || ! displayMiniProductionStatus ) ) { continue; } // @todo set the correct view location // miniProductionRect.setLocation(obj->area.getAbsRect(obj->location).getLocation() - gameViewRect.getLocation()); miniProductionRect.setSize(140, owned ? 50: 20); if ( obj->occupying_player ) { miniProductionRect.translate(0, -16); int length = strlen( obj->occupying_player->getName().c_str() ); if (length > 13) { strncpy(strBuf, obj->occupying_player->getName().c_str() , 10); strBuf[10] = 0; // fix runners sprintf(outpostUserNameBuf, "%s: %s...", _("Owner"), strBuf); } else { sprintf(outpostUserNameBuf, "%s: %s", _("Owner"), obj->occupying_player->getName().c_str() ); } } iXY pos(miniProductionRect.getLocation()); pos.x += 4; pos.y += 4; // Make sure the name will fit reasonably in the area. int length = strlen( obj->name ); if (length > 10) { strncpy(strBuf, (const char *) obj->name , 7); strBuf[7] = 0; // fix runners sprintf(outpostNameBuf, "%s: %s...", _("Outpost"), strBuf); } else { sprintf(outpostNameBuf, "%s: %s", _("Outpost"), (const char *) obj->name ); } checkMiniProductionRect(outpostNameBuf); if ( owned ) { if ( ! obj->unit_generation_on_flag ) { // Objective is off. // dest.bltLookup(miniProductionRect, Palette::filterDarkGray()); dest.bltString(pos.x, pos.y, outpostUserNameBuf, Color::cyan); pos.y += 16; dest.bltString(pos.x, pos.y, outpostNameBuf, Color::white); pos.y += 16; dest.bltString(pos.x, pos.y, _("Production Off"), Color::white); } else { // Objective is on. sprintf(productionUnitBuf, _("Production: %s"), getUnitName(obj->unit_generation_type)); checkMiniProductionRect(productionUnitBuf); float tleft = obj->unit_generation_timer.getTimeLeft(); sprintf(timeLeftBuf, "%s: %01d:%02d", _("Time Left"), ((int)tleft) / 60, ((int)tleft) % 60); checkMiniProductionRect(timeLeftBuf); // dest.bltLookup(miniProductionRect, Palette::filterDarkGray()); dest.bltString(pos.x, pos.y, outpostUserNameBuf, Color::cyan); pos.x += unitImages[0]->getWidth(); pos.y += 16; dest.bltString(pos.x, pos.y, outpostNameBuf, Color::white); pos.y += 16; dest.bltString(pos.x, pos.y, productionUnitBuf, Color::white); pos.y += 16; dest.bltString(pos.x, pos.y, timeLeftBuf, Color::white); pos.y += 16; // Draw the current production unit image. drawUnitImage(dest, miniProductionRect.getLocation() + iXY(1,16), obj->unit_generation_type); } } else { // dest.bltLookup(miniProductionRect, Palette::filterDarkGray()); if ( obj->occupying_player) { dest.bltString(pos.x, pos.y, outpostUserNameBuf, Color::cyan); pos.y += 16; } dest.bltString(pos.x, pos.y, outpostNameBuf, Color::white); } } } // end VehicleSelectionView::drawMiniProductionStatus
// addMeterButtons //--------------------------------------------------------------------------- void HostOptionsView::addMeterButtons(const iXY &pos) { const int yOffset = 15; const int arrowButtonWidth = 16; int x; int y = pos.y; int xTextStart = pos.x; int xControlStart = 270; x = xTextStart; add( new Label(x, y, "Max Players", windowTextColor, windowTextColorShadow, true) ); x += xControlStart; addButtonCenterText(iXY(x - 1, y), arrowButtonWidth, "<", "", bDecreasePlayerCount); x += arrowButtonWidth + meterWidth; addButtonCenterText(iXY(x + 1, y), arrowButtonWidth, ">", "", bIncreasePlayerCount); y += yOffset; x = xTextStart; add( new Label(x, y, "Game Max Unit Count", windowTextColor, windowTextColorShadow, true) ); x += xControlStart; addButtonCenterText(iXY(x - 1, y), arrowButtonWidth, "<", "", bDecreaseMaxUnitCount); x += arrowButtonWidth + meterWidth; addButtonCenterText(iXY(x + 1, y), arrowButtonWidth, ">", "", bIncreaseMaxUnitCount); y += yOffset; /* x = xTextStart; //addLabelShadowed(iXY(x, y), "Player Respawn Unit Count", windowTextColor, windowTextColorShadow); x += xControlStart; addButtonCenterText(iXY(x - 1, y), arrowButtonWidth, "<", "", bDecreaseRespawnCount); x += arrowButtonWidth + meterWidth; addButtonCenterText(iXY(x + 1, y), arrowButtonWidth, ">", "", bIncreaseRespawnCount); y += yOffset; */ //x = xTextStart; //addLabelShadowed(iXY(x, y), "Allow Allies", windowTextColor, windowTextColorShadow); //x += xControlStart; //addButtonCenterText(iXY(x - 1, y), arrowButtonWidth, "<", "", bSetAllowAlliesFalse); //x += arrowButtonWidth + meterWidth; //addButtonCenterText(iXY(x + 1, y), arrowButtonWidth, ">", "", bSetAllowAlliesTrue); //y += yOffset; // //x = xTextStart; //addLabelShadowed(iXY(x, y), "Spawn Placement", windowTextColor, windowTextColorShadow); //x += xControlStart; //addButtonCenterText(iXY(x - 1, y), arrowButtonWidth, "<", "", bPreviousSpawnPlacement); //x += arrowButtonWidth + meterWidth; //addButtonCenterText(iXY(x + 1, y), arrowButtonWidth, ">", "", bNextSpawnPlacement); //y += yOffset; x = xTextStart; add( new Label( x, y, "Objective Capture Percent", windowTextColor, windowTextColorShadow, true) ); x += xControlStart; addButtonCenterText(iXY(x - 1, y), arrowButtonWidth, "<", "", bDecreaseObjectiveCapturePercent); x += arrowButtonWidth + meterWidth; addButtonCenterText(iXY(x + 1, y), arrowButtonWidth, ">", "", bIncreaseObjectiveCapturePercent); y += yOffset; x = xTextStart; add( new Label( x, y, "Time Limit", windowTextColor, windowTextColorShadow, true) ); x += xControlStart; addButtonCenterText(iXY(x - 1, y), arrowButtonWidth, "<", "", bDecreaseTimeLimit); x += arrowButtonWidth + meterWidth; addButtonCenterText(iXY(x + 1, y), arrowButtonWidth, ">", "", bIncreaseTimeLimit); y += yOffset; x = xTextStart; add( new Label( x, y, "Frag Limit", windowTextColor, windowTextColorShadow, true) ); x += xControlStart; addButtonCenterText(iXY(x - 1, y), arrowButtonWidth, "<", "", bDecreaseFragLimit); x += arrowButtonWidth + meterWidth; addButtonCenterText(iXY(x + 1, y), arrowButtonWidth, ">", "", bIncreaseFragLimit); y += yOffset; const int minWidth = 150; int xChoiceOffset = 2; choiceGameType.setName("Game Type"); choiceGameType.addItem("Objective"); choiceGameType.addItem("Frag Limit"); choiceGameType.addItem("Time Limit"); choiceGameType.setMinWidth(minWidth); choiceGameType.setLocation(xChoiceOffset, 100); choiceGameType.select( getGameTypeString() ); add(&choiceGameType); xChoiceOffset += minWidth + 123; choiceCloudCoverage.setName("Cloud Coverage"); choiceCloudCoverage.addItem("Clear"); choiceCloudCoverage.addItem("Broken"); choiceCloudCoverage.addItem("Partly Cloudy"); choiceCloudCoverage.addItem("Overcast"); choiceCloudCoverage.addItem("Extremely Cloudy"); choiceCloudCoverage.setMinWidth(minWidth); choiceCloudCoverage.setLocation(xChoiceOffset, 100); choiceCloudCoverage.select(cloudCoverageCount); add(&choiceCloudCoverage); xChoiceOffset += minWidth + 13; choiceWindSpeed.setName("Wind Speed"); choiceWindSpeed.addItem("Calm"); choiceWindSpeed.addItem("Breezy"); choiceWindSpeed.addItem("Brisk"); choiceWindSpeed.addItem("Heavy"); choiceWindSpeed.addItem("Typhoon"); choiceWindSpeed.setMinWidth(minWidth); choiceWindSpeed.setLocation(xChoiceOffset, 100); choiceWindSpeed.select(windSpeed); add(&choiceWindSpeed); xChoiceOffset += minWidth + 10; checkPublic.setLabel("Public"); checkPublic.setState(GameConfig::server_public); checkPublic.setLocation(2, 125); add(&checkPublic); checkPowerUp.setLabel("PowerUps"); checkPowerUp.setState(GameConfig::game_powerups); checkPowerUp.setLocation(120, 125); add(&checkPowerUp); /* x = xTextStart; //addLabelShadowed(iXY(x, y), "Allow Fog Of War", windowTextColor, windowTextColorShadow); x += xControlStart; addButtonCenterText(iXY(x - 1, y), arrowButtonWidth, "<", "", bSetAllowFogOfWarFalse); x += arrowButtonWidth + meterWidth; addButtonCenterText(iXY(x + 1, y), arrowButtonWidth, ">", "", bSetAllowFogOfWarTrue); */ } // end HostOptionsView::addMeterButtons
iXY TileInterface::getTileSize( void ) { return( iXY( tile_set.getTileXsize(), tile_set.getTileYsize() ) ); }
// 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
inline void moveTo(const int &x, const int &y) { moveTo(iXY(x, y)); }
iXY getMapPos() const { return iXY(ltoh16(map_x), ltoh16(map_y)); }
inline void resizeClientArea(const int &x, const int &y) { resizeClientArea(iXY(x, y)); }
inline void resize(const int &x, const int &y) { resize(iXY(x, y)); }
// doDraw //--------------------------------------------------------------------------- void IRCLobbyView::doDraw(Surface &viewArea, Surface &clientArea) { assert(this!=0); clientArea.fill(Color::black); startIRC(); // start irc if needed int y=0; int disp_server_upto=0; total_displayed_servers=0; if(lobby_connection == 0 || !lobby_connection->isConnected()) { clientArea.bltString(iXY(0,0),"Not connected to lobby", Color::white); View::doDraw(viewArea, clientArea); return; } else { SDL_mutexP(lobby_connection->game_servers_mutex); GameServerList::iterator i; GameServerList* serverlist = lobby_connection->game_servers; disp_server_upto=0; int upto=0; for(i=serverlist->begin(); i!=serverlist->end(); i++) { if(upto>=topViewableItem) { break; } upto++; } for(; i!=serverlist->end(); i++) { const GameServer* server = &(*i); std::stringstream playerstr; playerstr << server->playercount << "/" << server->max_players; clientArea.bltString(iXY(0,y),server->real_user.c_str(), Color::white); clientArea.bltString(iXY(140,y),playerstr.str().c_str(), Color::white); clientArea.bltString(iXY(200,y),server->map.c_str(), Color::white); displayed_servers[disp_server_upto++]=server; y += Surface::getFontHeight(); if(y >= server_list_end_y) break; } SDL_mutexV(lobby_connection->game_servers_mutex); total_displayed_servers=disp_server_upto; } std::list<IRCChatMessage>::reverse_iterator m; y = chat_list_end_y - Surface::getFontHeight(); int skipped=0; for(m = lobby_connection->chat_messages.rbegin(); skipped < skipChatLines && m != lobby_connection->chat_messages.rend(); m++,skipped++) { } for(; m != lobby_connection->chat_messages.rend(); m++) { std::stringstream temp; temp << m->getUser() << ": " << m->getMessage(); clientArea.bltString(iXY(4,y), temp.str().c_str(), Color::white); y-=Surface::getFontHeight(); if(y < server_list_end_y) break; } View::doDraw(viewArea, clientArea); }
// 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
Valentine::Valentine( iXY initial_loc, unsigned char color, unsigned char flag ) : Vehicle( initial_loc ) { setUnitProperties(); if ( color == false) { body_anim.setData( gValentineBody ); turret_anim.setData( gValentineTurret ); } else { body_anim.setData( gValentineBodyDarkBlue ); turret_anim.setData( gValentineTurretDarkBlue ); } body_anim.setAttrib( iXY(0,0), iXY(0,0), unitLayer ); turret_anim.setAttrib( iXY(0,0), iXY(0,0), unitLayer ); body_anim_shadow.setData( gValentineBodyShadow ); turret_anim_shadow.setData( gValentineTurretShadow ); body_anim_shadow.setAttrib( iXY(0,0), iXY(0,0), unitLayer ); turret_anim_shadow.setAttrib( iXY(0,0), iXY(0,0), unitLayer ); select_info_box.setBoxAttributes( BoundBox( -20, -20, 20, 20), Color::blue ); select_info_box.setBoxState( false ); select_info_box.setFlag( flag ); body_anim_shadow.attachSprite( &body_anim, iXY(0,0) ); body_anim_shadow.attachSprite( &turret_anim_shadow, iXY(0,0) ); body_anim_shadow.attachSprite( &turret_anim, iXY(0,0) ); body_anim_shadow.attachSprite( &select_info_box, iXY(0,0) ); }
// doDraw //-------------------------------------------------------------------------- void VehicleSelectionView::doDraw( Surface& dest ) { Objective* obj = ObjectiveInterface::getObjective(CURRENT_SELECTED_OUTPOST_ID); if ( !obj || obj->occupying_player != PlayerInterface::getLocalPlayer() ) { // Desktop::setVisibilityNoDoAnything("VehicleSelectionView", false); changeMade = false; return; } char strBuf[256]; const int color = Color::white; // Draw a line attaching the VehicleSelectionView to its outpost. {if (WorldInputCmdProcessor::isObjectiveSelected()) { // Draw a line connecting the vehicleSelectionView and the objective. iRect gameViewRect; WorldViewInterface::getViewWindow(&gameViewRect); iXY objectivePos(WorldInputCmdProcessor::getSelectedObjectiveWorldPos()); objectivePos -= gameViewRect.getLocation(); iXY a(VehicleSelectionView::getLocation() + VehicleSelectionView::getSize() / 2); iXY b(objectivePos); // Calculate the starting point on the outside of the vehicleSelectionView box. fXY v2oSlope(Math::unitDirection(a, b)); a.x += int(v2oSlope.x * float(VehicleSelectionView::getWidth() / 2)); a.y += int(v2oSlope.y * float(VehicleSelectionView::getHeight() / 2)); // Calculate the starting point on the outside of the objective box. iXY objectiveOutlineSize(3, 3); //fXY o2vSlope(Math::unitDirection(b, a)); //b.x += o2vSlope.x * float(objectiveOutlineSize.x); //b.y += o2vSlope.y * float(objectiveOutlineSize.y); //screen.drawLine(a, b, Color::white); iRect r(objectivePos.x - objectiveOutlineSize.x, objectivePos.y - objectiveOutlineSize.y, objectiveOutlineSize.x, objectiveOutlineSize.y); screen->fillRect(r, Color::white); //int xOffset = (strlen(WorldInputCmdProcessor::getSelectedObjectiveName()) * CHAR_XPIX) / 2; //screen.bltStringShadowed(r.min.x - xOffset, r.min.y - 15, WorldInputCmdProcessor::getSelectedObjectiveName(), Color::white, Color::black); iXY oos(objectiveOutlineSize); iXY cpos; if (v2oSlope.x > 0 && v2oSlope.y > 0) { cpos = iXY(getEndX(), getEndY()); r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y); } if (v2oSlope.x > 0 && v2oSlope.y <= 0) { cpos = iXY(getEndX(), getLocationY()); r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y); } if (v2oSlope.x <= 0 && v2oSlope.y > 0) { cpos = iXY(getLocationX(), getEndY()); r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y); } if (v2oSlope.x <= 0 && v2oSlope.y <= 0) { cpos = iXY(getLocationX(), getLocationY()); r = iRect(cpos.x - oos.x, cpos.y-oos.y, oos.x, oos.y); } // screen->drawLine(cpos, b, Color::white); screen->fillRect(r, Color::white); //screen.bltLookup(r, Palette::darkGray256.getColorArray()); //screen.drawButtonBorder(r, Color::white, Color::gray96); // Draw the name of the outpost. }} bltViewBackground(dest); int remaining_time = 0; int generation_time = 0; if ( obj->unit_generation_on_flag ) { remaining_time = obj->unit_generation_timer.getTimeLeft(); UnitProfile* profile = UnitProfileInterface::getUnitProfile(obj->unit_generation_type); generation_time = profile->regen_time; } if (vsvUnitGenOn) { sprintf(strBuf, "%s", getUnitName(vsvSelectedUnit)); dest.bltString( productionUnitPos.x, productionUnitPos.y, strBuf, color); sprintf(strBuf, "%01d:%02d/%01d:%02d", remaining_time / 60, remaining_time % 60, generation_time / 60, generation_time % 60); dest.bltString( timeRequiredPos.x, timeRequiredPos.y, strBuf, color); } else { sprintf(strBuf, "%s", _("power off")); dest.bltString( productionUnitPos.x, productionUnitPos.y, strBuf, color); dest.bltString( timeRequiredPos.x, timeRequiredPos.y, strBuf, color); } int unitPerPlayer = GameConfig::game_maxunits / GameConfig::game_maxplayers; sprintf(strBuf, "%d/%d", int(UnitInterface::getUnitCount(PlayerInterface::getLocalPlayerIndex())), unitPerPlayer); dest.bltString(unitsBuiltPos.x, unitsBuiltPos.y, strBuf, color); drawUnitProfileInfo(dest, iXY(0, unitProfileDataY), highlightedUnitType); //sprintf(strBuf, "%01d:%02d", ( (int) outpost_status.unit_generation_time_remaining ) / 60, ( (int) outpost_status.unit_generation_time_remaining) % 60 ); //clientArea.bltString(timeRemainingPos, strBuf, color); View::doDraw( dest ); } // end VehicleSelectionView::doDraw
static size_t mapXYtoOffset(size_t map_x, size_t map_y) { return mapXYtoOffset(iXY(map_x, map_y)); }
// initButtons //--------------------------------------------------------------------------- void OptionsTemplateView::initButtons() { removeAllButtons(); removeComponents(); MenuTemplateView::initButtons(); int xTextStart = bodyTextRect.min.x; int x = xTextStart; int y = bodyTextRect.min.y; int yOffset = 17; int arrowButtonWidth = 16; int col = 200; // Settings //---------------------------------------------------------------------- int minWidth = 19 * 8; add( new Separator( bodyTextRect.min.x, y, bodyTextRect.max.x, "VISUAL", componentActiveTextColor) ); y += yOffset; x = xTextStart; checkBoxFullscreen = new CheckBox(); checkBoxFullscreen->setLabel("Fullscreen"); checkBoxFullscreen->setLocation(x+ col, y); checkBoxFullscreen->setStateChangedCallback(this); add(checkBoxFullscreen); y += yOffset; x = xTextStart; checkBoxDrawAllShadows = new CheckBox(); checkBoxDrawAllShadows->setLabel("Draw All Shadows"); checkBoxDrawAllShadows->setState(GameConfig::video_shadows); checkBoxDrawAllShadows->setLocation(x+ col, y); checkBoxDrawAllShadows->setStateChangedCallback(this); add(checkBoxDrawAllShadows); x = xTextStart; char res_str[20]; choiceResolution = new Choice(); choiceResolution->setName("Resolution"); choiceResolution->addItem("current"); SDL_Rect** modes = SDL_ListModes(0, SDL_FULLSCREEN); int cur_mode = 0; if ( modes && modes != (SDL_Rect**)-1 ) { while ( modes[cur_mode] ) { if ((modes[cur_mode]->w > 799) && (modes[cur_mode]->h > 599) ) { snprintf(res_str,sizeof(res_str),"%dx%d", modes[cur_mode]->w, modes[cur_mode]->h); res_str[sizeof(res_str)-1] = 0; choiceResolution->addItem(res_str); } ++cur_mode; } } choiceResolution->setLocation(x, y-3); choiceResolution->select(0); choiceResolution->setMinWidth(minWidth); choiceResolution->setStateChangedCallback(this); add(choiceResolution); current_width = 0; current_height = 0; y += yOffset; x = xTextStart; checkBoxBlendSmoke = new CheckBox(); checkBoxBlendSmoke->setLabel("Blend Smoke"); checkBoxBlendSmoke->setState(GameConfig::video_blendsmoke); checkBoxBlendSmoke->setLocation(x+ col, y); checkBoxBlendSmoke->setStateChangedCallback(this); add(checkBoxBlendSmoke); y += yOffset; #ifdef _WIN32 x = xTextStart; checkBoxUseDirectX = new CheckBox(); checkBoxUseDirectX->setLabel("Use DirectX"); checkBoxUseDirectX->setState(GameConfig::video_usedirectx); checkBoxUseDirectX->setLocation(x+ col, y); checkBoxUseDirectX->setStateChangedCallback(this); add(checkBoxUseDirectX); #endif x = xTextStart; choiceMiniMapUnitSize = new Choice(); choiceMiniMapUnitSize->setName("Mini Map Unit Size"); choiceMiniMapUnitSize->addItem("Small"); choiceMiniMapUnitSize->addItem("Large"); choiceMiniMapUnitSize->setLocation(x, y); choiceMiniMapUnitSize->select(gameconfig->radar_unitsize); choiceMiniMapUnitSize->setMinWidth(minWidth); choiceMiniMapUnitSize->setStateChangedCallback(this); add(choiceMiniMapUnitSize); y += yOffset*2; // VISUAL OPTIONS add( new Separator( bodyTextRect.min.x, y, bodyTextRect.max.x, "INTERFACE", componentActiveTextColor) ); y += yOffset; x = xTextStart; add( new Label( x, y+3, "Scroll Rate:", windowTextColor) ); x += optionsMeterStartX; addButtonCenterText(iXY(x - 1, y), arrowButtonWidth, "<", "", bDecreaseScrollRate); x += optionsMeterWidth + arrowButtonWidth; addButtonCenterText(iXY(x + 1, y), arrowButtonWidth, ">", "", bIncreaseScrollRate); y += yOffset*3; // SOUND OPTIONS add( new Separator( bodyTextRect.min.x, y, bodyTextRect.max.x, "SOUND", componentActiveTextColor) ); y += yOffset; x = xTextStart; add( new Label( x, y, "Sound Status:", windowTextColor) ); checkBoxSoundEnabled = new CheckBox(); checkBoxSoundEnabled->setLabel(gameconfig->enablesound?"Enabled":"Disabled"); checkBoxSoundEnabled->setState(gameconfig->enablesound); x += optionsMeterStartX; checkBoxSoundEnabled->setLocation(x, y-2); checkBoxSoundEnabled->setStateChangedCallback(this); add(checkBoxSoundEnabled); y += yOffset; x = xTextStart; add( new Label( x, y+3, "Sound Volume:", windowTextColor) ); x += optionsMeterStartX; addButtonCenterText(iXY(x - 1, y), arrowButtonWidth, "<", "", bDecreaseSoundVolume); x += optionsMeterWidth + arrowButtonWidth; addButtonCenterText(iXY(x + 1, y), arrowButtonWidth, ">", "", bIncreaseSoundVolume); y += yOffset; y += yOffset; x = xTextStart; add( new Label( x, y, "Music Status:", windowTextColor) ); checkBoxMusicEnabled = new CheckBox(); checkBoxMusicEnabled->setLabel(gameconfig->enablemusic?"Enabled":"Disabled"); checkBoxMusicEnabled->setState(gameconfig->enablemusic); x += optionsMeterStartX; checkBoxMusicEnabled->setLocation(x, y-2); checkBoxMusicEnabled->setStateChangedCallback(this); add(checkBoxMusicEnabled); y += yOffset; x = xTextStart; add( new Label( x, y+3, "Music Volume:", windowTextColor) ); x += optionsMeterStartX; addButtonCenterText(iXY(x - 1, y), arrowButtonWidth, "<", "", bDecreaseMusicVolume); x += optionsMeterWidth + arrowButtonWidth; addButtonCenterText(iXY(x + 1, y), arrowButtonWidth, ">", "", bIncreaseMusicVolume); y += yOffset; } // end OptionsTemplateView::initButtons
// LibView //--------------------------------------------------------------------------- LibView::LibView() : GameTemplateView() { setSearchName("LibView"); setTitle("Lib Stats"); setSubTitle(" - F5"); setAllowResize(false); setAllowMove(true); setDisplayStatusBar(false); setVisible(false); moveTo(0, 0); resize(325, 375); addButtonCenterText(iXY((getClientRect().getSize().x / 3) * 0, 0), getClientRect().getSize().x / 3, "Surface", "", bSurfaceInfo); addButtonCenterText(iXY((getClientRect().getSize().x / 3) * 1, 0), getClientRect().getSize().x / 3, "Particles", "", bParticleInfo); addButtonCenterText(iXY((getClientRect().getSize().x / 3) * 2, 0), getClientRect().getSize().x / 3, "Environment", "", bEnvironmentInfo); checkBoxAllowParticleGeneration = new CheckBox(); checkBoxAllowParticleGeneration->setLabel("Allow Particle Generation"); checkBoxAllowParticleGeneration->setLocation(0, 15); checkBoxAllowParticleGeneration->setState(Particle2D::getCreateParticles()); add(checkBoxAllowParticleGeneration); checkBoxAllowTimeSlice = new CheckBox(); checkBoxAllowTimeSlice->setLabel("Allow Time Slice"); checkBoxAllowTimeSlice->setLocation(0, 30); checkBoxAllowTimeSlice->setState(gTimeSliceFlag); add(checkBoxAllowTimeSlice); checkBoxAllowSpanBlitting = new CheckBox(); checkBoxAllowSpanBlitting->setLabel("Allow Blended Span Blitting"); checkBoxAllowSpanBlitting->setLocation(0, 45); checkBoxAllowSpanBlitting->setState(allowSpanBlitting); add(checkBoxAllowSpanBlitting); checkBoxParticlesCanHaveSmoke = new CheckBox(); checkBoxParticlesCanHaveSmoke->setLabel("Allow Explosion Particle Smoke"); checkBoxParticlesCanHaveSmoke->setLocation(0, 60); checkBoxParticlesCanHaveSmoke->setState(ParticleInterface::gParticlesCanHaveSmoke); add(checkBoxParticlesCanHaveSmoke); checkBoxSolidColorExplosionParticles = new CheckBox(); checkBoxSolidColorExplosionParticles->setLabel("Solid Color Explosion Particles"); checkBoxSolidColorExplosionParticles->setLocation(0, 75); checkBoxSolidColorExplosionParticles->setState(ParticleInterface::gSolidColorExplosionParticles); add(checkBoxSolidColorExplosionParticles); checkBoxParticleInterfaceSim = new CheckBox(); checkBoxParticleInterfaceSim->setLabel("Particle Interface Sim"); checkBoxParticleInterfaceSim->setLocation(0, 90); checkBoxParticleInterfaceSim->setState(ParticleInterface::gTestSim); add(checkBoxParticleInterfaceSim); checkBoxSolidBackground = new CheckBox(); checkBoxSolidBackground->setLabel("Solid Background"); checkBoxSolidBackground->setLocation(0, 105); checkBoxSolidBackground->setState(GameView::gDrawSolidBackground); add(checkBoxSolidBackground); checkBoxDrawExplosionParticleCount = new CheckBox(); checkBoxDrawExplosionParticleCount->setLabel("Draw Explosion Particle Count"); checkBoxDrawExplosionParticleCount->setLocation(0, 120); checkBoxDrawExplosionParticleCount->setState(ParticleInterface::gDrawExplosionParticleCount); add(checkBoxDrawExplosionParticleCount); } // end LibView::LibView
// addVehicleButtons //--------------------------------------------------------------------------- void HostJoinTemplateView::addVehicleButtons(const iXY &pos) { // Add the vehicle buttons. // Get the dimensions of the buttons to draw. Surface tempSurface; if (!tempSurface.loadTIL("pics/vehicleSelectionMenu/light.til")) { throw Exception("ERROR: Unable to open pics/vehicleSelectionMenu/light.til to find the size to make the buttons."); } iXY buttonSize(tempSurface.getPix()); int arrowButtonWidth = 16; int x; int y; x = pos.x; y = pos.y; addButtonTILBordered(iXY(x, y), "pics/vehicleSelectionMenu/humvee.til", "", 0); x += buttonSize.x + 1; addButtonTILBordered(iXY(x, y), "pics/vehicleSelectionMenu/light.til", "", 0); x += buttonSize.x + 1; addButtonTILBordered(iXY(x, y), "pics/vehicleSelectionMenu/medium.til", "", 0); x += buttonSize.x + 1; addButtonTILBordered(iXY(x, y), "pics/vehicleSelectionMenu/heavy.til", "", 0); x += buttonSize.x + 1; addButtonTILBordered(iXY(x, y), "pics/vehicleSelectionMenu/missle.til", "", 0); x += buttonSize.x + 1; // Draw the arrows to change the numbers. x = pos.x; y = pos.y + buttonSize.y; x = pos.x + (buttonSize.x + 1) * 0; x += (buttonSize.x - (arrowButtonWidth * 2)) / 2; addButtonCenterText(iXY(x, y), arrowButtonWidth, "<", "", bDecreaseHumvee); addButtonCenterText(iXY(x + arrowButtonWidth, y), arrowButtonWidth, ">", "", bIncreaseHumvee); x = pos.x + (buttonSize.x + 1) * 1; x += (buttonSize.x - (arrowButtonWidth * 2)) / 2; addButtonCenterText(iXY(x, y), arrowButtonWidth, "<", "", bDecreaseLightTank); addButtonCenterText(iXY(x + arrowButtonWidth, y), arrowButtonWidth, ">", "", bIncreaseLightTank); x = pos.x + (buttonSize.x + 1) * 2; x += (buttonSize.x - (arrowButtonWidth * 2)) / 2; addButtonCenterText(iXY(x, y), arrowButtonWidth, "<", "", bDecreaseMediumTank); addButtonCenterText(iXY(x + arrowButtonWidth, y), arrowButtonWidth, ">", "", bIncreaseMediumTank); x = pos.x + (buttonSize.x + 1) * 3; x += (buttonSize.x - (arrowButtonWidth * 2)) / 2; addButtonCenterText(iXY(x, y), arrowButtonWidth, "<", "", bDecreaseHeavyTank); addButtonCenterText(iXY(x + arrowButtonWidth, y), arrowButtonWidth, ">", "", bIncreaseHeavyTank); x = pos.x + (buttonSize.x + 1) * 4; x += (buttonSize.x - (arrowButtonWidth * 2)) / 2; addButtonCenterText(iXY(x, y), arrowButtonWidth, "<", "", bDecreaseMissleLauncher); addButtonCenterText(iXY(x + arrowButtonWidth, y), arrowButtonWidth, ">", "", bIncreaseMissleLauncher); } // end HostJoinTemplateView::addVehicleButtons
// init //--------------------------------------------------------------------------- void GameView::init() { resize(iXY(screen->getWidth(), screen->getHeight())); moveTo(iXY(0, 0)); } // end GameView::init
// getScreenToViewPos //--------------------------------------------------------------------------- // Purpose: Finds the position of the mouse in the client area of a window. // If this function gets called, we can assume that the mouse is in // client area of the window. //--------------------------------------------------------------------------- iXY View::getScreenToViewPos(const iXY &pos) { assert(this != 0); return iXY(pos.x - min.x, pos.y - min.y); } // end getScreenToViewPos
void GameView::checkResolution(iXY oldResolution, iXY newResolution) { resize(iXY(newResolution.x, newResolution.y)); moveTo(iXY(0,0)); }
static iXY getSize() { return iXY(main_map.getWidth(), main_map.getHeight()); }
void ObjectiveInterface::loadObjectiveList(const char *file_path) { if ( ! gameconfig->gameoptions.outposts.enabled() ) { return; } ObjectiveID objective_count = 0; try { NPString ff("/maps/"); ff += file_path; ff += ".opt"; IFileStream in(ff); cleanUpObjectiveList(); std::string objectivecount = readToken(in, "ObjectiveCount:"); std::stringstream ss(objectivecount); ss >> objective_count; if ( objective_count > 0 ) { objective_list = new Objective*[objective_count]; num_objectives = 0; } iXY loc; iXY world; std::string name; for (ObjectiveID objective_index = 0; objective_index < objective_count; objective_index++ ) { Objective *objective_obj; name = readToken(in, "Name:"); std::string location = readToken(in, "Location:"); std::stringstream ss(location); ss >> loc.x >> loc.y; MapInterface::mapXYtoPointXY( loc, world ); objective_obj = new Objective(objective_index, world, // BoundBox( -48, -32, 48, 32 ) BoundBox( iXY(48, 32) ) ); strcpy(objective_obj->name, name.c_str()); objective_list[objective_index] = objective_obj; ++num_objectives; } // ** for } catch(std::exception& e) { cleanUpObjectiveList(); LOGGER.warning("OILOL Error loading objectives '%s': %s. Working without them", file_path, e.what()); } }