This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 98
/
code-export-song.lua
181 lines (125 loc) · 4.27 KB
/
code-export-song.lua
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
function MusicTool:OnExportSong(songID, showWarning)
songID = songID or self.currentSongID
-- local workspacePath = NewWorkspacePath(rootDirectory).AppendDirectory("Wavs").AppendDirectory("Songs")
if(showWarning == true) then
local workspacePath = NewWorkspacePath(self.rootDirectory).AppendDirectory("Wavs").AppendDirectory("Songs")
local buttons =
{
{
name = "modalyesbutton",
action = function(target)
gameEditor:ExportSong(self.rootDirectory, songID)
target.onParentClose()
end,
key = Keys.Enter,
tooltip = "Press 'enter' to export the song"
},
{
name = "modalnobutton",
action = function(target)
target.onParentClose()
end,
key = Keys.Escape,
tooltip = "Press 'esc' to cancel"
}
}
pixelVisionOS:ShowMessageModal("Export Song", "Do you want to export this song to '"..workspacePath.Path.."'?", 200, buttons)
else
gameEditor:ExportSong(self.rootDirectory, songID)
end
end
function MusicTool:OnExportAllSongs()
local workspacePath = NewWorkspacePath(self.rootDirectory).AppendDirectory("Wavs").AppendDirectory("Songs")
local buttons =
{
{
name = "modalyesbutton",
action = function(target)
-- self.installing = true
self.installingTime = 0
self.installingDelay = .1
self.installingCounter = 0
self.installingTotal = songIDStepper.inputField.max
installRoot = rootPath
target.onParentClose()
print("Trigger Export")
pixelVisionOS:RegisterUI({name = "UpdateExportLoop"}, "UpdateExport", self)
end,
key = Keys.Enter,
tooltip = "Press 'enter' to export all songs"
},
{
name = "modalnobutton",
action = function(target)
target.onParentClose()
end,
key = Keys.Escape,
tooltip = "Press 'esc' to cancel"
}
}
pixelVisionOS:ShowMessageModal("Export All Songs", "Do you want to export all of the songs to '"..workspacePath.Path.."'?", 200, buttons)
end
function MusicTool:OnInstallNextStep()
-- print("Next step")
-- Look to see if the modal exists
if(self.installingModal == nil) then
-- Create the model
self.installingModal = ProgressModal:Init("Exporting", editorUI)
-- Open the modal
pixelVisionOS:OpenModal(self.installingModal)
end
OnExportSong(self.installingCounter, false)
self.installingCounter = self.installingCounter + 1
local message = "Exporting song "..string.lpad(tostring(self.installingCounter), string.len(tostring(self.installingTotal)), "0") .. " of " .. self.installingTotal .. ".\n\n\n\nDo not restart or shut down Pixel Vision 8."
local percent = (self.installingCounter / self.installingTotal)
self.installingModal:UpdateMessage(message, percent)
if(self.installingCounter >= self.installingTotal) then
self.installingDelay = .5
end
end
function MusicTool:OnInstallComplete()
pixelVisionOS:RemoveUI("UpdateExportLoop")
pixelVisionOS:CloseModal()
end
function MusicTool:OnResetConfig()
local buttons =
{
{
name = "modalyesbutton",
action = function(target)
-- Save changes
gameEditor.pcgDensity = 5
gameEditor.pcgFunk = 5
gameEditor.pcgLayering = 5
gameEditor.pcgMinTempo = 50
gameEditor.pcgMaxTempo = 120
gameEditor.scale = 1
disablePreview = true
configModal:OnResetConfig()
end,
key = Keys.Enter,
tooltip = "Press 'enter' to quit the tool"
},
{
name = "modalnobutton",
action = function(target)
target.onParentClose()
end,
key = Keys.Escape,
tooltip = "Press 'esc' to cancel"
}
}
pixelVisionOS:ShowMessageModal("Reset Music Generator", "Do you want to restore the music generator to its default values?", 160, buttons)
end
-- TODO this needs to be wired up
function MusicTool:UpdateExport()
print("Update Export")
self.installingTime = self.installingTime + editorUI.timeDelta
if(self.installingTime > self.installingDelay) then
self.installingTime = 0
self:OnInstallNextStep()
if(self.installingCounter >= self.installingTotal) then
self:OnInstallComplete()
end
end
end