summaryrefslogtreecommitdiff
path: root/dalos-cd.lua
blob: fc1ae3d01e7f1e75878fae52daef6d4b664d9b3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
loadmodule "luacd"

dalosp.cd = {   
    get_settings = function (self)
        return { filename = self.extra.filename }
    end,
    
    configure = function (self)
        local drives_list = self.extra.drives_list
        local list = ""
        for i, v in ipairs(drives_list) do
            list = list .. v .. "|"
        end
        local s, id = iup.GetParam("CD drive", nil, "CD drive: %l|" .. list .. "\n", 0)

        if s then
            self.extra.filename = "cd:" .. drives_list[id + 1]
            local s, v = pcall(cdabstract, self.extra.filename)
            if s then
                self:set_houtput(v)
                return
            end
        end
        self:set_houtput(nil)
    end,
    
    create = function (d, tab, settings)
        tab.ninputs = 0
        tab.noutputs = 1
        tab.otype = dalos.objtype.HANDLE
        tab.configure = dalosp.cd.configure
        tab.default_name = "CD"
        tab.ntype = "CD"
        tab.get_settings = dalosp.cd.get_settings
        local extra = { drives_list = cdprobe() }
        if settings then extra.filename = settings.filename end
        local obj = dalos.object(d, tab, extra)

        if extra.filename then
            local s, v = pcall(cdabstract, extra.filename)
            if s then obj:set_houtput(v) end
        end
        
        return obj
    end,
}

dalos.cd = dalosp.cd.create
dalos:register_obj("CD", dalos.cd, "Basic Inputs")

dalosp.dvd = {   
    get_settings = function (self)
        return { filename = self.extra.filename }
    end,
    
    configure = function (self)
        local dlg = iup.filedlg {
            dialogtype = "Open",
            file = self.extra.filename,
        }
        iup.Popup(dlg)
        if dlg.status ~= -1 then
            local s, v = pcall(dvdabstract, dlg.value)
            if s then
                self:set_houtput(v)
                return
            end
        end
        self:set_houtput(nil)
    end,
    
    create = function (d, tab, settings)
        tab.ninputs = 0
        tab.noutputs = 1
        tab.otype = dalos.objtype.HANDLE
        tab.configure = dalosp.dvd.configure
        tab.default_name = "DVD"
        tab.ntype = "DVD"
        tab.get_settings = dalosp.dvd.get_settings
        local extra = { drives_list = cdprobe() }
        if settings then extra.filename = settings.filename end
        local obj = dalos.object(d, tab, extra)

        if extra.filename then
            local s, v = pcall(cdabstract, extra.filename)
            if s then obj:set_houtput(v) end
        end
        
        return obj
    end,
}

dalos.dvd = dalosp.dvd.create
dalos:register_obj("DVD", dalos.dvd, "Basic Inputs")