Esempio n. 1
0
void HtmlLog::logFiltered(const std::string &cat, LogLevel level, const std::string &msg,
                          const std::string &extendedInfo)
{
    if (!file_)
        return;

    std::string output = "\t\t\t<tr bgcolor=\"" + getLevelColor(level) + "\">\n";
    if (dateStamping_)
        output += "\t\t\t\t<td>" + getDateString() + "</td>\n";
    if (timeStamping_)
        output += "\t\t\t\t<td>" + getTimeString() + "</td>\n";
    if (showCat_)
        output += "\t\t\t\t<td>" + cat + "</td>\n";
    if (showLevel_)
        output += "\t\t\t\t" + getLevelString(level) + "\n";
    fputs((output +  "\t\t\t\t<td title=\"" + extendedInfo + "\">" + msg + "</td>\n\t\t\t</tr>\n").c_str(), file_);
    fflush(file_);
}
Esempio n. 2
0
void formatMessage(char *writeBuffer,int adId,int id,int systemId,int channelId,char *msg)
/*--------------------------------------------
 * formatta il messaggio per la scrittura su file
 * char *writeBuffer	buffer
 * int adId  0=analogico, 1=digitale, 2=digital_out
 * int id	id da tabella db
 * int systemId	
 * int channelId
 * char *msg	messaggio
 * -----------------------------------------*/
{

	char temp[10];
	char tempString[MSGLENGTH];
	
	getTimeString("%H:%M:%S",temp);
	sprintf(writeBuffer,"%s\t%d\t%d\t%d\t%d\t%s\n",temp,id,adId,systemId,channelId,msg);
}
Esempio n. 3
0
void CallbackLog::log(LogManager::LogLevel level, const std::string& category,
                      const std::string& message) {
    std::string output;
    if (isDateStamping())
        output += "[" + getDateString();
    if (isTimeStamping())
        output += " | " + getTimeString();

    if (isDateStamping() || isTimeStamping())
        output += "] ";
    if (isCategoryStamping() && !category.empty())
        output += category + " ";
    if (isLogLevelStamping())
        output += "(" + LogManager::stringFromLevel(level) + ")";
    if (output != "")
        output += "\t";
    output += message;
    _callbackFunction(output);
}
Esempio n. 4
0
void TextLog::logFiltered(const std::string& cat, LogLevel level, const std::string& msg,
                          const std::string& /*extendedInfo*/)
{
    if (!file_)
        return;

    std::string output = "";
    if (dateStamping_)
        output += "[" + getDateString() + "] ";
    if (timeStamping_)
        output += "[" + getTimeString() + "] ";
    if (showCat_)
        output += cat + " ";
    if (showLevel_)
        output += "(" + getLevelString(level) + ") ";
    if (output != "")
        output += '\t';
    fputs((output +  msg + "\n").c_str(), file_);
    fflush(file_);
}
Esempio n. 5
0
std::string Log::getLinePrefix()
{
    // collect line number, time/date stamp
    std::stringstream linePrefix;
    gettimeofday(&curTime, NULL);
    sec = (curTime.tv_sec - timeStart.tv_sec);
    mSec = (curTime.tv_usec - timeStart.tv_usec)/1.0e05;
    
    linePrefix.str("");
    linePrefix.fill('0');
    linePrefix.width(8);
    linePrefix << logLineNumber++ <<" ["<<getTimeString()<<" ";
    linePrefix.fill('0');
    linePrefix.precision(8);
    //linePrefix << sec <<"."<< mSec <<"] ";
    // milliseconds since start of program
    linePrefix << sec+mSec <<"] ";
    return linePrefix.str();
    
}
Esempio n. 6
0
//Draws Black screen to LCD
void drawSleep(void){		
	char timeString[6];
	memset(timeString,0,sizeof(timeString));
		
	char time[6];
	memset(time,0,sizeof(time));	
	
	getTimeString(time);
	
	snprintf(timeString, sizeof(timeString), "%s%s", time, " ");
	timeString[5] = ' ';
	printStringOnLine(0,"                  ",1,NONE);
	printStringOnLine(1,"                  ",1,NONE);
	printStringOnLine(2,"                  ",1,NONE);
	printStringOnLine(3,"                  ",1,NONE);
	printStringOnLine(4,"                  ",1,NONE);
	printStringOnLine(5,"                  ",1,NONE);
	printStringOnLine(6,"                  ",1,NONE);
	printStringOnLine(7,"                  ",1,NONE);
	printBigTime(2,timeString, 1);		
}
Esempio n. 7
0
inline void page_modifyTime() {
  static int timeScaleIndex = 0;
  if (pre_page != MODIFY_TIME)
  {
    PTLS("Page Mod Time");
    pre_page = MODIFY_TIME;
    lcd.cursor();
  }
  lcd.setCursor(0,1);
  String str_time = getTimeString(); 
  lcd.print(str_time);

  if (timeScaleIndex == 0) lcd.setCursor(0,1);
  else if (timeScaleIndex == 1) lcd.setCursor(0,4);
  else if (timeScaleIndex == 2) lcd.setCursor(0,7);
    
  if (button_input == PLUS_UP || button_input == PLUS_HOLD)
  {
    long adjust = timeScale[timeScaleIndex];
    adjustTime(adjust);
    setSyncInterval(SCALE_HOUR);
  }
  else if (button_input == MINUS_UP || button_input == MINUS_HOLD)
  {
    long adjust = -timeScale[timeScaleIndex];
    adjustTime(adjust);
    setSyncInterval(SCALE_HOUR);
  }
  else if (button_input == SET_UP)
  {
    setSyncInterval( 3600 );
    switchPage(HOME);
  }
  else if (button_input == MODE_UP)
  {
    timeScaleIndex++;
    timeScaleIndex = timeScaleIndex % 3;
    PTS("Changed focus: "); PTL(timeScaleIndex);
  }
}
Esempio n. 8
0
void SGVisitItem1::refreshTimer()
{
    limit_time -= 1;
    if (limit_time <= 3600*2  || !isStartActivity) {
        if (lableDes.compare(str_TongQueLayer_str23) == 0) {
            lableDes = str_TongQueLayer_str24;
        }
        CCString *timeStr = CCString::createWithFormat("%s%s", getTimeString(limit_time),lableDes.c_str());
        labelTime->setString(timeStr->getCString());

    }
    if (limit_time <= 1) {
        // 刷新数据,将过期的数据隐藏掉
        this->unschedule(schedule_selector(SGVisitItem1::refreshTimer));
        if (isStartActivity) {
            labelTime->setString(str_TongQueLayer_str25);
        }
        else{
            labelTime->setString(str_TongQueLayer_str26);
        }
    }
}
Esempio n. 9
0
void ConsoleLog::logFiltered(const std::string& cat, LogLevel level, const std::string& msg,
                             const std::string& /*extendedInfo*/)
{
    std::string output;
    if (colorOutput_)
        output = getLevelColor(level);

    if (dateStamping_)
        output += "[" + getDateString() + "] ";
    if (timeStamping_)
        output += "[" + getTimeString() + "] ";
    if (showCat_)
        output += cat + " ";
    if (showLevel_)
        output += "(" + getLevelString(level) + ") ";
    if (output != "")
        output += '\t';

    output += msg;
    if (colorOutput_)
        output += "\033[00m"; // return to default color (Reset all attributes)

    std::cout << output << std::endl;
}
Esempio n. 10
0
void MeasureThreadCounter::outputCounting(int seconds)
{
	typedef map<ppi_time, map<string, vector<InformObject> > > order_type;
	bool bCount(false);
	int nCount;
	string folderName;
	SHAREDPTR::shared_ptr<meash_t> pCurrent;
	map<ppi_time, vector<InformObject> > starting;
	order_type timeOrder;
	ostringstream oCountOut;

	pCurrent= meash_t::firstInstance;
	tout << "inside time of " << getTimeString(seconds) << endl;
	while(pCurrent)
	{
		nCount= pCurrent->pMeasure->getRunningCount(starting);
		if(nCount > 0)
		{
			folderName= pCurrent->pMeasure->getFolderName();
			bCount= true;
			oCountOut << "folder " << folderName <<
							" running in " << nCount << " times" << endl;
			for(map<ppi_time, vector<InformObject> >::iterator it= starting.begin();
													it != starting.end(); ++it)
			{
				timeOrder[it->first][folderName].insert(
								timeOrder[it->first][folderName].end(),
								it->second.begin(), it->second.end()	);
			}
		}
		pCurrent= pCurrent->next;
	}
	if(bCount)
	{
		if(m_bShowOrder)
		{
			tout << endl;
			tout << "starting order of folders:" << endl;
			for(order_type::iterator it= timeOrder.begin();
							it != timeOrder.end(); ++it		)
			{
				tout << "     at " << it->first.toString(/*as date*/true);
				for(map<string, vector<InformObject> >::iterator f= it->second.begin();
													f != it->second.end(); ++f	)
				{
					string space("                 	          ");

					if(f != it->second.begin())
						tout << space;
					tout << " folder " << f->first << endl;
					tout << space << "      informed from ";
					space.append(/*informed from*/20, ' ');
					for(vector<InformObject>::iterator i= f->second.begin();
									i != f->second.end(); ++i			)
					{
						if(i != f->second.begin())
							tout << space;
						tout << i->toString() << endl;
					}
				}
			}//foreach(timeOrder)
			tout << endl;
		}//if(m_bShowOrder)
		tout << oCountOut.str() << endl;
		tout << endl;
	}else
		tout << "no folder running in given time" << endl;
	TERMINALEND;
}
Esempio n. 11
0
int
sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
	   int isStdin, const char *songLenStr, struct timeval *tv)
{
	unsigned char	 buff[4096];
	size_t		 bytes_read, total, oldTotal;
	int		 ret;
	double		 kbps = -1.0;
	struct timeval	 timeStamp, *startTime = tv;
	struct timeval	 callTime, currentTime;

	if (startTime == NULL) {
		printf("%s: sendStream(): Internal error: startTime is NULL\n",
		       __progname);
		abort();
	}

	ez_gettimeofday((void *)&callTime);

	timeStamp.tv_sec = startTime->tv_sec;
	timeStamp.tv_usec = startTime->tv_usec;

	total = oldTotal = 0;
	ret = STREAM_DONE;
	while ((bytes_read = fread(buff, 1UL, sizeof(buff), filepstream)) > 0) {
		if (shout_get_connected(shout) != SHOUTERR_CONNECTED &&
		    reconnectServer(shout, 0) == 0) {
			ret = STREAM_SERVERR;
			break;
		}

		shout_sync(shout);

		if (shout_send(shout, buff, bytes_read) != SHOUTERR_SUCCESS) {
			printf("%s: shout_send(): %s\n", __progname,
			       shout_get_error(shout));
			if (reconnectServer(shout, 1))
				break;
			else {
				ret = STREAM_SERVERR;
				break;
			}
		}

		if (quit)
			break;
		if (rereadPlaylist_notify) {
			rereadPlaylist_notify = 0;
			if (!pezConfig->fileNameIsProgram)
				printf("%s: SIGHUP signal received, will reread playlist after this file\n",
				       __progname);
		}
		if (skipTrack) {
			skipTrack = 0;
			ret = STREAM_SKIP;
			break;
		}

		ez_gettimeofday((void *)&currentTime);

		if (queryMetadata ||
		    (pezConfig->metadataRefreshInterval != -1
		     && (currentTime.tv_sec - callTime.tv_sec
			 >= pezConfig->metadataRefreshInterval)
		    )
		   ) {
			queryMetadata = 0;
			if (metadataFromProgram) {
				ret = STREAM_UPDMDATA;
				break;
			}
		}

		total += bytes_read;
		if (qFlag && vFlag) {
			double	oldTime, newTime;

			if (!isStdin && playlistMode) {
				if (pezConfig->fileNameIsProgram) {
					char *tmp = xstrdup(pezConfig->fileName);
					printf("  [%s]",
					       local_basename(tmp));
					xfree(tmp);
				} else
					printf("  [%4lu/%-4lu]",
					       playlist_get_position(playlist),
					       playlist_get_num_items(playlist));
			}

			oldTime = (double)timeStamp.tv_sec
				+ (double)timeStamp.tv_usec / 1000000.0;
			newTime = (double)currentTime.tv_sec
				+ (double)currentTime.tv_usec / 1000000.0;
			if (songLenStr == NULL)
				printf("  [ %s]",
				       getTimeString(currentTime.tv_sec -
						     startTime->tv_sec));
			else
				printf("  [ %s/%s]",
				       getTimeString(currentTime.tv_sec -
						     startTime->tv_sec),
				       songLenStr);
			if (newTime - oldTime >= 1.0) {
				kbps = (((double)(total - oldTotal)
					 / (newTime - oldTime)) * 8.0) / 1000.0;
				timeStamp.tv_sec = currentTime.tv_sec;
				timeStamp.tv_usec = currentTime.tv_usec;
				oldTotal = total;
			}
			if (kbps < 0)
				printf("                 ");
			else
				printf("  [%8.2f kbps]", kbps);

			printf("  \r");
			fflush(stdout);
		}
	}
	if (ferror(filepstream)) {
		if (errno == EINTR) {
			clearerr(filepstream);
			ret = STREAM_CONT;
		} else if (errno == EBADF && isStdin)
			printf("%s: No (more) data available on standard input\n",
			       __progname);
		else
			printf("%s: sendStream(): Error while reading '%s': %s\n",
			       __progname, fileName, strerror(errno));
	}

	return (ret);
}
Esempio n. 12
0
File: zMisc.cpp Progetto: ifzz/loki
char *getTimeString(time_t t,char *buffer,const int bufferlen)
{
  return getTimeString(t,buffer,bufferlen,"%C/%m/%d %T");
}
Esempio n. 13
0
void Output::printDebug(std::string message, int32_t minDebugLevel)
{
	if(_bl && _bl->debugLevel < minDebugLevel) return;
	std::cout << getTimeString() << " " << _prefix << message << std::endl;
}
Esempio n. 14
0
BOOL WINAPI DllMain(HMODULE hDll, DWORD dwReason, PVOID pvReserved) {	
	if(dwReason == DLL_PROCESS_ATTACH) {
		OutputDebugString("GeDoSaTo: startup");

		// read install location from registry
		getInstallDirectory();
		OutputDebugString("GeDoSaTo: Got install dir");

		// don't attach to processes on the blacklist / not on the whitelist
		if(getUseBlacklist() ? onList(getExeFileName(), "blacklist.txt") : !onList(getExeFileName(), "whitelist.txt")) {
			OutputDebugString("GeDoSaTo: blacklisted / not whitelisted");
			if(getExeFileName() == "GeDoSaToTool") return true;
			return true;
		}
		g_active = true;
		OutputDebugString("GeDoSaTo: Active");
		
		// initialize log
		string logFn = format("logs\\%s_%s.log", getExeFileName().c_str(), getTimeString().c_str());
		std::replace(logFn.begin(), logFn.end(), ':', '-');
		std::replace(logFn.begin(), logFn.end(), ' ', '_');
		logFn = getInstalledFileName(logFn);
		fopen_s(&g_oFile, logFn.c_str(), "w");
		if(!g_oFile) OutputDebugString(format("GeDoSaTo: Error opening log fn %s", logFn.c_str()).c_str());
		else OutputDebugString(format("GeDoSaTo: Opening log fn %s, handle: %p", logFn.c_str(), g_oFile).c_str());
		OutputDebugString("GeDoSaTo: Log file initialized, let that take over");

		// startup
		sdlogtime(-1);
		SDLOG(-1, "===== start "INTERCEPTOR_NAME" %s = fn: %s\n", GeDoSaToVersion(), getExeFileName().c_str());
		SDLOG(-1, "===== installation directory: %s\n", getInstallDirectory().c_str());

		// load settings
		Settings::get().load();
		Settings::get().report();
		 
		KeyActions::get().load();
		KeyActions::get().report();

		if(!Settings::get().getPreventSteamOverlay() && Settings::get().getLoadSteamOverlayEarly()) {
			SDLOG(2, "Attempting to pre-load Steam overlay dll.\n");
			LoadLibrary("gameoverlayrenderer.dll");
		}

		if(Settings::get().getLoadD3DEarly()) {
			SDLOG(2, "Early d3d loading.\n");
			auto dllname = getSystemDllName("d3d9.dll");
			LoadLibrary(dllname.c_str());
		}

		// detour
		startDetour();
		return true;
	}
	if(dwReason == DLL_PROCESS_DETACH && g_active) {
		Settings::get().shutdown();
		endDetour();
		SDLOG(-1, "===== end =\n");
		fclose(g_oFile);
	}
    return false;
}
Esempio n. 15
0
//--------------------------------------------------------------
void testApp::keyPressed  (int key)
{
	switch (key)
	{
		// TOGGLE GUI
		case ' ':
			gui.toggleDraw();
			break;
		
		// TOGGLE FULLSCREEN
		case 'f':
			ofToggleFullscreen();
			break;
		
		// TOGGLE DEBUG IMAGES
		case 'i':
			drawImages = !drawImages;
			break;

		// TOGGLE OPTICAL FLOW
		case 'o':
			cameraTracker.CTdoOpticalFlow = !cameraTracker.CTdoOpticalFlow;
			break;
			
		// RESET WARPING BOX
		case 'r':
			for( int i=0; i<4; i++)
			{
				vidWarpBox.dstPoints[i].x = vidWarpBox.srcPoints[i].x;
				vidWarpBox.dstPoints[i].y = vidWarpBox.srcPoints[i].y;
			}
			break;
		
		// LEARN BACKGROUND
		case 'b':
			cameraTracker.learnBackGround();
			drawImages = false;
			break;
		
		// TOGGLE AUTO CLEAR BACKGROUND
		case 'a':
			autoBg = !autoBg;
			ofSetBackgroundAuto( autoBg );
			break;

		// INCREASE THRESHOLD
		case '+':
			cameraTracker.CTthresh ++;
			if ( cameraTracker.CTthresh > 255)
			{
				cameraTracker.CTthresh = 255;
			}
			break;
		
		// DECREASE THRESHOLD
		case '-':
			cameraTracker.CTthresh --;
			if (cameraTracker.CTthresh < 0)
			{
				cameraTracker.CTthresh = 0;
			}
			break;
		
		// OUTPUT TO FIRST SCREEN FULLSCREEN
		case '1':
			for( int i=0; i < numOutputs; i++ ){				
				output[ i ]->setOutputArea( 0, 0, ofGetScreenWidth(), ofGetScreenHeight() );
			}
			break;

		// OUTPUT TO SECOND SCREEN FULLSCREEN
		case '2':
			for( int i=0; i < numOutputs; i++ ){				
				output[ i ]->setOutputArea( ofGetScreenWidth(), 0, ofGetScreenWidth(), ofGetScreenHeight() );
			}
			break;

		// OUTPUT TO FIRST SCREEN SMALL
		case '3':
			for( int i=0; i < numOutputs; i++ ){				
				output[ i ]->setOutputArea( 20+camX*2, 220, camX*2, camY*2 );
			}
			break;
	
		// LOAD RANDOM PRESET FROM XML
		case 'l':
			loadRandomPreset();
			break;

		
		// SAVE GUI SETTINGS AS PRESET TO XML
		case 's':{

			string newFilename  = "./presets/";
			newFilename        += gui.currentPage().name;
			newFilename        += " - ";
			newFilename        += getTimeString();
			newFilename        += ".xml";

			cout << "\nNEW NAME "  << newFilename;

			gui.currentPage().setXMLName( newFilename );
			gui.currentPage().saveToXML();
			break;
		 }

		// DISPLAY TRACKING SETTINGS
		case 't':
			gui.setPage("TrackingOptions");
			//cameraTracker.showSettings();
			break;

		case ',':
			if( currOutput == 0 ){
				changeOutputRenderer( numOutputs-1 );
			}
			else{
				changeOutputRenderer( (currOutput-1) % numOutputs );
			}
			break;

		case '.':
			changeOutputRenderer( (currOutput+1) % numOutputs );
			break;

		case 'd':
			drawDebugInfo = !drawDebugInfo;
			break;
			

	}
}
Esempio n. 16
0
void Output::printInfo(std::string message)
{
	if(_bl && _bl->debugLevel < 4) return;
	std::cout << getTimeString() << " " << _prefix << message << std::endl;
}
Esempio n. 17
0
void __cdecl sdlogtime(int level) {
	SDLOG(level, "===== %s =====\n", getTimeString().c_str());
}
Esempio n. 18
0
		// Returns formatted eta as string
		inline std::string getTextEta()
		{
			return getTimeString(getEta());
		}
Esempio n. 19
0
int
streamFile(shout_t *shout, const char *fileName)
{
	FILE		*filepstream = NULL;
	int		 popenFlag = 0;
	char		*songLenStr = NULL;
	int		 isStdin = 0;
	int		 ret, retval = 0;
	long		 songLen;
	metadata_t	*mdata;
	struct timeval	 startTime;

	if ((filepstream = openResource(shout, fileName, &popenFlag,
					&mdata, &isStdin, &songLen))
	    == NULL) {
		if (++resource_errors > 100) {
			printf("%s: Too many errors -- giving up.\n", __progname);
			return (0);
		}
		/* Continue with next resource on failure: */
		return (1);
	}
	resource_errors = 0;

	if (mdata != NULL) {
		char	*tmp, *metaData;

		tmp = metadata_assemble_string(mdata);
		if ((metaData = UTF8toCHAR(tmp, ICONV_REPLACE)) == NULL)
			metaData = xstrdup("(unknown title)");
		xfree(tmp);
		printf("%s: Streaming ``%s''", __progname, metaData);
		if (vFlag)
			printf(" (file: %s)\n", fileName);
		else
			printf("\n");
		xfree(metaData);

		/* MP3 streams are special, so set the metadata explicitly: */
		if (strcmp(pezConfig->format, MP3_FORMAT) == 0)
			setMetadata(shout, mdata, NULL);

		metadata_free(&mdata);
	} else if (isStdin)
		printf("%s: Streaming from standard input\n", __progname);

	if (songLen > 0)
		songLenStr = xstrdup(getTimeString(songLen));
	ez_gettimeofday((void *)&startTime);
	do {
		ret = sendStream(shout, filepstream, fileName, isStdin,
				 songLenStr, &startTime);
		if (quit)
			break;
		if (ret != STREAM_DONE) {
			if ((skipTrack && rereadPlaylist) ||
			    (skipTrack && queryMetadata)) {
				skipTrack = 0;
				ret = STREAM_CONT;
			}
			if (queryMetadata && rereadPlaylist) {
				queryMetadata = 0;
				ret = STREAM_CONT;
			}
			if (ret == STREAM_SKIP || skipTrack) {
				skipTrack = 0;
				if (!isStdin && vFlag)
					printf("%s: SIGUSR1 signal received, skipping current track\n",
					       __progname);
				retval = 1;
				ret = STREAM_DONE;
			}
			if (ret == STREAM_UPDMDATA || queryMetadata) {
				queryMetadata = 0;
				if (mFlag)
					continue;
				if (metadataFromProgram) {
					char		*mdataStr = NULL;
					metadata_t	*prog_mdata;

					if (vFlag > 1)
						printf("%s: Querying '%s' for fresh metadata\n",
						       __progname, pezConfig->metadataProgram);
					if ((prog_mdata = getMetadata(pezConfig->metadataProgram)) == NULL) {
						retval = 0;
						ret = STREAM_DONE;
						continue;
					}
					if (setMetadata(shout, prog_mdata, &mdataStr) != SHOUTERR_SUCCESS) {
						retval = 0;
						ret = STREAM_DONE;
						continue;
					}
					metadata_free(&prog_mdata);
					if (vFlag > 1)
						printf("%s: New metadata: ``%s''\n",
						       __progname, mdataStr);
					xfree(mdataStr);
				}
			}
			if (ret == STREAM_SERVERR) {
				retval = 0;
				ret = STREAM_DONE;
			}
		} else
			retval = 1;
	} while (ret != STREAM_DONE);

	if (popenFlag)
		pclose(filepstream);
	else if (!isStdin)
		fclose(filepstream);

	if (songLenStr != NULL)
		xfree(songLenStr);

	return (retval);
}
Esempio n. 20
0
		// Returns a friendly string for the current time remaining
		inline std::string getTextTimeRemaining()
		{
			return getTimeString(getTimeRemaining());
		}
Esempio n. 21
0
/******************************************************************************
 * Render the current scene
 * uses the global variables from the parser
 *****************************************************************************/
int ntlWorld::renderScene( void )
{
#ifndef ELBEEM_PLUGIN
	char nrStr[5];														// nr conversion 
	std::ostringstream outfn_conv("");  			// converted ppm with other suffix 
  ntlRenderGlobals *glob;                  	// storage for global rendering parameters 
  myTime_t timeStart,totalStart,timeEnd; 		// measure user running time 
  myTime_t rendStart,rendEnd;            		// measure user rendering time 
  glob = mpGlob;

	// deactivate for all with index!=0 
	if((glob_mpactive)&&(glob_mpindex>0)) return(0);

	/* check if picture already exists... */
	if(!glob->getSingleFrameMode() ) {
		snprintf(nrStr, 5, "%04d", glob->getAniCount() );

		if(glob_mpactive) {
			outfn_conv  << glob->getOutFilename() <<"_"<<glob_mpindex<<"_" << nrStr << ".png"; /// DEBUG!
		} else {
			// ORG
			outfn_conv  << glob->getOutFilename() <<"_" << nrStr << ".png";
		}
		
		//if((mpGlob->getDisplayMode() == DM_RAY)&&(mpGlob->getFrameSkip())) {
		if(mpGlob->getFrameSkip()) {
			struct stat statBuf;
			if(stat(outfn_conv.str().c_str(),&statBuf) == 0) {
				errorOut("ntlWorld::renderscene Warning: file "<<outfn_conv.str()<<" already exists - skipping frame..."); 
				glob->setAniCount( glob->getAniCount() +1 );
				return(2);
			}
		} // RAY mode
	} else {
		// single frame rendering, overwrite if necessary...
		outfn_conv << glob->getSingleFrameFilename();
	}

  /* start program */
	timeStart = getTime();

	/* build scene geometry, calls buildScene(t,false) */
	glob->getRenderScene()->prepareScene(mSimulationTime);

  /* start program */
	totalStart = getTime();


	/* view parameters are currently not animated */
	/* calculate rays through projection plane */
	ntlVec3Gfx direction = glob->getLookat() - glob->getEye();
	/* calculate width of screen using perpendicular triangle diven by
	 * viewing direction and screen plane */
	gfxReal screenWidth = norm(direction)*tan( (glob->getFovy()*0.5/180.0)*M_PI );

	/* calculate vector orthogonal to up and viewing direction */
	ntlVec3Gfx upVec = glob->getUpVec();
	ntlVec3Gfx rightVec( cross(upVec,direction) );
	normalize(rightVec);

	/* calculate screen plane up vector, perpendicular to viewdir and right vec */
	upVec = ntlVec3Gfx( cross(rightVec,direction) );
	normalize(upVec);

	/* check if vectors are valid */
	if( (equal(upVec,ntlVec3Gfx(0.0))) || (equal(rightVec,ntlVec3Gfx(0.0))) ) {
		errMsg("ntlWorld::renderScene","Invalid viewpoint vectors! up="<<upVec<<" right="<<rightVec);
		return(1);
	}

	/* length from center to border of screen plane */
	rightVec *= (screenWidth*glob->getAspect() * -1.0);
	upVec *= (screenWidth * -1.0);

	/* screen traversal variables */
	ntlVec3Gfx screenPos;                          /* current position on virtual screen */
	int Xres = glob->getResX();                  /* X resolution */
	int Yres = glob->getResY();                  /* Y resolution */
	ntlVec3Gfx rightStep = (rightVec/(Xres/2.0));  /* one step right for a pixel */
	ntlVec3Gfx upStep    = (upVec/(Yres/2.0));     /* one step up for a pixel */
    

	/* anti alias init */
	char  showAAPic = 0;
	int   aaDepth = glob->getAADepth();
	int   aaLength;
	if(aaDepth>=0) aaLength = (2<<aaDepth);
	else           aaLength = 0;
	float aaSensRed   = 0.1;
	float aaSensGreen = 0.1;
	float aaSensBlue  = 0.1;
	int   aaArrayX = aaLength*Xres+1;
	int   aaArrayY = ( aaLength+1 );
	ntlColor *aaCol = new ntlColor[ aaArrayX*aaArrayY ];
	char  *aaUse = new char[ aaArrayX*aaArrayY ];

	/* picture storage */
	int picX = Xres;
	int picY = Yres;
	if(showAAPic) {
		picX = Xres *aaLength+1;
		picY = Yres *aaLength+1;
	}
	ntlColor *finalPic = new ntlColor[picX * picY];


	/* reset picture vars */
	for(int j=0;j<aaArrayY;j++) {
		for(int i=0;i<aaArrayX;i++) {
			aaCol[j*aaArrayX+i] = ntlColor(0.0, 0.0, 0.0);
			aaUse[j*aaArrayX+i] = 0;
		}
	}
	for(int j=0;j<picY;j++) {
		for(int i=0;i<picX;i++) {
			finalPic[j*picX+i] = ntlColor(0.0, 0.0, 0.0);
		}
	}

	/* loop over all y lines in screen, from bottom to top because
	 * ppm format wants 0,0 top left */
	rendStart = getTime();
	glob->setCounterShades(0);
	glob->setCounterSceneInter(0);
	for (int scanline=Yres ; scanline > 0 ; --scanline) {
    
		debugOutInter( "ntlWorld::renderScene: Line "<<scanline<<
								 " ("<< ((Yres-scanline)*100/Yres) <<"%) ", 2, 2000 );
		screenPos = glob->getLookat() + upVec*((2.0*scanline-Yres)/Yres)
			- rightVec;

		/* loop over all pixels in line */
		for (int sx=0 ; sx < Xres ; ++sx) {

			if((sx==glob->getDebugPixelX())&&(scanline==(Yres-glob->getDebugPixelY()) )) {
				// DEBUG!!!
				glob->setDebugOut(10);
			} else glob->setDebugOut(0);
			
			/* compute ray from eye through current pixel into scene... */
			ntlColor col;
			if(aaDepth<0) {
				ntlVec3Gfx dir(screenPos - glob->getEye());
				ntlRay the_ray(glob->getEye(), getNormalized(dir), 0, 1.0, glob );

				/* ...and trace it */
				col = the_ray.shade();
			} else {
				/* anti alias */
				int ai,aj;                   /* position in grid */
				int aOrg = sx*aaLength;      /* grid offset x */
				int currStep = aaLength;     /* step size */
				char colDiff = 1;            /* do colors still differ too much? */
				ntlColor minCol,maxCol;         /* minimum and maximum Color Values */
				minCol = ntlColor(1.0,1.0,1.0);
				maxCol = ntlColor(0.0,0.0,0.0);

				while((colDiff) && (currStep>0)) {
					colDiff = 0;
	    
					for(aj = 0;aj<=aaLength;aj+= currStep) {
						for(ai = 0;ai<=aaLength;ai+= currStep) {

							/* shade pixel if not done */
							if(aaUse[aj*aaArrayX +ai +aOrg] == 0) {
								aaUse[aj*aaArrayX +ai +aOrg] = 1;
								ntlVec3Gfx aaPos( screenPos +
																(rightStep * (ai- aaLength/2)/(gfxReal)aaLength ) +
																(upStep    * (aj- aaLength/2)/(gfxReal)aaLength ) );

								ntlVec3Gfx dir(aaPos - glob->getEye());
								ntlRay the_ray(glob->getEye(), getNormalized(dir), 0, 1.0, glob );

								/* ...and trace it */
								ntlColor newCol= the_ray.shade();
								aaCol[aj*aaArrayX +ai +aOrg]= newCol;
							} /* not used? */

						}
					}

					/* check color differences */
					for(aj = 0;aj<aaLength;aj+= currStep) {
						for(ai = 0;ai<aaLength;ai+= currStep) {

							char thisColDiff = 0;
							if( 
								 (fabs(aaCol[aj*aaArrayX +ai +aOrg][0] - 
											 aaCol[(aj+0)*aaArrayX +(ai+currStep) +aOrg][0])> aaSensRed ) ||
								 (fabs(aaCol[aj*aaArrayX +ai +aOrg][1] - 
											 aaCol[(aj+0)*aaArrayX +(ai+currStep) +aOrg][1])> aaSensGreen ) ||
								 (fabs(aaCol[aj*aaArrayX +ai +aOrg][2] - 
											 aaCol[(aj+0)*aaArrayX +(ai+currStep) +aOrg][2])> aaSensBlue ) ) {
								thisColDiff = 1;
							} else
								if( 
									 (fabs(aaCol[aj*aaArrayX +ai +aOrg][0] - 
												 aaCol[(aj+currStep)*aaArrayX +(ai+0) +aOrg][0])> aaSensRed ) ||
									 (fabs(aaCol[aj*aaArrayX +ai +aOrg][1] - 
												 aaCol[(aj+currStep)*aaArrayX +(ai+0) +aOrg][1])> aaSensGreen ) ||
									 (fabs(aaCol[aj*aaArrayX +ai +aOrg][2] - 
												 aaCol[(aj+currStep)*aaArrayX +(ai+0) +aOrg][2])> aaSensBlue ) ) {
									thisColDiff = 1;
								} else
									if( 
										 (fabs(aaCol[aj*aaArrayX +ai +aOrg][0] - 
													 aaCol[(aj+currStep)*aaArrayX +(ai+currStep) +aOrg][0])> aaSensRed ) ||
										 (fabs(aaCol[aj*aaArrayX +ai +aOrg][1] - 
													 aaCol[(aj+currStep)*aaArrayX +(ai+currStep) +aOrg][1])> aaSensGreen ) ||
										 (fabs(aaCol[aj*aaArrayX +ai +aOrg][2] - 
													 aaCol[(aj+currStep)*aaArrayX +(ai+currStep) +aOrg][2])> aaSensBlue ) ) {
										thisColDiff = 1;
									} 

							//colDiff =1;
							if(thisColDiff) {
								/* set diff flag */
								colDiff = thisColDiff;
								for(int bj=aj;bj<=aj+currStep;bj++) {
									for(int bi=ai;bi<=ai+currStep;bi++) {
										if(aaUse[bj*aaArrayX +bi +aOrg]==2) {
											//if(showAAPic) 
											aaUse[bj*aaArrayX +bi +aOrg] = 0;
										}
									}
								}
							} else {
								/* set all values */
								ntlColor avgCol = (
																	 aaCol[(aj+0       )*aaArrayX +(ai+0       ) +aOrg] +
																	 aaCol[(aj+0       )*aaArrayX +(ai+currStep) +aOrg] +
																	 aaCol[(aj+currStep)*aaArrayX +(ai+0       ) +aOrg] +
																	 aaCol[(aj+currStep)*aaArrayX +(ai+currStep) +aOrg] ) *0.25;
								for(int bj=aj;bj<=aj+currStep;bj++) {
									for(int bi=ai;bi<=ai+currStep;bi++) {
										if(aaUse[bj*aaArrayX +bi +aOrg]==0) {
											aaCol[bj*aaArrayX +bi +aOrg] = avgCol; 
											aaUse[bj*aaArrayX +bi +aOrg] = 2;
										}
									}
								}
							} /* smaller values set */

						}
					}

					/* half step size */
					currStep /= 2;

				} /* repeat until diff not too big */

				/* get average color */
				gfxReal colNum = 0.0;
				col = ntlColor(0.0, 0.0, 0.0);
				for(aj = 0;aj<=aaLength;aj++) {
					for(ai = 0;ai<=aaLength;ai++) {
						col += aaCol[aj*aaArrayX +ai +aOrg];
						colNum += 1.0;
					}
				}
				col /= colNum;

			}

		  /* mark pixels with debugging */
			if( glob->getDebugOut() > 0) col = ntlColor(0,1,0);

			/* store pixel */
			if(!showAAPic) {
				finalPic[(scanline-1)*picX+sx] = col; 
			}
			screenPos +=  rightStep;

		} /* foreach x */

		/* init aa array */
		if(showAAPic) {
			for(int j=0;j<=aaArrayY-1;j++) {
				for(int i=0;i<=aaArrayX-1;i++) {
					if(aaUse[j*aaArrayX +i]==1) finalPic[((scanline-1)*aaLength +j)*picX+i][0] = 1.0;
				}
			}
		}

		for(int i=0;i<aaArrayX;i++) {
			aaCol[(aaArrayY-1)*aaArrayX+i] = aaCol[0*aaArrayX+i];
			aaUse[(aaArrayY-1)*aaArrayX+i] = aaUse[0*aaArrayX+i];
		}
		for(int j=0;j<aaArrayY-1;j++) {
			for(int i=0;i<aaArrayX;i++) {
				aaCol[j*aaArrayX+i] = ntlColor(0.0, 0.0, 0.0);
				aaUse[j*aaArrayX+i] = 0;
			}
		}

	} /* foreach y */
	rendEnd = getTime();


	/* write png file */
	{
		int w = picX;
		int h = picY;

		unsigned rowbytes = w*4;
		unsigned char *screenbuf, **rows;
		screenbuf = (unsigned char*)malloc( h*rowbytes );
		rows = (unsigned char**)malloc( h*sizeof(unsigned char*) );
		unsigned char *filler = screenbuf;

		// cutoff color values 0..1
		for(int j=0;j<h;j++) {
			for(int i=0;i<w;i++) {
				ntlColor col = finalPic[j*w+i];
				for (unsigned int cc=0; cc<3; cc++) {
					if(col[cc] <= 0.0) col[cc] = 0.0;
					if(col[cc] >= 1.0) col[cc] = 1.0;
				}
				*filler = (unsigned char)( col[0]*255.0 ); 
				filler++;
				*filler = (unsigned char)( col[1]*255.0 ); 
				filler++;
				*filler = (unsigned char)( col[2]*255.0 ); 
				filler++;
				*filler = (unsigned char)( 255.0 ); 
				filler++; // alpha channel
			}
		}

		for(int i = 0; i < h; i++) rows[i] = &screenbuf[ (h - i - 1)*rowbytes ];
		writePng(outfn_conv.str().c_str(), rows, w, h);
	}


	// next frame 
	glob->setAniCount( glob->getAniCount() +1 );

	// done 
	timeEnd = getTime();

	char resout[1024];
	snprintf(resout,1024, "NTL Done %s, frame %d/%d (took %s scene, %s raytracing, %s total, %d shades, %d i.s.'s)!\n", 
				 outfn_conv.str().c_str(), (glob->getAniCount()), (glob->getAniFrames()+1),
				 getTimeString(totalStart-timeStart).c_str(), getTimeString(rendEnd-rendStart).c_str(), getTimeString(timeEnd-timeStart).c_str(),
				 glob->getCounterShades(),
				 glob->getCounterSceneInter() );
	debMsgStd("ntlWorld::renderScene",DM_MSG, resout, 1 );

	/* clean stuff up */
	delete [] aaCol;
	delete [] aaUse;
	delete [] finalPic;
	glob->getRenderScene()->cleanupScene();

	if(mpGlob->getSingleFrameMode() ) {
		debMsgStd("ntlWorld::renderScene",DM_NOTIFY, "Single frame mode done...", 1 );
		return 1;
	}
#endif // ELBEEM_PLUGIN
	return 0;
}
Esempio n. 22
0
/******************************************************************************
 * advance simulations by time t 
 *****************************************************************************/
int ntlWorld::advanceSims(int framenum)
{
	bool done = false;
	bool allPanic = true;

	// stop/quit, dont display/render
	if(getElbeemState()==SIMWORLD_STOP) { 
		return 1;
	}

	for(size_t i=0;i<mpSims->size();i++) { (*mpSims)[i]->setFrameNum(framenum); }
	double targetTime = mSimulationTime + (*mpSims)[mFirstSim]->getFrameTime(framenum);

	// time stopped? nothing else to do...
	if( (*mpSims)[mFirstSim]->getFrameTime(framenum) <= 0.0 ){ 
		done=true; allPanic=false; 
	}

	int gstate = 0;
	myTime_t advsstart = getTime();

	// step all the sims, and check for panic
	debMsgStd("ntlWorld::advanceSims",DM_MSG, " sims "<<mpSims->size()<<" t"<<targetTime<<" done:"<<done<<" panic:"<<allPanic<<" gstate:"<<gstate, 10); // debug // timedebug
	while(!done) {
		double nextTargetTime = (*mpSims)[mFirstSim]->getCurrentTime() + (*mpSims)[mFirstSim]->getTimestep();
		singleStepSims(nextTargetTime);

		// check target times
		done = true;
		allPanic = false;
		
		if((*mpSims)[mFirstSim]->getTimestep() <1e-9 ) { 
			// safety check, avoid timesteps that are too small
			errMsg("ntlWorld::advanceSims","Invalid time step, causing panic! curr:"<<(*mpSims)[mFirstSim]->getCurrentTime()<<" next:"<<nextTargetTime<<", stept:"<< (*mpSims)[mFirstSim]->getTimestep() );
			allPanic = true; 
		} else {
			for(size_t i=0;i<mpSims->size();i++) {
				if(!(*mpSims)[i]->getVisible()) continue;
				if((*mpSims)[i]->getPanic()) allPanic = true; // do any panic now!?
				debMsgStd("ntlWorld::advanceSims",DM_MSG, "Sim "<<i<<", currt:"<<(*mpSims)[i]->getCurrentTime()<<", nt:"<<nextTargetTime<<", panic:"<<(*mpSims)[i]->getPanic()<<", targett:"<<targetTime, 10); // debug // timedebug
			} 
		}
		if( (targetTime - (*mpSims)[mFirstSim]->getCurrentTime()) > LBM_TIME_EPSILON) done=false;
		if(allPanic) done = true;
	}

	if(allPanic) {
		warnMsg("ntlWorld::advanceSims","All sims panicked... stopping thread" );
		setStopRenderVisualization( true );
		return 1;
	}

	myTime_t advsend = getTime();
	debMsgStd("ntlWorld::advanceSims",DM_MSG,"Overall steps so far took:"<< getTimeString(advsend-advsstart)<<" for sim time "<<targetTime, 4);

	// finish step
	for(size_t i=0;i<mpSims->size();i++) {
		SimulationObject *sim = (*mpSims)[i];
		if(!sim->getVisible()) continue;
		if(sim->getPanic()) continue;
		sim->prepareVisualization();
	}

	return 0;
}
Esempio n. 23
0
/******************************************************************************
 * render a whole animation (visualization mode) 
 * this function is run in another thread, and communicates 
 * with the parent thread via a mutex 
 *****************************************************************************/
int ntlWorld::renderVisualization( bool multiThreaded ) 
{
#ifndef NOGUI
	if(getElbeemState() != SIMWORLD_INITED) { return 0; }

	if(multiThreaded) mThreadRunning = true;
	// TODO, check global state?
	while(!getStopRenderVisualization()) {

		if(mpSims->size() <= 0) {
			debMsgStd("ntlWorld::renderVisualization",DM_NOTIFY,"No simulations found, stopping...",1);
			stopSimulationThread();
			break;
		}

		// determine stepsize
		if(!mSingleStepDebug) {
			long startTime = getTime();
			advanceSims(mFrameCnt);
			mFrameCnt++;
			long stopTime = getTime();
			debMsgStd("ntlWorld::renderVisualization",DM_MSG,"Time for t="<<mSimulationTime<<": "<< getTimeString(stopTime-startTime) <<" ", 10);
		} else {
			double targetTime = mSimulationTime + (*mpSims)[mFirstSim]->getTimestep();
			singleStepSims(targetTime);

			// check paniced sims (normally done by advanceSims
			bool allPanic = true;
			for(size_t i=0;i<mpSims->size();i++) {
				if(!(*mpSims)[i]->getPanic()) allPanic = false;
			}
			if(allPanic) {
				warnMsg("ntlWorld::advanceSims","All sims panicked... stopping thread" );
				setStopRenderVisualization( true );
			}
			if(! isSimworldOk() ) {
				warnMsg("ntlWorld::advanceSims","World state error... stopping" );
				setStopRenderVisualization( true );
			}
		}

		// save frame
		if(mpOpenGLRenderer) mpOpenGLRenderer->saveAnimationFrame( mSimulationTime );
		
		// for non-threaded check events
		if(!multiThreaded) {
			Fl::check();
      gpElbeemFrame->SceneDisplay->doOnlyForcedRedraw();
		}

	}
	mThreadRunning = false;
	stopSimulationRestoreGui();
#else 
	multiThreaded = false; // remove warning
#endif
	return 0;
}
Esempio n. 24
0
void ntlWorld::finishWorldInit()
{
	if(! isSimworldOk() ) return;

	// init the scene for the first time
  long sstartTime = getTime();

	// first init sim scene for geo setup
	mpGlob->getSimScene()->buildScene(0.0, true);
	if(! isSimworldOk() ) return;
	mpGlob->getRenderScene()->buildScene(0.0, true);
	if(! isSimworldOk() ) return;
	long sstopTime = getTime();
	debMsgStd("ntlWorld::ntlWorld",DM_MSG,"Scene build time: "<< getTimeString(sstopTime-sstartTime) <<" ", 10);

	// TODO check simulations, run first steps
	mFirstSim = -1;
	if(mpSims->size() > 0) {

		// use values from first simulation as master time scale
		long startTime = getTime();
		
		// remember first active sim
		for(size_t i=0;i<mpSims->size();i++) {
			if(!(*mpSims)[i]->getVisible()) continue;
			if((*mpSims)[i]->getPanic())    continue;

			// check largest timestep
			if(mFirstSim>=0) {
				if( (*mpSims)[i]->getTimestep() > (*mpSims)[mFirstSim]->getTimestep() ) {
					mFirstSim = i;
					debMsgStd("ntlWorld::ntlWorld",DM_MSG,"First Sim changed: "<<i ,10);
				}
			}
			// check any valid sim
			if(mFirstSim<0) {
				mFirstSim = i;
				debMsgStd("ntlWorld::ntlWorld",DM_MSG,"First Sim: "<<i ,10);
			}
		}

		if(mFirstSim>=0) {
			debMsgStd("ntlWorld::ntlWorld",DM_MSG,"Anistart Time: "<<(*mpSims)[mFirstSim]->getStartTime() ,10);
			while(mSimulationTime < (*mpSims)[mFirstSim]->getStartTime() ) {
			debMsgStd("ntlWorld::ntlWorld",DM_MSG,"Anistart Time: "<<(*mpSims)[mFirstSim]->getStartTime()<<" simtime:"<<mSimulationTime ,10);
				advanceSims(-1);
			}
			long stopTime = getTime();

			mSimulationTime += (*mpSims)[mFirstSim]->getStartTime();
			debMsgStd("ntlWorld::ntlWorld",DM_MSG,"Time for start-sims:"<< getTimeString(stopTime-startTime) , 1);
#ifndef NOGUI
			guiResetSimulationTimeRange( mSimulationTime );
#endif
		} else {
			if(!mpGlob->getSingleFrameMode()) debMsgStd("ntlWorld::ntlWorld",DM_WARNING,"No active simulations!", 1);
		}
	}

	if(! isSimworldOk() ) return;
	setElbeemState( SIMWORLD_INITED );
}
Esempio n. 25
0
void StructureManager::reportStructureStatus(CreatureObject* creature,
		StructureObject* structure) {
	ManagedReference<PlayerObject*> ghost = creature->getPlayerObject();

	if (ghost == NULL)
		return;

	//Close the window if it is already open.
	ghost->closeSuiWindowType(SuiWindowType::STRUCTURE_STATUS);

	ManagedReference<SuiListBox*> status = new SuiListBox(creature,
			SuiWindowType::STRUCTURE_STATUS);
	status->setPromptTitle("@player_structure:structure_status_t"); //Structure Status
	status->setPromptText(
			"@player_structure:structure_name_prompt "
					+ structure->getDisplayedName()); //Structure Name:
	status->setUsingObject(structure);
	status->setOkButton(true, "@refresh");
	status->setCancelButton(true, "@cancel");
	status->setCallback(new StructureStatusSuiCallback(server));

	ManagedReference<SceneObject*> ownerObject = server->getObject(
			structure->getOwnerObjectID());

	if (ownerObject != NULL && ownerObject->isCreatureObject()) {
		CreatureObject* owner = cast<CreatureObject*>(ownerObject.get());
		status->addMenuItem(
				"@player_structure:owner_prompt " + owner->getFirstName());
	}

	uint64 declaredOidResidence = ghost->getDeclaredResidence();

	ManagedReference<BuildingObject*> declaredResidence =
			server->getObject(declaredOidResidence).castTo<BuildingObject*>();

	if (declaredResidence == structure) {
		status->addMenuItem("@player_structure:declared_residency"); //You have declared your residency here.
	}

	if (structure->isPrivateStructure() && !structure->isCivicStructure()) {
		status->addMenuItem("@player_structure:structure_private"); //This structure is private
	} else {
		status->addMenuItem("@player_structure:structure_public"); //This structure is public
	}

	status->addMenuItem(
			"@player_structure:condition_prompt "
					+ String::valueOf(structure->getDecayPercentage()) + "%");

	if (!structure->isCivicStructure()) {

		// property tax
		float propertytax = 0.f;
		if(!structure->isCivicStructure() && structure->getCityRegion() != NULL){
			ManagedReference<CityRegion*> city = structure->getCityRegion().get();
			if(city != NULL){
				propertytax = city->getPropertyTax()/ 100.f * structure->getMaintenanceRate();
				status->addMenuItem(
							"@city/city:property_tax_prompt : "
									+ String::valueOf(ceil(propertytax))
									+  " cr/hr");
			}
		}

		// maintenance
		float secsRemainingMaint = 0.f;
		if( structure->getSurplusMaintenance() > 0 ){
			float totalrate = (float)structure->getMaintenanceRate() + propertytax;
			secsRemainingMaint = ((float)structure->getSurplusMaintenance() / totalrate)*3600;
		}

		status->addMenuItem(
			"@player_structure:maintenance_pool_prompt "
					+ String::valueOf( (int) floor( (float) structure->getSurplusMaintenance()))
					+ " "
					+ getTimeString( (uint32)secsRemainingMaint ) );

		status->addMenuItem(
			"@player_structure:maintenance_rate_prompt "
					+ String::valueOf(structure->getMaintenanceRate())
					+ " cr/hr");

		status->addMenuItem(
			"@player_structure:maintenance_mods_prompt "
					+ structure->getMaintenanceMods());
	}


	if (structure->isInstallationObject() && !structure->isGeneratorObject() && !structure->isCivicStructure()) {
		InstallationObject* installation = cast<InstallationObject*>(structure);

		float secsRemainingPower = 0.f;
		if( installation->getSurplusPower() > 0 ){
			secsRemainingPower = ((float)installation->getSurplusPower() / (float)installation->getBasePowerRate())*3600;
		}

		status->addMenuItem(
				"@player_structure:power_reserve_prompt "
						+ String::valueOf( (int) installation->getSurplusPower())
						+ " "
						+ getTimeString( (uint32)secsRemainingPower ) );

		status->addMenuItem(
				"@player_structure:power_consumption_prompt "
						+ String::valueOf(
								(int) installation->getBasePowerRate())
						+ " @player_structure:units_per_hour");
	}

	if (structure->isBuildingObject()) {
		BuildingObject* building = cast<BuildingObject*>(structure);

		status->addMenuItem(
				"@player_structure:items_in_building_prompt "
						+ String::valueOf(
								building->getCurrentNumberOfPlayerItems())); //Number of Items in Building:
	}

	ghost->addSuiBox(status);
	creature->sendMessage(status->generateMessage());
}
Esempio n. 26
0
std::string gt::Torrent::getTextTimeRemaining()
{
	return getTimeString(getTimeRemaining());
}
Esempio n. 27
0
		// Returns formatted active time as string
		inline std::string getTextActiveTime()
		{
			return getTimeString(getActiveTime());
		}
Esempio n. 28
0
// Returns formatted active time as string
std::string gt::Torrent::getTextActiveTime()
{
	return getTimeString(getActiveTime());
}
Esempio n. 29
0
void PropertyTimelineWidget::itemMoving(KeyframeGraphicsItem* kfgi) {
    moveFrameHUD(kfgi->pos().x()-40);
    currentFrameCounter_->setHtml(getTimeString(kfgi->pos().x()));
}
Esempio n. 30
0
// Returns formatted eta as string
std::string gt::Torrent::getTextEta()
{
	return getTimeString(getEta());
}