| | 21 | end |
| | 22 | |
| | 23 | -- Parses a string that describes a video mode. It returns the width, height, colour depth and refresh rate. |
| | 24 | function ParseModeStr(ModeStr) |
| | 25 | -- For case-insensitive matching, translate the entire string to lower case. |
| | 26 | ModeStr=ModeStr:lower(); |
| | 27 | |
| | 28 | local width, height=ModeStr:match("(%d+)%s*x%s*(%d+)"); |
| | 29 | local bpp =ModeStr:match("(%d+)%s*bpp"); |
| | 30 | local rate =ModeStr:match("(%d+)%s*hz"); |
| | 31 | |
| | 32 | if width then width =tonumber(width); end |
| | 33 | if height then height=tonumber(height); end |
| | 34 | if bpp then bpp =tonumber(bpp); end |
| | 35 | if rate then rate =tonumber(rate); end |
| | 36 | |
| | 37 | return width, height, bpp, rate; |
| 1162 | | VideoOptionsDialog.Frame.ScreenResChoice:Append(" 640 x 480"); |
| 1163 | | VideoOptionsDialog.Frame.ScreenResChoice:Append(" 800 x 600"); |
| 1164 | | VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1024 x 768"); |
| 1165 | | VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1152 x 864"); |
| 1166 | | VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1280 x 1024"); |
| 1167 | | VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1600 x 1200"); |
| 1168 | | VideoOptionsDialog.Frame.ScreenResChoice:SetSelection(2); -- Set again when the dialog is shown. |
| | 1184 | |
| | 1185 | -- For each video mode in console variable "VideoModes" (a multi-line string with one |
| | 1186 | -- video mode per line, separated by new-lines), append a choice to the choice window. |
| | 1187 | for ModeStr in ci.GetValue("VideoModes"):gmatch("[^\n]+") do |
| | 1188 | VideoOptionsDialog.Frame.ScreenResChoice:Append(" "..ModeStr); |
| | 1189 | end |
| | 1190 | |
| | 1191 | -- It is possible (though normally not necessary) to add custom video modes here, |
| | 1192 | -- for example when your favorite video mode is not automatically detected and provided above. |
| | 1193 | -- There is no guarantee though that the graphics driver can set any custom modes |
| | 1194 | -- (or else the mode had been automatically included in the enumeration above). |
| | 1195 | -- Examples: |
| | 1196 | -- VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1152 x 864"); |
| | 1197 | -- VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1440 x 900, 32 bpp, 60 Hz"); |
| | 1198 | |
| | 1199 | -- The list of video modes above should never be totally empty, |
| | 1200 | -- but still just handle the case here to be totally sure. |
| | 1201 | if (VideoOptionsDialog.Frame.ScreenResChoice:GetNumChoices()==0) then |
| | 1202 | Console.Warning("Console variable VideoModes is empty!\n"); |
| | 1203 | |
| | 1204 | VideoOptionsDialog.Frame.ScreenResChoice:Append(" 640 x 480"); |
| | 1205 | VideoOptionsDialog.Frame.ScreenResChoice:Append(" 800 x 600"); |
| | 1206 | VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1024 x 768"); |
| | 1207 | end |
| | 1208 | |
| | 1209 | VideoOptionsDialog.Frame.ScreenResChoice:SetSelection(0); -- Set again when the dialog is shown. |
| 1217 | | local ResX, ResY=ModeStr:match("(%d+)%s*x%s*(%d+)"); |
| 1218 | | |
| 1219 | | ci.SetValue("dlg_clWindowSizeX", ResX); |
| 1220 | | ci.SetValue("dlg_clWindowSizeY", ResY); |
| | 1258 | local width, height, bpp, rate=ParseModeStr(ModeStr); |
| | 1259 | |
| | 1260 | if width then ci.SetValue("dlg_clWindowSizeX", width ); end |
| | 1261 | if height then ci.SetValue("dlg_clWindowSizeY", height); end |
| | 1262 | if bpp then ci.SetValue("dlg_clDisplayBPP", bpp ); end |
| | 1263 | if rate then ci.SetValue("dlg_clDisplayRefresh", rate ); end |
| | 1264 | |