Changeset 340 for tools/dbc_export
- Timestamp:
- Feb 27, 2010, 6:25:07 PM (15 years ago)
- Location:
- tools/dbc_export
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/dbc_export/DBCExport.lpi
r339 r340 2 2 <CONFIG> 3 3 <ProjectOptions> 4 <PathDelim Value="/"/> 4 5 <Version Value="7"/> 5 6 <General> … … 16 17 <Language Value=""/> 17 18 <CharSet Value=""/> 18 <StringTable Comments="" CompanyName="" FileDescription="" FileVersion="0.0.0.0" InternalName="" LegalCopyright="" LegalTrademarks="" OriginalFilename="" ProductName="" ProductVersion=""/>19 19 </VersionInfo> 20 20 <PublishOptions> … … 27 27 <local> 28 28 <FormatVersion Value="1"/> 29 <CommandLineParams Value="-f ../../../trunk/source/3.3.0/dbc/GameTips.dbc -n test.dbc -c usuuuuuuuuuuuuuuuu -q "SELECT T.entry as entry,T.Text as text0 FROM (SELECT * FROM gametips WHERE (Complete = 1) AND ((Language = 1)) AND (User IN (459,670,602,462,1,400,638,592,624,610,769,331,131,704,2,499,641,660,578,337,304,277,208,613,768,754,590,606,26,618,739,503,601,607,585,596,765,320,547,687)) AND VersionStart <= 9947 AND VersionEnd >= 9947) AS T GROUP BY T.entry""/> 29 30 <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> 30 31 </local> … … 35 36 <IsPartOfProject Value="True"/> 36 37 <UnitName Value="DBCExport"/> 37 <CursorPos X="1" Y=" 35"/>38 <TopLine Value=" 22"/>38 <CursorPos X="1" Y="200"/> 39 <TopLine Value="180"/> 39 40 <EditorIndex Value="0"/> 40 <UsageCount Value=" 39"/>41 <UsageCount Value="45"/> 41 42 <Loaded Value="True"/> 42 43 <SyntaxHighlighter Value="Delphi"/> … … 47 48 <CursorPos X="1" Y="1"/> 48 49 <TopLine Value="1"/> 49 <UsageCount Value="2 8"/>50 <UsageCount Value="27"/> 50 51 <SyntaxHighlighter Value="Delphi"/> 51 52 </Unit1> … … 54 55 <CursorPos X="14" Y="719"/> 55 56 <TopLine Value="703"/> 56 <UsageCount Value="1 4"/>57 <UsageCount Value="13"/> 57 58 </Unit2> 58 59 <Unit3> … … 60 61 <CursorPos X="23" Y="36"/> 61 62 <TopLine Value="33"/> 62 <UsageCount Value="1 3"/>63 <UsageCount Value="12"/> 63 64 </Unit3> 64 65 <Unit4> … … 67 68 <CursorPos X="1" Y="1"/> 68 69 <TopLine Value="1"/> 69 <UsageCount Value="2 8"/>70 <UsageCount Value="27"/> 70 71 <SyntaxHighlighter Value="Delphi"/> 71 72 </Unit4> … … 74 75 <CursorPos X="24" Y="6"/> 75 76 <TopLine Value="1"/> 76 <UsageCount Value=" 8"/>77 <UsageCount Value="7"/> 77 78 <SyntaxHighlighter Value="None"/> 78 79 </Unit5> … … 82 83 <CursorPos X="3" Y="166"/> 83 84 <TopLine Value="164"/> 84 <UsageCount Value=" 9"/>85 <UsageCount Value="8"/> 85 86 </Unit6> 86 87 <Unit7> … … 88 89 <CursorPos X="22" Y="196"/> 89 90 <TopLine Value="184"/> 90 <UsageCount Value="1 1"/>91 <UsageCount Value="10"/> 91 92 </Unit7> 92 93 <Unit8> … … 95 96 <CursorPos X="12" Y="100"/> 96 97 <TopLine Value="66"/> 97 <UsageCount Value="1 1"/>98 <UsageCount Value="10"/> 98 99 </Unit8> 99 100 <Unit9> … … 101 102 <CursorPos X="1" Y="1"/> 102 103 <TopLine Value="51"/> 103 <UsageCount Value="1 1"/>104 <UsageCount Value="10"/> 104 105 </Unit9> 105 106 <Unit10> … … 108 109 <CursorPos X="9" Y="79"/> 109 110 <TopLine Value="51"/> 110 <UsageCount Value=" 10"/>111 <UsageCount Value="9"/> 111 112 </Unit10> 112 113 <Unit11> … … 114 115 <IsPartOfProject Value="True"/> 115 116 <UnitName Value="USqlDatabase"/> 116 <CursorPos X="1 " Y="1"/>117 <TopLine Value=" 71"/>118 <EditorIndex Value=" 4"/>119 <UsageCount Value="3 0"/>117 <CursorPos X="14" Y="34"/> 118 <TopLine Value="16"/> 119 <EditorIndex Value="3"/> 120 <UsageCount Value="36"/> 120 121 <Loaded Value="True"/> 121 122 <SyntaxHighlighter Value="Delphi"/> … … 125 126 <IsPartOfProject Value="True"/> 126 127 <UnitName Value="UDBC"/> 127 <CursorPos X=" 21" Y="54"/>128 <TopLine Value=" 60"/>129 <EditorIndex Value=" 2"/>130 <UsageCount Value="3 0"/>128 <CursorPos X="1" Y="130"/> 129 <TopLine Value="116"/> 130 <EditorIndex Value="1"/> 131 <UsageCount Value="36"/> 131 132 <Loaded Value="True"/> 132 133 <SyntaxHighlighter Value="Delphi"/> … … 135 136 <Filename Value="ReadMe.txt"/> 136 137 <IsPartOfProject Value="True"/> 137 <CursorPos X=" 1" Y="8"/>138 <CursorPos X="51" Y="8"/> 138 139 <TopLine Value="1"/> 139 <EditorIndex Value=" 3"/>140 <UsageCount Value="3 0"/>140 <EditorIndex Value="2"/> 141 <UsageCount Value="36"/> 141 142 <Loaded Value="True"/> 142 143 <SyntaxHighlighter Value="None"/> 143 144 </Unit13> 144 145 <Unit14> 145 <Filename Value=" /usr/share/fpcsrc/packages/fcl-base/src/custapp.pp"/>146 <Filename Value="../../../../../usr/share/fpcsrc/packages/fcl-base/src/custapp.pp"/> 146 147 <UnitName Value="CustApp"/> 147 <CursorPos X="1" Y="63"/> 148 <TopLine Value="47"/> 149 <EditorIndex Value="1"/> 148 <CursorPos X="15" Y="42"/> 149 <TopLine Value="28"/> 150 150 <UsageCount Value="15"/> 151 <Loaded Value="True"/>152 151 </Unit14> 153 152 </Units> 154 <JumpHistory Count=" 22" HistoryIndex="21">153 <JumpHistory Count="30" HistoryIndex="29"> 155 154 <Position1> 156 <Filename Value=" UDBC.pas"/>157 <Caret Line="1 " Column="1" TopLine="1"/>155 <Filename Value="DBCExport.pas"/> 156 <Caret Line="188" Column="1" TopLine="174"/> 158 157 </Position1> 159 158 <Position2> 160 159 <Filename Value="DBCExport.pas"/> 161 <Caret Line="1 1" Column="21" TopLine="1"/>160 <Caret Line="189" Column="1" TopLine="175"/> 162 161 </Position2> 163 162 <Position3> 164 163 <Filename Value="DBCExport.pas"/> 165 <Caret Line="1 00" Column="22" TopLine="72"/>164 <Caret Line="190" Column="1" TopLine="176"/> 166 165 </Position3> 167 166 <Position4> 168 167 <Filename Value="DBCExport.pas"/> 169 <Caret Line=" 71" Column="3" TopLine="55"/>168 <Caret Line="191" Column="1" TopLine="177"/> 170 169 </Position4> 171 170 <Position5> 172 <Filename Value=" UDBC.pas"/>173 <Caret Line="1 " Column="10" TopLine="1"/>171 <Filename Value="DBCExport.pas"/> 172 <Caret Line="192" Column="1" TopLine="178"/> 174 173 </Position5> 175 174 <Position6> 176 <Filename Value=" UDBC.pas"/>177 <Caret Line=" 8" Column="29" TopLine="1"/>175 <Filename Value="DBCExport.pas"/> 176 <Caret Line="193" Column="1" TopLine="179"/> 178 177 </Position6> 179 178 <Position7> 180 179 <Filename Value="DBCExport.pas"/> 181 <Caret Line="1 5" Column="38" TopLine="8"/>180 <Caret Line="194" Column="1" TopLine="180"/> 182 181 </Position7> 183 182 <Position8> 184 183 <Filename Value="DBCExport.pas"/> 185 <Caret Line=" 46" Column="12" TopLine="35"/>184 <Caret Line="188" Column="1" TopLine="174"/> 186 185 </Position8> 187 186 <Position9> 188 187 <Filename Value="DBCExport.pas"/> 189 <Caret Line=" 64" Column="1" TopLine="46"/>188 <Caret Line="83" Column="1" TopLine="69"/> 190 189 </Position9> 191 190 <Position10> 192 191 <Filename Value="DBCExport.pas"/> 193 <Caret Line=" 62" Column="52" TopLine="46"/>192 <Caret Line="186" Column="20" TopLine="166"/> 194 193 </Position10> 195 194 <Position11> 196 195 <Filename Value="DBCExport.pas"/> 197 <Caret Line=" 103" Column="33" TopLine="87"/>196 <Caret Line="83" Column="1" TopLine="69"/> 198 197 </Position11> 199 198 <Position12> 200 199 <Filename Value="DBCExport.pas"/> 201 <Caret Line="1 02" Column="10" TopLine="81"/>200 <Caret Line="186" Column="19" TopLine="166"/> 202 201 </Position12> 203 202 <Position13> 204 203 <Filename Value="DBCExport.pas"/> 205 <Caret Line=" 19" Column="13" TopLine="3"/>204 <Caret Line="83" Column="1" TopLine="69"/> 206 205 </Position13> 207 206 <Position14> 208 207 <Filename Value="DBCExport.pas"/> 209 <Caret Line="1 03" Column="33" TopLine="87"/>208 <Caret Line="180" Column="1" TopLine="166"/> 210 209 </Position14> 211 210 <Position15> 212 211 <Filename Value="DBCExport.pas"/> 213 <Caret Line=" 47" Column="31" TopLine="27"/>212 <Caret Line="186" Column="20" TopLine="174"/> 214 213 </Position15> 215 214 <Position16> 216 215 <Filename Value="DBCExport.pas"/> 217 <Caret Line=" 35" Column="22" TopLine="27"/>216 <Caret Line="82" Column="1" TopLine="69"/> 218 217 </Position16> 219 218 <Position17> 220 219 <Filename Value="DBCExport.pas"/> 221 <Caret Line=" 50" Column="37" TopLine="37"/>220 <Caret Line="188" Column="1" TopLine="166"/> 222 221 </Position17> 223 222 <Position18> 224 223 <Filename Value="DBCExport.pas"/> 225 <Caret Line="1 12" Column="13" TopLine="100"/>224 <Caret Line="187" Column="73" TopLine="173"/> 226 225 </Position18> 227 226 <Position19> 228 227 <Filename Value="DBCExport.pas"/> 229 <Caret Line="1 13" Column="5" TopLine="107"/>228 <Caret Line="188" Column="1" TopLine="174"/> 230 229 </Position19> 231 230 <Position20> 232 231 <Filename Value="DBCExport.pas"/> 233 <Caret Line=" 60" Column="61" TopLine="44"/>232 <Caret Line="186" Column="20" TopLine="174"/> 234 233 </Position20> 235 234 <Position21> 236 235 <Filename Value="DBCExport.pas"/> 237 <Caret Line="1 23" Column="36" TopLine="107"/>236 <Caret Line="188" Column="41" TopLine="173"/> 238 237 </Position21> 239 238 <Position22> 240 239 <Filename Value="DBCExport.pas"/> 241 <Caret Line=" 34" Column="3" TopLine="18"/>240 <Caret Line="187" Column="1" TopLine="173"/> 242 241 </Position22> 242 <Position23> 243 <Filename Value="DBCExport.pas"/> 244 <Caret Line="188" Column="1" TopLine="174"/> 245 </Position23> 246 <Position24> 247 <Filename Value="DBCExport.pas"/> 248 <Caret Line="189" Column="1" TopLine="175"/> 249 </Position24> 250 <Position25> 251 <Filename Value="DBCExport.pas"/> 252 <Caret Line="188" Column="32" TopLine="176"/> 253 </Position25> 254 <Position26> 255 <Filename Value="DBCExport.pas"/> 256 <Caret Line="190" Column="28" TopLine="176"/> 257 </Position26> 258 <Position27> 259 <Filename Value="DBCExport.pas"/> 260 <Caret Line="187" Column="1" TopLine="173"/> 261 </Position27> 262 <Position28> 263 <Filename Value="DBCExport.pas"/> 264 <Caret Line="188" Column="1" TopLine="174"/> 265 </Position28> 266 <Position29> 267 <Filename Value="DBCExport.pas"/> 268 <Caret Line="189" Column="1" TopLine="175"/> 269 </Position29> 270 <Position30> 271 <Filename Value="DBCExport.pas"/> 272 <Caret Line="190" Column="1" TopLine="176"/> 273 </Position30> 243 274 </JumpHistory> 244 275 </ProjectOptions> … … 253 284 <SyntaxOptions> 254 285 <SyntaxMode Value="Delphi"/> 286 <CStyleOperator Value="False"/> 255 287 </SyntaxOptions> 256 288 </Parsing> -
tools/dbc_export/DBCExport.pas
r339 r340 24 24 NewDBCFileName: string; 25 25 ColumnTypeDefinition: string; 26 SQLquery: string; 26 27 DisplayData: Boolean; 27 28 constructor Create(TheOwner: TComponent); override; … … 29 30 procedure WriteHelp; virtual; 30 31 procedure ShowDBC; 32 procedure LoadDBC; 33 procedure SaveDBC; 34 procedure ReplaceText; 35 function GetIDbyEntry(entry: integer; var DBRows: TDBRows): integer; 31 36 end; 32 37 … … 69 74 Database.Hostname := GetOptionValue('t', 'host'); 70 75 end else Database.Hostname := 'localhost'; 76 if HasOption('q', 'sql_query') then begin 77 SQLquery := GetOptionValue('q', 'sql_query'); 78 end; 71 79 end; 72 80 … … 74 82 begin 75 83 ParseParameters; 84 85 LoadDBC; 86 76 87 ShowDBC; 88 89 ReplaceText; 90 91 SaveDBC; 77 92 78 93 // Stop program loop … … 105 120 WriteLn(' -c --coltypedef DBC column type definition string (u - uint32, s - string)'); 106 121 WriteLn(' -d --display Display DBC data'); 122 WriteLn(' -q --sql_query SQL select when entry is ID first column in dbc file and text0,text1... is texts columns'); 123 // SELECT T.entry as entry,T.Text as text0 FROM (SELECT * FROM gametips WHERE (Complete = 1) AND ((Language = 1)) AND (User IN (459,670,602,462,1,400,638,592,624,610,769,331,131,704,2,499,641,660,578,337,304,277,208,613,768,754,590,606,26,618,739,503,601,607,585,596,765,320,547,687)) AND VersionStart <= 9947 AND VersionEnd >= 9947) AS T GROUP BY T.entry 107 124 end; 108 125 … … 111 128 X, Y: Integer; 112 129 Text: string; 113 I: Integer; 114 begin 115 DBC := TDBC.Create; 116 with DBC do begin 117 if FileExists(DBCFileName) then begin 118 LoadFromFile(DBCFileName); 119 120 // Load strings for string columns 121 for I := 1 to Length(ColumnTypeDefinition) do 122 if ColumnTypeDefinition[I] = 's' then 123 LoadColumnStrings(I - 1); 124 130 begin 131 with DBC do begin 125 132 // Display DBC data 126 133 if DisplayData then … … 132 139 WriteLn(Text); 133 140 end; 134 135 SaveToFile(NewDBCFileName); 141 end; 142 end; 143 144 procedure TDBCExport.LoadDBC; 145 var 146 I: Integer; 147 begin 148 DBC := TDBC.Create; 149 with DBC do begin 150 if FileExists(DBCFileName) then begin 151 LoadFromFile(DBCFileName); 152 153 // Load strings for string columns 154 for I := 1 to Length(ColumnTypeDefinition) do 155 if ColumnTypeDefinition[I] = 's' then 156 LoadColumnStrings(I - 1); 157 136 158 end else WriteLn('File ' + DBCFileName + ' not exists.'); 159 end; 160 end; 161 162 procedure TDBCExport.SaveDBC; 163 begin 164 with DBC do begin 165 SaveToFile(NewDBCFileName); 137 166 Free; 138 167 end; 168 end; 169 170 171 //function get data from database and replace text in dbc 172 procedure TDBCExport.ReplaceText; 173 var 174 DBRows : TDbRows; 175 Text: String; 176 X, Y, I: Integer; 177 IndexRowData: Integer; 178 begin 179 with DBC do begin 180 if (SQLquery <> '') then begin; 181 Database.Connect; 182 DBRows := Database.Query(SQLquery); 183 184 185 for Y := 0 to Length(DBC.Cells) - 1 do begin 186 if (Y = 129) then 187 IndexRowData:= GetIDbyEntry(Cells[Y,0],DBRows); 188 IndexRowData:= GetIDbyEntry(Cells[Y,0],DBRows); 189 I := 0; 190 if (IndexRowData <> -1) then begin 191 for X := 0 to Length(ColumnTypeDefinition)-1 do begin 192 if ColumnTypeDefinition[X+1] = 's' then begin 193 Text:=DBRows.Data[IndexRowData].Values['text'+IntToStr(I)]; 194 SetString(Y,X,Text); 195 I:=I+1; 196 end; 197 end; 198 DBRows.Delete(IndexRowData); 199 end; 200 end; 201 202 203 204 end; 205 end; 206 end; 207 208 function TDBCExport.GetIDbyEntry(entry: integer; var DBRows: TDBRows): integer; 209 var 210 i: integer; 211 Count: integer; 212 begin 213 try 214 Count:=DBRows.Count; 215 for i:=0 to DBRows.Count - 1 do begin 216 if (StrToInt(DBRows.Data[i].Values['entry']) = entry) then begin 217 Result := i; 218 exit; 219 end; 220 end; 221 except 222 end; 223 Result := -1; 139 224 end; 140 225 -
tools/dbc_export/UDBC.pas
r337 r340 30 30 procedure LoadColumnStrings(Column: Integer); 31 31 procedure SaveToFile(FileName: string); 32 procedure SetString(Row, Column: Integer; Text: AnsiString); 32 33 end; 33 34 … … 121 122 end; 122 123 124 procedure TDBC.SetString(Row, Column: Integer; Text: AnsiString); 125 begin 126 if VarIsStr(Cells[Row,Column]) then begin 127 StringBlockSize := StringBlockSize + strlen(Pchar(Text)) - strlen(Pchar(VarToStr(Cells[Row,Column]))); 128 Cells[Row,Column] := Text; 129 end; 130 end; 131 123 132 function TDBC.DetectColumnType(Column: Integer): TDBCColumnType; 124 133 //var
Note:
See TracChangeset
for help on using the changeset viewer.