⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guithemeinspector.cc

📁 五行MMORPG引擎系统V1.0
💻 CC
字号:
//-----------------------------------------------------------------------------
// Torque Game Engine 
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

#include "console/consoleTypes.h"
#include "console/console.h"
#include "gui/editor/guiThemeInspector.h"
#include "core/fileObject.h"
#include "core/fileStream.h"

#define NULL_STRING     "<NULL>"

IMPLEMENT_CONOBJECT(GuiThemeInspector);


GuiThemeInspector::GuiThemeInspector()
{
	/// TGE_Theme  1.4没有这些成员变量
   //mEditControlOffset = 5;
   //mEntryHeight = 16;
   //mTextExtent = 80;
   //mEntrySpacing = 2;
   //mMaxMenuExtent = 380;
   //mUseFieldGrouping = true;
}

//-----------------
ConsoleMethod(GuiThemeInspector, deleteThemeFile, bool, 3, 3, "obj.delete(fileName)")
{
	// delete the file
	dFileDelete(argv[2]);
	return true;

}
ConsoleMethod(GuiThemeInspector, saveThemeFile, bool, 3, 4, "obj.save(fileName, <selectedOnly>)")
{  // we read in the file first
   // then we write out our stuff
   // then we write out any non object code
   static const char *beginMessage = "//--- THEME WRITE BEGIN ---";
   static const char *endMessage = "//--- THEME WRITE END ---";
	static const char *beginProfile = "//--- PROFILE WRITE BEGIN ---\r\n";
	static const char *endProfile = "//--- PROFILE WRITE END ---\r\n";
	const char * inTheme;
   FileStream stream;
   FileObject f;


   // read the file in 
   f.readMemory(argv[2]);
   
   // check for flags <selected, ...>
   U32 writeFlags = 0;
   if(argc > 3)
   {
      if(dAtob(argv[3]))
         writeFlags |= SimObject::SelectedOnly;

		
   }

	writeFlags |= SimObject::ObjectExists;

   if(!ResourceManager->openFileForWrite(stream, argv[2])) 
      return false;
   
   char docRoot[256];
   char modRoot[256];
   // copy the file name to docRoot
   dStrcpy(docRoot, argv[2]);
   // find the last occurance of character
   char *p = dStrrchr(docRoot, '/');
   
   if (p) *++p = '\0';
   else  docRoot[0] = '\0';
      
   dStrcpy(modRoot, argv[2]);
   p = dStrchr(modRoot, '/');
   if (p) *++p = '\0';
   else  modRoot[0] = '\0';
   
   Con::setVariable("$DocRoot", docRoot);
   Con::setVariable("$ModRoot", modRoot);

   const char *buffer;
   while(!f.isEOF())
   {
      buffer = (const char *) f.readLine();
      if(!dStrcmp(buffer, beginMessage))
         break;
      stream.write(dStrlen(buffer), buffer);
      stream.write(2, "\r\n");
   }
   stream.write(dStrlen(beginMessage), beginMessage);
   stream.write(2, "\r\n");

	const char * days[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
	const char * months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };


   // what's the time and date?
   Platform::LocalTime localTime;
   Platform::getLocalTime(localTime);
   char timeBuffer[1024];
   dStrcpy(timeBuffer,avar("// 主题发布时间: %i:%i (%s %s %i)",localTime.hour,localTime.min,days[localTime.weekday],months[localTime.month],localTime.monthday));

	stream.write(dStrlen(timeBuffer), timeBuffer);
   stream.write(2, "\r\n");

   // to loop through all the existing profiles and dump them
   Vector<StringTableEntry> entries;

   SimGroup * grp = Sim::getGuiDataGroup();
   for(SimGroup::iterator i = grp->begin(); i != grp->end(); i++)
   {
      SimObject * profile = dynamic_cast<SimObject *>(*i);
		if (profile )
		{
			inTheme = profile->getDataField(StringTable->insert("inTheme", false),0);

			if (dStrcmp(inTheme, "1") == 0)
			{
				// can't use default SimObject write because that assumes
				// creation of a new object.

				stream.write(dStrlen(beginProfile), beginProfile);
				profile->write(stream,0,writeFlags);
				stream.write(dStrlen(endProfile), endProfile);
			}
      }
   }
   stream.write(34,"Canvas.setCursor(DefaultCursor);\r\n");
	stream.write(19,"Canvas.repaint();\r\n");
   stream.write(dStrlen(endMessage), endMessage);
   stream.write(2, "\r\n");
   
   // now write out non object stuff originally in the file
   
   while(!f.isEOF())
   {
      buffer = (const char *) f.readLine();
      if(!dStrcmp(buffer, endMessage))
         break;
   }
   while(!f.isEOF())
   {
      buffer = (const char *) f.readLine();
      stream.write(dStrlen(buffer), buffer);
      stream.write(2, "\r\n");
   }

   Con::setVariable("$DocRoot", NULL);
   Con::setVariable("$ModRoot", NULL);

   return true;
}


// end eag

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -