//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void ClientModeTFBase::Enable( void ) { // Hook the minimap traces into the minimap if ( GetMinimap() ) { GetMinimap()->Activate(); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void ClientModeTFBase::LevelShutdown( void ) { BaseClass::LevelShutdown(); if ( GetMinimap() ) { GetMinimap()->LevelShutdown(); } }
void ClientModeTFBase::LevelInit( const char *newmap ) { BaseClass::LevelInit( newmap ); // Tell the radar to load the radar's overlay map //g_Radar.LoadMap( newmap ); if ( GetMinimap() ) { GetMinimap()->LevelInit( newmap ); } }
JNIEXPORT jcharArray JNICALL Java_aflobby_CUnitSyncJNIBindings_GetMiniMapArray (JNIEnv *env, jclass myobject, jstring mapName){ jcharArray a = env->NewCharArray(1024*1024*2); const char* c = env->GetStringUTFChars(mapName,0); env->SetCharArrayRegion(a,0,1024*1024*2,(jchar*)GetMinimap(c,0)); env->ReleaseStringUTFChars(mapName,c); return a; }
/* * Class: aflobby_CUnitSyncJNIBindings * Method: WriteMiniMap * Signature: (II)I */ JNIEXPORT jboolean JNICALL Java_aflobby_CUnitSyncJNIBindings_WriteMiniMap (JNIEnv *env, jclass myobject, jstring mapfile, jstring imagename, jint miplevel){ const char *filename = env->GetStringUTFChars(mapfile, 0); const char *bitmap_filename = env->GetStringUTFChars(imagename, 0); void* minimap = GetMinimap(filename, miplevel); if (!minimap){ env->ReleaseStringUTFChars(mapfile, filename); env->ReleaseStringUTFChars(mapfile, bitmap_filename); return false; } int size = 1024 >> miplevel; CBitmap bm; bm.Alloc(size, size); unsigned short *src = (unsigned short*)minimap; unsigned char *dst = bm.mem; for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++){ dst[0] = RED_RGB565 ((*src)) << 3; dst[1] = GREEN_RGB565 ((*src)) << 2; dst[2] = BLUE_RGB565 ((*src)) << 3; dst[3] = 255; ++src; dst += 4; } } remove(bitmap_filename); //somehow overwriting doesn't work?? bm.Save(bitmap_filename); // check whether the bm.Save succeeded? FILE* f = fopen(bitmap_filename, "rb"); bool success = !!f; if (success) { fclose(f); } env->ReleaseStringUTFChars(mapfile, filename); env->ReleaseStringUTFChars(mapfile, bitmap_filename); return success; }
wxImage SpringUnitSync::GetMinimap( const wxString& mapname, int width, int height ) { wxLogDebugFunc( mapname + _T(" size: ") + TowxString( width ) + _T("x") + TowxString( height ) ); const bool tiny = ( width <= 100 && height <= 100 ); wxImage img; if ( tiny && m_tiny_minimap_cache.TryGet( mapname, img ) ) { wxSize image_size = MakeFit(wxSize(img.GetWidth(), img.GetHeight()), wxSize(width, height)); if ( image_size.GetWidth() != img.GetWidth() || image_size.GetHeight() != img.GetHeight() ) img.Rescale( image_size.GetWidth(), image_size.GetHeight() ); return img; } img = GetMinimap( mapname ); // special resizing code because minimap is always square, // and we need to resize it to the correct aspect ratio. if (img.GetWidth() > 1 && img.GetHeight() > 1) { try { MapInfo mapinfo = _GetMapInfoEx( mapname ); wxSize image_size = MakeFit(wxSize(mapinfo.width, mapinfo.height), wxSize(width, height)); img.Rescale( image_size.GetWidth(), image_size.GetHeight() ); } catch (...) { img = wxImage( 1, 1 ); } } if ( tiny ) m_tiny_minimap_cache.Add( mapname, img ); return img; }