2008-11-05 22:20:52 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.Text;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using Microsoft.Win32;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using CodeImp.DoomBuilder.Config;
|
|
|
|
using CodeImp.DoomBuilder.Types;
|
|
|
|
using CodeImp.DoomBuilder.IO;
|
2008-11-10 16:11:44 +00:00
|
|
|
using System.IO;
|
2008-11-05 22:20:52 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Controls
|
|
|
|
{
|
|
|
|
internal sealed class ScriptLumpDocumentTab : ScriptDocumentTab
|
|
|
|
{
|
|
|
|
#region ================== Constants
|
2008-11-06 15:00:01 +00:00
|
|
|
|
2008-11-05 22:20:52 +00:00
|
|
|
#endregion
|
2008-11-14 16:19:25 +00:00
|
|
|
|
2008-11-05 22:20:52 +00:00
|
|
|
#region ================== Variables
|
2008-11-14 16:19:25 +00:00
|
|
|
|
2008-11-06 15:00:01 +00:00
|
|
|
private string lumpname;
|
|
|
|
|
2008-11-05 22:20:52 +00:00
|
|
|
#endregion
|
2008-11-06 15:00:01 +00:00
|
|
|
|
2008-11-05 22:20:52 +00:00
|
|
|
#region ================== Properties
|
2008-11-06 15:00:01 +00:00
|
|
|
|
|
|
|
public override bool ExplicitSave { get { return false; } }
|
2008-11-10 16:11:44 +00:00
|
|
|
public override bool IsSaveAsRequired { get { return false; } }
|
2008-11-06 15:00:01 +00:00
|
|
|
public override bool IsClosable { get { return false; } }
|
2008-11-09 17:59:13 +00:00
|
|
|
public override bool IsReconfigurable { get { return false; } }
|
2008-11-06 15:00:01 +00:00
|
|
|
|
2008-11-05 22:20:52 +00:00
|
|
|
#endregion
|
2008-11-06 15:00:01 +00:00
|
|
|
|
2008-11-05 22:20:52 +00:00
|
|
|
#region ================== Constructor / Disposer
|
2008-11-06 15:00:01 +00:00
|
|
|
|
2008-11-05 22:20:52 +00:00
|
|
|
// Constructor
|
2008-11-10 16:11:44 +00:00
|
|
|
public ScriptLumpDocumentTab(string lumpname, ScriptConfiguration config)
|
2008-11-05 22:20:52 +00:00
|
|
|
{
|
|
|
|
// Initialize
|
2008-11-06 15:00:01 +00:00
|
|
|
this.lumpname = lumpname;
|
2008-11-10 16:11:44 +00:00
|
|
|
this.config = config;
|
|
|
|
editor.SetupStyles(config);
|
2008-11-06 15:00:01 +00:00
|
|
|
|
2008-11-10 16:11:44 +00:00
|
|
|
// Load the lump data
|
|
|
|
MemoryStream stream = General.Map.GetLumpData(lumpname);
|
|
|
|
if(stream != null)
|
|
|
|
{
|
|
|
|
StreamReader reader = new StreamReader(stream);
|
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
editor.Text = reader.ReadToEnd();
|
|
|
|
editor.ClearUndoRedo();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Done
|
2008-11-06 15:00:01 +00:00
|
|
|
SetTitle(lumpname.ToUpper());
|
2008-11-05 22:20:52 +00:00
|
|
|
}
|
2008-11-06 15:00:01 +00:00
|
|
|
|
2008-11-05 22:20:52 +00:00
|
|
|
// Disposer
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
{
|
|
|
|
base.Dispose(disposing);
|
|
|
|
}
|
2008-11-06 15:00:01 +00:00
|
|
|
|
2008-11-05 22:20:52 +00:00
|
|
|
#endregion
|
2008-11-06 15:00:01 +00:00
|
|
|
|
2008-11-05 22:20:52 +00:00
|
|
|
#region ================== Methods
|
2008-11-06 15:00:01 +00:00
|
|
|
|
2008-11-14 16:19:25 +00:00
|
|
|
// Compile script
|
|
|
|
public override void Compile()
|
|
|
|
{
|
|
|
|
// Do it!
|
|
|
|
General.Map.CompileLump(lumpname);
|
|
|
|
}
|
|
|
|
|
2008-11-10 16:11:44 +00:00
|
|
|
// Implicit save
|
|
|
|
public override bool Save()
|
|
|
|
{
|
|
|
|
// Store the lump data
|
|
|
|
byte[] data = Encoding.ASCII.GetBytes(editor.Text);
|
|
|
|
MemoryStream stream = new MemoryStream(data);
|
|
|
|
General.Map.SetLumpData(lumpname, stream);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-11-05 22:20:52 +00:00
|
|
|
#endregion
|
2008-11-06 15:00:01 +00:00
|
|
|
|
2008-11-05 22:20:52 +00:00
|
|
|
#region ================== Events
|
2008-11-06 15:00:01 +00:00
|
|
|
|
2008-11-05 22:20:52 +00:00
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|