00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "../global.h"
00023
00024 #include "../typen.h"
00025 #include "../mapfield.h"
00026 #include "../gamemap.h"
00027 #include "terraininfo.h"
00028
00029 #include "../widgets/textrenderer.h"
00030
00031
00032
00033
00034 void viewterraininfo ( GameMap* gamemap, const MapCoordinate& pos, bool fullVisibility )
00035 {
00036 MapField* fld = gamemap->getField( pos );
00037
00038 if ( !fld )
00039 return;
00040
00041 ASCString text;
00042
00043 text += "#fontsize=18#Field Information (";
00044 text += ASCString::toString(pos.x) + "/" + ASCString::toString(pos.y) + ")\n";
00045
00046
00047 text += "#fontsize=14#Terrain#aeinzug20##eeinzug20##fontsize=12##aeinzug30#\n";
00048
00049
00050 text += "ID: " + ASCString::toString( fld->typ->terraintype->id ) + "\n";
00051
00052 text += "Weather: " + ASCString(cwettertypen[fld->getWeather() ]) + "\n";
00053
00054
00055 ASCString sub;
00056 float ab = fld->getattackbonus();
00057 float db = fld->getdefensebonus();
00058 sub.format( "Attack Bonus: %.1f\nDefense Bonus: %.1f\n", ab/8, db/8 );
00059
00060 text += sub;
00061
00062 text += "Base Jamming: " + ASCString::toString( fld->getjamming() ) + "\n";
00063 text += "terrain filename: " + fld->typ->terraintype->location + "\n";
00064
00065
00066 fld->bdt.appendToString( text );
00067
00068 text += "\n\n#eeinzug0##fontsize=14#Visibility#eeinzug20##fontsize=12#\n";
00069
00070 int view = 0;
00071 int jamming = 0;
00072 for ( int i = 0; i < gamemap->getPlayerCount(); ++i )
00073 if ( gamemap->getPlayer(i).diplomacy.sharesView( gamemap->getPlayerView() )) {
00074 view += fld->view[i].view;
00075 jamming += fld->view[i].jamming;
00076 }
00077
00078 text += "View: " + ASCString::toString( view ) + "\n";
00079 text += "Jamming: " + ASCString::toString( jamming ) + "\n";
00080 text += "Terrain view obstruction (basejamming): " + ASCString::toString( fld->getjamming() ) + "\n";
00081
00082
00083 text += "\n#eeinzug0##fontsize=14#Movemali#eeinzug20##fontsize=12#\n";
00084
00085
00086 for ( int i = 0; i < cmovemalitypenum; i++ ) {
00087 if ( fld->vehicle && fld->vehicle->typ->movemalustyp == i )
00088 text += "#fontcolor=0xffd658#";
00089 text += cmovemalitypes[i] + ASCString(": ") + ASCString::toString( fld->getmovemalus(i) );
00090
00091 if ( fld->vehicle && fld->vehicle->typ->movemalustyp == i )
00092 text += "#fontcolor=default#";
00093
00094 text += "\n";
00095 }
00096
00097 int mines[4] = { 0, 0, 0, 0 };
00098 int mineDissolve[4] = { maxint, maxint, maxint, maxint };
00099
00100 for ( MapField::MineContainer::iterator m = fld->mines.begin(); m != fld->mines.end(); ++m )
00101 if ( m->player == gamemap->actplayer || fullVisibility ) {
00102 mines[m->type-1]++;
00103 int lifetime = gamemap->getgameparameter( GameParameter(cgp_antipersonnelmine_lifetime + m->type-1 ));
00104 if ( lifetime > 0)
00105 mineDissolve[m->type-1] = min( m->lifetimer, mineDissolve[m->type-1]);
00106 }
00107
00108 if ( mines[0] || mines[1] || mines[2] || mines[3] ) {
00109 text += "#eeinzug0##fontsize=14#Mine Information#fontsize=12##eeinzug20##aeinzug30#\n";
00110 text += "On this field are #aeinzug50# \n" ;
00111
00112 for ( int i = 0; i < 4; i++ ) {
00113 text += " " + ASCString::toString( mines[i] ) + " " + MineNames[i];
00114 if ( mines[i] > 1 )
00115 text += "s";
00116
00117 if ( mineDissolve[i] >= 0 && mineDissolve[i] < maxint )
00118 text += ", next mine will dissolve in " + ASCString::toString ( mineDissolve[i]) + " turns.";
00119
00120 text += "\n";
00121 }
00122 }
00123
00124 if ( fld->vehicle ) {
00125 text += "#aeinzug0##eeinzug0#\n#fontsize=14#Vehicle Information:#fontsize=12##aeinzug30##eeinzug20#\n" ;
00126
00127 const VehicleType* typ = fld->vehicle->typ;
00128
00129 text += "Unit name: ";
00130 if ( !typ->name.empty() )
00131 text += typ->name.c_str() ;
00132 else
00133 text += typ->description;
00134 text += "\n";
00135
00136 text += "Unit ID: " + ASCString::toString( typ->id ) + "\n";
00137 text += "Internal Unit Identification: " + ASCString::toString( fld->vehicle->networkid ) + "\n";
00138
00139 if ( !typ->filename.empty() )
00140 text += "File Name: " + typ->location + "\n";
00141
00142
00143 text += "Terrain access:\n" + typ->terrainaccess.toString() + "\n";
00144 }
00145
00146 if ( !fld->objects.empty() )
00147 text += "#aeinzug0##eeinzug0#\n#fontsize=14#Object Information:#fontsize=12##aeinzug30##eeinzug20#\n" ;
00148
00149 for ( MapField::ObjectContainer::iterator i = fld->objects.begin(); i != fld->objects.end(); i++ )
00150 text += i->typ->location + "\n";
00151
00152
00153 if ( fld->building ) {
00154 text += "#aeinzug0##eeinzug0#\n#fontsize=14#Building Information:#fontsize=12##aeinzug30##eeinzug20#\n";
00155 text += fld->building->typ->location + "\n";
00156 text += "Owner: " + gamemap->player[fld->building->getOwner()].getName() + "\n";
00157 }
00158
00159
00160 if ( !fld->objects.empty() ) {
00161 text += "#aeinzug0##eeinzug0#\n#fontsize=14#Object Details:#aeinzug30##eeinzug20#";
00162 for ( MapField::ObjectContainer::iterator i = fld->objects.begin(); i != fld->objects.end(); i++ ) {
00163 const TerrainAccess* ta = &i->typ->getFieldModification( fld->getWeather() ).terrainaccess;
00164 text += "#aeinzug30##eeinzug20##fontsize=12#\n";
00165 text += i->typ->name + "#aeinzug50##eeinzug40##fontsize=10#\n";
00166 text += "Type ID: " + ASCString::toString(i->typ->id) + "\n";
00167 text += "Location: " + i->typ->location + "\n";
00168
00169 text += "Terrain access:\n" + ta->toString() + "\n";
00170
00171 text += "\nremaining lifetime:";
00172 text += ASCString::toString( i->lifetimer ) + "\n";
00173
00174 text += "\nremaining child spawn counter:";
00175 text += ASCString::toString( i->remainingGrowthTime ) + "\n";
00176
00177 }
00178 }
00179
00180 ViewFormattedText vft( "Field Information", text, PG_Rect( -1, -1, 420, 600 ));
00181 vft.Show();
00182 vft.RunModal();
00183 }
00184
00185
00186