--- a/hedgewars/CMakeLists.txt Tue Nov 18 23:39:30 2014 +0300
+++ b/hedgewars/CMakeLists.txt Wed Nov 19 00:38:14 2014 +0300
@@ -100,12 +100,13 @@
uGearsUtils.pas
uTeams.pas
- uFLIPC.pas
- uFLTypes.pas
+ uFLData.pas
uFLGameConfig.pas
+ uFLIPC.pas
+ uFLScripts.pas
uFLTeams.pas
+ uFLTypes.pas
uFLUtils.pas
- uFLData.pas
#these interact with everything, so compile last
uScript.pas
--- a/hedgewars/hwLibrary.pas Tue Nov 18 23:39:30 2014 +0300
+++ b/hedgewars/hwLibrary.pas Wed Nov 19 00:38:14 2014 +0300
@@ -44,6 +44,7 @@
, uPhysFSLayer
, uFLData
, uFLTeams
+ , uFLScripts
;
{$INCLUDE "config.inc"}
@@ -158,6 +159,7 @@
getThemesList,
freeThemesList,
getThemeIcon,
+ getScriptsList,
getTeamsList,
tryAddTeam,
tryRemoveTeam,
--- a/hedgewars/uFLScripts.pas Tue Nov 18 23:39:30 2014 +0300
+++ b/hedgewars/uFLScripts.pas Wed Nov 19 00:38:14 2014 +0300
@@ -21,20 +21,30 @@
scriptsNumber: Longword;
listOfScriptNames: array[0..MAX_SCRIPT_NAMES] of PChar;
-procedure loadScript(var script: TScript; fileName: shortstring);
+procedure loadScript(var script: TScript; scriptName, fileName: shortstring);
var f: PFSFile;
- section: LongInt;
- l: shortstring;
begin
- section:= -1;
- f:= pfsOpenRead(fileName);
+ underScore2Space(scriptName);
+ script.scriptName:= scriptName;
+ script.description:= scriptName + ' script description';
- while (not pfsEOF(f)) do
+ f:= pfsOpenRead(copy(fileName, 1, length(fileName) - 4) + '.txt');
+
+ script.gameScheme:= '';
+ script.weapons:= '';
+
+ if f <> nil then
begin
- pfsReadLn(f, l);
- end;
+ if not pfsEOF(f) then
+ begin
+ pfsReadLn(f, script.gameScheme);
- pfsClose(f)
+ if not pfsEOF(f) then
+ pfsReadLn(f, script.weapons);
+ end;
+
+ pfsClose(f)
+ end
end;
procedure loadScripts;
@@ -66,7 +76,7 @@
l:= length(s);
if (l > 4) and (copy(s, l - 3, 4) = '.lua') then
begin
- loadScript(script^, '/Config/Scripts/' + s);
+ loadScript(script^, copy(s, 1, l - 4), '/Config/Scripts/' + s);
inc(script)
end;
inc(tmp)
--- a/hedgewars/uFLTeams.pas Tue Nov 18 23:39:30 2014 +0300
+++ b/hedgewars/uFLTeams.pas Wed Nov 19 00:38:14 2014 +0300
@@ -106,7 +106,6 @@
while tmp^ <> nil do
begin
s:= shortstring(tmp^);
- writeln(stderr, '> ', s);
l:= length(s);
if (l > 4) and (copy(s, l - 3, 4) = '.hwt') then inc(teamsNumber);
inc(tmp)
--- a/hedgewars/uFLUtils.pas Tue Nov 18 23:39:30 2014 +0300
+++ b/hedgewars/uFLUtils.pas Wed Nov 19 00:38:14 2014 +0300
@@ -4,6 +4,7 @@
function str2PChar(const s: shortstring): PChar;
function intToStr(n: LongInt): shortstring;
function midStr(s: shortstring; pos: byte): shortstring;
+procedure underScore2Space(var s: shortstring);
implementation
@@ -31,4 +32,11 @@
midStr:= copy(s, pos, length(s) - pos + 1)
end;
+procedure underScore2Space(var s: shortstring);
+var i: LongInt;
+begin
+ for i:= length(s) downto 1 do
+ if s[i] = '_' then s[i]:= ' '
+end;
+
end.
--- a/qmlFrontend/flib.h Tue Nov 18 23:39:30 2014 +0300
+++ b/qmlFrontend/flib.h Wed Nov 19 00:38:14 2014 +0300
@@ -43,6 +43,8 @@
typedef void freeThemesList_t(char **list);
typedef uint32_t getThemeIcon_t(char * theme, char * buffer, uint32_t size);
+typedef char **getScriptsList_t();
+
typedef char **getTeamsList_t();
typedef void tryAddTeam_t(const char * teamName);
typedef void tryRemoveTeam_t(const char * teamName);
--- a/qmlFrontend/hwengine.cpp Tue Nov 18 23:39:30 2014 +0300
+++ b/qmlFrontend/hwengine.cpp Wed Nov 19 00:38:14 2014 +0300
@@ -23,6 +23,7 @@
getThemesList_t *flibGetThemesList;
freeThemesList_t *flibFreeThemesList;
getThemeIcon_t *flibGetThemeIcon;
+ getScriptsList_t *flibGetScriptsList;
getTeamsList_t *flibGetTeamsList;
tryAddTeam_t * flibTryAddTeam;
tryRemoveTeam_t * flibTryRemoveTeam;
@@ -57,6 +58,8 @@
flibFreeThemesList = (freeThemesList_t*) hwlib.resolve("freeThemesList");
flibGetThemeIcon = (getThemeIcon_t*) hwlib.resolve("getThemeIcon");
+ flibGetScriptsList = (getScriptsList_t*) hwlib.resolve("getScriptsList");
+
flibResetGameConfig = (resetGameConfig_t*) hwlib.resolve("resetGameConfig");
flibGetTeamsList = (getTeamsList_t*) hwlib.resolve("getTeamsList");
flibTryAddTeam = (tryAddTeam_t*) hwlib.resolve("tryAddTeam");