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

📄 objectbuildergui.gui

📁 此为游戏源码 是很好 的学习工具阿
💻 GUI
📖 第 1 页 / 共 2 页
字号:
//--- OBJECT WRITE BEGIN ---
new GuiControl(ObjectBuilderGui) {
	profile = "GuiDefaultProfile";
	horizSizing = "right";
	vertSizing = "bottom";
	position = "0 0";
	extent = "640 480";
	minExtent = "8 8";
	visible = "1";
	setFirstResponder = "0";
	modal = "1";
	helpTag = "0";

	new GuiWindowCtrl(OBTargetWindow) {
		profile = "GuiWindowProfile";
		horizSizing = "right";
		vertSizing = "bottom";
		position = "217 74";
		extent = "256 282";
		minExtent = "8 8";
		visible = "1";
		setFirstResponder = "0";
		modal = "1";
		helpTag = "0";
		resizeWidth = "1";
		resizeHeight = "1";
		canMove = "1";
		canClose = "0";
		canMinimize = "0";
		canMaximize = "0";
		minSize = "50 50";

		new GuiTextCtrl() {
			profile = "GuiCenterTextProfile";
			horizSizing = "right";
			vertSizing = "bottom";
			position = "13 31";
			extent = "84 25";
			minExtent = "8 8";
			visible = "1";
			setFirstResponder = "0";
			modal = "1";
			helpTag = "0";
			text = "Object Name:";
		};
		new GuiTextEditCtrl(OBObjectName) {
			profile = "GuiTextEditProfile";
			horizSizing = "right";
			vertSizing = "bottom";
			position = "105 31";
			extent = "143 18";
			minExtent = "8 8";
			visible = "1";
			setFirstResponder = "0";
			modal = "1";
			helpTag = "0";
			historySize = "0";
		};
		new GuiControl(OBContentWindow) {
			profile = "GuiButtonProfile";
			horizSizing = "right";
			vertSizing = "bottom";
			position = "8 56";
			extent = "240 193";
			minExtent = "0 0";
			visible = "1";
			setFirstResponder = "0";
			modal = "1";
			helpTag = "0";
		};
		new GuiButtonCtrl(OBOKButton) {
			profile = "GuiButtonProfile";
			horizSizing = "right";
			vertSizing = "bottom";
			position = "70 254";
			extent = "80 20";
			minExtent = "8 8";
			visible = "1";
			setFirstResponder = "0";
			modal = "1";
			command = "ObjectBuilderGui.onOK();";
			helpTag = "0";
			text = "OK";
		};
		new GuiButtonCtrl(OBCancelButton) {
			profile = "GuiButtonProfile";
			horizSizing = "right";
			vertSizing = "bottom";
			position = "156 254";
			extent = "80 20";
			minExtent = "8 8";
			visible = "1";
			setFirstResponder = "0";
			modal = "1";
			command = "ObjectBuilderGui.onCancel();";
			helpTag = "0";
			text = "Cancel";
		};
	};
};
//--- OBJECT WRITE END ---

function ObjectBuilderGui::init(%this)
{
   %this.baseOffsetX       = 9;
   %this.baseOffsetY       = 10;
   %this.scriptFile        = "editor/newObject.cs";
   %this.defaultObjectName = "";
   %this.defaultFieldStep  = 26;
   %this.columnOffset      = 95;

   %this.fieldNameExtent   = "132 18";
   %this.textEditExtent    = "127 18";
   %this.checkBoxExtent    = "18 18";
   %this.popupMenuExtent   = "127 18";
   %this.fileButtonExtent  = "127 18";

   //
   %this.numControls       = 0;

   %this.reset();
}

function ObjectBuilderGui::reset(%this)
{
   %this.curXPos           = %this.baseOffsetX;
   %this.curYPos           = %this.baseOffsetY;
   %this.createCallback    = "";
   %this.currentControl    = 0;

   //
   OBObjectName.setValue(%this.defaultObjectName);

   //
   %this.newObject         = 0;
   %this.className         = "";
   %this.numFields         = 0;

   //
   for(%i = 0; %i < %this.numControls; %i++)
   {
      %this.textControls[%i].delete();
      %this.controls[%i].delete();
   }
   %this.numControls = 0;
}

//------------------------------------------------------------------------------

function ObjectBuilderGui::createFileType(%this, %index)
{
   if(%index >= %this.numFields || %this.field[%index, name] $= "")
   {
      error("ObjectBuilderGui::createFileType: invalid field");
      return;
   }

   //
   if(%this.field[%index, text] $= "")
      %name = %this.field[%index, name];
   else
      %name = %this.field[%index, text];

   // 
   %this.textControls[%this.numControls] = new GuiTextCtrl() {
      profile = "GuiTextProfile";
      text = %name;
      extent = %this.fieldNameExtent;
      position = %this.curXPos @ " " @ %this.curYPos;
      modal = "1";
   };

   // 
   %this.controls[%this.numControls] = new GuiButtonCtrl() {
      profile = "GuiButtonProfile";
      extent = %this.fileButtonExtent;
      position = %this.curXPos + %this.columnOffset @ " " @ %this.curYPos;
      modal = "1";
      command = %this @ ".getFileName(" @ %index @ ");";
   };

   %val = %this.field[%index, value];
   %this.controls[%this.numControls].setValue(fileBase(%val) @ fileExt(%val));

   %this.numControls++;
   %this.curYPos += %this.defaultFieldStep;
}

function ObjectBuilderGui::getFileName(%this, %index)
{
   if(%index >= %this.numFields || %this.field[%index, name] $= "")
   {
      error("ObjectBuilderGui::getFileName: invalid field");
      return;
   }
   
   %val = %this.field[%index, value];

   %path = filePath(%val);
   %ext = fileExt(%val);

   %this.currentControl = %index;
   getLoadFilename(%path @ "*" @ %ext, %this @ ".gotFileName");
}

function ObjectBuilderGui::gotFileName(%this, %name)
{
   %this.controls[%this.currentControl].setValue(%name);
}

//------------------------------------------------------------------------------

function ObjectBuilderGui::createDataBlockType(%this, %index)
{
   if(%index >= %this.numFields || %this.field[%index, name] $= "")
   {
      error("ObjectBuilderGui::createDataBlockType: invalid field");
      return;
   }

   //
   if(%this.field[%index, text] $= "")
      %name = %this.field[%index, name];
   else
      %name = %this.field[%index, text];

   // 
   %this.textControls[%this.numControls] = new GuiTextCtrl() {
      profile = "GuiTextProfile";
      text = %name;
      extent = %this.fieldNameExtent;
      position = %this.curXPos @ " " @ %this.curYPos;
      modal = "1";
   };

   // 
   %this.controls[%this.numControls] = new GuiPopupMenuCtrl() {
      profile = "GuiPopUpMenuProfile";
      extent = %this.popupMenuExtent;
      position = %this.curXPos + %this.columnOffset @ " " @ %this.curYPos;
      modal = "1";
      maxPopupHeight = "200";
   };

   %classname = getWord(%this.field[%index, value], 0);

   %this.controls[%this.numControls].add("", -1);

   // add the datablocks
   for(%i = 0; %i < DataBlockGroup.getCount(); %i++)
   {
      %obj = DataBlockGroup.getObject(%i);
      if(%obj.getClassName() $= %classname)
         %this.controls[%this.numControls].add(%obj.getName(), %i);
   }
   
   %this.controls[%this.numControls].setValue(getWord(%this.field[%index, value], 1));

   %this.numControls++;
   %this.curYPos += %this.defaultFieldStep;
}

function ObjectBuilderGui::createBoolType(%this, %index)
{
   if(%index >= %this.numFields || %this.field[%index, name] $= "")
   {
      error("ObjectBuilderGui::createBoolType: invalid field");
      return;
   }
   
   //
   if(%this.field[%index, value] $= "")
      %value = 0;
   else
      %value = %this.field[%index, value];

   //
   if(%this.field[%index, text] $= "")
      %name = %this.field[%index, name];
   else
      %name = %this.field[%index, text];

   // 
   %this.textControls[%this.numControls] = new GuiTextCtrl() {
      profile = "GuiTextProfile";
      text = %name;
      extent = %this.fieldNameExtent;
      position = %this.curXPos @ " " @ %this.curYPos;
      modal = "1";
   };

   // 
   %this.controls[%this.numControls] = new GuiCheckBoxCtrl() {
      profile = "GuiCheckBoxProfile";
      extent = %this.checkBoxExtent;
      position = %this.curXPos + %this.columnOffset @ " " @ %this.curYPos;
      modal = "1";
   };

   %this.controls[%this.numControls].setValue(%value);
   
   %this.numControls++;
   %this.curYPos += %this.defaultFieldStep;
}

function ObjectBuilderGui::createStringType(%this, %index)
{
   if(%index >= %this.numFields || %this.field[%index, name] $= "")
   {
      error("ObjectBuilderGui::createStringType: invalid field");
      return;
   }
   
   //
   if(%this.field[%index, text] $= "")
      %name = %this.field[%index, name];
   else
      %name = %this.field[%index, text];

   // 
   %this.textControls[%this.numControls] = new GuiTextCtrl() {
      profile = "GuiTextProfile";
      text = %name;
      extent = %this.fieldNameExtent;
      position = %this.curXPos @ " " @ %this.curYPos;
      modal = "1";
   };

   // 
   %this.controls[%this.numControls] = new GuiTextEditCtrl() {
      profile = "GuiTextEditProfile";
      extent = %this.textEditExtent;
      text = %this.field[%index, value];
      position = %this.curXPos + %this.columnOffset @ " " @ %this.curYPos;
      modal = "1";
   };
   
   %this.numControls++;

⌨️ 快捷键说明

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