Rev 8184 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8184 | Rev 8252 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include |
1 | #include |
2 | #include |
2 | #include |
3 | #include |
3 | #include |
- | 4 | #include |
|
- | 5 | #include |
|
4 | #include "lifegen.h" |
6 | #include "lifegen.h" |
5 | #include "life_bmp.h" |
7 | #include "life_bmp.h" |
6 | #include "kos_cdlg.h" |
- | |
Line 7... | Line 8... | ||
7 | 8 | ||
Line 8... | Line -... | ||
8 | using namespace Kolibri; |
- | |
9 | - | ||
10 | /*** |
- | |
11 | #define StrLen LibbStrLen |
- | |
12 | #define StrCopy LibbStrCopy |
- | |
13 | #define MemCopy LibbMemCopy |
9 | using namespace Kolibri; |
14 | #define MemSet LibbMemSet |
10 | |
15 | #define Floor LibbFloor |
11 | char library_path[2048]; |
16 | 12 | ||
17 | unsigned int (*StrLen)(const char *str) = 0; |
- | |
18 | char *(*StrCopy)(char *dest, const char *src) = 0; |
13 | OpenDialog_data ofd; |
19 | void *(*MemCopy)(void *dest, const void *src, unsigned int n) = 0; |
14 | unsigned char procinfo[1024]; |
20 | void *(*MemSet)(void *s, char c, unsigned int n) = 0; |
15 | char plugin_path[4096], filename_area[256]; |
21 | double (*Floor)(double x) = 0; |
16 | od_filter filter1 = { 8, "LIF\0\0" }; |
22 | - | ||
23 | void LibbInit() |
- | |
24 | { |
- | |
25 | HINSTANCE hLib = LoadLibrary("Libb.dll"); |
- | |
26 | if (!hLib) |
17 | |
27 | { |
- | |
28 | DebugPutString("Can't load the library.\n"); |
- | |
29 | Kolibri::Abort(); |
- | |
30 | } |
- | |
31 | StrLen = (unsigned int(*)(const char *str))GetProcAddress(hLib, "StrLen"); |
- | |
32 | StrCopy = (char *(*)(char *dest, const char *src))GetProcAddress(hLib, "StrCopy"); |
- | |
33 | MemCopy = (void *(*)(void *dest, const void *src, unsigned int n))GetProcAddress(hLib, "MemCopy"); |
- | |
34 | MemSet = (void *(*)(void *s, char c, unsigned int n))GetProcAddress(hLib, "MemSet"); |
18 | namespace Kolibri{ |
Line 35... | Line 19... | ||
35 | Floor = (double (*)(double x))GetProcAddress(hLib, "Floor"); |
19 | char CurrentDirectoryPath[2048]; |
- | 20 | } |
|
36 | } |
21 | |
- | 22 | void __stdcall DrawWindow() |
|
- | 23 | { |
|
- | 24 | asm{ |
|
- | 25 | push ebx |
|
- | 26 | mcall SF_REDRAW,SSF_BEGIN_DRAW |
|
- | 27 | } |
|
- | 28 | //KolibriOnPaint(); |
|
- | 29 | asm{ |
|
- | 30 | mcall SF_REDRAW,SSF_END_DRAW |
|
Line 37... | Line 31... | ||
37 | 31 | pop ebx |
|
Line 38... | Line 32... | ||
38 | #pragma startup LibbInit |
32 | } |
39 | /**/ |
33 | } |
Line 105... | Line 99... | ||
105 | GenerateParam generate = {0, 0, 0, 0, false, PaintWNull, 0}; |
99 | GenerateParam generate = {0, 0, 0, 0, false, PaintWNull, 0}; |
106 | AxisParam xpar = {0, 0, 0}; |
100 | AxisParam xpar = {0, 0, 0}; |
107 | AxisParam ypar = {0, 0, 0}; |
101 | AxisParam ypar = {0, 0, 0}; |
108 | MouseParam mpar = {0, 0, 0, 0, 0, MouseParam::HitNull}; |
102 | MouseParam mpar = {0, 0, 0, 0, 0, MouseParam::HitNull}; |
109 | MenuParam menu; |
103 | MenuParam menu; |
110 | TOpenFileStruct open_file_str = KOLIBRI_OPEN_FILE_INIT; |
104 | bool open_file_str = false; |
111 | TimeGeneration timegen[TimeGenLength]; |
105 | TimeGeneration timegen[TimeGenLength]; |
112 | int timegenpos = 0; |
106 | int timegenpos = 0; |
Line 113... | Line 107... | ||
113 | 107 | ||
Line 1354... | Line 1348... | ||
1354 | Paint(PaintWNull, th); |
1348 | Paint(PaintWNull, th); |
1355 | } |
1349 | } |
Line 1356... | Line 1350... | ||
1356 | 1350 | ||
1357 | void MenuOpenDialogEnd(TThreadData th) |
1351 | void MenuOpenDialogEnd(TThreadData th) |
1358 | { |
1352 | { |
1359 | int state = OpenFileGetState(open_file_str); |
- | |
1360 | if (state <= 0) return; |
1353 | if(!ofd.openfile_path[0] || !open_file_str) return; |
1361 | OpenFileSetState(open_file_str, 0); |
- | |
1362 | if (state != 2) return; |
1354 | open_file_str = false; |
1363 | char *name = OpenFileGetName(open_file_str); |
1355 | char *name = ofd.openfile_path; |
1364 | if (!name) return; |
1356 | if (!name) return; |
1365 | FileInfoBlock* file = FileOpen(name); |
1357 | FileInfoBlock* file = FileOpen(name); |
1366 | if (!file) return; |
1358 | if (!file) return; |
1367 | int k = FileGetLength(file); |
1359 | int k = FileGetLength(file); |
Line 1465... | Line 1457... | ||
1465 | break; |
1457 | break; |
1466 | case MenuIClear: |
1458 | case MenuIClear: |
1467 | MenuClearClick(th); |
1459 | MenuClearClick(th); |
1468 | break; |
1460 | break; |
1469 | case MenuIOpen: |
1461 | case MenuIOpen: |
- | 1462 | ofd.type = 0; // 0 - open |
|
1470 | if (OpenFileGetState(open_file_str) < 0) break; |
1463 | OpenDialog_Start(&ofd); |
1471 | OpenFileDialog(open_file_str); |
1464 | if(ofd.status==1) open_file_str = true; |
1472 | break; |
1465 | break; |
1473 | case MenuIAbout: |
1466 | case MenuIAbout: |
1474 | MenuAboutClick(th); |
1467 | MenuAboutClick(th); |
1475 | break; |
1468 | break; |
1476 | case MenuIExit: |
1469 | case MenuIExit: |
Line 1704... | Line 1697... | ||
1704 | randomize(); |
1697 | randomize(); |
1705 | me_start.WinData.Title = "Black and white Life"; |
1698 | me_start.WinData.Title = "Black and white Life"; |
1706 | me_start.Width = 500; me_start.Height = 400; |
1699 | me_start.Width = 500; me_start.Height = 400; |
1707 | InitGenerate(); |
1700 | InitGenerate(); |
1708 | InitMenuButton(); |
1701 | InitMenuButton(); |
1709 | if (CommandLine[0]) |
1702 | if(LoadLibrary("proc_lib.obj", library_path, "/sys/lib/proc_lib.obj", &import_proc_lib)) |
1710 | { |
1703 | { |
- | 1704 | ofd.procinfo = procinfo; |
|
- | 1705 | ofd.com_area_name = "FFFFFFFF_open_dialog"; |
|
- | 1706 | ofd.com_area = 0; |
|
- | 1707 | ofd.opendir_path = plugin_path; |
|
- | 1708 | ofd.dir_default_path = "/rd/1"; |
|
- | 1709 | ofd.start_path = "/rd/1/File managers/opendial"; |
|
- | 1710 | ofd.draw_window = DrawWindow; |
|
1711 | open_file_str.state = 2; |
1711 | ofd.status = 0; |
1712 | OpenFileSetName(open_file_str, CommandLine); |
1712 | ofd.openfile_path = CommandLine; |
- | 1713 | ofd.filename_area = filename_area; |
|
- | 1714 | ofd.filter_area = &filter1; |
|
- | 1715 | ofd.x_size = 420; |
|
- | 1716 | ofd.x_start = 10; |
|
- | 1717 | ofd.y_size = 320; |
|
- | 1718 | ofd.y_start = 10; |
|
- | 1719 | OpenDialog_Init(&ofd); |
|
1713 | } |
1720 | } else return false; |
- | 1721 | if (CommandLine[0]) open_file_str = true; |
|
1714 | return true; |
1722 | return true; |
1715 | } |
1723 | } |
Line 1716... | Line 1724... | ||
1716 | 1724 | ||
1717 | bool KolibriOnClose(TThreadData) |
1725 | bool KolibriOnClose(TThreadData) |
Line 1723... | Line 1731... | ||
1723 | 1731 | ||
1724 | int KolibriOnIdle(TThreadData th) |
1732 | int KolibriOnIdle(TThreadData th) |
1725 | { |
1733 | { |
1726 | static const unsigned int WAIT_TIME = 2, GEN_TIME = 1; |
1734 | static const unsigned int WAIT_TIME = 2, GEN_TIME = 1; |
1727 | int res = -1; |
1735 | int res = -1; |
1728 | if (OpenFileGetState(open_file_str) > 0) |
1736 | if (open_file_str) |
1729 | { |
1737 | { |
1730 | MenuOpenDialogEnd(th); |
1738 | MenuOpenDialogEnd(th); |
1731 | res = 0; |
1739 | res = 0; |
1732 | } |
1740 | } |
Line 1824... | Line 1832... | ||
1824 | case 'C': |
1832 | case 'C': |
1825 | MenuClearClick(th); |
1833 | MenuClearClick(th); |
1826 | break; |
1834 | break; |
1827 | case 'o': |
1835 | case 'o': |
1828 | case 'O': |
1836 | case 'O': |
- | 1837 | ofd.type = 0; // 0 - open |
|
1829 | if (OpenFileGetState(open_file_str) < 0) break; |
1838 | OpenDialog_Start(&ofd); |
1830 | OpenFileDialog(open_file_str); |
1839 | if(ofd.status==1) open_file_str=true; |
1831 | break; |
1840 | break; |
1832 | case 'a': |
1841 | case 'a': |
1833 | case 'A': |
1842 | case 'A': |
1834 | MenuAboutClick(th); |
1843 | MenuAboutClick(th); |
1835 | break; |
1844 | break; |