2024-04-18 16:34 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000185Spring engineGeneralpublic2006-06-03 13:38
ReporterNOiZE 
Assigned Totvo 
PrioritynormalSeverityfeatureReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000185: Wrecks and Feature's should display a tooltip
DescriptionWrecks and Feature's should display a tooltip which discribes the ammount of metal/energy it's worth. And showing the discription would be nice aswell.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • patch file icon featureTooltip.patch (5,042 bytes) 2006-06-02 19:24 -
    Index: Game/UI/MouseHandler.cpp
    ===================================================================
    --- Game/UI/MouseHandler.cpp	(revision 1385)
    +++ Game/UI/MouseHandler.cpp	(working copy)
    @@ -12,6 +12,7 @@
     #include "Game/GameHelper.h"
     #include "Game/SelectedUnits.h"
     #include "Sim/Units/Unit.h"
    +#include "Sim/Misc/Feature.h"
     #include "Game/Team.h"
     #include "InfoConsole.h"
     #include "MiniMap.h"
    @@ -23,6 +24,7 @@
     #include "MouseInput.h"
     #include "Sound.h"
     #include "Sim/Units/UnitDef.h"
    +#include "Sim/Misc/FeatureDef.h"
     #include "ExternalAI/Group.h"
     #include "Platform/ConfigHandler.h"
     #include "Rendering/InMapDraw.h"
     		mc = i->second;
     	}
     	else {
    -		//info->AddLine("Unknown cursor: %s", cursorText.c_str());		
    +		//info->AddLine("Unknown cursor: %s", cursorText.c_str());
     		mc = cursors[""];
     	}
     
    @@ -528,9 +530,27 @@
     	if(s!="")
     		return s;
     
    +	/*
    +	NOTE:
    +	The code below (up untill "if(unit)...") is exactly the same as
    +	some lines in CGuiHandler::GetDefaultCommand().
    +	Perhaps it would be possible to integrate the two, because now a
    +	racetray for units and features might be performed twice per frame.
    +	*/
     	CUnit* unit=0;
    -	float dist=helper->GuiTraceRay(camera->pos,dir,gu->viewRange*1.4,unit,20,false);
    +	CFeature* feature=0;
    +	float dist=helper->GuiTraceRay(camera->pos,dir,gu->viewRange*1.4,unit,20,true);
    +	float dist2=helper->GuiTraceRayFeature(camera->pos,dir,gu->viewRange*1.4,feature);
     
    +	if(dist>gu->viewRange*1.4-100 && dist2>gu->viewRange*1.4-100 && unit==0){
    +		return "";
    +	}
    +
    +	if(dist>dist2)
    +		unit=0;
    +	else
    +		feature=0;
    +
     	if(unit){
     		// show the player name instead of unit name if it has FBI tag showPlayerName
     		if(unit->unitDef->showPlayerName)
    @@ -548,18 +568,31 @@
     			s+=tmp;
     		}
     		return s;
    -	} else {
    -		if(dist<gu->viewRange*1.4-100){
    -			float3 pos=camera->pos+dir*dist;
    -			char tmp[500];
    -			CReadMap::TerrainType* tt=&readmap->terrainTypes[readmap->typemap[min(gs->hmapx*gs->hmapy-1,max(0,((int)pos.z/16)*gs->hmapx+((int)pos.x/16)))]];
    -			string ttype=tt->name;
    -			sprintf(tmp,"Pos %.0f %.0f Elevation %.0f\nTerrain type: %s\nSpeeds T/K/H/S %.2f %.2f %.2f %.2f\nHardness %.0f Metal %.1f",pos.x,pos.z,pos.y,ttype.c_str(),tt->tankSpeed,tt->kbotSpeed,tt->hoverSpeed,tt->shipSpeed,tt->hardness*mapDamage->mapHardness,readmap->metalMap->getMetalAmount((int)(pos.x/16),(int)(pos.z/16)));
    -			return tmp;
    +	}
    +	if(feature){
    +		if(feature->def->description==""){
    +			s="Feature";
     		} else {
    -			return "";
    +			s=feature->def->description;
     		}
    +		std::string metalColor = feature->def->metal > 0 ? "\xff\x50\xff\x50" : "\xff\xff\x50\x01";
    +		std::string energyColor = feature->def->energy > 0 ? "\xff\x50\xff\x50" : "\xff\xff\x50\x01";
    +		char tmp[500];
    +		sprintf(tmp,"\n\xff\xd3\xdb\xffMetal: %s%.0f \xff\xd3\xdb\xff Energy: %s%.0f",
    +			metalColor.c_str(), feature->def->metal, energyColor.c_str(), feature->def->energy);
    +		s+=tmp;
    +
    +		return s;
     	}
    +	if(dist<gu->viewRange*1.4-100){
    +		float3 pos=camera->pos+dir*dist;
    +		char tmp[500];
    +		CReadMap::TerrainType* tt=&readmap->terrainTypes[readmap->typemap[min(gs->hmapx*gs->hmapy-1,max(0,((int)pos.z/16)*gs->hmapx+((int)pos.x/16)))]];
    +		string ttype=tt->name;
    +		sprintf(tmp,"Pos %.0f %.0f Elevation %.0f\nTerrain type: %s\nSpeeds T/K/H/S %.2f %.2f %.2f %.2f\nHardness %.0f Metal %.1f",pos.x,pos.z,pos.y,ttype.c_str(),tt->tankSpeed,tt->kbotSpeed,tt->hoverSpeed,tt->shipSpeed,tt->hardness*mapDamage->mapHardness,readmap->metalMap->getMetalAmount((int)(pos.x/16),(int)(pos.z/16)));
    +		return tmp;
    +	}
    +	return "";
     }
     
     void CMouseHandler::EmptyMsgQueUpdate(void)
    Index: Sim/Misc/FeatureDef.h
    ===================================================================
    --- Sim/Misc/FeatureDef.h	(revision 1385)
    +++ Sim/Misc/FeatureDef.h	(working copy)
    @@ -14,6 +14,7 @@
     	FeatureDef():geoThermal(0),floating(false){};
     
     	std::string myName;
    +	std::string description;
     
     	float metal;
     	float energy;
    Index: Sim/Misc/FeatureHandler.cpp
    ===================================================================
    --- Sim/Misc/FeatureHandler.cpp	(revision 1385)
    +++ Sim/Misc/FeatureHandler.cpp	(working copy)
    @@ -234,6 +234,7 @@
     			fd->xsize=2;
     			fd->ysize=2;
     			fd->myName=name;
    +			fd->description="Tree";
     			fd->mass=20;
     			featureDefs[name]=fd;
     		} else if(name.find("GeoVent")!=string::npos){
     			if((*fi)->pos.y>ground->GetHeight((*fi)->pos.x,(*fi)->pos.z)){
     //				info->AddLine("Updating feature pos %f %f %i",(*fi)->pos.y,ground->GetHeight((*fi)->pos.x,(*fi)->pos.z),(*fi)->id);
     				SetFeatureUpdateable(*fi);
    -			
    +
     				if((*fi)->def->floating){
     					(*fi)->finalHeight=ground->GetHeight((*fi)->pos.x,(*fi)->pos.z);
     				} else {
    @@ -482,6 +483,7 @@
     		fd->xsize=atoi(wreckParser.SGetValueDef("1",name+"\\FootprintX").c_str())*2;		//our res is double TAs
     		fd->ysize=atoi(wreckParser.SGetValueDef("1",name+"\\FootprintZ").c_str())*2;
     		fd->mass=fd->metal*0.4+fd->maxHealth*0.1;
    +		fd->description=wreckParser.SGetValueDef("",name+"\\description");
     
     		fd->myName=name;
     		featureDefs[name]=fd;
    
    patch file icon featureTooltip.patch (5,042 bytes) 2006-06-02 19:24 +
  • patch file icon featureTooltipFixed.patch (4,511 bytes) 2006-06-02 23:06 -
    Index: Game/UI/MouseHandler.cpp
    ===================================================================
    --- Game/UI/MouseHandler.cpp	(revision 1385)
    +++ Game/UI/MouseHandler.cpp	(working copy)
    @@ -12,6 +12,7 @@
     #include "Game/GameHelper.h"
     #include "Game/SelectedUnits.h"
     #include "Sim/Units/Unit.h"
    +#include "Sim/Misc/Feature.h"
     #include "Game/Team.h"
     #include "InfoConsole.h"
     #include "MiniMap.h"
    @@ -23,6 +24,7 @@
     #include "MouseInput.h"
     #include "Sound.h"
     #include "Sim/Units/UnitDef.h"
    +#include "Sim/Misc/FeatureDef.h"
     #include "ExternalAI/Group.h"
     #include "Platform/ConfigHandler.h"
     #include "Rendering/InMapDraw.h"
    @@ -528,9 +530,27 @@
     	if(s!="")
     		return s;
     
    +	/*
    +	NOTE:
    +	The code below (up untill "if(unit)...") is exactly the same as
    +	some lines in CGuiHandler::GetDefaultCommand().
    +	Perhaps it would be possible to integrate the two, because now a
    +	racetray for units and features might be performed twice per frame.
    +	*/
     	CUnit* unit=0;
    -	float dist=helper->GuiTraceRay(camera->pos,dir,gu->viewRange*1.4,unit,20,false);
    +	CFeature* feature=0;
    +	float dist=helper->GuiTraceRay(camera->pos,dir,gu->viewRange*1.4,unit,20,true);
    +	float dist2=helper->GuiTraceRayFeature(camera->pos,dir,gu->viewRange*1.4,feature);
     
    +	if(dist>gu->viewRange*1.4-100 && dist2>gu->viewRange*1.4-100 && unit==0){
    +		return "";
    +	}
    +
    +	if(dist>dist2)
    +		unit=0;
    +	else
    +		feature=0;
    +
     	if(unit){
     		// show the player name instead of unit name if it has FBI tag showPlayerName
     		if(unit->unitDef->showPlayerName)
    @@ -548,18 +568,31 @@
     			s+=tmp;
     		}
     		return s;
    -	} else {
    -		if(dist<gu->viewRange*1.4-100){
    -			float3 pos=camera->pos+dir*dist;
    -			char tmp[500];
    -			CReadMap::TerrainType* tt=&readmap->terrainTypes[readmap->typemap[min(gs->hmapx*gs->hmapy-1,max(0,((int)pos.z/16)*gs->hmapx+((int)pos.x/16)))]];
    -			string ttype=tt->name;
    -			sprintf(tmp,"Pos %.0f %.0f Elevation %.0f\nTerrain type: %s\nSpeeds T/K/H/S %.2f %.2f %.2f %.2f\nHardness %.0f Metal %.1f",pos.x,pos.z,pos.y,ttype.c_str(),tt->tankSpeed,tt->kbotSpeed,tt->hoverSpeed,tt->shipSpeed,tt->hardness*mapDamage->mapHardness,readmap->metalMap->getMetalAmount((int)(pos.x/16),(int)(pos.z/16)));
    -			return tmp;
    +	}
    +	if(feature){
    +		if(feature->def->description==""){
    +			s="Feature";
     		} else {
    -			return "";
    +			s=feature->def->description;
     		}
    +		std::string metalColor = feature->def->metal > 0 ? "\xff\x50\xff\x50" : "\xff\xff\x50\x01";
    +		std::string energyColor = feature->def->energy > 0 ? "\xff\x50\xff\x50" : "\xff\xff\x50\x01";
    +		char tmp[500];
    +		sprintf(tmp,"\n\xff\xd3\xdb\xffMetal: %s%.0f \xff\xd3\xdb\xff Energy: %s%.0f",
    +			metalColor.c_str(), feature->def->metal, energyColor.c_str(), feature->def->energy);
    +		s+=tmp;
    +
    +		return s;
     	}
    +	if(dist<gu->viewRange*1.4-100){
    +		float3 pos=camera->pos+dir*dist;
    +		char tmp[500];
    +		CReadMap::TerrainType* tt=&readmap->terrainTypes[readmap->typemap[min(gs->hmapx*gs->hmapy-1,max(0,((int)pos.z/16)*gs->hmapx+((int)pos.x/16)))]];
    +		string ttype=tt->name;
    +		sprintf(tmp,"Pos %.0f %.0f Elevation %.0f\nTerrain type: %s\nSpeeds T/K/H/S %.2f %.2f %.2f %.2f\nHardness %.0f Metal %.1f",pos.x,pos.z,pos.y,ttype.c_str(),tt->tankSpeed,tt->kbotSpeed,tt->hoverSpeed,tt->shipSpeed,tt->hardness*mapDamage->mapHardness,readmap->metalMap->getMetalAmount((int)(pos.x/16),(int)(pos.z/16)));
    +		return tmp;
    +	}
    +	return "";
     }
     
     void CMouseHandler::EmptyMsgQueUpdate(void)
    Index: Sim/Misc/FeatureDef.h
    ===================================================================
    --- Sim/Misc/FeatureDef.h	(revision 1385)
    +++ Sim/Misc/FeatureDef.h	(working copy)
    @@ -14,6 +14,7 @@
     	FeatureDef():geoThermal(0),floating(false){};
     
     	std::string myName;
    +	std::string description;
     
     	float metal;
     	float energy;
    Index: Sim/Misc/FeatureHandler.cpp
    ===================================================================
    --- Sim/Misc/FeatureHandler.cpp	(revision 1385)
    +++ Sim/Misc/FeatureHandler.cpp	(working copy)
    @@ -234,6 +234,7 @@
     			fd->xsize=2;
     			fd->ysize=2;
     			fd->myName=name;
    +			fd->description="Tree";
     			fd->mass=20;
     			featureDefs[name]=fd;
     		} else if(name.find("GeoVent")!=string::npos){
    @@ -482,6 +483,7 @@
     		fd->xsize=atoi(wreckParser.SGetValueDef("1",name+"\\FootprintX").c_str())*2;		//our res is double TAs
     		fd->ysize=atoi(wreckParser.SGetValueDef("1",name+"\\FootprintZ").c_str())*2;
     		fd->mass=fd->metal*0.4+fd->maxHealth*0.1;
    +		fd->description=wreckParser.SGetValueDef("",name+"\\description");
     
     		fd->myName=name;
     		featureDefs[name]=fd;
    patch file icon featureTooltipFixed.patch (4,511 bytes) 2006-06-02 23:06 +

-Relationships
+Relationships

-Notes

~0000206

colorblind (reporter)

Last edited: 2006-06-02 21:24

:edit: oops nevermind.
I'll have a patch out for this soon.
:edit2: I've uploaded the patch.

~0000207

tvo (reporter)

patch is borked, waiting for a fixed one

~0000208

tvo (reporter)

committed
+Notes

-Issue History
Date Modified Username Field Change
2006-05-30 15:35 NOiZE New Issue
2006-06-02 12:37 colorblind Note Added: 0000206
2006-06-02 14:50 colorblind Note Edited: 0000206
2006-06-02 16:41 colorblind Note Edited: 0000206
2006-06-02 19:24 colorblind File Added: featureTooltip.patch
2006-06-02 21:24 colorblind Note Edited: 0000206
2006-06-02 22:07 tvo Status new => assigned
2006-06-02 22:07 tvo Assigned To => tvo
2006-06-02 22:08 tvo Note Added: 0000207
2006-06-02 23:06 colorblind File Added: featureTooltipFixed.patch
2006-06-03 13:38 tvo Status assigned => resolved
2006-06-03 13:38 tvo Resolution open => fixed
2006-06-03 13:38 tvo Note Added: 0000208
+Issue History