+ open files from CommandLine

git-svn-id: svn://kolibrios.org@8849 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2021-06-14 09:57:21 +00:00
parent eedf06ce2b
commit 0d1191b0fa

View File

@ -368,6 +368,36 @@ void __stdcall DrawWindow()
} }
} }
bool OpenModel(char* f_path)
{
FileInfoBlock* file;
unsigned long int k;
file = FileOpen(f_path);
if (!file){
SetWindowCaption("Error open file ...");
return false;
}
k = FileGetLength(file);
if (k > 0){
if(f_data) delete f_data;
f_data = new unsigned char[k];
if (f_data){
if (FileRead(file, f_data, k) != k){
delete f_data; f_data = 0;
}
else{
init_model();
draw_3d();
SetWindowCaption(ofd.openfile_path);
Redraw(1);
}
}
}
FileClose(file);
return (bool)f_data;
}
bool KolibriOnStart(TStartData &kos_start, TThreadData /*th*/) bool KolibriOnStart(TStartData &kos_start, TThreadData /*th*/)
{ {
kos_start.Left = 10; kos_start.Left = 10;
@ -408,8 +438,12 @@ bool KolibriOnStart(TStartData &kos_start, TThreadData /*th*/)
glClearColor(0.2,0.2,0.2,0.0); glClearColor(0.2,0.2,0.2,0.0);
glEnable(GL_NORMALIZE); glEnable(GL_NORMALIZE);
//draw_3d(); //draw_3d();
return init_block(); if(init_block()){
} else return false; if(CommandLine[0]) OpenModel(CommandLine);
return true;
}
}
return false;
} }
void KolibriOnPaint(void) void KolibriOnPaint(void)
@ -423,37 +457,11 @@ void KolibriOnPaint(void)
void KolibriOnButton(long id, TThreadData /*th*/) void KolibriOnButton(long id, TThreadData /*th*/)
{ {
FileInfoBlock* file;
unsigned long int k;
switch(id){ switch(id){
case 2: case 2:
ofd.type = 0; // 0 - open ofd.type = 0; // 0 - open
OpenDialog_Start(&ofd); OpenDialog_Start(&ofd);
if(ofd.status==1){ if(ofd.status==1) OpenModel(ofd.openfile_path);
file = FileOpen(ofd.openfile_path);
if (!file){
SetWindowCaption("Error open file ...");
break;
}
k = FileGetLength(file);
if (k > 0){
if(f_data) delete f_data;
f_data = new unsigned char[k];
if (f_data){
if (FileRead(file, f_data, k) != k){
delete f_data; f_data = 0;
}
else{
init_model();
draw_3d();
SetWindowCaption(ofd.openfile_path);
Redraw(1);
}
}
}
FileClose(file);
}
//break; //break;
}; };
} }