mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-01-31 05:00:34 +00:00
Added support for Lua and SOC scripts to script editor (including syntax highlighting for Lua)
This commit is contained in:
parent
8d48514ed2
commit
658e349f95
8 changed files with 644 additions and 9 deletions
|
@ -334,6 +334,22 @@ maplumpnames
|
|||
}
|
||||
}
|
||||
|
||||
scriptlumpnames
|
||||
{
|
||||
MAINCFG;
|
||||
OBJCTCFG;
|
||||
|
||||
SOC_
|
||||
{
|
||||
isprefix = true;
|
||||
}
|
||||
|
||||
LUA_
|
||||
{
|
||||
script = "Lua.cfg";
|
||||
isprefix = true;
|
||||
}
|
||||
}
|
||||
|
||||
// DEFAULT SECTOR BRIGHTNESS LEVELS
|
||||
sectorbrightness
|
||||
|
|
335
Build/Scripting/Lua.cfg
Normal file
335
Build/Scripting/Lua.cfg
Normal file
|
@ -0,0 +1,335 @@
|
|||
/*******************************************************************\
|
||||
Zone Builder Script highlighting definitions for SRB2 Lua
|
||||
\*******************************************************************/
|
||||
|
||||
// Editor settings
|
||||
description = "SRB2 Lua Script";
|
||||
codepage = 0;
|
||||
extensions = "lua";
|
||||
casesensitive = true;
|
||||
insertcase = 0; // 0=Normal, 1=Lowercase, 2=Uppercase
|
||||
lexer = 15;
|
||||
functionopen = "(";
|
||||
functionclose = ")";
|
||||
codeblockopen = "{";
|
||||
codeblockclose = "}";
|
||||
arrayopen = "[";
|
||||
arrayclose = "]";
|
||||
argumentdelimiter = ",";
|
||||
terminator = ";";
|
||||
scripttype = 0; //0 = unknown script, 1 = acc, 2 = modeldef, 3 = decorate
|
||||
|
||||
keywords
|
||||
{
|
||||
and = "";
|
||||
break = "";
|
||||
continue = "";
|
||||
do = "";
|
||||
else = "";
|
||||
elseif = "";
|
||||
end = "";
|
||||
false = "";
|
||||
for = "";
|
||||
function = "";
|
||||
if = "";
|
||||
in = "";
|
||||
local = "";
|
||||
nil = "";
|
||||
not = "";
|
||||
or = "";
|
||||
repeat = "";
|
||||
return = "";
|
||||
then = "";
|
||||
true = "";
|
||||
until = "";
|
||||
while = "";
|
||||
$1 = "";
|
||||
$2 = "";
|
||||
$3 = "";
|
||||
$4 = "";
|
||||
$5 = "";
|
||||
$6 = "";
|
||||
$7 = "";
|
||||
$8 = "";
|
||||
$9 = "";
|
||||
print = "string output, [string output2, [...]]";
|
||||
freeslot = "string resource, [string resource2, [...]]";
|
||||
super = "mobj_t actor, int var1, int var2";
|
||||
addHook = "string hook, function(?) fn, [int extra]";
|
||||
EvalMath = "string word";
|
||||
// math
|
||||
abs = "int a";
|
||||
min = "int a, int b";
|
||||
max = "int a, int b";
|
||||
sin = "angle angle";
|
||||
cos = "angle angle";
|
||||
tan = "angle angle";
|
||||
FixedAngle = "fixed angle";
|
||||
AngleFixed = "angle angle";
|
||||
InvAngle = "angle angle";
|
||||
FixedMul = "fixed a, fixed b";
|
||||
FixedInt = "fixed a";
|
||||
FixedDiv = "fixed a, fixed b";
|
||||
FixedRem = "fixed a, fixed b";
|
||||
FixedSqrt = "fixed a";
|
||||
FixedHypot = "fixed a, fixed b";
|
||||
FixedFloor = "fixed a";
|
||||
FixedTrunc = "fixed a";
|
||||
FixedCeil = "fixed a";
|
||||
FixedRound = "fixed a";
|
||||
// misc
|
||||
GetSecSpecial = "int special, int section";
|
||||
All7Emeralds = "int flags";
|
||||
ColorOpposite = "int color";
|
||||
// p_random
|
||||
P_Random = "";
|
||||
P_SignedRandom = "";
|
||||
P_RandomKey = "int a";
|
||||
P_RandomRange = "int a, int b";
|
||||
// p_maputil
|
||||
P_AproxDistance = "fixed dx, fixed dy";
|
||||
P_ClosestPointOnLine = "fixed x, fixed y, line_t line";
|
||||
// p_enemy
|
||||
P_CheckMeleeRange = "mobj_t actor";
|
||||
P_JetbCheckMeleeRange = "mobj_t actor";
|
||||
P_FaceStabCheckMeleeRange = "mobj_t actor";
|
||||
P_SkimCheckMeleeRange = "mobj_t actor";
|
||||
P_CheckMissileRange = "mobj_t actor";
|
||||
P_NewChaseDir = "mobj_t actor";
|
||||
P_LookForPlayers = "mobj_t actor, [fixed dist, [boolean allaround?, [boolean tracer?]]]";
|
||||
// p_mobj
|
||||
P_SpawnMobj = "fixed x, fixed y, fixed z, int type";
|
||||
P_RemoveMobj = "mobj_t mobj";
|
||||
P_SpawnMissile = "mobj_t source, mobj_t dest, int type";
|
||||
P_SpawnXYZMissile = "mobj_t source, mobj_t dest, int type, fixed x, fixed y, fixed z";
|
||||
P_SpawnPointMissile = "mobj_t source, fixed dest_x, fixed dest_y, fixed dest_z, int type, fixed x, fixed y, fixed z";
|
||||
P_SpawnAlteredDirectionMissile = "mobj_t source, int type, fixed x, fixed y, fixed z, int angle_shift";
|
||||
P_ColorTeamMissile = "mobj_t missile, player_t player";
|
||||
P_SPMAngle = "mobj_t source, int type, angle angle, [boolean allowaim?, [int flags2]]";
|
||||
P_SpawnPlayerMissile = "mobj_t source, int type, [int flags2]";
|
||||
P_MobjFlip = "mobj_t mobj";
|
||||
P_WeaponOrPanel = "int type";
|
||||
P_FlashPal = "player_t player, int type, int duration";
|
||||
P_GetClosestAxis = "mobj_t mobj";
|
||||
P_SpawnParaloop = "fixed x, fixed y, fixed z, fixed radius, int number, int type, int rotate, [int state, [boolean spawncenter?]]";
|
||||
P_BossTargetPlayer = "mobj_t actor, [boolean closest?]";
|
||||
P_SupermanLook4Players = "mobj_t actor";
|
||||
P_SetScale = "mobj_t mobj, fixed scale";
|
||||
P_CheckDeathPitCollide = "mobj_t mobj";
|
||||
P_InsideANonSolidFFloor = "mobj_t mobj, ffloor_t rover";
|
||||
P_CheckSolidLava = "mobj_t mobj, ffloor_t rover";
|
||||
P_CanRunOnWater = "player_t player, ffloor_t rover";
|
||||
// p_user
|
||||
P_GetPlayerHeight = "player_t player";
|
||||
P_GetPlayerSpinHeight = "player_t player";
|
||||
P_GetPlayerControlDirection = "player_t player";
|
||||
P_AddPlayerScore = "player_t player, int amount";
|
||||
P_PlayerInPain = "player_t player";
|
||||
P_DoPlayerPain = "player_t player, [mobj_t source, [mobj_t inflictor]]";
|
||||
P_ResetPlayer = "player_t player";
|
||||
P_IsObjectOnGround = "mobj_t mobj";
|
||||
P_SetObjectMomZ = "mobj_t mobj, fixed momz, [boolean relative?]";
|
||||
P_RestoreMusic = "player_t player";
|
||||
P_SpawnGhostMobj = "mobj_t mobj";
|
||||
P_GivePlayerRings = "player_t player, int amount";
|
||||
P_GivePlayerLives = "player_t player, int amount";
|
||||
P_ResetScore = "player_t player";
|
||||
P_BlackOw = "player_t player";
|
||||
P_ElementalFireTrail = "player_t player";
|
||||
P_DoPlayerExit = "player_t player";
|
||||
P_InstaThrust = "mobj_t mobj, angle angle, fixed move";
|
||||
P_ReturnThrustX = "mobj_t mobj, angle angle, fixed move";
|
||||
P_ReturnThrustY = "mobj_t mobj, angle angle, fixed move";
|
||||
P_LookForEnemies = "player_t player";
|
||||
P_NukeEnemies = "mobj_t inflictor, mobj_t source, fixed radius";
|
||||
P_HomingAttack = "mobj_t source, mobj_t target";
|
||||
P_SpawnThokMobj = "player_t player";
|
||||
P_SpawnSpinMobj = "player_t player, int type";
|
||||
P_Telekinesis = "player_t player, fixed_t thrust, fixed_t range";
|
||||
P_InQuicksand = "mobj_t mobj";
|
||||
P_InSpaceSector = "mobj_t mobj";
|
||||
P_DoJumpShield = "player_t player";
|
||||
P_IsObjectInGoop = "mobj_t mobj";
|
||||
// p_map
|
||||
P_CheckPosition = "mobj_t mobj, fixed x, fixed y, fixed z";
|
||||
P_TryMove = "mobj_t mobj, fixed x, fixed y, [boolean allowdrowoff?]";
|
||||
P_Move = "mobj_t actor, int speed";
|
||||
P_TeleportMove = "mobj_t mobj, fixed x, fixed y, fixed z";
|
||||
P_SlideMove = "mobj_t mo";
|
||||
P_BounceMove = "mobj_t mo";
|
||||
P_CheckSight = "mobj_t source, mobj_t target";
|
||||
P_CheckHoopPosition = "mobj_t hoop, fixed x, fixed y, fixed z, fixed radius";
|
||||
P_RadiusAttack = "mobj_t inflictor, mobj_t source, fixed radius";
|
||||
P_FloorzAtPos = "fixed x, fixed y, fixed z, fixed height";
|
||||
P_DoSpring = "mobj_t spring, mobj_t object";
|
||||
// p_inter
|
||||
P_RemoveShield = "player_t player";
|
||||
P_SpawnShieldOrb = "player_t player";
|
||||
P_DamageMobj = "mobj_t target, [mobj_t inflictor, [mobj_t source, [int damage]]]";
|
||||
P_KillMobj = "mobj_t target, [mobj_t inflictor, [mobj_t source]]";
|
||||
P_PlayerRingBurst = "player_t player, [int numrings]";
|
||||
P_PlayerWeaponPanelBurst = "player_t player";
|
||||
P_PlayerWeaponAmmoBurst = "player_t player";
|
||||
P_PlayerEmeraldBurst = "player_t player, [boolean toss?]";
|
||||
P_PlayerFlagBurst = "player_t player, [boolean toss?]";
|
||||
P_PlayRinglossSound = "mobj_t source, [player_t player]";
|
||||
P_PlayDeathSound = "mobj_t source, [player_t player]";
|
||||
P_PlayVictorySound = "mobj_t source, [player_t player]";
|
||||
P_PlayLivesJingle = "player_t player";
|
||||
P_CanPickupItem = "player_t player, [boolean weapon?]";
|
||||
P_DoNightsScore = "player_t player";
|
||||
// p_spec
|
||||
P_Thrust = "mobj_t mobj, angle angle, fixed move";
|
||||
P_SetMobjStateNF = "mobj_t mobj, int statenum";
|
||||
P_DoSuperTransformation = "player_t player, [boolean giverings?]";
|
||||
P_ExplodeMissile = "mobj_t missile";
|
||||
P_PlayerTouchingSectorSpecial = "player_t player, int section, int specialnum";
|
||||
P_FindSpecialLineFromTag = "int special, int tag, [int start]";
|
||||
P_SwitchWeather = "int weather, [player_t player]";
|
||||
P_LinedefExecute = "int tag, [mobj_t actor, [sector_t caller]]";
|
||||
P_SpawnLightningFlash = "sector_t sector";
|
||||
P_FadeLight = "int tag, int destvalue, int speed";
|
||||
P_ThingOnSpecial3DFloor = "mobj_t mobj";
|
||||
P_SetupLevelSky = "int skynum, [player player]";
|
||||
P_SetSkyboxMobj = "mobj_t mobj, [boolean centerpoint?, [player_t user]]";
|
||||
P_StartQuake = "fixed intensity, int time, [table{x/y/z} epicenter, [fixed radius]]";
|
||||
P_IsFlagAtBase = "int type";
|
||||
EV_CrumbleChain = "sector_t sector, ffloor_t rover";
|
||||
// r_defs
|
||||
R_PointToAngle = "fixed x, fixed y";
|
||||
R_PointToAngle2 = "fixed x, fixed y, fixed dest_x, fixed dest_y";
|
||||
R_PointToDist = "fixed x, fixed y";
|
||||
R_PointToDist2 = "fixed x, fixed y, fixed dest_x, fixed dest_y";
|
||||
R_PointInSubsector = "fixed x, fixed y";
|
||||
// r_things
|
||||
R_Char2Frame = "string char";
|
||||
R_Frame2Char = "int frame";
|
||||
R_SetPlayerSkin = "player_t player, int/string skin";
|
||||
// s_sound
|
||||
S_StartSound = "mobj_t origin, int soundnum, [player_t player]";
|
||||
S_StartSoundAtVolume = "mobj_t origin, int soundnum, int volume, [player_t player]";
|
||||
S_StopSound = "mobj_t origin";
|
||||
S_ChangeMusic = "int musicnum, [boolean looping?], [player_t player]";
|
||||
S_SpeedMusic = "fixed musicspeed, [player_t player]";
|
||||
S_StopMusic = "[player_t player]";
|
||||
S_OriginPlaying = "mobj_t origin";
|
||||
S_IdPlaying = "int soundnum";
|
||||
S_SoundPlaying = "mobj_t origin, int soundnum";
|
||||
// g_game
|
||||
G_BuildMapName = "int map";
|
||||
G_DoReborn = "int playernum";
|
||||
G_ExitLevel = "";
|
||||
G_IsSpecialStage = "int map";
|
||||
G_GametypeUsesLives = "";
|
||||
G_GametypeHasTeams = "";
|
||||
G_GametypeHasSpectators = "";
|
||||
G_RingSlingerGametype = "";
|
||||
G_PlatformGametype = "";
|
||||
G_TagGametype = "";
|
||||
G_TicsToHours = "int tics";
|
||||
G_TicsToMinutes = "int tics, [boolean full?]";
|
||||
G_TicsToSeconds = "int tics";
|
||||
G_TicsToCentiseconds = "int tics";
|
||||
G_TicsToMilliseconds = "int tics";
|
||||
// console
|
||||
COM_AddCommand = "string name, function(player_t player/[string arg/[...]]) fn, int flags";
|
||||
COM_BufAddText = "player_t player, string text";
|
||||
COM_BufInsertText = "player_t player, string text";
|
||||
CV_RegisterVar = "table{string name/string defaultvalue/int flags/PossibleValue pv/function() fn}, [...]";
|
||||
CONS_Printf = "player_t player, string text";
|
||||
// iterators
|
||||
players.iterate = "";
|
||||
thinkers.iterate = "string type";
|
||||
skins.iterate = "";
|
||||
sectors.iterate = "";
|
||||
subsectors.iterate = "";
|
||||
lines.iterate = "";
|
||||
sides.iterate = "";
|
||||
vertexes.iterate = "";
|
||||
hud.enable = "string huditem";
|
||||
hud.disable = "string huditem";
|
||||
hud.add = "function(drawer v/[player_t stplyr]), string type)";
|
||||
// technically these are a part of the video code but you can rename that whatever you want...
|
||||
draw = "int x, int y, patch patch, [int flags, [(unimplemented) colormap]]";
|
||||
drawScaled = "fixed x, fixed y, fixed scale, patch patch, [int flags, [(unimplemented) colormap]]";
|
||||
drawNum = "int x, int y, int num, [int flags]";
|
||||
drawPaddedNum = "int x, int y, int num, [int digits, [int flags]]";
|
||||
drawFill = "[int x, [int y, [int w, [int h, [int color]]]]]";
|
||||
drawString = "fixed x, fixed y, string str, [int flags, [string alignment]]";
|
||||
patchExists = "string name";
|
||||
cachePatch = "string name";
|
||||
stringWidth = "string string, [int flags, [string widthtype]]";
|
||||
// basic Lua
|
||||
assert = "boolean assert, [string errormsg]";
|
||||
collectgarbage = "[string opt, [string arg]]";
|
||||
error = "string message, [int level]";
|
||||
gcinfo = "(unknown)";
|
||||
getfenv = "function(*) fn";
|
||||
getmetatable = "object obj";
|
||||
ipairs = "table{} t";
|
||||
next = "table{} t, [int index]";
|
||||
pairs = "table{} t";
|
||||
pcall = "function(*) fn, [* arg, [...]]";
|
||||
rawequal = "* v1, * v2";
|
||||
rawget = "table{} t, * index";
|
||||
rawset = "table{} t, * index, * value";
|
||||
select = "* index";
|
||||
setfenv = "function(*) fn, table{} table";
|
||||
setmetatable = "table{} t, table{} metatable";
|
||||
tonumber = "* e, [int base]";
|
||||
tostring = "* e";
|
||||
type = "* v";
|
||||
unpack = "table{} list, [int start, [int end]]";
|
||||
xpcall = "function(?) call, function(boolean status) errortrap";
|
||||
coroutine.create = "function(?) fn";
|
||||
coroutine.resume = "coroutine co, [* val, [...]]";
|
||||
coroutine.running = "";
|
||||
coroutine.status = "coroutine co";
|
||||
coroutine.wrap = "function(?) fn";
|
||||
coroutine.yield = "[...]";
|
||||
string.byte = "string s, [int start, [int end]]";
|
||||
string.char = "[int charid, [...]]";
|
||||
string.dump = "function(?) fn";
|
||||
string.find = "string s, string pattern, [int start, [boolean plain?]]";
|
||||
string.format = "string formatstr, [...]";
|
||||
string.gfind = "string s, string pattern";
|
||||
string.gmatch = "string s, string pattern";
|
||||
string.gsub = "string s, string pattern, string replace, [int n]";
|
||||
string.len = "string s";
|
||||
string.lower = "string s";
|
||||
string.match = "string s, string pattern, [int n]";
|
||||
string.rep = "string s, int n";
|
||||
string.reverse = "string s, int start, [int end]";
|
||||
string.sub = "string s";
|
||||
string.upper = "string s";
|
||||
table.concat = "table{}, [string sep, [int start, [int end]]]";
|
||||
table.maxn = "table{}";
|
||||
table.insert = "table{}, * element";
|
||||
table.remove = "table{}, * key";
|
||||
table.sort = "table{}, [function(* element_a/* element_b) comp]";
|
||||
}
|
||||
|
||||
constants
|
||||
{
|
||||
valid;
|
||||
sprnames;
|
||||
states;
|
||||
mobjinfo;
|
||||
S_Sfx;
|
||||
sfxinfo;
|
||||
players;
|
||||
powers;
|
||||
skins;
|
||||
mapthings;
|
||||
vertexes;
|
||||
lines;
|
||||
sides;
|
||||
subsectors;
|
||||
sectors;
|
||||
sidenum;
|
||||
hudinfo;
|
||||
CV_OnOff;
|
||||
CV_YesNo;
|
||||
CV_Unsigned;
|
||||
CV_Natural;
|
||||
}
|
|
@ -87,6 +87,7 @@
|
|||
<Compile Include="Compilers\AccCompiler.cs" />
|
||||
<Compile Include="Compilers\NodesCompiler.cs" />
|
||||
<Compile Include="Config\ArgumentInfo.cs" />
|
||||
<Compile Include="Config\ScriptLumpInfo.cs" />
|
||||
<Compile Include="Config\MapLumpInfo.cs" />
|
||||
<Compile Include="Config\ScriptConfiguration.cs" />
|
||||
<Compile Include="Config\DefinedTextureSet.cs" />
|
||||
|
@ -134,6 +135,9 @@
|
|||
<Compile Include="Controls\ScriptFileDocumentTab.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\GlobalScriptLumpDocumentTab.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\ScriptLumpDocumentTab.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -99,6 +99,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
|
||||
// Map lumps
|
||||
private readonly Dictionary<string, MapLumpInfo> maplumps;
|
||||
//Global script lumps
|
||||
private readonly Dictionary<string, ScriptLumpInfo> scriptlumps;
|
||||
|
||||
//mxd. Map format
|
||||
private readonly bool doommapformat;
|
||||
|
@ -224,6 +226,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
|
||||
// Map lumps
|
||||
public Dictionary<string, MapLumpInfo> MapLumps { get { return maplumps; } }
|
||||
//Global script lumps
|
||||
public Dictionary<string, ScriptLumpInfo> ScriptLumps { get { return scriptlumps; } }
|
||||
|
||||
//mxd. Map format
|
||||
public bool UDMF { get { return universalmapformat; } }
|
||||
|
@ -317,6 +321,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
this.texturesets = new List<DefinedTextureSet>();
|
||||
this.makedoorargs = new int[Linedef.NUM_ARGS];
|
||||
this.maplumps = new Dictionary<string, MapLumpInfo>(StringComparer.Ordinal);
|
||||
this.scriptlumps = new Dictionary<string, ScriptLumpInfo>(StringComparer.Ordinal);
|
||||
this.thingflagstranslation = new List<FlagTranslation>();
|
||||
this.linedefflagstranslation = new List<FlagTranslation>();
|
||||
this.thingfilters = new List<ThingsFilter>();
|
||||
|
@ -407,6 +412,8 @@ namespace CodeImp.DoomBuilder.Config
|
|||
|
||||
// Map lumps
|
||||
LoadMapLumps();
|
||||
//Global script lumps
|
||||
LoadScriptLumps();
|
||||
|
||||
// Skills
|
||||
LoadSkills();
|
||||
|
@ -485,6 +492,19 @@ namespace CodeImp.DoomBuilder.Config
|
|||
}
|
||||
}
|
||||
|
||||
// This loads the script lumps
|
||||
private void LoadScriptLumps()
|
||||
{
|
||||
// Get script lumps list
|
||||
IDictionary dic = cfg.ReadSetting("scriptlumpnames", new Hashtable());
|
||||
foreach (DictionaryEntry de in dic)
|
||||
{
|
||||
// Make script lumps
|
||||
ScriptLumpInfo lumpinfo = new ScriptLumpInfo(de.Key.ToString(), cfg);
|
||||
scriptlumps.Add(de.Key.ToString(), lumpinfo);
|
||||
}
|
||||
}
|
||||
|
||||
// This loads the enumerations
|
||||
private void LoadEnums()
|
||||
{
|
||||
|
|
56
Source/Core/Config/ScriptLumpInfo.cs
Normal file
56
Source/Core/Config/ScriptLumpInfo.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
|
||||
#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 CodeImp.DoomBuilder.IO;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Config
|
||||
{
|
||||
public struct ScriptLumpInfo
|
||||
{
|
||||
// Members
|
||||
public readonly string Name;
|
||||
public readonly bool IsPrefix;
|
||||
internal readonly ScriptConfiguration Script;
|
||||
|
||||
// Construct from IDictionary
|
||||
internal ScriptLumpInfo(string name, Configuration cfg)
|
||||
{
|
||||
// Apply settings
|
||||
this.Name = name;
|
||||
this.Script = this.Script = new ScriptConfiguration();
|
||||
this.IsPrefix = cfg.ReadSetting("scriptlumpnames." + name + ".isprefix", false);
|
||||
string scriptconfig = cfg.ReadSetting("scriptlumpnames." + name + ".script", "");
|
||||
|
||||
// Find script configuration
|
||||
if(scriptconfig.Length > 0)
|
||||
{
|
||||
if(General.ScriptConfigs.ContainsKey(scriptconfig.ToLowerInvariant()))
|
||||
{
|
||||
this.Script = General.ScriptConfigs[scriptconfig.ToLowerInvariant()];
|
||||
}
|
||||
else
|
||||
{
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Script lump '" + name + "' in the current game configuration specifies an unknown script configuration '" + scriptconfig + "'. Using plain text instead.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
150
Source/Core/Controls/GlobalScriptLumpDocumentTab.cs
Normal file
150
Source/Core/Controls/GlobalScriptLumpDocumentTab.cs
Normal file
|
@ -0,0 +1,150 @@
|
|||
|
||||
#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.Collections.Generic;
|
||||
using System.IO;
|
||||
using CodeImp.DoomBuilder.Compilers;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Controls
|
||||
{
|
||||
internal sealed class GlobalScriptLumpDocumentTab : ScriptDocumentTab
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
private readonly string lumpname;
|
||||
private readonly string filepath;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public override bool ExplicitSave { get { return true; } }
|
||||
public override bool IsSaveAsRequired { get { return false; } }
|
||||
public override bool IsClosable { get { return false; } }
|
||||
public override bool IsReconfigurable { get { return false; } }
|
||||
public override string Filename { get { return lumpname; } } //mxd
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public GlobalScriptLumpDocumentTab(ScriptEditorPanel panel, string lumpname, ScriptConfiguration config, string filepath) : base(panel)
|
||||
{
|
||||
this.lumpname = lumpname;
|
||||
this.filepath = filepath;
|
||||
this.config = config;
|
||||
editor.SetupStyles(config);
|
||||
|
||||
// Load the lump data
|
||||
WAD file = new WAD(filepath);
|
||||
Lump lump = file.FindLump(lumpname);
|
||||
if (lump != null)
|
||||
{
|
||||
ClippedStream stream = lump.Stream;
|
||||
if (stream != null)
|
||||
{
|
||||
editor.SetText(stream.ReadAllBytes());
|
||||
editor.ClearUndoRedo();
|
||||
UpdateNavigator();
|
||||
}
|
||||
}
|
||||
file.Dispose();
|
||||
|
||||
// Set title
|
||||
SetTitle(lumpname.ToUpper());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// Compile script
|
||||
public override void Compile()
|
||||
{
|
||||
//mxd. List of errors. UpdateScriptNames can return errors and also updates acs includes list
|
||||
List<CompilerError> errors = (config.ScriptType == ScriptType.ACS ? General.Map.UpdateScriptNames() : new List<CompilerError>());
|
||||
|
||||
//mxd. Errors already?..
|
||||
if(errors.Count > 0)
|
||||
{
|
||||
// Feed errors to panel
|
||||
panel.ShowErrors(errors);
|
||||
return;
|
||||
}
|
||||
|
||||
// Compile
|
||||
General.Map.CompileLump(lumpname, true);
|
||||
|
||||
//mxd. Update script navigator
|
||||
UpdateNavigator();
|
||||
|
||||
// Feed errors to panel
|
||||
panel.ShowErrors(General.Map.Errors);
|
||||
}
|
||||
|
||||
// Implicit save
|
||||
public override bool Save()
|
||||
{
|
||||
if (!IsChanged) return true;
|
||||
|
||||
// Store the lump data
|
||||
MemoryStream stream = new MemoryStream(editor.GetText());
|
||||
WAD file = new WAD(filepath);
|
||||
int insertindex = file.Lumps.Count;
|
||||
|
||||
// Remove the lump if it already exists
|
||||
int li = file.FindLumpIndex(lumpname);
|
||||
if (li > -1)
|
||||
{
|
||||
insertindex = li;
|
||||
file.RemoveAt(li);
|
||||
}
|
||||
|
||||
// Insert new lump
|
||||
Lump l = file.Insert(lumpname, insertindex, (int)stream.Length);
|
||||
l.Stream.Seek(0, SeekOrigin.Begin);
|
||||
stream.WriteTo(l.Stream);
|
||||
file.Dispose();
|
||||
|
||||
editor.SetSavePoint(); //mxd
|
||||
UpdateTitle(); //mxd
|
||||
return true;
|
||||
}
|
||||
|
||||
// This checks if a script error applies to this script
|
||||
public override bool VerifyErrorForScript(CompilerError e)
|
||||
{
|
||||
return (string.Compare(e.filename, "?" + lumpname, true) == 0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Events
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ using CodeImp.DoomBuilder.Compilers;
|
|||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Windows;
|
||||
using ScintillaNET;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -134,6 +135,40 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
tabs.TabPages.Add(t);
|
||||
}
|
||||
}
|
||||
if (General.Map.FilePathName != "")
|
||||
{
|
||||
WAD file = new WAD(General.Map.FilePathName);
|
||||
List<Lump> lumps = file.Lumps;
|
||||
file.Dispose();
|
||||
|
||||
//Load the global script lumps
|
||||
foreach (ScriptLumpInfo scriptlumpinfo in General.Map.Config.ScriptLumps.Values)
|
||||
{
|
||||
if (scriptlumpinfo.Script != null)
|
||||
{
|
||||
if (scriptlumpinfo.IsPrefix)
|
||||
{
|
||||
foreach (Lump l in lumps)
|
||||
{
|
||||
if (l.Name.ToUpperInvariant().StartsWith(scriptlumpinfo.Name.ToUpperInvariant()))
|
||||
{
|
||||
GlobalScriptLumpDocumentTab t = new GlobalScriptLumpDocumentTab(this, l.Name, scriptlumpinfo.Script, General.Map.FilePathName);
|
||||
t.OnTextChanged += tabpage_OnTextChanged;
|
||||
t.Scintilla.UpdateUI += scintilla_OnUpdateUI;
|
||||
tabs.TabPages.Add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalScriptLumpDocumentTab t = new GlobalScriptLumpDocumentTab(this, scriptlumpinfo.Name, scriptlumpinfo.Script, General.Map.FilePathName);
|
||||
t.OnTextChanged += tabpage_OnTextChanged;
|
||||
t.Scintilla.UpdateUI += scintilla_OnUpdateUI;
|
||||
tabs.TabPages.Add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load the files that were previously opened for this map
|
||||
foreach (String filename in General.Map.Options.ScriptFiles)
|
||||
|
@ -147,7 +182,8 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
}
|
||||
|
||||
//mxd. Select "Scripts" tab, because that's what user will want 99% of time
|
||||
int scriptsindex = GetTabPageIndex("SCRIPTS");
|
||||
//MascaraSnake: For SRB2, select "MAINCFG" tab
|
||||
int scriptsindex = General.Map.SRB2 ? GetTabPageIndex("MAINCFG") : GetTabPageIndex("SCRIPTS");
|
||||
tabs.SelectedIndex = (scriptsindex == -1 ? 0 : scriptsindex);
|
||||
|
||||
//mxd. Apply quick search settings
|
||||
|
|
|
@ -57,6 +57,24 @@ lexer6 // Perl-style
|
|||
constantsindex = -1;
|
||||
}
|
||||
|
||||
lexer15 // Lua-style
|
||||
{
|
||||
10 = 0; // operator -> plain text
|
||||
11 = 0; // identifier -> plain text
|
||||
1 = 3; // comments
|
||||
2 = 3; // comments
|
||||
3 = 3; // comments
|
||||
5 = 1; // keywords
|
||||
4 = 4; // literal
|
||||
7 = 4; // literal
|
||||
8 = 4; // literal
|
||||
6 = 6; // strings
|
||||
9 = 7; // includes
|
||||
|
||||
keywordsindex = 0;
|
||||
constantsindex = 1;
|
||||
snippetindex = 2;
|
||||
}
|
||||
|
||||
lexer18 // Pascal-style
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue