tsdima писал(а): Не нашёл в исходниках обработку параметров командной строки. У тебя, видимо, какой-то свой hico.cpp
В репозитории нет этого модуля.
tsdima писал(а): Где брать?
Для пакета Windows:
<?php
$sdb = new SQLite3("<путь к пакету>/elements.db"); $result = $sdb->query("SELECT * FROM groups ORDER BY pos ASC");
function specchar($text) { return preg_replace("#\"#i", "\\\\\"", preg_replace("#\\\\#i", "\\\\\\", iconv("windows-1251", "utf-8", $text))); }
$grounpIndex = 0;
function loadConf($tab, $name) { global $json, $lang, $grounpIndex; if($name == "VisualStrings") { $json .= " \"$name\": { \"tab\": \"Tools\" },\n"; return; } $conf = @file_get_contents("<путь к пакету>/conf/$name.ini"); if($conf) { $lines = preg_split("#\r\n#", $conf); if($name == "EditMulti" || $name == "MRA_Wire") $tab = "";
$json .= " \"$name\": {\n"; $json .= " \"tab\": \"$tab\"";
$section = 0; $props = ""; $mt = ""; $group = ""; foreach ($lines as $line) { if($line == "[About]") { $section = 0; } else if($line == "[Type]") { $section = 1; } else if($line == "[Property]") { $section = 2; } else if($line == "[Methods]") { $section = 3; } else if($line == "[Edit]") { $section = 4; } else if ($line) { $pars = preg_split("#=#", $line, 2); if($section == 1) { if($pars[0] == "Class") { $class = $pars[1]; if($class == "EditMulti") $class = "MultiElementEditor"; if($class == "EditMultiEx") $class = "MultiElementEditorEx"; if($class == "MultiElementEditor" || $class == "MultiElementEditorEx") { $json .= ",\n \"sys\": [\n"; $json .= ' { "name": "VOffset", "type": 1, "def": 0 }, { "name": "HOffset", "type": 1, "def": 0 }, { "name": "Color", "def": "#969696" }, { "name": "Width", "type": 1, "def": 300 }, { "name": "Height", "type": 1, "def": 200 }'; $json .= "\n ]"; } if($class == "Cable") $class .= "Element"; if($class != "Element") $json .= ",\n \"class\": \"$class\""; } else if($pars[0] == "Sub") { $sub = $pars[1]; $json .= ",\n \"sub\": \"$sub\""; } else if($pars[0] == "Inherit") { $sub = $pars[1]; $json .= ",\n \"inherit\": \"$sub\""; } else if($pars[0] == "Interfaces") { $sub = $pars[1]; $json .= ",\n \"interfaces\": \"$sub\""; } } else if($section == 2) { if(count($pars) > 1) { if($pars[0][0] == "#") { $group = substr($pars[0], 2); continue; } if($props) $props .= ",\n"; $args = preg_split("#\|#", preg_replace("#\\|\\|#i", "/", $pars[1])); $type = ""; $list = ""; $def = ""; if(count($args) > 1) { if(trim($args[1])) $type = ", \"type\": $args[1]"; if(count($args) > 2) $def = ", \"def\": ".(is_numeric($args[2]) ? $args[2] : "\"".preg_replace("#\\\\#i", "\\\\\\", $args[2])."\""); if(count($args) > 3) $list = ", \"list\": \"$args[3]\"";
if(!$def && $args[1] == 3) $def = ", \"def\": \"\""; } else {
} $pname = $pars[0]; $flags = 0; if($pname[0] == "+") { $pname = substr($pname, 1); $flags |= 0x1; } if($pname[0] == "@") { $pname = substr($pname, 1); $flags |= 0x2; } $pflags = $flags ? ", \"flags\": $flags" : ""; $pgroup = $group ? ", \"group\": \"$group\"" : ""; $props .= " { \"name\": \"$pname\"$type$def$list$pgroup$pflags }"; } else { if($pars[0] == "##") $group = ""; } } else if($section == 3) { if(count($pars) > 1) { if($mt) $mt .= ",\n"; $args = preg_split("#\|#", preg_replace("#\\|\\|#i", "/", $pars[1])); $type = ""; $data = ""; $flags = ""; $pname = $pars[0]; if($pname[0] == "*") { $pname = substr($pname, 1); $flags = ", \"flags\": 1"; } if(count($args) > 1) { $type = ", \"type\": $args[1]"; //$data = ", \"def\": ".(is_numeric($args[2]) ? $args[2] : "\"".preg_replace("#\\\\#i", "\\\\\\", $args[2])."\""); } else {
} $pparts = preg_split("#%#", $pname); $mt .= " { \"name\": \"$pparts[0]\"$type$data$flags }"; $lang .= ",\n \"$name.$pname\": \"".specchar($args[0])."\""; } } } }
if($props) $json .= ",\n \"props\": [\n$props\n ]"; if($mt) $json .= ",\n \"points\": [\n$mt\n ]";
$json .= "\n },\n"; } }
$lang = "{";
$json = "{\n"; $json .= " \"element\": {},\n";
while ($arr = $result->fetchArray()) { if($arr['name']) { if($lang != "{") $lang .= ","; $lang .= "\n \"tab.$arr[name]\": \"".iconv("windows-1251", "utf-8", $arr['info'])."\""; } $res = $sdb->query("SELECT * FROM elements WHERE tab = ".$arr['id']." ORDER BY pos ASC"); $tab = $arr['name']; if(!$tab) $tab = "*"; while ($e = $res->fetchArray()) { if($e['name'][0] == "*") { $name = iconv("windows-1251", "utf-8", $e['name']); $pars = preg_split("#_#", $name); if(count($pars) == 2) $name = $pars[1]; $group = "group$grounpIndex"; $json .= " \"$group\": { \"tab\": \"$tab\", \"group\": true },\n"; $lang .= ",\n \"group.$group\": \"".$name."\""; $grounpIndex++; } else { $name = $e['name']; if(substr($name, 0, 3) == "Gl_") $name[1] = "L"; $lang .= ",\n \"el.$name\": \"".iconv("windows-1251", "utf-8", preg_replace("#\\\\#i", "\\\\\\", $e['info']))."\""; loadConf($tab, $name); } } }
$arr = array("ImgDrawPoint", "ImgDrawXY", "WinControl", "WinSplitter", "WinLayout", "WinRushControl", "EditMultiEx", "PlotSeries", "Sprite", "XPMenu", "PrintControl"); foreach ($arr as $value) { loadConf("", $value); }
$json .= ' "design": {}, "InfoTip": {}, "LinkTip": {}, "PictureTip": {}, "spheme": {}, "HubEx": {}, "GetDataEx": {}, "LineBreak": {}, "LineBreakEx": {}, "PointHint": {} '; $json .= "}";
$lang .= "\n}";
echo $json;
file_put_contents("<путь к пакету hion>/elements.json", $json); file_put_contents("<путь к пакету hion>/lang/ru.json", $lang);
$sdb->close();
|