First commit

This commit is contained in:
Crom (Thibaut CHARLES) 2014-11-16 23:48:56 +01:00
commit 99291fe235
37 changed files with 151 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.dub/
dub.selections.json
2daedit*

9
dub.json Normal file
View File

@ -0,0 +1,9 @@
{
"name": "2daedit",
"description": "A minimal D application.",
"copyright": "Copyright © 2014, Administrateur",
"authors": ["Administrateur"],
"dependencies": {
"gtk-d": ">=2.4.1"
}
}

BIN
libatk-1.0-0.dll Normal file

Binary file not shown.

BIN
libcairo-2.dll Normal file

Binary file not shown.

BIN
libcairo-gobject-2.dll Normal file

Binary file not shown.

Binary file not shown.

BIN
libcroco-0.6-3.dll Normal file

Binary file not shown.

BIN
libffi-6.dll Normal file

Binary file not shown.

BIN
libfontconfig-1.dll Normal file

Binary file not shown.

BIN
libfreetype-6.dll Normal file

Binary file not shown.

BIN
libgailutil-3-0.dll Normal file

Binary file not shown.

BIN
libgdk-3-0.dll Normal file

Binary file not shown.

BIN
libgdk_pixbuf-2.0-0.dll Normal file

Binary file not shown.

BIN
libgio-2.0-0.dll Normal file

Binary file not shown.

BIN
libglib-2.0-0.dll Normal file

Binary file not shown.

BIN
libgmodule-2.0-0.dll Normal file

Binary file not shown.

BIN
libgobject-2.0-0.dll Normal file

Binary file not shown.

BIN
libgthread-2.0-0.dll Normal file

Binary file not shown.

BIN
libgtk-3-0.dll Normal file

Binary file not shown.

BIN
libiconv-2.dll Normal file

Binary file not shown.

BIN
libintl-8.dll Normal file

Binary file not shown.

BIN
libjasper-1.dll Normal file

Binary file not shown.

BIN
libjpeg-9.dll Normal file

Binary file not shown.

BIN
liblzma-5.dll Normal file

Binary file not shown.

BIN
libpango-1.0-0.dll Normal file

Binary file not shown.

BIN
libpangocairo-1.0-0.dll Normal file

Binary file not shown.

BIN
libpangoft2-1.0-0.dll Normal file

Binary file not shown.

BIN
libpangowin32-1.0-0.dll Normal file

Binary file not shown.

BIN
libpixman-1-0.dll Normal file

Binary file not shown.

BIN
libpng15-15.dll Normal file

Binary file not shown.

BIN
librsvg-2-2.dll Normal file

Binary file not shown.

BIN
libtiff-5.dll Normal file

Binary file not shown.

BIN
libxml2-2.dll Normal file

Binary file not shown.

BIN
pthreadGC2.dll Normal file

Binary file not shown.

135
source/app.d Normal file
View File

@ -0,0 +1,135 @@
import std.stdio;
import std.string;
import std.conv : to;
import gtk.Main;
import gtk.MainWindow;
import gtk.TreeView;
import gtk.ListStore;
import gtk.TreeViewColumn;
import gtk.TreeIter;
import gtk.Label;
import gtk.Entry;
import gtk.CellRenderer;
import gtk.CellRendererText;
import gtk.CellRendererSpin;
void[] Serialize(VT...)(VT data){
void[] ret;
foreach(d ; data){
ret~=cast(void[])([d]);
}
return ret;
}
void main(string[] args)
{
auto twoda = new TwoDA("test.2da");
Main.init(args);
auto window = new MainWindow("Test");
auto store = new ListStore([GType.STRING,GType.STRING,GType.STRING]);
auto tree = new TreeView(store);
window.add(tree);
tree.setHeadersVisible(true);
tree.setEnableSearch(true);
tree.setModel(store);
foreach(index, s ; twoda.header){
CellRenderer cr;
writeln(index);
if(index==0){
cr = new CellRendererSpinner();
cr.setProperty("pulse", 1);
cr.setProperty("active", true);
}
else{
cr = new CellRendererText();
cr.setProperty("editable", true);
}
//cr.setSensitive(true);
auto col = new TreeViewColumn(s, cr, "text", index);
col.setResizable(true);
//if(index!=0) col.setReorderable(true);
tree.appendColumn(col);
}
TreeIter iter = store.createIter();
for(int i=0 ; i<=twoda.lastLine ; i++){
store.setValue(iter, 0, i);
if(i in twoda.values){
foreach(index, v ; twoda.values[i]){
store.setValue(iter, index+1, v);
}
}
else{
foreach(index ; 1..twoda.header.length){
store.setValue(iter, index+1, "_");
}
}
store.append(iter);
}
tree.columnsAutosize();
window.showAll();
Main.run();
}
class TwoDA{
import std.regex;
import std.file;
this(string filepath){
lastLine = 0;
foreach(index, line ; readText(filepath).splitLines()){
string data[];
auto results = matchAll(line, rgxField);
foreach(res ; results){
string s;
if(res[0][0]=='"') data~= res[2];
else data~= res[1];
}
if(index==0){
header = data;
//writeln(header);
}
else{
int nLine = data[0].to!int;
values[nLine] = data[1..$];
//writeln(values[nLine]);
if(nLine > lastLine)
lastLine = nLine;
}
}
}
string[] header;
string[][uint] values;
uint lastLine;
enum rgxField = ctRegex!"(?:\\b([^\\s]+?)\\b|\"([^\"]+?)\")";
}

4
test.2da Normal file
View File

@ -0,0 +1,4 @@
id name value
0 test testvalue0
1 test1 testvalue1
2 "Test Multiword" "Ddeedz fdes s fesq qs g sfddtrs"

BIN
zlib1.dll Normal file

Binary file not shown.