本文整理汇总了C#中WinterLeaf.Engine.Classes.View.Creators.ObjectCreator.openForRead方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectCreator.openForRead方法的具体用法?C# ObjectCreator.openForRead怎么用?C# ObjectCreator.openForRead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WinterLeaf.Engine.Classes.View.Creators.ObjectCreator
的用法示例。
在下文中一共展示了ObjectCreator.openForRead方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: save
public void save(bool selectedOnly, bool noPrompt)
{
GuiEditorGui.GuiEditor GuiEditor = "GuiEditor";
GuiControl GuiEditorContent = "GuiEditorContent";
GuiEditorStatusBar GuiEditorStatusBar = "GuiEditorStatusBar";
SimObject currentObject;
// Get the control we should save.
if (selectedOnly)
{
SimSet selected = GuiEditor.getSelection();
if (selected.getCount() == 0)
return;
else if (selected.getCount() > 1)
{
Util.messageBox("Invalid selection", "Only a single control hierarchy can be saved to a file. Make sure you have selected only one control in the tree view.", "", "");
return;
}
currentObject = selected.getObject(0);
}
else if (GuiEditorContent.getCount() > 0)
currentObject = GuiEditorContent.getObject(0);
else
return;
// Store the current guide set on the control.
GuiEditor.writeGuides(currentObject);
currentObject.canSaveDynamicFields = true; // Make sure the guides get saved out.
// Construct a base filename.
string name;
if (currentObject.getName() != "")
name = currentObject.getName() + ".gui";
else
name = "Untitled.gui";
// Construct a path.
string currentFile;
if (selectedOnly && currentObject != GuiEditorContent.getObject(0) && currentObject.getFilename() == ((SimObject) GuiEditorContent.getObject(0)).getFilename())
{
// Selected child control that hasn't been yet saved to its own file.
currentFile = GuiEditor["LastPath"] + "/" + name;
currentFile = Util.makeRelativePath(currentFile, Util.getMainDotCsDir());
}
else
{
currentFile = currentObject.getFilename();
if (currentFile == "")
{
// No file name set on control. Force a prompt.
noPrompt = false;
if (GuiEditor["LastPath"] != "")
{
currentFile = GuiEditor["LastPath"] + "/" + name;
currentFile = Util.makeRelativePath(currentFile, Util.getMainDotCsDir());
}
else
currentFile = Util._expandFilename(name);
}
else
currentFile = Util._expandFilename(currentFile);
}
// Get the filename.
string filename;
if (!noPrompt)
{
filename = GuiEditorFileDialog.GuiBuilder.GetSaveName(currentFile);
// console.Call_Classname("GuiBuilder", "getSaveName", new string[] {currentFile} );
if (filename == "")
return;
}
else
filename = currentFile;
// Save the Gui.
if (Util.isWriteableFileName(filename))
{
//
// Extract any existent TorqueScript before writing out to disk
//
FileObject fileObject = new ObjectCreator("FileObject").Create();
fileObject.openForRead(filename);
bool skipLines = true;
bool beforeObject = true;
// var++ does not post-increment var, in torquescript, it pre-increments it,
// because ++var is illegal.
//int lines = -1;
//int beforeLines = -1;
//.........这里部分代码省略.........
示例2: onWake
public override void onWake()
{
string text = "";
FileObject f = new ObjectCreator("FileObject").Create();
f.openForRead(this["fileName"]);
while (!f.isEOF())
text = text + f.readLine() + "\n";
f.delete();
((GuiMLTextCtrl) FOT("TextBox")).setText(text);
}
示例3: readDtsConfig
public void readDtsConfig()
{
string filename = Util.filePath(this.path) + "/" + Util.fileBase(this.path) + ".cfg";
string filename2 = Util.filePath(this.path) + "/" + "dtsScene.cfg";
FileObject fo = new ObjectCreator("FileObject").Create();
if (fo.openForRead(filename) || fo.openForRead(filename2))
{
string alwaysImport = "";
string neverImport = "";
string mode = "none";
while (!fo.isEOF())
{
string line = Util.trim(fo.readLine());
if (line == "AlwaysExport:") // Start of the AlwaysExport list
mode = "always";
else if (line == "NeverExport:") // Start of the NeverExport list
mode = "never";
else if (Util.startsWith(line, "+", false) || Util.startsWith(line, "-", false))
// Boolean parameters (not supported)
mode = "none";
else if (Util.startsWith(line, "=", false)) // Float and integer parameters (not supported)
mode = "none";
else if (!Util.startsWith(line, "//", false)) // Non-commented lines
{
switch (mode)
{
case "always":
alwaysImport = alwaysImport + '\t' + line;
break;
case "never":
neverImport = neverImport + '\t' + line;
break;
}
}
}
fo.close();
alwaysImport = Util.strreplace(Util.trim(alwaysImport), "\t", ";");
neverImport = Util.strreplace(Util.trim(neverImport), "\t", ";");
((GuiTextEditCtrl) this.FOT(alwaysImport)).setText(alwaysImport);
((GuiTextEditCtrl) this.FOT(neverImport)).setText(neverImport);
}
else
Util._error("Failed to open " + filename + " or " + filename2 + " for reading");
fo.delete();
}