|
From: <be...@us...> - 2016-10-15 06:15:57
|
Revision: 1011
http://sourceforge.net/p/freesynd/code/1011
Author: benblan
Date: 2016-10-15 06:15:54 +0000 (Sat, 15 Oct 2016)
Log Message:
-----------
- new property MapObject::isVisible to replace the "map == -1" rule for displaying object
- Added weapons and sfxobject in the new rendering process
- change location of updating agent markers position from MapRenderer to GameplayMenu
Modified Paths:
--------------
freesynd/branches/fix-render/src/mapobject.h
freesynd/branches/fix-render/src/menus/gameplaymenu.cpp
freesynd/branches/fix-render/src/menus/gameplaymenu.h
freesynd/branches/fix-render/src/menus/maprenderer.cpp
Modified: freesynd/branches/fix-render/src/mapobject.h
===================================================================
--- freesynd/branches/fix-render/src/mapobject.h 2016-10-12 20:28:47 UTC (rev 1010)
+++ freesynd/branches/fix-render/src/mapobject.h 2016-10-15 06:15:54 UTC (rev 1011)
@@ -67,6 +67,19 @@
//! Return the object's id
uint16 id() { return id_; }
+ void setVisible(bool visible) {
+ isVisible_ = visible;
+ // TODO : remove when isVisible is active
+ if (!isVisible_) {
+ map_ = -1;
+ }
+ }
+
+ bool isVisible() {
+ // TODO : replace with isvisible_
+ return map_ != -1;
+ }
+
virtual void draw(int x, int y) = 0;
enum DamageType {
dmg_None = 0x0000,
@@ -274,6 +287,9 @@
void offzOnStairs(uint8 twd);
protected:
+ void addOffs(int &x, int &y);
+
+protected:
//! the nature of this object
ObjectNature nature_;
//! Id of the object. Id is unique within a nature
@@ -286,6 +302,8 @@
int size_x_, size_y_, size_z_;
//! if equal -1 object is not on map and should not be drawn
int map_;
+ //! Object should be drawn only if visible
+ bool isVisible_;
//! animation frame changing
int frame_;
/*!
@@ -307,8 +325,6 @@
*/
bool is_frame_drawn_;
uint32 state_;
-
- void addOffs(int &x, int &y);
};
/*!
Modified: freesynd/branches/fix-render/src/menus/gameplaymenu.cpp
===================================================================
--- freesynd/branches/fix-render/src/menus/gameplaymenu.cpp 2016-10-12 20:28:47 UTC (rev 1010)
+++ freesynd/branches/fix-render/src/menus/gameplaymenu.cpp 2016-10-15 06:15:54 UTC (rev 1011)
@@ -215,7 +215,8 @@
menu_manager_->setPaletteForMission(g_Session.getSelectedBlock().mis_id);
g_Screen.clear(0);
- updtAgentsMarker();
+ highlightLeaderMarker();
+ updateMarkersPosition();
// Init renderers
map_renderer_.init(mission_, &selection_);
@@ -290,6 +291,8 @@
for (size_t i = 0; i < mission_->numPeds(); i++)
change |= mission_->ped(i)->animate(diff, mission_);
+ updateMarkersPosition();
+
for (size_t i = 0; i < mission_->numVehicles(); i++)
change |= mission_->vehicle(i)->animate(diff);
@@ -325,7 +328,7 @@
{
g_Screen.clear(0);
map_renderer_.render(viewPortOrigin_);
- g_Screen.drawRect(0,0, 129, GAME_SCREEN_HEIGHT);
+ g_Screen.drawRect(0,0, Screen::kScreenPanelWidth, Screen::kScreenHeight);
agt_sel_renderer_.render(selection_, mission_->getSquad());
drawSelectAllButton();
drawMissionHint(0);
@@ -345,7 +348,7 @@
for (int i = 1756; i < g_App.gameSprites().spriteCount(); i++) {
Sprite *s = g_App.gameSprites().sprite(i);
- if (y + s->height() > GAME_SCREEN_HEIGHT) {
+ if (y + s->height() > Screen::kScreenHeight) {
printf("last sprite %i\n", i - 1);
break;
}
@@ -523,19 +526,12 @@
for (size_t i = 0; mission_ && i < mission_->numWeapons(); ++i) {
WeaponInstance *w = mission_->weapon(i);
- if (w->map() != -1) {
- Point2D scPt;
- mission_->get_map()->tileToScreenPoint(w->position(), &scPt);
- int px = scPt.x - 10;
- int py = scPt.y + 4 - w->tileZ() * TILE_HEIGHT/3
- - (w->offZ() * TILE_HEIGHT/3) / 128;
+ mission_->get_map()->tileToViewportCoords(w->position(), &objPosInViewportPt);
- if (x - 129 + viewPortOrigin_.x >= px && y + viewPortOrigin_.y >= py &&
- x - 129 + viewPortOrigin_.x < px + 20 && y + viewPortOrigin_.y < py + 15)
- {
- target_ = w;
- break;
- }
+ if (isMouseOnObject(mouseInViewport, objPosInViewportPt, 4, -12, 10, 5)) {
+ // mouse pointer is on the object, so it's the new target
+ target_ = w;
+ break;
}
}
#if 0
@@ -1254,7 +1250,7 @@
if (selection_.selectAgent(agentNo, addToGroup)) {
updateSelectAll();
centerMinimapOnLeader();
- updtAgentsMarker();
+ highlightLeaderMarker();
g_App.gameSounds().play(snd::SPEECH_SELECTED);
// redraw agent selectors
@@ -1283,14 +1279,35 @@
* Make the current leader marker blinks.
* All other agents not.
*/
-void GameplayMenu::updtAgentsMarker()
+void GameplayMenu::highlightLeaderMarker()
{
for (size_t i = AgentManager::kSlot1; i < AgentManager::kMaxSlot; i++) {
- // draw animation only for leader
- mission_->sfxObjects(4 + i)->setDrawAllFrames(selection_.getLeaderSlot() == i);
+ PedInstance *pAgent = mission_->getSquad()->member(i);
+ if (pAgent == NULL || pAgent->isDead()) {
+ mission_->sfxObjects(4 + i)->setVisible(false);
+ } else {
+ // draw animation only for leader
+ mission_->sfxObjects(4 + i)->setDrawAllFrames(selection_.getLeaderSlot() == i);
+ }
}
}
+/**
+ * Updating position for visual markers for all agents.
+ * \return void
+ *
+ */
+void GameplayMenu::updateMarkersPosition() {
+ for (size_t i = 0; i < AgentManager::kMaxSlot; i++) {
+ if (mission_->sfxObjects(i + 4)->isVisible()) {
+ TilePoint agentPos = mission_->getSquad()->member(i)->position();
+ agentPos.ox -= 16;
+ agentPos.oz += 256;
+
+ mission_->sfxObjects(i + 4)->setPosition(agentPos);
+ }
+ }
+}
/*!
* This method checks among the squad to see if an agent died and deselects him.
*/
@@ -1310,7 +1327,7 @@
}
// anyway updates markers
- updtAgentsMarker();
+ highlightLeaderMarker();
updateSelectAll();
}
Modified: freesynd/branches/fix-render/src/menus/gameplaymenu.h
===================================================================
--- freesynd/branches/fix-render/src/menus/gameplaymenu.h 2016-10-12 20:28:47 UTC (rev 1010)
+++ freesynd/branches/fix-render/src/menus/gameplaymenu.h 2016-10-15 06:15:54 UTC (rev 1011)
@@ -92,8 +92,10 @@
//! Deselect agent if he died
void updateSelectionForDeadAgent(PedInstance *p_ped);
- //! updates visual markers for our agents
- void updtAgentsMarker();
+ //! Make leader's marker blink
+ void highlightLeaderMarker();
+ //! Make markers aligned with each agent position
+ void updateMarkersPosition();
//! Set pLocWToSet param with point on the map where player clicked to shoot
bool getAimedAt(int x, int y, WorldPoint *pLocWToSet);
void stopShootingEvent();
Modified: freesynd/branches/fix-render/src/menus/maprenderer.cpp
===================================================================
--- freesynd/branches/fix-render/src/menus/maprenderer.cpp 2016-10-12 20:28:47 UTC (rev 1010)
+++ freesynd/branches/fix-render/src/menus/maprenderer.cpp 2016-10-15 06:15:54 UTC (rev 1011)
@@ -160,11 +160,11 @@
freeUnreleasedResources();
- /*if (debugScreenPos.x != 0) {
- g_Screen.drawLine(debugScreenPos.x, debugScreenPos.y, debugScreenPos.x + TILE_WIDTH, debugScreenPos.y, 11);
- g_Screen.drawLine(debugScreenPos.x + TILE_WIDTH, debugScreenPos.y, debugScreenPos.x + TILE_WIDTH, debugScreenPos.y + TILE_HEIGHT, 11);
- g_Screen.drawLine(debugScreenPos.x, debugScreenPos.y, debugScreenPos.x, debugScreenPos.y + TILE_HEIGHT, 11);
- g_Screen.drawLine(debugScreenPos.x, debugScreenPos.y + TILE_HEIGHT, debugScreenPos.x + TILE_WIDTH, debugScreenPos.y + TILE_HEIGHT, 11);
+ /*if (point != NULL) {
+ g_Screen.drawLine(point.x, point.y, point.x + 5, point.y, 11);
+ g_Screen.drawLine(point.x + 5, point.y, point.x + 5, point.y + 5, 11);
+ g_Screen.drawLine(point.x, point.y, point.x, point.y + 5, 11);
+ g_Screen.drawLine(point.x, point.y + 5, point.x + 5, point.y + 5, 11);
}*/
DEBUG_SPEED_LOG("MapRenderer::render")
@@ -241,12 +241,26 @@
// Include peds
for (size_t i = 0; i < pMission_->numPeds(); i++) {
PedInstance *pPed = pMission_->ped(i);
- if (pPed->map() != -1) {
- if (isObjectInsideDrawingArea(pPed, viewport)) {
- addObjectToDraw(pPed);
- }
+ if (pPed->isVisible() && isObjectInsideDrawingArea(pPed, viewport)) {
+ addObjectToDraw(pPed);
}
}
+
+ // weapons
+ for (size_t i = 0; i < pMission_->numWeapons(); i++) {
+ WeaponInstance *pWeapon = pMission_->weapon(i);
+ if (pWeapon->isVisible() && isObjectInsideDrawingArea(pWeapon, viewport)) {
+ addObjectToDraw(pWeapon);
+ }
+ }
+
+ // sfx objects
+ for (size_t i = 0; i < pMission_->numSfxObjects(); i++) {
+ SFXObject *pSfx = pMission_->sfxObjects(i);
+ if (pSfx->isVisible() && isObjectInsideDrawingArea(pSfx, viewport)) {
+ addObjectToDraw(pSfx);
+ }
+ }
}
bool MapRenderer::isObjectInsideDrawingArea(MapObject *pObject, const Point2D &viewport) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|